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 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1545 | 1545 |
1546 breadth = end - start; | 1546 breadth = end - start; |
1547 offset = start; | 1547 offset = start; |
1548 | 1548 |
1549 if (isForColumns && !styleRef().isLeftToRightDirection() && !child.styleRef(
).hasStaticInlinePosition(child.isHorizontalWritingMode())) { | 1549 if (isForColumns && !styleRef().isLeftToRightDirection() && !child.styleRef(
).hasStaticInlinePosition(child.isHorizontalWritingMode())) { |
1550 // If the child doesn't have a static inline position (i.e. "left" and/o
r "right" aren't "auto", | 1550 // If the child doesn't have a static inline position (i.e. "left" and/o
r "right" aren't "auto", |
1551 // we need to calculate the offset from the left (even if we're in RTL). | 1551 // we need to calculate the offset from the left (even if we're in RTL). |
1552 if (endIsAuto) { | 1552 if (endIsAuto) { |
1553 offset = LayoutUnit(); | 1553 offset = LayoutUnit(); |
1554 } else { | 1554 } else { |
1555 LayoutUnit alignmentOffset = m_columnPositions[0] - borderAndPaddin
gStart(); | 1555 offset = translateRTLCoordinate(m_columnPositions[endLine]) - border
Left(); |
1556 LayoutUnit offsetFromLastLine = m_columnPositions[m_columnPositions.
size() - 1] - m_columnPositions[endLine]; | |
1557 offset = paddingLeft() + alignmentOffset + offsetFromLastLine; | |
1558 | 1556 |
1559 if (endLine > firstExplicitLine && endLine < lastExplicitLine) | 1557 if (endLine > firstExplicitLine && endLine < lastExplicitLine) |
1560 offset += guttersSize(direction, 2); | 1558 offset += guttersSize(direction, 2); |
1561 } | 1559 } |
1562 } | 1560 } |
1563 | 1561 |
1564 if (child.parent() == this && !startIsAuto) { | 1562 if (child.parent() == this && !startIsAuto) { |
1565 // If column/row start is "auto" the static position has been already se
t in prepareChildForPositionedLayout(). | 1563 // If column/row start is "auto" the static position has been already se
t in prepareChildForPositionedLayout(). |
1566 PaintLayer* childLayer = child.layer(); | 1564 PaintLayer* childLayer = child.layer(); |
1567 if (isForColumns) | 1565 if (isForColumns) |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2039 return {styleRef().isLeftToRightDirection() ? LayoutUnit() : availab
leFreeSpace, LayoutUnit()}; | 2037 return {styleRef().isLeftToRightDirection() ? LayoutUnit() : availab
leFreeSpace, LayoutUnit()}; |
2040 return {LayoutUnit(), LayoutUnit()}; | 2038 return {LayoutUnit(), LayoutUnit()}; |
2041 case ContentPositionNormal: | 2039 case ContentPositionNormal: |
2042 break; | 2040 break; |
2043 } | 2041 } |
2044 | 2042 |
2045 ASSERT_NOT_REACHED(); | 2043 ASSERT_NOT_REACHED(); |
2046 return {LayoutUnit(), LayoutUnit()}; | 2044 return {LayoutUnit(), LayoutUnit()}; |
2047 } | 2045 } |
2048 | 2046 |
| 2047 LayoutUnit LayoutGrid::translateRTLCoordinate(LayoutUnit coordinate) const |
| 2048 { |
| 2049 ASSERT(!styleRef().isLeftToRightDirection()); |
| 2050 |
| 2051 LayoutUnit alignmentOffset = m_columnPositions[0] - borderAndPaddingStart(); |
| 2052 LayoutUnit rightGridEdgePosition = m_columnPositions[m_columnPositions.size(
) - 1]; |
| 2053 return borderAndPaddingLogicalLeft() + rightGridEdgePosition + alignmentOffs
et - coordinate; |
| 2054 } |
| 2055 |
2049 LayoutPoint LayoutGrid::findChildLogicalPosition(const LayoutBox& child, GridSiz
ingData& sizingData) const | 2056 LayoutPoint LayoutGrid::findChildLogicalPosition(const LayoutBox& child, GridSiz
ingData& sizingData) const |
2050 { | 2057 { |
2051 LayoutUnit rowAxisOffset = rowAxisOffsetForChild(child, sizingData); | 2058 LayoutUnit rowAxisOffset = rowAxisOffsetForChild(child, sizingData); |
2052 // We stored m_columnPosition s's data ignoring the direction, hence we migh
t need now | 2059 // We stored m_columnPosition s's data ignoring the direction, hence we migh
t need now |
2053 // to translate positions from RTL to LTR, as it's more convenient for paint
ing. | 2060 // to translate positions from RTL to LTR, as it's more convenient for paint
ing. |
2054 if (!style()->isLeftToRightDirection()) { | 2061 if (!style()->isLeftToRightDirection()) |
2055 LayoutUnit alignmentOffset = m_columnPositions[0] - borderAndPaddingSta
rt(); | 2062 rowAxisOffset = translateRTLCoordinate(rowAxisOffset) - child.logicalWid
th(); |
2056 LayoutUnit rightGridEdgePosition = m_columnPositions[m_columnPositions.s
ize() - 1] + alignmentOffset + borderAndPaddingLogicalLeft(); | |
2057 rowAxisOffset = rightGridEdgePosition - (rowAxisOffset + child.logicalWi
dth()); | |
2058 } | |
2059 | 2063 |
2060 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData
)); | 2064 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData
)); |
2061 } | 2065 } |
2062 | 2066 |
2063 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const | 2067 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const |
2064 { | 2068 { |
2065 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2069 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
2066 } | 2070 } |
2067 | 2071 |
2068 } // namespace blink | 2072 } // namespace blink |
OLD | NEW |