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 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 LayoutUnit availableSpaceForRows = availableLogicalHeight(IncludeMarginBorde
rPadding); | 1095 LayoutUnit availableSpaceForRows = availableLogicalHeight(IncludeMarginBorde
rPadding); |
1096 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 1096 GridSizingData sizingData(gridColumnCount(), gridRowCount()); |
1097 computeUsedBreadthOfGridTracks(ForColumns, sizingData, availableSpaceForColu
mns); | 1097 computeUsedBreadthOfGridTracks(ForColumns, sizingData, availableSpaceForColu
mns); |
1098 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData.columnTracks
)); | 1098 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData.columnTracks
)); |
1099 computeUsedBreadthOfGridTracks(ForRows, sizingData, availableSpaceForRows); | 1099 computeUsedBreadthOfGridTracks(ForRows, sizingData, availableSpaceForRows); |
1100 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData.rowTracks)); | 1100 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData.rowTracks)); |
1101 | 1101 |
1102 populateGridPositions(sizingData, availableSpaceForColumns, availableSpaceFo
rRows); | 1102 populateGridPositions(sizingData, availableSpaceForColumns, availableSpaceFo
rRows); |
1103 m_gridItemsOverflowingGridArea.resize(0); | 1103 m_gridItemsOverflowingGridArea.resize(0); |
1104 | 1104 |
1105 LayoutUnit columnOffset = contentPositionAndDistributionColumnOffset(availab
leSpaceForColumns, style()->justifyContent(), style()->justifyContentDistributio
n(), m_columnPositions.size() - 1); | 1105 LayoutUnit columnOffset = contentPositionAndDistributionColumnOffset(availab
leSpaceForColumns, style()->justifyContent(), style()->justifyContentDistributio
n(), style()->justifyContentOverflowAlignment(), m_columnPositions.size() - 1); |
1106 LayoutUnit rowOffset = contentPositionAndDistributionRowOffset(availableSpac
eForRows, style()->alignContent(), style()->alignContentDistribution(), m_rowPos
itions.size() - 1); | 1106 LayoutUnit rowOffset = contentPositionAndDistributionRowOffset(availableSpac
eForRows, style()->alignContent(), style()->alignContentDistribution(), style()-
>alignContentOverflowAlignment(), m_rowPositions.size() - 1); |
1107 LayoutSize contentPositionOffset(columnOffset, rowOffset); | 1107 LayoutSize contentPositionOffset(columnOffset, rowOffset); |
1108 | 1108 |
1109 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { | 1109 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { |
1110 if (child->isOutOfFlowPositioned()) { | 1110 if (child->isOutOfFlowPositioned()) { |
1111 child->containingBlock()->insertPositionedObject(child); | 1111 child->containingBlock()->insertPositionedObject(child); |
1112 continue; | 1112 continue; |
1113 } | 1113 } |
1114 | 1114 |
1115 // Because the grid area cannot be styled, we don't need to adjust | 1115 // Because the grid area cannot be styled, we don't need to adjust |
1116 // the grid breadth to account for 'box-sizing'. | 1116 // the grid breadth to account for 'box-sizing'. |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1622 static inline LayoutUnit offsetToStartEdge(bool isLeftToRight, LayoutUnit availa
bleSpace) | 1622 static inline LayoutUnit offsetToStartEdge(bool isLeftToRight, LayoutUnit availa
bleSpace) |
1623 { | 1623 { |
1624 return isLeftToRight ? LayoutUnit(0) : availableSpace; | 1624 return isLeftToRight ? LayoutUnit(0) : availableSpace; |
1625 } | 1625 } |
1626 | 1626 |
1627 static inline LayoutUnit offsetToEndEdge(bool isLeftToRight, LayoutUnit availabl
eSpace) | 1627 static inline LayoutUnit offsetToEndEdge(bool isLeftToRight, LayoutUnit availabl
eSpace) |
1628 { | 1628 { |
1629 return !isLeftToRight ? LayoutUnit(0) : availableSpace; | 1629 return !isLeftToRight ? LayoutUnit(0) : availableSpace; |
1630 } | 1630 } |
1631 | 1631 |
1632 LayoutUnit RenderGrid::contentPositionAndDistributionColumnOffset(LayoutUnit ava
ilableFreeSpace, ContentPosition position, ContentDistributionType distribution,
unsigned numberOfGridTracks) const | 1632 LayoutUnit RenderGrid::contentPositionAndDistributionColumnOffset(LayoutUnit ava
ilableFreeSpace, ContentPosition position, ContentDistributionType distribution,
OverflowAlignment overflow, unsigned numberOfGridTracks) const |
1633 { | 1633 { |
1634 if (availableFreeSpace <= 0) | 1634 if (overflow == OverflowAlignmentSafe && availableFreeSpace <= 0) |
1635 return 0; | 1635 return 0; |
1636 | 1636 |
1637 // FIXME: for the time being, spec states that it will always fallback for G
rids, but | 1637 // FIXME: for the time being, spec states that it will always fallback for G
rids, but |
1638 // discussion is ongoing. | 1638 // discussion is ongoing. |
1639 if (distribution != ContentDistributionDefault && position == ContentPositio
nAuto) | 1639 if (distribution != ContentDistributionDefault && position == ContentPositio
nAuto) |
1640 position = resolveContentDistributionFallback(distribution); | 1640 position = resolveContentDistributionFallback(distribution); |
1641 | 1641 |
1642 // FIXME: still pending of implementing support for the <overflow-position>
keyword | |
1643 // in justify-content and aling-content properties. | |
1644 switch (position) { | 1642 switch (position) { |
1645 case ContentPositionLeft: | 1643 case ContentPositionLeft: |
1646 return 0; | 1644 return 0; |
1647 case ContentPositionRight: | 1645 case ContentPositionRight: |
1648 return availableFreeSpace; | 1646 return availableFreeSpace; |
1649 case ContentPositionCenter: | 1647 case ContentPositionCenter: |
1650 return availableFreeSpace / 2; | 1648 return availableFreeSpace / 2; |
1651 case ContentPositionFlexEnd: | 1649 case ContentPositionFlexEnd: |
1652 // Only used in flex layout, for other layout, it's equivalent to 'end'. | 1650 // Only used in flex layout, for other layout, it's equivalent to 'end'. |
1653 case ContentPositionEnd: | 1651 case ContentPositionEnd: |
1654 return offsetToEndEdge(style()->isLeftToRightDirection(), availableFreeS
pace); | 1652 return offsetToEndEdge(style()->isLeftToRightDirection(), availableFreeS
pace); |
1655 case ContentPositionFlexStart: | 1653 case ContentPositionFlexStart: |
1656 // Only used in flex layout, for other layout, it's equivalent to 'start
'. | 1654 // Only used in flex layout, for other layout, it's equivalent to 'start
'. |
1657 case ContentPositionStart: | 1655 case ContentPositionStart: |
1658 return offsetToStartEdge(style()->isLeftToRightDirection(), availableFre
eSpace); | 1656 return offsetToStartEdge(style()->isLeftToRightDirection(), availableFre
eSpace); |
1659 case ContentPositionBaseline: | 1657 case ContentPositionBaseline: |
1660 case ContentPositionLastBaseline: | 1658 case ContentPositionLastBaseline: |
1661 // FIXME: Implement the previous values. For now, we always 'start' alig
n. | 1659 // FIXME: Implement the previous values. For now, we always 'start' alig
n. |
1662 // crbug.com/234191 | 1660 // crbug.com/234191 |
1663 return offsetToStartEdge(style()->isLeftToRightDirection(), availableFre
eSpace); | 1661 return offsetToStartEdge(style()->isLeftToRightDirection(), availableFre
eSpace); |
1664 case ContentPositionAuto: | 1662 case ContentPositionAuto: |
1665 break; | 1663 break; |
1666 } | 1664 } |
1667 | 1665 |
1668 ASSERT_NOT_REACHED(); | 1666 ASSERT_NOT_REACHED(); |
1669 return 0; | 1667 return 0; |
1670 } | 1668 } |
1671 | 1669 |
1672 LayoutUnit RenderGrid::contentPositionAndDistributionRowOffset(LayoutUnit availa
bleFreeSpace, ContentPosition position, ContentDistributionType distribution, un
signed numberOfGridTracks) const | 1670 LayoutUnit RenderGrid::contentPositionAndDistributionRowOffset(LayoutUnit availa
bleFreeSpace, ContentPosition position, ContentDistributionType distribution, Ov
erflowAlignment overflow, unsigned numberOfGridTracks) const |
1673 { | 1671 { |
1674 if (availableFreeSpace <= 0) | 1672 if (overflow == OverflowAlignmentSafe && availableFreeSpace <= 0) |
1675 return 0; | 1673 return 0; |
1676 | 1674 |
1677 // FIXME: for the time being, spec states that it will always fallback for G
rids, but | 1675 // FIXME: for the time being, spec states that it will always fallback for G
rids, but |
1678 // discussion is ongoing. | 1676 // discussion is ongoing. |
1679 if (distribution != ContentDistributionDefault && position == ContentPositio
nAuto) | 1677 if (distribution != ContentDistributionDefault && position == ContentPositio
nAuto) |
1680 position = resolveContentDistributionFallback(distribution); | 1678 position = resolveContentDistributionFallback(distribution); |
1681 | 1679 |
1682 // FIXME: still pending of implementing support for the <overflow-position>
keyword | |
1683 // in justify-content and align-content properties. | |
1684 switch (position) { | 1680 switch (position) { |
1685 case ContentPositionLeft: | 1681 case ContentPositionLeft: |
1686 // The align-content's axis is always orthogonal to the inline-axis. | 1682 // The align-content's axis is always orthogonal to the inline-axis. |
1687 return 0; | 1683 return 0; |
1688 case ContentPositionRight: | 1684 case ContentPositionRight: |
1689 // The align-content's axis is always orthogonal to the inline-axis. | 1685 // The align-content's axis is always orthogonal to the inline-axis. |
1690 return 0; | 1686 return 0; |
1691 case ContentPositionCenter: | 1687 case ContentPositionCenter: |
1692 return availableFreeSpace / 2; | 1688 return availableFreeSpace / 2; |
1693 case ContentPositionFlexEnd: | 1689 case ContentPositionFlexEnd: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1738 if (isOutOfFlowPositioned()) | 1734 if (isOutOfFlowPositioned()) |
1739 return "RenderGrid (positioned)"; | 1735 return "RenderGrid (positioned)"; |
1740 if (isAnonymous()) | 1736 if (isAnonymous()) |
1741 return "RenderGrid (generated)"; | 1737 return "RenderGrid (generated)"; |
1742 if (isRelPositioned()) | 1738 if (isRelPositioned()) |
1743 return "RenderGrid (relative positioned)"; | 1739 return "RenderGrid (relative positioned)"; |
1744 return "RenderGrid"; | 1740 return "RenderGrid"; |
1745 } | 1741 } |
1746 | 1742 |
1747 } // namespace blink | 1743 } // namespace blink |
OLD | NEW |