Chromium Code Reviews| 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 |
| 11 * contributors may be used to endorse or promote products derived from | 11 * contributors may be used to endorse or promote products derived from |
| 12 * this software without specific prior written permission. | 12 * this software without specific prior written permission. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 17 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 17 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 18 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 18 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 20 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 20 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 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 "config.h" | 27 #include "config.h" |
| 28 #include "core/dom/NodeRenderingTraversal.h" | 28 #include "core/dom/LayoutTreeBuilderTraversal.h" |
| 29 | 29 |
| 30 #include "core/HTMLNames.h" | 30 #include "core/HTMLNames.h" |
| 31 #include "core/dom/PseudoElement.h" | 31 #include "core/dom/PseudoElement.h" |
| 32 #include "core/dom/shadow/ComposedTreeTraversal.h" | 32 #include "core/dom/shadow/ComposedTreeTraversal.h" |
| 33 #include "core/layout/LayoutObject.h" | 33 #include "core/layout/LayoutObject.h" |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 namespace NodeRenderingTraversal { | 37 namespace LayoutTreeBuilderTraversal { |
| 38 | 38 |
| 39 static bool isRendererReparented(const LayoutObject* renderer) | 39 static bool isRendererReparented(const LayoutObject* renderer) |
| 40 { | 40 { |
| 41 if (!renderer->node()->isElementNode()) | 41 if (!renderer->node()->isElementNode()) |
| 42 return false; | 42 return false; |
| 43 if (toElement(renderer->node())->isInTopLayer()) | 43 if (toElement(renderer->node())->isInTopLayer()) |
| 44 return true; | 44 return true; |
| 45 return false; | 45 return false; |
| 46 } | 46 } |
| 47 | 47 |
| 48 void ParentDetails::didTraverseInsertionPoint(const InsertionPoint* insertionPoi nt) | 48 void ParentDetails::didTraverseInsertionPoint(const InsertionPoint* insertionPoi nt) |
| 49 { | 49 { |
| 50 if (!m_insertionPoint) { | 50 if (!m_insertionPoint) { |
| 51 m_insertionPoint = insertionPoint; | 51 m_insertionPoint = insertionPoint; |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 ContainerNode* parent(const Node& node, ParentDetails* details) | 55 ContainerNode* parent(const Node& node, ParentDetails* details) |
| 56 { | 56 { |
| 57 // TODO(hayato): Uncomment this once we can be sure NodeRenderingTraversal i s used only for a node in a document. | 57 ASSERT(node.inDocument() ? !node.document().childNeedsDistributionRecalc() : !node.childNeedsDistributionRecalc()); |
|
hayato
2015/04/15 10:36:11
Looks this is the result of wrong rebase, which is
| |
| 58 // ASSERT(node.inDocument()); | 58 ASSERT(!node.isShadowRoot()); |
| 59 if (isActiveInsertionPoint(node)) | |
| 60 return 0; | |
| 59 return ComposedTreeTraversal::parent(node, details); | 61 return ComposedTreeTraversal::parent(node, details); |
| 60 } | 62 } |
| 61 | 63 |
| 62 bool contains(const ContainerNode& container, const Node& node) | 64 bool contains(const ContainerNode& container, const Node& node) |
| 63 { | 65 { |
| 64 for (const Node* current = &node; current; current = NodeRenderingTraversal: :parent(*current)) { | 66 for (const Node* current = &node; current; current = LayoutTreeBuilderTraver sal::parent(*current)) { |
| 65 if (current == &container) | 67 if (current == &container) |
| 66 return true; | 68 return true; |
| 67 } | 69 } |
| 68 return false; | 70 return false; |
| 69 } | 71 } |
| 70 | 72 |
| 71 Node* nextSibling(const Node& node) | 73 Node* nextSibling(const Node& node) |
| 72 { | 74 { |
| 73 if (node.isBeforePseudoElement()) { | 75 if (node.isBeforePseudoElement()) { |
| 74 if (Node* next = ComposedTreeTraversal::firstChild(*ComposedTreeTraversa l::parent(node))) | 76 if (Node* next = ComposedTreeTraversal::firstChild(*ComposedTreeTraversa l::parent(node))) |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 | 220 |
| 219 Node* next(const Node& node, const Node* stayWithin) | 221 Node* next(const Node& node, const Node* stayWithin) |
| 220 { | 222 { |
| 221 if (Node* child = pseudoAwareFirstChild(node)) | 223 if (Node* child = pseudoAwareFirstChild(node)) |
| 222 return child; | 224 return child; |
| 223 return nextSkippingChildren(node, stayWithin); | 225 return nextSkippingChildren(node, stayWithin); |
| 224 } | 226 } |
| 225 | 227 |
| 226 LayoutObject* nextSiblingRenderer(const Node& node) | 228 LayoutObject* nextSiblingRenderer(const Node& node) |
| 227 { | 229 { |
| 228 for (Node* sibling = NodeRenderingTraversal::nextSibling(node); sibling; sib ling = NodeRenderingTraversal::nextSibling(*sibling)) { | 230 for (Node* sibling = LayoutTreeBuilderTraversal::nextSibling(node); sibling; sibling = LayoutTreeBuilderTraversal::nextSibling(*sibling)) { |
| 229 LayoutObject* renderer = sibling->layoutObject(); | 231 LayoutObject* renderer = sibling->layoutObject(); |
| 230 if (renderer && !isRendererReparented(renderer)) | 232 if (renderer && !isRendererReparented(renderer)) |
| 231 return renderer; | 233 return renderer; |
| 232 } | 234 } |
| 233 return 0; | 235 return 0; |
| 234 } | 236 } |
| 235 | 237 |
| 236 LayoutObject* previousSiblingRenderer(const Node& node) | 238 LayoutObject* previousSiblingRenderer(const Node& node) |
| 237 { | 239 { |
| 238 for (Node* sibling = NodeRenderingTraversal::previousSibling(node); sibling; sibling = NodeRenderingTraversal::previousSibling(*sibling)) { | 240 for (Node* sibling = LayoutTreeBuilderTraversal::previousSibling(node); sibl ing; sibling = LayoutTreeBuilderTraversal::previousSibling(*sibling)) { |
| 239 LayoutObject* renderer = sibling->layoutObject(); | 241 LayoutObject* renderer = sibling->layoutObject(); |
| 240 if (renderer && !isRendererReparented(renderer)) | 242 if (renderer && !isRendererReparented(renderer)) |
| 241 return renderer; | 243 return renderer; |
| 242 } | 244 } |
| 243 return 0; | 245 return 0; |
| 244 } | 246 } |
| 245 | 247 |
| 246 LayoutObject* nextInTopLayer(const Element& element) | 248 LayoutObject* nextInTopLayer(const Element& element) |
| 247 { | 249 { |
| 248 if (!element.isInTopLayer()) | 250 if (!element.isInTopLayer()) |
| 249 return 0; | 251 return 0; |
| 250 const WillBeHeapVector<RefPtrWillBeMember<Element>>& topLayerElements = elem ent.document().topLayerElements(); | 252 const WillBeHeapVector<RefPtrWillBeMember<Element>>& topLayerElements = elem ent.document().topLayerElements(); |
| 251 size_t position = topLayerElements.find(&element); | 253 size_t position = topLayerElements.find(&element); |
| 252 ASSERT(position != kNotFound); | 254 ASSERT(position != kNotFound); |
| 253 for (size_t i = position + 1; i < topLayerElements.size(); ++i) { | 255 for (size_t i = position + 1; i < topLayerElements.size(); ++i) { |
| 254 if (LayoutObject* renderer = topLayerElements[i]->layoutObject()) | 256 if (LayoutObject* renderer = topLayerElements[i]->layoutObject()) |
| 255 return renderer; | 257 return renderer; |
| 256 } | 258 } |
| 257 return 0; | 259 return 0; |
| 258 } | 260 } |
| 259 | 261 |
| 260 } | 262 } |
| 261 | 263 |
| 262 } // namespace | 264 } // namespace |
| OLD | NEW |