| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 { | 37 { |
| 38 if (node && node->isElementNode()) | 38 if (node && node->isElementNode()) |
| 39 return toElement(node)->shadow(); | 39 return toElement(node)->shadow(); |
| 40 return 0; | 40 return 0; |
| 41 } | 41 } |
| 42 | 42 |
| 43 Node* ComposedTreeWalker::traverseChild(const Node* node, TraversalDirection dir
ection) const | 43 Node* ComposedTreeWalker::traverseChild(const Node* node, TraversalDirection dir
ection) const |
| 44 { | 44 { |
| 45 ASSERT(node); | 45 ASSERT(node); |
| 46 ElementShadow* shadow = shadowFor(node); | 46 ElementShadow* shadow = shadowFor(node); |
| 47 return shadow ? traverseLightChildren(shadow->youngestShadowRoot(), directio
n) | 47 return shadow ? traverseLightChildren(shadow->shadowRoot(), direction) |
| 48 : traverseLightChildren(node, direction); | 48 : traverseLightChildren(node, direction); |
| 49 } | 49 } |
| 50 | 50 |
| 51 Node* ComposedTreeWalker::traverseLightChildren(const Node* node, TraversalDirec
tion direction) | 51 Node* ComposedTreeWalker::traverseLightChildren(const Node* node, TraversalDirec
tion direction) |
| 52 { | 52 { |
| 53 ASSERT(node); | 53 ASSERT(node); |
| 54 return traverseSiblings(direction == TraversalDirectionForward ? node->first
Child() : node->lastChild(), direction); | 54 return traverseSiblings(direction == TraversalDirectionForward ? node->first
Child() : node->lastChild(), direction); |
| 55 } | 55 } |
| 56 | 56 |
| 57 Node* ComposedTreeWalker::traverseSiblings(const Node* node, TraversalDirection
direction) | 57 Node* ComposedTreeWalker::traverseSiblings(const Node* node, TraversalDirection
direction) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 if (Node* found = traverseDistributedNodes(direction == TraversalDirectionFo
rward ? insertionPoint->nextTo(node) : insertionPoint->previousTo(node), inserti
onPoint, direction)) | 98 if (Node* found = traverseDistributedNodes(direction == TraversalDirectionFo
rward ? insertionPoint->nextTo(node) : insertionPoint->previousTo(node), inserti
onPoint, direction)) |
| 99 return found; | 99 return found; |
| 100 return traverseSiblingOrBackToInsertionPoint(insertionPoint, direction); | 100 return traverseSiblingOrBackToInsertionPoint(insertionPoint, direction); |
| 101 } | 101 } |
| 102 | 102 |
| 103 Node* ComposedTreeWalker::traverseSiblingInCurrentTree(const Node* node, Travers
alDirection direction) | 103 Node* ComposedTreeWalker::traverseSiblingInCurrentTree(const Node* node, Travers
alDirection direction) |
| 104 { | 104 { |
| 105 ASSERT(node); | 105 ASSERT(node); |
| 106 if (Node* found = traverseSiblings(direction == TraversalDirectionForward ?
node->nextSibling() : node->previousSibling(), direction)) | 106 if (Node* found = traverseSiblings(direction == TraversalDirectionForward ?
node->nextSibling() : node->previousSibling(), direction)) |
| 107 return found; | 107 return found; |
| 108 if (Node* next = traverseBackToYoungerShadowRoot(node, direction)) | |
| 109 return next; | |
| 110 return 0; | 108 return 0; |
| 111 } | 109 } |
| 112 | 110 |
| 113 Node* ComposedTreeWalker::traverseBackToYoungerShadowRoot(const Node* node, Trav
ersalDirection direction) | |
| 114 { | |
| 115 // FIXME(sky): Remove this. | |
| 116 return 0; | |
| 117 } | |
| 118 | |
| 119 // FIXME: Use an iterative algorithm so that it can be inlined. | 111 // FIXME: Use an iterative algorithm so that it can be inlined. |
| 120 // https://bugs.webkit.org/show_bug.cgi?id=90415 | 112 // https://bugs.webkit.org/show_bug.cgi?id=90415 |
| 121 Node* ComposedTreeWalker::traverseParent(const Node* node, ParentTraversalDetail
s* details) const | 113 Node* ComposedTreeWalker::traverseParent(const Node* node, ParentTraversalDetail
s* details) const |
| 122 { | 114 { |
| 123 if (shadowWhereNodeCanBeDistributed(*node)) { | 115 if (shadowWhereNodeCanBeDistributed(*node)) { |
| 124 if (const InsertionPoint* insertionPoint = resolveReprojection(node)) { | 116 if (const InsertionPoint* insertionPoint = resolveReprojection(node)) { |
| 125 if (details) | 117 if (details) |
| 126 details->didTraverseInsertionPoint(insertionPoint); | 118 details->didTraverseInsertionPoint(insertionPoint); |
| 127 // The node is distributed. But the distribution was stopped at this
insertion point. | 119 // The node is distributed. But the distribution was stopped at this
insertion point. |
| 128 if (shadowWhereNodeCanBeDistributed(*insertionPoint)) | 120 if (shadowWhereNodeCanBeDistributed(*insertionPoint)) |
| 129 return 0; | 121 return 0; |
| 130 return traverseParentOrHost(insertionPoint); | 122 return traverseParentOrHost(insertionPoint); |
| 131 } | 123 } |
| 132 return 0; | 124 return 0; |
| 133 } | 125 } |
| 134 return traverseParentOrHost(node); | 126 return traverseParentOrHost(node); |
| 135 } | 127 } |
| 136 | 128 |
| 137 inline Node* ComposedTreeWalker::traverseParentOrHost(const Node* node) const | 129 inline Node* ComposedTreeWalker::traverseParentOrHost(const Node* node) const |
| 138 { | 130 { |
| 139 Node* parent = node->parentNode(); | 131 Node* parent = node->parentNode(); |
| 140 if (!parent) | 132 if (!parent) |
| 141 return 0; | 133 return 0; |
| 142 if (!parent->isShadowRoot()) | 134 if (!parent->isShadowRoot()) |
| 143 return parent; | 135 return parent; |
| 144 ShadowRoot* shadowRoot = toShadowRoot(parent); | 136 ShadowRoot* shadowRoot = toShadowRoot(parent); |
| 145 if (!shadowRoot->isYoungest()) | |
| 146 return 0; | |
| 147 return shadowRoot->host(); | 137 return shadowRoot->host(); |
| 148 } | 138 } |
| 149 | 139 |
| 150 } // namespace | 140 } // namespace |
| OLD | NEW |