summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/editing/selection_controller.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/editing/selection_controller.cc')
-rw-r--r--chromium/third_party/blink/renderer/core/editing/selection_controller.cc55
1 files changed, 26 insertions, 29 deletions
diff --git a/chromium/third_party/blink/renderer/core/editing/selection_controller.cc b/chromium/third_party/blink/renderer/core/editing/selection_controller.cc
index 8a9ee855603..8ed3c295c8a 100644
--- a/chromium/third_party/blink/renderer/core/editing/selection_controller.cc
+++ b/chromium/third_party/blink/renderer/core/editing/selection_controller.cc
@@ -30,7 +30,7 @@
#include "third_party/blink/renderer/core/editing/selection_controller.h"
#include "base/auto_reset.h"
-#include "third_party/blink/public/platform/web_menu_source_type.h"
+#include "third_party/blink/public/common/input/web_menu_source_type.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"
@@ -62,7 +62,8 @@
namespace blink {
SelectionController::SelectionController(LocalFrame& frame)
- : frame_(&frame),
+ : ExecutionContextLifecycleObserver(frame.GetDocument()),
+ frame_(&frame),
mouse_down_may_start_select_(false),
mouse_down_was_single_click_in_selection_(false),
mouse_down_allows_multi_click_(false),
@@ -71,7 +72,7 @@ SelectionController::SelectionController(LocalFrame& frame)
void SelectionController::Trace(Visitor* visitor) {
visitor->Trace(frame_);
visitor->Trace(original_base_in_flat_tree_);
- DocumentShutdownObserver::Trace(visitor);
+ ExecutionContextLifecycleObserver::Trace(visitor);
}
namespace {
@@ -123,8 +124,9 @@ bool CanMouseDownStartSelect(Node* node) {
PositionInFlatTreeWithAffinity PositionWithAffinityOfHitTestResult(
const HitTestResult& hit_test_result) {
return FromPositionInDOMTree<EditingInFlatTreeStrategy>(
- hit_test_result.InnerNode()->GetLayoutObject()->PositionForPoint(
- hit_test_result.LocalPoint()));
+ hit_test_result.InnerPossiblyPseudoNode()
+ ->GetLayoutObject()
+ ->PositionForPoint(hit_test_result.LocalPoint()));
}
DocumentMarker* SpellCheckMarkerAtPosition(
@@ -167,7 +169,7 @@ Document& SelectionController::GetDocument() const {
return *frame_->GetDocument();
}
-void SelectionController::ContextDestroyed(Document*) {
+void SelectionController::ContextDestroyed() {
original_base_in_flat_tree_ = PositionInFlatTreeWithAffinity();
}
@@ -311,8 +313,9 @@ bool SelectionController::HandleSingleClick(
DCHECK(!frame_->GetDocument()->NeedsLayoutTreeUpdate());
Node* inner_node = event.InnerNode();
- if (!(inner_node && inner_node->GetLayoutObject() &&
- mouse_down_may_start_select_))
+ Node* inner_pseudo = event.GetHitTestResult().InnerPossiblyPseudoNode();
+ if (!(inner_node && inner_node->GetLayoutObject() && inner_pseudo &&
+ inner_pseudo->GetLayoutObject() && mouse_down_may_start_select_))
return false;
// Extend the selection if the Shift key is down, unless the click is in a
@@ -477,13 +480,13 @@ void SelectionController::UpdateSelectionForMouseDrag(
if (!mouse_down_may_start_select_)
return;
- Node* target = hit_test_result.InnerNode();
+ Node* target = hit_test_result.InnerPossiblyPseudoNode();
if (!target)
return;
// TODO(editing-dev): Use of UpdateStyleAndLayout
// needs to be audited. See http://crbug.com/590369 for more details.
- frame_->GetDocument()->UpdateStyleAndLayout();
+ frame_->GetDocument()->UpdateStyleAndLayout(DocumentUpdateReason::kSelection);
const PositionWithAffinity& raw_target_position =
Selection().SelectionHasFocus()
@@ -581,7 +584,7 @@ bool SelectionController::UpdateSelectionForMouseDownDispatchingSelectStart(
// TODO(editing-dev): Use of UpdateStyleAndLayout
// needs to be audited. See http://crbug.com/590369 for more details.
- GetDocument().UpdateStyleAndLayout();
+ GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kSelection);
const SelectionInFlatTree visible_selection =
CreateVisibleSelection(selection).AsSelection();
@@ -602,7 +605,7 @@ bool SelectionController::SelectClosestWordFromHitTestResult(
const HitTestResult& result,
AppendTrailingWhitespace append_trailing_whitespace,
SelectInputEventType select_input_event_type) {
- Node* const inner_node = result.InnerNode();
+ Node* const inner_node = result.InnerPossiblyPseudoNode();
if (!inner_node || !inner_node->GetLayoutObject() ||
!inner_node->GetLayoutObject()->IsSelectable())
@@ -615,8 +618,8 @@ bool SelectionController::SelectClosestWordFromHitTestResult(
HitTestResult adjusted_hit_test_result = result;
if (select_input_event_type == SelectInputEventType::kTouch &&
result.GetImage()) {
- adjusted_hit_test_result.SetNodeAndPosition(result.InnerNode(),
- PhysicalOffset());
+ adjusted_hit_test_result.SetNodeAndPosition(
+ result.InnerPossiblyPseudoNode(), PhysicalOffset());
}
const PositionInFlatTreeWithAffinity pos =
@@ -681,7 +684,7 @@ bool SelectionController::SelectClosestWordFromHitTestResult(
void SelectionController::SelectClosestMisspellingFromHitTestResult(
const HitTestResult& result,
AppendTrailingWhitespace append_trailing_whitespace) {
- Node* inner_node = result.InnerNode();
+ Node* inner_node = result.InnerPossiblyPseudoNode();
if (!inner_node || !inner_node->GetLayoutObject())
return;
@@ -830,7 +833,7 @@ void SelectionController::SetNonDirectionalSelectionIfNeeded(
if (adjusted_selection.Base() != base.GetPosition() ||
adjusted_selection.Extent() != extent.GetPosition()) {
original_base_in_flat_tree_ = base;
- SetContext(&GetDocument());
+ SetExecutionContext(GetDocument().ToExecutionContext());
builder.SetBaseAndExtent(adjusted_selection.Base(),
adjusted_selection.Extent());
} else if (original_base.IsNotNull()) {
@@ -871,7 +874,7 @@ void SelectionController::SetNonDirectionalSelectionIfNeeded(
void SelectionController::SetCaretAtHitTestResult(
const HitTestResult& hit_test_result) {
- Node* inner_node = hit_test_result.InnerNode();
+ Node* inner_node = hit_test_result.InnerPossiblyPseudoNode();
DCHECK(inner_node);
const PositionInFlatTreeWithAffinity visible_hit_pos =
CreateVisiblePosition(
@@ -1078,7 +1081,8 @@ bool SelectionController::HandleMouseReleaseEvent(
event.Event().button != WebPointerProperties::Button::kRight) {
// TODO(editing-dev): Use of UpdateStyleAndLayout
// needs to be audited. See http://crbug.com/590369 for more details.
- frame_->GetDocument()->UpdateStyleAndLayout();
+ frame_->GetDocument()->UpdateStyleAndLayout(
+ DocumentUpdateReason::kSelection);
SelectionInFlatTree::Builder builder;
Node* node = event.InnerNode();
@@ -1156,7 +1160,7 @@ bool SelectionController::HandleGestureLongPress(
if (hit_test_result.IsLiveLink())
return false;
- Node* inner_node = hit_test_result.InnerNode();
+ Node* inner_node = hit_test_result.InnerPossiblyPseudoNode();
inner_node->GetDocument().UpdateStyleAndLayoutTree();
bool inner_node_is_selectable = HasEditableStyle(*inner_node) ||
inner_node->IsTextNode() ||
@@ -1182,15 +1186,8 @@ void SelectionController::HandleGestureTwoFingerTap(
SetCaretAtHitTestResult(targeted_event.GetHitTestResult());
}
-void SelectionController::HandleGestureLongTap(
- const GestureEventWithHitTestResults& targeted_event) {
- TRACE_EVENT0("blink", "SelectionController::handleGestureLongTap");
-
- SetCaretAtHitTestResult(targeted_event.GetHitTestResult());
-}
-
static bool HitTestResultIsMisspelled(const HitTestResult& result) {
- Node* inner_node = result.InnerNode();
+ Node* inner_node = result.InnerPossiblyPseudoNode();
if (!inner_node || !inner_node->GetLayoutObject())
return false;
PositionWithAffinity pos_with_affinity =
@@ -1206,7 +1203,7 @@ static bool HitTestResultIsMisspelled(const HitTestResult& result) {
ToPositionInFlatTree(marker_position));
}
-void SelectionController::SendContextMenuEvent(
+void SelectionController::UpdateSelectionForContextMenuEvent(
const MouseEventWithHitTestResults& mev,
const PhysicalOffset& position) {
if (!Selection().IsAvailable())
@@ -1241,7 +1238,7 @@ void SelectionController::PassMousePressEventToSubframe(
const MouseEventWithHitTestResults& mev) {
// TODO(editing-dev): The use of UpdateStyleAndLayout
// needs to be audited. See http://crbug.com/590369 for more details.
- frame_->GetDocument()->UpdateStyleAndLayout();
+ frame_->GetDocument()->UpdateStyleAndLayout(DocumentUpdateReason::kInput);
// If we're clicking into a frame that is selected, the frame will appear
// greyed out even though we're clicking on the selection. This looks