Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1502)

Unified Diff: Source/core/rendering/RenderGrid.cpp

Issue 438043002: [CSS Grid Layout] Support for justify-items property. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Applied suggested changes. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/rendering/RenderGrid.cpp
diff --git a/Source/core/rendering/RenderGrid.cpp b/Source/core/rendering/RenderGrid.cpp
index 4f474611800d3c8b62ce686754120dfe0f489ba7..cc9a0b393e47bf2f3217b6bbb98a4152e79700db 100644
--- a/Source/core/rendering/RenderGrid.cpp
+++ b/Source/core/rendering/RenderGrid.cpp
@@ -1163,17 +1163,37 @@ LayoutUnit RenderGrid::centeredColumnPositionForChild(const RenderBox* child) co
return columnPosition + std::max<LayoutUnit>(0, endOfColumn - startOfColumn - child->logicalWidth()) / 2;
}
+static ItemPosition resolveJustification(const RenderStyle* parentStyle, const RenderStyle* childStyle)
+{
+ ItemPosition justify = childStyle->justifySelf();
+ if (justify == ItemPositionAuto)
+ justify = (parentStyle->justifyItems() == ItemPositionAuto) ? ItemPositionStretch : parentStyle->justifyItems();
+
+ return justify;
+}
+
LayoutUnit RenderGrid::columnPositionForChild(const RenderBox* child) const
{
- ItemPosition childJustifySelf = child->style()->justifySelf();
- switch (childJustifySelf) {
+ bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHorizontalWritingMode();
+
+ switch (resolveJustification(style(), child->style())) {
case ItemPositionSelfStart:
+ // For orthogonal writing-modes, this computes to 'start'
+ // FIXME: grid track sizing and positioning do not support orthogonal modes yet.
+ if (hasOrthogonalWritingMode)
+ return columnPositionAlignedWithGridContainerStart(child);
+
// self-start is based on the child's direction. That's why we need to check against the grid container's direction.
if (child->style()->direction() != style()->direction())
return columnPositionAlignedWithGridContainerEnd(child);
return columnPositionAlignedWithGridContainerStart(child);
case ItemPositionSelfEnd:
+ // For orthogonal writing-modes, this computes to 'start'
+ // FIXME: grid track sizing and positioning do not support orthogonal modes yet.
+ if (hasOrthogonalWritingMode)
+ return columnPositionAlignedWithGridContainerEnd(child);
+
// self-end is based on the child's direction. That's why we need to check against the grid container's direction.
if (child->style()->direction() != style()->direction())
return columnPositionAlignedWithGridContainerStart(child);
@@ -1181,9 +1201,11 @@ LayoutUnit RenderGrid::columnPositionForChild(const RenderBox* child) const
return columnPositionAlignedWithGridContainerEnd(child);
case ItemPositionFlexStart:
- case ItemPositionFlexEnd:
// Only used in flex layout, for other layout, it's equivalent to 'start'.
return columnPositionAlignedWithGridContainerStart(child);
+ case ItemPositionFlexEnd:
+ // Only used in flex layout, for other layout, it's equivalent to 'start'.
+ return columnPositionAlignedWithGridContainerEnd(child);
case ItemPositionLeft:
// If the property's axis is not parallel with the inline axis, this is equivalent to ‘start’.
@@ -1212,6 +1234,7 @@ LayoutUnit RenderGrid::columnPositionForChild(const RenderBox* child) const
return columnPositionAlignedWithGridContainerEnd(child);
case ItemPositionAuto:
+ break;
case ItemPositionStretch:
case ItemPositionBaseline:
case ItemPositionLastBaseline:

Powered by Google App Engine
This is Rietveld 408576698