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

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_block_node.cc

Issue 2725773002: Remove NGBlockNode constructor, SetFirstChild, SetNextSibling methods (Closed)
Patch Set: git cl web Created 3 years, 9 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/ng/ng_block_node.h" 5 #include "core/layout/ng/ng_block_node.h"
6 6
7 #include "core/layout/LayoutBlockFlow.h" 7 #include "core/layout/LayoutBlockFlow.h"
8 #include "core/layout/api/LineLayoutAPIShim.h" 8 #include "core/layout/api/LineLayoutAPIShim.h"
9 #include "core/layout/line/InlineIterator.h" 9 #include "core/layout/line/InlineIterator.h"
10 #include "core/layout/ng/layout_ng_block_flow.h" 10 #include "core/layout/ng/layout_ng_block_flow.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 69
70 } // namespace 70 } // namespace
71 71
72 NGBlockNode::NGBlockNode(LayoutObject* layout_object) 72 NGBlockNode::NGBlockNode(LayoutObject* layout_object)
73 : NGLayoutInputNode(NGLayoutInputNodeType::kLegacyBlock), 73 : NGLayoutInputNode(NGLayoutInputNodeType::kLegacyBlock),
74 layout_box_(toLayoutBox(layout_object)) { 74 layout_box_(toLayoutBox(layout_object)) {
75 DCHECK(layout_box_); 75 DCHECK(layout_box_);
76 } 76 }
77 77
78 NGBlockNode::NGBlockNode(ComputedStyle* style)
79 : NGLayoutInputNode(NGLayoutInputNodeType::kLegacyBlock),
80 layout_box_(nullptr),
81 style_(style) {
82 DCHECK(style_);
83 }
84
85 // Need an explicit destructor in the .cc file, or the MSWIN compiler will 78 // Need an explicit destructor in the .cc file, or the MSWIN compiler will
86 // produce an error when attempting to generate a default one, if the .h file is 79 // produce an error when attempting to generate a default one, if the .h file is
87 // included from a compilation unit that lacks the ComputedStyle definition. 80 // included from a compilation unit that lacks the ComputedStyle definition.
88 NGBlockNode::~NGBlockNode() {} 81 NGBlockNode::~NGBlockNode() {}
89 82
90 RefPtr<NGLayoutResult> NGBlockNode::Layout(NGConstraintSpace* constraint_space, 83 RefPtr<NGLayoutResult> NGBlockNode::Layout(NGConstraintSpace* constraint_space,
91 NGBreakToken* break_token) { 84 NGBreakToken* break_token) {
92 // Use the old layout code and synthesize a fragment. 85 // Use the old layout code and synthesize a fragment.
93 if (!CanUseNewLayout()) { 86 if (!CanUseNewLayout()) {
94 DCHECK(layout_box_); 87 DCHECK(layout_box_);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 DCHECK(layout_box_); 160 DCHECK(layout_box_);
168 return layout_box_->styleRef(); 161 return layout_box_->styleRef();
169 } 162 }
170 163
171 NGLayoutInputNode* NGBlockNode::NextSibling() { 164 NGLayoutInputNode* NGBlockNode::NextSibling() {
172 if (!next_sibling_) { 165 if (!next_sibling_) {
173 LayoutObject* next_sibling = 166 LayoutObject* next_sibling =
174 layout_box_ ? layout_box_->nextSibling() : nullptr; 167 layout_box_ ? layout_box_->nextSibling() : nullptr;
175 if (next_sibling) { 168 if (next_sibling) {
176 if (next_sibling->isInline()) 169 if (next_sibling->isInline())
177 SetNextSibling(new NGInlineNode(next_sibling, &Style())); 170 next_sibling_ = new NGInlineNode(next_sibling, &Style());
178 else 171 else
179 SetNextSibling(new NGBlockNode(next_sibling)); 172 next_sibling_ = new NGBlockNode(next_sibling);
180 } 173 }
181 } 174 }
182 return next_sibling_; 175 return next_sibling_;
183 } 176 }
184 177
185 LayoutObject* NGBlockNode::GetLayoutObject() { 178 LayoutObject* NGBlockNode::GetLayoutObject() {
186 return layout_box_; 179 return layout_box_;
187 } 180 }
188 181
189 NGLayoutInputNode* NGBlockNode::FirstChild() { 182 NGLayoutInputNode* NGBlockNode::FirstChild() {
190 if (!first_child_) { 183 if (!first_child_) {
191 LayoutObject* child = layout_box_ ? layout_box_->slowFirstChild() : nullptr; 184 LayoutObject* child = layout_box_ ? layout_box_->slowFirstChild() : nullptr;
192 if (child) { 185 if (child) {
193 if (child->isInline()) { 186 if (child->isInline()) {
194 SetFirstChild(new NGInlineNode(child, &Style())); 187 first_child_ = new NGInlineNode(child, &Style());
195 } else { 188 } else {
196 SetFirstChild(new NGBlockNode(child)); 189 first_child_ = new NGBlockNode(child);
197 } 190 }
198 } 191 }
199 } 192 }
200 return first_child_; 193 return first_child_;
201 } 194 }
202 195
203 void NGBlockNode::SetNextSibling(NGLayoutInputNode* sibling) {
204 next_sibling_ = sibling;
205 }
206
207 void NGBlockNode::SetFirstChild(NGLayoutInputNode* child) {
208 first_child_ = child;
209 }
210
211 DEFINE_TRACE(NGBlockNode) { 196 DEFINE_TRACE(NGBlockNode) {
212 visitor->trace(next_sibling_); 197 visitor->trace(next_sibling_);
213 visitor->trace(first_child_); 198 visitor->trace(first_child_);
214 NGLayoutInputNode::trace(visitor); 199 NGLayoutInputNode::trace(visitor);
215 } 200 }
216 201
217 bool NGBlockNode::CanUseNewLayout() { 202 bool NGBlockNode::CanUseNewLayout() {
218 if (!layout_box_) 203 if (!layout_box_)
219 return true; 204 return true;
220 if (!layout_box_->isLayoutBlockFlow()) 205 if (!layout_box_->isLayoutBlockFlow())
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // Save static position for legacy AbsPos layout. 350 // Save static position for legacy AbsPos layout.
366 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { 351 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) {
367 DCHECK(layout_box_); 352 DCHECK(layout_box_);
368 DCHECK(layout_box_->isOutOfFlowPositioned()); 353 DCHECK(layout_box_->isOutOfFlowPositioned());
369 DCHECK(layout_box_->layer()); 354 DCHECK(layout_box_->layer());
370 layout_box_->layer()->setStaticBlockPosition(offset.block_offset); 355 layout_box_->layer()->setStaticBlockPosition(offset.block_offset);
371 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset); 356 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset);
372 } 357 }
373 358
374 } // namespace blink 359 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698