Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: third_party/WebKit/Source/core/dom/LayoutTreeBuilder.cpp

Issue 2450093005: Support display: contents for elements, first-line and first-letter pseudos. (Closed)
Patch Set: Support display: contents for elements, first-line and first-letter pseudos. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // FIXME: Move the first-letter logic inside parentLayoutObject too?
jfernandez 2016/10/27 17:08:02 We use to define this kind of comments with TODO (
52 if (element.isFirstLetterPseudoElement()) { 53 if (element.isFirstLetterPseudoElement()) {
53 if (LayoutObject* nextLayoutObject = 54 if (LayoutObject* nextLayoutObject =
54 FirstLetterPseudoElement::firstLetterTextLayoutObject(element)) 55 FirstLetterPseudoElement::firstLetterTextLayoutObject(element))
55 m_layoutObjectParent = nextLayoutObject->parent(); 56 m_layoutObjectParent = nextLayoutObject->parent();
56 } else if (ContainerNode* containerNode = 57 } else {
57 LayoutTreeBuilderTraversal::parent(element)) { 58 m_layoutObjectParent =
58 m_layoutObjectParent = containerNode->layoutObject(); 59 LayoutTreeBuilderTraversal::parentLayoutObject(element);
59 } 60 }
60 } 61 }
61 62
62 LayoutObject* LayoutTreeBuilderForElement::nextLayoutObject() const { 63 LayoutObject* LayoutTreeBuilderForElement::nextLayoutObject() const {
63 DCHECK(m_layoutObjectParent); 64 DCHECK(m_layoutObjectParent);
64 65
65 if (m_node->isInTopLayer()) 66 if (m_node->isInTopLayer())
66 return LayoutTreeBuilderTraversal::nextInTopLayer(*m_node); 67 return LayoutTreeBuilderTraversal::nextInTopLayer(*m_node);
67 68
68 if (m_node->isFirstLetterPseudoElement()) 69 if (m_node->isFirstLetterPseudoElement())
(...skipping 28 matching lines...) Expand all
97 (!m_layoutObjectParent->node() || 98 (!m_layoutObjectParent->node() ||
98 !m_layoutObjectParent->node()->isSVGElement())) 99 !m_layoutObjectParent->node()->isSVGElement()))
99 return false; 100 return false;
100 if (!toSVGElement(m_node)->isValid()) 101 if (!toSVGElement(m_node)->isValid())
101 return false; 102 return false;
102 } 103 }
103 104
104 LayoutObject* parentLayoutObject = this->parentLayoutObject(); 105 LayoutObject* parentLayoutObject = this->parentLayoutObject();
105 if (!parentLayoutObject) 106 if (!parentLayoutObject)
106 return false; 107 return false;
108
jfernandez 2016/10/27 17:08:01 Remove this empty line.
107 if (!parentLayoutObject->canHaveChildren()) 109 if (!parentLayoutObject->canHaveChildren())
108 return false; 110 return false;
109 111
110 return m_node->layoutObjectIsNeeded(style()); 112 // Make sure we keep track of "display: contents" styles.
113 ComputedStyle& style = this->style();
jfernandez 2016/10/27 17:08:01 I think we need to manage this as reference counte
114 if (!m_node->layoutObjectIsNeeded(style)) {
115 if (style.display() == EDisplay::Contents)
116 m_node->storeDisplayContentsStyle(style);
jfernandez 2016/10/27 17:08:01 We need to take care of references here.
117 return false;
118 }
119
120 return true;
111 } 121 }
112 122
113 ComputedStyle& LayoutTreeBuilderForElement::style() const { 123 ComputedStyle& LayoutTreeBuilderForElement::style() const {
114 if (!m_style) 124 if (!m_style)
115 m_style = m_node->styleForLayoutObject(); 125 m_style = m_node->styleForLayoutObject();
116 return *m_style; 126 return *m_style;
117 } 127 }
118 128
119 DISABLE_CFI_PERF 129 DISABLE_CFI_PERF
120 void LayoutTreeBuilderForElement::createLayoutObject() { 130 void LayoutTreeBuilderForElement::createLayoutObject() {
(...skipping 28 matching lines...) Expand all
149 if (!newLayoutObject) 159 if (!newLayoutObject)
150 return; 160 return;
151 } 161 }
152 162
153 // Note: Adding newLayoutObject instead of layoutObject(). layoutObject() may 163 // Note: Adding newLayoutObject instead of layoutObject(). layoutObject() may
154 // be a child of newLayoutObject. 164 // be a child of newLayoutObject.
155 parentLayoutObject->addChild(newLayoutObject, nextLayoutObject); 165 parentLayoutObject->addChild(newLayoutObject, nextLayoutObject);
156 } 166 }
157 167
158 void LayoutTreeBuilderForText::createLayoutObject() { 168 void LayoutTreeBuilderForText::createLayoutObject() {
159 ComputedStyle& style = m_layoutObjectParent->mutableStyleRef(); 169 ComputedStyle& style = *m_style;
jfernandez 2016/10/27 17:08:01 The removed code was like that becase we wanted a
170
171 DCHECK(m_style == m_layoutObjectParent->style() ||
172 toElement(LayoutTreeBuilderTraversal::parent(*m_node))
173 ->displayContentsStyle());
160 174
161 DCHECK(m_node->textLayoutObjectIsNeeded(style, *m_layoutObjectParent)); 175 DCHECK(m_node->textLayoutObjectIsNeeded(style, *m_layoutObjectParent));
162 176
163 LayoutText* newLayoutObject = m_node->createTextLayoutObject(style); 177 LayoutText* newLayoutObject = m_node->createTextLayoutObject(style);
164 if (!m_layoutObjectParent->isChildAllowed(newLayoutObject, style)) { 178 if (!m_layoutObjectParent->isChildAllowed(newLayoutObject, style)) {
165 newLayoutObject->destroy(); 179 newLayoutObject->destroy();
166 return; 180 return;
167 } 181 }
168 182
169 // Make sure the LayoutObject already knows it is going to be added to a 183 // 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 184 // LayoutFlowThread before we set the style for the first time. Otherwise code
171 // using inLayoutFlowThread() in the styleWillChange and styleDidChange will 185 // using inLayoutFlowThread() in the styleWillChange and styleDidChange will
172 // fail. 186 // fail.
173 newLayoutObject->setIsInsideFlowThread( 187 newLayoutObject->setIsInsideFlowThread(
174 m_layoutObjectParent->isInsideFlowThread()); 188 m_layoutObjectParent->isInsideFlowThread());
175 189
176 LayoutObject* nextLayoutObject = this->nextLayoutObject(); 190 LayoutObject* nextLayoutObject = this->nextLayoutObject();
177 m_node->setLayoutObject(newLayoutObject); 191 m_node->setLayoutObject(newLayoutObject);
178 // Parent takes care of the animations, no need to call setAnimatableStyle. 192 // Parent takes care of the animations, no need to call setAnimatableStyle.
179 newLayoutObject->setStyle(&style); 193 newLayoutObject->setStyle(&style);
180 m_layoutObjectParent->addChild(newLayoutObject, nextLayoutObject); 194 m_layoutObjectParent->addChild(newLayoutObject, nextLayoutObject);
181 } 195 }
182 196
183 } // namespace blink 197 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698