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

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

Issue 2872593003: [LayoutNG] Introduce NGPositionedFloat. (Closed)
Patch Set: address comments. 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 fragment.Width()); 58 fragment.Width());
59 } else { 59 } else {
60 layout_box->SetX(fragment.LeftOffset()); 60 layout_box->SetX(fragment.LeftOffset());
61 } 61 }
62 layout_box->SetY(fragment.TopOffset()); 62 layout_box->SetY(fragment.TopOffset());
63 } 63 }
64 64
65 // Similar to FragmentPositionUpdated but for floats. 65 // Similar to FragmentPositionUpdated but for floats.
66 // - Updates layout object's geometric information. 66 // - Updates layout object's geometric information.
67 // - Creates legacy FloatingObject and attached it to the provided parent. 67 // - Creates legacy FloatingObject and attached it to the provided parent.
68 void FloatingObjectPositionedUpdated(NGFloatingObject* ng_floating_object, 68 void FloatingObjectPositionedUpdated(const NGPositionedFloat& positioned_float,
69 LayoutBox* parent) { 69 LayoutBox* parent) {
70 NGPhysicalBoxFragment* box_fragment = 70 NGPhysicalBoxFragment* box_fragment =
71 ToNGPhysicalBoxFragment(ng_floating_object->fragment.Get()); 71 ToNGPhysicalBoxFragment(positioned_float.fragment.Get());
72 FragmentPositionUpdated(*box_fragment); 72 FragmentPositionUpdated(*box_fragment);
73 73
74 LayoutBox* layout_box = ToLayoutBox(box_fragment->GetLayoutObject()); 74 LayoutBox* layout_box = ToLayoutBox(box_fragment->GetLayoutObject());
75 DCHECK(layout_box->IsFloating()); 75 DCHECK(layout_box->IsFloating());
76 76
77 if (parent && parent->IsLayoutBlockFlow()) { 77 if (parent && parent->IsLayoutBlockFlow()) {
78 FloatingObject* floating_object = 78 FloatingObject* floating_object =
79 ToLayoutBlockFlow(parent)->InsertFloatingObject(*layout_box); 79 ToLayoutBlockFlow(parent)->InsertFloatingObject(*layout_box);
80 floating_object->SetIsInPlacedTree(false); 80 floating_object->SetIsInPlacedTree(false);
81 floating_object->SetX(ng_floating_object->left_offset); 81 floating_object->SetX(positioned_float.left_offset);
82 floating_object->SetY(box_fragment->TopOffset()); 82 floating_object->SetY(box_fragment->TopOffset());
83 floating_object->SetIsPlaced(true); 83 floating_object->SetIsPlaced(true);
84 floating_object->SetIsInPlacedTree(true); 84 floating_object->SetIsInPlacedTree(true);
85 } 85 }
86 } 86 }
87 87
88 void UpdateLegacyMultiColumnFlowThread(LayoutBox* layout_box, 88 void UpdateLegacyMultiColumnFlowThread(LayoutBox* layout_box,
89 const NGPhysicalBoxFragment* fragment) { 89 const NGPhysicalBoxFragment* fragment) {
90 LayoutBlockFlow* multicol = ToLayoutBlockFlow(layout_box); 90 LayoutBlockFlow* multicol = ToLayoutBlockFlow(layout_box);
91 LayoutMultiColumnFlowThread* flow_thread = multicol->MultiColumnFlowThread(); 91 LayoutMultiColumnFlowThread* flow_thread = multicol->MultiColumnFlowThread();
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 ComputePadding(constraint_space, Style()); 295 ComputePadding(constraint_space, Style());
296 LayoutUnit intrinsic_logical_height = 296 LayoutUnit intrinsic_logical_height =
297 layout_box_->Style()->IsHorizontalWritingMode() 297 layout_box_->Style()->IsHorizontalWritingMode()
298 ? fragment->OverflowSize().height 298 ? fragment->OverflowSize().height
299 : fragment->OverflowSize().width; 299 : fragment->OverflowSize().width;
300 intrinsic_logical_height -= border_and_padding.BlockSum(); 300 intrinsic_logical_height -= border_and_padding.BlockSum();
301 layout_box_->SetIntrinsicContentLogicalHeight(intrinsic_logical_height); 301 layout_box_->SetIntrinsicContentLogicalHeight(intrinsic_logical_height);
302 302
303 // We may still have unpositioned floats when we reach the root box. 303 // We may still have unpositioned floats when we reach the root box.
304 if (!layout_box_->Parent()) { 304 if (!layout_box_->Parent()) {
305 for (const RefPtr<NGFloatingObject>& floating_object : 305 for (const NGPositionedFloat& positioned_float :
306 fragment->PositionedFloats()) { 306 fragment->PositionedFloats()) {
307 FloatingObjectPositionedUpdated(floating_object.Get(), layout_box_); 307 FloatingObjectPositionedUpdated(positioned_float, layout_box_);
308 } 308 }
309 } 309 }
310 310
311 for (const auto& child_fragment : fragment->Children()) { 311 for (const auto& child_fragment : fragment->Children()) {
312 if (child_fragment->IsPlaced()) 312 if (child_fragment->IsPlaced())
313 FragmentPositionUpdated(ToNGPhysicalBoxFragment(*child_fragment)); 313 FragmentPositionUpdated(ToNGPhysicalBoxFragment(*child_fragment));
314 314
315 for (const RefPtr<NGFloatingObject>& floating_object : 315 for (const NGPositionedFloat& positioned_float :
316 ToNGPhysicalBoxFragment(child_fragment.Get())->PositionedFloats()) { 316 ToNGPhysicalBoxFragment(child_fragment.Get())->PositionedFloats()) {
317 FloatingObjectPositionedUpdated( 317 FloatingObjectPositionedUpdated(
318 floating_object.Get(), 318 positioned_float, ToLayoutBox(child_fragment->GetLayoutObject()));
319 ToLayoutBox(child_fragment->GetLayoutObject()));
320 } 319 }
321 } 320 }
322 321
323 if (layout_box_->IsLayoutBlock()) 322 if (layout_box_->IsLayoutBlock())
324 ToLayoutBlock(layout_box_)->LayoutPositionedObjects(true); 323 ToLayoutBlock(layout_box_)->LayoutPositionedObjects(true);
325 layout_box_->ClearNeedsLayout(); 324 layout_box_->ClearNeedsLayout();
326 if (layout_box_->IsLayoutBlockFlow()) { 325 if (layout_box_->IsLayoutBlockFlow()) {
327 ToLayoutBlockFlow(layout_box_)->UpdateIsSelfCollapsing(); 326 ToLayoutBlockFlow(layout_box_)->UpdateIsSelfCollapsing();
328 } 327 }
329 } 328 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 392
394 // Save static position for legacy AbsPos layout. 393 // Save static position for legacy AbsPos layout.
395 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { 394 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) {
396 DCHECK(layout_box_->IsOutOfFlowPositioned()); 395 DCHECK(layout_box_->IsOutOfFlowPositioned());
397 DCHECK(layout_box_->Layer()); 396 DCHECK(layout_box_->Layer());
398 layout_box_->Layer()->SetStaticBlockPosition(offset.block_offset); 397 layout_box_->Layer()->SetStaticBlockPosition(offset.block_offset);
399 layout_box_->Layer()->SetStaticInlinePosition(offset.inline_offset); 398 layout_box_->Layer()->SetStaticInlinePosition(offset.inline_offset);
400 } 399 }
401 400
402 } // namespace blink 401 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698