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

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

Issue 1756763002: 2016-03-02T18:53:01 LayoutPosition Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-04-25T19:02:18 Created 4 years, 8 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
Index: third_party/WebKit/Source/core/editing/LayoutTreeTraversal.cpp
diff --git a/third_party/WebKit/Source/core/editing/LayoutTreeTraversal.cpp b/third_party/WebKit/Source/core/editing/LayoutTreeTraversal.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..026f6f7e4e70a7a69c47fd1a8d4115f77eba039b
--- /dev/null
+++ b/third_party/WebKit/Source/core/editing/LayoutTreeTraversal.cpp
@@ -0,0 +1,63 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/editing/LayoutTreeTraversal.h"
+
+#include "core/layout/LayoutObject.h"
+
+namespace blink {
+
+LayoutObject* LayoutTreeTraversal::firstChild(const LayoutObject& layoutObject)
+{
+ return layoutObject.slowFirstChild();
+}
+
+bool LayoutTreeTraversal::hasChildren(const LayoutObject& layoutObject)
+{
+ return firstChild(layoutObject);
+}
+
+LayoutObject* LayoutTreeTraversal::lastChild(const LayoutObject& layoutObject)
+{
+ return layoutObject.slowLastChild();
+}
+
+LayoutObject* LayoutTreeTraversal::nextSibling(const LayoutObject& layoutObject)
+{
+ return layoutObject.nextSibling();
+}
+
+LayoutObject* LayoutTreeTraversal::parent(const LayoutObject& layoutObject)
+{
+ return layoutObject.parent();
+}
+
+LayoutObject* LayoutTreeTraversal::previousSibling(const LayoutObject& layoutObject)
+{
+ return layoutObject.previousSibling();
+}
+
+LayoutObject* LayoutTreeTraversal::next(const LayoutObject& layoutObject)
+{
+ if (LayoutObject* firstChild = LayoutTreeTraversal::firstChild(layoutObject))
+ return firstChild;
+ for (LayoutObject* runner = const_cast<LayoutObject*>(&layoutObject); runner; runner = LayoutTreeTraversal::parent(*runner)) {
+ if (LayoutObject* nextSibling = LayoutTreeTraversal::nextSibling(*runner))
+ return nextSibling;
+ }
+ return nullptr;
+}
+
+LayoutObject* LayoutTreeTraversal::previous(const LayoutObject& layoutObject)
+{
+ if (LayoutObject* previousSibling = LayoutTreeTraversal::previousSibling(layoutObject)) {
+ LayoutObject* result = previousSibling;
+ while (LayoutObject* lastChild = LayoutTreeTraversal::lastChild(*result))
+ result = lastChild;
+ return result;
+ }
+ return LayoutTreeTraversal::parent(layoutObject);
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/editing/LayoutTreeTraversal.h ('k') | third_party/WebKit/Source/core/editing/Position.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698