#include "third_party/blink/renderer/core/editing/selection_controller.h"
#include "base/auto_reset.h"
#include "third_party/blink/public/common/input/web_menu_source_type.h"
#include "third_party/blink/public/platform/web_input_event_result.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/editing/bidi_adjustment.h"
#include "third_party/blink/renderer/core/editing/editing_behavior.h"
#include "third_party/blink/renderer/core/editing/editing_boundary.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/iterators/text_iterator.h"
#include "third_party/blink/renderer/core/editing/markers/document_marker_controller.h"
#include "third_party/blink/renderer/core/editing/selection_template.h"
#include "third_party/blink/renderer/core/editing/set_selection_options.h"
#include "third_party/blink/renderer/core/editing/spellcheck/spell_checker.h"
#include "third_party/blink/renderer/core/editing/suggestion/text_suggestion_controller.h"
#include "third_party/blink/renderer/core/editing/visible_position.h"
#include "third_party/blink/renderer/core/fragment_directive/text_fragment_handler.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/local_frame_client.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/input/event_handler.h"
#include "third_party/blink/renderer/core/layout/layout_view.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/runtime_enabled_features.h"
#include "ui/gfx/geometry/point_conversions.h"
namespace blink {
SelectionController::SelectionController(LocalFrame& frame)
: … { … }
void SelectionController::Trace(Visitor* visitor) const { … }
namespace {
DispatchEventResult DispatchSelectStart(Node* node) { … }
SelectionInFlatTree ExpandSelectionToRespectUserSelectAll(
Node* target_node,
const SelectionInFlatTree& selection) { … }
static int TextDistance(const PositionInFlatTree& start,
const PositionInFlatTree& end) { … }
bool CanMouseDownStartSelect(Node* node) { … }
PositionInFlatTreeWithAffinity PositionWithAffinityOfHitTestResult(
const HitTestResult& hit_test_result) { … }
DocumentMarkerGroup* SpellCheckMarkerGroupAtPosition(
DocumentMarkerController& document_marker_controller,
const PositionInFlatTree& position) { … }
void MarkSelectionEndpointsForRepaint(const SelectionInFlatTree& selection) { … }
bool IsNonSelectable(const Node* node) { … }
inline bool ShouldIgnoreNodeForCheckSelectable(const Node* enclosing_block,
const Node* node) { … }
}
SelectionInFlatTree AdjustSelectionWithTrailingWhitespace(
const SelectionInFlatTree& selection) { … }
SelectionInFlatTree AdjustSelectionByUserSelect(
Node* anchor_node,
const SelectionInFlatTree& selection) { … }
SelectionController::~SelectionController() = default;
Document& SelectionController::GetDocument() const { … }
void SelectionController::ContextDestroyed() { … }
static PositionInFlatTreeWithAffinity AdjustPositionRespectUserSelectAll(
Node* inner_node,
const PositionInFlatTree& selection_start,
const PositionInFlatTree& selection_end,
const PositionInFlatTreeWithAffinity& position) { … }
static PositionInFlatTree ComputeStartFromEndForExtendForward(
const PositionInFlatTree& end,
TextGranularity granularity) { … }
static SelectionInFlatTree ExtendSelectionAsDirectional(
const PositionInFlatTreeWithAffinity& position,
const SelectionInFlatTree& selection,
TextGranularity granularity) { … }
static SelectionInFlatTree ExtendSelectionAsNonDirectional(
const PositionInFlatTree& position,
const SelectionInFlatTree& selection,
TextGranularity granularity) { … }
bool SelectionController::HandleSingleClick(
const MouseEventWithHitTestResults& event) { … }
void SelectionController::HandleTapOnCaret(
const MouseEventWithHitTestResults& event,
const SelectionInFlatTree& selection) { … }
bool SelectionController::HandleTapInsideSelection(
const MouseEventWithHitTestResults& event,
const SelectionInFlatTree& selection) { … }
WebInputEventResult SelectionController::UpdateSelectionForMouseDrag(
const HitTestResult& hit_test_result,
const PhysicalOffset& last_known_mouse_position) { … }
bool SelectionController::UpdateSelectionForMouseDownDispatchingSelectStart(
Node* target_node,
const SelectionInFlatTree& selection,
const SetSelectionOptions& set_selection_options) { … }
bool SelectionController::SelectClosestWordFromHitTestResult(
const HitTestResult& result,
AppendTrailingWhitespace append_trailing_whitespace,
SelectInputEventType select_input_event_type) { … }
void SelectionController::SelectClosestMisspellingFromHitTestResult(
const HitTestResult& result,
AppendTrailingWhitespace append_trailing_whitespace) { … }
template <typename MouseEventObject>
bool SelectionController::SelectClosestWordFromMouseEvent(
const MouseEventObject* mouse_event,
const HitTestResult& result) { … }
template <typename MouseEventObject>
void SelectionController::SelectClosestMisspellingFromMouseEvent(
const MouseEventObject* mouse_event,
const HitTestResult& hit_test_result) { … }
template <typename MouseEventObject>
void SelectionController::SelectClosestWordOrLinkFromMouseEvent(
const MouseEventObject* mouse_event,
const HitTestResult& hit_test_result) { … }
void SelectionController::SetNonDirectionalSelectionIfNeeded(
const SelectionInFlatTree& new_selection,
const SetSelectionOptions& set_selection_options,
EndPointsAdjustmentMode endpoints_adjustment_mode) { … }
void SelectionController::SetCaretAtHitTestResult(
const HitTestResult& hit_test_result) { … }
bool SelectionController::HandleDoubleClick(
const MouseEventWithHitTestResults& event) { … }
bool SelectionController::HandleTripleClick(
const MouseEventWithHitTestResults& event) { … }
bool SelectionController::HandleMousePressEvent(
const MouseEventWithHitTestResults& event) { … }
WebInputEventResult SelectionController::HandleMouseDraggedEvent(
const MouseEventWithHitTestResults& event,
const gfx::Point& mouse_down_pos,
const PhysicalOffset& last_known_mouse_position) { … }
void SelectionController::UpdateSelectionForMouseDrag(
const PhysicalOffset& drag_start_pos_in_root_frame,
const PhysicalOffset& last_known_mouse_position_in_root_frame) { … }
bool SelectionController::HandleMouseReleaseEvent(
const MouseEventWithHitTestResults& event,
const PhysicalOffset& drag_start_pos) { … }
bool SelectionController::HandlePasteGlobalSelection(
const WebMouseEvent& mouse_event) { … }
bool SelectionController::HandleGestureLongPress(
const HitTestResult& hit_test_result) { … }
void SelectionController::HandleGestureTwoFingerTap(
const GestureEventWithHitTestResults& targeted_event) { … }
static bool HitTestResultIsMisspelled(const HitTestResult& result) { … }
template <typename MouseEventObject>
void SelectionController::UpdateSelectionForContextMenuEvent(
const MouseEventObject* mouse_event,
const HitTestResult& hit_test_result,
const PhysicalOffset& position) { … }
void SelectionController::PassMousePressEventToSubframe(
const MouseEventWithHitTestResults& mev) { … }
void SelectionController::InitializeSelectionState() { … }
void SelectionController::SetMouseDownMayStartSelect(bool may_start_select) { … }
bool SelectionController::MouseDownMayStartSelect() const { … }
bool SelectionController::MouseDownWasSingleClickInSelection() const { … }
void SelectionController::NotifySelectionChanged() { … }
FrameSelection& SelectionController::Selection() const { … }
bool IsSelectionOverLink(const MouseEventWithHitTestResults& event) { … }
bool IsUserNodeDraggable(const MouseEventWithHitTestResults& event) { … }
bool IsExtendingSelection(const MouseEventWithHitTestResults& event) { … }
template void SelectionController::UpdateSelectionForContextMenuEvent<
MouseEvent>(const MouseEvent*, const HitTestResult&, const PhysicalOffset&);
}