| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 SubtreeLayoutScope layoutScope(*this); | 446 SubtreeLayoutScope layoutScope(*this); |
| 447 | 447 |
| 448 { | 448 { |
| 449 // LayoutState needs this deliberate scope to pop before updating scroll
information (which | 449 // LayoutState needs this deliberate scope to pop before updating scroll
information (which |
| 450 // may trigger relayout). | 450 // may trigger relayout). |
| 451 LayoutState state(*this, locationOffset()); | 451 LayoutState state(*this, locationOffset()); |
| 452 | 452 |
| 453 LayoutSize previousSize = size(); | 453 LayoutSize previousSize = size(); |
| 454 | 454 |
| 455 updateLogicalWidth(); | 455 updateLogicalWidth(); |
| 456 bool logicalHeightWasIndefinite = !hasDefiniteLogicalHeight(); | 456 m_hasDefiniteLogicalHeight = hasDefiniteLogicalHeight(); |
| 457 | 457 |
| 458 TextAutosizer::LayoutScope textAutosizerLayoutScope(this, &layoutScope); | 458 TextAutosizer::LayoutScope textAutosizerLayoutScope(this, &layoutScope); |
| 459 | 459 |
| 460 // TODO(svillar): we won't need to do this once the intrinsic width comp
utation is isolated | 460 // TODO(svillar): we won't need to do this once the intrinsic width comp
utation is isolated |
| 461 // from the LayoutGrid object state (it should not touch any attribute)
(see crbug.com/627812) | 461 // from the LayoutGrid object state (it should not touch any attribute)
(see crbug.com/627812) |
| 462 if (m_autoRepeatColumns && m_autoRepeatColumns != computeAutoRepeatTrack
sCount(ForColumns, TrackSizing)) | 462 if (m_autoRepeatColumns && m_autoRepeatColumns != computeAutoRepeatTrack
sCount(ForColumns, TrackSizing)) |
| 463 dirtyGrid(); | 463 dirtyGrid(); |
| 464 placeItemsOnGrid(TrackSizing); | 464 placeItemsOnGrid(TrackSizing); |
| 465 | 465 |
| 466 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 466 GridSizingData sizingData(gridColumnCount(), gridRowCount()); |
| 467 | 467 |
| 468 // 1- First, the track sizing algorithm is used to resolve the sizes of
the grid columns. | 468 // 1- First, the track sizing algorithm is used to resolve the sizes of
the grid columns. |
| 469 // At this point the logical width is always definite as the above call
to updateLogicalWidth() | 469 // At this point the logical width is always definite as the above call
to updateLogicalWidth() |
| 470 // properly resolves intrinsic sizes. We cannot do the same for heights
though because many code | 470 // properly resolves intrinsic sizes. We cannot do the same for heights
though because many code |
| 471 // paths inside updateLogicalHeight() require a previous call to setLogi
calHeight() to resolve | 471 // paths inside updateLogicalHeight() require a previous call to setLogi
calHeight() to resolve |
| 472 // heights properly (like for positioned items for example). | 472 // heights properly (like for positioned items for example). |
| 473 LayoutUnit availableSpaceForColumns = availableLogicalWidth(); | 473 LayoutUnit availableSpaceForColumns = availableLogicalWidth(); |
| 474 computeTrackSizesForDirection(ForColumns, sizingData, availableSpaceForC
olumns); | 474 computeTrackSizesForDirection(ForColumns, sizingData, availableSpaceForC
olumns); |
| 475 | 475 |
| 476 // 2- Next, the track sizing algorithm resolves the sizes of the grid ro
ws, using the | 476 // 2- Next, the track sizing algorithm resolves the sizes of the grid ro
ws, using the |
| 477 // grid column sizes calculated in the previous step. | 477 // grid column sizes calculated in the previous step. |
| 478 if (logicalHeightWasIndefinite) | 478 if (cachedHasDefiniteLogicalHeight()) |
| 479 computeTrackSizesForDirection(ForRows, sizingData, availableLogicalH
eight(ExcludeMarginBorderPadding)); |
| 480 else |
| 479 computeIntrinsicLogicalHeight(sizingData); | 481 computeIntrinsicLogicalHeight(sizingData); |
| 480 else | |
| 481 computeTrackSizesForDirection(ForRows, sizingData, availableLogicalH
eight(ExcludeMarginBorderPadding)); | |
| 482 setLogicalHeight(computeTrackBasedLogicalHeight(sizingData) + borderAndP
addingLogicalHeight() + scrollbarLogicalHeight()); | 482 setLogicalHeight(computeTrackBasedLogicalHeight(sizingData) + borderAndP
addingLogicalHeight() + scrollbarLogicalHeight()); |
| 483 | 483 |
| 484 LayoutUnit oldClientAfterEdge = clientLogicalBottom(); | 484 LayoutUnit oldClientAfterEdge = clientLogicalBottom(); |
| 485 updateLogicalHeight(); | 485 updateLogicalHeight(); |
| 486 | 486 |
| 487 // The above call might have changed the grid's logical height depending
on min|max height restrictions. | 487 // The above call might have changed the grid's logical height depending
on min|max height restrictions. |
| 488 // Update the sizes of the rows whose size depends on the logical height
(also on definite|indefinite sizes). | 488 // Update the sizes of the rows whose size depends on the logical height
(also on definite|indefinite sizes). |
| 489 LayoutUnit availableSpaceForRows = contentLogicalHeight(); | 489 LayoutUnit availableSpaceForRows = contentLogicalHeight(); |
| 490 if (logicalHeightWasIndefinite) | 490 if (!cachedHasDefiniteLogicalHeight()) |
| 491 computeTrackSizesForDirection(ForRows, sizingData, availableSpaceFor
Rows); | 491 computeTrackSizesForDirection(ForRows, sizingData, availableSpaceFor
Rows); |
| 492 | 492 |
| 493 // 3- If the min-content contribution of any grid items have changed bas
ed on the row | 493 // 3- If the min-content contribution of any grid items have changed bas
ed on the row |
| 494 // sizes calculated in step 2, steps 1 and 2 are repeated with the new m
in-content | 494 // sizes calculated in step 2, steps 1 and 2 are repeated with the new m
in-content |
| 495 // contribution (once only). | 495 // contribution (once only). |
| 496 repeatTracksSizingIfNeeded(sizingData, availableSpaceForColumns, availab
leSpaceForRows); | 496 repeatTracksSizingIfNeeded(sizingData, availableSpaceForColumns, availab
leSpaceForRows); |
| 497 | 497 |
| 498 // Grid container should have the minimum height of a line if it's edita
ble. That doesn't affect track sizing though. | 498 // Grid container should have the minimum height of a line if it's edita
ble. That doesn't affect track sizing though. |
| 499 if (hasLineIfEmpty()) | 499 if (hasLineIfEmpty()) |
| 500 setLogicalHeight(std::max(logicalHeight(), minimumLogicalHeightForEm
ptyLine())); | 500 setLogicalHeight(std::max(logicalHeight(), minimumLogicalHeightForEm
ptyLine())); |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 | 917 |
| 918 const GridTrackSize& trackSize = rawGridTrackSize(direction, translatedIndex
); | 918 const GridTrackSize& trackSize = rawGridTrackSize(direction, translatedIndex
); |
| 919 if (trackSize.isFitContent()) | 919 if (trackSize.isFitContent()) |
| 920 return trackSize; | 920 return trackSize; |
| 921 | 921 |
| 922 GridLength minTrackBreadth = trackSize.minTrackBreadth(); | 922 GridLength minTrackBreadth = trackSize.minTrackBreadth(); |
| 923 GridLength maxTrackBreadth = trackSize.maxTrackBreadth(); | 923 GridLength maxTrackBreadth = trackSize.maxTrackBreadth(); |
| 924 // If the logical width/height of the grid container is indefinite, percenta
ge values are treated as <auto>. | 924 // If the logical width/height of the grid container is indefinite, percenta
ge values are treated as <auto>. |
| 925 if (minTrackBreadth.hasPercentage() || maxTrackBreadth.hasPercentage()) { | 925 if (minTrackBreadth.hasPercentage() || maxTrackBreadth.hasPercentage()) { |
| 926 // For the inline axis this only happens when we're computing the intrin
sic sizes (AvailableSpaceIndefinite). | 926 // For the inline axis this only happens when we're computing the intrin
sic sizes (AvailableSpaceIndefinite). |
| 927 if ((sizingOperation == IntrinsicSizeComputation) || (direction == ForRo
ws && !hasDefiniteLogicalHeight())) { | 927 if ((sizingOperation == IntrinsicSizeComputation) || (direction == ForRo
ws && !cachedHasDefiniteLogicalHeight())) { |
| 928 if (minTrackBreadth.hasPercentage()) | 928 if (minTrackBreadth.hasPercentage()) |
| 929 minTrackBreadth = Length(Auto); | 929 minTrackBreadth = Length(Auto); |
| 930 if (maxTrackBreadth.hasPercentage()) | 930 if (maxTrackBreadth.hasPercentage()) |
| 931 maxTrackBreadth = Length(Auto); | 931 maxTrackBreadth = Length(Auto); |
| 932 } | 932 } |
| 933 } | 933 } |
| 934 | 934 |
| 935 // Flex sizes are invalid as a min sizing function. However we still can hav
e a flexible |minTrackBreadth| | 935 // Flex sizes are invalid as a min sizing function. However we still can hav
e a flexible |minTrackBreadth| |
| 936 // if the track had a flex size directly (e.g. "1fr"), the spec says that in
this case it implies an automatic minimum. | 936 // if the track had a flex size directly (e.g. "1fr"), the spec says that in
this case it implies an automatic minimum. |
| 937 if (minTrackBreadth.isFlex()) | 937 if (minTrackBreadth.isFlex()) |
| (...skipping 1722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2660 LayoutPoint childLocation(rowAxisOffset, columnAxisOffset); | 2660 LayoutPoint childLocation(rowAxisOffset, columnAxisOffset); |
| 2661 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc
ation; | 2661 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc
ation; |
| 2662 } | 2662 } |
| 2663 | 2663 |
| 2664 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const | 2664 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const |
| 2665 { | 2665 { |
| 2666 if (!m_gridItemArea.isEmpty()) | 2666 if (!m_gridItemArea.isEmpty()) |
| 2667 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2667 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
| 2668 } | 2668 } |
| 2669 | 2669 |
| 2670 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const |
| 2671 { |
| 2672 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); |
| 2673 return m_hasDefiniteLogicalHeight.value(); |
| 2674 } |
| 2675 |
| 2670 } // namespace blink | 2676 } // namespace blink |
| OLD | NEW |