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 | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
6 * rights reserved. | 6 * rights reserved. |
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
8 * (http://www.torchmobile.com/) | 8 * (http://www.torchmobile.com/) |
9 * Copyright (C) 2011 Google Inc. All rights reserved. | 9 * Copyright (C) 2011 Google Inc. All rights reserved. |
10 * | 10 * |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "core/layout/LayoutView.h" | 42 #include "core/layout/LayoutView.h" |
43 #include "core/svg/SVGElement.h" | 43 #include "core/svg/SVGElement.h" |
44 #include "platform/RuntimeEnabledFeatures.h" | 44 #include "platform/RuntimeEnabledFeatures.h" |
45 | 45 |
46 namespace blink { | 46 namespace blink { |
47 | 47 |
48 LayoutTreeBuilderForElement::LayoutTreeBuilderForElement(Element& element, | 48 LayoutTreeBuilderForElement::LayoutTreeBuilderForElement(Element& element, |
49 ComputedStyle* style) | 49 ComputedStyle* style) |
50 : LayoutTreeBuilder(element, nullptr), m_style(style) { | 50 : LayoutTreeBuilder(element, nullptr), m_style(style) { |
51 DCHECK(!element.isActiveSlotOrActiveInsertionPoint()); | 51 DCHECK(!element.isActiveSlotOrActiveInsertionPoint()); |
| 52 // TODO(ecobos): Move the first-letter logic inside parentLayoutObject too? |
| 53 // It's an extra (unnecessary) check for text nodes, though. |
52 if (element.isFirstLetterPseudoElement()) { | 54 if (element.isFirstLetterPseudoElement()) { |
53 if (LayoutObject* nextLayoutObject = | 55 if (LayoutObject* nextLayoutObject = |
54 FirstLetterPseudoElement::firstLetterTextLayoutObject(element)) | 56 FirstLetterPseudoElement::firstLetterTextLayoutObject(element)) |
55 m_layoutObjectParent = nextLayoutObject->parent(); | 57 m_layoutObjectParent = nextLayoutObject->parent(); |
56 } else if (ContainerNode* containerNode = | 58 } else { |
57 LayoutTreeBuilderTraversal::parent(element)) { | 59 m_layoutObjectParent = |
58 m_layoutObjectParent = containerNode->layoutObject(); | 60 LayoutTreeBuilderTraversal::parentLayoutObject(element); |
59 } | 61 } |
60 } | 62 } |
61 | 63 |
62 LayoutObject* LayoutTreeBuilderForElement::nextLayoutObject() const { | 64 LayoutObject* LayoutTreeBuilderForElement::nextLayoutObject() const { |
63 DCHECK(m_layoutObjectParent); | 65 DCHECK(m_layoutObjectParent); |
64 | 66 |
65 if (m_node->isInTopLayer()) | 67 if (m_node->isInTopLayer()) |
66 return LayoutTreeBuilderTraversal::nextInTopLayer(*m_node); | 68 return LayoutTreeBuilderTraversal::nextInTopLayer(*m_node); |
67 | 69 |
68 if (m_node->isFirstLetterPseudoElement()) | 70 if (m_node->isFirstLetterPseudoElement()) |
(...skipping 30 matching lines...) Expand all Loading... |
99 return false; | 101 return false; |
100 if (!toSVGElement(m_node)->isValid()) | 102 if (!toSVGElement(m_node)->isValid()) |
101 return false; | 103 return false; |
102 } | 104 } |
103 | 105 |
104 LayoutObject* parentLayoutObject = this->parentLayoutObject(); | 106 LayoutObject* parentLayoutObject = this->parentLayoutObject(); |
105 if (!parentLayoutObject) | 107 if (!parentLayoutObject) |
106 return false; | 108 return false; |
107 if (!parentLayoutObject->canHaveChildren()) | 109 if (!parentLayoutObject->canHaveChildren()) |
108 return false; | 110 return false; |
109 | |
110 return m_node->layoutObjectIsNeeded(style()); | 111 return m_node->layoutObjectIsNeeded(style()); |
111 } | 112 } |
112 | 113 |
113 ComputedStyle& LayoutTreeBuilderForElement::style() const { | 114 ComputedStyle& LayoutTreeBuilderForElement::style() const { |
114 if (!m_style) | 115 if (!m_style) |
115 m_style = m_node->styleForLayoutObject(); | 116 m_style = m_node->styleForLayoutObject(); |
116 return *m_style; | 117 return *m_style; |
117 } | 118 } |
118 | 119 |
119 DISABLE_CFI_PERF | 120 DISABLE_CFI_PERF |
(...skipping 29 matching lines...) Expand all Loading... |
149 if (!newLayoutObject) | 150 if (!newLayoutObject) |
150 return; | 151 return; |
151 } | 152 } |
152 | 153 |
153 // Note: Adding newLayoutObject instead of layoutObject(). layoutObject() may | 154 // Note: Adding newLayoutObject instead of layoutObject(). layoutObject() may |
154 // be a child of newLayoutObject. | 155 // be a child of newLayoutObject. |
155 parentLayoutObject->addChild(newLayoutObject, nextLayoutObject); | 156 parentLayoutObject->addChild(newLayoutObject, nextLayoutObject); |
156 } | 157 } |
157 | 158 |
158 void LayoutTreeBuilderForText::createLayoutObject() { | 159 void LayoutTreeBuilderForText::createLayoutObject() { |
159 ComputedStyle& style = m_layoutObjectParent->mutableStyleRef(); | 160 ComputedStyle& style = *m_style; |
| 161 |
| 162 DCHECK(m_style == m_layoutObjectParent->style() || |
| 163 toElement(LayoutTreeBuilderTraversal::parent(*m_node)) |
| 164 ->hasDisplayContentsStyle()); |
160 | 165 |
161 DCHECK(m_node->textLayoutObjectIsNeeded(style, *m_layoutObjectParent)); | 166 DCHECK(m_node->textLayoutObjectIsNeeded(style, *m_layoutObjectParent)); |
162 | 167 |
163 LayoutText* newLayoutObject = m_node->createTextLayoutObject(style); | 168 LayoutText* newLayoutObject = m_node->createTextLayoutObject(style); |
164 if (!m_layoutObjectParent->isChildAllowed(newLayoutObject, style)) { | 169 if (!m_layoutObjectParent->isChildAllowed(newLayoutObject, style)) { |
165 newLayoutObject->destroy(); | 170 newLayoutObject->destroy(); |
166 return; | 171 return; |
167 } | 172 } |
168 | 173 |
169 // Make sure the LayoutObject already knows it is going to be added to a | 174 // Make sure the LayoutObject already knows it is going to be added to a |
170 // LayoutFlowThread before we set the style for the first time. Otherwise code | 175 // LayoutFlowThread before we set the style for the first time. Otherwise code |
171 // using inLayoutFlowThread() in the styleWillChange and styleDidChange will | 176 // using inLayoutFlowThread() in the styleWillChange and styleDidChange will |
172 // fail. | 177 // fail. |
173 newLayoutObject->setIsInsideFlowThread( | 178 newLayoutObject->setIsInsideFlowThread( |
174 m_layoutObjectParent->isInsideFlowThread()); | 179 m_layoutObjectParent->isInsideFlowThread()); |
175 | 180 |
176 LayoutObject* nextLayoutObject = this->nextLayoutObject(); | 181 LayoutObject* nextLayoutObject = this->nextLayoutObject(); |
177 m_node->setLayoutObject(newLayoutObject); | 182 m_node->setLayoutObject(newLayoutObject); |
178 // Parent takes care of the animations, no need to call setAnimatableStyle. | 183 // Parent takes care of the animations, no need to call setAnimatableStyle. |
179 newLayoutObject->setStyle(&style); | 184 newLayoutObject->setStyle(&style); |
180 m_layoutObjectParent->addChild(newLayoutObject, nextLayoutObject); | 185 m_layoutObjectParent->addChild(newLayoutObject, nextLayoutObject); |
181 } | 186 } |
182 | 187 |
183 } // namespace blink | 188 } // namespace blink |
OLD | NEW |