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

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

Issue 2829593002: (CANCELED) [LayoutNG] Use ChildrenInline() to determine if children are inline (Closed)
Patch Set: Add TestExpectations Created 3 years, 7 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/LayoutMultiColumnFlowThread.h" 8 #include "core/layout/LayoutMultiColumnFlowThread.h"
9 #include "core/layout/LayoutMultiColumnSet.h" 9 #include "core/layout/LayoutMultiColumnSet.h"
10 #include "core/layout/api/LineLayoutAPIShim.h" 10 #include "core/layout/api/LineLayoutAPIShim.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 215 }
216 } 216 }
217 } 217 }
218 return next_sibling_; 218 return next_sibling_;
219 } 219 }
220 220
221 LayoutObject* NGBlockNode::GetLayoutObject() { 221 LayoutObject* NGBlockNode::GetLayoutObject() {
222 return layout_box_; 222 return layout_box_;
223 } 223 }
224 224
225 static bool ShouldHandleByInlineContext(LayoutObject* child) {
226 DCHECK(child);
227 // The spec isn't clear about whether floats/OOF should be in inline
228 // formatting context or in block formatting context.
229 // Prefer inline formatting context because 1) floats/OOF at the beginning
230 // and in the middle of inline should be handled in the same code, and 2)
231 // it matches to the LayoutObject tree.
232 for (; child; child = child->NextSibling()) {
233 if (child->IsInline())
234 return true;
235 if (child->IsFloating() || child->IsOutOfFlowPositioned())
236 continue;
237 return false;
238 }
239 // All children are either float or OOF.
240 // TODO(kojii): Should this be handled in block context or inline context?
241 // If we handle in inline, we can remove all code for floats/OOF from block
242 // layout, but it may change semantics and causes incorrectness?
243 return false;
244 }
245
246 NGLayoutInputNode* NGBlockNode::FirstChild() { 225 NGLayoutInputNode* NGBlockNode::FirstChild() {
247 if (!first_child_) { 226 if (!first_child_) {
248 LayoutObject* child = layout_box_->SlowFirstChild(); 227 LayoutObject* child = layout_box_->SlowFirstChild();
249 if (child) { 228 if (child) {
250 if (ShouldHandleByInlineContext(child)) { 229 if (layout_box_->ChildrenInline()) {
251 first_child_ = new NGInlineNode(child, ToLayoutBlockFlow(layout_box_)); 230 first_child_ = new NGInlineNode(child, ToLayoutBlockFlow(layout_box_));
252 } else { 231 } else {
253 first_child_ = new NGBlockNode(child); 232 first_child_ = new NGBlockNode(child);
254 } 233 }
255 } 234 }
256 } 235 }
257 return first_child_; 236 return first_child_;
258 } 237 }
259 238
260 DEFINE_TRACE(NGBlockNode) { 239 DEFINE_TRACE(NGBlockNode) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 366
388 // Save static position for legacy AbsPos layout. 367 // Save static position for legacy AbsPos layout.
389 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { 368 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) {
390 DCHECK(layout_box_->IsOutOfFlowPositioned()); 369 DCHECK(layout_box_->IsOutOfFlowPositioned());
391 DCHECK(layout_box_->Layer()); 370 DCHECK(layout_box_->Layer());
392 layout_box_->Layer()->SetStaticBlockPosition(offset.block_offset); 371 layout_box_->Layer()->SetStaticBlockPosition(offset.block_offset);
393 layout_box_->Layer()->SetStaticInlinePosition(offset.inline_offset); 372 layout_box_->Layer()->SetStaticInlinePosition(offset.inline_offset);
394 } 373 }
395 374
396 } // namespace blink 375 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698