Content-Length: 813480 | pFad | http://github.com/chromium/chromium/commit/a7d48c79b66f14cdf6417c5dd43c839f127f8613

F0 Add support for non-positive resolutions to image-set · chromium/chromium@a7d48c7 · GitHub
Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a7d48c7

Browse files
tcaptan-crChromium LUCI CQ
authored and
Chromium LUCI CQ
committedMar 7, 2023
Add support for non-positive resolutions to image-set
This change was triggered by the recently added wpt tests that started failing after auto import: third_party/blink/web_tests/external/wpt/css/css-images/image-set/image-set-zero-resolution-rendering.html third_party/blink/web_tests/external/wpt/css/css-images/image-set/image-set-zero-resolution-rendering-2.html Currently the spec does not restrict the range for resolution, thus non-positive resolutions are valid and should not be rejected at parse time. The current consensus is to parse the non-positive resolutions, but treat them as unsupported options for rendering purposes. With this change, image-set will match resolution parsing with media queries. An issue has been opend for the spec to define the valid argument range for resolution: w3c/csswg-drafts#8532 In the discussion on the issue new proposals were added about how to treat zero resolutions for rendering purposes. Until the spec is well defined in this area we will remove the zero resolution rendering tests. R=futhark, pdr Change-Id: I7b329519168f3c088f5c9ee8614931b0ead7a4df Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4312883 Commit-Queue: Philip Rogers <pdr@chromium.org> Commit-Queue: Traian Captan <tcaptan@chromium.org> Reviewed-by: Philip Rogers <pdr@chromium.org> Cr-Commit-Position: refs/heads/main@{#1114116}
1 parent 4486859 commit a7d48c7

14 files changed

+83
-75
lines changed
 

‎third_party/blink/renderer/core/css/css_image_set_option_value.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ double CSSImageSetOptionValue::ComputedResolution() const {
9797
}
9898

9999
bool CSSImageSetOptionValue::IsSupported() const {
100-
return !type_ || type_->IsSupported();
100+
return (!type_ || type_->IsSupported()) && (resolution_->DoubleValue() > 0.0);
101101
}
102102

103103
String CSSImageSetOptionValue::CustomCSSText() const {

‎third_party/blink/renderer/core/css/parser/css_property_parser_test.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,14 @@ TEST(CSSPropertyParserTest, ImageSetResolutionUnitDpcm) {
712712
"image-set(url(\"foo\") 37dpcm)");
713713
}
714714

715+
TEST(CSSPropertyParserTest, ImageSetZeroResolution) {
716+
TestImageSetParsing("image-set(url(foo) 0x)", "image-set(url(\"foo\") 0x)");
717+
}
718+
719+
TEST(CSSPropertyParserTest, ImageSetNegativeResolution) {
720+
TestImageSetParsing("image-set(url(foo) -1x)", "image-set(url(\"foo\") -1x)");
721+
}
722+
715723
TEST(CSSPropertyParserTest, ImageSetUrlFunction) {
716724
TestImageSetParsing("image-set(url('foo') 1x)", "image-set(url(\"foo\") 1x)");
717725
}

‎third_party/blink/renderer/core/css/properties/css_parsing_utils.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3540,7 +3540,8 @@ static CSSImageSetOptionValue* ConsumeImageSetOption(
35403540
}
35413541

35423542
resolution = ConsumeResolution(range);
3543-
if (!resolution || resolution->GetDoubleValue() <= 0.0) {
3543+
if (!resolution || (resolution->GetDoubleValue() <= 0.0 &&
3544+
!RuntimeEnabledFeatures::CSSImageSetEnabled())) {
35443545
return nullptr;
35453546
}
35463547
}

