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

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

Issue 2721613003: [LayoutNG] Move remaining ng_units structs to their own files (Closed)
Patch Set: Don't export NGBoxStrut for now 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"
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_constraint_space.h" 14 #include "core/layout/ng/ng_constraint_space.h"
15 #include "core/layout/ng/ng_constraint_space_builder.h" 15 #include "core/layout/ng/ng_constraint_space_builder.h"
16 #include "core/layout/ng/ng_fragment_builder.h" 16 #include "core/layout/ng/ng_fragment_builder.h"
17 #include "core/layout/ng/ng_inline_node.h" 17 #include "core/layout/ng/ng_inline_node.h"
18 #include "core/layout/ng/ng_layout_result.h" 18 #include "core/layout/ng/ng_layout_result.h"
19 #include "core/layout/ng/ng_length_utils.h" 19 #include "core/layout/ng/ng_length_utils.h"
20 #include "core/layout/ng/ng_min_max_content_size.h"
20 #include "core/layout/ng/ng_writing_mode.h" 21 #include "core/layout/ng/ng_writing_mode.h"
21 #include "core/paint/PaintLayer.h" 22 #include "core/paint/PaintLayer.h"
22 #include "platform/RuntimeEnabledFeatures.h" 23 #include "platform/RuntimeEnabledFeatures.h"
23 24
24 namespace blink { 25 namespace blink {
25 26
26 namespace { 27 namespace {
27 28
28 // Copies data back to the legacy layout tree for a given child fragment. 29 // Copies data back to the legacy layout tree for a given child fragment.
29 void FragmentPositionUpdated(const NGPhysicalFragment& fragment) { 30 void FragmentPositionUpdated(const NGPhysicalFragment& fragment) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 98 }
98 99
99 layout_result_ = NGBlockLayoutAlgorithm(this, constraint_space, 100 layout_result_ = NGBlockLayoutAlgorithm(this, constraint_space,
100 toNGBlockBreakToken(break_token)) 101 toNGBlockBreakToken(break_token))
101 .Layout(); 102 .Layout();
102 103
103 CopyFragmentDataToLayoutBox(*constraint_space); 104 CopyFragmentDataToLayoutBox(*constraint_space);
104 return layout_result_; 105 return layout_result_;
105 } 106 }
106 107
107 MinAndMaxContentSizes NGBlockNode::ComputeMinAndMaxContentSizes() { 108 MinMaxContentSize NGBlockNode::ComputeMinMaxContentSize() {
108 MinAndMaxContentSizes sizes; 109 MinMaxContentSize sizes;
109 if (!CanUseNewLayout()) { 110 if (!CanUseNewLayout()) {
110 DCHECK(layout_box_); 111 DCHECK(layout_box_);
111 // TODO(layout-ng): This could be somewhat optimized by directly calling 112 // TODO(layout-ng): This could be somewhat optimized by directly calling
112 // computeIntrinsicLogicalWidths, but that function is currently private. 113 // computeIntrinsicLogicalWidths, but that function is currently private.
113 // Consider doing that if this becomes a performance issue. 114 // Consider doing that if this becomes a performance issue.
114 LayoutUnit borderAndPadding = layout_box_->borderAndPaddingLogicalWidth(); 115 LayoutUnit borderAndPadding = layout_box_->borderAndPaddingLogicalWidth();
115 sizes.min_content = layout_box_->computeLogicalWidthUsing( 116 sizes.min_content = layout_box_->computeLogicalWidthUsing(
116 MainOrPreferredSize, Length(MinContent), 117 MainOrPreferredSize, Length(MinContent),
117 LayoutUnit(), layout_box_->containingBlock()) - 118 LayoutUnit(), layout_box_->containingBlock()) -
118 borderAndPadding; 119 borderAndPadding;
119 sizes.max_content = layout_box_->computeLogicalWidthUsing( 120 sizes.max_content = layout_box_->computeLogicalWidthUsing(
120 MainOrPreferredSize, Length(MaxContent), 121 MainOrPreferredSize, Length(MaxContent),
121 LayoutUnit(), layout_box_->containingBlock()) - 122 LayoutUnit(), layout_box_->containingBlock()) -
122 borderAndPadding; 123 borderAndPadding;
123 return sizes; 124 return sizes;
124 } 125 }
125 126
126 NGConstraintSpace* constraint_space = 127 NGConstraintSpace* constraint_space =
127 NGConstraintSpaceBuilder( 128 NGConstraintSpaceBuilder(
128 FromPlatformWritingMode(Style().getWritingMode())) 129 FromPlatformWritingMode(Style().getWritingMode()))
129 .SetTextDirection(Style().direction()) 130 .SetTextDirection(Style().direction())
130 .ToConstraintSpace(FromPlatformWritingMode(Style().getWritingMode())); 131 .ToConstraintSpace(FromPlatformWritingMode(Style().getWritingMode()));
131 132
132 // TODO(cbiesinger): For orthogonal children, we need to always synthesize. 133 // TODO(cbiesinger): For orthogonal children, we need to always synthesize.
133 NGBlockLayoutAlgorithm minmax_algorithm(this, constraint_space); 134 NGBlockLayoutAlgorithm minmax_algorithm(this, constraint_space);
134 Optional<MinAndMaxContentSizes> maybe_sizes = 135 Optional<MinMaxContentSize> maybe_sizes =
135 minmax_algorithm.ComputeMinAndMaxContentSizes(); 136 minmax_algorithm.ComputeMinMaxContentSize();
136 if (maybe_sizes.has_value()) 137 if (maybe_sizes.has_value())
137 return *maybe_sizes; 138 return *maybe_sizes;
138 139
139 // Have to synthesize this value. 140 // Have to synthesize this value.
140 RefPtr<NGLayoutResult> layout_result = Layout(constraint_space); 141 RefPtr<NGLayoutResult> layout_result = Layout(constraint_space);
141 NGPhysicalFragment* physical_fragment = 142 NGPhysicalFragment* physical_fragment =
142 layout_result->PhysicalFragment().get(); 143 layout_result->PhysicalFragment().get();
143 NGBoxFragment min_fragment(FromPlatformWritingMode(Style().getWritingMode()), 144 NGBoxFragment min_fragment(FromPlatformWritingMode(Style().getWritingMode()),
144 toNGPhysicalBoxFragment(physical_fragment)); 145 toNGPhysicalBoxFragment(physical_fragment));
145 sizes.min_content = min_fragment.InlineOverflow(); 146 sizes.min_content = min_fragment.InlineOverflow();
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // Save static position for legacy AbsPos layout. 366 // Save static position for legacy AbsPos layout.
366 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { 367 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) {
367 DCHECK(layout_box_); 368 DCHECK(layout_box_);
368 DCHECK(layout_box_->isOutOfFlowPositioned()); 369 DCHECK(layout_box_->isOutOfFlowPositioned());
369 DCHECK(layout_box_->layer()); 370 DCHECK(layout_box_->layer());
370 layout_box_->layer()->setStaticBlockPosition(offset.block_offset); 371 layout_box_->layer()->setStaticBlockPosition(offset.block_offset);
371 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset); 372 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset);
372 } 373 }
373 374
374 } // namespace blink 375 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698