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_box.cc

Issue 2456973002: [LayoutNG] Move ng_block_layout_algorithm to use constraint space builder. (Closed)
Patch Set: rebase. Created 4 years, 1 month 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_box.h" 5 #include "core/layout/ng/ng_box.h"
6 6
7 #include "core/layout/LayoutBlockFlow.h" 7 #include "core/layout/LayoutBlockFlow.h"
8 #include "core/layout/ng/layout_ng_block_flow.h" 8 #include "core/layout/ng/layout_ng_block_flow.h"
9 #include "core/layout/ng/ng_block_layout_algorithm.h" 9 #include "core/layout/ng/ng_block_layout_algorithm.h"
10 #include "core/layout/ng/ng_constraint_space.h" 10 #include "core/layout/ng/ng_constraint_space.h"
(...skipping 15 matching lines...) Expand all
26 } 26 }
27 27
28 bool NGBox::Layout(const NGConstraintSpace* constraint_space, 28 bool NGBox::Layout(const NGConstraintSpace* constraint_space,
29 NGFragment** out) { 29 NGFragment** out) {
30 if (layout_box_ && layout_box_->isOutOfFlowPositioned()) 30 if (layout_box_ && layout_box_->isOutOfFlowPositioned())
31 layout_box_->containingBlock()->insertPositionedObject(layout_box_); 31 layout_box_->containingBlock()->insertPositionedObject(layout_box_);
32 // We can either use the new layout code to do the layout and then copy the 32 // We can either use the new layout code to do the layout and then copy the
33 // resulting size to the LayoutObject, or use the old layout code and 33 // resulting size to the LayoutObject, or use the old layout code and
34 // synthesize a fragment. 34 // synthesize a fragment.
35 if (CanUseNewLayout()) { 35 if (CanUseNewLayout()) {
36 if (!algorithm_)
37 algorithm_ = new NGBlockLayoutAlgorithm(Style(), FirstChild());
38 // Change the coordinate system of the constraint space. 36 // Change the coordinate system of the constraint space.
39 NGConstraintSpace* child_constraint_space = new NGConstraintSpace( 37 NGConstraintSpace* child_constraint_space = new NGConstraintSpace(
40 FromPlatformWritingMode(Style()->getWritingMode()), 38 FromPlatformWritingMode(Style()->getWritingMode()),
41 FromPlatformDirection(Style()->direction()), 39 FromPlatformDirection(Style()->direction()),
42 constraint_space->MutablePhysicalSpace()); 40 constraint_space->MutablePhysicalSpace());
43 41
42 if (!algorithm_)
43 algorithm_ = new NGBlockLayoutAlgorithm(Style(), FirstChild(),
44 child_constraint_space);
45
44 NGPhysicalFragment* fragment = nullptr; 46 NGPhysicalFragment* fragment = nullptr;
45 if (!algorithm_->Layout(child_constraint_space, &fragment)) 47 if (!algorithm_->Layout(&fragment))
46 return false; 48 return false;
47 fragment_ = fragment; 49 fragment_ = fragment;
48 50
49 if (layout_box_) { 51 if (layout_box_) {
50 CopyFragmentDataToLayoutBox(*constraint_space); 52 CopyFragmentDataToLayoutBox(*constraint_space);
51 } 53 }
52 } else { 54 } else {
53 DCHECK(layout_box_); 55 DCHECK(layout_box_);
54 fragment_ = RunOldLayout(*constraint_space); 56 fragment_ = RunOldLayout(*constraint_space);
55 } 57 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 .SetBlockSize(layout_box_->logicalHeight()) 179 .SetBlockSize(layout_box_->logicalHeight())
178 .SetDirection(FromPlatformDirection(layout_box_->styleRef().direction())) 180 .SetDirection(FromPlatformDirection(layout_box_->styleRef().direction()))
179 .SetWritingMode( 181 .SetWritingMode(
180 FromPlatformWritingMode(layout_box_->styleRef().getWritingMode())) 182 FromPlatformWritingMode(layout_box_->styleRef().getWritingMode()))
181 .SetInlineOverflow(overflow.width()) 183 .SetInlineOverflow(overflow.width())
182 .SetBlockOverflow(overflow.height()); 184 .SetBlockOverflow(overflow.height());
183 return builder.ToFragment(); 185 return builder.ToFragment();
184 } 186 }
185 187
186 } // namespace blink 188 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698