| 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 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1703 return; | 1703 return; |
| 1704 } | 1704 } |
| 1705 | 1705 |
| 1706 // For positioned items we cannot use GridSpan::translate(). Because we coul
d end up with negative values, as the positioned items do not create implicit tr
acks per spec. | 1706 // For positioned items we cannot use GridSpan::translate(). Because we coul
d end up with negative values, as the positioned items do not create implicit tr
acks per spec. |
| 1707 int smallestStart = abs(isForColumns ? m_smallestColumnStart : m_smallestRow
Start); | 1707 int smallestStart = abs(isForColumns ? m_smallestColumnStart : m_smallestRow
Start); |
| 1708 int startLine = positions.untranslatedStartLine() + smallestStart; | 1708 int startLine = positions.untranslatedStartLine() + smallestStart; |
| 1709 int endLine = positions.untranslatedEndLine() + smallestStart; | 1709 int endLine = positions.untranslatedEndLine() + smallestStart; |
| 1710 | 1710 |
| 1711 GridPosition startPosition = isForColumns ? child.style()->gridColumnStart()
: child.style()->gridRowStart(); | 1711 GridPosition startPosition = isForColumns ? child.style()->gridColumnStart()
: child.style()->gridRowStart(); |
| 1712 GridPosition endPosition = isForColumns ? child.style()->gridColumnEnd() : c
hild.style()->gridRowEnd(); | 1712 GridPosition endPosition = isForColumns ? child.style()->gridColumnEnd() : c
hild.style()->gridRowEnd(); |
| 1713 int firstExplicitLine = smallestStart; | 1713 int lastLine = isForColumns ? gridColumnCount() : gridRowCount(); |
| 1714 size_t autoRepeatCount = autoRepeatCountForDirection(direction); | |
| 1715 int lastExplicitLine = (isForColumns ? GridPositionsResolver::explicitGridCo
lumnCount(styleRef(), autoRepeatCount) : GridPositionsResolver::explicitGridRowC
ount(styleRef(), autoRepeatCount)) + smallestStart; | |
| 1716 | 1714 |
| 1717 bool startIsAuto = startPosition.isAuto() | 1715 bool startIsAuto = startPosition.isAuto() |
| 1718 || (startPosition.isNamedGridArea() && !NamedLineCollection::isValidName
dLineOrArea(startPosition.namedGridLine(), styleRef(), GridPositionsResolver::in
itialPositionSide(direction))) | 1716 || (startPosition.isNamedGridArea() && !NamedLineCollection::isValidName
dLineOrArea(startPosition.namedGridLine(), styleRef(), GridPositionsResolver::in
itialPositionSide(direction))) |
| 1719 || (startLine < firstExplicitLine) | 1717 || (startLine < 0) |
| 1720 || (startLine > lastExplicitLine); | 1718 || (startLine > lastLine); |
| 1721 bool endIsAuto = endPosition.isAuto() | 1719 bool endIsAuto = endPosition.isAuto() |
| 1722 || (endPosition.isNamedGridArea() && !NamedLineCollection::isValidNamedL
ineOrArea(endPosition.namedGridLine(), styleRef(), GridPositionsResolver::finalP
ositionSide(direction))) | 1720 || (endPosition.isNamedGridArea() && !NamedLineCollection::isValidNamedL
ineOrArea(endPosition.namedGridLine(), styleRef(), GridPositionsResolver::finalP
ositionSide(direction))) |
| 1723 || (endLine < firstExplicitLine) | 1721 || (endLine < 0) |
| 1724 || (endLine > lastExplicitLine); | 1722 || (endLine > lastLine); |
| 1725 | 1723 |
| 1726 LayoutUnit start; | 1724 LayoutUnit start; |
| 1727 if (!startIsAuto) { | 1725 if (!startIsAuto) { |
| 1728 if (isForColumns) { | 1726 if (isForColumns) { |
| 1729 if (styleRef().isLeftToRightDirection()) | 1727 if (styleRef().isLeftToRightDirection()) |
| 1730 start = m_columnPositions[startLine] - borderLogicalLeft(); | 1728 start = m_columnPositions[startLine] - borderLogicalLeft(); |
| 1731 else | 1729 else |
| 1732 start = logicalWidth() - translateRTLCoordinate(m_columnPosition
s[startLine]) - borderLogicalRight(); | 1730 start = logicalWidth() - translateRTLCoordinate(m_columnPosition
s[startLine]) - borderLogicalRight(); |
| 1733 } else { | 1731 } else { |
| 1734 start = m_rowPositions[startLine] - borderBefore(); | 1732 start = m_rowPositions[startLine] - borderBefore(); |
| 1735 } | 1733 } |
| 1736 } | 1734 } |
| 1737 | 1735 |
| 1738 LayoutUnit end = isForColumns ? clientLogicalWidth() : clientLogicalHeight()
; | 1736 LayoutUnit end = isForColumns ? clientLogicalWidth() : clientLogicalHeight()
; |
| 1739 if (!endIsAuto) { | 1737 if (!endIsAuto) { |
| 1740 if (isForColumns) { | 1738 if (isForColumns) { |
| 1741 if (styleRef().isLeftToRightDirection()) | 1739 if (styleRef().isLeftToRightDirection()) |
| 1742 end = m_columnPositions[endLine] - borderLogicalLeft(); | 1740 end = m_columnPositions[endLine] - borderLogicalLeft(); |
| 1743 else | 1741 else |
| 1744 end = logicalWidth() - translateRTLCoordinate(m_columnPositions[
endLine]) - borderLogicalRight(); | 1742 end = logicalWidth() - translateRTLCoordinate(m_columnPositions[
endLine]) - borderLogicalRight(); |
| 1745 } else { | 1743 } else { |
| 1746 end = m_rowPositions[endLine] - borderBefore(); | 1744 end = m_rowPositions[endLine] - borderBefore(); |
| 1747 } | 1745 } |
| 1748 | 1746 |
| 1749 // These vectors store line positions including gaps, but we shouldn't c
onsider them for the edges of the grid. | 1747 // These vectors store line positions including gaps, but we shouldn't c
onsider them for the edges of the grid. |
| 1750 if (endLine > firstExplicitLine && endLine < lastExplicitLine) { | 1748 if (endLine > 0 && endLine < lastLine) { |
| 1751 end -= guttersSize(direction, 2); | 1749 end -= guttersSize(direction, 2); |
| 1752 end -= isForColumns ? m_offsetBetweenColumns : m_offsetBetweenRows; | 1750 end -= isForColumns ? m_offsetBetweenColumns : m_offsetBetweenRows; |
| 1753 } | 1751 } |
| 1754 } | 1752 } |
| 1755 | 1753 |
| 1756 breadth = end - start; | 1754 breadth = end - start; |
| 1757 offset = start; | 1755 offset = start; |
| 1758 | 1756 |
| 1759 if (isForColumns && !styleRef().isLeftToRightDirection() && !child.styleRef(
).hasStaticInlinePosition(child.isHorizontalWritingMode())) { | 1757 if (isForColumns && !styleRef().isLeftToRightDirection() && !child.styleRef(
).hasStaticInlinePosition(child.isHorizontalWritingMode())) { |
| 1760 // If the child doesn't have a static inline position (i.e. "left" and/o
r "right" aren't "auto", | 1758 // If the child doesn't have a static inline position (i.e. "left" and/o
r "right" aren't "auto", |
| 1761 // we need to calculate the offset from the left (even if we're in RTL). | 1759 // we need to calculate the offset from the left (even if we're in RTL). |
| 1762 if (endIsAuto) { | 1760 if (endIsAuto) { |
| 1763 offset = LayoutUnit(); | 1761 offset = LayoutUnit(); |
| 1764 } else { | 1762 } else { |
| 1765 offset = translateRTLCoordinate(m_columnPositions[endLine]) - border
LogicalLeft(); | 1763 offset = translateRTLCoordinate(m_columnPositions[endLine]) - border
LogicalLeft(); |
| 1766 | 1764 |
| 1767 if (endLine > firstExplicitLine && endLine < lastExplicitLine) { | 1765 if (endLine > 0 && endLine < lastLine) { |
| 1768 offset += guttersSize(direction, 2); | 1766 offset += guttersSize(direction, 2); |
| 1769 offset += isForColumns ? m_offsetBetweenColumns : m_offsetBetwee
nRows; | 1767 offset += isForColumns ? m_offsetBetweenColumns : m_offsetBetwee
nRows; |
| 1770 } | 1768 } |
| 1771 } | 1769 } |
| 1772 } | 1770 } |
| 1773 | 1771 |
| 1774 } | 1772 } |
| 1775 | 1773 |
| 1776 GridArea LayoutGrid::cachedGridArea(const LayoutBox& gridItem) const | 1774 GridArea LayoutGrid::cachedGridArea(const LayoutBox& gridItem) const |
| 1777 { | 1775 { |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2257 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData
)); | 2255 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData
)); |
| 2258 } | 2256 } |
| 2259 | 2257 |
| 2260 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const | 2258 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const |
| 2261 { | 2259 { |
| 2262 if (!m_gridItemArea.isEmpty()) | 2260 if (!m_gridItemArea.isEmpty()) |
| 2263 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2261 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
| 2264 } | 2262 } |
| 2265 | 2263 |
| 2266 } // namespace blink | 2264 } // namespace blink |
| OLD | NEW |