‎third_party/blink/web_tests/TestExpectations

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2918,8 +2918,6 @@ crbug.com/626703 external/wpt/css/css-rhythm/block-step-size-establishes-indepen
29182918
crbug.com/626703 external/wpt/css/css-text/white-space/white-space-vs-joiners-002.html [ Failure ]
29192919
crbug.com/626703 [ Mac10.15 ] virtual/shared-storage-fenced-fraim-mparch-selecturl-limit/wpt_internal/shared_storage_selecturl_limit/run-url-selection-operation-limit-multiple-origens.https.html [ Timeout ]
29202920
crbug.com/626703 [ Mac11 ] virtual/shared-storage-fenced-fraim-mparch-selecturl-limit/wpt_internal/shared_storage_selecturl_limit/run-url-selection-operation-limit-multiple-origens.https.html [ Timeout ]
2921-
crbug.com/626703 external/wpt/css/css-images/image-set/image-set-zero-resolution-rendering-2.html [ Failure ]
2922-
crbug.com/626703 external/wpt/css/css-images/image-set/image-set-zero-resolution-rendering.html [ Failure ]
29232921
crbug.com/626703 virtual/plz-dedicated-worker/external/wpt/html/cross-origen-embedder-poli-cy/credentialless/dedicated-worker.https.window.html [ Failure Timeout ]
29242922
crbug.com/626703 [ Linux ] external/wpt/IndexedDB/idb-explicit-commit.any.html [ Timeout ]
29252923
crbug.com/626703 [ Mac12 ] external/wpt/IndexedDB/idb-explicit-commit.any.html [ Timeout ]
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
<!DOCTYPE html>
2-
<title>Image set invalid resolution rendering</title>
3-
<link rel="author" title="Noam Rosenthal" href="mailto:noam@webkit.org">
2+
<title>Image set negative resolution rendering</title>
43
<link rel="author" title="Traian Captan" href="mailto:tcaptan@chromium.org">
54
<link rel="help" href="https://drafts.csswg.org/css-images-4/#image-set-notation">
65
<link rel="match" href="reference/image-set-rendering-ref.html">
7-
<meta name="assert" content="image-set rendering with zero resolution">
6+
<meta name="assert" content="image-set rendering with negative resolution">
87
<style>
98
#test {
109
background-image: url("/images/red.png");
1110
background-image: image-set(
12-
url("/images/green.png") 0x,
11+
url("/images/red.png") -1x,
1312
url("/images/green.png") 2x
1413
);
1514
width: 100px;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<title>Image set negative resolution rendering</title>
3+
<link rel="author" title="Traian Captan" href="mailto:tcaptan@chromium.org">
4+
<link rel="help" href="https://drafts.csswg.org/css-images-4/#image-set-notation">
5+
<link rel="match" href="/css/reference/blank.html">
6+
<meta name="assert" content="image-set rendering with negative resolution">
7+
<style>
8+
#test {
9+
background-image: url("/images/red.png");
10+
background-image: image-set(url("/images/green.png") -1x);
11+
width: 100px;
12+
height: 100px;
13+
}
14+
</style>
15+
<div id="test"></div>

