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/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" |
11 #include "core/layout/ng/ng_block_break_token.h" | 11 #include "core/layout/ng/ng_block_break_token.h" |
12 #include "core/layout/ng/ng_block_layout_algorithm.h" | 12 #include "core/layout/ng/ng_block_layout_algorithm.h" |
13 #include "core/layout/ng/ng_box_fragment.h" | 13 #include "core/layout/ng/ng_box_fragment.h" |
| 14 #include "core/layout/ng/ng_column_layout_algorithm.h" |
14 #include "core/layout/ng/ng_constraint_space.h" | 15 #include "core/layout/ng/ng_constraint_space.h" |
15 #include "core/layout/ng/ng_constraint_space_builder.h" | 16 #include "core/layout/ng/ng_constraint_space_builder.h" |
16 #include "core/layout/ng/ng_fragment_builder.h" | 17 #include "core/layout/ng/ng_fragment_builder.h" |
17 #include "core/layout/ng/ng_inline_node.h" | 18 #include "core/layout/ng/ng_inline_node.h" |
18 #include "core/layout/ng/ng_layout_result.h" | 19 #include "core/layout/ng/ng_layout_result.h" |
19 #include "core/layout/ng/ng_length_utils.h" | 20 #include "core/layout/ng/ng_length_utils.h" |
20 #include "core/layout/ng/ng_min_max_content_size.h" | 21 #include "core/layout/ng/ng_min_max_content_size.h" |
21 #include "core/layout/ng/ng_writing_mode.h" | 22 #include "core/layout/ng/ng_writing_mode.h" |
22 #include "core/paint/PaintLayer.h" | 23 #include "core/paint/PaintLayer.h" |
23 #include "platform/RuntimeEnabledFeatures.h" | 24 #include "platform/RuntimeEnabledFeatures.h" |
24 | 25 |
25 namespace blink { | 26 namespace blink { |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
| 30 RefPtr<NGLayoutResult> LayoutWithAlgorithm(const ComputedStyle& style, |
| 31 NGBlockNode* node, |
| 32 NGConstraintSpace* space, |
| 33 NGBreakToken* break_token) { |
| 34 if (style.specifiesColumns()) |
| 35 return NGColumnLayoutAlgorithm(node, space, |
| 36 toNGBlockBreakToken(break_token)) |
| 37 .Layout(); |
| 38 return NGBlockLayoutAlgorithm(node, space, toNGBlockBreakToken(break_token)) |
| 39 .Layout(); |
| 40 } |
| 41 |
29 // Copies data back to the legacy layout tree for a given child fragment. | 42 // Copies data back to the legacy layout tree for a given child fragment. |
30 void FragmentPositionUpdated(const NGPhysicalFragment& fragment) { | 43 void FragmentPositionUpdated(const NGPhysicalFragment& fragment) { |
31 LayoutBox* layout_box = toLayoutBox(fragment.GetLayoutObject()); | 44 LayoutBox* layout_box = toLayoutBox(fragment.GetLayoutObject()); |
32 if (!layout_box) | 45 if (!layout_box) |
33 return; | 46 return; |
34 | 47 |
35 DCHECK(layout_box->parent()) << "Should be called on children only."; | 48 DCHECK(layout_box->parent()) << "Should be called on children only."; |
36 | 49 |
37 // LegacyLayout flips vertical-rl horizontal coordinates before paint. | 50 // LegacyLayout flips vertical-rl horizontal coordinates before paint. |
38 // NGLayout flips X location for LegacyLayout compatibility. | 51 // NGLayout flips X location for LegacyLayout compatibility. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 NGBlockNode::~NGBlockNode() {} | 97 NGBlockNode::~NGBlockNode() {} |
85 | 98 |
86 RefPtr<NGLayoutResult> NGBlockNode::Layout(NGConstraintSpace* constraint_space, | 99 RefPtr<NGLayoutResult> NGBlockNode::Layout(NGConstraintSpace* constraint_space, |
87 NGBreakToken* break_token) { | 100 NGBreakToken* break_token) { |
88 // Use the old layout code and synthesize a fragment. | 101 // Use the old layout code and synthesize a fragment. |
89 if (!CanUseNewLayout()) { | 102 if (!CanUseNewLayout()) { |
90 return RunOldLayout(*constraint_space); | 103 return RunOldLayout(*constraint_space); |
91 } | 104 } |
92 | 105 |
93 RefPtr<NGLayoutResult> layout_result = | 106 RefPtr<NGLayoutResult> layout_result = |
94 NGBlockLayoutAlgorithm(this, constraint_space, | 107 LayoutWithAlgorithm(Style(), this, constraint_space, break_token); |
95 toNGBlockBreakToken(break_token)) | |
96 .Layout(); | |
97 | 108 |
98 CopyFragmentDataToLayoutBox(*constraint_space, layout_result.get()); | 109 CopyFragmentDataToLayoutBox(*constraint_space, layout_result.get()); |
99 return layout_result; | 110 return layout_result; |
100 } | 111 } |
101 | 112 |
102 MinMaxContentSize NGBlockNode::ComputeMinMaxContentSize() { | 113 MinMaxContentSize NGBlockNode::ComputeMinMaxContentSize() { |
103 MinMaxContentSize sizes; | 114 MinMaxContentSize sizes; |
104 if (!CanUseNewLayout()) { | 115 if (!CanUseNewLayout()) { |
105 // TODO(layout-ng): This could be somewhat optimized by directly calling | 116 // TODO(layout-ng): This could be somewhat optimized by directly calling |
106 // computeIntrinsicLogicalWidths, but that function is currently private. | 117 // computeIntrinsicLogicalWidths, but that function is currently private. |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 339 |
329 // Save static position for legacy AbsPos layout. | 340 // Save static position for legacy AbsPos layout. |
330 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { | 341 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { |
331 DCHECK(layout_box_->isOutOfFlowPositioned()); | 342 DCHECK(layout_box_->isOutOfFlowPositioned()); |
332 DCHECK(layout_box_->layer()); | 343 DCHECK(layout_box_->layer()); |
333 layout_box_->layer()->setStaticBlockPosition(offset.block_offset); | 344 layout_box_->layer()->setStaticBlockPosition(offset.block_offset); |
334 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset); | 345 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset); |
335 } | 346 } |
336 | 347 |
337 } // namespace blink | 348 } // namespace blink |
OLD | NEW |