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

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

Issue 2668183003: [LayoutNG] Make NG algorithms non-oilpan. (Closed)
Patch Set: fix win compile 2? 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"
11 #include "core/layout/ng/ng_block_layout_algorithm.h" 11 #include "core/layout/ng/ng_block_layout_algorithm.h"
12 #include "core/layout/ng/ng_box_fragment.h" 12 #include "core/layout/ng/ng_box_fragment.h"
13 #include "core/layout/ng/ng_constraint_space.h" 13 #include "core/layout/ng/ng_constraint_space.h"
14 #include "core/layout/ng/ng_constraint_space_builder.h" 14 #include "core/layout/ng/ng_constraint_space_builder.h"
15 #include "core/layout/ng/ng_fragment_builder.h" 15 #include "core/layout/ng/ng_fragment_builder.h"
16 #include "core/layout/ng/ng_inline_layout_algorithm.h"
16 #include "core/layout/ng/ng_inline_node.h" 17 #include "core/layout/ng/ng_inline_node.h"
17 #include "core/layout/ng/ng_length_utils.h" 18 #include "core/layout/ng/ng_length_utils.h"
18 #include "core/layout/ng/ng_writing_mode.h" 19 #include "core/layout/ng/ng_writing_mode.h"
19 #include "core/paint/PaintLayer.h" 20 #include "core/paint/PaintLayer.h"
20 #include "platform/RuntimeEnabledFeatures.h" 21 #include "platform/RuntimeEnabledFeatures.h"
21 22
22 namespace blink { 23 namespace blink {
23 24
24 namespace { 25 namespace {
25 26
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 style_(style) { 73 style_(style) {
73 DCHECK(style_); 74 DCHECK(style_);
74 } 75 }
75 76
76 // Need an explicit destructor in the .cc file, or the MSWIN compiler will 77 // Need an explicit destructor in the .cc file, or the MSWIN compiler will
77 // produce an error when attempting to generate a default one, if the .h file is 78 // produce an error when attempting to generate a default one, if the .h file is
78 // included from a compilation unit that lacks the ComputedStyle definition. 79 // included from a compilation unit that lacks the ComputedStyle definition.
79 NGBlockNode::~NGBlockNode() {} 80 NGBlockNode::~NGBlockNode() {}
80 81
81 NGPhysicalFragment* NGBlockNode::Layout(NGConstraintSpace* constraint_space) { 82 NGPhysicalFragment* NGBlockNode::Layout(NGConstraintSpace* constraint_space) {
82 // We can either use the new layout code to do the layout and then copy the 83 // Use the old layout code and synthesize a fragment.
83 // resulting size to the LayoutObject, or use the old layout code and 84 if (!CanUseNewLayout()) {
84 // synthesize a fragment.
85 if (CanUseNewLayout()) {
86 NGLayoutAlgorithm* algorithm =
87 NGLayoutInputNode::AlgorithmForInputNode(this, constraint_space);
88 fragment_ = toNGPhysicalBoxFragment(algorithm->Layout());
89 CopyFragmentDataToLayoutBox(*constraint_space);
90 } else {
91 DCHECK(layout_box_); 85 DCHECK(layout_box_);
92 fragment_ = RunOldLayout(*constraint_space); 86 fragment_ = RunOldLayout(*constraint_space);
87 return fragment_;
93 } 88 }
94 89
90 NGPhysicalFragment* fragment;
91
92 if (HasInlineChildren()) {
93 fragment =
94 NGInlineLayoutAlgorithm(GetLayoutObject(), &Style(),
95 toNGInlineNode(FirstChild()), constraint_space)
96 .Layout();
97 } else {
98 fragment = NGBlockLayoutAlgorithm(GetLayoutObject(), &Style(),
99 toNGBlockNode(FirstChild()),
100 constraint_space, CurrentBreakToken())
101 .Layout();
102 }
103
104 fragment_ = toNGPhysicalBoxFragment(fragment);
105 CopyFragmentDataToLayoutBox(*constraint_space);
95 return fragment_; 106 return fragment_;
96 } 107 }
97 108
98 MinAndMaxContentSizes NGBlockNode::ComputeMinAndMaxContentSizes() { 109 MinAndMaxContentSizes NGBlockNode::ComputeMinAndMaxContentSizes() {
99 MinAndMaxContentSizes sizes; 110 MinAndMaxContentSizes sizes;
100 if (!CanUseNewLayout()) { 111 if (!CanUseNewLayout()) {
101 DCHECK(layout_box_); 112 DCHECK(layout_box_);
102 // TODO(layout-ng): This could be somewhat optimized by directly calling 113 // TODO(layout-ng): This could be somewhat optimized by directly calling
103 // computeIntrinsicLogicalWidths, but that function is currently private. 114 // computeIntrinsicLogicalWidths, but that function is currently private.
104 // Consider doing that if this becomes a performance issue. 115 // Consider doing that if this becomes a performance issue.
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 // Save static position for legacy AbsPos layout. 343 // Save static position for legacy AbsPos layout.
333 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { 344 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) {
334 DCHECK(layout_box_); 345 DCHECK(layout_box_);
335 DCHECK(layout_box_->isOutOfFlowPositioned()); 346 DCHECK(layout_box_->isOutOfFlowPositioned());
336 DCHECK(layout_box_->layer()); 347 DCHECK(layout_box_->layer());
337 layout_box_->layer()->setStaticBlockPosition(offset.block_offset); 348 layout_box_->layer()->setStaticBlockPosition(offset.block_offset);
338 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset); 349 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset);
339 } 350 }
340 351
341 } // namespace blink 352 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698