#include "third_party/blink/renderer/core/page/context_menu_controller.h"
#include <memory>
#include <utility>
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_functions.h"
#include "base/ranges/algorithm.h"
#include "components/shared_highlighting/core/common/shared_highlighting_features.h"
#include "third_party/blink/public/common/context_menu_data/context_menu_data.h"
#include "third_party/blink/public/common/context_menu_data/edit_flags.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/input/web_menu_source_type.h"
#include "third_party/blink/public/common/navigation/impression.h"
#include "third_party/blink/public/mojom/context_menu/context_menu.mojom-blink.h"
#include "third_party/blink/public/web/web_local_frame_client.h"
#include "third_party/blink/public/web/web_plugin.h"
#include "third_party/blink/public/web/web_text_check_client.h"
#include "third_party/blink/renderer/core/annotation/annotation_agent_container_impl.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/element_traversal.h"
#include "third_party/blink/renderer/core/dom/events/event_target.h"
#include "third_party/blink/renderer/core/dom/node.h"
#include "third_party/blink/renderer/core/editing/editing_tri_state.h"
#include "third_party/blink/renderer/core/editing/editing_utilities.h"
#include "third_party/blink/renderer/core/editing/editor.h"
#include "third_party/blink/renderer/core/editing/ephemeral_range.h"
#include "third_party/blink/renderer/core/editing/frame_selection.h"
#include "third_party/blink/renderer/core/editing/ime/input_method_controller.h"
#include "third_party/blink/renderer/core/editing/markers/document_marker.h"
#include "third_party/blink/renderer/core/editing/markers/document_marker_controller.h"
#include "third_party/blink/renderer/core/editing/selection_controller.h"
#include "third_party/blink/renderer/core/editing/spellcheck/spell_checker.h"
#include "third_party/blink/renderer/core/events/mouse_event.h"
#include "third_party/blink/renderer/core/execution_context/agent.h"
#include "third_party/blink/renderer/core/exported/web_plugin_container_impl.h"
#include "third_party/blink/renderer/core/fragment_directive/text_fragment_handler.h"
#include "third_party/blink/renderer/core/frame/attribution_src_loader.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/picture_in_picture_controller.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/frame/web_frame_widget_impl.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/html/canvas/html_canvas_element.h"
#include "third_party/blink/renderer/core/html/forms/html_form_element.h"
#include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html/html_anchor_element.h"
#include "third_party/blink/renderer/core/html/html_document.h"
#include "third_party/blink/renderer/core/html/html_embed_element.h"
#include "third_party/blink/renderer/core/html/html_frame_element_base.h"
#include "third_party/blink/renderer/core/html/html_image_element.h"
#include "third_party/blink/renderer/core/html/html_object_element.h"
#include "third_party/blink/renderer/core/html/html_plugin_element.h"
#include "third_party/blink/renderer/core/html/media/html_audio_element.h"
#include "third_party/blink/renderer/core/html/media/html_media_element.h"
#include "third_party/blink/renderer/core/html/media/html_video_element.h"
#include "third_party/blink/renderer/core/input/context_menu_allowed_scope.h"
#include "third_party/blink/renderer/core/input/event_handler.h"
#include "third_party/blink/renderer/core/input_type_names.h"
#include "third_party/blink/renderer/core/layout/layout_embedded_content.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/page/context_menu_provider.h"
#include "third_party/blink/renderer/core/page/focus_controller.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/platform/bindings/script_regexp.h"
#include "third_party/blink/renderer/platform/exported/wrapped_resource_response.h"
namespace blink {
FormControlType;
namespace {
constexpr char kPasswordRe[] = …
"pass(?:word|code)|pas(?:word|code)|pswrd|psw|pswd|pwd|parole|watchword|"
"pasahitza|parol|lozinka|sifr|contrasenya|heslo|adgangskode|losen|"
"wachtwoord|paswoord|salasana|passe|contrasinal|passwort|jelszo|"
"sandi|signum|slaptazodis|kata|passord|haslo|senha|geslo|contrasena|"
"khau";
void SetPasswordManagerData(Element* element, ContextMenuData& data) { … }
void SetAutofillData(Node* node, ContextMenuData& data) { … }
bool UnvisitedNodeOrAncestorHasContextMenuListener(
Node* node,
HeapHashSet<Member<Node>>& already_visited_nodes) { … }
template <class enumType>
uint32_t EnumToBitmask(enumType outcome) { … }
}
ContextMenuController::ContextMenuController(Page* page) : … { … }
ContextMenuController::~ContextMenuController() = default;
void ContextMenuController::Trace(Visitor* visitor) const { … }
void ContextMenuController::ClearContextMenu() { … }
void ContextMenuController::DocumentDetached(Document* document) { … }
void ContextMenuController::HandleContextMenuEvent(MouseEvent* mouse_event) { … }
void ContextMenuController::ShowContextMenuAtPoint(
LocalFrame* frame,
float x,
float y,
ContextMenuProvider* menu_provider) { … }
void ContextMenuController::CustomContextMenuItemSelected(unsigned action) { … }
Node* ContextMenuController::GetContextMenuNodeWithImageContents() { … }
Node* ContextMenuController::ContextMenuImageNodeForFrame(LocalFrame* frame) { … }
Node* ContextMenuController::ContextMenuNodeForFrame(LocalFrame* frame) { … }
void ContextMenuController::CustomContextMenuAction(uint32_t action) { … }
void ContextMenuController::ContextMenuClosed(const KURL& link_followed) { … }
static int ComputeEditFlags(Document& selected_document, Editor& editor) { … }
static gfx::Rect ComputeSelectionRect(LocalFrame* selected_frame) { … }
bool ContextMenuController::ShouldShowContextMenuFromTouch(
const ContextMenuData& data) { … }
bool ContextMenuController::ShowContextMenu(LocalFrame* frame,
const PhysicalOffset& point,
WebMenuSourceType source_type,
const MouseEvent* mouse_event) { … }
}