OLD | NEW |
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 21 matching lines...) Expand all Loading... |
32 layout_box_(nullptr), | 32 layout_box_(nullptr), |
33 style_(style) { | 33 style_(style) { |
34 DCHECK(style_); | 34 DCHECK(style_); |
35 } | 35 } |
36 | 36 |
37 // Need an explicit destructor in the .cc file, or the MSWIN compiler will | 37 // Need an explicit destructor in the .cc file, or the MSWIN compiler will |
38 // produce an error when attempting to generate a default one, if the .h file is | 38 // produce an error when attempting to generate a default one, if the .h file is |
39 // included from a compilation unit that lacks the ComputedStyle definition. | 39 // included from a compilation unit that lacks the ComputedStyle definition. |
40 NGBlockNode::~NGBlockNode() {} | 40 NGBlockNode::~NGBlockNode() {} |
41 | 41 |
42 bool NGBlockNode::Layout(const NGConstraintSpace* constraint_space, | 42 bool NGBlockNode::Layout(NGConstraintSpace* constraint_space, |
43 NGFragmentBase** out) { | 43 NGFragmentBase** out) { |
44 DCHECK(!minmax_algorithm_) | 44 DCHECK(!minmax_algorithm_) |
45 << "Can't interleave Layout and ComputeMinAndMaxContentSizes"; | 45 << "Can't interleave Layout and ComputeMinAndMaxContentSizes"; |
46 if (layout_box_ && layout_box_->isOutOfFlowPositioned()) | 46 if (layout_box_ && layout_box_->isOutOfFlowPositioned()) |
47 layout_box_->containingBlock()->insertPositionedObject(layout_box_); | 47 layout_box_->containingBlock()->insertPositionedObject(layout_box_); |
48 // We can either use the new layout code to do the layout and then copy the | 48 // We can either use the new layout code to do the layout and then copy the |
49 // resulting size to the LayoutObject, or use the old layout code and | 49 // resulting size to the LayoutObject, or use the old layout code and |
50 // synthesize a fragment. | 50 // synthesize a fragment. |
51 if (CanUseNewLayout()) { | 51 if (CanUseNewLayout()) { |
52 NGPhysicalFragmentBase* fragment; | 52 NGPhysicalFragmentBase* fragment; |
53 | 53 |
54 // Store a coordinator so Layout can preserve its existing semantic | 54 // Store a coordinator so Layout can preserve its existing semantic |
55 // of returning false until completed. | 55 // of returning false until completed. |
56 if (!layout_coordinator_) | 56 if (!layout_coordinator_) |
57 layout_coordinator_ = new NGLayoutCoordinator(this, constraint_space); | 57 layout_coordinator_ = new NGLayoutCoordinator(this, constraint_space); |
58 | 58 |
59 if (!layout_coordinator_->Tick(&fragment)) | 59 if (!layout_coordinator_->Tick(&fragment)) |
60 return false; | 60 return false; |
61 | 61 |
62 fragment_ = toNGPhysicalFragment(fragment); | 62 fragment_ = toNGPhysicalFragment(fragment); |
63 | 63 |
64 UpdateLayoutBox(fragment_, constraint_space); | 64 UpdateLayoutBox(fragment_, constraint_space); |
65 } else { | 65 } else { |
66 DCHECK(layout_box_); | 66 DCHECK(layout_box_); |
67 fragment_ = RunOldLayout(*constraint_space); | 67 fragment_ = RunOldLayout(*constraint_space); |
68 } | 68 } |
69 *out = new NGFragment(constraint_space->WritingMode(), Style()->direction(), | 69 *out = new NGFragment(FromPlatformWritingMode(Style()->getWritingMode()), |
70 fragment_.get()); | 70 Style()->direction(), fragment_.get()); |
71 // Reset coordinator for future use | 71 // Reset coordinator for future use |
72 layout_coordinator_ = nullptr; | 72 layout_coordinator_ = nullptr; |
73 return true; | 73 return true; |
74 } | 74 } |
75 | 75 |
76 void NGBlockNode::UpdateLayoutBox(NGPhysicalFragment* fragment, | 76 void NGBlockNode::UpdateLayoutBox(NGPhysicalFragment* fragment, |
77 const NGConstraintSpace* constraint_space) { | 77 const NGConstraintSpace* constraint_space) { |
78 fragment_ = fragment; | 78 fragment_ = fragment; |
79 if (layout_box_) { | 79 if (layout_box_) { |
80 CopyFragmentDataToLayoutBox(*constraint_space); | 80 CopyFragmentDataToLayoutBox(*constraint_space); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 .SetBlockSize(layout_box_->logicalHeight()) | 319 .SetBlockSize(layout_box_->logicalHeight()) |
320 .SetDirection(layout_box_->styleRef().direction()) | 320 .SetDirection(layout_box_->styleRef().direction()) |
321 .SetWritingMode( | 321 .SetWritingMode( |
322 FromPlatformWritingMode(layout_box_->styleRef().getWritingMode())) | 322 FromPlatformWritingMode(layout_box_->styleRef().getWritingMode())) |
323 .SetInlineOverflow(overflow.width()) | 323 .SetInlineOverflow(overflow.width()) |
324 .SetBlockOverflow(overflow.height()); | 324 .SetBlockOverflow(overflow.height()); |
325 return builder.ToFragment(); | 325 return builder.ToFragment(); |
326 } | 326 } |
327 | 327 |
328 } // namespace blink | 328 } // namespace blink |
OLD | NEW |