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

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: Created 6 years, 6 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 91edb430ee0bd5e1f29df19ae155d704db5defaa..b1b9fca52a68df16cc43f681cf9f9c742a4312df 100644
--- a/Source/core/css/resolver/StyleAdjuster.cpp
+++ b/Source/core/css/resolver/StyleAdjuster.cpp
@@ -254,6 +254,62 @@ void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty
style->setTextAutosizingMultiplier(e->renderStyle()->textAutosizingMultiplier());
style->setUnique();
}
+
+ adjustStyleForAlignment(style, parentStyle);
+}
+
+void StyleAdjuster::adjustStyleForAlignment(RenderStyle* style, RenderStyle* parentStyle)
esprehn 2014/07/12 00:39:19 These should both be references.
+{
+ // If the inherited value of justify-items includes the legacy keyword, 'auto'
+ // computes to the the inherited value.
+ if (style->justifyItems() == ItemPositionAuto) {
+ if (parentStyle->justifyItemsPositionType() == LegacyPosition) {
+ style->setJustifyItems(parentStyle->justifyItems());
+ style->setJustifyItemsPositionType(parentStyle->justifyItemsPositionType());
+ // Otherwise, auto computes to:
+ } else if (style->isDisplayFlexibleOrGridBox()) {
+ // 'stretch' for flex containers and grid containers.
+ style->setJustifyItems(ItemPositionStretch);
+ } else {
+ // 'start' for everything else.
+ style->setJustifyItems(ItemPositionStart);
+ }
+ }
+
+ // The 'auto' keyword computes to 'stretch' on absolutely-positioned elements,
+ if (style->justifySelf() == ItemPositionAuto) {
+ if (style->position() == AbsolutePosition) {
+ style->setJustifySelf(ItemPositionStretch);
+ } else {
+ // and to the computed value of justify-items on the parent (minus
+ // any legacy keywords) on all other boxes.
+ style->setJustifySelf(parentStyle->justifyItems());
+ style->setJustifySelfOverflowAlignment(parentStyle->justifyItemsOverflowAlignment());
+ }
+ }
+
+ // The 'auto' keyword computes to:
+ if (style->alignItems() == ItemPositionAuto) {
+ if (style->isDisplayFlexibleOrGridBox()) {
+ // 'stretch' for flex containers and grid containers,
+ style->setAlignItems(ItemPositionStretch);
+ } else {
+ // 'start' for everything else
+ style->setAlignItems(ItemPositionStart);
+ }
+ }
+
+ // The 'auto' keyword computes to 'stretch' on absolutely-positioned elements,
+ if (style->alignSelf() == ItemPositionAuto) {
+ if ((style->position() == AbsolutePosition) || (parentStyle->alignItems() == ItemPositionAuto)) {
+ style->setAlignSelf(ItemPositionStretch);
+ } else {
+ // and to the computed value of align-items on the parent (minus
+ // any 'legacy' keywords) on all other boxes.
+ 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