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

Side by Side 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: Applied suggested changes. 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2011 Sencha, Inc. All rights reserved. 6 * Copyright (C) 2011 Sencha, Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 CSSPropertyFontFamily, 129 CSSPropertyFontFamily,
130 CSSPropertyFontKerning, 130 CSSPropertyFontKerning,
131 CSSPropertyFontSize, 131 CSSPropertyFontSize,
132 CSSPropertyFontStyle, 132 CSSPropertyFontStyle,
133 CSSPropertyFontVariant, 133 CSSPropertyFontVariant,
134 CSSPropertyFontVariantLigatures, 134 CSSPropertyFontVariantLigatures,
135 CSSPropertyFontWeight, 135 CSSPropertyFontWeight,
136 CSSPropertyHeight, 136 CSSPropertyHeight,
137 CSSPropertyImageRendering, 137 CSSPropertyImageRendering,
138 CSSPropertyIsolation, 138 CSSPropertyIsolation,
139 CSSPropertyJustifyItems,
139 CSSPropertyJustifySelf, 140 CSSPropertyJustifySelf,
140 CSSPropertyLeft, 141 CSSPropertyLeft,
141 CSSPropertyLetterSpacing, 142 CSSPropertyLetterSpacing,
142 CSSPropertyLineHeight, 143 CSSPropertyLineHeight,
143 CSSPropertyListStyleImage, 144 CSSPropertyListStyleImage,
144 CSSPropertyListStylePosition, 145 CSSPropertyListStylePosition,
145 CSSPropertyListStyleType, 146 CSSPropertyListStyleType,
146 CSSPropertyMarginBottom, 147 CSSPropertyMarginBottom,
147 CSSPropertyMarginLeft, 148 CSSPropertyMarginLeft,
148 CSSPropertyMarginRight, 149 CSSPropertyMarginRight,
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 { 1548 {
1548 if (!m_node) 1549 if (!m_node)
1549 return 0; 1550 return 0;
1550 if (m_node->isElementNode()) { 1551 if (m_node->isElementNode()) {
1551 if (PseudoElement* element = toElement(m_node)->pseudoElement(m_pseudoEl ementSpecifier)) 1552 if (PseudoElement* element = toElement(m_node)->pseudoElement(m_pseudoEl ementSpecifier))
1552 return element; 1553 return element;
1553 } 1554 }
1554 return m_node.get(); 1555 return m_node.get();
1555 } 1556 }
1556 1557
1557 static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlig nment(ItemPosition itemPosition, OverflowAlignment overflowAlignment) 1558 static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlig nment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, LegacyPosi tion isLegacy)
1558 { 1559 {
1559 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated (); 1560 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated ();
1561 if (isLegacy == LegacyPositionTrue)
1562 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy));
1560 result->append(CSSPrimitiveValue::create(itemPosition)); 1563 result->append(CSSPrimitiveValue::create(itemPosition));
1561 if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlign mentDefault) 1564 if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlign mentDefault)
1562 result->append(CSSPrimitiveValue::create(overflowAlignment)); 1565 result->append(CSSPrimitiveValue::create(overflowAlignment));
1566 ASSERT(result->length() <= 2);
1563 return result.release(); 1567 return result.release();
1564 } 1568 }
1565 1569
1566 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu e(CSSPropertyID propertyID, EUpdateLayout updateLayout) const 1570 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu e(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
1567 { 1571 {
1568 Node* styledNode = this->styledNode(); 1572 Node* styledNode = this->styledNode();
1569 if (!styledNode) 1573 if (!styledNode)
1570 return nullptr; 1574 return nullptr;
1571 RenderObject* renderer = styledNode->renderer(); 1575 RenderObject* renderer = styledNode->renderer();
1572 RefPtr<RenderStyle> style; 1576 RefPtr<RenderStyle> style;
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 } 1883 }
1880 case CSSPropertyDirection: 1884 case CSSPropertyDirection:
1881 return cssValuePool().createValue(style->direction()); 1885 return cssValuePool().createValue(style->direction());
1882 case CSSPropertyDisplay: 1886 case CSSPropertyDisplay:
1883 return cssValuePool().createValue(style->display()); 1887 return cssValuePool().createValue(style->display());
1884 case CSSPropertyEmptyCells: 1888 case CSSPropertyEmptyCells:
1885 return cssValuePool().createValue(style->emptyCells()); 1889 return cssValuePool().createValue(style->emptyCells());
1886 case CSSPropertyAlignContent: 1890 case CSSPropertyAlignContent:
1887 return cssValuePool().createValue(style->alignContent()); 1891 return cssValuePool().createValue(style->alignContent());
1888 case CSSPropertyAlignItems: 1892 case CSSPropertyAlignItems:
1889 return valueForItemPositionWithOverflowAlignment(style->alignItems() , style->alignItemsOverflowAlignment()); 1893 return valueForItemPositionWithOverflowAlignment(style->alignItems() , style->alignItemsOverflowAlignment(), LegacyPositionFalse);
1890 case CSSPropertyAlignSelf: { 1894 case CSSPropertyAlignSelf: {
1891 ItemPosition alignSelf = style->alignSelf(); 1895 ItemPosition alignSelf = style->alignSelf();
1892 if (alignSelf == ItemPositionAuto) { 1896 if (alignSelf == ItemPositionAuto) {
1893 Node* parent = styledNode->parentNode(); 1897 Node* parent = styledNode->parentNode();
1894 if (parent && parent->computedStyle()) 1898 if (parent && parent->computedStyle())
1895 alignSelf = parent->computedStyle()->alignItems(); 1899 alignSelf = parent->computedStyle()->alignItems();
1896 else 1900 else
1897 alignSelf = ItemPositionStretch; 1901 alignSelf = ItemPositionStretch;
1898 } 1902 }
1899 return valueForItemPositionWithOverflowAlignment(alignSelf, style->a lignSelfOverflowAlignment()); 1903 return valueForItemPositionWithOverflowAlignment(alignSelf, style->a lignSelfOverflowAlignment(), LegacyPositionFalse);
1900 } 1904 }
1901 case CSSPropertyFlex: 1905 case CSSPropertyFlex:
1902 return valuesForShorthandProperty(flexShorthand()); 1906 return valuesForShorthandProperty(flexShorthand());
1903 case CSSPropertyFlexBasis: 1907 case CSSPropertyFlexBasis:
1904 return zoomAdjustedPixelValueForLength(style->flexBasis(), *style); 1908 return zoomAdjustedPixelValueForLength(style->flexBasis(), *style);
1905 case CSSPropertyFlexDirection: 1909 case CSSPropertyFlexDirection:
1906 return cssValuePool().createValue(style->flexDirection()); 1910 return cssValuePool().createValue(style->flexDirection());
1907 case CSSPropertyFlexFlow: 1911 case CSSPropertyFlexFlow:
1908 return valuesForShorthandProperty(flexFlowShorthand()); 1912 return valuesForShorthandProperty(flexFlowShorthand());
1909 case CSSPropertyFlexGrow: 1913 case CSSPropertyFlexGrow:
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2020 return cssValuePool().createIdentifierValue(CSSValueAuto); 2024 return cssValuePool().createIdentifierValue(CSSValueAuto);
2021 return cssValuePool().createValue(style->hyphenationString(), CSSPri mitiveValue::CSS_STRING); 2025 return cssValuePool().createValue(style->hyphenationString(), CSSPri mitiveValue::CSS_STRING);
2022 case CSSPropertyWebkitBorderFit: 2026 case CSSPropertyWebkitBorderFit:
2023 if (style->borderFit() == BorderFitBorder) 2027 if (style->borderFit() == BorderFitBorder)
2024 return cssValuePool().createIdentifierValue(CSSValueBorder); 2028 return cssValuePool().createIdentifierValue(CSSValueBorder);
2025 return cssValuePool().createIdentifierValue(CSSValueLines); 2029 return cssValuePool().createIdentifierValue(CSSValueLines);
2026 case CSSPropertyImageRendering: 2030 case CSSPropertyImageRendering:
2027 return CSSPrimitiveValue::create(style->imageRendering()); 2031 return CSSPrimitiveValue::create(style->imageRendering());
2028 case CSSPropertyIsolation: 2032 case CSSPropertyIsolation:
2029 return cssValuePool().createValue(style->isolation()); 2033 return cssValuePool().createValue(style->isolation());
2030 case CSSPropertyJustifySelf: 2034 case CSSPropertyJustifyItems: {
2031 return valueForItemPositionWithOverflowAlignment(style->justifySelf( ), style->justifySelfOverflowAlignment()); 2035 ItemPosition justifyItems = style->justifyItems();
2036 LegacyPosition isLegacy = style->justifyItemsIsLegacy();
2037 if (justifyItems == ItemPositionAuto) {
2038 Node* parent = styledNode->parentNode();
2039 // If the inherited value of justify-items includes the legacy k eyword, 'auto'
2040 // computes to the the inherited value.
2041 if (parent && parent->computedStyle() && parent->computedStyle() ->justifyItemsIsLegacy()) {
2042 justifyItems = parent->computedStyle()->justifyItems();
2043 isLegacy = parent->computedStyle()->justifyItemsIsLegacy();
2044 // Otherwise, auto computes to:
2045 } else if (style->isDisplayFlexibleOrGridBox()) {
2046 // 'stretch' for flex containers and grid containers.
2047 justifyItems = ItemPositionStretch;
2048 } else {
2049 // 'start' for everything else.
2050 justifyItems = ItemPositionStart;
2051 }
Julien - ping for review 2014/06/26 17:37:20 I would like this to be tested. This is not possib
jfernandez 2014/06/26 22:36:05 Such logic is already covered by the provided layo
2052 }
2053 return valueForItemPositionWithOverflowAlignment(justifyItems, style ->justifyItemsOverflowAlignment(), isLegacy);
2054 }
2055 case CSSPropertyJustifySelf: {
2056 ItemPosition justifySelf = style->justifySelf();
2057 if (justifySelf == ItemPositionAuto) {
2058 // The auto keyword computes to stretch on absolutely-positioned elements,
2059 if (style->position() == AbsolutePosition) {
2060 justifySelf = ItemPositionStretch;
2061 } else {
2062 // and to the computed value of justify-items on the parent (minus
2063 // any legacy keywords) on all other boxes.
2064 Node* parent = styledNode->parentNode();
2065 if (parent && parent->computedStyle())
2066 justifySelf = parent->computedStyle()->justifyItems();
2067 }
2068 }
Julien - ping for review 2014/06/26 17:37:20 Ditto.
jfernandez 2014/06/26 22:36:05 Done.
2069 return valueForItemPositionWithOverflowAlignment(justifySelf, style- >justifySelfOverflowAlignment(), LegacyPositionFalse);
2070 }
2032 case CSSPropertyLeft: 2071 case CSSPropertyLeft:
2033 return valueForPositionOffset(*style, CSSPropertyLeft, renderer); 2072 return valueForPositionOffset(*style, CSSPropertyLeft, renderer);
2034 case CSSPropertyLetterSpacing: 2073 case CSSPropertyLetterSpacing:
2035 if (!style->letterSpacing()) 2074 if (!style->letterSpacing())
2036 return cssValuePool().createIdentifierValue(CSSValueNormal); 2075 return cssValuePool().createIdentifierValue(CSSValueNormal);
2037 return zoomAdjustedPixelValue(style->letterSpacing(), *style); 2076 return zoomAdjustedPixelValue(style->letterSpacing(), *style);
2038 case CSSPropertyWebkitLineClamp: 2077 case CSSPropertyWebkitLineClamp:
2039 if (style->lineClamp().isNone()) 2078 if (style->lineClamp().isNone())
2040 return cssValuePool().createIdentifierValue(CSSValueNone); 2079 return cssValuePool().createIdentifierValue(CSSValueNone);
2041 return cssValuePool().createValue(style->lineClamp().value(), style- >lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveVa lue::CSS_NUMBER); 2080 return cssValuePool().createValue(style->lineClamp().value(), style- >lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveVa lue::CSS_NUMBER);
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
3057 return list.release(); 3096 return list.release();
3058 } 3097 }
3059 3098
3060 void CSSComputedStyleDeclaration::trace(Visitor* visitor) 3099 void CSSComputedStyleDeclaration::trace(Visitor* visitor)
3061 { 3100 {
3062 visitor->trace(m_node); 3101 visitor->trace(m_node);
3063 CSSStyleDeclaration::trace(visitor); 3102 CSSStyleDeclaration::trace(visitor);
3064 } 3103 }
3065 3104
3066 } // namespace WebCore 3105 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698