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

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

Issue 2724133003: [LayoutNG] Switch NGConstraintSpace to being RefCounted. (Closed)
Patch Set: moar. 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"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 MainOrPreferredSize, Length(MinContent), 109 MainOrPreferredSize, Length(MinContent),
110 LayoutUnit(), layout_box_->containingBlock()) - 110 LayoutUnit(), layout_box_->containingBlock()) -
111 borderAndPadding; 111 borderAndPadding;
112 sizes.max_content = layout_box_->computeLogicalWidthUsing( 112 sizes.max_content = layout_box_->computeLogicalWidthUsing(
113 MainOrPreferredSize, Length(MaxContent), 113 MainOrPreferredSize, Length(MaxContent),
114 LayoutUnit(), layout_box_->containingBlock()) - 114 LayoutUnit(), layout_box_->containingBlock()) -
115 borderAndPadding; 115 borderAndPadding;
116 return sizes; 116 return sizes;
117 } 117 }
118 118
119 NGConstraintSpace* constraint_space = 119 RefPtr<NGConstraintSpace> constraint_space =
120 NGConstraintSpaceBuilder( 120 NGConstraintSpaceBuilder(
121 FromPlatformWritingMode(Style().getWritingMode())) 121 FromPlatformWritingMode(Style().getWritingMode()))
122 .SetTextDirection(Style().direction()) 122 .SetTextDirection(Style().direction())
123 .ToConstraintSpace(FromPlatformWritingMode(Style().getWritingMode())); 123 .ToConstraintSpace(FromPlatformWritingMode(Style().getWritingMode()));
124 124
125 // TODO(cbiesinger): For orthogonal children, we need to always synthesize. 125 // TODO(cbiesinger): For orthogonal children, we need to always synthesize.
126 NGBlockLayoutAlgorithm minmax_algorithm(this, constraint_space); 126 NGBlockLayoutAlgorithm minmax_algorithm(this, constraint_space.get());
127 Optional<MinAndMaxContentSizes> maybe_sizes = 127 Optional<MinAndMaxContentSizes> maybe_sizes =
128 minmax_algorithm.ComputeMinAndMaxContentSizes(); 128 minmax_algorithm.ComputeMinAndMaxContentSizes();
129 if (maybe_sizes.has_value()) 129 if (maybe_sizes.has_value())
130 return *maybe_sizes; 130 return *maybe_sizes;
131 131
132 // Have to synthesize this value. 132 // Have to synthesize this value.
133 RefPtr<NGLayoutResult> layout_result = Layout(constraint_space); 133 RefPtr<NGLayoutResult> layout_result = Layout(constraint_space.get());
134 NGPhysicalFragment* physical_fragment = 134 NGPhysicalFragment* physical_fragment =
135 layout_result->PhysicalFragment().get(); 135 layout_result->PhysicalFragment().get();
136 NGBoxFragment min_fragment(FromPlatformWritingMode(Style().getWritingMode()), 136 NGBoxFragment min_fragment(FromPlatformWritingMode(Style().getWritingMode()),
137 toNGPhysicalBoxFragment(physical_fragment)); 137 toNGPhysicalBoxFragment(physical_fragment));
138 sizes.min_content = min_fragment.InlineOverflow(); 138 sizes.min_content = min_fragment.InlineOverflow();
139 139
140 // Now, redo with infinite space for max_content 140 // Now, redo with infinite space for max_content
141 constraint_space = 141 constraint_space =
142 NGConstraintSpaceBuilder( 142 NGConstraintSpaceBuilder(
143 FromPlatformWritingMode(Style().getWritingMode())) 143 FromPlatformWritingMode(Style().getWritingMode()))
144 .SetTextDirection(Style().direction()) 144 .SetTextDirection(Style().direction())
145 .SetAvailableSize({LayoutUnit::max(), LayoutUnit()}) 145 .SetAvailableSize({LayoutUnit::max(), LayoutUnit()})
146 .SetPercentageResolutionSize({LayoutUnit(), LayoutUnit()}) 146 .SetPercentageResolutionSize({LayoutUnit(), LayoutUnit()})
147 .ToConstraintSpace(FromPlatformWritingMode(Style().getWritingMode())); 147 .ToConstraintSpace(FromPlatformWritingMode(Style().getWritingMode()));
148 148
149 layout_result = Layout(constraint_space); 149 layout_result = Layout(constraint_space.get());
150 physical_fragment = layout_result->PhysicalFragment().get(); 150 physical_fragment = layout_result->PhysicalFragment().get();
151 NGBoxFragment max_fragment(FromPlatformWritingMode(Style().getWritingMode()), 151 NGBoxFragment max_fragment(FromPlatformWritingMode(Style().getWritingMode()),
152 toNGPhysicalBoxFragment(physical_fragment)); 152 toNGPhysicalBoxFragment(physical_fragment));
153 sizes.max_content = max_fragment.InlineOverflow(); 153 sizes.max_content = max_fragment.InlineOverflow();
154 return sizes; 154 return sizes;
155 } 155 }
156 156
157 const ComputedStyle& NGBlockNode::Style() const { 157 const ComputedStyle& NGBlockNode::Style() const {
158 if (style_) 158 if (style_)
159 return *style_.get(); 159 return *style_.get();
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 // Save static position for legacy AbsPos layout. 350 // Save static position for legacy AbsPos layout.
351 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { 351 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) {
352 DCHECK(layout_box_); 352 DCHECK(layout_box_);
353 DCHECK(layout_box_->isOutOfFlowPositioned()); 353 DCHECK(layout_box_->isOutOfFlowPositioned());
354 DCHECK(layout_box_->layer()); 354 DCHECK(layout_box_->layer());
355 layout_box_->layer()->setStaticBlockPosition(offset.block_offset); 355 layout_box_->layer()->setStaticBlockPosition(offset.block_offset);
356 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset); 356 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset);
357 } 357 }
358 358
359 } // namespace blink 359 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698