| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 if (!slot) | 108 if (!slot) |
| 109 return nullptr; | 109 return nullptr; |
| 110 for (HTMLSlotElement* next = slot->assignedSlot(); next; | 110 for (HTMLSlotElement* next = slot->assignedSlot(); next; |
| 111 next = next->assignedSlot()) { | 111 next = next->assignedSlot()) { |
| 112 slot = next; | 112 slot = next; |
| 113 } | 113 } |
| 114 return slot; | 114 return slot; |
| 115 } | 115 } |
| 116 | 116 |
| 117 // TODO(hayato): This may return a wrong result for a node which is not in a | 117 // TODO(hayato): This may return a wrong result for a node which is not in a |
| 118 // document flat tree. See FlatTreeTraversalTest's redistribution test for deta
ils. | 118 // document flat tree. See FlatTreeTraversalTest's redistribution test for |
| 119 // details. |
| 119 Node* FlatTreeTraversal::traverseSiblings(const Node& node, | 120 Node* FlatTreeTraversal::traverseSiblings(const Node& node, |
| 120 TraversalDirection direction) { | 121 TraversalDirection direction) { |
| 121 if (node.isChildOfV1ShadowHost()) | 122 if (node.isChildOfV1ShadowHost()) |
| 122 return traverseSiblingsForV1HostChild(node, direction); | 123 return traverseSiblingsForV1HostChild(node, direction); |
| 123 | 124 |
| 124 if (shadowWhereNodeCanBeDistributedForV0(node)) | 125 if (shadowWhereNodeCanBeDistributedForV0(node)) |
| 125 return traverseSiblingsForV0Distribution(node, direction); | 126 return traverseSiblingsForV0Distribution(node, direction); |
| 126 | 127 |
| 127 if (Node* found = resolveDistributionStartingAt( | 128 if (Node* found = resolveDistributionStartingAt( |
| 128 direction == TraversalDirectionForward ? node.nextSibling() | 129 direction == TraversalDirectionForward ? node.nextSibling() |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 if (Node* found = (direction == TraversalDirectionForward | 170 if (Node* found = (direction == TraversalDirectionForward |
| 170 ? finalDestination->distributedNodeNextTo(&node) | 171 ? finalDestination->distributedNodeNextTo(&node) |
| 171 : finalDestination->distributedNodePreviousTo(&node))) | 172 : finalDestination->distributedNodePreviousTo(&node))) |
| 172 return found; | 173 return found; |
| 173 return traverseSiblings(*finalDestination, direction); | 174 return traverseSiblings(*finalDestination, direction); |
| 174 } | 175 } |
| 175 | 176 |
| 176 ContainerNode* FlatTreeTraversal::traverseParent( | 177 ContainerNode* FlatTreeTraversal::traverseParent( |
| 177 const Node& node, | 178 const Node& node, |
| 178 ParentTraversalDetails* details) { | 179 ParentTraversalDetails* details) { |
| 179 // TODO(hayato): Stop this hack for a pseudo element because a pseudo element
is not a child of its parentOrShadowHostNode() in a flat tree. | 180 // TODO(hayato): Stop this hack for a pseudo element because a pseudo element |
| 181 // is not a child of its parentOrShadowHostNode() in a flat tree. |
| 180 if (node.isPseudoElement()) | 182 if (node.isPseudoElement()) |
| 181 return node.parentOrShadowHostNode(); | 183 return node.parentOrShadowHostNode(); |
| 182 | 184 |
| 183 if (node.isChildOfV1ShadowHost()) { | 185 if (node.isChildOfV1ShadowHost()) { |
| 184 HTMLSlotElement* slot = finalDestinationSlotFor(node); | 186 HTMLSlotElement* slot = finalDestinationSlotFor(node); |
| 185 if (!slot) | 187 if (!slot) |
| 186 return nullptr; | 188 return nullptr; |
| 187 return traverseParent(*slot); | 189 return traverseParent(*slot); |
| 188 } | 190 } |
| 189 | 191 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 202 return traverseParentOrHost(node); | 204 return traverseParentOrHost(node); |
| 203 } | 205 } |
| 204 | 206 |
| 205 ContainerNode* FlatTreeTraversal::traverseParentForV0( | 207 ContainerNode* FlatTreeTraversal::traverseParentForV0( |
| 206 const Node& node, | 208 const Node& node, |
| 207 ParentTraversalDetails* details) { | 209 ParentTraversalDetails* details) { |
| 208 if (shadowWhereNodeCanBeDistributedForV0(node)) { | 210 if (shadowWhereNodeCanBeDistributedForV0(node)) { |
| 209 if (const InsertionPoint* insertionPoint = resolveReprojection(&node)) { | 211 if (const InsertionPoint* insertionPoint = resolveReprojection(&node)) { |
| 210 if (details) | 212 if (details) |
| 211 details->didTraverseInsertionPoint(insertionPoint); | 213 details->didTraverseInsertionPoint(insertionPoint); |
| 212 // The node is distributed. But the distribution was stopped at this inser
tion point. | 214 // The node is distributed. But the distribution was stopped at this |
| 215 // insertion point. |
| 213 if (shadowWhereNodeCanBeDistributedForV0(*insertionPoint)) | 216 if (shadowWhereNodeCanBeDistributedForV0(*insertionPoint)) |
| 214 return nullptr; | 217 return nullptr; |
| 215 return traverseParent(*insertionPoint); | 218 return traverseParent(*insertionPoint); |
| 216 } | 219 } |
| 217 return nullptr; | 220 return nullptr; |
| 218 } | 221 } |
| 219 ContainerNode* parent = traverseParentOrHost(node); | 222 ContainerNode* parent = traverseParentOrHost(node); |
| 220 if (isActiveInsertionPoint(*parent)) | 223 if (isActiveInsertionPoint(*parent)) |
| 221 return nullptr; | 224 return nullptr; |
| 222 return parent; | 225 return parent; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 378 |
| 376 Node& FlatTreeTraversal::lastWithinOrSelf(const Node& node) { | 379 Node& FlatTreeTraversal::lastWithinOrSelf(const Node& node) { |
| 377 assertPrecondition(node); | 380 assertPrecondition(node); |
| 378 Node* lastDescendant = lastWithin(node); | 381 Node* lastDescendant = lastWithin(node); |
| 379 Node& result = lastDescendant ? *lastDescendant : const_cast<Node&>(node); | 382 Node& result = lastDescendant ? *lastDescendant : const_cast<Node&>(node); |
| 380 assertPostcondition(&result); | 383 assertPostcondition(&result); |
| 381 return result; | 384 return result; |
| 382 } | 385 } |
| 383 | 386 |
| 384 } // namespace blink | 387 } // namespace blink |
| OLD | NEW |