Title: [199098] trunk
Revision
199098
Author
[email protected]
Date
2016-04-06 03:21:59 -0700 (Wed, 06 Apr 2016)

Log Message

[css-grid] Fix positioned children in RTL
https://bugs.webkit.org/show_bug.cgi?id=156162

Reviewed by Sergio Villar Senin.

Source/WebCore:

This patch fixes a problem affecting the items without
a static inline position (i.e. "left" and/or "right" properties
are not "auto"). In this particular case we need to compute
the "offset" from the left, so we need a specific condition
and computation.

Let's use an example to understand what it's fixing:
<div style="display: grid; grid-template-columns: 100px 50px; width: 300px;
            position: relative; direction: rtl;">
    <div style="position: absolute; left: 0; grid-column: 1 / 2;">item</div>
</div>

In this case the item has to be placed in the first column
(the one on the right as we're in RTL).
For this we need to calculate the offset from the left, which is 200px:
150px (alignment offset) + 50px (offset from line 3 to 2).

Test: fast/css-grid-layout/grid-positioned-items-background-rtl.html

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::offsetAndBreadthForPositionedChild):

LayoutTests:

Added more RTL cases for the positioned tests.

* fast/css-grid-layout/absolute-positioning-grid-container-containing-block-expected.txt:
* fast/css-grid-layout/absolute-positioning-grid-container-containing-block.html:
* fast/css-grid-layout/grid-positioned-items-background-rtl-expected.html: Added.
* fast/css-grid-layout/grid-positioned-items-background-rtl.html: Added.
* fast/css-grid-layout/grid-positioned-items-padding-expected.txt:
* fast/css-grid-layout/grid-positioned-items-padding.html:
* fast/css-grid-layout/grid-positioned-items-within-grid-implicit-track-expected.txt:
* fast/css-grid-layout/grid-positioned-items-within-grid-implicit-track.html:
* fast/css-grid-layout/grid-sizing-positioned-items-expected.txt:
* fast/css-grid-layout/grid-sizing-positioned-items.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (199097 => 199098)


--- trunk/LayoutTests/ChangeLog	2016-04-06 09:27:22 UTC (rev 199097)
+++ trunk/LayoutTests/ChangeLog	2016-04-06 10:21:59 UTC (rev 199098)
@@ -1,3 +1,23 @@
+2016-04-06  Manuel Rego Casasnovas  <[email protected]>
+
+        [css-grid] Fix positioned children in RTL
+        https://bugs.webkit.org/show_bug.cgi?id=156162
+
+        Reviewed by Sergio Villar Senin.
+
+        Added more RTL cases for the positioned tests.
+
+        * fast/css-grid-layout/absolute-positioning-grid-container-containing-block-expected.txt:
+        * fast/css-grid-layout/absolute-positioning-grid-container-containing-block.html:
+        * fast/css-grid-layout/grid-positioned-items-background-rtl-expected.html: Added.
+        * fast/css-grid-layout/grid-positioned-items-background-rtl.html: Added.
+        * fast/css-grid-layout/grid-positioned-items-padding-expected.txt:
+        * fast/css-grid-layout/grid-positioned-items-padding.html:
+        * fast/css-grid-layout/grid-positioned-items-within-grid-implicit-track-expected.txt:
+        * fast/css-grid-layout/grid-positioned-items-within-grid-implicit-track.html:
+        * fast/css-grid-layout/grid-sizing-positioned-items-expected.txt:
+        * fast/css-grid-layout/grid-sizing-positioned-items.html:
+
 2016-04-06  Antti Koivisto  <[email protected]>
 
         ComposedTreeIterator may crash when first child of shadow root is a comment node

Modified: trunk/LayoutTests/fast/css-grid-layout/absolute-positioning-grid-container-containing-block-expected.txt (199097 => 199098)


--- trunk/LayoutTests/fast/css-grid-layout/absolute-positioning-grid-container-containing-block-expected.txt	2016-04-06 09:27:22 UTC (rev 199097)
+++ trunk/LayoutTests/fast/css-grid-layout/absolute-positioning-grid-container-containing-block-expected.txt	2016-04-06 10:21:59 UTC (rev 199098)
@@ -8,3 +8,5 @@
 PASS
 PASS
 PASS
+PASS
+PASS

Modified: trunk/LayoutTests/fast/css-grid-layout/absolute-positioning-grid-container-containing-block.html (199097 => 199098)


--- trunk/LayoutTests/fast/css-grid-layout/absolute-positioning-grid-container-containing-block.html	2016-04-06 09:27:22 UTC (rev 199097)
+++ trunk/LayoutTests/fast/css-grid-layout/absolute-positioning-grid-container-containing-block.html	2016-04-06 10:21:59 UTC (rev 199098)
@@ -293,5 +293,55 @@
     </div>
 </div>
 
+<div class="grid directionRTL">
+    <div class="sizedToGridArea absolute autoRowAutoColumn offsetLeft25 offsetTop75"
+        data-offset-x="25" data-offset-y="75" data-expected-width="530" data-expected-height="530">
+    </div>
+    <div class="sizedToGridArea absolute firstRowFirstColumn offsetRightMinus40 offsetBottomMinus80"
+        data-offset-x="40" data-offset-y="95" data-expected-width="515" data-expected-height="515">
+    </div>
+    <div class="sizedToGridArea absolute secondRowFirstColumn offsetRight50 offsetBottom100"
+        data-offset-x="-50" data-offset-y="-35" data-expected-width="515" data-expected-height="465">
+    </div>
+    <div class="sizedToGridArea absolute firstRowSecondColumn offsetLeftMinus20 offsetTopMinus60"
+        data-offset-x="-20" data-offset-y="-45" data-expected-width="465" data-expected-height="515">
+    </div>
+    <div class="sizedToGridArea absolute secondRowSecondColumn offsetRight50 offsetTop75"
+        data-offset-x="-50" data-offset-y="140" data-expected-width="465" data-expected-height="465">
+    </div>
+    <div class="sizedToGridArea absolute thirdRowThirdColumnSpanning2Rows offsetLeft25 offsetBottom100"
+        data-offset-x="25" data-offset-y="65" data-expected-width="365" data-expected-height="350">
+    </div>
+    <div class="sizedToGridArea absolute thirdRowThirdColumnSpanning2Rows2Columns offsetLeftMinus20 offsetRight50 offsetTopMinus60 offsetBottom100"
+        data-offset-x="-35" data-offset-y="105" data-expected-width="350" data-expected-height="350">
+    </div>
+</div>
+
+<div class="grid directionRTL">
+    <div>
+        <div class="sizedToGridArea absolute autoRowAutoColumn offsetLeft25 offsetTop75"
+            data-offset-x="25" data-offset-y="75" data-expected-width="530" data-expected-height="530">
+        </div>
+        <div class="sizedToGridArea absolute firstRowFirstColumn offsetRightMinus40 offsetBottomMinus80"
+            data-offset-x="40" data-offset-y="95" data-expected-width="515" data-expected-height="515">
+        </div>
+        <div class="sizedToGridArea absolute secondRowFirstColumn offsetRight50 offsetBottom100"
+            data-offset-x="-50" data-offset-y="-35" data-expected-width="515" data-expected-height="465">
+        </div>
+        <div class="sizedToGridArea absolute firstRowSecondColumn offsetLeftMinus20 offsetTopMinus60"
+            data-offset-x="-20" data-offset-y="-45" data-expected-width="465" data-expected-height="515">
+        </div>
+        <div class="sizedToGridArea absolute secondRowSecondColumn offsetRight50 offsetTop75"
+            data-offset-x="-50" data-offset-y="140" data-expected-width="465" data-expected-height="465">
+        </div>
+        <div class="sizedToGridArea absolute thirdRowThirdColumnSpanning2Rows offsetLeft25 offsetBottom100"
+            data-offset-x="25" data-offset-y="65" data-expected-width="365" data-expected-height="350">
+        </div>
+        <div class="sizedToGridArea absolute thirdRowThirdColumnSpanning2Rows2Columns offsetLeftMinus20 offsetRight50 offsetTopMinus60 offsetBottom100"
+            data-offset-x="-35" data-offset-y="105" data-expected-width="350" data-expected-height="350">
+        </div>
+    </div>
+</div>
+
 </body>
 </html>

Added: trunk/LayoutTests/fast/css-grid-layout/grid-positioned-items-background-rtl-expected.html (0 => 199098)


