Commit d33f201d authored by Nate Chapin's avatar Nate Chapin Committed by Commit Bot

Remove usage of ExecutionContextClient frame-variants from DOMSelection

Change-Id: I7d0598be2359323a33915fff8c4345eeac8a2a3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2490546
Commit-Queue: Kentaro Hara <haraken@chromium.org>
Auto-Submit: Nate Chapin <japhet@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819636}
parent 5cf584e0
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "third_party/blink/renderer/core/editing/set_selection_options.h" #include "third_party/blink/renderer/core/editing/set_selection_options.h"
#include "third_party/blink/renderer/core/editing/visible_selection.h" #include "third_party/blink/renderer/core/editing/visible_selection.h"
#include "third_party/blink/renderer/core/frame/deprecation.h" #include "third_party/blink/renderer/core/frame/deprecation.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.h"
#include "third_party/blink/renderer/core/inspector/console_message.h" #include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h"
...@@ -52,68 +53,52 @@ ...@@ -52,68 +53,52 @@
namespace blink { namespace blink {
static Node* SelectionShadowAncestor(LocalFrame* frame) {
Node* node = frame->Selection()
.ComputeVisibleSelectionInDOMTreeDeprecated()
.Base()
.AnchorNode();
if (!node)
return nullptr;
if (!node->IsInShadowTree())
return nullptr;
return frame->GetDocument()->AncestorInThisScope(node);
}
DOMSelection::DOMSelection(const TreeScope* tree_scope) DOMSelection::DOMSelection(const TreeScope* tree_scope)
: ExecutionContextClient(tree_scope->RootNode().GetDocument().GetFrame()), : ExecutionContextClient(tree_scope->RootNode().GetExecutionContext()),
tree_scope_(tree_scope) {} tree_scope_(tree_scope) {}
void DOMSelection::ClearTreeScope() { void DOMSelection::ClearTreeScope() {
tree_scope_ = nullptr; tree_scope_ = nullptr;
} }
FrameSelection& DOMSelection::Selection() const {
DCHECK(DomWindow());
return DomWindow()->GetFrame()->Selection();
}
// TODO(editing-dev): The behavior after loosing browsing context is not // TODO(editing-dev): The behavior after loosing browsing context is not
// specified. https://github.com/w3c/selection-api/issues/82 // specified. https://github.com/w3c/selection-api/issues/82
bool DOMSelection::IsAvailable() const { bool DOMSelection::IsAvailable() const {
return GetFrame() && GetFrame()->Selection().IsAvailable(); return DomWindow() && Selection().IsAvailable();
} }
void DOMSelection::UpdateFrameSelection( void DOMSelection::UpdateFrameSelection(
const SelectionInDOMTree& selection, const SelectionInDOMTree& selection,
Range* new_cached_range, Range* new_cached_range,
const SetSelectionOptions& passed_options) const { const SetSelectionOptions& passed_options) const {
DCHECK(GetFrame()); DCHECK(DomWindow());
FrameSelection& frame_selection = GetFrame()->Selection();
SetSelectionOptions::Builder builder(passed_options); SetSelectionOptions::Builder builder(passed_options);
builder.SetShouldCloseTyping(true).SetShouldClearTypingStyle(true); builder.SetShouldCloseTyping(true).SetShouldClearTypingStyle(true);
SetSelectionOptions options = builder.Build(); SetSelectionOptions options = builder.Build();
// TODO(tkent): Specify FrameSelection::DoNotSetFocus. crbug.com/690272 // TODO(tkent): Specify FrameSelection::DoNotSetFocus. crbug.com/690272
const bool did_set = const bool did_set = Selection().SetSelectionDeprecated(selection, options);
frame_selection.SetSelectionDeprecated(selection, options);
CacheRangeIfSelectionOfDocument(new_cached_range); CacheRangeIfSelectionOfDocument(new_cached_range);
if (!did_set) if (!did_set)
return; return;
Element* focused_element = GetFrame()->GetDocument()->FocusedElement(); Element* focused_element = DomWindow()->document()->FocusedElement();
frame_selection.DidSetSelectionDeprecated(selection, options); Selection().DidSetSelectionDeprecated(selection, options);
if (GetFrame() && GetFrame()->GetDocument() && if (DomWindow() &&
focused_element != GetFrame()->GetDocument()->FocusedElement()) { focused_element != DomWindow()->document()->FocusedElement()) {
UseCounter::Count(GetFrame()->GetDocument(), UseCounter::Count(DomWindow(), WebFeature::kSelectionFuncionsChangeFocus);
WebFeature::kSelectionFuncionsChangeFocus);
} }
} }
VisibleSelection DOMSelection::GetVisibleSelection() const { VisibleSelection DOMSelection::GetVisibleSelection() const {
DCHECK(GetFrame()); return Selection().ComputeVisibleSelectionInDOMTreeDeprecated();
return GetFrame()->Selection().ComputeVisibleSelectionInDOMTreeDeprecated();
} }
bool DOMSelection::IsBaseFirstInSelection() const { bool DOMSelection::IsBaseFirstInSelection() const {
DCHECK(GetFrame()); return Selection().GetSelectionInDOMTree().IsBaseFirst();
const SelectionInDOMTree& selection =
GetFrame()->Selection().GetSelectionInDOMTree();
return selection.IsBaseFirst();
} }
// TODO(tkent): Following four functions based on VisibleSelection should be // TODO(tkent): Following four functions based on VisibleSelection should be
...@@ -132,7 +117,7 @@ static Position FocusPosition(const VisibleSelection& selection) { ...@@ -132,7 +117,7 @@ static Position FocusPosition(const VisibleSelection& selection) {
Node* DOMSelection::anchorNode() const { Node* DOMSelection::anchorNode() const {
if (Range* range = PrimaryRangeOrNull()) { if (Range* range = PrimaryRangeOrNull()) {
if (!GetFrame() || IsBaseFirstInSelection()) if (!DomWindow() || IsBaseFirstInSelection())
return range->startContainer(); return range->startContainer();
return range->endContainer(); return range->endContainer();
} }
...@@ -141,7 +126,7 @@ Node* DOMSelection::anchorNode() const { ...@@ -141,7 +126,7 @@ Node* DOMSelection::anchorNode() const {
unsigned DOMSelection::anchorOffset() const { unsigned DOMSelection::anchorOffset() const {
if (Range* range = PrimaryRangeOrNull()) { if (Range* range = PrimaryRangeOrNull()) {
if (!GetFrame() || IsBaseFirstInSelection()) if (!DomWindow() || IsBaseFirstInSelection())
return range->startOffset(); return range->startOffset();
return range->endOffset(); return range->endOffset();
} }
...@@ -150,7 +135,7 @@ unsigned DOMSelection::anchorOffset() const { ...@@ -150,7 +135,7 @@ unsigned DOMSelection::anchorOffset() const {
Node* DOMSelection::focusNode() const { Node* DOMSelection::focusNode() const {
if (Range* range = PrimaryRangeOrNull()) { if (Range* range = PrimaryRangeOrNull()) {
if (!GetFrame() || IsBaseFirstInSelection()) if (!DomWindow() || IsBaseFirstInSelection())
return range->endContainer(); return range->endContainer();
return range->startContainer(); return range->startContainer();
} }
...@@ -159,7 +144,7 @@ Node* DOMSelection::focusNode() const { ...@@ -159,7 +144,7 @@ Node* DOMSelection::focusNode() const {
unsigned DOMSelection::focusOffset() const { unsigned DOMSelection::focusOffset() const {
if (Range* range = PrimaryRangeOrNull()) { if (Range* range = PrimaryRangeOrNull()) {
if (!GetFrame() || IsBaseFirstInSelection()) if (!DomWindow() || IsBaseFirstInSelection())
return range->endOffset(); return range->endOffset();
return range->startOffset(); return range->startOffset();
} }
...@@ -183,8 +168,17 @@ unsigned DOMSelection::extentOffset() const { ...@@ -183,8 +168,17 @@ unsigned DOMSelection::extentOffset() const {
} }
bool DOMSelection::isCollapsed() const { bool DOMSelection::isCollapsed() const {
if (!IsAvailable() || SelectionShadowAncestor(GetFrame())) if (!IsAvailable())
return true; return true;
Node* node = Selection()
.ComputeVisibleSelectionInDOMTreeDeprecated()
.Base()
.AnchorNode();
if (node && node->IsInShadowTree() &&
DomWindow()->document()->AncestorInThisScope(node)) {
return true;
}
if (Range* range = PrimaryRangeOrNull()) if (Range* range = PrimaryRangeOrNull())
return range->collapsed(); return range->collapsed();
return true; return true;
...@@ -200,7 +194,7 @@ String DOMSelection::type() const { ...@@ -200,7 +194,7 @@ String DOMSelection::type() const {
return "None"; return "None";
// Do not use isCollapsed() here. We'd like to return "Range" for // Do not use isCollapsed() here. We'd like to return "Range" for
// range-selection in text control elements. // range-selection in text control elements.
if (GetFrame()->Selection().GetSelectionInDOMTree().IsCaret()) if (Selection().GetSelectionInDOMTree().IsCaret())
return "Caret"; return "Caret";
return "Range"; return "Range";
} }
...@@ -210,10 +204,7 @@ unsigned DOMSelection::rangeCount() const { ...@@ -210,10 +204,7 @@ unsigned DOMSelection::rangeCount() const {
return 0; return 0;
if (DocumentCachedRange()) if (DocumentCachedRange())
return 1; return 1;
if (GetFrame() if (Selection().ComputeVisibleSelectionInDOMTreeDeprecated().IsNone())
->Selection()
.ComputeVisibleSelectionInDOMTreeDeprecated()
.IsNone())
return 0; return 0;
// Any selection can be adjusted to Range for Document. // Any selection can be adjusted to Range for Document.
if (IsSelectionOfDocument()) if (IsSelectionOfDocument())
...@@ -234,9 +225,8 @@ void DOMSelection::collapse(Node* node, ...@@ -234,9 +225,8 @@ void DOMSelection::collapse(Node* node,
// 1. If node is null, this method must behave identically as // 1. If node is null, this method must behave identically as
// removeAllRanges() and abort these steps. // removeAllRanges() and abort these steps.
if (!node) { if (!node) {
UseCounter::Count(GetFrame()->GetDocument(), UseCounter::Count(DomWindow(), WebFeature::kSelectionCollapseNull);
WebFeature::kSelectionCollapseNull); Selection().Clear();
GetFrame()->Selection().Clear();
return; return;
} }
...@@ -252,7 +242,7 @@ void DOMSelection::collapse(Node* node, ...@@ -252,7 +242,7 @@ void DOMSelection::collapse(Node* node,
return; return;
// 4. Otherwise, let newRange be a new range. // 4. Otherwise, let newRange be a new range.
Range* new_range = Range::Create(*GetFrame()->GetDocument()); Range* new_range = Range::Create(*DomWindow()->document());
// 5. Set ([DOM4]) the start and the end of newRange to (node, offset). // 5. Set ([DOM4]) the start and the end of newRange to (node, offset).
new_range->setStart(node, offset, exception_state); new_range->setStart(node, offset, exception_state);
...@@ -268,12 +258,10 @@ void DOMSelection::collapse(Node* node, ...@@ -268,12 +258,10 @@ void DOMSelection::collapse(Node* node,
// 6. Set the context object's range to newRange. // 6. Set the context object's range to newRange.
UpdateFrameSelection( UpdateFrameSelection(
SelectionInDOMTree::Builder() SelectionInDOMTree::Builder().Collapse(Position(node, offset)).Build(),
.Collapse(Position(node, offset))
.Build(),
new_range, new_range,
SetSelectionOptions::Builder() SetSelectionOptions::Builder()
.SetIsDirectional(GetFrame()->Selection().IsDirectional()) .SetIsDirectional(Selection().IsDirectional())
.Build()); .Build());
} }
...@@ -304,8 +292,7 @@ void DOMSelection::collapseToEnd(ExceptionState& exception_state) { ...@@ -304,8 +292,7 @@ void DOMSelection::collapseToEnd(ExceptionState& exception_state) {
// TODO(tkent): The Selection API doesn't define this behavior. We should // TODO(tkent): The Selection API doesn't define this behavior. We should
// discuss this on https://github.com/w3c/selection-api/issues/83. // discuss this on https://github.com/w3c/selection-api/issues/83.
SelectionInDOMTree::Builder builder; SelectionInDOMTree::Builder builder;
builder.Collapse( builder.Collapse(Selection().GetSelectionInDOMTree().ComputeEndPosition());
GetFrame()->Selection().GetSelectionInDOMTree().ComputeEndPosition());
UpdateFrameSelection(builder.Build(), nullptr, SetSelectionOptions()); UpdateFrameSelection(builder.Build(), nullptr, SetSelectionOptions());
} }
} }
...@@ -338,15 +325,14 @@ void DOMSelection::collapseToStart(ExceptionState& exception_state) { ...@@ -338,15 +325,14 @@ void DOMSelection::collapseToStart(ExceptionState& exception_state) {
// discuss this on https://github.com/w3c/selection-api/issues/83. // discuss this on https://github.com/w3c/selection-api/issues/83.
SelectionInDOMTree::Builder builder; SelectionInDOMTree::Builder builder;
builder.Collapse( builder.Collapse(
GetFrame()->Selection().GetSelectionInDOMTree().ComputeStartPosition()); Selection().GetSelectionInDOMTree().ComputeStartPosition());
UpdateFrameSelection(builder.Build(), nullptr, SetSelectionOptions()); UpdateFrameSelection(builder.Build(), nullptr, SetSelectionOptions());
} }
} }
void DOMSelection::empty() { void DOMSelection::empty() {
if (!IsAvailable()) if (IsAvailable())
return; Selection().Clear();
GetFrame()->Selection().Clear();
} }
void DOMSelection::setBaseAndExtent(Node* base_node, void DOMSelection::setBaseAndExtent(Node* base_node,
...@@ -360,14 +346,12 @@ void DOMSelection::setBaseAndExtent(Node* base_node, ...@@ -360,14 +346,12 @@ void DOMSelection::setBaseAndExtent(Node* base_node,
// TODO(editing-dev): Behavior on where base or extent is null is still // TODO(editing-dev): Behavior on where base or extent is null is still
// under discussion: https://github.com/w3c/selection-api/issues/72 // under discussion: https://github.com/w3c/selection-api/issues/72
if (!base_node) { if (!base_node) {
UseCounter::Count(GetFrame()->GetDocument(), UseCounter::Count(DomWindow(), WebFeature::kSelectionSetBaseAndExtentNull);
WebFeature::kSelectionSetBaseAndExtentNull); Selection().Clear();
GetFrame()->Selection().Clear();
return; return;
} }
if (!extent_node) { if (!extent_node) {
UseCounter::Count(GetFrame()->GetDocument(), UseCounter::Count(DomWindow(), WebFeature::kSelectionSetBaseAndExtentNull);
WebFeature::kSelectionSetBaseAndExtentNull);
extent_offset = 0; extent_offset = 0;
} }
...@@ -455,16 +439,14 @@ void DOMSelection::modify(const String& alter_string, ...@@ -455,16 +439,14 @@ void DOMSelection::modify(const String& alter_string,
// TODO(editing-dev): The use of UpdateStyleAndLayout // TODO(editing-dev): The use of UpdateStyleAndLayout
// needs to be audited. See http://crbug.com/590369 for more details. // needs to be audited. See http://crbug.com/590369 for more details.
GetFrame()->GetDocument()->UpdateStyleAndLayout( DomWindow()->document()->UpdateStyleAndLayout(
DocumentUpdateReason::kSelection); DocumentUpdateReason::kSelection);
Element* focused_element = GetFrame()->GetDocument()->FocusedElement(); Element* focused_element = DomWindow()->document()->FocusedElement();
GetFrame()->Selection().Modify(alter, direction, granularity, Selection().Modify(alter, direction, granularity, SetSelectionBy::kSystem);
SetSelectionBy::kSystem); if (DomWindow() &&
if (GetFrame() && GetFrame()->GetDocument() && focused_element != DomWindow()->document()->FocusedElement()) {
focused_element != GetFrame()->GetDocument()->FocusedElement()) { UseCounter::Count(DomWindow(), WebFeature::kSelectionFuncionsChangeFocus);
UseCounter::Count(GetFrame()->GetDocument(),
WebFeature::kSelectionFuncionsChangeFocus);
} }
} }
...@@ -503,7 +485,7 @@ void DOMSelection::extend(Node* node, ...@@ -503,7 +485,7 @@ void DOMSelection::extend(Node* node,
ClearCachedRangeIfSelectionOfDocument(); ClearCachedRangeIfSelectionOfDocument();
// 4. Let newRange be a new range. // 4. Let newRange be a new range.
Range* new_range = Range::Create(*GetFrame()->GetDocument()); Range* new_range = Range::Create(*DomWindow()->document());
// 5. If node's root is not the same as the context object's range's root, set // 5. If node's root is not the same as the context object's range's root, set
// newRange's start and end to newFocus. // newRange's start and end to newFocus.
...@@ -592,35 +574,29 @@ bool DOMSelection::IsSelectionOfDocument() const { ...@@ -592,35 +574,29 @@ bool DOMSelection::IsSelectionOfDocument() const {
void DOMSelection::CacheRangeIfSelectionOfDocument(Range* range) const { void DOMSelection::CacheRangeIfSelectionOfDocument(Range* range) const {
if (!IsSelectionOfDocument()) if (!IsSelectionOfDocument())
return; return;
if (!GetFrame()) if (!DomWindow())
return; return;
GetFrame()->Selection().CacheRangeOfDocument(range); Selection().CacheRangeOfDocument(range);
} }
Range* DOMSelection::DocumentCachedRange() const { Range* DOMSelection::DocumentCachedRange() const {
if (!IsSelectionOfDocument()) return IsSelectionOfDocument() ? Selection().DocumentCachedRange() : nullptr;
return nullptr;
return GetFrame()->Selection().DocumentCachedRange();
} }
void DOMSelection::ClearCachedRangeIfSelectionOfDocument() { void DOMSelection::ClearCachedRangeIfSelectionOfDocument() {
if (!IsSelectionOfDocument()) if (IsSelectionOfDocument())
return; Selection().ClearDocumentCachedRange();
GetFrame()->Selection().ClearDocumentCachedRange();
} }
void DOMSelection::removeRange(Range* range) { void DOMSelection::removeRange(Range* range) {
DCHECK(range); DCHECK(range);
if (!IsAvailable()) if (IsAvailable() && range == PrimaryRangeOrNull())
return; Selection().Clear();
if (range == PrimaryRangeOrNull())
GetFrame()->Selection().Clear();
} }
void DOMSelection::removeAllRanges() { void DOMSelection::removeAllRanges() {
if (!IsAvailable()) if (IsAvailable())
return; Selection().Clear();
GetFrame()->Selection().Clear();
} }
void DOMSelection::addRange(Range* new_range) { void DOMSelection::addRange(Range* new_range) {
...@@ -629,7 +605,7 @@ void DOMSelection::addRange(Range* new_range) { ...@@ -629,7 +605,7 @@ void DOMSelection::addRange(Range* new_range) {
if (!IsAvailable()) if (!IsAvailable())
return; return;
if (new_range->OwnerDocument() != GetFrame()->GetDocument()) if (new_range->OwnerDocument() != DomWindow()->document())
return; return;
if (!new_range->IsConnected()) { if (!new_range->IsConnected()) {
...@@ -637,9 +613,7 @@ void DOMSelection::addRange(Range* new_range) { ...@@ -637,9 +613,7 @@ void DOMSelection::addRange(Range* new_range) {
return; return;
} }
FrameSelection& selection = GetFrame()->Selection(); if (new_range->OwnerDocument() != Selection().GetDocument()) {
if (new_range->OwnerDocument() != selection.GetDocument()) {
// "editing/selection/selection-in-iframe-removed-crash.html" goes here. // "editing/selection/selection-in-iframe-removed-crash.html" goes here.
return; return;
} }
...@@ -691,7 +665,7 @@ void DOMSelection::deleteFromDocument() { ...@@ -691,7 +665,7 @@ void DOMSelection::deleteFromDocument() {
// TODO(editing-dev): The use of UpdateStyleAndLayout // TODO(editing-dev): The use of UpdateStyleAndLayout
// needs to be audited. See http://crbug.com/590369 for more details. // needs to be audited. See http://crbug.com/590369 for more details.
GetFrame()->GetDocument()->UpdateStyleAndLayout( DomWindow()->document()->UpdateStyleAndLayout(
DocumentUpdateReason::kSelection); DocumentUpdateReason::kSelection);
// The following code is necessary for // The following code is necessary for
...@@ -699,13 +673,11 @@ void DOMSelection::deleteFromDocument() { ...@@ -699,13 +673,11 @@ void DOMSelection::deleteFromDocument() {
// deleteFromDocument() for text selection in a TEXTAREA deletes the TEXTAREA // deleteFromDocument() for text selection in a TEXTAREA deletes the TEXTAREA
// value. // value.
FrameSelection& selection = GetFrame()->Selection(); if (Selection().ComputeVisibleSelectionInDOMTree().IsNone())
if (selection.ComputeVisibleSelectionInDOMTree().IsNone())
return; return;
Range* selected_range = Range* selected_range = CreateRange(Selection()
CreateRange(selection.ComputeVisibleSelectionInDOMTree() .ComputeVisibleSelectionInDOMTree()
.ToNormalizedEphemeralRange()); .ToNormalizedEphemeralRange());
if (!selected_range) if (!selected_range)
return; return;
...@@ -720,7 +692,7 @@ bool DOMSelection::containsNode(const Node* n, bool allow_partial) const { ...@@ -720,7 +692,7 @@ bool DOMSelection::containsNode(const Node* n, bool allow_partial) const {
if (!IsAvailable()) if (!IsAvailable())
return false; return false;
if (GetFrame()->GetDocument() != n->GetDocument()) if (DomWindow()->document() != n->GetDocument())
return false; return false;
unsigned node_index = n->NodeIndex(); unsigned node_index = n->NodeIndex();
...@@ -728,12 +700,12 @@ bool DOMSelection::containsNode(const Node* n, bool allow_partial) const { ...@@ -728,12 +700,12 @@ bool DOMSelection::containsNode(const Node* n, bool allow_partial) const {
// TODO(editing-dev): The use of UpdateStyleAndLayout // TODO(editing-dev): The use of UpdateStyleAndLayout
// needs to be audited. See http://crbug.com/590369 for more details. // needs to be audited. See http://crbug.com/590369 for more details.
// |VisibleSelection::toNormalizedEphemeralRange| requires clean layout. // |VisibleSelection::toNormalizedEphemeralRange| requires clean layout.
GetFrame()->GetDocument()->UpdateStyleAndLayout( DomWindow()->document()->UpdateStyleAndLayout(
DocumentUpdateReason::kSelection); DocumentUpdateReason::kSelection);
FrameSelection& selection = GetFrame()->Selection();
const EphemeralRange selected_range = const EphemeralRange selected_range =
selection.ComputeVisibleSelectionInDOMTreeDeprecated() Selection()
.ComputeVisibleSelectionInDOMTreeDeprecated()
.ToNormalizedEphemeralRange(); .ToNormalizedEphemeralRange();
if (selected_range.IsNull()) if (selected_range.IsNull())
return false; return false;
...@@ -789,14 +761,13 @@ String DOMSelection::toString() { ...@@ -789,14 +761,13 @@ String DOMSelection::toString() {
// TODO(editing-dev): The use of UpdateStyleAndLayout // TODO(editing-dev): The use of UpdateStyleAndLayout
// needs to be audited. See http://crbug.com/590369 for more details. // needs to be audited. See http://crbug.com/590369 for more details.
GetFrame()->GetDocument()->UpdateStyleAndLayout( DomWindow()->document()->UpdateStyleAndLayout(
DocumentUpdateReason::kSelection); DocumentUpdateReason::kSelection);
DocumentLifecycle::DisallowTransitionScope disallow_transition( DocumentLifecycle::DisallowTransitionScope disallow_transition(
GetFrame()->GetDocument()->Lifecycle()); DomWindow()->document()->Lifecycle());
const EphemeralRange range = GetFrame() const EphemeralRange range = Selection()
->Selection()
.ComputeVisibleSelectionInDOMTreeDeprecated() .ComputeVisibleSelectionInDOMTreeDeprecated()
.ToNormalizedEphemeralRange(); .ToNormalizedEphemeralRange();
return PlainText( return PlainText(
...@@ -838,11 +809,10 @@ unsigned DOMSelection::ShadowAdjustedOffset(const Position& position) const { ...@@ -838,11 +809,10 @@ unsigned DOMSelection::ShadowAdjustedOffset(const Position& position) const {
} }
bool DOMSelection::IsValidForPosition(Node* node) const { bool DOMSelection::IsValidForPosition(Node* node) const {
DCHECK(GetFrame()); DCHECK(DomWindow());
if (!node) if (!node)
return true; return true;
return node->GetDocument() == GetFrame()->GetDocument() && return node->GetDocument() == DomWindow()->document() && node->isConnected();
node->isConnected();
} }
void DOMSelection::AddConsoleWarning(const String& message) { void DOMSelection::AddConsoleWarning(const String& message) {
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
namespace blink { namespace blink {
class ExceptionState; class ExceptionState;
class FrameSelection;
class Node; class Node;
class Range; class Range;
class SetSelectionOptions; class SetSelectionOptions;
...@@ -102,6 +103,7 @@ class CORE_EXPORT DOMSelection final : public ScriptWrappable, ...@@ -102,6 +103,7 @@ class CORE_EXPORT DOMSelection final : public ScriptWrappable,
void Trace(Visitor*) const override; void Trace(Visitor*) const override;
private: private:
FrameSelection& Selection() const;
bool IsAvailable() const; bool IsAvailable() const;
void UpdateFrameSelection(const SelectionInDOMTree&, void UpdateFrameSelection(const SelectionInDOMTree&,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment