Changeset 214852 in webkit
- Timestamp:
- Apr 3, 2017 4:08:42 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r214851 r214852 1 2017-04-03 Javier Fernandez <jfernandez@igalia.com> 2 3 [css-align] Adapt place-content alignment shorthand to the new baseline syntax 4 https://bugs.webkit.org/show_bug.cgi?id=170340 5 6 Reviewed by David Hyatt. 7 8 Added additional test cases to evaluate the new baseline-alignment syntax. 9 10 * css3/parse-place-content-expected.txt: 11 * css3/parse-place-content.html: 12 1 13 2017-04-03 Nan Wang <n_wang@apple.com> 2 14 -
trunk/LayoutTests/css3/parse-place-content-expected.txt
r213230 r214852 4 4 PASS Test getting the Computed Value of place-content's longhand properties when setting 'normal' value through CSS. 5 5 PASS Test getting the Computed Value of place-content's longhand properties when setting 'baseline' value through CSS. 6 PASS Test getting the Computed Value of place-content's longhand properties when setting 'first baseline' value through CSS. 7 PASS Test getting the Computed Value of place-content's longhand properties when setting 'last baseline' value through CSS. 6 8 PASS Test getting the Computed Value of place-content's longhand properties when setting 'start' value through CSS. 7 9 PASS Test getting the Computed Value of place-content's longhand properties when setting 'flex-start' value through CSS. … … 19 21 PASS Test setting 'baseline safe' as incorrect value through CSS. 20 22 PASS Test setting 'start end left' as incorrect value through CSS. 21 FAIL Test setting values through JS. assert_equals: placeContent specified value is not what it should. expected "center" but got "center center" 23 PASS Test setting values through JS. 22 24 PASS Test setting incorrect values through JS. 23 25 PASS Test the 'initial' value of the place-content shorthand and its longhand properties' Computed value -
trunk/LayoutTests/css3/parse-place-content.html
r213230 r214852 8 8 #placeContentBaseline { 9 9 place-content: baseline; 10 } 11 #placeContentFirstBaseline { 12 place-content: first baseline; 13 } 14 #placeContentLastBaseline { 15 place-content: last baseline; 10 16 } 11 17 #placeContentStart { … … 64 70 <div id="placeContentNormal"></div> 65 71 <div id="placeContentBaseline"></div> 72 <div id="placeContentFirstBaseline"></div> 73 <div id="placeContentLastBaseline"></div> 66 74 <div id="placeContentStart"></div> 67 75 <div id="placeContentFlexStart"></div> … … 83 91 function checkPlaceContentValues(element, value, alignValue, justifyValue) 84 92 { 85 var res = value.split(" "); 86 if (res.length < 2) 87 res[1] = res[0]; 88 checkValues(element, "alignContent", "align-content", res[0], alignValue); 89 checkValues(element, "justifyContent", "justify-content", res[1], justifyValue); 93 var res = value.split(" "); 94 var alignContentSpecified = res[0]; 95 var justifyContentSpecified = ""; 96 if (res[0] === "first" || res[0] === "last") { 97 alignContentSpecified = res[0] + " " + res[1]; 98 if (res.length > 2) 99 justifyContentSpecified = res.slice(2).join(" "); 100 } else { 101 justifyContentSpecified = res.slice(1).join(" "); 102 } 103 104 if (justifyContentSpecified === "") 105 justifyContentSpecified = alignContentSpecified; 106 checkValues(element, "alignContent", "align-content", alignContentSpecified, alignValue); 107 checkValues(element, "justifyContent", "justify-content", justifyContentSpecified, justifyValue); 90 108 } 91 109 92 110 function checkPlaceContentValuesJS(value, alignValue, justifyValue) 93 111 { 94 element = document.createElement("div");95 document.body.appendChild(element);96 element.style.placeContent = value;97 checkValues(element, "placeContent", "place-content", value, alignValue + ' ' + justifyValue)98 checkPlaceContentValues(element, value, alignValue, justifyValue)112 element = document.createElement("div"); 113 document.body.appendChild(element); 114 element.style.placeContent = value; 115 checkValues(element, "placeContent", "place-content", value, alignValue + ' ' + justifyValue) 116 checkPlaceContentValues(element, value, alignValue, justifyValue) 99 117 } 100 118 … … 140 158 141 159 test(function() { 160 checkValues(placeContentFirstBaseline, "placeContent", "place-content", "", "baseline baseline"); 161 checkPlaceContentValues(placeContentFirstBaseline, "", "baseline", "baseline"); 162 }, "Test getting the Computed Value of place-content's longhand properties when setting 'first baseline' value through CSS."); 163 164 test(function() { 165 checkValues(placeContentLastBaseline, "placeContent", "place-content", "", "last baseline last baseline"); 166 checkPlaceContentValues(placeContentLastBaseline, "", "last baseline", "last baseline"); 167 }, "Test getting the Computed Value of place-content's longhand properties when setting 'last baseline' value through CSS."); 168 169 test(function() { 142 170 checkValues(placeContentStart, "placeContent", "place-content", "", "start start"); 143 171 checkPlaceContentValues(placeContentStart, "", "start", "start"); … … 215 243 216 244 test(function() { 217 // FIXME: We will get FAIL for placeContent specified values tests because we still don't know how to serialize this shortand.218 // https://github.com/w3c/csswg-drafts/issues/1041219 245 checkPlaceContentValuesJS("center", "center", "center"); 220 checkPlaceContentValuesJS("start start", "start", "start");221 246 checkPlaceContentValuesJS("center start", "center", "start"); 222 247 checkPlaceContentValuesJS("space-between end", "space-between", "end"); … … 232 257 checkPlaceContentValuesBadJS("stretch safe", "normal", "normal"); 233 258 checkPlaceContentValuesBadJS("space-between start end", "normal", "normal"); 259 checkPlaceContentValuesBadJS("", "normal", "normal"); 234 260 }, "Test setting incorrect values through JS."); 235 261 -
trunk/Source/WebCore/ChangeLog
r214851 r214852 1 2017-04-03 Javier Fernandez <jfernandez@igalia.com> 2 3 [css-align] Adapt place-content alignment shorthand to the new baseline syntax 4 https://bugs.webkit.org/show_bug.cgi?id=170340 5 6 Reviewed by David Hyatt. 7 8 Now that the align-content and justify-content CSS properties are 9 adapted to the new baseline-position CSS values syntax we can adapt the 10 shorthand that controls such properties to the new syntax as well. 11 12 No new tests, just adding some additional cases to the tests we already have. 13 14 * css/StyleProperties.cpp: 15 (WebCore::StyleProperties::getPropertyValue): 16 (WebCore::StyleProperties::placeContentPropertyValue): 17 * css/StyleProperties.h: 18 * css/parser/CSSPropertyParser.cpp: 19 (WebCore::isContentDistributionKeyword): 20 (WebCore::isContentPositionKeyword): 21 (WebCore::isOverflowKeyword): 22 (WebCore::getBaselineKeyword): 23 (WebCore::consumeContentDistributionOverflowPosition): 24 (WebCore::consumeSimplifiedContentPosition): 25 1 26 2017-04-03 Nan Wang <n_wang@apple.com> 2 27 -
trunk/Source/WebCore/css/StyleProperties.cpp
r214383 r214852 187 187 return getShorthandValue(gridRowShorthand()); 188 188 case CSSPropertyPlaceContent: 189 return getShorthandValue(placeContentShorthand());189 return placeContentPropertyValue(); 190 190 case CSSPropertyFont: 191 191 return fontValue(); … … 584 584 } 585 585 586 String StyleProperties::placeContentPropertyValue() const 587 { 588 String value = getCommonValue(placeContentShorthand()); 589 if (value.isNull() || value.isEmpty()) 590 return getShorthandValue(placeContentShorthand()); 591 return value; 592 } 593 586 594 String StyleProperties::borderPropertyValue(CommonValueMode valueMode) const 587 595 { -
trunk/Source/WebCore/css/StyleProperties.h
r209826 r214852 158 158 String getShorthandValue(const StylePropertyShorthand&) const; 159 159 String getCommonValue(const StylePropertyShorthand&) const; 160 String placeContentPropertyValue() const; 160 161 enum CommonValueMode { OmitUncommonValues, ReturnNullOnUncommonValues }; 161 162 String borderPropertyValue(CommonValueMode) const; -
trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp
r214624 r214852 2620 2620 } 2621 2621 2622 static bool isContentDistributionKeyword(CSSValueID id) 2623 { 2624 return identMatches<CSSValueSpaceBetween, CSSValueSpaceAround, CSSValueSpaceEvenly, CSSValueStretch>(id); 2625 } 2626 2627 static bool isContentPositionKeyword(CSSValueID id) 2628 { 2629 return identMatches<CSSValueStart, CSSValueEnd, CSSValueCenter, CSSValueFlexStart, CSSValueFlexEnd, CSSValueLeft, CSSValueRight>(id); 2630 } 2631 2632 static bool isOverflowKeyword(CSSValueID id) 2633 { 2634 return CSSPropertyParserHelpers::identMatches<CSSValueUnsafe, CSSValueSafe>(id); 2635 } 2636 2622 2637 static bool isBaselineKeyword(CSSValueID id) 2623 2638 { 2624 2639 return identMatches<CSSValueFirst, CSSValueLast, CSSValueBaseline>(id); 2640 } 2641 2642 static CSSValueID getBaselineKeyword(RefPtr<CSSValue> value) 2643 { 2644 auto& primitiveValue = downcast<CSSPrimitiveValue>(*value); 2645 if (auto* pairValue = primitiveValue.pairValue()) { 2646 ASSERT(pairValue->second()->valueID() == CSSValueBaseline); 2647 if (pairValue->first()->valueID() == CSSValueLast) 2648 return CSSValueLastBaseline; 2649 return CSSValueFirstBaseline; 2650 } 2651 ASSERT(primitiveValue.valueID() == CSSValueBaseline); 2652 return CSSValueBaseline; 2625 2653 } 2626 2654 … … 2649 2677 if (!baseline) 2650 2678 return nullptr; 2651 CSSValueID baselineID = CSSValueBaseline; 2652 auto& primitiveValue = downcast<CSSPrimitiveValue>(*baseline); 2653 if (auto* pairValue = primitiveValue.pairValue()) { 2654 if (pairValue->first()->valueID() == CSSValueLast) 2655 baselineID = CSSValueLastBaseline; 2656 else 2657 baselineID = CSSValueFirstBaseline; 2658 } 2659 return CSSContentDistributionValue::create(CSSValueInvalid, baselineID, CSSValueInvalid); 2679 return CSSContentDistributionValue::create(CSSValueInvalid, getBaselineKeyword(baseline), CSSValueInvalid); 2660 2680 } 2661 2681 … … 2665 2685 do { 2666 2686 CSSValueID id = range.peek().id(); 2667 if (i dentMatches<CSSValueSpaceBetween, CSSValueSpaceAround, CSSValueSpaceEvenly, CSSValueStretch>(id)) {2687 if (isContentDistributionKeyword(id)) { 2668 2688 if (distribution != CSSValueInvalid) 2669 2689 return nullptr; 2670 2690 distribution = id; 2671 } else if (i dentMatches<CSSValueStart, CSSValueEnd, CSSValueCenter, CSSValueFlexStart, CSSValueFlexEnd, CSSValueLeft, CSSValueRight>(id)) {2691 } else if (isContentPositionKeyword(id)) { 2672 2692 if (position != CSSValueInvalid) 2673 2693 return nullptr; 2674 2694 position = id; 2675 } else if (i dentMatches<CSSValueUnsafe, CSSValueSafe>(id)) {2695 } else if (isOverflowKeyword(id)) { 2676 2696 if (overflow != CSSValueInvalid) 2677 2697 return nullptr; … … 5452 5472 { 5453 5473 CSSValueID id = range.peek().id(); 5454 if (identMatches<CSSValueNormal , CSSValueBaseline, CSSValueLastBaseline>(id))5474 if (identMatches<CSSValueNormal>(id) || isContentPositionKeyword(id)) 5455 5475 return CSSContentDistributionValue::create(CSSValueInvalid, range.consumeIncludingWhitespace().id(), CSSValueInvalid); 5456 if (identMatches<CSSValueSpaceBetween, CSSValueSpaceAround, CSSValueSpaceEvenly, CSSValueStretch>(id)) 5476 if (isBaselineKeyword(id)) { 5477 RefPtr<CSSValue> baseline = consumeBaselineKeyword(range); 5478 if (!baseline) 5479 return nullptr; 5480 return CSSContentDistributionValue::create(CSSValueInvalid, getBaselineKeyword(baseline.releaseNonNull()), CSSValueInvalid); 5481 } 5482 if (isContentDistributionKeyword(id)) 5457 5483 return CSSContentDistributionValue::create(range.consumeIncludingWhitespace().id(), CSSValueInvalid, CSSValueInvalid); 5458 if (identMatches<CSSValueStart, CSSValueEnd, CSSValueCenter, CSSValueFlexStart, CSSValueFlexEnd, CSSValueLeft, CSSValueRight>(id))5459 return CSSContentDistributionValue::create(CSSValueInvalid, range.consumeIncludingWhitespace().id(), CSSValueInvalid);5460 5484 return nullptr; 5461 5485 }
Note: See TracChangeset
for help on using the changeset viewer.