--- trunk/LayoutTests/fast/css-grid-layout/grid-positioned-items-background-rtl-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-positioned-items-background-rtl-expected.html	2016-04-06 10:21:59 UTC (rev 199098)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<style>
+.grid {
+    width: 500px;
+    height: 300px;
+    border: 5px solid black;
+    margin: 30px;
+    padding: 15px;
+}
+
+.container {
+    position: relative;
+    float: left;
+}
+
+.absolute {
+    position: absolute;
+}
+
+.green {
+    background-color: green;
+}
+</style>
+
+<p>This test checks that the background of positioned items is painted in the right position using RTL direction.</p>
+
+<p>The test passes if you see 4 green boxes and no red.</p>
+
+<div class="container">
+    <div class="grid"></div>
+    <div class="absolute green" style="left: 455px; top: 50px; width: 100px; height: 50px"></div>
+    <div class="absolute green" style="left: 390px; top: 50px; width: 50px; height: 20px"></div>
+    <div class="absolute green" style="left: 500px; top: 115px; width: 50px; height: 30px"></div>
+    <div class="absolute green" style="left: 275px; top: 135px; width: 145px; height: 75px"></div>
+</div>

Added: trunk/LayoutTests/fast/css-grid-layout/grid-positioned-items-background-rtl.html (0 => 199098)


--- trunk/LayoutTests/fast/css-grid-layout/grid-positioned-items-background-rtl.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-positioned-items-background-rtl.html	2016-04-06 10:21:59 UTC (rev 199098)
@@ -0,0 +1,74 @@
+<!DOCTYPE html>
+<link href="" rel="stylesheet">
+<style>
+
+.grid {
+    -webkit-grid-template-columns: 100px 200px;
+    -webkit-grid-template-rows: 50px 150px;
+    width: 500px;
+    height: 300px;
+    border: 5px solid black;
+    margin: 30px;
+    padding: 15px;
+    /* Ensures that the grid container is the containing block of the absolutely positioned grid children. */
+    position: relative;
+    background-color: transparent;
+}
+
+.container {
+    position: relative;
+    float: left;
+}
+
+.absolute {
+    position: absolute;
+}
+
+.grid > div {
+    background-color: green;
+}
+
+.lengthSize {
+    width: 50px;
+    height: 20px;
+}
+
+.percentageSize {
+    width: 50%;
+    height: 20%;
+}
+
+.offsetsSize {
+    left: 25px;
+    right: 30px;
+    top: 35px;
+    bottom: 40px;
+}
+
+.red {
+    background-color: red;
+}
+</style>
+
+<p>This test checks that the background of positioned items is painted in the right position using RTL direction.</p>
+
+<p>The test passes if you see 4 green boxes and no red.</p>
+
+<div class="container">
+    <div class="absolute red" style="left: 455px; top: 50px; width: 100px; height: 50px"></div>
+    <div class="absolute red" style="left: 390px; top: 50px; width: 50px; height: 20px"></div>
+    <div class="absolute red" style="left: 500px; top: 115px; width: 50px; height: 30px"></div>
+    <div class="absolute red" style="left: 275px; top: 135px; width: 145px; height: 75px"></div>
+    <div class="grid directionRTL">
+        <div class="absolute onlyFirstRowOnlyFirstColumn sizedToGridArea"
+            style="left: 5px;">
+        </div>
+        <div class="absolute onlyFirstRowOnlySecondColumn lengthSize"
+            style="right: 10px;">
+        </div>
+        <div class="absolute onlySecondRowOnlyFirstColumn percentageSize"
+            style="top: 15px;">
+        </div>
+        <div class="absolute onlySecondRowOnlySecondColumn offsetsSize"></div>
+    </div>
+</div>

Modified: trunk/LayoutTests/fast/css-grid-layout/grid-positioned-items-padding-expected.txt (199097 => 199098)


--- trunk/LayoutTests/fast/css-grid-layout/grid-positioned-items-padding-expected.txt	2016-04-06 09:27:22 UTC (rev 199097)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-positioned-items-padding-expected.txt	2016-04-06 10:21:59 UTC (rev 199098)
@@ -4,3 +4,7 @@
 PASS
 PASS
 PASS
+PASS
+PASS
+PASS
+PASS

Modified: trunk/LayoutTests/fast/css-grid-layout/grid-positioned-items-padding.html (199097 => 199098)


--- trunk/LayoutTests/fast/css-grid-layout/grid-positioned-items-padding.html	2016-04-06 09:27:22 UTC (rev 199097)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-positioned-items-padding.html	2016-04-06 10:21:59 UTC (rev 199098)
@@ -113,4 +113,88 @@
     </div>
 </div>
 
