Changeset 282234 in webkit
- Timestamp:
- Sep 9, 2021 12:12:38 PM (10 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 15 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/backgrounds/background-position-xy-expected.html (added)
-
LayoutTests/fast/backgrounds/background-position-xy.html (added)
-
LayoutTests/fast/css/background-position-serialize-expected.txt (modified) (1 diff)
-
LayoutTests/fast/css/background-position-serialize.html (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-position-x-computed-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-position-x-valid-expected.txt (modified) (2 diffs)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-position-y-computed-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-position-y-valid-expected.txt (modified) (2 diffs)
-
LayoutTests/transitions/background-position-transitions-expected.txt (modified) (1 diff)
-
LayoutTests/transitions/background-position-transitions.html (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/CSSComputedStyleDeclaration.cpp (modified) (3 diffs)
-
Source/WebCore/css/parser/CSSPropertyParser.cpp (modified) (1 diff)
-
Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (modified) (3 diffs)
-
Source/WebCore/css/parser/CSSPropertyParserHelpers.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r282233 r282234 1 2021-09-09 Simon Fraser <simon.fraser@apple.com> 2 3 right- and bottom-relative values in background-position-x/y don't work 4 https://bugs.webkit.org/show_bug.cgi?id=202148 5 6 Reviewed by Antti Koivisto. 7 8 Ref test for various background-position-* values. Adjust for serialization output changes. 9 10 * fast/backgrounds/background-position-xy-expected.html: Added. 11 * fast/backgrounds/background-position-xy.html: Added. 12 * fast/css/background-position-serialize-expected.txt: 13 * fast/css/background-position-serialize.html: 14 * transitions/background-position-transitions-expected.txt: 15 * transitions/background-position-transitions.html: 16 1 17 2021-09-09 Eric Hutchison <ehutchison@apple.com> 2 18 -
trunk/LayoutTests/fast/css/background-position-serialize-expected.txt
r275269 r282234 66 66 PASS: t.style.backgroundPosition should be and is. 67 67 t.setAttribute('style', 'background-position-x: right 20px'); 68 PASS: window.getComputedStyle(t).backgroundPositionX should be 0%and is.68 PASS: window.getComputedStyle(t).backgroundPositionX should be right 20px and is. 69 69 t.setAttribute('style', 'background-position: right 20px bottom 10px'); 70 70 PASS: window.getComputedStyle(t).backgroundPosition should be right 20px bottom 10px and is. 71 PASS: window.getComputedStyle(t).backgroundPositionX should be 20px and is.71 PASS: window.getComputedStyle(t).backgroundPositionX should be right 20px and is. 72 72 t.setAttribute('style', 'background: url(about:blank) 80% 80%;'); 73 73 t.style.backgroundPositionY = '50px' -
trunk/LayoutTests/fast/css/background-position-serialize.html
r275269 r282234 123 123 shouldBe("t.style.backgroundPosition", ""); 124 124 125 run("t.setAttribute('style', 'background-position-x: right 20px');"); // This does not parse, but perhaps it should.126 shouldBe("window.getComputedStyle(t).backgroundPositionX", " 0%");125 run("t.setAttribute('style', 'background-position-x: right 20px');"); 126 shouldBe("window.getComputedStyle(t).backgroundPositionX", "right 20px"); 127 127 128 128 run("t.setAttribute('style', 'background-position: right 20px bottom 10px');"); 129 129 shouldBe("window.getComputedStyle(t).backgroundPosition", "right 20px bottom 10px"); 130 shouldBe("window.getComputedStyle(t).backgroundPositionX", " 20px"); // This is a bug. webkit.org/b/154551130 shouldBe("window.getComputedStyle(t).backgroundPositionX", "right 20px"); 131 131 132 132 run("t.setAttribute('style', 'background: url(about:blank) 80% 80%;');"); -
trunk/LayoutTests/imported/w3c/ChangeLog
r282217 r282234 1 2021-09-09 Simon Fraser <simon.fraser@apple.com> 2 3 right- and bottom-relative values in background-position-x/y don't work 4 https://bugs.webkit.org/show_bug.cgi?id=202148 5 6 Reviewed by Antti Koivisto. 7 8 More passing results. 9 10 * web-platform-tests/css/css-backgrounds/parsing/background-position-x-computed-expected.txt: 11 * web-platform-tests/css/css-backgrounds/parsing/background-position-x-valid-expected.txt: 12 * web-platform-tests/css/css-backgrounds/parsing/background-position-y-computed-expected.txt: 13 * web-platform-tests/css/css-backgrounds/parsing/background-position-y-valid-expected.txt: 14 1 15 2021-09-09 Youenn Fablet <youenn@apple.com> 2 16 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-position-x-computed-expected.txt
r267650 r282234 9 9 PASS Property background-position-x value '0.5em' 10 10 PASS Property background-position-x value 'calc(10px - 0.5em)' 11 FAIL Property background-position-x value 'left -20%' assert_true: 'left -20%' is a supported value for background-position-x. expected true got false 12 FAIL Property background-position-x value 'right -10px' assert_ true: 'right -10px' is a supported value for background-position-x. expected true got false11 PASS Property background-position-x value 'left -20%' 12 FAIL Property background-position-x value 'right -10px' assert_equals: expected "calc(100% + 10px)" but got "right -10px" 13 13 PASS Property background-position-x value '-20%, 10px' 14 14 PASS Property background-position-x value 'center, left, right' 15 15 FAIL Property background-position-x value '0.5em, x-start, x-end' assert_true: '0.5em, x-start, x-end' is a supported value for background-position-x. expected true got false 16 16 PASS Property background-position-x value 'calc(10px - 0.5em), -20%, 10px' 17 FAIL Property background-position-x value 'calc(10px - 0.5em), left -20%, right 10px' assert_true: 'calc(10px - 0.5em), left -20%, right 10px' is a supported value for background-position-x. expected true got false 17 PASS Property background-position-x value 'calc(10px - 0.5em), left -20%, right 10px' 18 18 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-position-x-valid-expected.txt
r267650 r282234 1 1 2 FAIL e.style['background-position-x'] = "center" should set the property value assert_equals: serialization should be canonical expected "center" but got "50%" 3 FAIL e.style['background-position-x'] = "left" should set the property value assert_equals: serialization should be canonical expected "left" but got "0%" 4 FAIL e.style['background-position-x'] = "right" should set the property value assert_equals: serialization should be canonical expected "right" but got "100%" 2 PASS e.style['background-position-x'] = "center" should set the property value 3 PASS e.style['background-position-x'] = "left" should set the property value 4 PASS e.style['background-position-x'] = "right" should set the property value 5 5 FAIL e.style['background-position-x'] = "x-start" should set the property value assert_not_equals: property should be set got disallowed value "" 6 6 FAIL e.style['background-position-x'] = "x-end" should set the property value assert_not_equals: property should be set got disallowed value "" … … 9 9 PASS e.style['background-position-x'] = "0.5em" should set the property value 10 10 PASS e.style['background-position-x'] = "calc(10px - 0.5em)" should set the property value 11 FAIL e.style['background-position-x'] = "left -20%" should set the property value assert_not_equals: property should be set got disallowed value "" 12 FAIL e.style['background-position-x'] = "right 10px" should set the property value assert_not_equals: property should be set got disallowed value "" 11 PASS e.style['background-position-x'] = "left -20%" should set the property value 12 PASS e.style['background-position-x'] = "right 10px" should set the property value 13 13 PASS e.style['background-position-x'] = "-20%, 10px" should set the property value 14 FAIL e.style['background-position-x'] = "center, left, right" should set the property value assert_equals: serialization should be canonical expected "center, left, right" but got "50%, 0%, 100%" 14 PASS e.style['background-position-x'] = "center, left, right" should set the property value 15 15 FAIL e.style['background-position-x'] = "0.5em, x-start, x-end" should set the property value assert_not_equals: property should be set got disallowed value "" 16 FAIL e.style['background-position-x'] = "calc(10px - 0.5em), left -20%, right 10px" should set the property value assert_not_equals: property should be set got disallowed value "" 16 PASS e.style['background-position-x'] = "calc(10px - 0.5em), left -20%, right 10px" should set the property value 17 17 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-position-y-computed-expected.txt
r267650 r282234 9 9 PASS Property background-position-y value '0.5em' 10 10 PASS Property background-position-y value 'calc(10px - 0.5em)' 11 FAIL Property background-position-y value 'top -20%' assert_true: 'top -20%' is a supported value for background-position-y. expected true got false 12 FAIL Property background-position-y value 'bottom -10px' assert_ true: 'bottom -10px' is a supported value for background-position-y. expected true got false11 PASS Property background-position-y value 'top -20%' 12 FAIL Property background-position-y value 'bottom -10px' assert_equals: expected "calc(100% + 10px)" but got "bottom -10px" 13 13 PASS Property background-position-y value '-20%, 10px' 14 14 PASS Property background-position-y value 'center, top, bottom' 15 15 FAIL Property background-position-y value '0.5em, y-start, y-end' assert_true: '0.5em, y-start, y-end' is a supported value for background-position-y. expected true got false 16 16 PASS Property background-position-y value 'calc(10px - 0.5em), -20%, 10px' 17 FAIL Property background-position-y value 'calc(10px - 0.5em), top -20%, bottom 10px' assert_true: 'calc(10px - 0.5em), top -20%, bottom 10px' is a supported value for background-position-y. expected true got false 17 PASS Property background-position-y value 'calc(10px - 0.5em), top -20%, bottom 10px' 18 18 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-position-y-valid-expected.txt
r267650 r282234 1 1 2 FAIL e.style['background-position-y'] = "center" should set the property value assert_equals: serialization should be canonical expected "center" but got "50%" 3 FAIL e.style['background-position-y'] = "top" should set the property value assert_equals: serialization should be canonical expected "top" but got "0%" 4 FAIL e.style['background-position-y'] = "bottom" should set the property value assert_equals: serialization should be canonical expected "bottom" but got "100%" 2 PASS e.style['background-position-y'] = "center" should set the property value 3 PASS e.style['background-position-y'] = "top" should set the property value 4 PASS e.style['background-position-y'] = "bottom" should set the property value 5 5 FAIL e.style['background-position-y'] = "y-start" should set the property value assert_not_equals: property should be set got disallowed value "" 6 6 FAIL e.style['background-position-y'] = "y-end" should set the property value assert_not_equals: property should be set got disallowed value "" … … 9 9 PASS e.style['background-position-y'] = "0.5em" should set the property value 10 10 PASS e.style['background-position-y'] = "calc(10px - 0.5em)" should set the property value 11 FAIL e.style['background-position-y'] = "top -20%" should set the property value assert_not_equals: property should be set got disallowed value "" 12 FAIL e.style['background-position-y'] = "bottom 10px" should set the property value assert_not_equals: property should be set got disallowed value "" 11 PASS e.style['background-position-y'] = "top -20%" should set the property value 12 PASS e.style['background-position-y'] = "bottom 10px" should set the property value 13 13 PASS e.style['background-position-y'] = "-20%, 10px" should set the property value 14 FAIL e.style['background-position-y'] = "center, top, bottom" should set the property value assert_equals: serialization should be canonical expected "center, top, bottom" but got "50%, 0%, 100%" 14 PASS e.style['background-position-y'] = "center, top, bottom" should set the property value 15 15 FAIL e.style['background-position-y'] = "0.5em, y-start, y-end" should set the property value assert_not_equals: property should be set got disallowed value "" 16 FAIL e.style['background-position-y'] = "calc(10px - 0.5em), top -20%, bottom 10px" should set the property value assert_ not_equals: property should be set got disallowed value ""16 FAIL e.style['background-position-y'] = "calc(10px - 0.5em), top -20%, bottom 10px" should set the property value assert_equals: serialization should be canonical expected "calc(-0.5em + 10px), top -20%, top 10px" but got "calc(-0.5em + 10px), top -20%, bottom 10px" 17 17 -
trunk/LayoutTests/transitions/background-position-transitions-expected.txt
r275869 r282234 1 1 PASS - "background-position-x" property for "box1" element at 0.5s saw something close to: 45px 2 2 PASS - "background-position-y" property for "box1" element at 0.5s saw something close to: 60px 3 PASS - "background-position-x" property for "box2" element at 0.5s saw something close to: 45px4 PASS - "background-position-y" property for "box2" element at 0.5s saw something close to: 60px3 PASS - "background-position-x" property for "box2" element at 0.5s saw something close to: right 45px 4 PASS - "background-position-y" property for "box2" element at 0.5s saw something close to: bottom 60px 5 5 PASS - "background-position-x" property for "box3" element at 0.5s saw something close to: calc(50% - 35px) 6 6 PASS - "background-position-y" property for "box3" element at 0.5s saw something close to: calc(50% - 40px) -
trunk/LayoutTests/transitions/background-position-transitions.html
r275869 r282234 44 44 [0.5, 'box1', 'background-position-x', "45px"], 45 45 [0.5, 'box1', 'background-position-y', "60px"], 46 [0.5, 'box2', 'background-position-x', " 45px"],47 [0.5, 'box2', 'background-position-y', " 60px"],46 [0.5, 'box2', 'background-position-x', "right 45px"], 47 [0.5, 'box2', 'background-position-y', "bottom 60px"], 48 48 [0.5, 'box3', 'background-position-x', "calc(50% - 35px)"], 49 49 [0.5, 'box3', 'background-position-y', "calc(50% - 40px)"], -
trunk/Source/WebCore/ChangeLog
r282223 r282234 1 2021-09-09 Simon Fraser <simon.fraser@apple.com> 2 3 right- and bottom-relative values in background-position-x/y don't work 4 https://bugs.webkit.org/show_bug.cgi?id=202148 5 6 Reviewed by Antti Koivisto. 7 8 Test: fast/backgrounds/background-position-xy.html 9 10 background-position[1] and background-position-x/background-position-y allow authors 11 to specify edge-relative values, like "background-position-x: right 10px". We 12 failed to handle this syntax in background-position-x and background-position-y, 13 but we do handle it in background-position. 14 15 So fix consumePositionX()/consumePositionY(), which are used when parsing 16 background-position-x/y, -webkit-mask-position-x/y, perspective-origin-x/y, and 17 transform-origin-x.y, to handle this edge-relative form. 18 19 A failure on imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-position-x-computed.html 20 (which only passes in Firefox) suggets that we should convert "right 10px" to "calc(100% - 10px)" 21 but for now, this patch serializes with edge keywords, as we do for the shorthand. 22 23 [1] https://www.w3.org/TR/css-backgrounds-3/#background-position 24 25 Test: fast/backgrounds/background-position-xy.html 26 27 * css/CSSComputedStyleDeclaration.cpp: 28 (WebCore::createSingleAxisPositionValueForLayer): 29 (WebCore::ComputedStyleExtractor::valueForPropertyInStyle): 30 * css/parser/CSSPropertyParser.cpp: 31 (WebCore::consumePositionX): 32 (WebCore::consumePositionY): 33 (WebCore::consumePositionLonghand): Deleted. 34 * css/parser/CSSPropertyParserHelpers.cpp: 35 (WebCore::CSSPropertyParserHelpers::consumePositionCoordinates): 36 (WebCore::CSSPropertyParserHelpers::consumeSingleAxisPosition): 37 * css/parser/CSSPropertyParserHelpers.h: 38 1 39 2021-09-09 Antti Koivisto <antti@apple.com> 2 40 -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r282143 r282234 298 298 list->append(CSSValuePool::singleton().createValue(layer.backgroundYOrigin())); 299 299 } 300 list->append(zoomAdjustedPixelValueForLength(layer.yPosition(), style)); 301 return list; 302 } 303 304 static Ref<CSSValue> createSingleAxisPositionValueForLayer(CSSPropertyID propertyID, const FillLayer& layer, const RenderStyle& style) 305 { 306 if (propertyID == CSSPropertyBackgroundPositionX || propertyID == CSSPropertyWebkitMaskPositionX) { 307 if (!layer.isBackgroundXOriginSet() || layer.backgroundXOrigin() == Edge::Left) 308 return zoomAdjustedPixelValueForLength(layer.xPosition(), style); 309 310 auto list = CSSValueList::createSpaceSeparated(); 311 list->append(CSSValuePool::singleton().createValue(layer.backgroundXOrigin())); 312 list->append(zoomAdjustedPixelValueForLength(layer.xPosition(), style)); 313 return list; 314 } 315 316 if (!layer.isBackgroundYOriginSet() || layer.backgroundYOrigin() == Edge::Top) 317 return zoomAdjustedPixelValueForLength(layer.yPosition(), style); 318 319 auto list = CSSValueList::createSpaceSeparated(); 320 list->append(CSSValuePool::singleton().createValue(layer.backgroundYOrigin())); 300 321 list->append(zoomAdjustedPixelValueForLength(layer.yPosition(), style)); 301 322 return list; … … 2700 2721 auto& layers = propertyID == CSSPropertyWebkitMaskPositionX ? style.maskLayers() : style.backgroundLayers(); 2701 2722 if (!layers.next()) 2702 return c ssValuePool.createValue(layers.xPosition(), style);2723 return createSingleAxisPositionValueForLayer(propertyID, layers, style); 2703 2724 2704 2725 auto list = CSSValueList::createCommaSeparated(); 2705 2726 for (auto* currLayer = &layers; currLayer; currLayer = currLayer->next()) 2706 list->append(c ssValuePool.createValue(currLayer->xPosition(), style));2727 list->append(createSingleAxisPositionValueForLayer(propertyID, *currLayer, style)); 2707 2728 2708 2729 return list; … … 2712 2733 auto& layers = propertyID == CSSPropertyWebkitMaskPositionY ? style.maskLayers() : style.backgroundLayers(); 2713 2734 if (!layers.next()) 2714 return c ssValuePool.createValue(layers.yPosition(), style);2735 return createSingleAxisPositionValueForLayer(propertyID, layers, style); 2715 2736 2716 2737 auto list = CSSValueList::createCommaSeparated(); 2717 2738 for (auto* currLayer = &layers; currLayer; currLayer = currLayer->next()) 2718 list->append(c ssValuePool.createValue(currLayer->yPosition(), style));2739 list->append(createSingleAxisPositionValueForLayer(propertyID, *currLayer, style)); 2719 2740 2720 2741 return list; -
trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp
r282144 r282234 2133 2133 } 2134 2134 2135 template <CSSValueID start, CSSValueID end>2136 static RefPtr<CSSPrimitiveValue> consumePositionLonghand(CSSParserTokenRange& range, CSSParserMode cssParserMode)2137 {2138 if (range.peek().type() == IdentToken) {2139 CSSValueID id = range.peek().id();2140 int percent;2141 if (id == start)2142 percent = 0;2143 else if (id == CSSValueCenter)2144 percent = 50;2145 else if (id == end)2146 percent = 100;2147 else2148 return nullptr;2149 range.consumeIncludingWhitespace();2150 return CSSPrimitiveValue::create(percent, CSSUnitType::CSS_PERCENTAGE);2151 }2152 return consumeLengthOrPercent(range, cssParserMode, ValueRange::All);2153 }2154 2155 2135 static RefPtr<CSSPrimitiveValue> consumePositionX(CSSParserTokenRange& range, CSSParserMode cssParserMode) 2156 2136 { 2157 return consume PositionLonghand<CSSValueLeft, CSSValueRight>(range, cssParserMode);2137 return consumeSingleAxisPosition(range, cssParserMode, BoxOrient::Horizontal); 2158 2138 } 2159 2139 2160 2140 static RefPtr<CSSPrimitiveValue> consumePositionY(CSSParserTokenRange& range, CSSParserMode cssParserMode) 2161 2141 { 2162 return consume PositionLonghand<CSSValueTop, CSSValueBottom>(range, cssParserMode);2142 return consumeSingleAxisPosition(range, cssParserMode, BoxOrient::Vertical); 2163 2143 } 2164 2144 -
trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
r282144 r282234 47 47 #include "ColorLuminance.h" 48 48 #include "Pair.h" 49 #include "RenderStyleConstants.h" 49 50 #include "RuntimeEnabledFeatures.h" 50 51 #include "StyleColor.h" … … 2769 2770 if (positionSyntax != PositionSyntax::BackgroundPosition) 2770 2771 return std::nullopt; 2771 2772 2772 2773 return backgroundPositionFromThreeValues(values); 2773 2774 } … … 2789 2790 return positionFromOneValue(*value1); 2790 2791 return positionFromTwoValues(*value1, *value2); 2792 } 2793 2794 RefPtr<CSSPrimitiveValue> consumeSingleAxisPosition(CSSParserTokenRange& range, CSSParserMode parserMode, BoxOrient orientation) 2795 { 2796 RefPtr<CSSPrimitiveValue> value1; 2797 2798 if (range.peek().type() == IdentToken) { 2799 switch (orientation) { 2800 case BoxOrient::Horizontal: 2801 value1 = consumeIdent<CSSValueLeft, CSSValueRight, CSSValueCenter>(range); 2802 break; 2803 case BoxOrient::Vertical: 2804 value1 = consumeIdent<CSSValueTop, CSSValueBottom, CSSValueCenter>(range); 2805 break; 2806 } 2807 if (!value1) 2808 return nullptr; 2809 2810 if (value1->valueID() == CSSValueCenter) 2811 return value1; 2812 } 2813 2814 auto value2 = consumeLengthOrPercent(range, parserMode, ValueRange::All, UnitlessQuirk::Forbid); 2815 if (value1 && value2) 2816 return CSSPropertyParserHelpersInternal::createPrimitiveValuePair(WTFMove(value1), WTFMove(value2)); 2817 2818 return value1 ? value1 : value2; 2791 2819 } 2792 2820 -
trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h
r282144 r282234 47 47 } 48 48 49 enum class BoxOrient : uint8_t; 50 49 51 // When these functions are successful, they will consume all the relevant 50 52 // tokens from the range and also consume any whitespace which follows. When … … 127 129 128 130 RefPtr<CSSPrimitiveValue> consumePosition(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk, PositionSyntax); 131 RefPtr<CSSPrimitiveValue> consumeSingleAxisPosition(CSSParserTokenRange&, CSSParserMode, BoxOrient); 129 132 std::optional<PositionCoordinates> consumePositionCoordinates(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk, PositionSyntax); 130 133 std::optional<PositionCoordinates> consumeOneOrTwoValuedPositionCoordinates(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk);
Note: See TracChangeset
for help on using the changeset viewer.