| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 if (!minmax_algorithm_) { | 93 if (!minmax_algorithm_) { |
| 94 NGConstraintSpaceBuilder builder( | 94 NGConstraintSpaceBuilder builder( |
| 95 FromPlatformWritingMode(Style()->getWritingMode())); | 95 FromPlatformWritingMode(Style()->getWritingMode())); |
| 96 | 96 |
| 97 builder.SetAvailableSize(NGLogicalSize(LayoutUnit(), LayoutUnit())); | 97 builder.SetAvailableSize(NGLogicalSize(LayoutUnit(), LayoutUnit())); |
| 98 builder.SetPercentageResolutionSize( | 98 builder.SetPercentageResolutionSize( |
| 99 NGLogicalSize(LayoutUnit(), LayoutUnit())); | 99 NGLogicalSize(LayoutUnit(), LayoutUnit())); |
| 100 // TODO(layoutng): Use builder.ToConstraintSpace.ToLogicalConstraintSpace | 100 // TODO(layoutng): Use builder.ToConstraintSpace.ToLogicalConstraintSpace |
| 101 // once | 101 // once |
| 102 // that's available. | 102 // that's available. |
| 103 NGConstraintSpace* constraint_space = new NGConstraintSpace( | 103 NGConstraintSpace* constraint_space = |
| 104 FromPlatformWritingMode(Style()->getWritingMode()), | 104 NGConstraintSpaceBuilder( |
| 105 Style()->direction(), builder.ToConstraintSpace()); | 105 FromPlatformWritingMode(Style()->getWritingMode())) |
| 106 .SetTextDirection(Style()->direction()) |
| 107 .ToConstraintSpace(); |
| 106 | 108 |
| 107 minmax_algorithm_ = new NGBlockLayoutAlgorithm( | 109 minmax_algorithm_ = new NGBlockLayoutAlgorithm( |
| 108 Style(), toNGBlockNode(FirstChild()), constraint_space); | 110 Style(), toNGBlockNode(FirstChild()), constraint_space); |
| 109 } | 111 } |
| 110 // TODO(cbiesinger): For orthogonal children, we need to always synthesize. | 112 // TODO(cbiesinger): For orthogonal children, we need to always synthesize. |
| 111 NGLayoutAlgorithm::MinAndMaxState state = | 113 NGLayoutAlgorithm::MinAndMaxState state = |
| 112 minmax_algorithm_->ComputeMinAndMaxContentSizes(sizes); | 114 minmax_algorithm_->ComputeMinAndMaxContentSizes(sizes); |
| 113 if (state == NGLayoutAlgorithm::Success) | 115 if (state == NGLayoutAlgorithm::Success) |
| 114 return true; | 116 return true; |
| 115 if (state == NGLayoutAlgorithm::Pending) | 117 if (state == NGLayoutAlgorithm::Pending) |
| 116 return false; | 118 return false; |
| 117 DCHECK_EQ(state, NGLayoutAlgorithm::NotImplemented); | 119 DCHECK_EQ(state, NGLayoutAlgorithm::NotImplemented); |
| 118 | 120 |
| 119 // TODO(cbiesinger): Replace the loops below with a state machine like in | 121 // TODO(cbiesinger): Replace the loops below with a state machine like in |
| 120 // Layout. | 122 // Layout. |
| 121 | 123 |
| 122 // Have to synthesize this value. | 124 // Have to synthesize this value. |
| 123 NGPhysicalFragmentBase* physical_fragment; | 125 NGPhysicalFragmentBase* physical_fragment; |
| 124 while (!minmax_algorithm_->Layout(nullptr, &physical_fragment, nullptr)) | 126 while (!minmax_algorithm_->Layout(nullptr, &physical_fragment, nullptr)) |
| 125 continue; | 127 continue; |
| 126 NGFragment* fragment = new NGFragment( | 128 NGFragment* fragment = new NGFragment( |
| 127 FromPlatformWritingMode(Style()->getWritingMode()), Style()->direction(), | 129 FromPlatformWritingMode(Style()->getWritingMode()), Style()->direction(), |
| 128 toNGPhysicalFragment(physical_fragment)); | 130 toNGPhysicalFragment(physical_fragment)); |
| 129 | 131 |
| 130 sizes->min_content = fragment->InlineOverflow(); | 132 sizes->min_content = fragment->InlineOverflow(); |
| 131 | 133 |
| 132 // Now, redo with infinite space for max_content | 134 // Now, redo with infinite space for max_content |
| 133 NGConstraintSpaceBuilder builder( | |
| 134 FromPlatformWritingMode(Style()->getWritingMode())); | |
| 135 builder.SetAvailableSize(NGLogicalSize(LayoutUnit::max(), LayoutUnit())); | |
| 136 builder.SetPercentageResolutionSize( | |
| 137 NGLogicalSize(LayoutUnit(), LayoutUnit())); | |
| 138 NGConstraintSpace* constraint_space = | 135 NGConstraintSpace* constraint_space = |
| 139 new NGConstraintSpace(FromPlatformWritingMode(Style()->getWritingMode()), | 136 NGConstraintSpaceBuilder( |
| 140 Style()->direction(), builder.ToConstraintSpace()); | 137 FromPlatformWritingMode(Style()->getWritingMode())) |
| 138 .SetTextDirection(Style()->direction()) |
| 139 .SetAvailableSize({LayoutUnit::max(), LayoutUnit()}) |
| 140 .SetPercentageResolutionSize({LayoutUnit(), LayoutUnit()}) |
| 141 .ToConstraintSpace(); |
| 141 | 142 |
| 142 minmax_algorithm_ = new NGBlockLayoutAlgorithm( | 143 minmax_algorithm_ = new NGBlockLayoutAlgorithm( |
| 143 Style(), toNGBlockNode(FirstChild()), constraint_space); | 144 Style(), toNGBlockNode(FirstChild()), constraint_space); |
| 144 while (!minmax_algorithm_->Layout(nullptr, &physical_fragment, nullptr)) | 145 while (!minmax_algorithm_->Layout(nullptr, &physical_fragment, nullptr)) |
| 145 continue; | 146 continue; |
| 146 | 147 |
| 147 fragment = new NGFragment(FromPlatformWritingMode(Style()->getWritingMode()), | 148 fragment = new NGFragment(FromPlatformWritingMode(Style()->getWritingMode()), |
| 148 Style()->direction(), | 149 Style()->direction(), |
| 149 toNGPhysicalFragment(physical_fragment)); | 150 toNGPhysicalFragment(physical_fragment)); |
| 150 sizes->max_content = fragment->InlineOverflow(); | 151 sizes->max_content = fragment->InlineOverflow(); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 .SetBlockSize(layout_box_->logicalHeight()) | 316 .SetBlockSize(layout_box_->logicalHeight()) |
| 316 .SetDirection(layout_box_->styleRef().direction()) | 317 .SetDirection(layout_box_->styleRef().direction()) |
| 317 .SetWritingMode( | 318 .SetWritingMode( |
| 318 FromPlatformWritingMode(layout_box_->styleRef().getWritingMode())) | 319 FromPlatformWritingMode(layout_box_->styleRef().getWritingMode())) |
| 319 .SetInlineOverflow(overflow.width()) | 320 .SetInlineOverflow(overflow.width()) |
| 320 .SetBlockOverflow(overflow.height()); | 321 .SetBlockOverflow(overflow.height()); |
| 321 return builder.ToFragment(); | 322 return builder.ToFragment(); |
| 322 } | 323 } |
| 323 | 324 |
| 324 } // namespace blink | 325 } // namespace blink |
| OLD | NEW |