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 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1748 // crbug.com/234191 | 1748 // crbug.com/234191 |
1749 return GridAxisStart; | 1749 return GridAxisStart; |
1750 case ItemPositionAuto: | 1750 case ItemPositionAuto: |
1751 break; | 1751 break; |
1752 } | 1752 } |
1753 | 1753 |
1754 ASSERT_NOT_REACHED(); | 1754 ASSERT_NOT_REACHED(); |
1755 return GridAxisStart; | 1755 return GridAxisStart; |
1756 } | 1756 } |
1757 | 1757 |
1758 static inline LayoutUnit offsetBetweenTracks(ContentDistributionType distributio n, const Vector<LayoutUnit>& trackPositions, const LayoutUnit& childBreadth) | |
1759 { | |
1760 return (distribution == ContentDistributionStretch || ContentDistributionStr etch == ContentDistributionDefault) ? LayoutUnit(0) : trackPositions[1] - trackP ositions[0] - childBreadth; | |
cbiesinger
2015/09/30 15:09:10
Use LayoutUnit() instead of specifying the explici
| |
1761 | |
1762 } | |
1763 | |
1758 LayoutUnit LayoutGrid::columnAxisOffsetForChild(const LayoutBox& child) const | 1764 LayoutUnit LayoutGrid::columnAxisOffsetForChild(const LayoutBox& child) const |
1759 { | 1765 { |
1760 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1766 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
1761 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi on.toInt()]; | 1767 size_t childStartLine = coordinate.rows.resolvedInitialPosition.toInt(); |
1768 LayoutUnit startOfRow = m_rowPositions[childStartLine]; | |
1762 LayoutUnit startPosition = startOfRow + marginBeforeForChild(child); | 1769 LayoutUnit startPosition = startOfRow + marginBeforeForChild(child); |
1763 GridAxisPosition axisPosition = columnAxisPositionForChild(child); | 1770 GridAxisPosition axisPosition = columnAxisPositionForChild(child); |
1764 switch (axisPosition) { | 1771 switch (axisPosition) { |
1765 case GridAxisStart: | 1772 case GridAxisStart: |
1766 return startPosition; | 1773 return startPosition; |
1767 case GridAxisEnd: | 1774 case GridAxisEnd: |
1768 case GridAxisCenter: { | 1775 case GridAxisCenter: { |
1769 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPositi on.next().toInt()]; | 1776 size_t childEndLine = coordinate.rows.resolvedFinalPosition.next().toInt (); |
1770 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil d.styleRef().alignSelfOverflowAlignment(), endOfRow - startOfRow, child.logicalH eight() + child.marginLogicalHeight()); | 1777 LayoutUnit endOfRow = m_rowPositions[childEndLine]; |
1778 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHei ght(); | |
1779 if (childEndLine - childStartLine > 1 && childEndLine < m_rowPositions.s ize() - 1) | |
1780 endOfRow -= offsetBetweenTracks(styleRef().alignContentDistribution( ), m_rowPositions, childBreadth); | |
1781 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil d.styleRef().alignSelfOverflowAlignment(), endOfRow - startOfRow, childBreadth); | |
1771 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); | 1782 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); |
1772 } | 1783 } |
1773 } | 1784 } |
1774 | 1785 |
1775 ASSERT_NOT_REACHED(); | 1786 ASSERT_NOT_REACHED(); |
1776 return 0; | 1787 return 0; |
1777 } | 1788 } |
1778 | 1789 |
1779 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child) const | 1790 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child) const |
1780 { | 1791 { |
1781 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1792 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
1782 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit ialPosition.toInt()]; | 1793 size_t childStartLine = coordinate.columns.resolvedInitialPosition.toInt(); |
1794 LayoutUnit startOfColumn = m_columnPositions[childStartLine]; | |
1783 LayoutUnit startPosition = startOfColumn + marginStartForChild(child); | 1795 LayoutUnit startPosition = startOfColumn + marginStartForChild(child); |
1784 GridAxisPosition axisPosition = rowAxisPositionForChild(child); | 1796 GridAxisPosition axisPosition = rowAxisPositionForChild(child); |
1785 switch (axisPosition) { | 1797 switch (axisPosition) { |
1786 case GridAxisStart: | 1798 case GridAxisStart: |
1787 return startPosition; | 1799 return startPosition; |
1788 case GridAxisEnd: | 1800 case GridAxisEnd: |
1789 case GridAxisCenter: { | 1801 case GridAxisCenter: { |
1790 LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFi nalPosition.next().toInt()]; | 1802 size_t childEndLine = coordinate.columns.resolvedFinalPosition.next().to Int(); |
1791 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil d.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, child. logicalWidth() + child.marginLogicalWidth()); | 1803 LayoutUnit endOfColumn = m_columnPositions[childEndLine]; |
1804 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidt h(); | |
1805 if (childEndLine - childStartLine > 1 && childEndLine < m_columnPosition s.size() - 1) | |
1806 endOfColumn -= offsetBetweenTracks(styleRef().justifyContentDistribu tion(), m_columnPositions, childBreadth); | |
1807 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil d.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, childB readth); | |
1792 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); | 1808 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); |
1793 } | 1809 } |
1794 } | 1810 } |
1795 | 1811 |
1796 ASSERT_NOT_REACHED(); | 1812 ASSERT_NOT_REACHED(); |
1797 return 0; | 1813 return 0; |
1798 } | 1814 } |
1799 | 1815 |
1800 ContentPosition static resolveContentDistributionFallback(ContentDistributionTyp e distribution) | 1816 ContentPosition static resolveContentDistributionFallback(ContentDistributionTyp e distribution) |
1801 { | 1817 { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1923 | 1939 |
1924 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child)); | 1940 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child)); |
1925 } | 1941 } |
1926 | 1942 |
1927 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) | 1943 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) |
1928 { | 1944 { |
1929 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 1945 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
1930 } | 1946 } |
1931 | 1947 |
1932 } // namespace blink | 1948 } // namespace blink |
OLD | NEW |