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

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

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

Powered by Google App Engine
This is Rietveld 408576698