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.isSlotOrActiveInsertionPoint()); | 51 DCHECK(!element.isSlotOrActiveInsertionPoint()); |
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 28 matching lines...) Expand all Loading... | |
97 (!m_layoutObjectParent->node() || | 99 (!m_layoutObjectParent->node() || |
98 !m_layoutObjectParent->node()->isSVGElement())) | 100 !m_layoutObjectParent->node()->isSVGElement())) |
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; |
109 | |
107 if (!parentLayoutObject->canHaveChildren()) | 110 if (!parentLayoutObject->canHaveChildren()) |
108 return false; | 111 return false; |
109 | 112 |
110 return m_node->layoutObjectIsNeeded(style()); | 113 // Make sure we keep track of "display: contents" styles. |
114 ComputedStyle& style = this->style(); | |
115 if (!m_node->layoutObjectIsNeeded(style)) { | |
116 if (style.display() == EDisplay::Contents) | |
117 m_node->storeDisplayContentsStyle(style); | |
rune
2016/11/01 07:12:23
It's a surprise that shouldCreateLayoutObject has
emilio
2016/11/01 15:46:31
Agreed, moved it out of there. Still, createLayout
| |
118 return false; | |
119 } | |
120 | |
121 return true; | |
111 } | 122 } |
112 | 123 |
113 ComputedStyle& LayoutTreeBuilderForElement::style() const { | 124 ComputedStyle& LayoutTreeBuilderForElement::style() const { |
114 if (!m_style) | 125 if (!m_style) |
115 m_style = m_node->styleForLayoutObject(); | 126 m_style = m_node->styleForLayoutObject(); |
116 return *m_style; | 127 return *m_style; |
117 } | 128 } |
118 | 129 |
119 DISABLE_CFI_PERF | 130 DISABLE_CFI_PERF |
120 void LayoutTreeBuilderForElement::createLayoutObject() { | 131 void LayoutTreeBuilderForElement::createLayoutObject() { |
(...skipping 28 matching lines...) Expand all Loading... | |
149 if (!newLayoutObject) | 160 if (!newLayoutObject) |
150 return; | 161 return; |
151 } | 162 } |
152 | 163 |
153 // Note: Adding newLayoutObject instead of layoutObject(). layoutObject() may | 164 // Note: Adding newLayoutObject instead of layoutObject(). layoutObject() may |
154 // be a child of newLayoutObject. | 165 // be a child of newLayoutObject. |
155 parentLayoutObject->addChild(newLayoutObject, nextLayoutObject); | 166 parentLayoutObject->addChild(newLayoutObject, nextLayoutObject); |
156 } | 167 } |
157 | 168 |
158 void LayoutTreeBuilderForText::createLayoutObject() { | 169 void LayoutTreeBuilderForText::createLayoutObject() { |
159 ComputedStyle& style = m_layoutObjectParent->mutableStyleRef(); | 170 ComputedStyle& style = *m_style; |
171 | |
172 DCHECK(m_style == m_layoutObjectParent->style() || | |
173 toElement(LayoutTreeBuilderTraversal::parent(*m_node)) | |
174 ->displayContentsStyle()); | |
160 | 175 |
161 DCHECK(m_node->textLayoutObjectIsNeeded(style, *m_layoutObjectParent)); | 176 DCHECK(m_node->textLayoutObjectIsNeeded(style, *m_layoutObjectParent)); |
162 | 177 |
163 LayoutText* newLayoutObject = m_node->createTextLayoutObject(style); | 178 LayoutText* newLayoutObject = m_node->createTextLayoutObject(style); |
164 if (!m_layoutObjectParent->isChildAllowed(newLayoutObject, style)) { | 179 if (!m_layoutObjectParent->isChildAllowed(newLayoutObject, style)) { |
165 newLayoutObject->destroy(); | 180 newLayoutObject->destroy(); |
166 return; | 181 return; |
167 } | 182 } |
168 | 183 |
169 // Make sure the LayoutObject already knows it is going to be added to a | 184 // 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 | 185 // LayoutFlowThread before we set the style for the first time. Otherwise code |
171 // using inLayoutFlowThread() in the styleWillChange and styleDidChange will | 186 // using inLayoutFlowThread() in the styleWillChange and styleDidChange will |
172 // fail. | 187 // fail. |
173 newLayoutObject->setIsInsideFlowThread( | 188 newLayoutObject->setIsInsideFlowThread( |
174 m_layoutObjectParent->isInsideFlowThread()); | 189 m_layoutObjectParent->isInsideFlowThread()); |
175 | 190 |
176 LayoutObject* nextLayoutObject = this->nextLayoutObject(); | 191 LayoutObject* nextLayoutObject = this->nextLayoutObject(); |
177 m_node->setLayoutObject(newLayoutObject); | 192 m_node->setLayoutObject(newLayoutObject); |
178 // Parent takes care of the animations, no need to call setAnimatableStyle. | 193 // Parent takes care of the animations, no need to call setAnimatableStyle. |
179 newLayoutObject->setStyle(&style); | 194 newLayoutObject->setStyle(&style); |
180 m_layoutObjectParent->addChild(newLayoutObject, nextLayoutObject); | 195 m_layoutObjectParent->addChild(newLayoutObject, nextLayoutObject); |
181 } | 196 } |
182 | 197 |
183 } // namespace blink | 198 } // namespace blink |
OLD | NEW |