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

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

Issue 1362283003: Make toPositionInComposedTree() with non-distributed node to return non-null position (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2015-09-24T18:07:50 Created 5 years, 3 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 7034bbb344628038a70b7ffbc838bf6d11f1902f..f1c6789e9c788c98574baf02254e2fe8ba42227f 100644
--- a/third_party/WebKit/Source/core/editing/Position.cpp
+++ b/third_party/WebKit/Source/core/editing/Position.cpp
@@ -385,7 +385,6 @@ PositionInComposedTree toPositionInComposedTree(const Position& pos)
if (pos.isNull())
return PositionInComposedTree();
- PositionInComposedTree position;
if (pos.isOffsetInAnchor()) {
Node* anchor = pos.anchorNode();
if (anchor->offsetInCharacters())
@@ -404,7 +403,14 @@ PositionInComposedTree toPositionInComposedTree(const Position& pos)
return PositionInComposedTree(anchor->shadowHost(), offset);
return PositionInComposedTree(anchor, offset);
}
- return PositionInComposedTree(ComposedTreeTraversal::parent(*child), ComposedTreeTraversal::index(*child));
+ if (Node* parent = ComposedTreeTraversal::parent(*child))
+ return PositionInComposedTree(parent, ComposedTreeTraversal::index(*child));
+ // When |pos| isn't appeared in composed tree, we map |pos| to after
+ // children of shadow host.
+ // e.g. "foo",0 in <progress>foo</progress>
+ if (anchor->isShadowRoot())
+ return PositionInComposedTree(anchor->shadowHost(), PositionAnchorType::AfterChildren);
+ return PositionInComposedTree(anchor, PositionAnchorType::AfterChildren);
}
return PositionInComposedTree(pos.anchorNode(), pos.anchorType());
« 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