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

Unified Diff: Source/core/css/resolver/StyleAdjuster.cpp

Issue 363133003: [CSS Grid Layout] Adapting align-self, align-items and justify-self to the last CSS 3 spec. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Resolve grid and flex cases during cascade, the rest will wait for layout. Created 6 years, 5 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/css/resolver/StyleAdjuster.cpp
diff --git a/Source/core/css/resolver/StyleAdjuster.cpp b/Source/core/css/resolver/StyleAdjuster.cpp
index 5d7c1aa7b235643035d2c71cb92d93279de623bd..b8ffe49313c1ce9b67e375f3cd034605fb375424 100644
--- a/Source/core/css/resolver/StyleAdjuster.cpp
+++ b/Source/core/css/resolver/StyleAdjuster.cpp
@@ -254,6 +254,60 @@ void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty
style->setTextAutosizingMultiplier(e->renderStyle()->textAutosizingMultiplier());
style->setUnique();
}
+
+ adjustStyleForAlignment(*style, *parentStyle);
+}
+
+void StyleAdjuster::adjustStyleForAlignment(RenderStyle& style, const RenderStyle& parentStyle)
+{
+ bool isFlexOrGrid = style.isDisplayFlexibleOrGridBox();
+ bool absolutePositioned = style.position() == AbsolutePosition;
+
+ // If the inherited value of justify-items includes the legacy keyword, 'auto'
+ // computes to the the inherited value.
+ // Otherwise, auto computes to:
+ // - 'stretch' for flex containers and grid containers.
+ // - 'start' for everything else.
+ if (style.justifyItems() == ItemPositionAuto) {
+ if (parentStyle.justifyItemsPositionType() == LegacyPosition) {
+ style.setJustifyItems(parentStyle.justifyItems());
+ style.setJustifyItemsPositionType(parentStyle.justifyItemsPositionType());
+ } else if (isFlexOrGrid) {
+ style.setJustifyItems(ItemPositionStretch);
+ }
+ }
+
+ // The 'auto' keyword computes to 'stretch' on absolutely-positioned elements,
+ // and to the computed value of justify-items on the parent (minus
+ // any legacy keywords) on all other boxes.
+ if (style.justifySelf() == ItemPositionAuto) {
+ if (absolutePositioned) {
+ style.setJustifySelf(ItemPositionStretch);
+ } else {
+ style.setJustifySelf(parentStyle.justifyItems());
+ style.setJustifySelfOverflowAlignment(parentStyle.justifyItemsOverflowAlignment());
+ }
+ }
+
+ // The 'auto' keyword computes to:
+ // - 'stretch' for flex containers and grid containers,
+ // - 'start' for everything else.
+ if (style.alignItems() == ItemPositionAuto) {
+ if (isFlexOrGrid)
+ style.setAlignItems(ItemPositionStretch);
+ }
+
+ // The 'auto' keyword computes to 'stretch' on absolutely-positioned elements,
+ // and to the computed value of align-items on the parent (minus
+ // any 'legacy' keywords) on all other boxes.
+ if (style.alignSelf() == ItemPositionAuto) {
+ if (absolutePositioned) {
+ style.setAlignSelf(ItemPositionStretch);
+ } else {
+ style.setAlignSelf(parentStyle.alignItems());
+ style.setAlignSelfOverflowAlignment(parentStyle.alignItemsOverflowAlignment());
+ }
+ }
}
void StyleAdjuster::adjustStyleForTagName(RenderStyle* style, RenderStyle* parentStyle, Element& element)

Powered by Google App Engine
This is Rietveld 408576698