Index: third_party/WebKit/Source/core/editing/FrameSelection.cpp |
diff --git a/third_party/WebKit/Source/core/editing/FrameSelection.cpp b/third_party/WebKit/Source/core/editing/FrameSelection.cpp |
index 0a2138367e08782e4c98e35d6f156429ce0656a2..f558ccd64342b5a67f8f8cf4cbda09aac5d88868 100644 |
--- a/third_party/WebKit/Source/core/editing/FrameSelection.cpp |
+++ b/third_party/WebKit/Source/core/editing/FrameSelection.cpp |
@@ -798,6 +798,13 @@ void FrameSelection::selectFrameElementInParentIfFullySelected() |
toLocalFrame(parent)->selection().setSelection(newSelection); |
} |
+// Returns a shadow tree node for legacy shadow trees, a child of the |
+// ShadowRoot node for new shadow trees, or 0 for non-shadow trees. |
+static Node* nonBoundaryShadowTreeRootNode(const Position& position) |
+{ |
+ return position.anchorNode() && !position.anchorNode()->isShadowRoot() ? position.anchorNode()->nonBoundaryShadowTreeRootNode() : nullptr; |
+} |
+ |
void FrameSelection::selectAll() |
{ |
Document* document = m_frame->document(); |
@@ -814,12 +821,12 @@ void FrameSelection::selectAll() |
Node* selectStartTarget = nullptr; |
if (isContentEditable()) { |
root = highestEditableRoot(selection().start()); |
- if (Node* shadowRoot = selection().nonBoundaryShadowTreeRootNode()) |
+ if (Node* shadowRoot = nonBoundaryShadowTreeRootNode(selection().start())) |
selectStartTarget = shadowRoot->shadowHost(); |
else |
selectStartTarget = root; |
} else { |
- root = selection().nonBoundaryShadowTreeRootNode(); |
+ root = nonBoundaryShadowTreeRootNode(selection().start()); |
if (root) { |
selectStartTarget = root->shadowHost(); |
} else { |