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 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 LayoutUnit availableSpaceForRows = availableLogicalHeight(IncludeMarginBorde
rPadding); | 1081 LayoutUnit availableSpaceForRows = availableLogicalHeight(IncludeMarginBorde
rPadding); |
1082 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 1082 GridSizingData sizingData(gridColumnCount(), gridRowCount()); |
1083 computeUsedBreadthOfGridTracks(ForColumns, sizingData, availableSpaceForColu
mns); | 1083 computeUsedBreadthOfGridTracks(ForColumns, sizingData, availableSpaceForColu
mns); |
1084 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData.columnTracks
)); | 1084 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData.columnTracks
)); |
1085 computeUsedBreadthOfGridTracks(ForRows, sizingData, availableSpaceForRows); | 1085 computeUsedBreadthOfGridTracks(ForRows, sizingData, availableSpaceForRows); |
1086 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData.rowTracks)); | 1086 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData.rowTracks)); |
1087 | 1087 |
1088 populateGridPositions(sizingData, availableSpaceForColumns, availableSpaceFo
rRows); | 1088 populateGridPositions(sizingData, availableSpaceForColumns, availableSpaceFo
rRows); |
1089 m_gridItemsOverflowingGridArea.resize(0); | 1089 m_gridItemsOverflowingGridArea.resize(0); |
1090 | 1090 |
1091 LayoutUnit columnOffset = contentPositionAndDistributionColumnOffset(availab
leSpaceForColumns, style()->justifyContent(), style()->justifyContentDistributio
n(), m_columnPositions.size() - 1); | 1091 LayoutUnit columnOffset = contentPositionAndDistributionColumnOffset(availab
leSpaceForColumns, style()->justifyContent(), style()->justifyContentDistributio
n(), style()->justifyContentOverflowAlignment(), m_columnPositions.size() - 1); |
1092 LayoutUnit rowOffset = contentPositionAndDistributionRowOffset(availableSpac
eForRows, style()->alignContent(), style()->alignContentDistribution(), m_rowPos
itions.size() - 1); | 1092 LayoutUnit rowOffset = contentPositionAndDistributionRowOffset(availableSpac
eForRows, style()->alignContent(), style()->alignContentDistribution(), style()-
>alignContentOverflowAlignment(), m_rowPositions.size() - 1); |
1093 LayoutSize contentPositionOffset(columnOffset, rowOffset); | 1093 LayoutSize contentPositionOffset(columnOffset, rowOffset); |
1094 | 1094 |
1095 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { | 1095 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { |
1096 if (child->isOutOfFlowPositioned()) { | 1096 if (child->isOutOfFlowPositioned()) { |
1097 child->containingBlock()->insertPositionedObject(child); | 1097 child->containingBlock()->insertPositionedObject(child); |
1098 continue; | 1098 continue; |
1099 } | 1099 } |
1100 | 1100 |
1101 // FIXME: This logic is part of the RenderBlockFlow::layoutBlockChild, w
hich probably | 1101 // FIXME: This logic is part of the RenderBlockFlow::layoutBlockChild, w
hich probably |
1102 // should be part of the refactor to be done for RenderGrid::layoutBlock
. | 1102 // should be part of the refactor to be done for RenderGrid::layoutBlock
. |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1591 static inline LayoutUnit offsetToStartEdge(bool isLeftToRight, LayoutUnit availa
bleSpace) | 1591 static inline LayoutUnit offsetToStartEdge(bool isLeftToRight, LayoutUnit availa
bleSpace) |
1592 { | 1592 { |
1593 return isLeftToRight ? LayoutUnit(0) : availableSpace; | 1593 return isLeftToRight ? LayoutUnit(0) : availableSpace; |
1594 } | 1594 } |
1595 | 1595 |
1596 static inline LayoutUnit offsetToEndEdge(bool isLeftToRight, LayoutUnit availabl
eSpace) | 1596 static inline LayoutUnit offsetToEndEdge(bool isLeftToRight, LayoutUnit availabl
eSpace) |
1597 { | 1597 { |
1598 return !isLeftToRight ? LayoutUnit(0) : availableSpace; | 1598 return !isLeftToRight ? LayoutUnit(0) : availableSpace; |
1599 } | 1599 } |
1600 | 1600 |
1601 LayoutUnit RenderGrid::contentPositionAndDistributionColumnOffset(LayoutUnit ava
ilableFreeSpace, ContentPosition position, ContentDistributionType distribution,
unsigned numberOfGridTracks) const | 1601 LayoutUnit RenderGrid::contentPositionAndDistributionColumnOffset(LayoutUnit ava
ilableFreeSpace, ContentPosition position, ContentDistributionType distribution,
OverflowAlignment overflow, unsigned numberOfGridTracks) const |
1602 { | 1602 { |
1603 if (availableFreeSpace <= 0) | 1603 if (overflow == OverflowAlignmentSafe && availableFreeSpace <= 0) |
1604 return 0; | 1604 return 0; |
1605 | 1605 |
1606 // FIXME: for the time being, spec states that it will always fallback for G
rids, but | 1606 // FIXME: for the time being, spec states that it will always fallback for G
rids, but |
1607 // discussion is ongoing. | 1607 // discussion is ongoing. |
1608 if (distribution != ContentDistributionDefault && position == ContentPositio
nAuto) | 1608 if (distribution != ContentDistributionDefault && position == ContentPositio
nAuto) |
1609 position = resolveContentDistributionFallback(distribution); | 1609 position = resolveContentDistributionFallback(distribution); |
1610 | 1610 |
1611 // FIXME: still pending of implementing support for the <overflow-position>
keyword | |
1612 // in justify-content and aling-content properties. | |
1613 switch (position) { | 1611 switch (position) { |
1614 case ContentPositionLeft: | 1612 case ContentPositionLeft: |
1615 return 0; | 1613 return 0; |
1616 case ContentPositionRight: | 1614 case ContentPositionRight: |
1617 return availableFreeSpace; | 1615 return availableFreeSpace; |
1618 case ContentPositionCenter: | 1616 case ContentPositionCenter: |
1619 return availableFreeSpace / 2; | 1617 return availableFreeSpace / 2; |
1620 case ContentPositionFlexEnd: | 1618 case ContentPositionFlexEnd: |
1621 // Only used in flex layout, for other layout, it's equivalent to 'end'. | 1619 // Only used in flex layout, for other layout, it's equivalent to 'end'. |
1622 case ContentPositionEnd: | 1620 case ContentPositionEnd: |
1623 return offsetToEndEdge(style()->isLeftToRightDirection(), availableFreeS
pace); | 1621 return offsetToEndEdge(style()->isLeftToRightDirection(), availableFreeS
pace); |
1624 case ContentPositionFlexStart: | 1622 case ContentPositionFlexStart: |
1625 // Only used in flex layout, for other layout, it's equivalent to 'start
'. | 1623 // Only used in flex layout, for other layout, it's equivalent to 'start
'. |
1626 case ContentPositionStart: | 1624 case ContentPositionStart: |
1627 return offsetToStartEdge(style()->isLeftToRightDirection(), availableFre
eSpace); | 1625 return offsetToStartEdge(style()->isLeftToRightDirection(), availableFre
eSpace); |
1628 case ContentPositionBaseline: | 1626 case ContentPositionBaseline: |
1629 case ContentPositionLastBaseline: | 1627 case ContentPositionLastBaseline: |
1630 // FIXME: Implement the previous values. For now, we always 'start' alig
n. | 1628 // FIXME: Implement the previous values. For now, we always 'start' alig
n. |
1631 // crbug.com/234191 | 1629 // crbug.com/234191 |
1632 return offsetToStartEdge(style()->isLeftToRightDirection(), availableFre
eSpace); | 1630 return offsetToStartEdge(style()->isLeftToRightDirection(), availableFre
eSpace); |
1633 case ContentPositionAuto: | 1631 case ContentPositionAuto: |
1634 break; | 1632 break; |
1635 } | 1633 } |
1636 | 1634 |
1637 ASSERT_NOT_REACHED(); | 1635 ASSERT_NOT_REACHED(); |
1638 return 0; | 1636 return 0; |
1639 } | 1637 } |
1640 | 1638 |
1641 LayoutUnit RenderGrid::contentPositionAndDistributionRowOffset(LayoutUnit availa
bleFreeSpace, ContentPosition position, ContentDistributionType distribution, un
signed numberOfGridTracks) const | 1639 LayoutUnit RenderGrid::contentPositionAndDistributionRowOffset(LayoutUnit availa
bleFreeSpace, ContentPosition position, ContentDistributionType distribution, Ov
erflowAlignment overflow, unsigned numberOfGridTracks) const |
1642 { | 1640 { |
1643 if (availableFreeSpace <= 0) | 1641 if (overflow == OverflowAlignmentSafe && availableFreeSpace <= 0) |
1644 return 0; | 1642 return 0; |
1645 | 1643 |
1646 // FIXME: for the time being, spec states that it will always fallback for G
rids, but | 1644 // FIXME: for the time being, spec states that it will always fallback for G
rids, but |
1647 // discussion is ongoing. | 1645 // discussion is ongoing. |
1648 if (distribution != ContentDistributionDefault && position == ContentPositio
nAuto) | 1646 if (distribution != ContentDistributionDefault && position == ContentPositio
nAuto) |
1649 position = resolveContentDistributionFallback(distribution); | 1647 position = resolveContentDistributionFallback(distribution); |
1650 | 1648 |
1651 // FIXME: still pending of implementing support for the <overflow-position>
keyword | |
1652 // in justify-content and align-content properties. | |
1653 switch (position) { | 1649 switch (position) { |
1654 case ContentPositionLeft: | 1650 case ContentPositionLeft: |
1655 // The align-content's axis is always orthogonal to the inline-axis. | 1651 // The align-content's axis is always orthogonal to the inline-axis. |
1656 return 0; | 1652 return 0; |
1657 case ContentPositionRight: | 1653 case ContentPositionRight: |
1658 // The align-content's axis is always orthogonal to the inline-axis. | 1654 // The align-content's axis is always orthogonal to the inline-axis. |
1659 return 0; | 1655 return 0; |
1660 case ContentPositionCenter: | 1656 case ContentPositionCenter: |
1661 return availableFreeSpace / 2; | 1657 return availableFreeSpace / 2; |
1662 case ContentPositionFlexEnd: | 1658 case ContentPositionFlexEnd: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1707 if (isOutOfFlowPositioned()) | 1703 if (isOutOfFlowPositioned()) |
1708 return "RenderGrid (positioned)"; | 1704 return "RenderGrid (positioned)"; |
1709 if (isAnonymous()) | 1705 if (isAnonymous()) |
1710 return "RenderGrid (generated)"; | 1706 return "RenderGrid (generated)"; |
1711 if (isRelPositioned()) | 1707 if (isRelPositioned()) |
1712 return "RenderGrid (relative positioned)"; | 1708 return "RenderGrid (relative positioned)"; |
1713 return "RenderGrid"; | 1709 return "RenderGrid"; |
1714 } | 1710 } |
1715 | 1711 |
1716 } // namespace blink | 1712 } // namespace blink |
OLD | NEW |