Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1148)

Unified Diff: third_party/WebKit/Source/core/editing/Position.cpp

Issue 2229463003: Make toPositionInFlatTree() to handle a position anchored by shadow root (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-08-09T14:04:01 Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/PositionTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/Position.cpp
diff --git a/third_party/WebKit/Source/core/editing/Position.cpp b/third_party/WebKit/Source/core/editing/Position.cpp
index 01f0364a006e652f08bdf32c1affcd23bf5451aa..c0a6bf2259c17821451675d374f728b81f9839a9 100644
--- a/third_party/WebKit/Source/core/editing/Position.cpp
+++ b/third_party/WebKit/Source/core/editing/Position.cpp
@@ -513,8 +513,8 @@ PositionInFlatTree toPositionInFlatTree(const Position& pos)
if (pos.isNull())
return PositionInFlatTree();
+ Node* const anchor = pos.anchorNode();
if (pos.isOffsetInAnchor()) {
- Node* anchor = pos.anchorNode();
if (anchor->isCharacterDataNode())
return PositionInFlatTree(anchor, pos.computeOffsetInContainerNode());
DCHECK(!anchor->isSlotOrActiveInsertionPoint());
@@ -541,7 +541,11 @@ PositionInFlatTree toPositionInFlatTree(const Position& pos)
return PositionInFlatTree(anchor, PositionAnchorType::AfterChildren);
}
- return PositionInFlatTree(pos.anchorNode(), pos.anchorType());
+ if (anchor->isShadowRoot())
+ return PositionInFlatTree(anchor->shadowHost(), pos.anchorType());
+ // TODO(yosin): Once we have a test case for SLOT or active insertion point,
+ // this function should handle it.
+ return PositionInFlatTree(anchor, pos.anchorType());
}
Position toPositionInDOMTree(const Position& position)
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/PositionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698