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

Unified Diff: Source/core/css/CSSComputedStyleDeclaration.cpp

Issue 333423005: [CSS Grid Layout] Implement 'justify-items' parsing (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Modifying computed value resolution. 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/CSSComputedStyleDeclaration.cpp
diff --git a/Source/core/css/CSSComputedStyleDeclaration.cpp b/Source/core/css/CSSComputedStyleDeclaration.cpp
index 1c1eb5780f5380fa6fc7e183fc073d7bb97ed3fa..e53518fc553e876e5a2541c38528b53363d86d34 100644
--- a/Source/core/css/CSSComputedStyleDeclaration.cpp
+++ b/Source/core/css/CSSComputedStyleDeclaration.cpp
@@ -136,6 +136,7 @@ static const CSSPropertyID staticComputableProperties[] = {
CSSPropertyHeight,
CSSPropertyImageRendering,
CSSPropertyIsolation,
+ CSSPropertyJustifyItems,
CSSPropertyJustifySelf,
CSSPropertyLeft,
CSSPropertyLetterSpacing,
@@ -1554,15 +1555,22 @@ Node* CSSComputedStyleDeclaration::styledNode() const
return m_node.get();
}
-static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlignment(ItemPosition itemPosition, OverflowAlignment overflowAlignment)
+static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlignment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, bool isLegacy)
Julien - ping for review 2014/06/24 19:04:56 PLEASE NO BOOLEAN PARAMETERS! You can either add
jfernandez 2014/06/26 12:58:44 I finally implemented an enumeration.
{
RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated();
+ if (isLegacy)
+ result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy));
result->append(CSSPrimitiveValue::create(itemPosition));
if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlignmentDefault)
result->append(CSSPrimitiveValue::create(overflowAlignment));
Julien - ping for review 2014/06/24 19:04:56 ASSERT(result.size() <= 2); as you make the assump
jfernandez 2014/06/26 12:58:44 "result->length() <= 2", instead, but I've got the
return result.release();
}
+static bool isDisplayFlexibleOrGridBox(EDisplay display)
+{
+ return display == FLEX || display == INLINE_FLEX || display == GRID || display == INLINE_GRID;
Julien - ping for review 2014/06/24 19:04:56 RenderStyle has some similar checks, maybe we coul
jfernandez 2014/06/26 12:58:44 I've finally implemented a new method "isDisplayFl
+}
+
PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
{
Node* styledNode = this->styledNode();
@@ -1886,7 +1894,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu
case CSSPropertyAlignContent:
return cssValuePool().createValue(style->alignContent());
case CSSPropertyAlignItems:
- return valueForItemPositionWithOverflowAlignment(style->alignItems(), style->alignItemsOverflowAlignment());
+ return valueForItemPositionWithOverflowAlignment(style->alignItems(), style->alignItemsOverflowAlignment(), false);
case CSSPropertyAlignSelf: {
ItemPosition alignSelf = style->alignSelf();
if (alignSelf == ItemPositionAuto) {
@@ -1896,7 +1904,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu
else
alignSelf = ItemPositionStretch;
}
- return valueForItemPositionWithOverflowAlignment(alignSelf, style->alignSelfOverflowAlignment());
+ return valueForItemPositionWithOverflowAlignment(alignSelf, style->alignSelfOverflowAlignment(), false);
}
case CSSPropertyFlex:
return valuesForShorthandProperty(flexShorthand());
@@ -2027,8 +2035,43 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu
return CSSPrimitiveValue::create(style->imageRendering());
case CSSPropertyIsolation:
return cssValuePool().createValue(style->isolation());
- case CSSPropertyJustifySelf:
- return valueForItemPositionWithOverflowAlignment(style->justifySelf(), style->justifySelfOverflowAlignment());
+ case CSSPropertyJustifyItems: {
+ ItemPosition justifyItems = style->justifyItems();
+ bool isLegacy = style->justifyItemsIsLegacy();
+ if (justifyItems == ItemPositionAuto) {
+ Node* parent = styledNode->parentNode();
+ // If the inherited value of justify-items includes the legacy keyword, 'auto'
+ // computes to the the inherited value.
+ if (parent && parent->computedStyle() && parent->computedStyle()->justifyItemsIsLegacy()) {
+ justifyItems = parent->computedStyle()->justifyItems();
+ isLegacy = parent->computedStyle()->justifyItemsIsLegacy();
+ // Otherwise, auto computes to:
+ } else if (isDisplayFlexibleOrGridBox(style->display())) {
+ // 'stretch' for flex containers and grid containers.
+ justifyItems = ItemPositionStretch;
+ } else {
+ // 'start' for everything else.
+ justifyItems = ItemPositionStart;
+ }
+ }
+ return valueForItemPositionWithOverflowAlignment(justifyItems, style->justifyItemsOverflowAlignment(), isLegacy);
+ }
+ case CSSPropertyJustifySelf: {
+ ItemPosition justifySelf = style->justifySelf();
+ if (justifySelf == ItemPositionAuto) {
+ // The auto keyword computes to stretch on absolutely-positioned elements,
+ if (style->position() == AbsolutePosition) {
+ justifySelf = ItemPositionStretch;
+ } else {
+ // and to the computed value of justify-items on the parent (minus
+ // any legacy keywords) on all other boxes.
+ Node* parent = styledNode->parentNode();
+ if (parent && parent->computedStyle())
+ justifySelf = parent->computedStyle()->justifyItems();
+ }
+ }
+ return valueForItemPositionWithOverflowAlignment(justifySelf, style->justifySelfOverflowAlignment(), false);
+ }
case CSSPropertyLeft:
return valueForPositionOffset(*style, CSSPropertyLeft, renderer);
case CSSPropertyLetterSpacing:

Powered by Google App Engine
This is Rietveld 408576698