| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 return slot; | 96 return slot; |
| 97 } | 97 } |
| 98 | 98 |
| 99 // TODO(hayato): This may return a wrong result for a node which is not in a | 99 // TODO(hayato): This may return a wrong result for a node which is not in a |
| 100 // document flat tree. See FlatTreeTraversalTest's redistribution test for deta
ils. | 100 // document flat tree. See FlatTreeTraversalTest's redistribution test for deta
ils. |
| 101 Node* FlatTreeTraversal::traverseSiblings(const Node& node, TraversalDirection d
irection) | 101 Node* FlatTreeTraversal::traverseSiblings(const Node& node, TraversalDirection d
irection) |
| 102 { | 102 { |
| 103 if (node.isChildOfV1ShadowHost()) | 103 if (node.isChildOfV1ShadowHost()) |
| 104 return traverseSiblingsForV1HostChild(node, direction); | 104 return traverseSiblingsForV1HostChild(node, direction); |
| 105 | 105 |
| 106 if (shadowWhereNodeCanBeDistributed(node)) | 106 if (shadowWhereNodeCanBeDistributedForV0(node)) |
| 107 return traverseSiblingsForV0Distribution(node, direction); | 107 return traverseSiblingsForV0Distribution(node, direction); |
| 108 | 108 |
| 109 if (Node* found = resolveDistributionStartingAt(direction == TraversalDirect
ionForward ? node.nextSibling() : node.previousSibling(), direction)) | 109 if (Node* found = resolveDistributionStartingAt(direction == TraversalDirect
ionForward ? node.nextSibling() : node.previousSibling(), direction)) |
| 110 return found; | 110 return found; |
| 111 | 111 |
| 112 if (!node.isInV0ShadowTree()) | 112 if (!node.isInV0ShadowTree()) |
| 113 return nullptr; | 113 return nullptr; |
| 114 | 114 |
| 115 // For v0 older shadow tree | 115 // For v0 older shadow tree |
| 116 if (node.parentNode() && node.parentNode()->isShadowRoot()) { | 116 if (node.parentNode() && node.parentNode()->isShadowRoot()) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 if (parent && isHTMLSlotElement(parent)) { | 162 if (parent && isHTMLSlotElement(parent)) { |
| 163 HTMLSlotElement& slot = toHTMLSlotElement(*parent); | 163 HTMLSlotElement& slot = toHTMLSlotElement(*parent); |
| 164 if (!slot.assignedNodes().isEmpty()) | 164 if (!slot.assignedNodes().isEmpty()) |
| 165 return nullptr; | 165 return nullptr; |
| 166 return traverseParent(slot, details); | 166 return traverseParent(slot, details); |
| 167 } | 167 } |
| 168 | 168 |
| 169 if (canBeDistributedToInsertionPoint(node)) | 169 if (canBeDistributedToInsertionPoint(node)) |
| 170 return traverseParentForV0(node, details); | 170 return traverseParentForV0(node, details); |
| 171 | 171 |
| 172 DCHECK(!shadowWhereNodeCanBeDistributed(node)); | 172 DCHECK(!shadowWhereNodeCanBeDistributedForV0(node)); |
| 173 return traverseParentOrHost(node); | 173 return traverseParentOrHost(node); |
| 174 } | 174 } |
| 175 | 175 |
| 176 ContainerNode* FlatTreeTraversal::traverseParentForV0(const Node& node, ParentTr
aversalDetails* details) | 176 ContainerNode* FlatTreeTraversal::traverseParentForV0(const Node& node, ParentTr
aversalDetails* details) |
| 177 { | 177 { |
| 178 if (shadowWhereNodeCanBeDistributed(node)) { | 178 if (shadowWhereNodeCanBeDistributedForV0(node)) { |
| 179 if (const InsertionPoint* insertionPoint = resolveReprojection(&node)) { | 179 if (const InsertionPoint* insertionPoint = resolveReprojection(&node)) { |
| 180 if (details) | 180 if (details) |
| 181 details->didTraverseInsertionPoint(insertionPoint); | 181 details->didTraverseInsertionPoint(insertionPoint); |
| 182 // The node is distributed. But the distribution was stopped at this
insertion point. | 182 // The node is distributed. But the distribution was stopped at this
insertion point. |
| 183 if (shadowWhereNodeCanBeDistributed(*insertionPoint)) | 183 if (shadowWhereNodeCanBeDistributedForV0(*insertionPoint)) |
| 184 return nullptr; | 184 return nullptr; |
| 185 return traverseParent(*insertionPoint); | 185 return traverseParent(*insertionPoint); |
| 186 } | 186 } |
| 187 return nullptr; | 187 return nullptr; |
| 188 } | 188 } |
| 189 ContainerNode* parent = traverseParentOrHost(node); | 189 ContainerNode* parent = traverseParentOrHost(node); |
| 190 if (isActiveInsertionPoint(*parent)) | 190 if (isActiveInsertionPoint(*parent)) |
| 191 return nullptr; | 191 return nullptr; |
| 192 return parent; | 192 return parent; |
| 193 } | 193 } |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 Node& FlatTreeTraversal::lastWithinOrSelf(const Node& node) | 352 Node& FlatTreeTraversal::lastWithinOrSelf(const Node& node) |
| 353 { | 353 { |
| 354 assertPrecondition(node); | 354 assertPrecondition(node); |
| 355 Node* lastDescendant = lastWithin(node); | 355 Node* lastDescendant = lastWithin(node); |
| 356 Node& result = lastDescendant ? *lastDescendant : const_cast<Node&>(node); | 356 Node& result = lastDescendant ? *lastDescendant : const_cast<Node&>(node); |
| 357 assertPostcondition(&result); | 357 assertPostcondition(&result); |
| 358 return result; | 358 return result; |
| 359 } | 359 } |
| 360 | 360 |
| 361 } // namespace blink | 361 } // namespace blink |
| OLD | NEW |