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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 } | 473 } |
474 | 474 |
475 if (logicalHeightLength.isFillAvailable()) | 475 if (logicalHeightLength.isFillAvailable()) |
476 return containingBlock()->availableLogicalHeight( | 476 return containingBlock()->availableLogicalHeight( |
477 ExcludeMarginBorderPadding) - | 477 ExcludeMarginBorderPadding) - |
478 borderAndPadding; | 478 borderAndPadding; |
479 NOTREACHED(); | 479 NOTREACHED(); |
480 return LayoutUnit(); | 480 return LayoutUnit(); |
481 } | 481 } |
482 | 482 |
483 static LayoutUnit overrideContainingBlockContentSizeForChild( | 483 LayoutUnit LayoutGrid::overrideContainingBlockContentSizeForChild( |
484 const LayoutBox& child, | 484 const LayoutBox& child, |
485 GridTrackSizingDirection direction) { | 485 GridTrackSizingDirection direction) { |
486 return direction == ForColumns | 486 return direction == ForColumns |
487 ? child.overrideContainingBlockContentLogicalWidth() | 487 ? child.overrideContainingBlockContentLogicalWidth() |
488 : child.overrideContainingBlockContentLogicalHeight(); | 488 : child.overrideContainingBlockContentLogicalHeight(); |
489 } | 489 } |
490 | 490 |
491 bool LayoutGrid::isOrthogonalChild(const LayoutBox& child) const { | 491 bool LayoutGrid::isOrthogonalChild(const LayoutBox& child) const { |
492 return child.isHorizontalWritingMode() != isHorizontalWritingMode(); | 492 return child.isHorizontalWritingMode() != isHorizontalWritingMode(); |
493 } | 493 } |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 bool allRemainingTracksAreEmpty = remainingEmptyTracks == (lastLine - i); | 1031 bool allRemainingTracksAreEmpty = remainingEmptyTracks == (lastLine - i); |
1032 if (!allRemainingTracksAreEmpty || | 1032 if (!allRemainingTracksAreEmpty || |
1033 !m_grid.isEmptyAutoRepeatTrack(direction, i)) | 1033 !m_grid.isEmptyAutoRepeatTrack(direction, i)) |
1034 tracks[i - 1] -= gap; | 1034 tracks[i - 1] -= gap; |
1035 } | 1035 } |
1036 } | 1036 } |
1037 | 1037 |
1038 return tracks; | 1038 return tracks; |
1039 } | 1039 } |
1040 | 1040 |
1041 static const StyleContentAlignmentData& contentAlignmentNormalBehavior() { | 1041 const StyleContentAlignmentData& LayoutGrid::contentAlignmentNormalBehavior() { |
1042 static const StyleContentAlignmentData normalBehavior = { | 1042 static const StyleContentAlignmentData normalBehavior = { |
1043 ContentPositionNormal, ContentDistributionStretch}; | 1043 ContentPositionNormal, ContentDistributionStretch}; |
1044 return normalBehavior; | 1044 return normalBehavior; |
1045 } | 1045 } |
1046 | 1046 |
1047 void LayoutGrid::applyStretchAlignmentToTracksIfNeeded( | 1047 void LayoutGrid::applyStretchAlignmentToTracksIfNeeded( |
1048 GridTrackSizingDirection direction) { | 1048 GridTrackSizingDirection direction) { |
1049 LayoutUnit& availableSpace = m_trackSizingAlgorithm.freeSpace(direction); | 1049 LayoutUnit& availableSpace = m_trackSizingAlgorithm.freeSpace(direction); |
1050 if (availableSpace <= 0 || | 1050 if (availableSpace <= 0 || |
1051 (direction == ForColumns && | 1051 (direction == ForColumns && |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1592 child.setMarginAfter(availableAlignmentSpace / 2, style()); | 1592 child.setMarginAfter(availableAlignmentSpace / 2, style()); |
1593 } else if (marginBefore.isAuto()) { | 1593 } else if (marginBefore.isAuto()) { |
1594 child.setMarginBefore(availableAlignmentSpace, style()); | 1594 child.setMarginBefore(availableAlignmentSpace, style()); |
1595 } else if (marginAfter.isAuto()) { | 1595 } else if (marginAfter.isAuto()) { |
1596 child.setMarginAfter(availableAlignmentSpace, style()); | 1596 child.setMarginAfter(availableAlignmentSpace, style()); |
1597 } | 1597 } |
1598 } | 1598 } |
1599 | 1599 |
1600 // TODO(lajava): This logic is shared by LayoutFlexibleBox, so it might be | 1600 // TODO(lajava): This logic is shared by LayoutFlexibleBox, so it might be |
1601 // refactored somehow. | 1601 // refactored somehow. |
1602 static int synthesizedBaselineFromContentBox(const LayoutBox& box, | 1602 int LayoutGrid::synthesizedBaselineFromContentBox(const LayoutBox& box, |
1603 LineDirectionMode direction) { | 1603 LineDirectionMode direction) { |
1604 if (direction == HorizontalLine) { | 1604 if (direction == HorizontalLine) { |
1605 return (box.size().height() - box.borderBottom() - box.paddingBottom() - | 1605 return (box.size().height() - box.borderBottom() - box.paddingBottom() - |
1606 box.horizontalScrollbarHeight()) | 1606 box.horizontalScrollbarHeight()) |
1607 .toInt(); | 1607 .toInt(); |
1608 } | 1608 } |
1609 return (box.size().width() - box.borderLeft() - box.paddingLeft() - | 1609 return (box.size().width() - box.borderLeft() - box.paddingLeft() - |
1610 box.verticalScrollbarWidth()) | 1610 box.verticalScrollbarWidth()) |
1611 .toInt(); | 1611 .toInt(); |
1612 } | 1612 } |
1613 | 1613 |
1614 static int synthesizedBaselineFromBorderBox(const LayoutBox& box, | 1614 int LayoutGrid::synthesizedBaselineFromBorderBox(const LayoutBox& box, |
1615 LineDirectionMode direction) { | 1615 LineDirectionMode direction) { |
1616 return (direction == HorizontalLine ? box.size().height() | 1616 return (direction == HorizontalLine ? box.size().height() |
1617 : box.size().width()) | 1617 : box.size().width()) |
1618 .toInt(); | 1618 .toInt(); |
1619 } | 1619 } |
1620 | 1620 |
1621 int LayoutGrid::baselinePosition(FontBaseline, | 1621 int LayoutGrid::baselinePosition(FontBaseline, |
1622 bool, | 1622 bool, |
1623 LineDirectionMode direction, | 1623 LineDirectionMode direction, |
1624 LinePositionMode mode) const { | 1624 LinePositionMode mode) const { |
1625 DCHECK_EQ(mode, PositionOnContainingLine); | 1625 DCHECK_EQ(mode, PositionOnContainingLine); |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2323 if (direction == ForRows) | 2323 if (direction == ForRows) |
2324 return grid.numTracks(ForRows); | 2324 return grid.numTracks(ForRows); |
2325 | 2325 |
2326 return grid.numTracks(ForRows) | 2326 return grid.numTracks(ForRows) |
2327 ? grid.numTracks(ForColumns) | 2327 ? grid.numTracks(ForColumns) |
2328 : GridPositionsResolver::explicitGridColumnCount( | 2328 : GridPositionsResolver::explicitGridColumnCount( |
2329 styleRef(), grid.autoRepeatTracks(ForColumns)); | 2329 styleRef(), grid.autoRepeatTracks(ForColumns)); |
2330 } | 2330 } |
2331 | 2331 |
2332 } // namespace blink | 2332 } // namespace blink |
OLD | NEW |