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_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_builder.h" | 10 #include "core/layout/ng/ng_constraint_space_builder.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } | 60 } |
61 *out = new NGFragment(constraint_space->WritingMode(), | 61 *out = new NGFragment(constraint_space->WritingMode(), |
62 FromPlatformDirection(Style()->direction()), | 62 FromPlatformDirection(Style()->direction()), |
63 fragment_.get()); | 63 fragment_.get()); |
64 // Reset algorithm for future use | 64 // Reset algorithm for future use |
65 layout_algorithm_ = nullptr; | 65 layout_algorithm_ = nullptr; |
66 return true; | 66 return true; |
67 } | 67 } |
68 | 68 |
69 bool NGBox::ComputeMinAndMaxContentSizes(MinAndMaxContentSizes* sizes) { | 69 bool NGBox::ComputeMinAndMaxContentSizes(MinAndMaxContentSizes* sizes) { |
| 70 if (!CanUseNewLayout()) { |
| 71 DCHECK(layout_box_); |
| 72 // TODO(layout-ng): This could be somewhat optimized by directly calling |
| 73 // computeIntrinsicLogicalWidths, but that function is currently private. |
| 74 // Consider doing that if this becomes a performance issue. |
| 75 LayoutUnit borderAndPadding = layout_box_->borderAndPaddingLogicalWidth(); |
| 76 sizes->min_content = layout_box_->computeLogicalWidthUsing( |
| 77 MainOrPreferredSize, Length(MinContent), |
| 78 LayoutUnit(), layout_box_->containingBlock()) - |
| 79 borderAndPadding; |
| 80 sizes->max_content = layout_box_->computeLogicalWidthUsing( |
| 81 MainOrPreferredSize, Length(MaxContent), |
| 82 LayoutUnit(), layout_box_->containingBlock()) - |
| 83 borderAndPadding; |
| 84 return true; |
| 85 } |
70 DCHECK(!layout_algorithm_) | 86 DCHECK(!layout_algorithm_) |
71 << "Can't interleave Layout and ComputeMinAndMaxContentSizes"; | 87 << "Can't interleave Layout and ComputeMinAndMaxContentSizes"; |
72 if (!minmax_algorithm_) { | 88 if (!minmax_algorithm_) { |
73 NGConstraintSpaceBuilder builder( | 89 NGConstraintSpaceBuilder builder( |
74 FromPlatformWritingMode(Style()->getWritingMode())); | 90 FromPlatformWritingMode(Style()->getWritingMode())); |
75 | 91 |
76 builder.SetContainerSize(NGLogicalSize(LayoutUnit(), LayoutUnit())); | 92 builder.SetContainerSize(NGLogicalSize(LayoutUnit(), LayoutUnit())); |
77 // TODO(layoutng): Use builder.ToConstraintSpace.ToLogicalConstraintSpace | 93 // TODO(layoutng): Use builder.ToConstraintSpace.ToLogicalConstraintSpace |
78 // once | 94 // once |
79 // that's available. | 95 // that's available. |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 .SetBlockSize(layout_box_->logicalHeight()) | 268 .SetBlockSize(layout_box_->logicalHeight()) |
253 .SetDirection(FromPlatformDirection(layout_box_->styleRef().direction())) | 269 .SetDirection(FromPlatformDirection(layout_box_->styleRef().direction())) |
254 .SetWritingMode( | 270 .SetWritingMode( |
255 FromPlatformWritingMode(layout_box_->styleRef().getWritingMode())) | 271 FromPlatformWritingMode(layout_box_->styleRef().getWritingMode())) |
256 .SetInlineOverflow(overflow.width()) | 272 .SetInlineOverflow(overflow.width()) |
257 .SetBlockOverflow(overflow.height()); | 273 .SetBlockOverflow(overflow.height()); |
258 return builder.ToFragment(); | 274 return builder.ToFragment(); |
259 } | 275 } |
260 | 276 |
261 } // namespace blink | 277 } // namespace blink |
OLD | NEW |