Changeset 182613 in webkit
- Timestamp:
- Apr 9, 2015 4:36:28 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r182609 r182613 1 2015-04-09 Javier Fernandez <jfernandez@igalia.com> 2 3 [CSS Grid Layout] Implement justify-self and justify-item css properties. 4 https://bugs.webkit.org/show_bug.cgi?id=133281 5 6 Reviewed by David Hyatt. 7 8 Implement the new property 'justify-items', defined in the CSS Box Alignment 9 specification to desribe the container's alignment behavior, in the same way 10 the 'align-items' property does. 11 12 * fast/css/parse-justify-items-expected.txt: Added. 13 * fast/css/parse-justify-items.html: Added. 14 * fast/css/resources/alignment-parsing-utils.js: Added. 15 (checkValues): 16 (checkBadValues): 17 (checkInitialValues): 18 (checkInheritValues): 19 (checkLegacyValues): 20 1 21 2015-04-09 Myles C. Maxfield <mmaxfield@apple.com> 2 22 -
trunk/LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt
r182147 r182613 154 154 justify-content: flex-start; 155 155 justify-self: start; 156 justify-items: start; 156 157 -webkit-font-kerning: auto; 157 158 -webkit-font-smoothing: auto; -
trunk/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt
r182147 r182613 153 153 justify-content: flex-start 154 154 justify-self: auto 155 justify-items: auto 155 156 -webkit-font-kerning: auto 156 157 -webkit-font-smoothing: auto -
trunk/LayoutTests/fast/css/getComputedStyle/resources/property-names.js
r182147 r182613 67 67 "justify-content": true, 68 68 "justify-self": true, 69 "justify-items": true, 69 70 "-webkit-line-align": true, 70 71 "-webkit-line-box-contain": true, -
trunk/LayoutTests/svg/css/getComputedStyle-basic-expected.txt
r182147 r182613 305 305 rect: style.getPropertyValue(justify-self) : start 306 306 rect: style.getPropertyCSSValue(justify-self) : [object CSSValueList] 307 rect: style.getPropertyValue(justify-items) : start 308 rect: style.getPropertyCSSValue(justify-items) : [object CSSValueList] 307 309 rect: style.getPropertyValue(-webkit-font-kerning) : auto 308 310 rect: style.getPropertyCSSValue(-webkit-font-kerning) : [object CSSPrimitiveValue] … … 821 823 g: style.getPropertyValue(justify-self) : start 822 824 g: style.getPropertyCSSValue(justify-self) : [object CSSValueList] 825 g: style.getPropertyValue(justify-items) : start 826 g: style.getPropertyCSSValue(justify-items) : [object CSSValueList] 823 827 g: style.getPropertyValue(-webkit-font-kerning) : auto 824 828 g: style.getPropertyCSSValue(-webkit-font-kerning) : [object CSSPrimitiveValue] -
trunk/Source/WebCore/ChangeLog
r182612 r182613 1 2015-04-09 Javier Fernandez <jfernandez@igalia.com> 2 3 [CSS Grid Layout] Implement justify-self and justify-item css properties. 4 https://bugs.webkit.org/show_bug.cgi?id=133281 5 6 Reviewed by David Hyatt. 7 8 Implement the new property 'justify-items', defined in the CSS Box Alignment 9 specification to describe the container's alignment behavior, in the same way 10 the 'align-items' property does. The 'justify-self' 'auto' value of any relative 11 positioned element will be resolved to its container's 'justify-items' value. 12 13 Test: fast/css/parse-justify-items.html 14 15 * css/CSSComputedStyleDeclaration.cpp: 16 (WebCore::resolveContainerAlignmentAuto): Function to resolve 'auto' values for 'align-items' or 'justify-items'. 17 (WebCore::resolveSelfAlignmentAuto): Function to resolve 'auto' values for 'align-self' or 'justify-self'. 18 (WebCore::valueForItemPositionWithOverflowAlignment): Take into account the 'legacy' keyword. 19 (WebCore::ComputedStyleExtractor::propertyValue): 20 (WebCore::resolveAlignmentAuto): Deleted (renamed to resolveContainerAlignmentAuto). 21 * css/CSSParser.cpp: 22 (WebCore::CSSParser::parseValue): Refactoring to share logic between justify-xxx and align-xxx properties. 23 (WebCore::CSSParser::parseLegacyPosition): Parsing logic of 'legacy' keyword, 24 (WebCore::CSSParser::parseItemPositionOverflowPosition): Take into account the 'legacy' keyword. 25 * css/CSSParser.h: 26 * css/CSSPropertyNames.in: 27 * css/CSSValueKeywords.in: 28 * css/StyleBuilderCustom.h: 29 (WebCore::StyleBuilderCustom::applyInheritJustifyItems): Added. 30 (WebCore::StyleBuilderCustom::applyInitialJustifyItems): Added. 31 (WebCore::StyleBuilderCustom::applyValueJustifyItems): Added. 32 * css/StyleResolver.cpp: 33 (WebCore::StyleResolver::adjustRenderStyle): Resolve 'auto' values for justify-items when parents have the 'legacy' keyword. 34 * rendering/style/RenderStyle.h: Managing the new ItemPositionType fields. 35 * rendering/style/RenderStyleConstants.h: Added the ItemPositionType enumeration for handling the 'legacy' keyword. 36 * rendering/style/StyleRareNonInheritedData.cpp: Managing the new ItemPositionType fields. 37 (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): 38 (WebCore::StyleRareNonInheritedData::operator==): 39 * rendering/style/StyleRareNonInheritedData.h: 40 1 41 2015-04-09 Anders Carlsson <andersca@apple.com> 2 42 -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r182243 r182613 310 310 CSSPropertyJustifyContent, 311 311 CSSPropertyJustifySelf, 312 CSSPropertyJustifyItems, 312 313 CSSPropertyWebkitFilter, 313 314 #if ENABLE(FILTERS_LEVEL_2) … … 1696 1697 } 1697 1698 1698 static ItemPosition resolve AlignmentAuto(ItemPosition position, RenderObject* element)1699 static ItemPosition resolveContainerAlignmentAuto(ItemPosition position, RenderObject* element) 1699 1700 { 1700 1701 if (position != ItemPositionAuto || !element) … … 1705 1706 } 1706 1707 1708 static ItemPosition resolveSelfAlignmentAuto(ItemPosition position, OverflowAlignment& overflow, RenderObject* element) 1709 { 1710 if (position != ItemPositionAuto || !element || element->isOutOfFlowPositioned()) 1711 return position; 1712 1713 RenderBlock* parent = element->containingBlock(); 1714 if (!parent) 1715 return ItemPositionStart; 1716 1717 overflow = parent->style().alignItemsOverflowAlignment(); 1718 return resolveContainerAlignmentAuto(parent->style().alignItems(), parent); 1719 } 1707 1720 1708 1721 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const … … 1786 1799 #endif 1787 1800 1788 static PassRefPtr<CSSValueList> valueForItemPositionWithOverflowAlignment(ItemPosition itemPosition, OverflowAlignment overflowAlignment )1801 static PassRefPtr<CSSValueList> valueForItemPositionWithOverflowAlignment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, ItemPositionType positionType) 1789 1802 { 1790 1803 RefPtr<CSSValueList> result = CSSValueList::createSpaceSeparated(); 1804 if (positionType == LegacyPosition) 1805 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); 1791 1806 result->append(cssValuePool().createValue(itemPosition)); 1792 1807 if (overflowAlignment != OverflowAlignmentDefault) 1793 1808 result->append(cssValuePool().createValue(overflowAlignment)); 1809 ASSERT(result->length() <= 2); 1794 1810 return result.release(); 1795 1811 } … … 2158 2174 return cssValuePool().createValue(style->alignContent()); 2159 2175 case CSSPropertyAlignItems: 2160 return valueForItemPositionWithOverflowAlignment(resolve AlignmentAuto(style->alignItems(), renderer), style->alignItemsOverflowAlignment());2176 return valueForItemPositionWithOverflowAlignment(resolveContainerAlignmentAuto(style->alignItems(), renderer), style->alignItemsOverflowAlignment(), NonLegacyPosition); 2161 2177 case CSSPropertyAlignSelf: { 2162 ItemPosition alignSelf = style->alignSelf();2163 2178 OverflowAlignment overflow = style->alignSelfOverflowAlignment(); 2164 if (alignSelf == ItemPositionAuto) { 2165 if (renderer && !renderer->isOutOfFlowPositioned()) { 2166 alignSelf = ItemPositionStart; 2167 RenderBlock* parent = renderer->containingBlock(); 2168 if (parent) { 2169 alignSelf = resolveAlignmentAuto(parent->style().alignItems(), parent); 2170 overflow = parent->style().alignItemsOverflowAlignment(); 2171 } 2172 } 2173 } 2174 return valueForItemPositionWithOverflowAlignment(alignSelf, overflow); 2179 ItemPosition alignSelf = resolveSelfAlignmentAuto(style->alignSelf(), overflow, renderer); 2180 return valueForItemPositionWithOverflowAlignment(alignSelf, overflow, NonLegacyPosition); 2175 2181 } 2176 2182 case CSSPropertyFlex: … … 2190 2196 case CSSPropertyJustifyContent: 2191 2197 return cssValuePool().createValue(style->justifyContent()); 2192 case CSSPropertyJustifySelf: 2193 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(style->justifySelf(), renderer), style->justifySelfOverflowAlignment()); 2198 case CSSPropertyJustifyItems: 2199 return valueForItemPositionWithOverflowAlignment(resolveContainerAlignmentAuto(style->justifyItems(), renderer), style->justifyItemsOverflowAlignment(), style->justifyItemsPositionType()); 2200 case CSSPropertyJustifySelf: { 2201 OverflowAlignment overflow = style->justifySelfOverflowAlignment(); 2202 ItemPosition justifySelf = resolveSelfAlignmentAuto(style->justifySelf(), overflow, renderer); 2203 return valueForItemPositionWithOverflowAlignment(justifySelf, overflow, NonLegacyPosition); 2204 } 2194 2205 case CSSPropertyOrder: 2195 2206 return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER); -
trunk/Source/WebCore/css/CSSParser.cpp
r182525 r182613 2698 2698 case CSSPropertyJustifySelf: 2699 2699 return parseItemPositionOverflowPosition(propId, important); 2700 case CSSPropertyJustifyItems: 2701 if (parseLegacyPosition(propId, important)) 2702 return true; 2703 m_valueList->setCurrentIndex(0); 2704 return parseItemPositionOverflowPosition(propId, important); 2700 2705 #if ENABLE(CSS_GRID_LAYOUT) 2701 2706 case CSSPropertyWebkitGridAutoColumns: … … 3222 3227 } 3223 3228 3229 bool CSSParser::parseLegacyPosition(CSSPropertyID propId, bool important) 3230 { 3231 // [ legacy && [ left | right | center ] 3232 3233 CSSParserValue* value = m_valueList->current(); 3234 if (!value) 3235 return false; 3236 3237 if (value->id == CSSValueLegacy) { 3238 value = m_valueList->next(); 3239 if (!value) 3240 return false; 3241 if (value->id != CSSValueCenter && value->id != CSSValueLeft && value->id != CSSValueRight) 3242 return false; 3243 } else if (value->id == CSSValueCenter || value->id == CSSValueLeft || value->id == CSSValueRight) { 3244 if (!m_valueList->next() || m_valueList->current()->id != CSSValueLegacy) 3245 return false; 3246 } else 3247 return false; 3248 3249 addProperty(propId, createPrimitiveValuePair(cssValuePool().createIdentifierValue(CSSValueLegacy), cssValuePool().createIdentifierValue(value->id)), important); 3250 return !m_valueList->next(); 3251 } 3252 3224 3253 bool CSSParser::parseItemPositionOverflowPosition(CSSPropertyID propId, bool important) 3225 3254 { 3226 // auto | baseline | stretch | [<item-position> && <overflow-position>? ] 3255 // auto | stretch | <baseline-position> | [<item-position> && <overflow-position>? ] 3256 // <baseline-position> = baseline | last-baseline; 3227 3257 // <item-position> = center | start | end | self-start | self-end | flex-start | flex-end | left | right; 3228 3258 // <overflow-position> = true | safe 3229 3259 3230 3260 CSSParserValue* value = m_valueList->current(); 3261 if (!value) 3262 return false; 3231 3263 3232 3264 if (value->id == CSSValueAuto || value->id == CSSValueStretch || isBaselinePositionKeyword(value->id)) { -
trunk/Source/WebCore/css/CSSParser.h
r182270 r182613 219 219 bool parseClipShape(CSSPropertyID, bool important); 220 220 221 bool parseLegacyPosition(CSSPropertyID, bool important); 221 222 bool parseItemPositionOverflowPosition(CSSPropertyID, bool important); 222 223 -
trunk/Source/WebCore/css/CSSPropertyNames.in
r182147 r182613 480 480 justify-self [Custom=All] 481 481 -webkit-font-size-delta [SkipBuilder] 482 justify-items [Custom=All] 483 -webkit-justify-items = justify-items 482 484 #if defined(ENABLE_CSS_GRID_LAYOUT) && ENABLE_CSS_GRID_LAYOUT 483 485 -webkit-grid [Longhands=-webkit-grid-template-columns|-webkit-grid-template-rows|-webkit-grid-template-areas|-webkit-grid-auto-flow|-webkit-grid-auto-columns|-webkit-grid-auto-rows] -
trunk/Source/WebCore/css/CSSValueKeywords.in
r182147 r182613 554 554 // space-around 555 555 556 // CSS_PROP_JUSTIFY_ SELF556 // CSS_PROP_JUSTIFY_ITEMS / CSS_PROP_JUSTIFY_SELF 557 557 // auto 558 558 // stretch … … 570 570 true 571 571 safe 572 legacy 572 573 573 574 // CSS_PROP_FLEX_FLOW -
trunk/Source/WebCore/css/StyleBuilderCustom.h
r182147 r182613 104 104 DECLARE_PROPERTY_CUSTOM_HANDLERS(Zoom); 105 105 DECLARE_PROPERTY_CUSTOM_HANDLERS(JustifySelf); 106 DECLARE_PROPERTY_CUSTOM_HANDLERS(JustifyItems); 106 107 DECLARE_PROPERTY_CUSTOM_HANDLERS(AlignItems); 107 108 DECLARE_PROPERTY_CUSTOM_HANDLERS(AlignSelf); … … 579 580 } 580 581 582 inline void StyleBuilderCustom::applyInheritJustifyItems(StyleResolver& styleResolver) 583 { 584 styleResolver.style()->setJustifyItems(styleResolver.parentStyle()->justifyItems()); 585 styleResolver.style()->setJustifyItemsOverflowAlignment(styleResolver.parentStyle()->justifyItemsOverflowAlignment()); 586 styleResolver.style()->setJustifyItemsPositionType(styleResolver.parentStyle()->justifyItemsPositionType()); 587 } 588 589 inline void StyleBuilderCustom::applyInitialJustifyItems(StyleResolver& styleResolver) 590 { 591 styleResolver.style()->setJustifyItems(RenderStyle::initialJustifyItems()); 592 styleResolver.style()->setJustifyItemsOverflowAlignment(RenderStyle::initialJustifyItemsOverflowAlignment()); 593 styleResolver.style()->setJustifyItemsPositionType(RenderStyle::initialJustifyItemsPositionType()); 594 } 595 596 inline void StyleBuilderCustom::applyValueJustifyItems(StyleResolver& styleResolver, CSSValue& value) 597 { 598 styleResolver.style()->setJustifyItems(RenderStyle::initialJustifyItems()); 599 styleResolver.style()->setJustifyItemsOverflowAlignment(RenderStyle::initialJustifyItemsOverflowAlignment()); 600 styleResolver.style()->setJustifyItemsPositionType(RenderStyle::initialJustifyItemsPositionType()); 601 602 auto& primitiveValue = downcast<CSSPrimitiveValue>(value); 603 if (Pair* pairValue = primitiveValue.getPairValue()) { 604 if (pairValue->first()->getValueID() == CSSValueLegacy) { 605 styleResolver.style()->setJustifyItemsPositionType(LegacyPosition); 606 styleResolver.style()->setJustifyItems(*pairValue->second()); 607 } else { 608 styleResolver.style()->setJustifyItems(*pairValue->first()); 609 styleResolver.style()->setJustifyItemsOverflowAlignment(*pairValue->second()); 610 } 611 } else 612 styleResolver.style()->setJustifyItems(primitiveValue); 613 } 614 581 615 enum BorderImageType { BorderImage, WebkitMaskBoxImage }; 582 616 enum BorderImageModifierType { Outset, Repeat, Slice, Width }; -
trunk/Source/WebCore/css/StyleResolver.cpp
r182364 r182613 1435 1435 style.setDisplay(BLOCK); 1436 1436 } 1437 1438 // If the inherited value of justify-items includes the legacy keyword, 'auto' 1439 // computes to the the inherited value. 1440 if (parentStyle.justifyItemsPositionType() == LegacyPosition && style.justifyItems() == ItemPositionAuto) { 1441 style.setJustifyItems(parentStyle.justifyItems()); 1442 style.setJustifyItemsPositionType(parentStyle.justifyItemsPositionType()); 1443 } 1437 1444 } 1438 1445 -
trunk/Source/WebCore/rendering/style/RenderStyle.h
r182207 r182613 919 919 EFlexWrap flexWrap() const { return static_cast<EFlexWrap>(rareNonInheritedData->m_flexibleBox->m_flexWrap); } 920 920 EJustifyContent justifyContent() const { return static_cast<EJustifyContent>(rareNonInheritedData->m_justifyContent); } 921 ItemPosition justifyItems() const { return static_cast<ItemPosition>(rareNonInheritedData->m_justifyItems); } 922 OverflowAlignment justifyItemsOverflowAlignment() const { return static_cast<OverflowAlignment>(rareNonInheritedData->m_justifyItemsOverflowAlignment); } 923 ItemPositionType justifyItemsPositionType() const { return static_cast<ItemPositionType>(rareNonInheritedData->m_justifyItemsPositionType); } 921 924 ItemPosition justifySelf() const { return static_cast<ItemPosition>(rareNonInheritedData->m_justifySelf); } 922 925 OverflowAlignment justifySelfOverflowAlignment() const { return static_cast<OverflowAlignment>(rareNonInheritedData->m_justifySelfOverflowAlignment); } … … 1495 1498 void setFlexWrap(EFlexWrap w) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_flexWrap, w); } 1496 1499 void setJustifyContent(EJustifyContent p) { SET_VAR(rareNonInheritedData, m_justifyContent, p); } 1500 void setJustifyItems(ItemPosition justifyItems) { SET_VAR(rareNonInheritedData, m_justifyItems, justifyItems); } 1501 void setJustifyItemsOverflowAlignment(OverflowAlignment overflowAlignment) { SET_VAR(rareNonInheritedData, m_justifyItemsOverflowAlignment, overflowAlignment); } 1502 void setJustifyItemsPositionType(ItemPositionType positionType) { SET_VAR(rareNonInheritedData, m_justifyItemsPositionType, positionType); } 1497 1503 void setJustifySelf(ItemPosition p) { SET_VAR(rareNonInheritedData, m_justifySelf, p); } 1498 1504 void setJustifySelfOverflowAlignment(OverflowAlignment overflowAlignment) { SET_VAR(rareNonInheritedData, m_justifySelfOverflowAlignment, overflowAlignment); } … … 1913 1919 static EFlexWrap initialFlexWrap() { return FlexNoWrap; } 1914 1920 static EJustifyContent initialJustifyContent() { return JustifyFlexStart; } 1921 static ItemPosition initialJustifyItems() { return ItemPositionAuto; } 1922 static OverflowAlignment initialJustifyItemsOverflowAlignment() { return OverflowAlignmentDefault; } 1923 static ItemPositionType initialJustifyItemsPositionType() { return NonLegacyPosition; } 1915 1924 static ItemPosition initialJustifySelf() { return ItemPositionAuto; } 1916 1925 static OverflowAlignment initialJustifySelfOverflowAlignment() { return OverflowAlignmentDefault; } -
trunk/Source/WebCore/rendering/style/RenderStyleConstants.h
r182147 r182613 251 251 enum ItemPosition {ItemPositionAuto, ItemPositionStretch, ItemPositionBaseline, ItemPositionLastBaseline, ItemPositionCenter, ItemPositionStart, ItemPositionEnd, ItemPositionSelfStart, ItemPositionSelfEnd, ItemPositionFlexStart, ItemPositionFlexEnd, ItemPositionLeft, ItemPositionRight}; 252 252 enum OverflowAlignment {OverflowAlignmentDefault, OverflowAlignmentTrue, OverflowAlignmentSafe}; 253 253 enum ItemPositionType {NonLegacyPosition, LegacyPosition}; 254 254 255 255 enum ETextSecurity { -
trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp
r182147 r182613 88 88 , m_alignSelfOverflowAlignment(RenderStyle::initialAlignSelfOverflowAlignment()) 89 89 , m_justifyContent(RenderStyle::initialJustifyContent()) 90 , m_justifyItems(RenderStyle::initialJustifyItems()) 91 , m_justifyItemsOverflowAlignment(RenderStyle::initialJustifyItemsOverflowAlignment()) 92 , m_justifyItemsPositionType(NonLegacyPosition) 90 93 , m_justifySelf(RenderStyle::initialJustifySelf()) 91 94 , m_justifySelfOverflowAlignment(RenderStyle::initialJustifySelfOverflowAlignment()) … … 178 181 , m_alignSelfOverflowAlignment(o.m_alignSelfOverflowAlignment) 179 182 , m_justifyContent(o.m_justifyContent) 183 , m_justifyItems(o.m_justifyItems) 184 , m_justifyItemsOverflowAlignment(o.m_justifyItemsOverflowAlignment) 185 , m_justifyItemsPositionType(o.m_justifyItemsPositionType) 180 186 , m_justifySelf(o.m_justifySelf) 181 187 , m_justifySelfOverflowAlignment(o.m_justifySelfOverflowAlignment) … … 293 299 && m_aspectRatioType == o.m_aspectRatioType 294 300 && m_objectFit == o.m_objectFit 301 && m_justifyItems == o.m_justifyItems 302 && m_justifyItemsOverflowAlignment == o.m_justifyItemsOverflowAlignment 303 && m_justifyItemsPositionType == o.m_justifyItemsPositionType 295 304 && m_justifySelf == o.m_justifySelf 296 305 && m_justifySelfOverflowAlignment == o.m_justifySelfOverflowAlignment; -
trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h
r182147 r182613 195 195 unsigned m_justifyContent : 3; // EJustifyContent 196 196 197 unsigned m_justifyItems : 4; // ItemPosition 198 unsigned m_justifyItemsOverflowAlignment : 2; // OverflowAlignment 199 unsigned m_justifyItemsPositionType: 1; // Whether or not alignment uses the 'legacy' keyword. 200 197 201 unsigned m_justifySelf : 4; // ItemPosition 198 202 unsigned m_justifySelfOverflowAlignment : 2; // OverflowAlignment
Note: See TracChangeset
for help on using the changeset viewer.