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

Side by Side Diff: third_party/WebKit/Source/core/dom/LayoutTreeBuilderTraversal.h

Issue 2725953002: Refactor LayoutTreeBuilderTraversal to expose a cleaner interface to layout sibling nodes. (Closed)
Patch Set: Refactor LayoutTreeBuilderTraversal to expose a cleaner interface to layout sibling nodes. Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/LayoutTreeBuilderTraversal.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 19 matching lines...) Expand all
30 #include "core/CoreExport.h" 30 #include "core/CoreExport.h"
31 #include "core/dom/Element.h" 31 #include "core/dom/Element.h"
32 #include "core/dom/shadow/InsertionPoint.h" 32 #include "core/dom/shadow/InsertionPoint.h"
33 #include <cstdint> 33 #include <cstdint>
34 34
35 namespace blink { 35 namespace blink {
36 36
37 class LayoutObject; 37 class LayoutObject;
38 38
39 class CORE_EXPORT LayoutTreeBuilderTraversal { 39 class CORE_EXPORT LayoutTreeBuilderTraversal {
40 static Node* nextLayoutSibling(const Node&, int32_t& limit);
41 static Node* previousLayoutSibling(const Node&, int32_t& limit);
rune 2017/03/10 12:32:41 I'd put these in a private section below the publi
42
40 public: 43 public:
41 static const int32_t kTraverseAllSiblings = -2; 44 static const int32_t kTraverseAllSiblings = -2;
42 class ParentDetails { 45 class ParentDetails {
43 STACK_ALLOCATED(); 46 STACK_ALLOCATED();
44 47
45 public: 48 public:
46 ParentDetails() : m_insertionPoint(nullptr) {} 49 ParentDetails() : m_insertionPoint(nullptr) {}
47 50
48 const InsertionPoint* insertionPoint() const { return m_insertionPoint; } 51 const InsertionPoint* insertionPoint() const { return m_insertionPoint; }
49 52
50 void didTraverseInsertionPoint(const InsertionPoint*); 53 void didTraverseInsertionPoint(const InsertionPoint*);
51 54
52 bool operator==(const ParentDetails& other) { 55 bool operator==(const ParentDetails& other) {
53 return m_insertionPoint == other.m_insertionPoint; 56 return m_insertionPoint == other.m_insertionPoint;
54 } 57 }
55 58
56 private: 59 private:
57 Member<const InsertionPoint> m_insertionPoint; 60 Member<const InsertionPoint> m_insertionPoint;
58 }; 61 };
59 62
60 static ContainerNode* parent(const Node&, ParentDetails* = nullptr); 63 static ContainerNode* parent(const Node&, ParentDetails* = nullptr);
61 static ContainerNode* layoutParent(const Node&, ParentDetails* = nullptr); 64 static ContainerNode* layoutParent(const Node&, ParentDetails* = nullptr);
62 static Node* firstChild(const Node&); 65 static Node* firstChild(const Node&);
63 static Node* nextSibling(const Node&); 66 static Node* nextSibling(const Node&);
67 static Node* nextLayoutSibling(const Node& node) {
68 int32_t limit = kTraverseAllSiblings;
69 return nextLayoutSibling(node, limit);
70 }
71 static Node* previousLayoutSibling(const Node& node) {
72 int32_t limit = kTraverseAllSiblings;
73 return previousLayoutSibling(node, limit);
74 }
64 static Node* previousSibling(const Node&); 75 static Node* previousSibling(const Node&);
65 static Node* previous(const Node&, const Node* stayWithin); 76 static Node* previous(const Node&, const Node* stayWithin);
66 static Node* next(const Node&, const Node* stayWithin); 77 static Node* next(const Node&, const Node* stayWithin);
67 static Node* nextSkippingChildren(const Node&, const Node* stayWithin); 78 static Node* nextSkippingChildren(const Node&, const Node* stayWithin);
68 static LayoutObject* parentLayoutObject(const Node&); 79 static LayoutObject* parentLayoutObject(const Node&);
69 static LayoutObject* nextSiblingLayoutObject( 80 static LayoutObject* nextSiblingLayoutObject(
70 const Node&, 81 const Node&,
71 int32_t limit = kTraverseAllSiblings); 82 int32_t limit = kTraverseAllSiblings);
72 static LayoutObject* previousSiblingLayoutObject( 83 static LayoutObject* previousSiblingLayoutObject(
73 const Node&, 84 const Node&,
74 int32_t limit = kTraverseAllSiblings); 85 int32_t limit = kTraverseAllSiblings);
75 static LayoutObject* nextInTopLayer(const Element&); 86 static LayoutObject* nextInTopLayer(const Element&);
76 87
77 static inline Element* parentElement(const Node& node) { 88 static inline Element* parentElement(const Node& node) {
78 ContainerNode* found = parent(node); 89 ContainerNode* found = parent(node);
79 return found && found->isElementNode() ? toElement(found) : 0; 90 return found && found->isElementNode() ? toElement(found) : 0;
80 } 91 }
81 }; 92 };
82 93
83 } // namespace blink 94 } // namespace blink
84 95
85 #endif 96 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/LayoutTreeBuilderTraversal.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698