| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
| 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 7 * Copyright (C) 2011 Google Inc. All rights reserved. | 7 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "platform/RuntimeEnabledFeatures.h" | 42 #include "platform/RuntimeEnabledFeatures.h" |
| 43 | 43 |
| 44 namespace blink { | 44 namespace blink { |
| 45 | 45 |
| 46 LayoutTreeBuilderForElement::LayoutTreeBuilderForElement(Element& element, Layou
tStyle* style) | 46 LayoutTreeBuilderForElement::LayoutTreeBuilderForElement(Element& element, Layou
tStyle* style) |
| 47 : LayoutTreeBuilder(element, nullptr) | 47 : LayoutTreeBuilder(element, nullptr) |
| 48 , m_style(style) | 48 , m_style(style) |
| 49 { | 49 { |
| 50 if (element.isFirstLetterPseudoElement()) { | 50 if (element.isFirstLetterPseudoElement()) { |
| 51 if (LayoutObject* nextRenderer = FirstLetterPseudoElement::firstLetterTe
xtRenderer(element)) | 51 if (LayoutObject* nextRenderer = FirstLetterPseudoElement::firstLetterTe
xtRenderer(element)) |
| 52 m_renderingParent = nextRenderer->parent(); | 52 m_layoutObjectParent = nextRenderer->parent(); |
| 53 } else if (ContainerNode* containerNode = NodeRenderingTraversal::parent(ele
ment)) { | 53 } else if (ContainerNode* containerNode = NodeRenderingTraversal::parent(ele
ment)) { |
| 54 m_renderingParent = containerNode->renderer(); | 54 m_layoutObjectParent = containerNode->layoutObject(); |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 LayoutObject* LayoutTreeBuilderForElement::nextRenderer() const | 58 LayoutObject* LayoutTreeBuilderForElement::nextRenderer() const |
| 59 { | 59 { |
| 60 ASSERT(m_renderingParent); | 60 ASSERT(m_layoutObjectParent); |
| 61 | 61 |
| 62 if (m_node->isInTopLayer()) | 62 if (m_node->isInTopLayer()) |
| 63 return NodeRenderingTraversal::nextInTopLayer(*m_node); | 63 return NodeRenderingTraversal::nextInTopLayer(*m_node); |
| 64 | 64 |
| 65 if (m_node->isFirstLetterPseudoElement()) | 65 if (m_node->isFirstLetterPseudoElement()) |
| 66 return FirstLetterPseudoElement::firstLetterTextRenderer(*m_node); | 66 return FirstLetterPseudoElement::firstLetterTextRenderer(*m_node); |
| 67 | 67 |
| 68 return LayoutTreeBuilder::nextRenderer(); | 68 return LayoutTreeBuilder::nextRenderer(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 LayoutObject* LayoutTreeBuilderForElement::parentRenderer() const | 71 LayoutObject* LayoutTreeBuilderForElement::parentRenderer() const |
| 72 { | 72 { |
| 73 LayoutObject* parentRenderer = LayoutTreeBuilder::parentRenderer(); | 73 LayoutObject* parentRenderer = LayoutTreeBuilder::parentRenderer(); |
| 74 | 74 |
| 75 if (parentRenderer) { | 75 if (parentRenderer) { |
| 76 // FIXME: Guarding this by parentRenderer isn't quite right as the spec
for | 76 // FIXME: Guarding this by parentRenderer isn't quite right as the spec
for |
| 77 // top layer only talks about display: none ancestors so putting a <dial
og> inside an | 77 // top layer only talks about display: none ancestors so putting a <dial
og> inside an |
| 78 // <optgroup> seems like it should still work even though this check wil
l prevent it. | 78 // <optgroup> seems like it should still work even though this check wil
l prevent it. |
| 79 if (m_node->isInTopLayer()) | 79 if (m_node->isInTopLayer()) |
| 80 return m_node->document().layoutView(); | 80 return m_node->document().layoutView(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 return parentRenderer; | 83 return parentRenderer; |
| 84 } | 84 } |
| 85 | 85 |
| 86 bool LayoutTreeBuilderForElement::shouldCreateRenderer() const | 86 bool LayoutTreeBuilderForElement::shouldCreateRenderer() const |
| 87 { | 87 { |
| 88 if (!m_renderingParent) | 88 if (!m_layoutObjectParent) |
| 89 return false; | 89 return false; |
| 90 | 90 |
| 91 // FIXME: Should the following be in SVGElement::layoutObjectIsNeeded()? | 91 // FIXME: Should the following be in SVGElement::layoutObjectIsNeeded()? |
| 92 if (m_node->isSVGElement()) { | 92 if (m_node->isSVGElement()) { |
| 93 // SVG elements only render when inside <svg>, or if the element is an <
svg> itself. | 93 // SVG elements only render when inside <svg>, or if the element is an <
svg> itself. |
| 94 if (!isSVGSVGElement(*m_node) && (!m_renderingParent->node() || !m_rende
ringParent->node()->isSVGElement())) | 94 if (!isSVGSVGElement(*m_node) && (!m_layoutObjectParent->node() || !m_la
youtObjectParent->node()->isSVGElement())) |
| 95 return false; | 95 return false; |
| 96 if (!toSVGElement(m_node)->isValid()) | 96 if (!toSVGElement(m_node)->isValid()) |
| 97 return false; | 97 return false; |
| 98 } | 98 } |
| 99 | 99 |
| 100 LayoutObject* parentRenderer = this->parentRenderer(); | 100 LayoutObject* parentRenderer = this->parentRenderer(); |
| 101 if (!parentRenderer) | 101 if (!parentRenderer) |
| 102 return false; | 102 return false; |
| 103 if (!parentRenderer->canHaveChildren()) | 103 if (!parentRenderer->canHaveChildren()) |
| 104 return false; | 104 return false; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 127 newLayoutObject->destroy(); | 127 newLayoutObject->destroy(); |
| 128 return; | 128 return; |
| 129 } | 129 } |
| 130 | 130 |
| 131 // Make sure the LayoutObject already knows it is going to be added to a Lay
outFlowThread before we set the style | 131 // Make sure the LayoutObject already knows it is going to be added to a Lay
outFlowThread before we set the style |
| 132 // for the first time. Otherwise code using inLayoutFlowThread() in the styl
eWillChange and styleDidChange will fail. | 132 // for the first time. Otherwise code using inLayoutFlowThread() in the styl
eWillChange and styleDidChange will fail. |
| 133 newLayoutObject->setFlowThreadState(parentRenderer->flowThreadState()); | 133 newLayoutObject->setFlowThreadState(parentRenderer->flowThreadState()); |
| 134 | 134 |
| 135 LayoutObject* nextRenderer = this->nextRenderer(); | 135 LayoutObject* nextRenderer = this->nextRenderer(); |
| 136 m_node->setLayoutObject(newLayoutObject); | 136 m_node->setLayoutObject(newLayoutObject); |
| 137 newLayoutObject->setStyle(&style); // setStyle() can depend on renderer() al
ready being set. | 137 newLayoutObject->setStyle(&style); // setStyle() can depend on layoutObject(
) already being set. |
| 138 | 138 |
| 139 if (Fullscreen::isActiveFullScreenElement(*m_node)) { | 139 if (Fullscreen::isActiveFullScreenElement(*m_node)) { |
| 140 newLayoutObject = LayoutFullScreen::wrapRenderer(newLayoutObject, parent
Renderer, &m_node->document()); | 140 newLayoutObject = LayoutFullScreen::wrapRenderer(newLayoutObject, parent
Renderer, &m_node->document()); |
| 141 if (!newLayoutObject) | 141 if (!newLayoutObject) |
| 142 return; | 142 return; |
| 143 } | 143 } |
| 144 | 144 |
| 145 // Note: Adding newLayoutObject instead of renderer(). renderer() may be a c
hild of newLayoutObject. | 145 // Note: Adding newLayoutObject instead of layoutObject(). layoutObject() ma
y be a child of newLayoutObject. |
| 146 parentRenderer->addChild(newLayoutObject, nextRenderer); | 146 parentRenderer->addChild(newLayoutObject, nextRenderer); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void LayoutTreeBuilderForText::createLayoutObject() | 149 void LayoutTreeBuilderForText::createLayoutObject() |
| 150 { | 150 { |
| 151 LayoutObject* parentRenderer = this->parentRenderer(); | 151 LayoutObject* parentRenderer = this->parentRenderer(); |
| 152 LayoutStyle* style = parentRenderer->style(); | 152 LayoutStyle* style = parentRenderer->style(); |
| 153 | 153 |
| 154 ASSERT(m_node->textRendererIsNeeded(*style, *parentRenderer)); | 154 ASSERT(m_node->textRendererIsNeeded(*style, *parentRenderer)); |
| 155 | 155 |
| 156 LayoutText* newLayoutObject = m_node->createTextRenderer(style); | 156 LayoutText* newLayoutObject = m_node->createTextRenderer(style); |
| 157 if (!parentRenderer->isChildAllowed(newLayoutObject, *style)) { | 157 if (!parentRenderer->isChildAllowed(newLayoutObject, *style)) { |
| 158 newLayoutObject->destroy(); | 158 newLayoutObject->destroy(); |
| 159 return; | 159 return; |
| 160 } | 160 } |
| 161 | 161 |
| 162 // Make sure the LayoutObject already knows it is going to be added to a Lay
outFlowThread before we set the style | 162 // Make sure the LayoutObject already knows it is going to be added to a Lay
outFlowThread before we set the style |
| 163 // for the first time. Otherwise code using inLayoutFlowThread() in the styl
eWillChange and styleDidChange will fail. | 163 // for the first time. Otherwise code using inLayoutFlowThread() in the styl
eWillChange and styleDidChange will fail. |
| 164 newLayoutObject->setFlowThreadState(parentRenderer->flowThreadState()); | 164 newLayoutObject->setFlowThreadState(parentRenderer->flowThreadState()); |
| 165 | 165 |
| 166 LayoutObject* nextRenderer = this->nextRenderer(); | 166 LayoutObject* nextRenderer = this->nextRenderer(); |
| 167 m_node->setLayoutObject(newLayoutObject); | 167 m_node->setLayoutObject(newLayoutObject); |
| 168 // Parent takes care of the animations, no need to call setAnimatableStyle. | 168 // Parent takes care of the animations, no need to call setAnimatableStyle. |
| 169 newLayoutObject->setStyle(style); | 169 newLayoutObject->setStyle(style); |
| 170 parentRenderer->addChild(newLayoutObject, nextRenderer); | 170 parentRenderer->addChild(newLayoutObject, nextRenderer); |
| 171 } | 171 } |
| 172 | 172 |
| 173 } | 173 } |
| OLD | NEW |