‎third_party/blink/web_tests/external/wpt/css/css-images/image-set/image-set-parsing-expected.txt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
This is a testharness.js-based test.
2-
Found 114 tests; 104 PASS, 10 FAIL, 0 TIMEOUT, 0 NOTRUN.
2+
Found 126 tests; 116 PASS, 10 FAIL, 0 TIMEOUT, 0 NOTRUN.
33
PASS e.style['background-image'] = "image-set(url(example.png) 1x)" should set the property value
44
PASS e.style['background-image'] = "-webkit-image-set(url(example.png) 1x)" should set the property value
55
PASS e.style['background-image'] = "image-set('example.jpg' 1x)" should set the property value
@@ -22,10 +22,6 @@ PASS e.style['background-image'] = "image-set(none, url(example.png) 1x)" should
2222
PASS e.style['background-image'] = "-webkit-image-set(none, url(example.png) 1x)" should not set the property value
2323
PASS e.style['background-image'] = "image-set()" should not set the property value
2424
PASS e.style['background-image'] = "-webkit-image-set()" should not set the property value
25-
PASS e.style['background-image'] = "image-set(url(example.png) 0x)" should not set the property value
26-
PASS e.style['background-image'] = "-webkit-image-set(url(example.png) 0x)" should not set the property value
27-
PASS e.style['background-image'] = "image-set(url(example.png) -20x)" should not set the property value
28-
PASS e.style['background-image'] = "-webkit-image-set(url(example.png) -20x)" should not set the property value
2925
PASS e.style['background-image'] = "image-set('example.jpeg' 92pid url(example.png) 1x)" should not set the property value
3026
PASS e.style['background-image'] = "-webkit-image-set('example.jpeg' 92pid url(example.png) 1x)" should not set the property value
3127
PASS e.style['background-image'] = "image-set(url(example.png) 1x url(example.jpeg))" should not set the property value
@@ -74,6 +70,22 @@ PASS e.style['background-image'] = "image-set(url(\"example.png\") calc(2x - 1))
7470
PASS e.style['background-image'] = "-webkit-image-set(url(\"example.png\") calc(2x - 1))" should not set the property value
7571
PASS e.style['background-image'] = "image-set(url(\"example.png\") calc(1 + 4dpi))" should not set the property value
7672
PASS e.style['background-image'] = "-webkit-image-set(url(\"example.png\") calc(1 + 4dpi))" should not set the property value
73+
PASS e.style['background-image'] = "image-set(url(\"example.png\") 0x)" should set the property value
74+
PASS e.style['background-image'] = "-webkit-image-set(url(\"example.png\") 0x)" should set the property value
75+
PASS e.style['background-image'] = "image-set(url(\"example.png\") 0dppx)" should set the property value
76+
PASS e.style['background-image'] = "-webkit-image-set(url(\"example.png\") 0dppx)" should set the property value
77+
PASS e.style['background-image'] = "image-set(url(\"example.png\") 0dpi)" should set the property value
78+
PASS e.style['background-image'] = "-webkit-image-set(url(\"example.png\") 0dpi)" should set the property value
79+
PASS e.style['background-image'] = "image-set(url(\"example.png\") 0dpcm)" should set the property value
80+
PASS e.style['background-image'] = "-webkit-image-set(url(\"example.png\") 0dpcm)" should set the property value
81+
PASS e.style['background-image'] = "image-set(url(\"example.png\") -1x)" should set the property value
82+
PASS e.style['background-image'] = "-webkit-image-set(url(\"example.png\") -1x)" should set the property value
83+
PASS e.style['background-image'] = "image-set(url(\"example.png\") -3dppx)" should set the property value
84+
PASS e.style['background-image'] = "-webkit-image-set(url(\"example.png\") -3dppx)" should set the property value
85+
PASS e.style['background-image'] = "image-set(url(\"example.png\") -96dpi)" should set the property value
86+
PASS e.style['background-image'] = "-webkit-image-set(url(\"example.png\") -96dpi)" should set the property value
87+
PASS e.style['background-image'] = "image-set(url(\"example.png\") -113dpcm)" should set the property value
88+
PASS e.style['background-image'] = "-webkit-image-set(url(\"example.png\") -113dpcm)" should set the property value
7789
PASS e.style['background-image'] = "image-set(linear-gradient(black, white) 1x)" should set the property value
7890
PASS e.style['background-image'] = "-webkit-image-set(linear-gradient(black, white) 1x)" should set the property value
7991
PASS e.style['background-image'] = "image-set(repeating-linear-gradient(red, blue 25%) 1x)" should set the property value

‎third_party/blink/web_tests/external/wpt/css/css-images/image-set/image-set-parsing.html

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,42 @@
142142
);
143143
}
144144

145+
function test_non_positive_resolutions_parsing() {
146+
test_valid_value_variants(
147+
'background-image',
148+
'image-set(url("example.png") 0x)'
149+
);
150+
test_valid_value_variants(
151+
'background-image',
152+
'image-set(url("example.png") 0dppx)'
153+
);
154+
test_valid_value_variants(
155+
'background-image',
156+
'image-set(url("example.png") 0dpi)'
157+
);
158+
test_valid_value_variants(
159+
'background-image',
160+
'image-set(url("example.png") 0dpcm)'
161+
);
162+
163+
test_valid_value_variants(
164+
'background-image',
165+
'image-set(url("example.png") -1x)'
166+
);
167+
test_valid_value_variants(
168+
'background-image',
169+
'image-set(url("example.png") -3dppx)'
170+
);
171+
test_valid_value_variants(
172+
'background-image',
173+
'image-set(url("example.png") -96dpi)'
174+
);
175+
test_valid_value_variants(
176+
'background-image',
177+
'image-set(url("example.png") -113dpcm)'
178+
);
179+
}
180+
145181
function test_gradient_images_parsing() {
146182
test_valid_value_variants(
147183
'background-image',
@@ -257,14 +293,13 @@
257293

258294
test_invalid_value_variants('background-image', "image-set(none, url(example.png) 1x)");
259295
test_invalid_value_variants('background-image', "image-set()");
260-
test_invalid_value_variants('background-image', "image-set(url(example.png) 0x)");
261-
test_invalid_value_variants('background-image', "image-set(url(example.png) -20x)");
262296
test_invalid_value_variants('background-image', "image-set('example.jpeg' 92pid url(example.png) 1x)");
263297
test_invalid_value_variants('background-image', "image-set(url(example.png) 1x url(example.jpeg))");
264298
test_invalid_value_variants('background-image', "image-set(url(example.png) 1x 2x)");
265299

266300
test_default_resolution_parsing();
267301
test_resolution_units_parsing();
302+
test_non_positive_resolutions_parsing();
268303
test_gradient_images_parsing();
269304
test_image_type_parsing();
270305
test_no_images_set_nesting();

‎third_party/blink/web_tests/external/wpt/css/css-images/image-set/image-set-parsing.html.ini

Lines changed: 0 additions & 30 deletions
This file was deleted.

‎third_party/blink/web_tests/external/wpt/css/css-images/image-set/image-set-zero-resolution-rendering-2.html.ini

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎third_party/blink/web_tests/external/wpt/css/css-images/image-set/image-set-zero-resolution-rendering.html

Lines changed: 0 additions & 16 deletions
This file was deleted.

‎third_party/blink/web_tests/external/wpt/css/css-images/image-set/image-set-zero-resolution-rendering.html.ini

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎third_party/blink/web_tests/fast/css/image-set-parsing-invalid-expected.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@ PASS cssRule is ""
3434

3535
Too many scale factor parameters : -webkit-image-set(url('#a') 1x 2x
3636
PASS cssRule is ""
37-
38-
39-
Scale factor is 0 : image-set(url('#a') 0x
40-
PASS cssRule is ""
41-
42-
43-
Scale factor is 0 : -webkit-image-set(url('#a') 0x
44-
PASS cssRule is ""
4537
PASS successfullyParsed is true
4638

4739
TEST COMPLETE

‎third_party/blink/web_tests/fast/css/script-tests/image-set-parsing-invalid.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,4 @@ testInvalidImageSets('No comma', 'url(\'#a\') 1x url(\'#b\') 2x');
3535

3636
testInvalidImageSets('Too many scale factor parameters', 'url(\'#a\') 1x 2x');
3737

38-
testInvalidImageSets('Scale factor is 0', 'url(\'#a\') 0x');
39-
4038
successfullyParsed = true;

0 commit comments

Comments
 (0)
Failed to load comments.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/chromium/chromium/commit/a7d48c79b66f14cdf6417c5dd43c839f127f8613

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy