Changeset 102183 in webkit
- Timestamp:
- Dec 6, 2011 3:11:05 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r102155 r102183 1 2011-12-06 Julien Chaffraix <jchaffraix@webkit.org> 2 3 CSS Grid Layout: Add support for parsing multiple grid-columns or grid-rows 4 https://bugs.webkit.org/show_bug.cgi?id=73272 5 6 Reviewed by Tony Chang. 7 8 * fast/css-grid-layout/grid-columns-rows-get-set-expected.txt: 9 * fast/css-grid-layout/resources/grid-columns-rows-get-set.js: 10 Added more testing for the single case. 11 12 * fast/css-grid-layout/grid-columns-rows-get-set-multiple-expected.txt: Added. 13 * fast/css-grid-layout/grid-columns-rows-get-set-multiple.html: Added. 14 * fast/css-grid-layout/resources/grid-columns-rows-get-set-multiple.js: Added. 15 1 16 2011-12-06 Darin Adler <darin@apple.com> 2 17 -
trunk/LayoutTests/fast/css-grid-layout/grid-columns-rows-get-set-expected.txt
r101288 r102183 27 27 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is 'auto' 28 28 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is 'auto' 29 30 Test setting grid-columns and grid-rows back to 'none' through JS 31 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is '18px' 32 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is '66px' 33 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns') is 'none' 34 PASS getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows') is 'none' 29 35 PASS successfullyParsed is true 30 36 -
trunk/LayoutTests/fast/css-grid-layout/resources/grid-columns-rows-get-set.js
r101288 r102183 49 49 shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'auto'"); 50 50 shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'auto'"); 51 52 debug(""); 53 debug("Test setting grid-columns and grid-rows back to 'none' through JS"); 54 element.style.webkitGridColumns = "18px"; 55 element.style.webkitGridRows = "66px"; 56 shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'18px'"); 57 shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'66px'"); 58 element.style.webkitGridColumns = "none"; 59 element.style.webkitGridRows = "none"; 60 shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-columns')", "'none'"); 61 shouldBe("getComputedStyle(element, '').getPropertyValue('-webkit-grid-rows')", "'none'"); -
trunk/Source/WebCore/ChangeLog
r102181 r102183 1 2011-12-06 Julien Chaffraix <jchaffraix@webkit.org> 2 3 CSS Grid Layout: Add support for parsing multiple grid-columns or grid-rows 4 https://bugs.webkit.org/show_bug.cgi?id=73272 5 6 Reviewed by Tony Chang. 7 8 Test: fast/css-grid-layout/grid-columns-rows-get-set-multiple.html 9 10 Updated our supported syntax to match the following: 11 <track-list> := [ <track-breadth> ]+ | 'none' 12 <track-breadth> := <length> | <percentage> | 'auto' 13 (the naming loosely matches the specification) 14 15 * css/CSSComputedStyleDeclaration.cpp: 16 (WebCore::valueForGridTrackBreadth): Added function to handle a breadth 17 (extended with 'auto' that the spec puts in <track-minmax>). 18 19 (WebCore::valueForGridTrackList): Create a space seperated list of 20 track breadth or none. 21 22 (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Updated 23 to use the new functions. 24 25 * css/CSSParser.cpp: 26 (WebCore::CSSParser::parseGridTrackList): Extended the function to 27 match the new syntax. 28 29 * css/CSSStyleApplyProperty.cpp: 30 (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty): Removed our 31 simple implementation. Replaced by the CSSStyleSelector functions. 32 33 * css/CSSStyleSelector.cpp: 34 (WebCore::createGridTrackBreadth): 35 (WebCore::createGridTrackList): 36 Added those 2 functions to convert the CSSPrimitiveValue to a Vector 37 as expected by RenderStyle. 38 39 (WebCore::CSSStyleSelector::applyProperty): Added our 2 properties 40 now that it is not handled by CSSStyleApplyProperty. 41 42 * rendering/style/RenderStyle.h: 43 (WebCore::InheritedFlags::gridColumns): 44 (WebCore::InheritedFlags::gridRows): 45 (WebCore::InheritedFlags::setGridColumns): 46 (WebCore::InheritedFlags::setGridRows): 47 (WebCore::InheritedFlags::initialGridColumns): 48 (WebCore::InheritedFlags::initialGridRows): 49 Updated the previous methods to take a Vector of Length. 50 51 (WebCore::InheritedFlags::initialGridTrackValue): 52 Needed function to return a Vector with one 'none' Length (the initial 53 value per the specification). 54 55 * rendering/style/StyleGridData.h: Updated to use a Vector. 56 1 57 2011-12-06 David Reveman <reveman@chromium.org> 2 58 -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r102149 r102183 795 795 796 796 #if ENABLE(CSS_GRID_LAYOUT) 797 static PassRefPtr<CSSValue> valueForGridTrack List(const Length& trackLength, const RenderStyle* style, CSSValuePool* cssValuePool)797 static PassRefPtr<CSSValue> valueForGridTrackBreadth(const Length& trackLength, const RenderStyle* style, CSSValuePool* cssValuePool) 798 798 { 799 799 if (trackLength.isPercent()) … … 801 801 if (trackLength.isAuto()) 802 802 return cssValuePool->createIdentifierValue(CSSValueAuto); 803 if (trackLength.isUndefined()) 803 return zoomAdjustedPixelValue(trackLength.value(), style, cssValuePool); 804 } 805 806 static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<Length>& trackLengths, const RenderStyle* style, CSSValuePool* cssValuePool) 807 { 808 // We should have at least an element! 809 ASSERT(trackLengths.size()); 810 811 // Handle the 'none' case here. 812 if (trackLengths.size() == 1 && trackLengths[0].isUndefined()) 804 813 return cssValuePool->createIdentifierValue(CSSValueNone); 805 return zoomAdjustedPixelValue(trackLength.value(), style, cssValuePool); 814 815 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 816 for (size_t i = 0; i < trackLengths.size(); ++i) 817 list->append(valueForGridTrackBreadth(trackLengths[i], style, cssValuePool)); 818 return list.release(); 806 819 } 807 820 #endif … … 1516 1529 #if ENABLE(CSS_GRID_LAYOUT) 1517 1530 case CSSPropertyWebkitGridColumns: { 1518 Length gridColumns = style->gridColumns(); 1519 return valueForGridTrackList(gridColumns, style.get(), cssValuePool); 1531 return valueForGridTrackList(style->gridColumns(), style.get(), cssValuePool); 1520 1532 } 1521 1533 case CSSPropertyWebkitGridRows: { 1522 Length gridRows = style->gridRows(); 1523 return valueForGridTrackList(gridRows, style.get(), cssValuePool); 1534 return valueForGridTrackList(style->gridRows(), style.get(), cssValuePool); 1524 1535 } 1525 1536 #endif -
trunk/Source/WebCore/css/CSSParser.cpp
r101998 r102183 3527 3527 { 3528 3528 CSSParserValue* value = m_valueList->current(); 3529 if (value->id == CSSValueNone || value->id == CSSValueAuto) { 3529 if (value->id == CSSValueNone) { 3530 if (m_valueList->next()) 3531 return false; 3532 3530 3533 addProperty(propId, cssValuePool()->createIdentifierValue(value->id), important); 3531 3534 return true; 3532 3535 } 3533 3536 3534 if (validUnit(value, FLength | FPercent, m_strict)) { 3535 addProperty(propId, createPrimitiveNumericValue(value), important); 3536 return true; 3537 } 3538 return false; 3537 RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated(); 3538 while (value) { 3539 bool valid = validUnit(value, FLength | FPercent, m_strict) || value->id == CSSValueAuto; 3540 if (!valid) 3541 return false; 3542 3543 RefPtr<CSSPrimitiveValue> primitiveValue = value->id == CSSValueAuto ? cssValuePool()->createIdentifierValue(CSSValueAuto) : createPrimitiveNumericValue(value); 3544 values->append(primitiveValue.release()); 3545 value = m_valueList->next(); 3546 } 3547 addProperty(propId, values.release(), important); 3548 return true; 3539 3549 } 3540 3550 #endif -
trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp
r101499 r102183 1332 1332 setPropertyHandler(CSSPropertyLeft, ApplyPropertyLength<&RenderStyle::left, &RenderStyle::setLeft, &RenderStyle::initialOffset, AutoEnabled>::createHandler()); 1333 1333 1334 #if ENABLE(CSS_GRID_LAYOUT)1335 setPropertyHandler(CSSPropertyWebkitGridColumns, ApplyPropertyLength<&RenderStyle::gridColumns, &RenderStyle::setGridColumns, &RenderStyle::initialGridColumns, AutoEnabled, IntrinsicDisabled, MinIntrinsicDisabled, NoneEnabled, UndefinedEnabled>::createHandler());1336 setPropertyHandler(CSSPropertyWebkitGridRows, ApplyPropertyLength<&RenderStyle::gridRows, &RenderStyle::setGridRows, &RenderStyle::initialGridRows, AutoEnabled, IntrinsicDisabled, MinIntrinsicDisabled, NoneEnabled, UndefinedEnabled>::createHandler());1337 #endif1338 1339 1334 setPropertyHandler(CSSPropertyWidth, ApplyPropertyLength<&RenderStyle::width, &RenderStyle::setWidth, &RenderStyle::initialSize, AutoEnabled, IntrinsicEnabled, MinIntrinsicEnabled, NoneDisabled, UndefinedDisabled, FlexWidth>::createHandler()); 1340 1335 setPropertyHandler(CSSPropertyHeight, ApplyPropertyLength<&RenderStyle::height, &RenderStyle::setHeight, &RenderStyle::initialSize, AutoEnabled, IntrinsicEnabled, MinIntrinsicEnabled, NoneDisabled, UndefinedDisabled, FlexHeight>::createHandler()); -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r102063 r102183 2507 2507 } 2508 2508 2509 #if ENABLE(CSS_GRID_LAYOUT) 2510 2511 static bool createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, CSSStyleSelector* selector, Length& length) 2512 { 2513 if (primitiveValue->getIdent() == CSSValueAuto) { 2514 length = Length(); 2515 return true; 2516 } 2517 2518 int type = primitiveValue->primitiveType(); 2519 if (CSSPrimitiveValue::isUnitTypeLength(type)) { 2520 length = primitiveValue->computeLength<Length>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()); 2521 length.setQuirk(primitiveValue->isQuirkValue()); 2522 return true; 2523 } 2524 2525 if (type == CSSPrimitiveValue::CSS_PERCENTAGE) { 2526 length = Length(primitiveValue->getDoubleValue(), Percent); 2527 return true; 2528 } 2529 2530 return false; 2531 } 2532 2533 static bool createGridTrackList(CSSValue* value, Vector<Length>& lengths, CSSStyleSelector* selector) 2534 { 2535 // Handle 'none'. 2536 if (value->isPrimitiveValue()) { 2537 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); 2538 if (primitiveValue->getIdent() == CSSValueNone) { 2539 lengths.append(Length(Undefined)); 2540 return true; 2541 } 2542 return false; 2543 } 2544 2545 if (value->isValueList()) { 2546 for (CSSValueListIterator i = value; i.hasMore(); i.advance()) { 2547 CSSValue* currValue = i.value(); 2548 if (!currValue->isPrimitiveValue()) 2549 return false; 2550 2551 Length length; 2552 if (!createGridTrackBreadth(static_cast<CSSPrimitiveValue*>(currValue), selector, length)) 2553 return false; 2554 2555 lengths.append(length); 2556 } 2557 return true; 2558 } 2559 2560 return false; 2561 } 2562 #endif 2563 2509 2564 void CSSStyleSelector::applyProperty(int id, CSSValue *value) 2510 2565 { … … 3759 3814 createFilterOperations(value, style(), m_rootElementStyle, operations); 3760 3815 m_style->setFilter(operations); 3816 return; 3817 } 3818 #endif 3819 #if ENABLE(CSS_GRID_LAYOUT) 3820 case CSSPropertyWebkitGridColumns: { 3821 Vector<Length> lengths; 3822 if (!createGridTrackList(value, lengths, this)) 3823 return; 3824 m_style->setGridColumns(lengths); 3825 return; 3826 } 3827 case CSSPropertyWebkitGridRows: { 3828 Vector<Length> lengths; 3829 if (!createGridTrackList(value, lengths, this)) 3830 return; 3831 m_style->setGridRows(lengths); 3761 3832 return; 3762 3833 } … … 3825 3896 case CSSPropertyFontStyle: 3826 3897 case CSSPropertyFontVariant: 3827 #if ENABLE(CSS_GRID_LAYOUT)3828 case CSSPropertyWebkitGridColumns:3829 case CSSPropertyWebkitGridRows:3830 #endif3831 3898 case CSSPropertyTextRendering: 3832 3899 case CSSPropertyWebkitTextOrientation: -
trunk/Source/WebCore/rendering/style/RenderStyle.h
r101524 r102183 730 730 731 731 #if ENABLE(CSS_GRID_LAYOUT) 732 LengthgridColumns() const { return rareNonInheritedData->m_grid->m_gridColumns; }733 LengthgridRows() const { return rareNonInheritedData->m_grid->m_gridRows; }732 const Vector<Length>& gridColumns() const { return rareNonInheritedData->m_grid->m_gridColumns; } 733 const Vector<Length>& gridRows() const { return rareNonInheritedData->m_grid->m_gridRows; } 734 734 #endif 735 735 … … 1147 1147 void setFlexFlow(EFlexFlow flow) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_flexFlow, flow); } 1148 1148 #if ENABLE(CSS_GRID_LAYOUT) 1149 void setGridColumns( Length length) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridColumns, length); }1150 void setGridRows( Length length) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridRows, length); }1149 void setGridColumns(const Vector<Length>& lengths) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridColumns, lengths); } 1150 void setGridRows(const Vector<Length>& lengths) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridRows, lengths); } 1151 1151 #endif 1152 1152 … … 1526 1526 1527 1527 #if ENABLE(CSS_GRID_LAYOUT) 1528 static Length initialGridColumns() { return Length(Undefined); } 1529 static Length initialGridRows() { return Length(Undefined); } 1528 // The initial value is 'none' for grid tracks. 1529 static Vector<Length> initialGridTrackValue() 1530 { 1531 static Vector<Length> defaultLength; 1532 // We need to manually add the Length here as the Length(0) is 'auto'. 1533 if (!defaultLength.size()) 1534 defaultLength.append(Length(Undefined)); 1535 return defaultLength; 1536 } 1537 static Vector<Length> initialGridColumns() { return initialGridTrackValue(); } 1538 static Vector<Length> initialGridRows() { return initialGridTrackValue(); } 1530 1539 #endif 1531 1540 -
trunk/Source/WebCore/rendering/style/StyleGridData.h
r101288 r102183 32 32 #include <wtf/PassRefPtr.h> 33 33 #include <wtf/RefCounted.h> 34 #include <wtf/Vector.h> 34 35 35 36 namespace WebCore { … … 52 53 // FIXME: For the moment, we only support a subset of the grammar which correspond to: 53 54 // 'auto' | <length> | <percentage> | 'none' 54 Lengthm_gridColumns;55 Lengthm_gridRows;55 Vector<Length> m_gridColumns; 56 Vector<Length> m_gridRows; 56 57 57 58 private:
Note: See TracChangeset
for help on using the changeset viewer.