Title: [200427] trunk/Source/WebCore
- Revision
- 200427
- Author
- [email protected]
- Date
- 2016-05-04 13:32:06 -0700 (Wed, 04 May 2016)
Log Message
[css-grid] Refactor information stored related to column positions
https://bugs.webkit.org/show_bug.cgi?id=157342
Reviewed by Darin Adler.
In m_columnPositions we were storing position of each column
including the alignment offset, always from the logical left,
and the border and padding, depending on the direction.
This was really confusing as in the case of RTL direction
we were adding the offset from the left and
the right border and padding.
This patches changes it to store always the info from the left,
so even in RTL direction we use the left border and padding.
This allows us to simplify translateRTLCoordinate() as
it doesn't need to care about border and padding anymore.
And also to refactor offsetAndBreadthForPositionedChild()
which became really complex after adding RTL support.
No new tests, no change of behavior.
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::offsetAndBreadthForPositionedChild):
(WebCore::RenderGrid::populateGridPositions):
(WebCore::RenderGrid::translateRTLCoordinate):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (200426 => 200427)
--- trunk/Source/WebCore/ChangeLog 2016-05-04 20:15:26 UTC (rev 200426)
+++ trunk/Source/WebCore/ChangeLog 2016-05-04 20:32:06 UTC (rev 200427)
@@ -1,3 +1,33 @@
+2016-05-04 Manuel Rego Casasnovas <[email protected]>
+
+ [css-grid] Refactor information stored related to column positions
+ https://bugs.webkit.org/show_bug.cgi?id=157342
+
+ Reviewed by Darin Adler.
+
+ In m_columnPositions we were storing position of each column
+ including the alignment offset, always from the logical left,
+ and the border and padding, depending on the direction.
+
+ This was really confusing as in the case of RTL direction
+ we were adding the offset from the left and
+ the right border and padding.
+
+ This patches changes it to store always the info from the left,
+ so even in RTL direction we use the left border and padding.
+
+ This allows us to simplify translateRTLCoordinate() as
+ it doesn't need to care about border and padding anymore.
+ And also to refactor offsetAndBreadthForPositionedChild()
+ which became really complex after adding RTL support.
+
+ No new tests, no change of behavior.
+
+ * rendering/RenderGrid.cpp:
+ (WebCore::RenderGrid::offsetAndBreadthForPositionedChild):
+ (WebCore::RenderGrid::populateGridPositions):
+ (WebCore::RenderGrid::translateRTLCoordinate):
+
2016-05-04 Mark Lam <[email protected]>
ES6 Function.name inferred from property names of literal objects can break some websites.
Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (200426 => 200427)
--- trunk/Source/WebCore/rendering/RenderGrid.cpp 2016-05-04 20:15:26 UTC (rev 200426)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp 2016-05-04 20:32:06 UTC (rev 200427)
@@ -1560,18 +1560,24 @@
// We're normalizing the positions to avoid issues with RTL (as they're stored in the same order than LTR but adding an offset).
LayoutUnit start;
if (!startIsAuto) {
- if (isRowAxis)
- start = m_columnPositions[startLine] - m_columnPositions[0] + paddingStart();
- else
- start = m_rowPositions[startLine] - m_rowPositions[0] + paddingBefore();
+ if (isRowAxis) {
+ if (style().isLeftToRightDirection())
+ start = m_columnPositions[startLine] - borderLogicalLeft();
+ else
+ start = logicalWidth() - translateRTLCoordinate(m_columnPositions[startLine]) - borderLogicalRight();
+ } else
+ start = m_rowPositions[startLine] - borderBefore();
}
LayoutUnit end = isRowAxis ? clientLogicalWidth() : clientLogicalHeight();
if (!endIsAuto) {
- if (isRowAxis)
- end = m_columnPositions[endLine] - m_columnPositions[0] + paddingStart();
- else
- end = m_rowPositions[endLine] - m_rowPositions[0] + paddingBefore();
+ if (isRowAxis) {
+ if (style().isLeftToRightDirection())
+ end = m_columnPositions[endLine] - borderLogicalLeft();
+ else
+ end = logicalWidth() - translateRTLCoordinate(m_columnPositions[endLine]) - borderLogicalRight();
+ } else
+ end = m_rowPositions[endLine] - borderBefore();
// These vectors store line positions including gaps, but we shouldn't consider them for the edges of the grid.
if (endLine > firstExplicitLine && endLine < lastExplicitLine) {
@@ -1580,15 +1586,6 @@
}
}
- LayoutUnit alignmentOffset = isRowAxis ? m_columnPositions[0] - borderAndPaddingStart() : m_rowPositions[0] - borderAndPaddingBefore();
- if (isRowAxis && !style().isLeftToRightDirection())
- alignmentOffset = contentLogicalWidth() - (m_columnPositions[m_columnPositions.size() - 1] - borderAndPaddingStart());
-
- if (!startIsAuto)
- start += alignmentOffset;
- if (!endIsAuto)
- end += alignmentOffset;
-
breadth = end - start;
offset = start;
@@ -1672,7 +1669,7 @@
ContentAlignmentData offset = computeContentPositionAndDistributionOffset(ForColumns, sizingData.freeSpaceForDirection(ForColumns).value(), numberOfTracks);
LayoutUnit trackGap = guttersSize(ForColumns, 2);
m_columnPositions.resize(numberOfLines);
- m_columnPositions[0] = borderAndPaddingStart() + offset.positionOffset;
+ m_columnPositions[0] = borderAndPaddingLogicalLeft() + offset.positionOffset;
for (unsigned i = 0; i < nextToLastLine; ++i)
m_columnPositions[i + 1] = m_columnPositions[i] + offset.distributionOffset + sizingData.columnTracks[i].baseSize() + trackGap;
m_columnPositions[lastLine] = m_columnPositions[nextToLastLine] + sizingData.columnTracks[nextToLastLine].baseSize();
@@ -2098,9 +2095,9 @@
{
ASSERT(!style().isLeftToRightDirection());
- LayoutUnit alignmentOffset = m_columnPositions[0] - borderAndPaddingStart();
+ LayoutUnit alignmentOffset = m_columnPositions[0];
LayoutUnit rightGridEdgePosition = m_columnPositions[m_columnPositions.size() - 1];
- return borderAndPaddingLogicalLeft() + rightGridEdgePosition + alignmentOffset - coordinate;
+ return rightGridEdgePosition + alignmentOffset - coordinate;
}
LayoutPoint RenderGrid::findChildLogicalPosition(const RenderBox& child) const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes