Commit e2df3dc1 authored by yoav@yoav.ws's avatar yoav@yoav.ws

Enable a srcset 0x descriptor

According to recent spec changes, a "0x" descriptor should be correctly parsed,
and imply intrinsic dimensions of infinity to the image.
This CL enables that, and tests that intrinsic dimensions are impacted accordingly.

BUG=378252

Review URL: https://codereview.chromium.org/305643006

git-svn-id: svn://svn.chromium.org/blink/trunk@175196 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0fb4b0ab
...@@ -62,6 +62,11 @@ crbug.com/245611 [ Linux ] fast/hidpi/video-controls-in-hidpi.html [ ImageOnlyFa ...@@ -62,6 +62,11 @@ crbug.com/245611 [ Linux ] fast/hidpi/video-controls-in-hidpi.html [ ImageOnlyFa
crbug.com/304953 fast/css/font-face-download-error.html [ Pass Timeout ] crbug.com/304953 fast/css/font-face-download-error.html [ Pass Timeout ]
crbug.com/379155 [ Win ] fast/hidpi/image-srcset-intrinsic-size-zero.html [ Failure ]
crbug.com/379155 [ Win ] virtual/gpu/fast/hidpi/image-srcset-intrinsic-size-zero.html [ Failure ]
crbug.com/379155 [ Linux Debug ] fast/hidpi/image-srcset-intrinsic-size-zero.html [ Failure ]
crbug.com/379155 [ Linux Debug ] virtual/gpu/fast/hidpi/image-srcset-intrinsic-size-zero.html [ Failure ]
# This batch were marked as NeedsRebaseline for crbug.com/133097 but are flaky: # This batch were marked as NeedsRebaseline for crbug.com/133097 but are flaky:
crbug.com/310679 [ Mac ] compositing/fixed-body-background-positioned.html [ Failure Pass ] crbug.com/310679 [ Mac ] compositing/fixed-body-background-positioned.html [ Failure Pass ]
crbug.com/310679 [ Mac ] compositing/rubberbanding/transform-overhang-e.html [ ImageOnlyFailure Pass ] crbug.com/310679 [ Mac ] compositing/rubberbanding/transform-overhang-e.html [ ImageOnlyFailure Pass ]
......
PASS successfullyParsed is true PASS successfullyParsed is true
TEST COMPLETE TEST COMPLETE
PASS document.getElementById("foo").clientWidth==200 is true PASS document.getElementById("foo").clientWidth is 200
PASS document.getElementById("foo2").clientWidth==400 is true PASS document.getElementById("foo2").clientWidth is 400
PASS document.getElementById("foo3").clientWidth==100 is true PASS document.getElementById("foo3").clientWidth is 100
PASS document.getElementById("foo4").clientWidth==200 is true PASS document.getElementById("foo4").clientWidth is 200
PASS document.getElementById("foo5").clientWidth is 200
This test passes if the images are all displayed with appropriate dimensions. This test passes if the images are all displayed with appropriate dimensions.
PASS successfullyParsed is true
TEST COMPLETE
PASS document.getElementById("foo").clientWidth is 33554432
This test passes if the image is displayed with infinite dimensions
<html>
<head>
<script>
window.targetScaleFactor = 2;
</script>
<script src="resources/srcset-helper.js"></script>
<script src="../../resources/js-test.js"></script>
<script>
addEventListener("load", function() {
shouldBe('document.getElementById("foo").clientWidth', '33554432');
}, false);
</script>
</head>
<body id="body">
<div>
This test passes if the image is displayed with infinite dimensions
</div>
<img id="foo" srcset="resources/blue-100-px-square.png 0x">
</body>
</html>
...@@ -7,10 +7,11 @@ ...@@ -7,10 +7,11 @@
<script src="../../resources/js-test.js"></script> <script src="../../resources/js-test.js"></script>
<script> <script>
addEventListener("load", function() { addEventListener("load", function() {
shouldBeTrue('document.getElementById("foo").clientWidth==200'); shouldBe('document.getElementById("foo").clientWidth', '200');
shouldBeTrue('document.getElementById("foo2").clientWidth==400'); shouldBe('document.getElementById("foo2").clientWidth', '400');
shouldBeTrue('document.getElementById("foo3").clientWidth==100'); shouldBe('document.getElementById("foo3").clientWidth', '100');
shouldBeTrue('document.getElementById("foo4").clientWidth==200'); shouldBe('document.getElementById("foo4").clientWidth', '200');
shouldBe('document.getElementById("foo5").clientWidth', '200');
}, false); }, false);
</script> </script>
</head> </head>
...@@ -25,6 +26,8 @@ ...@@ -25,6 +26,8 @@
<br> <br>
<img id="foo3" srcset="resources/srcset.svg 2x"> <img id="foo3" srcset="resources/srcset.svg 2x">
<br> <br>
<img id="foo4" src="resources/srcset.svg"> <img id="foo4" srcset="resources/blue-100-px-square.png 0.5x">
<br>
<img id="foo5" src="resources/srcset.svg">
</body> </body>
</html> </html>
...@@ -181,9 +181,8 @@ void HTMLImageElement::setBestFitURLAndDPRFromImageCandidate(const ImageCandidat ...@@ -181,9 +181,8 @@ void HTMLImageElement::setBestFitURLAndDPRFromImageCandidate(const ImageCandidat
m_bestFitImageURL = candidate.url(); m_bestFitImageURL = candidate.url();
m_currentSrc = AtomicString(document().completeURL(imageSourceURL()).string()); m_currentSrc = AtomicString(document().completeURL(imageSourceURL()).string());
float candidateDensity = candidate.density(); float candidateDensity = candidate.density();
// FIXME: Make this ">0" part match the spec, once it settles. if (candidateDensity >= 0)
if (candidateDensity > 0) m_imageDevicePixelRatio = 1.0 / candidateDensity;
m_imageDevicePixelRatio = 1 / candidateDensity;
if (renderer() && renderer()->isImage()) if (renderer() && renderer()->isImage())
toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevicePixelRatio); toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevicePixelRatio);
} }
......
...@@ -185,7 +185,7 @@ static bool parseDescriptors(const CharType* attribute, Vector<DescriptorToken>& ...@@ -185,7 +185,7 @@ static bool parseDescriptors(const CharType* attribute, Vector<DescriptorToken>&
} else if (c == 'x') { } else if (c == 'x') {
if (result.hasDensity() || result.hasHeight() || result.hasWidth()) if (result.hasDensity() || result.hasHeight() || result.hasWidth())
return false; return false;
int density = it->toFloat(attribute, isValid); float density = it->toFloat(attribute, isValid);
if (!isValid || density < 0) if (!isValid || density < 0)
return false; return false;
result.setDensity(density); result.setDensity(density);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment