| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/GridTrackSizingAlgorithm.h" | 5 #include "core/layout/GridTrackSizingAlgorithm.h" |
| 6 | 6 |
| 7 #include "core/layout/Grid.h" | 7 #include "core/layout/Grid.h" |
| 8 #include "core/layout/LayoutGrid.h" | 8 #include "core/layout/LayoutGrid.h" |
| 9 #include "platform/LengthFunctions.h" | 9 #include "platform/LengthFunctions.h" |
| 10 | 10 |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // intrinsic height, which is what we are interested in here. Thus we need to | 276 // intrinsic height, which is what we are interested in here. Thus we need to |
| 277 // set the block-axis override size to -1 (no possible resolution). | 277 // set the block-axis override size to -1 (no possible resolution). |
| 278 if (ShouldClearOverrideContainingBlockContentSizeForChild(child, kForRows)) { | 278 if (ShouldClearOverrideContainingBlockContentSizeForChild(child, kForRows)) { |
| 279 SetOverrideContainingBlockContentSizeForChild(child, child_block_direction, | 279 SetOverrideContainingBlockContentSizeForChild(child, child_block_direction, |
| 280 LayoutUnit(-1)); | 280 LayoutUnit(-1)); |
| 281 child.SetNeedsLayout(LayoutInvalidationReason::kGridChanged, kMarkOnlyThis); | 281 child.SetNeedsLayout(LayoutInvalidationReason::kGridChanged, kMarkOnlyThis); |
| 282 } | 282 } |
| 283 | 283 |
| 284 child.LayoutIfNeeded(); | 284 child.LayoutIfNeeded(); |
| 285 | 285 |
| 286 if (auto baseline_extent = ExtentForBaselineAlignment(child)) | 286 // if (auto baseline_extent = ExtentForBaselineAlignment(child)) |
| 287 return baseline_extent.value(); | 287 // return baseline_extent.value(); |
| 288 | 288 |
| 289 return child.LogicalHeight() + child.MarginLogicalHeight(); | 289 return child.LogicalHeight() + child.MarginLogicalHeight(); |
| 290 } | 290 } |
| 291 | 291 |
| 292 DISABLE_CFI_PERF | 292 DISABLE_CFI_PERF |
| 293 LayoutUnit GridTrackSizingAlgorithmStrategy::MinContentForChild( | 293 LayoutUnit GridTrackSizingAlgorithmStrategy::MinContentForChild( |
| 294 LayoutBox& child) const { | 294 LayoutBox& child) const { |
| 295 GridTrackSizingDirection child_inline_direction = | 295 GridTrackSizingDirection child_inline_direction = |
| 296 FlowAwareDirectionForChild(GetLayoutGrid(), child, kForColumns); | 296 FlowAwareDirectionForChild(GetLayoutGrid(), child, kForColumns); |
| 297 if (Direction() == child_inline_direction) { | 297 if (Direction() == child_inline_direction) { |
| 298 // If |child| has a relative logical width, we shouldn't let it override its | 298 // If |child| has a relative logical width, we shouldn't let it override its |
| 299 // intrinsic width, which is what we are interested in here. Thus we need to | 299 // intrinsic width, which is what we are interested in here. Thus we need to |
| 300 // set the inline-axis override size to -1 (no possible resolution). | 300 // set the inline-axis override size to -1 (no possible resolution). |
| 301 if (ShouldClearOverrideContainingBlockContentSizeForChild(child, | 301 if (ShouldClearOverrideContainingBlockContentSizeForChild(child, |
| 302 kForColumns)) { | 302 kForColumns)) { |
| 303 SetOverrideContainingBlockContentSizeForChild( | 303 SetOverrideContainingBlockContentSizeForChild( |
| 304 child, child_inline_direction, LayoutUnit(-1)); | 304 child, child_inline_direction, LayoutUnit(-1)); |
| 305 } | 305 } |
| 306 | 306 |
| 307 // FIXME: It's unclear if we should return the intrinsic width or the | 307 // FIXME: It's unclear if we should return the intrinsic width or the |
| 308 // preferred width. | 308 // preferred width. |
| 309 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html | 309 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html |
| 310 LayoutUnit margin_logical_width = | 310 LayoutUnit margin_logical_width = |
| 311 child.NeedsLayout() ? ComputeMarginLogicalSizeForChild( | 311 child.NeedsLayout() ? ComputeMarginLogicalSizeForChild( |
| 312 kInlineDirection, GetLayoutGrid(), child) | 312 kInlineDirection, GetLayoutGrid(), child) |
| 313 : child.MarginLogicalWidth(); | 313 : child.MarginLogicalWidth(); |
| 314 return child.MinPreferredLogicalWidth() + margin_logical_width; | 314 return child.MinPreferredLogicalWidth() + margin_logical_width; |
| 315 } | 315 } |
| 316 | 316 |
| 317 /* |
| 317 if (Direction() == kForColumns && !AvailableSpace()) { | 318 if (Direction() == kForColumns && !AvailableSpace()) { |
| 318 DCHECK(GetLayoutGrid()->IsOrthogonalChild(child)); | 319 DCHECK(GetLayoutGrid()->IsOrthogonalChild(child)); |
| 319 if (auto baseline_extent = ExtentForBaselineAlignment(child)) | 320 if (auto baseline_extent = ExtentForBaselineAlignment(child)) |
| 320 return baseline_extent.value(); | 321 return baseline_extent.value(); |
| 321 } | 322 } |
| 323 */ |
| 322 | 324 |
| 323 if (UpdateOverrideContainingBlockContentSizeForChild(child, | 325 if (UpdateOverrideContainingBlockContentSizeForChild(child, |
| 324 child_inline_direction)) | 326 child_inline_direction)) |
| 325 child.SetNeedsLayout(LayoutInvalidationReason::kGridChanged, kMarkOnlyThis); | 327 child.SetNeedsLayout(LayoutInvalidationReason::kGridChanged, kMarkOnlyThis); |
| 326 return LogicalHeightForChild(child); | 328 return LogicalHeightForChild(child); |
| 327 } | 329 } |
| 328 | 330 |
| 329 DISABLE_CFI_PERF | 331 DISABLE_CFI_PERF |
| 330 LayoutUnit GridTrackSizingAlgorithmStrategy::MaxContentForChild( | 332 LayoutUnit GridTrackSizingAlgorithmStrategy::MaxContentForChild( |
| 331 LayoutBox& child) const { | 333 LayoutBox& child) const { |
| (...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1493 DCHECK(algorithm_.IsValidTransition()); | 1495 DCHECK(algorithm_.IsValidTransition()); |
| 1494 DCHECK(!algorithm_.needs_setup_); | 1496 DCHECK(!algorithm_.needs_setup_); |
| 1495 } | 1497 } |
| 1496 | 1498 |
| 1497 GridTrackSizingAlgorithm::StateMachine::~StateMachine() { | 1499 GridTrackSizingAlgorithm::StateMachine::~StateMachine() { |
| 1498 algorithm_.AdvanceNextState(); | 1500 algorithm_.AdvanceNextState(); |
| 1499 algorithm_.needs_setup_ = true; | 1501 algorithm_.needs_setup_ = true; |
| 1500 } | 1502 } |
| 1501 | 1503 |
| 1502 } // namespace blink | 1504 } // namespace blink |
| OLD | NEW |