+<div class="grid directionRTL">
+    <div class="absolute" style="-webkit-grid-column: auto / 1; -webkit-grid-row: auto / 1;"
+        data-offset-x="515" data-offset-y="0" data-expected-width="15" data-expected-height="15">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 1 / 2; -webkit-grid-row: auto / 1;"
+        data-offset-x="415" data-offset-y="0" data-expected-width="100" data-expected-height="15">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: auto / 1; -webkit-grid-row: 1 / 2;"
+        data-offset-x="515" data-offset-y="15" data-expected-width="15" data-expected-height="50">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 3 / auto; -webkit-grid-row: 3 / auto;"
+        data-offset-x="0" data-offset-y="215" data-expected-width="215" data-expected-height="115">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 2 / 3; -webkit-grid-row: 3 / auto;"
+        data-offset-x="215" data-offset-y="215" data-expected-width="200" data-expected-height="115">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 3 / auto; -webkit-grid-row: 2 / 3;"
+        data-offset-x="0" data-offset-y="65" data-expected-width="215" data-expected-height="150">
+    </div>
+</div>
+
+<div class="grid directionRTL">
+    <div class="absolute" style="-webkit-grid-column: -5 / 1; -webkit-grid-row: -5 / 1;"
+        data-offset-x="515" data-offset-y="0" data-expected-width="15" data-expected-height="15">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 1 / 2; -webkit-grid-row: -5 / 1;"
+        data-offset-x="415" data-offset-y="0" data-expected-width="100" data-expected-height="15">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: -5 / 1; -webkit-grid-row: 1 / 2;"
+        data-offset-x="515" data-offset-y="15" data-expected-width="15" data-expected-height="50">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 3 / 5; -webkit-grid-row: 3 / 5;"
+        data-offset-x="0" data-offset-y="215" data-expected-width="215" data-expected-height="115">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 2 / 3; -webkit-grid-row: 3 / 5;"
+        data-offset-x="215" data-offset-y="215" data-expected-width="200" data-expected-height="115">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 3 / 5; -webkit-grid-row: 2 / 3;"
+        data-offset-x="0" data-offset-y="65" data-expected-width="215" data-expected-height="150">
+    </div>
+</div>
+
+<div class="grid directionRTL">
+    <div class="absolute" style="-webkit-grid-column: span 2 / 1; -webkit-grid-row: span 2 / 1;"
+        data-offset-x="515" data-offset-y="0" data-expected-width="15" data-expected-height="15">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 1 / 2; -webkit-grid-row: span 2 / 1;"
+        data-offset-x="415" data-offset-y="0" data-expected-width="100" data-expected-height="15">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: span 2 / 1; -webkit-grid-row: 1 / 2;"
+        data-offset-x="515" data-offset-y="15" data-expected-width="15" data-expected-height="50">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 3 / span 2; -webkit-grid-row: 3 / span 2;"
+        data-offset-x="0" data-offset-y="215" data-expected-width="215" data-expected-height="115">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 2 / 3; -webkit-grid-row: 3 / span 2;"
+        data-offset-x="215" data-offset-y="215" data-expected-width="200" data-expected-height="115">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 3 / span 2; -webkit-grid-row: 2 / 3;"
+        data-offset-x="0" data-offset-y="65" data-expected-width="215" data-expected-height="150">
+    </div>
+</div>
+
+<div class="grid directionRTL">
+    <div class="absolute" style="-webkit-grid-column: foo / 1; -webkit-grid-row: foo / 1;"
+        data-offset-x="515" data-offset-y="0" data-expected-width="15" data-expected-height="15">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 1 / 2; -webkit-grid-row: foo / 1;"
+        data-offset-x="415" data-offset-y="0" data-expected-width="100" data-expected-height="15">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: foo / 1; -webkit-grid-row: 1 / 2;"
+        data-offset-x="515" data-offset-y="15" data-expected-width="15" data-expected-height="50">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 3 / foo; -webkit-grid-row: 3 / foo;"
+        data-offset-x="0" data-offset-y="215" data-expected-width="215" data-expected-height="115">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 2 / 3; -webkit-grid-row: 3 / foo;"
+        data-offset-x="215" data-offset-y="215" data-expected-width="200" data-expected-height="115">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 3 / foo; -webkit-grid-row: 2 / 3;"
+        data-offset-x="0" data-offset-y="65" data-expected-width="215" data-expected-height="150">
+    </div>
+</div>
+
 </body>

