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 |
6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 6 * rights reserved. |
| 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 8 * (http://www.torchmobile.com/) |
7 * Copyright (C) 2011 Google Inc. All rights reserved. | 9 * Copyright (C) 2011 Google Inc. All rights reserved. |
8 * | 10 * |
9 * This library is free software; you can redistribute it and/or | 11 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 12 * modify it under the terms of the GNU Library General Public |
11 * License as published by the Free Software Foundation; either | 13 * License as published by the Free Software Foundation; either |
12 * version 2 of the License, or (at your option) any later version. | 14 * version 2 of the License, or (at your option) any later version. |
13 * | 15 * |
14 * This library is distributed in the hope that it will be useful, | 16 * This library is distributed in the hope that it will be useful, |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 return LayoutTreeBuilderTraversal::nextInTopLayer(*m_node); | 66 return LayoutTreeBuilderTraversal::nextInTopLayer(*m_node); |
65 | 67 |
66 if (m_node->isFirstLetterPseudoElement()) | 68 if (m_node->isFirstLetterPseudoElement()) |
67 return FirstLetterPseudoElement::firstLetterTextLayoutObject(*m_node); | 69 return FirstLetterPseudoElement::firstLetterTextLayoutObject(*m_node); |
68 | 70 |
69 return LayoutTreeBuilder::nextLayoutObject(); | 71 return LayoutTreeBuilder::nextLayoutObject(); |
70 } | 72 } |
71 | 73 |
72 LayoutObject* LayoutTreeBuilderForElement::parentLayoutObject() const { | 74 LayoutObject* LayoutTreeBuilderForElement::parentLayoutObject() const { |
73 if (m_layoutObjectParent) { | 75 if (m_layoutObjectParent) { |
74 // FIXME: Guarding this by parentLayoutObject isn't quite right as the spec
for | 76 // FIXME: Guarding this by parentLayoutObject isn't quite right as the spec |
75 // top layer only talks about display: none ancestors so putting a <dialog>
inside an | 77 // for top layer only talks about display: none ancestors so putting a |
76 // <optgroup> seems like it should still work even though this check will pr
event it. | 78 // <dialog> inside an <optgroup> seems like it should still work even though |
| 79 // this check will prevent it. |
77 if (m_node->isInTopLayer()) | 80 if (m_node->isInTopLayer()) |
78 return m_node->document().layoutView(); | 81 return m_node->document().layoutView(); |
79 } | 82 } |
80 | 83 |
81 return m_layoutObjectParent; | 84 return m_layoutObjectParent; |
82 } | 85 } |
83 | 86 |
84 DISABLE_CFI_PERF | 87 DISABLE_CFI_PERF |
85 bool LayoutTreeBuilderForElement::shouldCreateLayoutObject() const { | 88 bool LayoutTreeBuilderForElement::shouldCreateLayoutObject() const { |
86 if (!m_layoutObjectParent) | 89 if (!m_layoutObjectParent) |
87 return false; | 90 return false; |
88 | 91 |
89 // FIXME: Should the following be in SVGElement::layoutObjectIsNeeded()? | 92 // FIXME: Should the following be in SVGElement::layoutObjectIsNeeded()? |
90 if (m_node->isSVGElement()) { | 93 if (m_node->isSVGElement()) { |
91 // SVG elements only render when inside <svg>, or if the element is an <svg>
itself. | 94 // SVG elements only render when inside <svg>, or if the element is an <svg> |
| 95 // itself. |
92 if (!isSVGSVGElement(*m_node) && | 96 if (!isSVGSVGElement(*m_node) && |
93 (!m_layoutObjectParent->node() || | 97 (!m_layoutObjectParent->node() || |
94 !m_layoutObjectParent->node()->isSVGElement())) | 98 !m_layoutObjectParent->node()->isSVGElement())) |
95 return false; | 99 return false; |
96 if (!toSVGElement(m_node)->isValid()) | 100 if (!toSVGElement(m_node)->isValid()) |
97 return false; | 101 return false; |
98 } | 102 } |
99 | 103 |
100 LayoutObject* parentLayoutObject = this->parentLayoutObject(); | 104 LayoutObject* parentLayoutObject = this->parentLayoutObject(); |
101 if (!parentLayoutObject) | 105 if (!parentLayoutObject) |
(...skipping 18 matching lines...) Expand all Loading... |
120 if (!newLayoutObject) | 124 if (!newLayoutObject) |
121 return; | 125 return; |
122 | 126 |
123 LayoutObject* parentLayoutObject = this->parentLayoutObject(); | 127 LayoutObject* parentLayoutObject = this->parentLayoutObject(); |
124 | 128 |
125 if (!parentLayoutObject->isChildAllowed(newLayoutObject, style)) { | 129 if (!parentLayoutObject->isChildAllowed(newLayoutObject, style)) { |
126 newLayoutObject->destroy(); | 130 newLayoutObject->destroy(); |
127 return; | 131 return; |
128 } | 132 } |
129 | 133 |
130 // Make sure the LayoutObject already knows it is going to be added to a Layou
tFlowThread before we set the style | 134 // Make sure the LayoutObject already knows it is going to be added to a |
131 // for the first time. Otherwise code using inLayoutFlowThread() in the styleW
illChange and styleDidChange will fail. | 135 // LayoutFlowThread before we set the style for the first time. Otherwise code |
| 136 // using inLayoutFlowThread() in the styleWillChange and styleDidChange will |
| 137 // fail. |
132 newLayoutObject->setIsInsideFlowThread( | 138 newLayoutObject->setIsInsideFlowThread( |
133 parentLayoutObject->isInsideFlowThread()); | 139 parentLayoutObject->isInsideFlowThread()); |
134 | 140 |
135 LayoutObject* nextLayoutObject = this->nextLayoutObject(); | 141 LayoutObject* nextLayoutObject = this->nextLayoutObject(); |
136 m_node->setLayoutObject(newLayoutObject); | 142 m_node->setLayoutObject(newLayoutObject); |
137 newLayoutObject->setStyle( | 143 newLayoutObject->setStyle( |
138 &style); // setStyle() can depend on layoutObject() already being set. | 144 &style); // setStyle() can depend on layoutObject() already being set. |
139 | 145 |
140 if (Fullscreen::isCurrentFullScreenElement(*m_node)) { | 146 if (Fullscreen::isCurrentFullScreenElement(*m_node)) { |
141 newLayoutObject = LayoutFullScreen::wrapLayoutObject( | 147 newLayoutObject = LayoutFullScreen::wrapLayoutObject( |
142 newLayoutObject, parentLayoutObject, &m_node->document()); | 148 newLayoutObject, parentLayoutObject, &m_node->document()); |
143 if (!newLayoutObject) | 149 if (!newLayoutObject) |
144 return; | 150 return; |
145 } | 151 } |
146 | 152 |
147 // Note: Adding newLayoutObject instead of layoutObject(). layoutObject() may
be a child of newLayoutObject. | 153 // Note: Adding newLayoutObject instead of layoutObject(). layoutObject() may |
| 154 // be a child of newLayoutObject. |
148 parentLayoutObject->addChild(newLayoutObject, nextLayoutObject); | 155 parentLayoutObject->addChild(newLayoutObject, nextLayoutObject); |
149 } | 156 } |
150 | 157 |
151 void LayoutTreeBuilderForText::createLayoutObject() { | 158 void LayoutTreeBuilderForText::createLayoutObject() { |
152 ComputedStyle& style = m_layoutObjectParent->mutableStyleRef(); | 159 ComputedStyle& style = m_layoutObjectParent->mutableStyleRef(); |
153 | 160 |
154 DCHECK(m_node->textLayoutObjectIsNeeded(style, *m_layoutObjectParent)); | 161 DCHECK(m_node->textLayoutObjectIsNeeded(style, *m_layoutObjectParent)); |
155 | 162 |
156 LayoutText* newLayoutObject = m_node->createTextLayoutObject(style); | 163 LayoutText* newLayoutObject = m_node->createTextLayoutObject(style); |
157 if (!m_layoutObjectParent->isChildAllowed(newLayoutObject, style)) { | 164 if (!m_layoutObjectParent->isChildAllowed(newLayoutObject, style)) { |
158 newLayoutObject->destroy(); | 165 newLayoutObject->destroy(); |
159 return; | 166 return; |
160 } | 167 } |
161 | 168 |
162 // Make sure the LayoutObject already knows it is going to be added to a Layou
tFlowThread before we set the style | 169 // Make sure the LayoutObject already knows it is going to be added to a |
163 // for the first time. Otherwise code using inLayoutFlowThread() in the styleW
illChange and styleDidChange will fail. | 170 // LayoutFlowThread before we set the style for the first time. Otherwise code |
| 171 // using inLayoutFlowThread() in the styleWillChange and styleDidChange will |
| 172 // fail. |
164 newLayoutObject->setIsInsideFlowThread( | 173 newLayoutObject->setIsInsideFlowThread( |
165 m_layoutObjectParent->isInsideFlowThread()); | 174 m_layoutObjectParent->isInsideFlowThread()); |
166 | 175 |
167 LayoutObject* nextLayoutObject = this->nextLayoutObject(); | 176 LayoutObject* nextLayoutObject = this->nextLayoutObject(); |
168 m_node->setLayoutObject(newLayoutObject); | 177 m_node->setLayoutObject(newLayoutObject); |
169 // Parent takes care of the animations, no need to call setAnimatableStyle. | 178 // Parent takes care of the animations, no need to call setAnimatableStyle. |
170 newLayoutObject->setStyle(&style); | 179 newLayoutObject->setStyle(&style); |
171 m_layoutObjectParent->addChild(newLayoutObject, nextLayoutObject); | 180 m_layoutObjectParent->addChild(newLayoutObject, nextLayoutObject); |
172 } | 181 } |
173 | 182 |
174 } // namespace blink | 183 } // namespace blink |
OLD | NEW |