| 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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 if (cachedHasDefiniteLogicalHeight()) { | 528 if (cachedHasDefiniteLogicalHeight()) { |
| 529 computeTrackSizesForDefiniteSize( | 529 computeTrackSizesForDefiniteSize( |
| 530 ForRows, sizingData, | 530 ForRows, sizingData, |
| 531 availableLogicalHeight(ExcludeMarginBorderPadding)); | 531 availableLogicalHeight(ExcludeMarginBorderPadding)); |
| 532 } else { | 532 } else { |
| 533 computeTrackSizesForIndefiniteSize( | 533 computeTrackSizesForIndefiniteSize( |
| 534 ForRows, sizingData, m_minContentHeight, m_maxContentHeight); | 534 ForRows, sizingData, m_minContentHeight, m_maxContentHeight); |
| 535 sizingData.nextState(); | 535 sizingData.nextState(); |
| 536 sizingData.sizingOperation = TrackSizing; | 536 sizingData.sizingOperation = TrackSizing; |
| 537 } | 537 } |
| 538 setLogicalHeight(computeTrackBasedLogicalHeight(sizingData) + | 538 LayoutUnit trackBasedLogicalHeight = |
| 539 borderAndPaddingLogicalHeight() + | 539 computeTrackBasedLogicalHeight(sizingData) + |
| 540 scrollbarLogicalHeight()); | 540 borderAndPaddingLogicalHeight() + scrollbarLogicalHeight(); |
| 541 setLogicalHeight(trackBasedLogicalHeight); |
| 541 | 542 |
| 542 LayoutUnit oldClientAfterEdge = clientLogicalBottom(); | 543 LayoutUnit oldClientAfterEdge = clientLogicalBottom(); |
| 543 updateLogicalHeight(); | 544 updateLogicalHeight(); |
| 544 | 545 |
| 546 // Once grid's indefinite height is resolved, we can compute the |
| 547 // available free space for Content Alignment. |
| 548 if (!cachedHasDefiniteLogicalHeight()) |
| 549 sizingData.freeSpace(ForRows) = logicalHeight() - trackBasedLogicalHeight; |
| 550 |
| 545 // 3- If the min-content contribution of any grid items have changed based | 551 // 3- If the min-content contribution of any grid items have changed based |
| 546 // on the row sizes calculated in step 2, steps 1 and 2 are repeated with | 552 // on the row sizes calculated in step 2, steps 1 and 2 are repeated with |
| 547 // the new min-content contribution (once only). | 553 // the new min-content contribution (once only). |
| 548 repeatTracksSizingIfNeeded(sizingData, availableSpaceForColumns, | 554 repeatTracksSizingIfNeeded(sizingData, availableSpaceForColumns, |
| 549 contentLogicalHeight()); | 555 contentLogicalHeight()); |
| 550 | 556 |
| 551 // Grid container should have the minimum height of a line if it's editable. | 557 // Grid container should have the minimum height of a line if it's editable. |
| 552 // That doesn't affect track sizing though. | 558 // That doesn't affect track sizing though. |
| 553 if (hasLineIfEmpty()) | 559 if (hasLineIfEmpty()) |
| 554 setLogicalHeight( | 560 setLogicalHeight( |
| (...skipping 2665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3220 // If <content-distribution> value can't be applied, 'position' will become | 3226 // If <content-distribution> value can't be applied, 'position' will become |
| 3221 // the associated <content-position> fallback value. | 3227 // the associated <content-position> fallback value. |
| 3222 ContentAlignmentData contentAlignment = contentDistributionOffset( | 3228 ContentAlignmentData contentAlignment = contentDistributionOffset( |
| 3223 availableFreeSpace, position, distribution, numberOfGridTracks); | 3229 availableFreeSpace, position, distribution, numberOfGridTracks); |
| 3224 if (contentAlignment.isValid()) | 3230 if (contentAlignment.isValid()) |
| 3225 return contentAlignment; | 3231 return contentAlignment; |
| 3226 | 3232 |
| 3227 OverflowAlignment overflow = | 3233 OverflowAlignment overflow = |
| 3228 isRowAxis ? styleRef().justifyContentOverflowAlignment() | 3234 isRowAxis ? styleRef().justifyContentOverflowAlignment() |
| 3229 : styleRef().alignContentOverflowAlignment(); | 3235 : styleRef().alignContentOverflowAlignment(); |
| 3230 if (availableFreeSpace <= 0 && overflow == OverflowAlignmentSafe) | 3236 // TODO (lajava): Default value for overflow isn't exaclty as 'unsafe'. |
| 3237 // https://drafts.csswg.org/css-align/#overflow-values |
| 3238 if (availableFreeSpace == 0 || |
| 3239 (availableFreeSpace < 0 && overflow == OverflowAlignmentSafe)) |
| 3231 return {LayoutUnit(), LayoutUnit()}; | 3240 return {LayoutUnit(), LayoutUnit()}; |
| 3232 | 3241 |
| 3233 switch (position) { | 3242 switch (position) { |
| 3234 case ContentPositionLeft: | 3243 case ContentPositionLeft: |
| 3235 // The align-content's axis is always orthogonal to the inline-axis. | 3244 // The align-content's axis is always orthogonal to the inline-axis. |
| 3236 return {LayoutUnit(), LayoutUnit()}; | 3245 return {LayoutUnit(), LayoutUnit()}; |
| 3237 case ContentPositionRight: | 3246 case ContentPositionRight: |
| 3238 if (isRowAxis) | 3247 if (isRowAxis) |
| 3239 return {availableFreeSpace, LayoutUnit()}; | 3248 return {availableFreeSpace, LayoutUnit()}; |
| 3240 // The align-content's axis is always orthogonal to the inline-axis. | 3249 // The align-content's axis is always orthogonal to the inline-axis. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3323 if (!m_gridItemArea.isEmpty()) | 3332 if (!m_gridItemArea.isEmpty()) |
| 3324 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 3333 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
| 3325 } | 3334 } |
| 3326 | 3335 |
| 3327 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const { | 3336 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const { |
| 3328 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); | 3337 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); |
| 3329 return m_hasDefiniteLogicalHeight.value(); | 3338 return m_hasDefiniteLogicalHeight.value(); |
| 3330 } | 3339 } |
| 3331 | 3340 |
| 3332 } // namespace blink | 3341 } // namespace blink |
| OLD | NEW |