Title: [199655] trunk/Source/WebCore
Revision
199655
Author
[email protected]
Date
2016-04-18 01:03:24 -0700 (Mon, 18 Apr 2016)

Log Message

[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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (199654 => 199655)


--- trunk/Source/WebCore/ChangeLog	2016-04-18 08:01:07 UTC (rev 199654)
+++ trunk/Source/WebCore/ChangeLog	2016-04-18 08:03:24 UTC (rev 199655)
@@ -1,3 +1,26 @@
+2016-04-18  Manuel Rego Casasnovas  <[email protected]>
+
+        [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  <[email protected]>
 
         [Fetch] Use @isArray instead of `instanceof @Array`

Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (199654 => 199655)


--- trunk/Source/WebCore/rendering/RenderGrid.cpp	2016-04-18 08:01:07 UTC (rev 199654)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp	2016-04-18 08:03:24 UTC (rev 199655)
@@ -1547,9 +1547,7 @@
         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 @@
     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));
 }

Modified: trunk/Source/WebCore/rendering/RenderGrid.h (199654 => 199655)


--- trunk/Source/WebCore/rendering/RenderGrid.h	2016-04-18 08:01:07 UTC (rev 199654)
+++ trunk/Source/WebCore/rendering/RenderGrid.h	2016-04-18 08:03:24 UTC (rev 199655)
@@ -181,6 +181,7 @@
     }
 
     bool hasDefiniteLogicalSize(GridTrackSizingDirection) const;
+    LayoutUnit translateRTLCoordinate(LayoutUnit) const;
 
     Vector<Vector<Vector<RenderBox*, 1>>> m_grid;
     Vector<LayoutUnit> m_columnPositions;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to