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

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 3 years, 10 months 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.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 18 matching lines...) Expand all
87 DISABLE_CFI_PERF 89 DISABLE_CFI_PERF
88 bool LayoutTreeBuilderForElement::shouldCreateLayoutObject() const { 90 bool LayoutTreeBuilderForElement::shouldCreateLayoutObject() const {
89 if (!m_layoutObjectParent) 91 if (!m_layoutObjectParent)
90 return false; 92 return false;
91 93
92 LayoutObject* parentLayoutObject = this->parentLayoutObject(); 94 LayoutObject* parentLayoutObject = this->parentLayoutObject();
93 if (!parentLayoutObject) 95 if (!parentLayoutObject)
94 return false; 96 return false;
95 if (!parentLayoutObject->canHaveChildren()) 97 if (!parentLayoutObject->canHaveChildren())
96 return false; 98 return false;
97
98 return m_node->layoutObjectIsNeeded(style()); 99 return m_node->layoutObjectIsNeeded(style());
99 } 100 }
100 101
101 ComputedStyle& LayoutTreeBuilderForElement::style() const { 102 ComputedStyle& LayoutTreeBuilderForElement::style() const {
102 if (!m_style) 103 if (!m_style)
103 m_style = m_node->styleForLayoutObject(); 104 m_style = m_node->styleForLayoutObject();
104 return *m_style; 105 return *m_style;
105 } 106 }
106 107
107 DISABLE_CFI_PERF 108 DISABLE_CFI_PERF
(...skipping 29 matching lines...) Expand all
137 if (!newLayoutObject) 138 if (!newLayoutObject)
138 return; 139 return;
139 } 140 }
140 141
141 // Note: Adding newLayoutObject instead of layoutObject(). layoutObject() may 142 // Note: Adding newLayoutObject instead of layoutObject(). layoutObject() may
142 // be a child of newLayoutObject. 143 // be a child of newLayoutObject.
143 parentLayoutObject->addChild(newLayoutObject, nextLayoutObject); 144 parentLayoutObject->addChild(newLayoutObject, nextLayoutObject);
144 } 145 }
145 146
146 void LayoutTreeBuilderForText::createLayoutObject() { 147 void LayoutTreeBuilderForText::createLayoutObject() {
147 ComputedStyle& style = m_layoutObjectParent->mutableStyleRef(); 148 ComputedStyle& style = *m_style;
149
150 DCHECK(m_style == m_layoutObjectParent->style() ||
151 toElement(LayoutTreeBuilderTraversal::parent(*m_node))
152 ->hasDisplayContentsStyle());
148 153
149 DCHECK(m_node->textLayoutObjectIsNeeded(style, *m_layoutObjectParent)); 154 DCHECK(m_node->textLayoutObjectIsNeeded(style, *m_layoutObjectParent));
150 155
151 LayoutText* newLayoutObject = m_node->createTextLayoutObject(style); 156 LayoutText* newLayoutObject = m_node->createTextLayoutObject(style);
152 if (!m_layoutObjectParent->isChildAllowed(newLayoutObject, style)) { 157 if (!m_layoutObjectParent->isChildAllowed(newLayoutObject, style)) {
153 newLayoutObject->destroy(); 158 newLayoutObject->destroy();
154 return; 159 return;
155 } 160 }
156 161
157 // Make sure the LayoutObject already knows it is going to be added to a 162 // Make sure the LayoutObject already knows it is going to be added to a
158 // LayoutFlowThread before we set the style for the first time. Otherwise code 163 // LayoutFlowThread before we set the style for the first time. Otherwise code
159 // using inLayoutFlowThread() in the styleWillChange and styleDidChange will 164 // using inLayoutFlowThread() in the styleWillChange and styleDidChange will
160 // fail. 165 // fail.
161 newLayoutObject->setIsInsideFlowThread( 166 newLayoutObject->setIsInsideFlowThread(
162 m_layoutObjectParent->isInsideFlowThread()); 167 m_layoutObjectParent->isInsideFlowThread());
163 168
164 LayoutObject* nextLayoutObject = this->nextLayoutObject(); 169 LayoutObject* nextLayoutObject = this->nextLayoutObject();
165 m_node->setLayoutObject(newLayoutObject); 170 m_node->setLayoutObject(newLayoutObject);
166 // Parent takes care of the animations, no need to call setAnimatableStyle. 171 // Parent takes care of the animations, no need to call setAnimatableStyle.
167 newLayoutObject->setStyle(&style); 172 newLayoutObject->setStyle(&style);
168 m_layoutObjectParent->addChild(newLayoutObject, nextLayoutObject); 173 m_layoutObjectParent->addChild(newLayoutObject, nextLayoutObject);
169 } 174 }
170 175
171 } // namespace blink 176 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698