Modified: trunk/LayoutTests/fast/css-grid-layout/grid-positioned-items-within-grid-implicit-track-expected.txt (199097 => 199098)


--- trunk/LayoutTests/fast/css-grid-layout/grid-positioned-items-within-grid-implicit-track-expected.txt	2016-04-06 09:27:22 UTC (rev 199097)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-positioned-items-within-grid-implicit-track-expected.txt	2016-04-06 10:21:59 UTC (rev 199098)
@@ -8,3 +8,11 @@
 PASS
 PASS
 PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS

Modified: trunk/LayoutTests/fast/css-grid-layout/grid-positioned-items-within-grid-implicit-track.html (199097 => 199098)


--- trunk/LayoutTests/fast/css-grid-layout/grid-positioned-items-within-grid-implicit-track.html	2016-04-06 09:27:22 UTC (rev 199097)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-positioned-items-within-grid-implicit-track.html	2016-04-06 10:21:59 UTC (rev 199098)
@@ -109,4 +109,76 @@
     </div>
 </div>
 
+<div class="grid directionRTL">
+    <div class="sixRowsAndSixColumns"
+        data-offset-x="-85" data-offset-y="15" data-expected-width="900" data-expected-height="600">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: auto / 1; -webkit-grid-row: auto / 1;"
+        data-offset-x="615" data-offset-y="0" data-expected-width="215" data-expected-height="115">
+    </div>
+</div>
+
+<div class="grid directionRTL">
+    <div class="sixRowsAndSixColumns"
+        data-offset-x="-85" data-offset-y="15" data-expected-width="900" data-expected-height="600">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: auto / 2; -webkit-grid-row: auto / 2;"
+        data-offset-x="415" data-offset-y="0" data-expected-width="415" data-expected-height="265">
+    </div>
+</div>
+
+<div class="grid directionRTL">
+    <div class="sixRowsAndSixColumns"
+        data-offset-x="-85" data-offset-y="15" data-expected-width="900" data-expected-height="600">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 3 / auto; -webkit-grid-row: 3 / auto;"
+        data-offset-x="0" data-offset-y="515" data-expected-width="115" data-expected-height="115">
+    </div>
+</div>
+
+<div class="grid directionRTL">
+    <div class="sixRowsAndSixColumns"
+        data-offset-x="-85" data-offset-y="15" data-expected-width="900" data-expected-height="600">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 2 / auto; -webkit-grid-row: 2 / auto;"
+        data-offset-x="0" data-offset-y="265" data-expected-width="415" data-expected-height="365">
+    </div>
+</div>
+
+<div class="grid directionRTL">
+    <div class="sixRowsAndSixColumns"
+        data-offset-x="-85" data-offset-y="15" data-expected-width="900" data-expected-height="600">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: -4 / 1; -webkit-grid-row: -4 / 1;"
+        data-offset-x="615" data-offset-y="0" data-expected-width="215" data-expected-height="115">
+    </div>
+</div>
+
+<div class="grid directionRTL">
+    <div class="sixRowsAndSixColumns"
+        data-offset-x="-85" data-offset-y="15" data-expected-width="900" data-expected-height="600">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: -4 / 2; -webkit-grid-row: -4 / 2;"
+        data-offset-x="415" data-offset-y="0" data-expected-width="415" data-expected-height="265">
+    </div>
+</div>
+
+<div class="grid directionRTL">
+    <div class="sixRowsAndSixColumns"
+        data-offset-x="-85" data-offset-y="15" data-expected-width="900" data-expected-height="600">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 3 / 4; -webkit-grid-row: 3 / 4;"
+        data-offset-x="0" data-offset-y="515" data-expected-width="115" data-expected-height="115">
+    </div>
+</div>
+
+<div class="grid directionRTL">
+    <div class="sixRowsAndSixColumns"
+        data-offset-x="-85" data-offset-y="15" data-expected-width="900" data-expected-height="600">
+    </div>
+    <div class="absolute" style="-webkit-grid-column: 2 / 4; -webkit-grid-row: 2 / 4;"
+        data-offset-x="0" data-offset-y="265" data-expected-width="415" data-expected-height="365">
+    </div>
+</div>
+
 </body>

