OLD | NEW |
---|---|
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 Loading... | |
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( |
69 LayoutBox* parent) { | 69 const NGPositionedFloat& ng_positioned_float, |
Gleb Lanbin
2017/05/08 19:03:38
positioned_float or float
ikilpatrick
2017/05/08 19:18:19
Done.
| |
70 LayoutBox* parent) { | |
70 NGPhysicalBoxFragment* box_fragment = | 71 NGPhysicalBoxFragment* box_fragment = |
71 ToNGPhysicalBoxFragment(ng_floating_object->fragment.Get()); | 72 ToNGPhysicalBoxFragment(ng_positioned_float.fragment.Get()); |
72 FragmentPositionUpdated(*box_fragment); | 73 FragmentPositionUpdated(*box_fragment); |
73 | 74 |
74 LayoutBox* layout_box = ToLayoutBox(box_fragment->GetLayoutObject()); | 75 LayoutBox* layout_box = ToLayoutBox(box_fragment->GetLayoutObject()); |
75 DCHECK(layout_box->IsFloating()); | 76 DCHECK(layout_box->IsFloating()); |
76 | 77 |
77 if (parent && parent->IsLayoutBlockFlow()) { | 78 if (parent && parent->IsLayoutBlockFlow()) { |
78 FloatingObject* floating_object = | 79 FloatingObject* floating_object = |
79 ToLayoutBlockFlow(parent)->InsertFloatingObject(*layout_box); | 80 ToLayoutBlockFlow(parent)->InsertFloatingObject(*layout_box); |
80 floating_object->SetIsInPlacedTree(false); | 81 floating_object->SetIsInPlacedTree(false); |
81 floating_object->SetX(ng_floating_object->left_offset); | 82 floating_object->SetX(ng_positioned_float.left_offset); |
82 floating_object->SetY(box_fragment->TopOffset()); | 83 floating_object->SetY(box_fragment->TopOffset()); |
83 floating_object->SetIsPlaced(true); | 84 floating_object->SetIsPlaced(true); |
84 floating_object->SetIsInPlacedTree(true); | 85 floating_object->SetIsInPlacedTree(true); |
85 } | 86 } |
86 } | 87 } |
87 | 88 |
88 void UpdateLegacyMultiColumnFlowThread(LayoutBox* layout_box, | 89 void UpdateLegacyMultiColumnFlowThread(LayoutBox* layout_box, |
89 const NGPhysicalBoxFragment* fragment) { | 90 const NGPhysicalBoxFragment* fragment) { |
90 LayoutBlockFlow* multicol = ToLayoutBlockFlow(layout_box); | 91 LayoutBlockFlow* multicol = ToLayoutBlockFlow(layout_box); |
91 LayoutMultiColumnFlowThread* flow_thread = multicol->MultiColumnFlowThread(); | 92 LayoutMultiColumnFlowThread* flow_thread = multicol->MultiColumnFlowThread(); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 ComputePadding(constraint_space, Style()); | 296 ComputePadding(constraint_space, Style()); |
296 LayoutUnit intrinsic_logical_height = | 297 LayoutUnit intrinsic_logical_height = |
297 layout_box_->Style()->IsHorizontalWritingMode() | 298 layout_box_->Style()->IsHorizontalWritingMode() |
298 ? fragment->OverflowSize().height | 299 ? fragment->OverflowSize().height |
299 : fragment->OverflowSize().width; | 300 : fragment->OverflowSize().width; |
300 intrinsic_logical_height -= border_and_padding.BlockSum(); | 301 intrinsic_logical_height -= border_and_padding.BlockSum(); |
301 layout_box_->SetIntrinsicContentLogicalHeight(intrinsic_logical_height); | 302 layout_box_->SetIntrinsicContentLogicalHeight(intrinsic_logical_height); |
302 | 303 |
303 // We may still have unpositioned floats when we reach the root box. | 304 // We may still have unpositioned floats when we reach the root box. |
304 if (!layout_box_->Parent()) { | 305 if (!layout_box_->Parent()) { |
305 for (const RefPtr<NGFloatingObject>& floating_object : | 306 for (const NGPositionedFloat& positioned_float : |
306 fragment->PositionedFloats()) { | 307 fragment->PositionedFloats()) { |
307 FloatingObjectPositionedUpdated(floating_object.Get(), layout_box_); | 308 FloatingObjectPositionedUpdated(positioned_float, layout_box_); |
308 } | 309 } |
309 } | 310 } |
310 | 311 |
311 for (const auto& child_fragment : fragment->Children()) { | 312 for (const auto& child_fragment : fragment->Children()) { |
312 if (child_fragment->IsPlaced()) | 313 if (child_fragment->IsPlaced()) |
313 FragmentPositionUpdated(ToNGPhysicalBoxFragment(*child_fragment)); | 314 FragmentPositionUpdated(ToNGPhysicalBoxFragment(*child_fragment)); |
314 | 315 |
315 for (const RefPtr<NGFloatingObject>& floating_object : | 316 for (const NGPositionedFloat& positioned_float : |
316 ToNGPhysicalBoxFragment(child_fragment.Get())->PositionedFloats()) { | 317 ToNGPhysicalBoxFragment(child_fragment.Get())->PositionedFloats()) { |
317 FloatingObjectPositionedUpdated( | 318 FloatingObjectPositionedUpdated( |
318 floating_object.Get(), | 319 positioned_float, ToLayoutBox(child_fragment->GetLayoutObject())); |
319 ToLayoutBox(child_fragment->GetLayoutObject())); | |
320 } | 320 } |
321 } | 321 } |
322 | 322 |
323 if (layout_box_->IsLayoutBlock()) | 323 if (layout_box_->IsLayoutBlock()) |
324 ToLayoutBlock(layout_box_)->LayoutPositionedObjects(true); | 324 ToLayoutBlock(layout_box_)->LayoutPositionedObjects(true); |
325 layout_box_->ClearNeedsLayout(); | 325 layout_box_->ClearNeedsLayout(); |
326 if (layout_box_->IsLayoutBlockFlow()) { | 326 if (layout_box_->IsLayoutBlockFlow()) { |
327 ToLayoutBlockFlow(layout_box_)->UpdateIsSelfCollapsing(); | 327 ToLayoutBlockFlow(layout_box_)->UpdateIsSelfCollapsing(); |
328 } | 328 } |
329 } | 329 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 | 393 |
394 // Save static position for legacy AbsPos layout. | 394 // Save static position for legacy AbsPos layout. |
395 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { | 395 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { |
396 DCHECK(layout_box_->IsOutOfFlowPositioned()); | 396 DCHECK(layout_box_->IsOutOfFlowPositioned()); |
397 DCHECK(layout_box_->Layer()); | 397 DCHECK(layout_box_->Layer()); |
398 layout_box_->Layer()->SetStaticBlockPosition(offset.block_offset); | 398 layout_box_->Layer()->SetStaticBlockPosition(offset.block_offset); |
399 layout_box_->Layer()->SetStaticInlinePosition(offset.inline_offset); | 399 layout_box_->Layer()->SetStaticInlinePosition(offset.inline_offset); |
400 } | 400 } |
401 | 401 |
402 } // namespace blink | 402 } // namespace blink |
OLD | NEW |