chromium/third_party/blink/renderer/core/editing/selection_controller.cc

/*
 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
 * reserved.
 * Copyright (C) 2006 Alexey Proskuryakov ([email protected])
 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
 * Copyright (C) 2015 Google Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#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) {}

}  // namespace

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) {}

// Updating the selection is considered side-effect of the event and so it
// doesn't impact the handled state.
bool SelectionController::HandleSingleClick(
    const MouseEventWithHitTestResults& event) {}

// Returns true if the tap is processed.
void SelectionController::HandleTapOnCaret(
    const MouseEventWithHitTestResults& event,
    const SelectionInFlatTree& selection) {}

// Returns true if the tap is processed.
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) {}

// TODO(yosin): We should take |granularity| and |handleVisibility| from
// |newSelection|.
// We should rename this function to appropriate name because
// set_selection_options has selection directional value in few cases.
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&);

}  // namespace blink