Modified: trunk/LayoutTests/fast/css-grid-layout/grid-sizing-positioned-items-expected.txt (199097 => 199098)


--- trunk/LayoutTests/fast/css-grid-layout/grid-sizing-positioned-items-expected.txt	2016-04-06 09:27:22 UTC (rev 199097)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-sizing-positioned-items-expected.txt	2016-04-06 10:21:59 UTC (rev 199098)
@@ -7,3 +7,4 @@
 PASS
 PASS
 PASS
+PASS

Modified: trunk/LayoutTests/fast/css-grid-layout/grid-sizing-positioned-items.html (199097 => 199098)


--- trunk/LayoutTests/fast/css-grid-layout/grid-sizing-positioned-items.html	2016-04-06 09:27:22 UTC (rev 199097)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-sizing-positioned-items.html	2016-04-06 10:21:59 UTC (rev 199098)
@@ -161,4 +161,21 @@
     </div>
 </div>
 
+<div class="unconstrainedContainer">
+    <div class="grid directionRTL">
+        <div class="absolute autoRowAutoColumn offsets"
+            data-offset-x="5" data-offset-y="15" data-expected-width="1015" data-expected-height="995">
+        </div>
+        <div class="absolute secondRowSecondColumn offsets"
+            data-offset-x="5" data-offset-y="80" data-expected-width="900" data-expected-height="930">
+        </div>
+        <div class="absolute onlyFirstRowOnlyFirstColumn offsets"
+            data-offset-x="920" data-offset-y="30" data-expected-width="85" data-expected-height="15">
+        </div>
+        <div class="absolute endSecondRowEndSecondColumn offsets"
+            data-offset-x="720" data-offset-y="15" data-expected-width="300" data-expected-height="180">
+        </div>
+    </div>
+</div>
+
 </body>

Modified: trunk/Source/WebCore/ChangeLog (199097 => 199098)


--- trunk/Source/WebCore/ChangeLog	2016-04-06 09:27:22 UTC (rev 199097)
+++ trunk/Source/WebCore/ChangeLog	2016-04-06 10:21:59 UTC (rev 199098)
@@ -1,3 +1,32 @@
+2016-04-06  Manuel Rego Casasnovas  <[email protected]>
+
+        [css-grid] Fix positioned children in RTL
+        https://bugs.webkit.org/show_bug.cgi?id=156162
+
+        Reviewed by Sergio Villar Senin.
+
+        This patch fixes a problem affecting the items without
+        a static inline position (i.e. "left" and/or "right" properties
+        are not "auto"). In this particular case we need to compute
+        the "offset" from the left, so we need a specific condition
+        and computation.
+
+        Let's use an example to understand what it's fixing:
+        <div style="display: grid; grid-template-columns: 100px 50px; width: 300px;
+                    position: relative; direction: rtl;">
+            <div style="position: absolute; left: 0; grid-column: 1 / 2;">item</div>
+        </div>
+
+        In this case the item has to be placed in the first column
+        (the one on the right as we're in RTL).
+        For this we need to calculate the offset from the left, which is 200px:
+        150px (alignment offset) + 50px (offset from line 3 to 2).
+
+        Test: fast/css-grid-layout/grid-positioned-items-background-rtl.html
+
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::offsetAndBreadthForPositionedChild):
+
 2016-04-06  Antti Koivisto  <[email protected]>
 
         ComposedTreeIterator may crash when first child of shadow root is a comment node

Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (199097 => 199098)


--- trunk/Source/WebCore/rendering/RenderGrid.cpp	2016-04-06 09:27:22 UTC (rev 199097)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp	2016-04-06 10:21:59 UTC (rev 199098)
@@ -1537,6 +1537,18 @@
     breadth = end - start;
     offset = start;
 
+    if (isRowAxis && !style().isLeftToRightDirection() && !child.style().hasStaticInlinePosition(child.isHorizontalWritingMode())) {
+        // If the child doesn't have a static inline position (i.e. "left" and/or "right" aren't "auto",
+        // we need to calculate the offset from the left (even if we're in RTL).
+        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;
+        }
+    }
+
     if (child.parent() == this && !startIsAuto) {
         // If column/row start is "auto" the static position has been already set in prepareChildForPositionedLayout().
         RenderLayer* childLayer = child.layer();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to