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 1678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 | 1689 |
1690 bool startIsAuto = startPosition.isAuto() | 1690 bool startIsAuto = startPosition.isAuto() |
1691 || (startPosition.isNamedGridArea() && !NamedLineCollection::isValidName
dLineOrArea(startPosition.namedGridLine(), styleRef(), GridPositionsResolver::in
itialPositionSide(direction))) | 1691 || (startPosition.isNamedGridArea() && !NamedLineCollection::isValidName
dLineOrArea(startPosition.namedGridLine(), styleRef(), GridPositionsResolver::in
itialPositionSide(direction))) |
1692 || (startLine < firstExplicitLine) | 1692 || (startLine < firstExplicitLine) |
1693 || (startLine > lastExplicitLine); | 1693 || (startLine > lastExplicitLine); |
1694 bool endIsAuto = endPosition.isAuto() | 1694 bool endIsAuto = endPosition.isAuto() |
1695 || (endPosition.isNamedGridArea() && !NamedLineCollection::isValidNamedL
ineOrArea(endPosition.namedGridLine(), styleRef(), GridPositionsResolver::finalP
ositionSide(direction))) | 1695 || (endPosition.isNamedGridArea() && !NamedLineCollection::isValidNamedL
ineOrArea(endPosition.namedGridLine(), styleRef(), GridPositionsResolver::finalP
ositionSide(direction))) |
1696 || (endLine < firstExplicitLine) | 1696 || (endLine < firstExplicitLine) |
1697 || (endLine > lastExplicitLine); | 1697 || (endLine > lastExplicitLine); |
1698 | 1698 |
1699 // We're normalizing the positions to avoid issues with RTL (as they're stor
ed in the same order than LTR but adding an offset). | |
1700 LayoutUnit start; | 1699 LayoutUnit start; |
1701 if (!startIsAuto) { | 1700 if (!startIsAuto) { |
1702 if (isForColumns) | 1701 if (isForColumns) { |
1703 start = m_columnPositions[startLine] - m_columnPositions[0] + paddin
gStart(); | 1702 if (styleRef().isLeftToRightDirection()) |
1704 else | 1703 start = m_columnPositions[startLine] - borderLogicalLeft(); |
1705 start = m_rowPositions[startLine] - m_rowPositions[0] + paddingBefor
e(); | 1704 else |
| 1705 start = logicalWidth() - translateRTLCoordinate(m_columnPosition
s[startLine]) - borderLogicalRight(); |
| 1706 } else { |
| 1707 start = m_rowPositions[startLine] - borderBefore(); |
| 1708 } |
1706 } | 1709 } |
1707 | 1710 |
1708 LayoutUnit end = isForColumns ? clientLogicalWidth() : clientLogicalHeight()
; | 1711 LayoutUnit end = isForColumns ? clientLogicalWidth() : clientLogicalHeight()
; |
1709 if (!endIsAuto) { | 1712 if (!endIsAuto) { |
1710 if (isForColumns) | 1713 if (isForColumns) { |
1711 end = m_columnPositions[endLine] - m_columnPositions[0] + paddingSta
rt(); | 1714 if (styleRef().isLeftToRightDirection()) |
1712 else | 1715 end = m_columnPositions[endLine] - borderLogicalLeft(); |
1713 end = m_rowPositions[endLine] - m_rowPositions[0] + paddingBefore(); | 1716 else |
| 1717 end = logicalWidth() - translateRTLCoordinate(m_columnPositions[
endLine]) - borderLogicalRight(); |
| 1718 } else { |
| 1719 end = m_rowPositions[endLine] - borderBefore(); |
| 1720 } |
1714 | 1721 |
1715 // These vectors store line positions including gaps, but we shouldn't c
onsider them for the edges of the grid. | 1722 // These vectors store line positions including gaps, but we shouldn't c
onsider them for the edges of the grid. |
1716 if (endLine > firstExplicitLine && endLine < lastExplicitLine) { | 1723 if (endLine > firstExplicitLine && endLine < lastExplicitLine) { |
1717 end -= guttersSize(direction, 2); | 1724 end -= guttersSize(direction, 2); |
1718 end -= isForColumns ? m_offsetBetweenColumns : m_offsetBetweenRows; | 1725 end -= isForColumns ? m_offsetBetweenColumns : m_offsetBetweenRows; |
1719 } | 1726 } |
1720 } | 1727 } |
1721 | 1728 |
1722 LayoutUnit alignmentOffset = isForColumns ? m_columnPositions[0] - borderAnd
PaddingLogicalLeft() : m_rowPositions[0] - borderAndPaddingBefore(); | |
1723 if (isForColumns && !styleRef().isLeftToRightDirection()) | |
1724 alignmentOffset = contentLogicalWidth() - (m_columnPositions[m_columnPos
itions.size() - 1] - borderAndPaddingLogicalLeft()); | |
1725 | |
1726 if (!startIsAuto) | |
1727 start += alignmentOffset; | |
1728 if (!endIsAuto) | |
1729 end += alignmentOffset; | |
1730 | |
1731 breadth = end - start; | 1729 breadth = end - start; |
1732 offset = start; | 1730 offset = start; |
1733 | 1731 |
1734 if (isForColumns && !styleRef().isLeftToRightDirection() && !child.styleRef(
).hasStaticInlinePosition(child.isHorizontalWritingMode())) { | 1732 if (isForColumns && !styleRef().isLeftToRightDirection() && !child.styleRef(
).hasStaticInlinePosition(child.isHorizontalWritingMode())) { |
1735 // If the child doesn't have a static inline position (i.e. "left" and/o
r "right" aren't "auto", | 1733 // If the child doesn't have a static inline position (i.e. "left" and/o
r "right" aren't "auto", |
1736 // we need to calculate the offset from the left (even if we're in RTL). | 1734 // we need to calculate the offset from the left (even if we're in RTL). |
1737 if (endIsAuto) { | 1735 if (endIsAuto) { |
1738 offset = LayoutUnit(); | 1736 offset = LayoutUnit(); |
1739 } else { | 1737 } else { |
1740 offset = translateRTLCoordinate(m_columnPositions[endLine]) - border
LogicalLeft(); | 1738 offset = translateRTLCoordinate(m_columnPositions[endLine]) - border
LogicalLeft(); |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2237 | 2235 |
2238 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData
)); | 2236 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData
)); |
2239 } | 2237 } |
2240 | 2238 |
2241 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const | 2239 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const |
2242 { | 2240 { |
2243 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2241 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
2244 } | 2242 } |
2245 | 2243 |
2246 } // namespace blink | 2244 } // namespace blink |
OLD | NEW |