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 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1786 // crbug.com/234191 | 1786 // crbug.com/234191 |
1787 return GridAxisStart; | 1787 return GridAxisStart; |
1788 case ItemPositionAuto: | 1788 case ItemPositionAuto: |
1789 break; | 1789 break; |
1790 } | 1790 } |
1791 | 1791 |
1792 ASSERT_NOT_REACHED(); | 1792 ASSERT_NOT_REACHED(); |
1793 return GridAxisStart; | 1793 return GridAxisStart; |
1794 } | 1794 } |
1795 | 1795 |
| 1796 static inline LayoutUnit offsetBetweenTracks(ContentDistributionType distributio
n, const Vector<LayoutUnit>& trackPositions, const LayoutUnit& childBreadth) |
| 1797 { |
| 1798 return (distribution == ContentDistributionStretch || ContentDistributionStr
etch == ContentDistributionDefault) ? LayoutUnit() : trackPositions[1] - trackPo
sitions[0] - childBreadth; |
| 1799 |
| 1800 } |
| 1801 |
1796 LayoutUnit LayoutGrid::columnAxisOffsetForChild(const LayoutBox& child) const | 1802 LayoutUnit LayoutGrid::columnAxisOffsetForChild(const LayoutBox& child) const |
1797 { | 1803 { |
1798 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1804 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
1799 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
on.toInt()]; | 1805 size_t childStartLine = coordinate.rows.resolvedInitialPosition.toInt(); |
| 1806 LayoutUnit startOfRow = m_rowPositions[childStartLine]; |
1800 LayoutUnit startPosition = startOfRow + marginBeforeForChild(child); | 1807 LayoutUnit startPosition = startOfRow + marginBeforeForChild(child); |
1801 if (hasAutoMarginsInColumnAxis(child)) | 1808 if (hasAutoMarginsInColumnAxis(child)) |
1802 return startPosition; | 1809 return startPosition; |
1803 GridAxisPosition axisPosition = columnAxisPositionForChild(child); | 1810 GridAxisPosition axisPosition = columnAxisPositionForChild(child); |
1804 switch (axisPosition) { | 1811 switch (axisPosition) { |
1805 case GridAxisStart: | 1812 case GridAxisStart: |
1806 return startPosition; | 1813 return startPosition; |
1807 case GridAxisEnd: | 1814 case GridAxisEnd: |
1808 case GridAxisCenter: { | 1815 case GridAxisCenter: { |
1809 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPositi
on.next().toInt()]; | 1816 size_t childEndLine = coordinate.rows.resolvedFinalPosition.next().toInt
(); |
1810 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil
d.styleRef().alignSelfOverflowAlignment(), endOfRow - startOfRow, child.logicalH
eight() + child.marginLogicalHeight()); | 1817 LayoutUnit endOfRow = m_rowPositions[childEndLine]; |
| 1818 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHei
ght(); |
| 1819 if (childEndLine - childStartLine > 1 && childEndLine < m_rowPositions.s
ize() - 1) |
| 1820 endOfRow -= offsetBetweenTracks(styleRef().alignContentDistribution(
), m_rowPositions, childBreadth); |
| 1821 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil
d.styleRef().alignSelfOverflowAlignment(), endOfRow - startOfRow, childBreadth); |
1811 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); | 1822 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); |
1812 } | 1823 } |
1813 } | 1824 } |
1814 | 1825 |
1815 ASSERT_NOT_REACHED(); | 1826 ASSERT_NOT_REACHED(); |
1816 return 0; | 1827 return 0; |
1817 } | 1828 } |
1818 | 1829 |
1819 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child) const | 1830 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child) const |
1820 { | 1831 { |
1821 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1832 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
1822 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit
ialPosition.toInt()]; | 1833 size_t childStartLine = coordinate.columns.resolvedInitialPosition.toInt(); |
| 1834 LayoutUnit startOfColumn = m_columnPositions[childStartLine]; |
1823 LayoutUnit startPosition = startOfColumn + marginStartForChild(child); | 1835 LayoutUnit startPosition = startOfColumn + marginStartForChild(child); |
1824 if (hasAutoMarginsInRowAxis(child)) | 1836 if (hasAutoMarginsInRowAxis(child)) |
1825 return startPosition; | 1837 return startPosition; |
1826 GridAxisPosition axisPosition = rowAxisPositionForChild(child); | 1838 GridAxisPosition axisPosition = rowAxisPositionForChild(child); |
1827 switch (axisPosition) { | 1839 switch (axisPosition) { |
1828 case GridAxisStart: | 1840 case GridAxisStart: |
1829 return startPosition; | 1841 return startPosition; |
1830 case GridAxisEnd: | 1842 case GridAxisEnd: |
1831 case GridAxisCenter: { | 1843 case GridAxisCenter: { |
1832 LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFi
nalPosition.next().toInt()]; | 1844 size_t childEndLine = coordinate.columns.resolvedFinalPosition.next().to
Int(); |
1833 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil
d.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, child.
logicalWidth() + child.marginLogicalWidth()); | 1845 LayoutUnit endOfColumn = m_columnPositions[childEndLine]; |
| 1846 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidt
h(); |
| 1847 if (childEndLine - childStartLine > 1 && childEndLine < m_columnPosition
s.size() - 1) |
| 1848 endOfColumn -= offsetBetweenTracks(styleRef().justifyContentDistribu
tion(), m_columnPositions, childBreadth); |
| 1849 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil
d.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, childB
readth); |
1834 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); | 1850 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); |
1835 } | 1851 } |
1836 } | 1852 } |
1837 | 1853 |
1838 ASSERT_NOT_REACHED(); | 1854 ASSERT_NOT_REACHED(); |
1839 return 0; | 1855 return 0; |
1840 } | 1856 } |
1841 | 1857 |
1842 ContentPosition static resolveContentDistributionFallback(ContentDistributionTyp
e distribution) | 1858 ContentPosition static resolveContentDistributionFallback(ContentDistributionTyp
e distribution) |
1843 { | 1859 { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1965 | 1981 |
1966 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child)); | 1982 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child)); |
1967 } | 1983 } |
1968 | 1984 |
1969 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const | 1985 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const |
1970 { | 1986 { |
1971 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 1987 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
1972 } | 1988 } |
1973 | 1989 |
1974 } // namespace blink | 1990 } // namespace blink |
OLD | NEW |