<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[183399] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/183399">183399</a></dd>
<dt>Author</dt> <dd>jfernandez@igalia.com</dd>
<dt>Date</dt> <dd>2015-04-27 10:24:44 -0700 (Mon, 27 Apr 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[CSS Grid Layout] Support for the justify-self and justify-items in grid layout
https://bugs.webkit.org/show_bug.cgi?id=133280

Source/WebCore:

Reviewed by David Hyatt.

Implementation of justify-self and justify-items properties for grid. It supports
different writing-modes and direction. Margins, borders and paddings are also
considered when computing the final position and stretched size.

This patch applies also a quite important refactoring of the alignment logic in
order to share code between the two alignment dimensions, row-axis and column-axis.

Overflow handling is still missing and will be added later in a follow-up bug.

Tests: fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-lr.html
       fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-rl.html
       fast/css-grid-layout/grid-align-justify-margin-border-padding.html
       fast/css-grid-layout/justify-self-cell.html

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::layoutGridItems):
(WebCore::RenderGrid::columnAxisPositionForChild):
(WebCore::RenderGrid::rowAxisPositionForChild):
(WebCore::RenderGrid::rowPositionForChild):
(WebCore::RenderGrid::columnPositionForChild):
(WebCore::RenderGrid::findChildLogicalPosition):
(WebCore::RenderGrid::allowedToStretchLogicalHeightForChild): Deleted.
(WebCore::RenderGrid::needToStretchChildLogicalHeight): Deleted.
(WebCore::RenderGrid::marginLogicalHeightForChild): Deleted.
(WebCore::RenderGrid::availableAlignmentSpaceForChildBeforeStretching): Deleted.
(WebCore::RenderGrid::applyStretchAlignmentToChildIfNeeded): Deleted.
* rendering/RenderGrid.h:
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::resolveJustification):
* rendering/style/RenderStyle.h:

LayoutTests:

Implementation of justify-self and justify-items properties for grid.
Added additional testing for ensuring margin, padding and border are considered when
computing grid item's position.

Reviewed by David Hyatt.

