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 10 matching lines...) Expand all Loading... |
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #include "core/dom/LayoutTreeBuilderTraversal.h" | 27 #include "core/dom/LayoutTreeBuilderTraversal.h" |
28 | 28 |
29 #include "core/HTMLNames.h" | 29 #include "core/HTMLNames.h" |
30 #include "core/dom/PseudoElement.h" | 30 #include "core/dom/PseudoElement.h" |
31 #include "core/dom/shadow/ComposedTreeTraversal.h" | 31 #include "core/dom/shadow/FlatTreeTraversal.h" |
32 #include "core/layout/LayoutObject.h" | 32 #include "core/layout/LayoutObject.h" |
33 | 33 |
34 namespace blink { | 34 namespace blink { |
35 | 35 |
36 namespace LayoutTreeBuilderTraversal { | 36 namespace LayoutTreeBuilderTraversal { |
37 | 37 |
38 static bool isLayoutObjectReparented(const LayoutObject* layoutObject) | 38 static bool isLayoutObjectReparented(const LayoutObject* layoutObject) |
39 { | 39 { |
40 if (!layoutObject->node()->isElementNode()) | 40 if (!layoutObject->node()->isElementNode()) |
41 return false; | 41 return false; |
42 if (toElement(layoutObject->node())->isInTopLayer()) | 42 if (toElement(layoutObject->node())->isInTopLayer()) |
43 return true; | 43 return true; |
44 return false; | 44 return false; |
45 } | 45 } |
46 | 46 |
47 void ParentDetails::didTraverseInsertionPoint(const InsertionPoint* insertionPoi
nt) | 47 void ParentDetails::didTraverseInsertionPoint(const InsertionPoint* insertionPoi
nt) |
48 { | 48 { |
49 if (!m_insertionPoint) { | 49 if (!m_insertionPoint) { |
50 m_insertionPoint = insertionPoint; | 50 m_insertionPoint = insertionPoint; |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 ContainerNode* parent(const Node& node, ParentDetails* details) | 54 ContainerNode* parent(const Node& node, ParentDetails* details) |
55 { | 55 { |
56 // TODO(hayato): Uncomment this once we can be sure LayoutTreeBuilderTravers
al::parent() is used only for a node in a document. | 56 // TODO(hayato): Uncomment this once we can be sure LayoutTreeBuilderTravers
al::parent() is used only for a node in a document. |
57 // ASSERT(node.inDocument()); | 57 // ASSERT(node.inDocument()); |
58 return ComposedTreeTraversal::parent(node, details); | 58 return FlatTreeTraversal::parent(node, details); |
59 } | 59 } |
60 | 60 |
61 Node* nextSibling(const Node& node) | 61 Node* nextSibling(const Node& node) |
62 { | 62 { |
63 if (node.isBeforePseudoElement()) { | 63 if (node.isBeforePseudoElement()) { |
64 if (Node* next = ComposedTreeTraversal::firstChild(*ComposedTreeTraversa
l::parent(node))) | 64 if (Node* next = FlatTreeTraversal::firstChild(*FlatTreeTraversal::paren
t(node))) |
65 return next; | 65 return next; |
66 } else { | 66 } else { |
67 if (Node* next = ComposedTreeTraversal::nextSibling(node)) | 67 if (Node* next = FlatTreeTraversal::nextSibling(node)) |
68 return next; | 68 return next; |
69 if (node.isAfterPseudoElement()) | 69 if (node.isAfterPseudoElement()) |
70 return 0; | 70 return 0; |
71 } | 71 } |
72 | 72 |
73 Node* parent = ComposedTreeTraversal::parent(node); | 73 Node* parent = FlatTreeTraversal::parent(node); |
74 if (parent && parent->isElementNode()) | 74 if (parent && parent->isElementNode()) |
75 return toElement(parent)->pseudoElement(AFTER); | 75 return toElement(parent)->pseudoElement(AFTER); |
76 | 76 |
77 return 0; | 77 return 0; |
78 } | 78 } |
79 | 79 |
80 Node* previousSibling(const Node& node) | 80 Node* previousSibling(const Node& node) |
81 { | 81 { |
82 if (node.isAfterPseudoElement()) { | 82 if (node.isAfterPseudoElement()) { |
83 if (Node* previous = ComposedTreeTraversal::lastChild(*ComposedTreeTrave
rsal::parent(node))) | 83 if (Node* previous = FlatTreeTraversal::lastChild(*FlatTreeTraversal::pa
rent(node))) |
84 return previous; | 84 return previous; |
85 } else { | 85 } else { |
86 if (Node* previous = ComposedTreeTraversal::previousSibling(node)) | 86 if (Node* previous = FlatTreeTraversal::previousSibling(node)) |
87 return previous; | 87 return previous; |
88 if (node.isBeforePseudoElement()) | 88 if (node.isBeforePseudoElement()) |
89 return 0; | 89 return 0; |
90 } | 90 } |
91 | 91 |
92 Node* parent = ComposedTreeTraversal::parent(node); | 92 Node* parent = FlatTreeTraversal::parent(node); |
93 if (parent && parent->isElementNode()) | 93 if (parent && parent->isElementNode()) |
94 return toElement(parent)->pseudoElement(BEFORE); | 94 return toElement(parent)->pseudoElement(BEFORE); |
95 | 95 |
96 return 0; | 96 return 0; |
97 } | 97 } |
98 | 98 |
99 static Node* lastChild(const Node& node) | 99 static Node* lastChild(const Node& node) |
100 { | 100 { |
101 return ComposedTreeTraversal::lastChild(node); | 101 return FlatTreeTraversal::lastChild(node); |
102 } | 102 } |
103 | 103 |
104 static Node* pseudoAwarePreviousSibling(const Node& node) | 104 static Node* pseudoAwarePreviousSibling(const Node& node) |
105 { | 105 { |
106 Node* previousNode = previousSibling(node); | 106 Node* previousNode = previousSibling(node); |
107 Node* parentNode = parent(node); | 107 Node* parentNode = parent(node); |
108 | 108 |
109 if (parentNode && parentNode->isElementNode() && !previousNode) { | 109 if (parentNode && parentNode->isElementNode() && !previousNode) { |
110 if (node.isAfterPseudoElement()) { | 110 if (node.isAfterPseudoElement()) { |
111 if (Node* child = lastChild(*parentNode)) | 111 if (Node* child = lastChild(*parentNode)) |
(...skipping 30 matching lines...) Expand all Loading... |
142 if (Node* previousNode = pseudoAwarePreviousSibling(node)) { | 142 if (Node* previousNode = pseudoAwarePreviousSibling(node)) { |
143 while (Node* previousLastChild = pseudoAwareLastChild(*previousNode)) | 143 while (Node* previousLastChild = pseudoAwareLastChild(*previousNode)) |
144 previousNode = previousLastChild; | 144 previousNode = previousLastChild; |
145 return previousNode; | 145 return previousNode; |
146 } | 146 } |
147 return parent(node); | 147 return parent(node); |
148 } | 148 } |
149 | 149 |
150 Node* firstChild(const Node& node) | 150 Node* firstChild(const Node& node) |
151 { | 151 { |
152 return ComposedTreeTraversal::firstChild(node); | 152 return FlatTreeTraversal::firstChild(node); |
153 } | 153 } |
154 | 154 |
155 static Node* pseudoAwareNextSibling(const Node& node) | 155 static Node* pseudoAwareNextSibling(const Node& node) |
156 { | 156 { |
157 Node* parentNode = parent(node); | 157 Node* parentNode = parent(node); |
158 Node* nextNode = nextSibling(node); | 158 Node* nextNode = nextSibling(node); |
159 | 159 |
160 if (parentNode && parentNode->isElementNode() && !nextNode) { | 160 if (parentNode && parentNode->isElementNode() && !nextNode) { |
161 if (node.isBeforePseudoElement()) { | 161 if (node.isBeforePseudoElement()) { |
162 if (Node* child = firstChild(*parentNode)) | 162 if (Node* child = firstChild(*parentNode)) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 for (size_t i = position + 1; i < topLayerElements.size(); ++i) { | 243 for (size_t i = position + 1; i < topLayerElements.size(); ++i) { |
244 if (LayoutObject* layoutObject = topLayerElements[i]->layoutObject()) | 244 if (LayoutObject* layoutObject = topLayerElements[i]->layoutObject()) |
245 return layoutObject; | 245 return layoutObject; |
246 } | 246 } |
247 return 0; | 247 return 0; |
248 } | 248 } |
249 | 249 |
250 } // namespace LayoutTreeBuilderTraversal | 250 } // namespace LayoutTreeBuilderTraversal |
251 | 251 |
252 } // namespace blink | 252 } // namespace blink |
OLD | NEW |