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

Unified Diff: Source/core/editing/VisibleUnits.cpp

Issue 1288063008: Move parentEditingBoundary() to VisibileUnits.cpp from Position.cpp. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-20T22:51:43 Rebase Created 5 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 | « Source/core/editing/Position.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/VisibleUnits.cpp
diff --git a/Source/core/editing/VisibleUnits.cpp b/Source/core/editing/VisibleUnits.cpp
index 88b7d3ec67f5fd222c3ad2ac90b1032d6e3ee68b..db73057e3293e2946b78262100fa9b1062e156f5 100644
--- a/Source/core/editing/VisibleUnits.cpp
+++ b/Source/core/editing/VisibleUnits.cpp
@@ -455,6 +455,30 @@ VisiblePosition rightWordPosition(const VisiblePosition& visiblePosition, bool s
return rightWordBreak;
}
+template <typename Strategy>
+static ContainerNode* nonShadowBoundaryParentNode(Node* node)
+{
+ ContainerNode* parent = Strategy::parent(*node);
+ return parent && !parent->isShadowRoot() ? parent : nullptr;
+}
+
+template <typename Strategy>
+static Node* parentEditingBoundary(const PositionAlgorithm<Strategy>& position)
+{
+ Node* const anchorNode = position.anchorNode();
+ if (!anchorNode)
+ return nullptr;
+
+ Node* documentElement = anchorNode->document().documentElement();
+ if (!documentElement)
+ return nullptr;
+
+ Node* boundary = position.computeContainerNode();
+ while (boundary != documentElement && nonShadowBoundaryParentNode<Strategy>(boundary) && anchorNode->hasEditableStyle() == Strategy::parent(*boundary)->hasEditableStyle())
+ boundary = nonShadowBoundaryParentNode<Strategy>(boundary);
+
+ return boundary;
+}
enum BoundarySearchContextAvailability { DontHaveMoreContext, MayHaveMoreContext };
« no previous file with comments | « Source/core/editing/Position.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698