| 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 // FIXME: It's unclear if we should return the intrinsic width or the | 317 // FIXME: It's unclear if we should return the intrinsic width or the |
| 318 // preferred width. | 318 // preferred width. |
| 319 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html | 319 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html |
| 320 LayoutUnit margin_logical_width = | 320 LayoutUnit margin_logical_width = |
| 321 child.NeedsLayout() ? ComputeMarginLogicalSizeForChild( | 321 child.NeedsLayout() ? ComputeMarginLogicalSizeForChild( |
| 322 kInlineDirection, GetLayoutGrid(), child) | 322 kInlineDirection, GetLayoutGrid(), child) |
| 323 : child.MarginLogicalWidth(); | 323 : child.MarginLogicalWidth(); |
| 324 return child.MinPreferredLogicalWidth() + margin_logical_width; | 324 return child.MinPreferredLogicalWidth() + margin_logical_width; |
| 325 } | 325 } |
| 326 | 326 |
| 327 if (Direction() == kForColumns && | 327 if (Direction() == kForColumns && !AvailableSpace()) { |
| 328 algorithm_.sizing_operation_ == kIntrinsicSizeComputation) { | |
| 329 DCHECK(GetLayoutGrid()->IsOrthogonalChild(child)); | 328 DCHECK(GetLayoutGrid()->IsOrthogonalChild(child)); |
| 330 if (GetLayoutGrid()->IsBaselineAlignmentForChild(child, kGridRowAxis) && | 329 if (GetLayoutGrid()->IsBaselineAlignmentForChild(child, kGridRowAxis) && |
| 331 GetLayoutGrid()->IsBaselineContextComputed(kGridRowAxis)) { | 330 GetLayoutGrid()->IsBaselineContextComputed(kGridRowAxis)) { |
| 332 auto& group = | 331 auto& group = |
| 333 GetLayoutGrid()->GetBaselineGroupForChild(child, kGridRowAxis); | 332 GetLayoutGrid()->GetBaselineGroupForChild(child, kGridRowAxis); |
| 334 return group.MaxAscent() + group.MaxDescent(); | 333 return group.MaxAscent() + group.MaxDescent(); |
| 335 } | 334 } |
| 336 } | 335 } |
| 337 | 336 |
| 338 if (UpdateOverrideContainingBlockContentSizeForChild(child, | 337 if (UpdateOverrideContainingBlockContentSizeForChild(child, |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1398 case kRowSizingFirstIteration: | 1397 case kRowSizingFirstIteration: |
| 1399 case kRowSizingSecondIteration: | 1398 case kRowSizingSecondIteration: |
| 1400 return direction_ == kForRows; | 1399 return direction_ == kForRows; |
| 1401 } | 1400 } |
| 1402 NOTREACHED(); | 1401 NOTREACHED(); |
| 1403 return false; | 1402 return false; |
| 1404 } | 1403 } |
| 1405 | 1404 |
| 1406 void GridTrackSizingAlgorithm::Setup(GridTrackSizingDirection direction, | 1405 void GridTrackSizingAlgorithm::Setup(GridTrackSizingDirection direction, |
| 1407 size_t num_tracks, | 1406 size_t num_tracks, |
| 1408 SizingOperation sizing_operation, | |
| 1409 Optional<LayoutUnit> available_space, | 1407 Optional<LayoutUnit> available_space, |
| 1410 Optional<LayoutUnit> free_space) { | 1408 Optional<LayoutUnit> free_space) { |
| 1411 DCHECK(needs_setup_); | 1409 DCHECK(needs_setup_); |
| 1412 DCHECK_EQ(!!available_space, !!free_space); | 1410 DCHECK_EQ(!!available_space, !!free_space); |
| 1413 direction_ = direction; | 1411 direction_ = direction; |
| 1414 SetAvailableSpace( | 1412 SetAvailableSpace( |
| 1415 direction, available_space ? available_space.value().ClampNegativeToZero() | 1413 direction, available_space ? available_space.value().ClampNegativeToZero() |
| 1416 : available_space); | 1414 : available_space); |
| 1417 | 1415 |
| 1418 sizing_operation_ = sizing_operation; | |
| 1419 | |
| 1420 if (available_space) | 1416 if (available_space) |
| 1421 strategy_ = WTF::MakeUnique<DefiniteSizeStrategy>(*this); | 1417 strategy_ = WTF::MakeUnique<DefiniteSizeStrategy>(*this); |
| 1422 else | 1418 else |
| 1423 strategy_ = WTF::MakeUnique<IndefiniteSizeStrategy>(*this); | 1419 strategy_ = WTF::MakeUnique<IndefiniteSizeStrategy>(*this); |
| 1424 | 1420 |
| 1425 content_sized_tracks_index_.Shrink(0); | 1421 content_sized_tracks_index_.Shrink(0); |
| 1426 flexible_sized_tracks_index_.Shrink(0); | 1422 flexible_sized_tracks_index_.Shrink(0); |
| 1427 | 1423 |
| 1428 SetFreeSpace(direction, free_space); | 1424 SetFreeSpace(direction, free_space); |
| 1429 Tracks(direction).Resize(num_tracks); | 1425 Tracks(direction).Resize(num_tracks); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1497 DCHECK(algorithm_.IsValidTransition()); | 1493 DCHECK(algorithm_.IsValidTransition()); |
| 1498 DCHECK(!algorithm_.needs_setup_); | 1494 DCHECK(!algorithm_.needs_setup_); |
| 1499 } | 1495 } |
| 1500 | 1496 |
| 1501 GridTrackSizingAlgorithm::StateMachine::~StateMachine() { | 1497 GridTrackSizingAlgorithm::StateMachine::~StateMachine() { |
| 1502 algorithm_.AdvanceNextState(); | 1498 algorithm_.AdvanceNextState(); |
| 1503 algorithm_.needs_setup_ = true; | 1499 algorithm_.needs_setup_ = true; |
| 1504 } | 1500 } |
| 1505 | 1501 |
| 1506 } // namespace blink | 1502 } // namespace blink |
| OLD | NEW |