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

Unified Diff: sky/engine/core/dom/NodeRenderingTraversal.cpp

Issue 693243002: Remove interactive content and form related API from HTMLElement. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 2 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 | « sky/engine/core/dom/NodeRenderingTraversal.h ('k') | sky/engine/core/html/HTMLAnchorElement.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/dom/NodeRenderingTraversal.cpp
diff --git a/sky/engine/core/dom/NodeRenderingTraversal.cpp b/sky/engine/core/dom/NodeRenderingTraversal.cpp
index 1b2fe5ff4c0985188b93467e6b7febc982cfdfb2..b1dda328f31df8cf35b95708ab95852f31455d1f 100644
--- a/sky/engine/core/dom/NodeRenderingTraversal.cpp
+++ b/sky/engine/core/dom/NodeRenderingTraversal.cpp
@@ -137,6 +137,43 @@ RenderObject* previousSiblingRenderer(const Node* node)
return 0;
}
+Node* commonAncestor(Node& a, Node& b)
+{
+ if (a == b)
+ return &a;
+ if (a.document() != b.document())
+ return 0;
+ int thisDepth = 0;
+ for (Node* node = &a; node; node = parent(node)) {
+ if (node == b)
+ return node;
+ thisDepth++;
+ }
+ int otherDepth = 0;
+ for (const Node* node = &b; node; node = parent(node)) {
+ if (node == a)
+ return &a;
+ otherDepth++;
+ }
+ Node* thisIterator = &a;
+ const Node* otherIterator = &b;
+ if (thisDepth > otherDepth) {
+ for (int i = thisDepth; i > otherDepth; --i)
+ thisIterator = parent(thisIterator);
+ } else if (otherDepth > thisDepth) {
+ for (int i = otherDepth; i > thisDepth; --i)
+ otherIterator = parent(otherIterator);
+ }
+ while (thisIterator) {
+ if (thisIterator == otherIterator)
+ return thisIterator;
+ thisIterator = parent(thisIterator);
+ otherIterator = parent(otherIterator);
+ }
+ ASSERT(!otherIterator);
+ return 0;
+}
+
}
} // namespace
« no previous file with comments | « sky/engine/core/dom/NodeRenderingTraversal.h ('k') | sky/engine/core/html/HTMLAnchorElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698