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

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

Issue 2692403003: [LayoutNG] Make NGBlockLayoutAlgorithm accept a NGBlockNode. (Closed)
Patch Set: comments! Created 3 years, 10 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 RefPtr<NGPhysicalFragment> NGBlockNode::Layout( 79 RefPtr<NGPhysicalFragment> NGBlockNode::Layout(
80 NGConstraintSpace* constraint_space) { 80 NGConstraintSpace* constraint_space) {
81 // Use the old layout code and synthesize a fragment. 81 // Use the old layout code and synthesize a fragment.
82 if (!CanUseNewLayout()) { 82 if (!CanUseNewLayout()) {
83 DCHECK(layout_box_); 83 DCHECK(layout_box_);
84 fragment_ = RunOldLayout(*constraint_space); 84 fragment_ = RunOldLayout(*constraint_space);
85 return fragment_; 85 return fragment_;
86 } 86 }
87 87
88 RefPtr<NGPhysicalFragment> fragment = 88 RefPtr<NGPhysicalFragment> fragment =
89 NGBlockLayoutAlgorithm(GetLayoutObject(), &Style(), FirstChild(), 89 NGBlockLayoutAlgorithm(this, constraint_space, CurrentBreakToken())
90 constraint_space, CurrentBreakToken())
91 .Layout(); 90 .Layout();
92 91
93 fragment_ = toNGPhysicalBoxFragment(fragment.get()); 92 fragment_ = toNGPhysicalBoxFragment(fragment.get());
94 CopyFragmentDataToLayoutBox(*constraint_space); 93 CopyFragmentDataToLayoutBox(*constraint_space);
95 return fragment_; 94 return fragment_;
96 } 95 }
97 96
98 MinAndMaxContentSizes NGBlockNode::ComputeMinAndMaxContentSizes() { 97 MinAndMaxContentSizes NGBlockNode::ComputeMinAndMaxContentSizes() {
99 MinAndMaxContentSizes sizes; 98 MinAndMaxContentSizes sizes;
100 if (!CanUseNewLayout()) { 99 if (!CanUseNewLayout()) {
(...skipping 13 matching lines...) Expand all
114 return sizes; 113 return sizes;
115 } 114 }
116 115
117 NGConstraintSpace* constraint_space = 116 NGConstraintSpace* constraint_space =
118 NGConstraintSpaceBuilder( 117 NGConstraintSpaceBuilder(
119 FromPlatformWritingMode(Style().getWritingMode())) 118 FromPlatformWritingMode(Style().getWritingMode()))
120 .SetTextDirection(Style().direction()) 119 .SetTextDirection(Style().direction())
121 .ToConstraintSpace(FromPlatformWritingMode(Style().getWritingMode())); 120 .ToConstraintSpace(FromPlatformWritingMode(Style().getWritingMode()));
122 121
123 // TODO(cbiesinger): For orthogonal children, we need to always synthesize. 122 // TODO(cbiesinger): For orthogonal children, we need to always synthesize.
124 NGBlockLayoutAlgorithm minmax_algorithm(layout_box_, &Style(), FirstChild(), 123 NGBlockLayoutAlgorithm minmax_algorithm(this, constraint_space);
125 constraint_space);
126 Optional<MinAndMaxContentSizes> maybe_sizes = 124 Optional<MinAndMaxContentSizes> maybe_sizes =
127 minmax_algorithm.ComputeMinAndMaxContentSizes(); 125 minmax_algorithm.ComputeMinAndMaxContentSizes();
128 if (maybe_sizes.has_value()) 126 if (maybe_sizes.has_value())
129 return *maybe_sizes; 127 return *maybe_sizes;
130 128
131 // Have to synthesize this value. 129 // Have to synthesize this value.
132 RefPtr<NGPhysicalFragment> physical_fragment = Layout(constraint_space); 130 RefPtr<NGPhysicalFragment> physical_fragment = Layout(constraint_space);
133 NGBoxFragment min_fragment(FromPlatformWritingMode(Style().getWritingMode()), 131 NGBoxFragment min_fragment(FromPlatformWritingMode(Style().getWritingMode()),
134 toNGPhysicalBoxFragment(physical_fragment.get())); 132 toNGPhysicalBoxFragment(physical_fragment.get()));
135 sizes.min_content = min_fragment.InlineOverflow(); 133 sizes.min_content = min_fragment.InlineOverflow();
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } 296 }
299 297
300 if (layout_box_->isLayoutNGBlockFlow() && layout_box_->needsLayout()) { 298 if (layout_box_->isLayoutNGBlockFlow() && layout_box_->needsLayout()) {
301 toLayoutNGBlockFlow(layout_box_)->LayoutBlockFlow::layoutBlock(true); 299 toLayoutNGBlockFlow(layout_box_)->LayoutBlockFlow::layoutBlock(true);
302 } else { 300 } else {
303 layout_box_->forceLayout(); 301 layout_box_->forceLayout();
304 } 302 }
305 LayoutRect overflow = layout_box_->layoutOverflowRect(); 303 LayoutRect overflow = layout_box_->layoutOverflowRect();
306 // TODO(layout-ng): This does not handle writing modes correctly (for 304 // TODO(layout-ng): This does not handle writing modes correctly (for
307 // overflow) 305 // overflow)
308 NGFragmentBuilder builder(NGPhysicalFragment::kFragmentBox, layout_box_); 306 NGFragmentBuilder builder(NGPhysicalFragment::kFragmentBox, this);
309 builder.SetInlineSize(layout_box_->logicalWidth()) 307 builder.SetInlineSize(layout_box_->logicalWidth())
310 .SetBlockSize(layout_box_->logicalHeight()) 308 .SetBlockSize(layout_box_->logicalHeight())
311 .SetDirection(layout_box_->styleRef().direction()) 309 .SetDirection(layout_box_->styleRef().direction())
312 .SetWritingMode( 310 .SetWritingMode(
313 FromPlatformWritingMode(layout_box_->styleRef().getWritingMode())) 311 FromPlatformWritingMode(layout_box_->styleRef().getWritingMode()))
314 .SetInlineOverflow(overflow.width()) 312 .SetInlineOverflow(overflow.width())
315 .SetBlockOverflow(overflow.height()); 313 .SetBlockOverflow(overflow.height());
316 return builder.ToBoxFragment(); 314 return builder.ToBoxFragment();
317 } 315 }
318 316
319 void NGBlockNode::UseOldOutOfFlowPositioning() { 317 void NGBlockNode::UseOldOutOfFlowPositioning() {
320 DCHECK(layout_box_); 318 DCHECK(layout_box_);
321 DCHECK(layout_box_->isOutOfFlowPositioned()); 319 DCHECK(layout_box_->isOutOfFlowPositioned());
322 layout_box_->containingBlock()->insertPositionedObject(layout_box_); 320 layout_box_->containingBlock()->insertPositionedObject(layout_box_);
323 } 321 }
324 322
325 // Save static position for legacy AbsPos layout. 323 // Save static position for legacy AbsPos layout.
326 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { 324 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) {
327 DCHECK(layout_box_); 325 DCHECK(layout_box_);
328 DCHECK(layout_box_->isOutOfFlowPositioned()); 326 DCHECK(layout_box_->isOutOfFlowPositioned());
329 DCHECK(layout_box_->layer()); 327 DCHECK(layout_box_->layer());
330 layout_box_->layer()->setStaticBlockPosition(offset.block_offset); 328 layout_box_->layer()->setStaticBlockPosition(offset.block_offset);
331 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset); 329 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset);
332 } 330 }
333 331
334 } // namespace blink 332 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698