Skip to content
Permalink
Browse files
[css-grid] Add method to translate RTL coordinates
https://bugs.webkit.org/show_bug.cgi?id=156589

Reviewed by Antonio Gomes.

This is just a small refactoring adding a new function
LayoutGrid::translateRTLCoordinate().
This method translates to physical coordinates the information
stored in m_columnPositions when you're using RTL direction.

No new tests, no change of behavior.

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::offsetAndBreadthForPositionedChild): Use the new
method translateRTLCoordinate().
(WebCore::RenderGrid::translateRTLCoordinate): New method that converts
a coordinate from m_columnPositions in RTL into a physical coordinate.
(WebCore::RenderGrid::findChildLogicalPosition): Use the new method
translateRTLCoordinate().
* rendering/RenderGrid.h: Add method signature.


Canonical link: https://commits.webkit.org/174790@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199655 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
mrego committed Apr 18, 2016
1 parent 934b9f2 commit 1bc15d66bbebecf1a471c329c7e772b0df6f6572
Showing with 36 additions and 8 deletions.
  1. +23 −0 Source/WebCore/ChangeLog
  2. +12 −8 Source/WebCore/rendering/RenderGrid.cpp
  3. +1 −0 Source/WebCore/rendering/RenderGrid.h
@@ -1,3 +1,26 @@
2016-04-18 Manuel Rego Casasnovas <rego@igalia.com>

[css-grid] Add method to translate RTL coordinates
https://bugs.webkit.org/show_bug.cgi?id=156589

Reviewed by Antonio Gomes.

This is just a small refactoring adding a new function
LayoutGrid::translateRTLCoordinate().
This method translates to physical coordinates the information
stored in m_columnPositions when you're using RTL direction.

No new tests, no change of behavior.

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::offsetAndBreadthForPositionedChild): Use the new
method translateRTLCoordinate().
(WebCore::RenderGrid::translateRTLCoordinate): New method that converts
a coordinate from m_columnPositions in RTL into a physical coordinate.
(WebCore::RenderGrid::findChildLogicalPosition): Use the new method
translateRTLCoordinate().
* rendering/RenderGrid.h: Add method signature.

2016-04-18 Yusuke Suzuki <utatane.tea@gmail.com>

[Fetch] Use @isArray instead of `instanceof @Array`
@@ -1547,9 +1547,7 @@ void RenderGrid::offsetAndBreadthForPositionedChild(const RenderBox& child, Grid
if (endIsAuto)
offset = LayoutUnit();
else {
LayoutUnit alignmentOffset = m_columnPositions[0] - borderAndPaddingStart();
LayoutUnit offsetFromLastLine = m_columnPositions[m_columnPositions.size() - 1] - m_columnPositions[endLine];
offset = paddingLeft() + alignmentOffset + offsetFromLastLine;
offset = translateRTLCoordinate(m_columnPositions[endLine]) - borderLeft();

if (endLine > firstExplicitLine && endLine < lastExplicitLine)
offset += guttersSize(direction, 2);
@@ -2049,16 +2047,22 @@ ContentAlignmentData RenderGrid::computeContentPositionAndDistributionOffset(Gri
return {0, 0};
}

LayoutUnit RenderGrid::translateRTLCoordinate(LayoutUnit coordinate) const
{
ASSERT(!style().isLeftToRightDirection());

LayoutUnit alignmentOffset = m_columnPositions[0] - borderAndPaddingStart();
LayoutUnit rightGridEdgePosition = m_columnPositions[m_columnPositions.size() - 1];
return borderAndPaddingLogicalLeft() + rightGridEdgePosition + alignmentOffset - coordinate;
}

LayoutPoint RenderGrid::findChildLogicalPosition(const RenderBox& child) const
{
LayoutUnit rowAxisOffset = rowAxisOffsetForChild(child);
// We stored m_columnPositions's data ignoring the direction, hence we might need now
// to translate positions from RTL to LTR, as it's more convenient for painting.
if (!style().isLeftToRightDirection()) {
LayoutUnit alignmentOffset = m_columnPositions[0] - borderAndPaddingStart();
LayoutUnit rightGridEdgePosition = m_columnPositions[m_columnPositions.size() - 1] + alignmentOffset + borderAndPaddingLogicalLeft();
rowAxisOffset = rightGridEdgePosition - (rowAxisOffset + child.logicalWidth());
}
if (!style().isLeftToRightDirection())
rowAxisOffset = translateRTLCoordinate(rowAxisOffset) - child.logicalWidth();

return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child));
}
@@ -181,6 +181,7 @@ class RenderGrid final : public RenderBlock {
}

bool hasDefiniteLogicalSize(GridTrackSizingDirection) const;
LayoutUnit translateRTLCoordinate(LayoutUnit) const;

Vector<Vector<Vector<RenderBox*, 1>>> m_grid;
Vector<LayoutUnit> m_columnPositions;

0 comments on commit 1bc15d6

Please sign in to comment.