OLD | NEW |
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 private: | 67 private: |
68 ComposedTreeWalker(const Node*, ParentTraversalDetails*); | 68 ComposedTreeWalker(const Node*, ParentTraversalDetails*); |
69 | 69 |
70 enum TraversalDirection { | 70 enum TraversalDirection { |
71 TraversalDirectionForward, | 71 TraversalDirectionForward, |
72 TraversalDirectionBackward | 72 TraversalDirectionBackward |
73 }; | 73 }; |
74 | 74 |
75 void assertPrecondition() const | 75 void assertPrecondition() const |
76 { | 76 { |
77 #ifndef NDEBUG | 77 #if ENABLE(ASSERT) |
78 ASSERT(m_node); | 78 ASSERT(m_node); |
79 ASSERT(!m_node->isShadowRoot()); | 79 ASSERT(!m_node->isShadowRoot()); |
80 ASSERT(!isActiveInsertionPoint(*m_node)); | 80 ASSERT(!isActiveInsertionPoint(*m_node)); |
81 #endif | 81 #endif |
82 } | 82 } |
83 | 83 |
84 void assertPostcondition() const | 84 void assertPostcondition() const |
85 { | 85 { |
86 #ifndef NDEBUG | 86 #if ENABLE(ASSERT) |
87 if (m_node) | 87 if (m_node) |
88 assertPrecondition(); | 88 assertPrecondition(); |
89 #endif | 89 #endif |
90 } | 90 } |
91 | 91 |
92 static Node* traverseNode(const Node*, TraversalDirection); | 92 static Node* traverseNode(const Node*, TraversalDirection); |
93 static Node* traverseLightChildren(const Node*, TraversalDirection); | 93 static Node* traverseLightChildren(const Node*, TraversalDirection); |
94 | 94 |
95 Node* traverseFirstChild(const Node*) const; | 95 Node* traverseFirstChild(const Node*) const; |
96 Node* traverseLastChild(const Node*) const; | 96 Node* traverseLastChild(const Node*) const; |
(...skipping 11 matching lines...) Expand all Loading... |
108 static Node* traverseBackToYoungerShadowRoot(const Node*, TraversalDirection
); | 108 static Node* traverseBackToYoungerShadowRoot(const Node*, TraversalDirection
); |
109 | 109 |
110 Node* traverseParentOrHost(const Node*) const; | 110 Node* traverseParentOrHost(const Node*) const; |
111 | 111 |
112 RawPtrWillBeMember<const Node> m_node; | 112 RawPtrWillBeMember<const Node> m_node; |
113 }; | 113 }; |
114 | 114 |
115 inline ComposedTreeWalker::ComposedTreeWalker(const Node* node, StartPolicy star
tPolicy) | 115 inline ComposedTreeWalker::ComposedTreeWalker(const Node* node, StartPolicy star
tPolicy) |
116 : m_node(node) | 116 : m_node(node) |
117 { | 117 { |
118 #ifndef NDEBUG | 118 #if ENABLE(ASSERT) |
119 if (m_node && startPolicy == CannotStartFromShadowBoundary) | 119 if (m_node && startPolicy == CannotStartFromShadowBoundary) |
120 assertPrecondition(); | 120 assertPrecondition(); |
121 #endif | 121 #endif |
122 } | 122 } |
123 | 123 |
124 inline void ComposedTreeWalker::parent() | 124 inline void ComposedTreeWalker::parent() |
125 { | 125 { |
126 assertPrecondition(); | 126 assertPrecondition(); |
127 m_node = traverseParent(m_node); | 127 m_node = traverseParent(m_node); |
128 assertPostcondition(); | 128 assertPostcondition(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 206 |
207 inline Node* ComposedTreeWalker::traverseLastChild(const Node* node) const | 207 inline Node* ComposedTreeWalker::traverseLastChild(const Node* node) const |
208 { | 208 { |
209 ASSERT(node); | 209 ASSERT(node); |
210 return traverseChild(node, TraversalDirectionBackward); | 210 return traverseChild(node, TraversalDirectionBackward); |
211 } | 211 } |
212 | 212 |
213 } // namespace | 213 } // namespace |
214 | 214 |
215 #endif | 215 #endif |
OLD | NEW |