* fast/css-grid-layout/grid-align-justify-margin-border-padding-expected.txt: Added.
* fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-lr-expected.txt: Added.
* fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-lr.html: Added.
* fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-rl-expected.txt: Added.
* fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-rl.html: Added.
* fast/css-grid-layout/grid-align-justify-margin-border-padding.html: Added.
* fast/css-grid-layout/justify-self-cell-expected.txt: Added.
* fast/css-grid-layout/justify-self-cell.html: Added.
* fast/css-grid-layout/resources/grid.css:
(.directionLTR): Added. Useful for defining orthogonal flows.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastcssgridlayoutresourcesgridcss">trunk/LayoutTests/fast/css-grid-layout/resources/grid.css</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderGridcpp">trunk/Source/WebCore/rendering/RenderGrid.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderGridh">trunk/Source/WebCore/rendering/RenderGrid.h</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleRenderStylecpp">trunk/Source/WebCore/rendering/style/RenderStyle.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleRenderStyleh">trunk/Source/WebCore/rendering/style/RenderStyle.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastcssgridlayoutgridalignjustifymarginborderpaddingexpectedtxt">trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcssgridlayoutgridalignjustifymarginborderpaddingverticallrexpectedtxt">trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-lr-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcssgridlayoutgridalignjustifymarginborderpaddingverticallrhtml">trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-lr.html</a></li>
<li><a href="#trunkLayoutTestsfastcssgridlayoutgridalignjustifymarginborderpaddingverticalrlexpectedtxt">trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-rl-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcssgridlayoutgridalignjustifymarginborderpaddingverticalrlhtml">trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-rl.html</a></li>
<li><a href="#trunkLayoutTestsfastcssgridlayoutgridalignjustifymarginborderpaddinghtml">trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding.html</a></li>
<li><a href="#trunkLayoutTestsfastcssgridlayoutjustifyselfcellexpectedtxt">trunk/LayoutTests/fast/css-grid-layout/justify-self-cell-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcssgridlayoutjustifyselfcellhtml">trunk/LayoutTests/fast/css-grid-layout/justify-self-cell.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (183398 => 183399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-04-27 17:07:20 UTC (rev 183398)
+++ trunk/LayoutTests/ChangeLog        2015-04-27 17:24:44 UTC (rev 183399)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2015-04-27  Javier Fernandez  &lt;jfernandez@igalia.com&gt;
+
+        [CSS Grid Layout] Support for the justify-self and justify-items in grid layout
+        https://bugs.webkit.org/show_bug.cgi?id=133280
+
+        Implementation of justify-self and justify-items properties for grid.
+        Added additional testing for ensuring margin, padding and border are considered when
+        computing grid item's position.
+
+        Reviewed by David Hyatt.
+
+        * fast/css-grid-layout/grid-align-justify-margin-border-padding-expected.txt: Added.
+        * fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-lr-expected.txt: Added.
+        * fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-lr.html: Added.
+        * fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-rl-expected.txt: Added.
+        * fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-rl.html: Added.
+        * fast/css-grid-layout/grid-align-justify-margin-border-padding.html: Added.
+        * fast/css-grid-layout/justify-self-cell-expected.txt: Added.
+        * fast/css-grid-layout/justify-self-cell.html: Added.
+        * fast/css-grid-layout/resources/grid.css:
+        (.directionLTR): Added. Useful for defining orthogonal flows.
+
</ins><span class="cx"> 2015-04-27  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt; and Xabier Rodriguez Calvar  &lt;calvaris@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed.
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssgridlayoutgridalignjustifymarginborderpaddingexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-expected.txt (0 => 183399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-expected.txt        2015-04-27 17:24:44 UTC (rev 183399)
</span><span class="lines">@@ -0,0 +1,74 @@
</span><ins>+This test checks that the 'margin', 'border' and 'padding' properties are applied together correctly for 'align' and 'justify' properties.
+
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR | align-items: 'auto' | justify-items: 'auto'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR | align-items: 'center' | justify-items: 'center'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR | align-items: 'end' | justify-items: 'end'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR | align-items: 'left' | justify-items: 'left'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR | align-items: 'right' | justify-items: 'right'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR (ortho) | align-items: 'self-start' | justify-items: 'self-start'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR (ortho) | align-items: 'self-end' | justify-items: 'self-end'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR (parall) | align-items: 'self-start' | justify-items: 'self-start'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR - (parall) | align-items: 'self-end' | justify-items: 'self-end'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL | align-items: 'auto' | justify-items: 'auto'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL | align-items: 'center' | justify-items: 'center'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL | align-items: 'end' | justify-items: 'end'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL | align-items: 'left' | justify-items: 'left'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL | align-items: 'right' | justify-items: 'right'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL (ortho) | align-items: 'self-start' | justify-items: 'self-start'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL (ortho) | align-items: 'self-end' | justify-items: 'self-end'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL (parall) | align-items: 'self-start' | justify-items: 'self-start'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL (parall) | align-items: 'self-end' | justify-items: 'self-end'
+
+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssgridlayoutgridalignjustifymarginborderpaddingverticallrexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-lr-expected.txt (0 => 183399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-lr-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-lr-expected.txt        2015-04-27 17:24:44 UTC (rev 183399)
</span><span class="lines">@@ -0,0 +1,74 @@
</span><ins>+This test checks that the 'margin', 'border' and 'padding' properties are applied together correctly for 'align' and 'justify' properties on vertical-LR grids.
+
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR | align-items: 'auto' | justify-items: 'auto'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR | align-items: 'center' | justify-items: 'center'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR | align-items: 'end' | justify-items: 'end'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR | align-items: 'left' | justify-items: 'left'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR | align-items: 'right' | justify-items: 'right'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR (ortho) | align-items: 'self-start' | justify-items: 'self-start'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR (ortho) | align-items: 'self-end' | justify-items: 'self-end'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR (parall) | align-items: 'self-start' | justify-items: 'self-start'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR (parall) | align-items: 'self-end' | justify-items: 'self-end'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL | align-items: 'auto' | justify-items: 'auto'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL | align-items: 'center' | justify-items: 'center'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL | align-items: 'end' | justify-items: 'end'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL | align-items: 'left' | justify-items: 'left'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL | align-items: 'right' | justify-items: 'right'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL (ortho) | align-items: 'self-start' | justify-items: 'self-start'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL (ortho) | align-items: 'self-end' | justify-items: 'self-end'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL (parall) | align-items: 'self-start' | justify-items: 'self-start'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL (parall) | align-items: 'self-end' | justify-items: 'self-end'
+
+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssgridlayoutgridalignjustifymarginborderpaddingverticallrhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-lr.html (0 => 183399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-lr.html                                (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-lr.html        2015-04-27 17:24:44 UTC (rev 183399)
</span><span class="lines">@@ -0,0 +1,269 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;link href=&quot;resources/grid.css&quot; rel=&quot;stylesheet&quot;&gt;
+&lt;script src=&quot;../../resources/check-layout.js&quot;&gt;&lt;/script&gt;
+&lt;style&gt;
+body {
+    margin: 0;
+}
+
+.grid {
+    -webkit-grid-template-columns: 100px 200px;
+    -webkit-grid-template-rows: 200px 200px;
+    padding: 10px 15px 20px 30px;
+    border-width: 5px 10px 15px 20px;
+    border-style: dotted;
+    border-color: blue;
+    width: -webkit-fit-content;
+    position: relative;
+}
+
+.cell {
+    width: 20px;
+    height: 40px;
+    margin: 4px 8px 12px 16px;
+}
+
+.itemsCenter {
+    align-items: center;
+    justify-items: center;
+}
+
+.itemsEnd {
+    align-items: end;
+    justify-items: end;
+}
+
+.itemsLeft {
+    align-items: left;
+    justify-items: left;
+}
+
+.itemsRight {
+    align-items: right;
+    justify-items: right;
+}
+
+.itemsSelfStart {
+    align-items: self-start;
+    justify-items: self-start;
+}
+
+.itemsSelfEnd {
+    align-items: self-end;
+    justify-items: self-end;
+}
+
+.stretch {
+    align-self: stretch;
+    justify-self: stretch;
+}
+
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;checkLayout('.grid')&quot;&gt;
+
+&lt;p&gt;This test checks that the 'margin', 'border' and 'padding' properties are applied together correctly for 'align' and 'justify' properties on vertical-LR grids.&lt;/p&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR | align-items: 'auto' | justify-items: 'auto'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalLR&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;   data-offset-x=&quot;46&quot;  data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell firstRowSecondColumn&quot;  data-offset-x=&quot;46&quot;  data-offset-y=&quot;114&quot; data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowFirstColumn&quot;  data-offset-x=&quot;246&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot; data-offset-x=&quot;246&quot; data-offset-y=&quot;114&quot; data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR | align-items: 'center' | justify-items: 'center'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalLR itemsCenter&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;firstRowFirstColumn cell&quot;     data-offset-x=&quot;124&quot;  data-offset-y=&quot;36&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;   data-offset-y=&quot;110&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;324&quot;  data-offset-y=&quot;186&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR | align-items: 'end' | justify-items: 'end'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalLR itemsEnd&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;202&quot; data-offset-y=&quot;58&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;110&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;402&quot; data-offset-y=&quot;258&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR | align-items: 'left' | justify-items: 'left'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalLR itemsLeft&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;46&quot;  data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;110&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;246&quot; data-offset-y=&quot;114&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR | align-items: 'right' | justify-items: 'right'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalLR itemsRight&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;46&quot;  data-offset-y=&quot;58&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;110&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;246&quot; data-offset-y=&quot;258&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR (ortho) | align-items: 'self-start' | justify-items: 'self-start'&lt;/p&gt;
+    &lt;div class=&quot;grid directionLTR verticalLR itemsSelfStart&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;directionRTL cell firstRowFirstColumn&quot;     data-offset-x=&quot;46&quot;  data-offset-y=&quot;58&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;110&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL cell secondRowSecondColumn&quot;   data-offset-x=&quot;246&quot; data-offset-y=&quot;258&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR (ortho) | align-items: 'self-end' | justify-items: 'self-end'&lt;/p&gt;
+    &lt;div class=&quot;grid directionLTR verticalLR itemsSelfEnd&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;directionRTL cell firstRowFirstColumn&quot;     data-offset-x=&quot;202&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;110&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL cell secondRowSecondColumn&quot;   data-offset-x=&quot;402&quot; data-offset-y=&quot;114&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR (parall) | align-items: 'self-start' | justify-items: 'self-start'&lt;/p&gt;
+    &lt;div class=&quot;grid directionLTR verticalLR itemsSelfStart&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;directionLTR cell firstRowFirstColumn&quot;     data-offset-x=&quot;46&quot;  data-offset-y=&quot;14&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;110&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR cell secondRowSecondColumn&quot;   data-offset-x=&quot;246&quot; data-offset-y=&quot;114&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR (parall) | align-items: 'self-end' | justify-items: 'self-end'&lt;/p&gt;
+    &lt;div class=&quot;grid directionLTR verticalLR itemsSelfEnd&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;directionLTR cell firstRowFirstColumn&quot;     data-offset-x=&quot;202&quot; data-offset-y=&quot;58&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;110&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR cell secondRowSecondColumn&quot;   data-offset-x=&quot;402&quot; data-offset-y=&quot;258&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;!-- RTL direction. --&gt;
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL | align-items: 'auto' | justify-items: 'auto'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalLR directionRTL&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;   data-offset-x=&quot;46&quot;  data-offset-y=&quot;258&quot; data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell firstRowSecondColumn&quot;  data-offset-x=&quot;46&quot;  data-offset-y=&quot;158&quot; data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowFirstColumn&quot;  data-offset-x=&quot;246&quot; data-offset-y=&quot;258&quot; data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot; data-offset-x=&quot;246&quot; data-offset-y=&quot;158&quot; data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL | align-items: 'center' | justify-items: 'center'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalLR directionRTL itemsCenter&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;124&quot; data-offset-y=&quot;236&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;210&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;324&quot; data-offset-y=&quot;86&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL | align-items: 'end' | justify-items: 'end'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalLR directionRTL itemsEnd&quot;       data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;202&quot; data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;210&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;402&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL | align-items: 'left' | justify-items: 'left'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalLR directionRTL itemsLeft&quot;      data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;46&quot;  data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;210&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;246&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL | align-items: 'right' | justify-items: 'right'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalLR directionRTL itemsRight&quot;     data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;46&quot;  data-offset-y=&quot;258&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;210&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;246&quot; data-offset-y=&quot;158&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL (ortho) | align-items: 'self-start' | justify-items: 'self-start'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalLR directionRTL itemsSelfStart&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;directionLTR cell firstRowFirstColumn&quot;     data-offset-x=&quot;46&quot;  data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;210&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR cell secondRowSecondColumn&quot;   data-offset-x=&quot;246&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL (ortho) | align-items: 'self-end' | justify-items: 'self-end'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalLR directionRTL itemsSelfEnd&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;directionLTR cell firstRowFirstColumn&quot;     data-offset-x=&quot;202&quot; data-offset-y=&quot;258&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;210&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR cell secondRowSecondColumn&quot;   data-offset-x=&quot;402&quot; data-offset-y=&quot;158&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL (parall) | align-items: 'self-start' | justify-items: 'self-start'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalLR directionRTL itemsSelfStart&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;directionRTL cell firstRowFirstColumn&quot;     data-offset-x=&quot;46&quot;  data-offset-y=&quot;258&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;210&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL cell secondRowSecondColumn&quot;   data-offset-x=&quot;246&quot; data-offset-y=&quot;158&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL (parall) | align-items: 'self-end' | justify-items: 'self-end'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalLR directionRTL itemsSelfEnd&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;directionRTL cell firstRowFirstColumn&quot;     data-offset-x=&quot;202&quot; data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;210&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL cell secondRowSecondColumn&quot;   data-offset-x=&quot;402&quot; data-offset-y=&quot;14&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssgridlayoutgridalignjustifymarginborderpaddingverticalrlexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-rl-expected.txt (0 => 183399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-rl-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-rl-expected.txt        2015-04-27 17:24:44 UTC (rev 183399)
</span><span class="lines">@@ -0,0 +1,74 @@
</span><ins>+This test checks that the 'margin', 'border' and 'padding' properties are applied together correctly for 'align' and 'justify' properties on vertical-RL grids.
+
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR | align-items: 'auto' | justify-items: 'auto'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR | align-items: 'center' | justify-items: 'center'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR | align-items: 'end' | justify-items: 'end'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR | align-items: 'left' | justify-items: 'left'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR | align-items: 'right' | justify-items: 'right'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR (ortho) | align-items: 'self-start' | justify-items: 'self-start'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR (ortho) | align-items: 'self-end' | justify-items: 'self-end'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR (parall) | align-items: 'self-start' | justify-items: 'self-start'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: LTR (parall) | align-items: 'self-end' | justify-items: 'self-end'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL | align-items: 'auto' | justify-items: 'auto'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL | align-items: 'center' | justify-items: 'center'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL | align-items: 'end' | justify-items: 'end'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL | align-items: 'left' | justify-items: 'left'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL | align-items: 'right' | justify-items: 'right'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL (ortho) | align-items: 'self-start' | justify-items: 'self-start'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL (ortho) | align-items: 'self-end' | justify-items: 'self-end'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL (parall) | align-items: 'self-start' | justify-items: 'self-start'
+
+PASS
+border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px
+direction: RTL (parall) | align-items: 'self-end' | justify-items: 'self-end'
+
+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssgridlayoutgridalignjustifymarginborderpaddingverticalrlhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-rl.html (0 => 183399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-rl.html                                (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-rl.html        2015-04-27 17:24:44 UTC (rev 183399)
</span><span class="lines">@@ -0,0 +1,270 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;link href=&quot;resources/grid.css&quot; rel=&quot;stylesheet&quot;&gt;
+&lt;script src=&quot;../../resources/check-layout.js&quot;&gt;&lt;/script&gt;
+&lt;style&gt;
+body {
+    margin: 0;
+}
+
+.grid {
+    -webkit-grid-template-columns: 100px 200px;
+    -webkit-grid-template-rows: 200px 200px;
+    padding: 10px 15px 20px 30px;
+    border-width: 5px 10px 15px 20px;
+    border-style: dotted;
+    border-color: blue;
+    width: -webkit-fit-content;
+    position: relative;
+}
+
+.cell {
+    width: 20px;
+    height: 40px;
+    margin: 4px 8px 12px 16px;
+}
+
+.itemsCenter {
+    align-items: center;
+    justify-items: center;
+}
+
+.itemsEnd {
+    align-items: end;
+    justify-items: end;
+}
+
+.itemsLeft {
+    align-items: left;
+    justify-items: left;
+}
+
+.itemsRight {
+    align-items: right;
+    justify-items: right;
+}
+
+.itemsSelfStart {
+    align-items: self-start;
+    justify-items: self-start;
+}
+
+.itemsSelfEnd {
+    align-items: self-end;
+    justify-items: self-end;
+}
+
+.stretch {
+    align-self: stretch;
+    justify-self: stretch;
+}
+
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;checkLayout('.grid')&quot;&gt;
+
+&lt;p&gt;This test checks that the 'margin', 'border' and 'padding' properties are applied together correctly for 'align' and 'justify' properties on vertical-RL grids.&lt;/p&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR | align-items: 'auto' | justify-items: 'auto'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalRL&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;   data-offset-x=&quot;402&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell firstRowSecondColumn&quot;  data-offset-x=&quot;402&quot; data-offset-y=&quot;114&quot; data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowFirstColumn&quot;  data-offset-x=&quot;202&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot; data-offset-x=&quot;202&quot; data-offset-y=&quot;114&quot; data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR | align-items: 'center' | justify-items: 'center'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalRL itemsCenter&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;firstRowFirstColumn cell&quot;     data-offset-x=&quot;324&quot; data-offset-y=&quot;36&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;110&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;124&quot; data-offset-y=&quot;186&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR | align-items: 'end' | justify-items: 'end'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalRL itemsEnd&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;246&quot; data-offset-y=&quot;58&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;110&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;46&quot;  data-offset-y=&quot;258&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR | align-items: 'left' | justify-items: 'left'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalRL itemsLeft&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;402&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;110&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;202&quot; data-offset-y=&quot;114&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR | align-items: 'right' | justify-items: 'right'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalRL itemsRight&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;402&quot; data-offset-y=&quot;58&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;110&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;202&quot; data-offset-y=&quot;258&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR (ortho) | align-items: 'self-start' | justify-items: 'self-start'&lt;/p&gt;
+    &lt;div class=&quot;grid directionLTR verticalRL itemsSelfStart&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;directionRTL cell firstRowFirstColumn&quot;     data-offset-x=&quot;402&quot; data-offset-y=&quot;58&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch firstRowSecondColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;110&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL cell secondRowSecondColumn&quot;   data-offset-x=&quot;202&quot; data-offset-y=&quot;258&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR (ortho) | align-items: 'self-end' | justify-items: 'self-end'&lt;/p&gt;
+    &lt;div class=&quot;grid directionLTR verticalRL itemsSelfEnd&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;directionRTL cell firstRowFirstColumn&quot;     data-offset-x=&quot;246&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch firstRowSecondColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;110&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL cell secondRowSecondColumn&quot;   data-offset-x=&quot;46&quot;  data-offset-y=&quot;114&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR (parall) | align-items: 'self-start' | justify-items: 'self-start'&lt;/p&gt;
+    &lt;div class=&quot;grid directionLTR verticalRL itemsSelfStart&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;directionLTR cell firstRowFirstColumn&quot;     data-offset-x=&quot;402&quot; data-offset-y=&quot;14&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch firstRowSecondColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;110&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR cell secondRowSecondColumn&quot;   data-offset-x=&quot;202&quot; data-offset-y=&quot;114&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR (parall) | align-items: 'self-end' | justify-items: 'self-end'&lt;/p&gt;
+    &lt;div class=&quot;grid directionLTR verticalRL itemsSelfEnd&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;directionLTR cell firstRowFirstColumn&quot;     data-offset-x=&quot;246&quot; data-offset-y=&quot;58&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch firstRowSecondColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;110&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR cell secondRowSecondColumn&quot;   data-offset-x=&quot;46&quot;  data-offset-y=&quot;258&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+
+&lt;!-- RTL direction. --&gt;
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL | align-items: 'auto' | justify-items: 'auto'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalRL directionRTL&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;   data-offset-x=&quot;402&quot; data-offset-y=&quot;258&quot; data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell firstRowSecondColumn&quot;  data-offset-x=&quot;402&quot; data-offset-y=&quot;158&quot; data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowFirstColumn&quot;  data-offset-x=&quot;202&quot; data-offset-y=&quot;258&quot; data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot; data-offset-x=&quot;202&quot; data-offset-y=&quot;158&quot; data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL | align-items: 'center' | justify-items: 'center'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalRL directionRTL itemsCenter&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;324&quot; data-offset-y=&quot;236&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;210&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;124&quot; data-offset-y=&quot;86&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL | align-items: 'end' | justify-items: 'end'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalRL directionRTL itemsEnd&quot;       data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;246&quot; data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;210&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;46&quot;  data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL | align-items: 'left' | justify-items: 'left'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalRL directionRTL itemsLeft&quot;      data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;402&quot; data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;210&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;202&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL | align-items: 'right' | justify-items: 'right'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalRL directionRTL itemsRight&quot;     data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;402&quot; data-offset-y=&quot;258&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;210&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;202&quot; data-offset-y=&quot;158&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL (ortho) | align-items: 'self-start' | justify-items: 'self-start'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalRL directionRTL itemsSelfStart&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;directionLTR cell firstRowFirstColumn&quot;     data-offset-x=&quot;402&quot; data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch firstRowSecondColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;210&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR cell secondRowSecondColumn&quot;   data-offset-x=&quot;202&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL (ortho) | align-items: 'self-end' | justify-items: 'self-end'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalRL directionRTL itemsSelfEnd&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;directionLTR cell firstRowFirstColumn&quot;     data-offset-x=&quot;246&quot; data-offset-y=&quot;258&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch firstRowSecondColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;210&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR cell secondRowSecondColumn&quot;   data-offset-x=&quot;46&quot;  data-offset-y=&quot;158&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL (parall) | align-items: 'self-start' | justify-items: 'self-start'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalRL directionRTL itemsSelfStart&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;directionRTL cell firstRowFirstColumn&quot;     data-offset-x=&quot;402&quot; data-offset-y=&quot;258&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch firstRowSecondColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;210&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL cell secondRowSecondColumn&quot;   data-offset-x=&quot;202&quot; data-offset-y=&quot;158&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL (parall) | align-items: 'self-end' | justify-items: 'self-end'&lt;/p&gt;
+    &lt;div class=&quot;grid verticalRL directionRTL itemsSelfEnd&quot; data-expected-width=&quot;475&quot; data-expected-height=&quot;350&quot;&gt;
+        &lt;div class=&quot;directionRTL cell firstRowFirstColumn&quot;     data-offset-x=&quot;246&quot; data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch firstRowSecondColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;210&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL cell secondRowSecondColumn&quot;   data-offset-x=&quot;46&quot;  data-offset-y=&quot;14&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssgridlayoutgridalignjustifymarginborderpaddinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding.html (0 => 183399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding.html                                (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-align-justify-margin-border-padding.html        2015-04-27 17:24:44 UTC (rev 183399)
</span><span class="lines">@@ -0,0 +1,269 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;link href=&quot;resources/grid.css&quot; rel=&quot;stylesheet&quot;&gt;
+&lt;script src=&quot;../../resources/check-layout.js&quot;&gt;&lt;/script&gt;
+&lt;style&gt;
+body {
+    margin: 0;
+}
+
+.grid {
+    -webkit-grid-template-columns: 100px 200px;
+    -webkit-grid-template-rows: 200px 200px;
+    padding: 10px 15px 20px 30px;
+    border-width: 5px 10px 15px 20px;
+    border-style: dotted;
+    border-color: blue;
+    width: -webkit-fit-content;
+    position: relative;
+}
+
+.cell {
+    width: 20px;
+    height: 40px;
+    margin: 4px 8px 12px 16px;
+}
+
+.itemsCenter {
+    align-items: center;
+    justify-items: center;
+}
+
+.itemsEnd {
+    align-items: end;
+    justify-items: end;
+}
+
+.itemsLeft {
+    align-items: left;
+    justify-items: left;
+}
+
+.itemsRight {
+    align-items: right;
+    justify-items: right;
+}
+
+.itemsSelfStart {
+    align-items: self-start;
+    justify-items: self-start;
+}
+
+.itemsSelfEnd {
+    align-items: self-end;
+    justify-items: self-end;
+}
+
+.stretch {
+    align-self: stretch;
+    justify-self: stretch;
+}
+
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;checkLayout('.grid')&quot;&gt;
+
+&lt;p&gt;This test checks that the 'margin', 'border' and 'padding' properties are applied together correctly for 'align' and 'justify' properties.&lt;/p&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR | align-items: 'auto' | justify-items: 'auto'&lt;/p&gt;
+    &lt;div class=&quot;grid&quot; data-expected-width=&quot;375&quot; data-expected-height=&quot;450&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;   data-offset-x=&quot;46&quot;  data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell firstRowSecondColumn&quot;  data-offset-x=&quot;146&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowFirstColumn&quot;  data-offset-x=&quot;46&quot;  data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot; data-offset-x=&quot;146&quot; data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR | align-items: 'center' | justify-items: 'center'&lt;/p&gt;
+    &lt;div class=&quot;grid itemsCenter&quot; data-expected-width=&quot;375&quot; data-expected-height=&quot;450&quot;&gt;
+        &lt;div class=&quot;firstRowFirstColumn cell&quot;     data-offset-x=&quot;74&quot;  data-offset-y=&quot;86&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;130&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;210&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;224&quot; data-offset-y=&quot;286&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR | align-items: 'end' | justify-items: 'end'&lt;/p&gt;
+    &lt;div class=&quot;grid itemsEnd&quot; data-expected-width=&quot;375&quot; data-expected-height=&quot;450&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;102&quot; data-offset-y=&quot;158&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;130&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;210&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;302&quot; data-offset-y=&quot;358&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR | align-items: 'left' | justify-items: 'left'&lt;/p&gt;
+    &lt;div class=&quot;grid itemsLeft&quot; data-expected-width=&quot;375&quot; data-expected-height=&quot;450&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;46&quot;  data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;130&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;210&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;146&quot; data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR | align-items: 'right' | justify-items: 'right'&lt;/p&gt;
+    &lt;div class=&quot;grid itemsRight&quot; data-expected-width=&quot;375&quot; data-expected-height=&quot;450&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;102&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;130&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;210&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;302&quot; data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR (ortho) | align-items: 'self-start' | justify-items: 'self-start'&lt;/p&gt;
+    &lt;div class=&quot;grid directionLTR itemsSelfStart&quot; data-expected-width=&quot;375&quot; data-expected-height=&quot;450&quot;&gt;
+        &lt;div class=&quot;directionRTL cell firstRowFirstColumn&quot;     data-offset-x=&quot;102&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch firstRowSecondColumn&quot; data-offset-x=&quot;130&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;210&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL cell secondRowSecondColumn&quot;   data-offset-x=&quot;302&quot; data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR (ortho) | align-items: 'self-end' | justify-items: 'self-end'&lt;/p&gt;
+    &lt;div class=&quot;grid directionLTR itemsSelfEnd&quot; data-expected-width=&quot;375&quot; data-expected-height=&quot;450&quot;&gt;
+        &lt;div class=&quot;directionRTL cell firstRowFirstColumn&quot;     data-offset-x=&quot;46&quot;  data-offset-y=&quot;158&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch firstRowSecondColumn&quot; data-offset-x=&quot;130&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;210&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL cell secondRowSecondColumn&quot;   data-offset-x=&quot;146&quot; data-offset-y=&quot;358&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR (parall) | align-items: 'self-start' | justify-items: 'self-start'&lt;/p&gt;
+    &lt;div class=&quot;grid directionLTR itemsSelfStart&quot; data-expected-width=&quot;375&quot; data-expected-height=&quot;450&quot;&gt;
+        &lt;div class=&quot;directionLTR cell firstRowFirstColumn&quot;     data-offset-x=&quot;46&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch firstRowSecondColumn&quot; data-offset-x=&quot;130&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;210&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR cell secondRowSecondColumn&quot;   data-offset-x=&quot;146&quot; data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: LTR - (parall) | align-items: 'self-end' | justify-items: 'self-end'&lt;/p&gt;
+    &lt;div class=&quot;grid directionLTR itemsSelfEnd&quot; data-expected-width=&quot;375&quot; data-expected-height=&quot;450&quot;&gt;
+        &lt;div class=&quot;directionLTR cell firstRowFirstColumn&quot;     data-offset-x=&quot;102&quot;  data-offset-y=&quot;158&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch firstRowSecondColumn&quot; data-offset-x=&quot;130&quot; data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch secondRowFirstColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;210&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR cell secondRowSecondColumn&quot;   data-offset-x=&quot;302&quot; data-offset-y=&quot;358&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;!-- RTL direction. --&gt;
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL | align-items: 'auto' | justify-items: 'auto'&lt;/p&gt;
+    &lt;div class=&quot;grid directionRTL&quot; data-expected-width=&quot;375&quot; data-expected-height=&quot;450&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;   data-offset-x=&quot;302&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell firstRowSecondColumn&quot;  data-offset-x=&quot;202&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowFirstColumn&quot;  data-offset-x=&quot;302&quot; data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot; data-offset-x=&quot;202&quot; data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot; data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL | align-items: 'center' | justify-items: 'center'&lt;/p&gt;
+    &lt;div class=&quot;grid directionRTL itemsCenter&quot; data-expected-width=&quot;375&quot; data-expected-height=&quot;450&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;274&quot; data-offset-y=&quot;86&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;210&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;124&quot; data-offset-y=&quot;286&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL | align-items: 'end' | justify-items: 'end'&lt;/p&gt;
+    &lt;div class=&quot;grid directionRTL itemsEnd&quot;       data-expected-width=&quot;375&quot; data-expected-height=&quot;450&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;246&quot; data-offset-y=&quot;158&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;210&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;46&quot;  data-offset-y=&quot;358&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL | align-items: 'left' | justify-items: 'left'&lt;/p&gt;
+    &lt;div class=&quot;grid directionRTL itemsLeft&quot;      data-expected-width=&quot;375&quot; data-expected-height=&quot;450&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;246&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;210&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;46&quot;  data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL | align-items: 'right' | justify-items: 'right'&lt;/p&gt;
+    &lt;div class=&quot;grid directionRTL itemsRight&quot;     data-expected-width=&quot;375&quot; data-expected-height=&quot;450&quot;&gt;
+        &lt;div class=&quot;cell firstRowFirstColumn&quot;     data-offset-x=&quot;302&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;210&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell secondRowSecondColumn&quot;   data-offset-x=&quot;202&quot; data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL (ortho) | align-items: 'self-start' | justify-items: 'self-start'&lt;/p&gt;
+    &lt;div class=&quot;grid directionRTL itemsSelfStart&quot; data-expected-width=&quot;375&quot; data-expected-height=&quot;450&quot;&gt;
+        &lt;div class=&quot;directionLTR cell firstRowFirstColumn&quot;     data-offset-x=&quot;246&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;210&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR cell secondRowSecondColumn&quot;   data-offset-x=&quot;46&quot;  data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL (ortho) | align-items: 'self-end' | justify-items: 'self-end'&lt;/p&gt;
+    &lt;div class=&quot;grid directionRTL itemsSelfEnd&quot; data-expected-width=&quot;375&quot; data-expected-height=&quot;450&quot;&gt;
+        &lt;div class=&quot;directionLTR cell firstRowFirstColumn&quot;     data-offset-x=&quot;302&quot; data-offset-y=&quot;158&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;210&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionLTR cell secondRowSecondColumn&quot;   data-offset-x=&quot;202&quot; data-offset-y=&quot;358&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL (parall) | align-items: 'self-start' | justify-items: 'self-start'&lt;/p&gt;
+    &lt;div class=&quot;grid directionRTL itemsSelfStart&quot; data-expected-width=&quot;375&quot; data-expected-height=&quot;450&quot;&gt;
+        &lt;div class=&quot;directionRTL cell firstRowFirstColumn&quot;     data-offset-x=&quot;302&quot; data-offset-y=&quot;14&quot;  data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;210&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL cell secondRowSecondColumn&quot;   data-offset-x=&quot;202&quot;  data-offset-y=&quot;214&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div&gt;
+    &lt;p&gt;border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px&lt;br&gt;
+        direction: RTL (parall) | align-items: 'self-end' | justify-items: 'self-end'&lt;/p&gt;
+    &lt;div class=&quot;grid directionRTL itemsSelfEnd&quot; data-expected-width=&quot;375&quot; data-expected-height=&quot;450&quot;&gt;
+        &lt;div class=&quot;directionRTL cell firstRowFirstColumn&quot;     data-offset-x=&quot;246&quot; data-offset-y=&quot;158&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch firstRowSecondColumn&quot; data-offset-x=&quot;30&quot;  data-offset-y=&quot;10&quot;  data-expected-width=&quot;200&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL stretch secondRowFirstColumn&quot; data-offset-x=&quot;230&quot; data-offset-y=&quot;210&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;directionRTL cell secondRowSecondColumn&quot;   data-offset-x=&quot;46&quot; data-offset-y=&quot;358&quot; data-expected-width=&quot;20&quot;  data-expected-height=&quot;40&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssgridlayoutjustifyselfcellexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css-grid-layout/justify-self-cell-expected.txt (0 => 183399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css-grid-layout/justify-self-cell-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/justify-self-cell-expected.txt        2015-04-27 17:24:44 UTC (rev 183399)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+This test checks that the justify-self property is applied correctly.
+
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssgridlayoutjustifyselfcellhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css-grid-layout/justify-self-cell.html (0 => 183399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css-grid-layout/justify-self-cell.html                                (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/justify-self-cell.html        2015-04-27 17:24:44 UTC (rev 183399)
</span><span class="lines">@@ -0,0 +1,168 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;link href=&quot;resources/grid.css&quot; rel=&quot;stylesheet&quot;&gt;
+&lt;style&gt;
+.grid {
+    -webkit-grid-template-columns: 100px 100px;
+    -webkit-grid-template-rows: 200px 200px;
+    width: -webkit-fit-content;
+}
+
+.cell {
+    width: 10px;
+    height: 20px;
+}
+
+.justifySelfAuto {
+    justify-self: auto;
+}
+
+.justifySelfStretch {
+    justify-self: stretch;
+}
+
+.justifySelfStart {
+    justify-self: start;
+}
+
+.justifySelfEnd {
+    justify-self: end;
+}
+
+.justifySelfCenter {
+    justify-self: center;
+}
+
+.justifySelfRight {
+    justify-self: right;
+}
+
+.justifySelfLeft {
+    justify-self: left;
+}
+
+.justifySelfFlexStart {
+    justify-self: flex-start;
+}
+
+.justifySelfFlexEnd {
+    justify-self: flex-end;
+}
+
+.justifySelfSelfStart {
+    justify-self: self-start;
+}
+
+.justifySelfSelfEnd {
+    justify-self: self-end;
+}
+
+.justifyItemsCenter {
+    justify-items: center;
+}
+&lt;/style&gt;
+&lt;script src=&quot;../../resources/check-layout.js&quot;&gt;&lt;/script&gt;
+&lt;body onload=&quot;checkLayout('.grid')&quot;&gt;
+
+&lt;p&gt;This test checks that the justify-self property is applied correctly.&lt;/p&gt;
+
+&lt;div style=&quot;position: relative&quot; class=&quot;constrainedContainer&quot;&gt;
+&lt;div class=&quot;grid&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;400&quot;&gt;
+    &lt;div class=&quot;justifySelfStretch firstRowFirstColumn&quot; data-offset-x=&quot;0&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfStart firstRowSecondColumn&quot; data-offset-x=&quot;100&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfEnd firstRowSecondColumn&quot; data-offset-x=&quot;190&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfCenter secondRowFirstColumn&quot; data-offset-x=&quot;45&quot; data-offset-y=&quot;200&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfRight secondRowSecondColumn&quot; data-offset-x=&quot;190&quot; data-offset-y=&quot;200&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfLeft secondRowSecondColumn&quot; data-offset-x=&quot;100&quot; data-offset-y=&quot;200&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div style=&quot;position: relative&quot; class=&quot;constrainedContainer&quot;&gt;
+&lt;div class=&quot;grid&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;400&quot;&gt;
+    &lt;div class=&quot;cell justifySelfFlexEnd firstRowFirstColumn&quot; data-offset-x=&quot;90&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfFlexStart firstRowSecondColumn&quot; data-offset-x=&quot;100&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfSelfStart secondRowFirstColumn&quot; data-offset-x=&quot;0&quot; data-offset-y=&quot;200&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfSelfEnd secondRowSecondColumn&quot; data-offset-x=&quot;190&quot; data-offset-y=&quot;200&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;!-- Default justification and initial values. --&gt;
+&lt;div style=&quot;position: relative&quot;&gt;
+    &lt;div class=&quot;grid justifyItemsCenter&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;400&quot;&gt;
+        &lt;div class=&quot;cell justifySelfAuto firstRowFirstColumn&quot; data-offset-x=&quot;45&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell firstRowSecondColumn&quot; data-offset-x=&quot;145&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell justifySelfSelfStart secondRowFirstColumn&quot; data-offset-x=&quot;0&quot; data-offset-y=&quot;200&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell justifySelfSelfEnd secondRowSecondColumn&quot; data-offset-x=&quot;190&quot; data-offset-y=&quot;200&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div style=&quot;position: relative&quot;&gt;
+    &lt;div class=&quot;grid&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;400&quot;&gt;
+        &lt;div class=&quot;justifySelfAuto firstRowFirstColumn&quot; data-offset-x=&quot;0&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell firstRowSecondColumn&quot; data-offset-x=&quot;100&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell justifySelfStart secondRowFirstColumn&quot; data-offset-x=&quot;0&quot; data-offset-y=&quot;200&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+        &lt;div class=&quot;cell justifySelfEnd secondRowSecondColumn&quot; data-offset-x=&quot;190&quot; data-offset-y=&quot;200&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;!-- Vertical writing mode. --&gt;
+&lt;div style=&quot;position: relative&quot; class=&quot;constrainedContainer&quot;&gt;
+&lt;div class=&quot;grid verticalRL&quot; data-expected-width=&quot;400&quot; data-expected-height=&quot;200&quot;&gt;
+    &lt;div class=&quot;justifySelfStretch firstRowFirstColumn&quot; data-offset-x=&quot;200&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;100&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfStart firstRowSecondColumn&quot; data-offset-x=&quot;390&quot; data-offset-y=&quot;100&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfEnd firstRowSecondColumn&quot; data-offset-x=&quot;390&quot; data-offset-y=&quot;180&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfCenter secondRowFirstColumn&quot; data-offset-x=&quot;190&quot; data-offset-y=&quot;40&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfRight secondRowSecondColumn&quot; data-offset-x=&quot;190&quot; data-offset-y=&quot;180&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfLeft secondRowSecondColumn&quot; data-offset-x=&quot;190&quot; data-offset-y=&quot;100&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div style=&quot;position: relative&quot; class=&quot;constrainedContainer&quot;&gt;
+&lt;div class=&quot;grid verticalLR&quot; data-expected-width=&quot;400&quot; data-expected-height=&quot;200&quot;&gt;
+    &lt;div class=&quot;cell justifySelfFlexEnd firstRowFirstColumn&quot; data-offset-x=&quot;0&quot; data-offset-y=&quot;80&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfFlexStart firstRowSecondColumn&quot; data-offset-x=&quot;0&quot; data-offset-y=&quot;100&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfSelfStart secondRowFirstColumn&quot; data-offset-x=&quot;200&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfSelfEnd secondRowSecondColumn&quot; data-offset-x=&quot;200&quot; data-offset-y=&quot;180&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;!-- RTL direction. --&gt;
+&lt;div style=&quot;position: relative&quot; class=&quot;constrainedContainer&quot;&gt;
+&lt;div class=&quot;grid directionRTL&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;400&quot;&gt;
+    &lt;div class=&quot;justifySelfStretch firstRowFirstColumn&quot; data-offset-x=&quot;100&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfStart firstRowSecondColumn&quot; data-offset-x=&quot;90&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfEnd firstRowSecondColumn&quot; data-offset-x=&quot;0&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfCenter secondRowFirstColumn&quot; data-offset-x=&quot;145&quot; data-offset-y=&quot;200&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfRight secondRowSecondColumn&quot; data-offset-x=&quot;90&quot; data-offset-y=&quot;200&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfLeft secondRowSecondColumn&quot; data-offset-x=&quot;0&quot; data-offset-y=&quot;200&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div style=&quot;position: relative&quot; class=&quot;constrainedContainer&quot;&gt;
+&lt;div class=&quot;grid directionRTL&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;400&quot;&gt;
+    &lt;div class=&quot;cell justifySelfFlexEnd firstRowFirstColumn&quot; data-offset-x=&quot;100&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfFlexStart firstRowSecondColumn&quot; data-offset-x=&quot;90&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfSelfStart secondRowFirstColumn&quot; data-offset-x=&quot;190&quot; data-offset-y=&quot;200&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfSelfEnd secondRowSecondColumn&quot; data-offset-x=&quot;0&quot; data-offset-y=&quot;200&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;!-- RTL direction with opposite directions grid container vs grid item. --&gt;
+&lt;div style=&quot;position: relative&quot; class=&quot;constrainedContainer&quot;&gt;
+&lt;div class=&quot;grid&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;400&quot;&gt;
+    &lt;div class=&quot;justifySelfStretch firstRowFirstColumn directionRTL&quot; data-offset-x=&quot;0&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;100&quot; data-expected-height=&quot;200&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfStart firstRowSecondColumn directionRTL&quot; data-offset-x=&quot;100&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfEnd firstRowSecondColumn directionRTL&quot; data-offset-x=&quot;190&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfCenter secondRowFirstColumn directionRTL&quot; data-offset-x=&quot;45&quot; data-offset-y=&quot;200&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfRight secondRowSecondColumn directionRTL&quot; data-offset-x=&quot;190&quot; data-offset-y=&quot;200&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfLeft secondRowSecondColumn directionRTL&quot; data-offset-x=&quot;100&quot; data-offset-y=&quot;200&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div style=&quot;position: relative&quot; class=&quot;constrainedContainer&quot;&gt;
+&lt;div class=&quot;grid&quot; data-expected-width=&quot;200&quot; data-expected-height=&quot;400&quot;&gt;
+    &lt;div class=&quot;cell justifySelfFlexEnd firstRowFirstColumn directionRTL&quot; data-offset-x=&quot;90&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfFlexStart firstRowSecondColumn directionRTL&quot; data-offset-x=&quot;100&quot; data-offset-y=&quot;0&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfSelfStart secondRowFirstColumn directionRTL&quot; data-offset-x=&quot;90&quot; data-offset-y=&quot;200&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+    &lt;div class=&quot;cell justifySelfSelfEnd secondRowSecondColumn directionRTL&quot; data-offset-x=&quot;100&quot; data-offset-y=&quot;200&quot; data-expected-width=&quot;10&quot; data-expected-height=&quot;20&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssgridlayoutresourcesgridcss"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/css-grid-layout/resources/grid.css (183398 => 183399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css-grid-layout/resources/grid.css        2015-04-27 17:07:20 UTC (rev 183398)
+++ trunk/LayoutTests/fast/css-grid-layout/resources/grid.css        2015-04-27 17:24:44 UTC (rev 183399)
</span><span class="lines">@@ -222,3 +222,7 @@
</span><span class="cx"> .directionRTL {
</span><span class="cx">     direction: rtl;
</span><span class="cx"> }
</span><ins>+
+.directionLTR {
+    direction: ltr;
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (183398 => 183399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-04-27 17:07:20 UTC (rev 183398)
+++ trunk/Source/WebCore/ChangeLog        2015-04-27 17:24:44 UTC (rev 183399)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2015-04-27  Javier Fernandez  &lt;jfernandez@igalia.com&gt;
+
+        [CSS Grid Layout] Support for the justify-self and justify-items in grid layout
+        https://bugs.webkit.org/show_bug.cgi?id=133280
+
+        Reviewed by David Hyatt.
+
+        Implementation of justify-self and justify-items properties for grid. It supports
+        different writing-modes and direction. Margins, borders and paddings are also
+        considered when computing the final position and stretched size.
+
+        This patch applies also a quite important refactoring of the alignment logic in
+        order to share code between the two alignment dimensions, row-axis and column-axis.
+
+        Overflow handling is still missing and will be added later in a follow-up bug.
+
+        Tests: fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-lr.html
+               fast/css-grid-layout/grid-align-justify-margin-border-padding-vertical-rl.html
+               fast/css-grid-layout/grid-align-justify-margin-border-padding.html
+               fast/css-grid-layout/justify-self-cell.html
+
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::layoutGridItems):
+        (WebCore::RenderGrid::columnAxisPositionForChild):
+        (WebCore::RenderGrid::rowAxisPositionForChild):
+        (WebCore::RenderGrid::rowPositionForChild):
+        (WebCore::RenderGrid::columnPositionForChild):
+        (WebCore::RenderGrid::findChildLogicalPosition):
+        (WebCore::RenderGrid::allowedToStretchLogicalHeightForChild): Deleted.
+        (WebCore::RenderGrid::needToStretchChildLogicalHeight): Deleted.
+        (WebCore::RenderGrid::marginLogicalHeightForChild): Deleted.
+        (WebCore::RenderGrid::availableAlignmentSpaceForChildBeforeStretching): Deleted.
+        (WebCore::RenderGrid::applyStretchAlignmentToChildIfNeeded): Deleted.
+        * rendering/RenderGrid.h:
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::resolveJustification):
+        * rendering/style/RenderStyle.h:
+
</ins><span class="cx"> 2015-04-27  Darin Adler  &lt;darin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Crashes under IDBDatabase::closeConnection
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderGridcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (183398 => 183399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderGrid.cpp        2015-04-27 17:07:20 UTC (rev 183398)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp        2015-04-27 17:24:44 UTC (rev 183399)
</span><span class="lines">@@ -40,8 +40,6 @@
</span><span class="cx"> 
</span><span class="cx"> static const int infinity = -1;
</span><span class="cx"> 
</span><del>-enum GridAxisPosition {GridAxisStart, GridAxisEnd, GridAxisCenter};
-
</del><span class="cx"> class GridTrack {
</span><span class="cx"> public:
</span><span class="cx">     GridTrack() {}
</span><span class="lines">@@ -1186,7 +1184,7 @@
</span><span class="cx"> 
</span><span class="cx">         child-&gt;layoutIfNeeded();
</span><span class="cx"> 
</span><del>-        child-&gt;setLogicalLocation(findChildLogicalPosition(*child, sizingData));
</del><ins>+        child-&gt;setLogicalLocation(findChildLogicalPosition(*child));
</ins><span class="cx"> 
</span><span class="cx">         // If the child moved, we have to repaint it as well as any floating/positioned
</span><span class="cx">         // descendants. An exception is if we need a layout. In this case, we know we're going to
</span><span class="lines">@@ -1240,42 +1238,6 @@
</span><span class="cx">         m_rowPositions[i + 1] = m_rowPositions[i] + sizingData.rowTracks[i].baseSize();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-LayoutUnit RenderGrid::endOfRowForChild(const RenderBox&amp; child) const
-{
-    const GridCoordinate&amp; coordinate = cachedGridCoordinate(child);
-
-    LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPosition.toInt()];
-    // The grid items should be inside the grid container's border box, that's why they need to be shifted.
-    LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child);
-
-    LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.next().toInt()];
-    // FIXME: This should account for the grid item's &lt;overflow-position&gt;.
-    return rowPosition + std::max&lt;LayoutUnit&gt;(0, endOfRow - startOfRow - child.logicalHeight());
-}
-
-LayoutUnit RenderGrid::startOfRowForChild(const RenderBox&amp; child) const
-{
-    const GridCoordinate&amp; coordinate = cachedGridCoordinate(child);
-
-    LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPosition.toInt()];
-    // The grid items should be inside the grid container's border box, that's why they need to be shifted.
-    // FIXME: This should account for the grid item's &lt;overflow-position&gt;.
-    LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child);
-
-    return rowPosition;
-}
-
-LayoutUnit RenderGrid::centeredRowPositionForChild(const RenderBox&amp; child) const
-{
-    const GridCoordinate&amp; coordinate = cachedGridCoordinate(child);
-
-    // The grid items should be inside the grid container's border box, that's why they need to be shifted.
-    LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPosition.toInt()];
-    LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.next().toInt()];
-    // FIXME: This should account for the grid item's &lt;overflow-position&gt;.
-    return startOfRow + std::max&lt;LayoutUnit&gt;(0, endOfRow - startOfRow - child.logicalHeight()) / 2;
-}
-
</del><span class="cx"> bool RenderGrid::allowedToStretchLogicalHeightForChild(const RenderBox&amp; child) const
</span><span class="cx"> {
</span><span class="cx">     return child.style().logicalHeight().isAuto() &amp;&amp; !child.style().marginBeforeUsing(&amp;style()).isAuto() &amp;&amp; !child.style().marginAfterUsing(&amp;style()).isAuto();
</span><span class="lines">@@ -1327,9 +1289,12 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static GridAxisPosition columnAxisPosition(ItemPosition position, bool hasOrthogonalWritingMode, bool hasSameWritingMode)
</del><ins>+GridAxisPosition RenderGrid::columnAxisPositionForChild(const RenderBox&amp; child) const
</ins><span class="cx"> {
</span><del>-    switch (position) {
</del><ins>+    bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizontalWritingMode();
+    bool hasSameWritingMode = child.style().writingMode() == style().writingMode();
+
+    switch (RenderStyle::resolveAlignment(style(), child.style(), ItemPositionStretch)) {
</ins><span class="cx">     case ItemPositionSelfStart:
</span><span class="cx">         // If orthogonal writing-modes, this computes to 'start'.
</span><span class="cx">         // FIXME: grid track sizing and positioning do not support orthogonal modes yet.
</span><span class="lines">@@ -1362,7 +1327,7 @@
</span><span class="cx">         return GridAxisStart;
</span><span class="cx">     case ItemPositionBaseline:
</span><span class="cx">     case ItemPositionLastBaseline:
</span><del>-        // FIXME: Implement the ItemPositionBaseline value. For now, we always 'start' align the child.
</del><ins>+        // FIXME: Implement the previous values. For now, we always 'start' align the child.
</ins><span class="cx">         return GridAxisStart;
</span><span class="cx">     case ItemPositionAuto:
</span><span class="cx">         break;
</span><span class="lines">@@ -1372,32 +1337,96 @@
</span><span class="cx">     return GridAxisStart;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-LayoutUnit RenderGrid::rowPositionForChild(const RenderBox&amp; child) const
</del><ins>+GridAxisPosition RenderGrid::rowAxisPositionForChild(const RenderBox&amp; child) const
</ins><span class="cx"> {
</span><span class="cx">     bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizontalWritingMode();
</span><del>-    bool hasSameWritingMode = child.style().writingMode() == style().writingMode();
-    ItemPosition position = RenderStyle::resolveAlignment(style(), child.style(), ItemPositionStretch);
</del><ins>+    bool hasSameDirection = child.style().direction() == style().direction();
+    bool isLTR = style().isLeftToRightDirection();
</ins><span class="cx"> 
</span><del>-    switch (columnAxisPosition(position, hasOrthogonalWritingMode, hasSameWritingMode)) {
</del><ins>+    switch (RenderStyle::resolveJustification(style(), child.style(), ItemPositionStretch)) {
+    case ItemPositionSelfStart:
+        // For orthogonal writing-modes, this computes to 'start'
+        // FIXME: grid track sizing and positioning do not support orthogonal modes yet.
+        // self-start is based on the child's direction. That's why we need to check against the grid container's direction.
+        return (hasOrthogonalWritingMode || hasSameDirection) ? GridAxisStart : GridAxisEnd;
+    case ItemPositionSelfEnd:
+        // For orthogonal writing-modes, this computes to 'start'
+        // FIXME: grid track sizing and positioning do not support orthogonal modes yet.
+        return (hasOrthogonalWritingMode || hasSameDirection) ? GridAxisEnd : GridAxisStart;
+    case ItemPositionLeft:
+        return isLTR ? GridAxisStart : GridAxisEnd;
+    case ItemPositionRight:
+        return isLTR ? GridAxisEnd : GridAxisStart;
+    case ItemPositionCenter:
+        return GridAxisCenter;
+    case ItemPositionFlexStart: // Only used in flex layout, otherwise equivalent to 'start'.
+    case ItemPositionStart:
+        return GridAxisStart;
+    case ItemPositionFlexEnd: // Only used in flex layout, otherwise equivalent to 'end'.
+    case ItemPositionEnd:
+        return GridAxisEnd;
+    case ItemPositionStretch:
+        return GridAxisStart;
+    case ItemPositionBaseline:
+    case ItemPositionLastBaseline:
+        // FIXME: Implement the previous values. For now, we always 'start' align the child.
+        return GridAxisStart;
+    case ItemPositionAuto:
+        break;
+    }
+
+    ASSERT_NOT_REACHED();
+    return GridAxisStart;
+}
+
+LayoutUnit RenderGrid::rowPositionForChild(const RenderBox&amp; child) const
+{
+    const GridCoordinate&amp; coordinate = cachedGridCoordinate(child);
+    LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPosition.toInt()];
+    LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.next().toInt()];
+    LayoutUnit startPosition = startOfRow + marginBeforeForChild(child);
+    // FIXME: This should account for the grid item's &lt;overflow-position&gt;.
+    LayoutUnit offsetFromStartPosition = endOfRow - startOfRow - child.logicalHeight() - child.marginLogicalHeight();
+
+    switch (columnAxisPositionForChild(child)) {
</ins><span class="cx">     case GridAxisStart:
</span><del>-        return startOfRowForChild(child);
</del><ins>+        return startPosition;
</ins><span class="cx">     case GridAxisEnd:
</span><del>-        return endOfRowForChild(child);
</del><ins>+        return startPosition + offsetFromStartPosition;
</ins><span class="cx">     case GridAxisCenter:
</span><del>-        return centeredRowPositionForChild(child);
</del><ins>+        return startPosition + offsetFromStartPosition / 2;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-LayoutPoint RenderGrid::findChildLogicalPosition(const RenderBox&amp; child, const GridSizingData&amp; sizingData) const
</del><ins>+
+LayoutUnit RenderGrid::columnPositionForChild(const RenderBox&amp; child) const
</ins><span class="cx"> {
</span><span class="cx">     const GridCoordinate&amp; coordinate = cachedGridCoordinate(child);
</span><del>-    ASSERT_UNUSED(sizingData, coordinate.columns.resolvedInitialPosition.toInt() &lt; sizingData.columnTracks.size());
-    ASSERT_UNUSED(sizingData, coordinate.rows.resolvedInitialPosition.toInt() &lt; sizingData.rowTracks.size());
</del><ins>+    LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInitialPosition.toInt()];
+    LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalPosition.next().toInt()];
+    LayoutUnit startPosition = startOfColumn + marginStartForChild(child);
+    // FIXME: This should account for the grid item's &lt;overflow-position&gt;.
+    LayoutUnit offsetFromStartPosition = endOfColumn - startOfColumn - child.logicalWidth() - child.marginLogicalWidth();
</ins><span class="cx"> 
</span><del>-    LayoutUnit columnPosition = m_columnPositions[coordinate.columns.resolvedInitialPosition.toInt()] + marginStartForChild(child);
</del><ins>+    switch (rowAxisPositionForChild(child)) {
+    case GridAxisStart:
+        return startPosition;
+    case GridAxisEnd:
+        return startPosition + offsetFromStartPosition;
+    case GridAxisCenter:
+        return startPosition + offsetFromStartPosition / 2;
+    }
+
+    ASSERT_NOT_REACHED();
+    return 0;
+}
+
+LayoutPoint RenderGrid::findChildLogicalPosition(const RenderBox&amp; child) const
+{
+    LayoutUnit columnPosition = columnPositionForChild(child);
</ins><span class="cx">     // We stored m_columnPositions's data ignoring the direction, hence we might need now
</span><span class="cx">     // to translate positions from RTL to LTR, as it's more convenient for painting.
</span><span class="cx">     if (!style().isLeftToRightDirection())
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderGridh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderGrid.h (183398 => 183399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderGrid.h        2015-04-27 17:07:20 UTC (rev 183398)
+++ trunk/Source/WebCore/rendering/RenderGrid.h        2015-04-27 17:24:44 UTC (rev 183399)
</span><span class="lines">@@ -40,6 +40,8 @@
</span><span class="cx"> class GridTrack;
</span><span class="cx"> class GridItemWithSpan;
</span><span class="cx"> 
</span><ins>+enum GridAxisPosition {GridAxisStart, GridAxisEnd, GridAxisCenter};
+
</ins><span class="cx"> class RenderGrid final : public RenderBlock {
</span><span class="cx"> public:
</span><span class="cx">     RenderGrid(Element&amp;, Ref&lt;RenderStyle&gt;&amp;&amp;);
</span><span class="lines">@@ -117,13 +119,14 @@
</span><span class="cx">     LayoutUnit logicalContentHeightForChild(RenderBox&amp;, Vector&lt;GridTrack&gt;&amp;);
</span><span class="cx">     LayoutUnit minContentForChild(RenderBox&amp;, GridTrackSizingDirection, Vector&lt;GridTrack&gt;&amp; columnTracks);
</span><span class="cx">     LayoutUnit maxContentForChild(RenderBox&amp;, GridTrackSizingDirection, Vector&lt;GridTrack&gt;&amp; columnTracks);
</span><del>-    LayoutUnit startOfRowForChild(const RenderBox&amp;) const;
-    LayoutUnit endOfRowForChild(const RenderBox&amp;) const;
-    LayoutUnit centeredRowPositionForChild(const RenderBox&amp;) const;
</del><ins>+    GridAxisPosition columnAxisPositionForChild(const RenderBox&amp;) const;
+    GridAxisPosition rowAxisPositionForChild(const RenderBox&amp;) const;
</ins><span class="cx">     LayoutUnit rowPositionForChild(const RenderBox&amp;) const;
</span><del>-    LayoutPoint findChildLogicalPosition(const RenderBox&amp;, const GridSizingData&amp;) const;
</del><ins>+    LayoutUnit columnPositionForChild(const RenderBox&amp;) const;
+    LayoutPoint findChildLogicalPosition(const RenderBox&amp;) const;
</ins><span class="cx">     GridCoordinate cachedGridCoordinate(const RenderBox&amp;) const;
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx">     LayoutUnit gridAreaBreadthForChild(const RenderBox&amp; child, GridTrackSizingDirection, const Vector&lt;GridTrack&gt;&amp;) const;
</span><span class="cx"> 
</span><span class="cx">     virtual void paintChildren(PaintInfo&amp; forSelf, const LayoutPoint&amp; paintOffset, PaintInfo&amp; forChild, bool usePrintRect) override;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleRenderStylecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (183398 => 183399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp        2015-04-27 17:07:20 UTC (rev 183398)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp        2015-04-27 17:24:44 UTC (rev 183399)
</span><span class="lines">@@ -179,6 +179,13 @@
</span><span class="cx">     return childStyle.alignSelf();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+ItemPosition RenderStyle::resolveJustification(const RenderStyle&amp; parentStyle, const RenderStyle&amp; childStyle, ItemPosition resolvedAutoPositionForLayoutObject)
+{
+    if (childStyle.justifySelf() == ItemPositionAuto)
+        return (parentStyle.justifyItems() == ItemPositionAuto) ? resolvedAutoPositionForLayoutObject : parentStyle.justifyItems();
+    return childStyle.justifySelf();
+}
+
</ins><span class="cx"> void RenderStyle::inheritFrom(const RenderStyle* inheritParent, IsAtShadowBoundary isAtShadowBoundary)
</span><span class="cx"> {
</span><span class="cx">     if (isAtShadowBoundary == AtShadowBoundary) {
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleRenderStyleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (183398 => 183399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/RenderStyle.h        2015-04-27 17:07:20 UTC (rev 183398)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h        2015-04-27 17:24:44 UTC (rev 183399)
</span><span class="lines">@@ -492,6 +492,7 @@
</span><span class="cx">     static Ref&lt;RenderStyle&gt; createStyleInheritingFromPseudoStyle(const RenderStyle&amp; pseudoStyle);
</span><span class="cx"> 
</span><span class="cx">     static ItemPosition resolveAlignment(const RenderStyle&amp; parentStyle, const RenderStyle&amp; childStyle, ItemPosition resolvedAutoPositionForRenderer);
</span><ins>+    static ItemPosition resolveJustification(const RenderStyle&amp; parentStyle, const RenderStyle&amp; childStyle, ItemPosition resolvedAutoPositionForLayoutObject);
</ins><span class="cx"> 
</span><span class="cx">     enum IsAtShadowBoundary {
</span><span class="cx">         AtShadowBoundary,
</span></span></pre>
</div>
</div>

</body>
</html>