Title: [154497] trunk
- Revision
- 154497
- Author
- [email protected]
- Date
- 2013-08-23 10:41:26 -0700 (Fri, 23 Aug 2013)
Log Message
Fix srcset's image candidate algorithm when DPR exceeds all candidates
https://bugs.webkit.org/show_bug.cgi?id=120168
Source/WebCore:
When the DPR exceeded the 'x' qualifier of all image candidates, none was chosen.
>From the srcset spec: "If there are any entries in candidates that have an associated pixel density that is less than a
user-agent-defined value giving the nominal pixel density of the display, then remove them, unless that would remove all the
entries, in which case remove only the entries whose associated pixel density is less than the greatest such pixel density."
Fixed by returning the last one in the list of candidates sorted by their qualifier, in case none of them is equal or greater than
DPR.
Patch by Yoav Weiss <[email protected]> on 2013-08-23
Reviewed by Andreas Kling.
Test: fast/hidpi/image-srcset-fraction.html
* html/parser/HTMLParserIdioms.cpp:
(WebCore::bestFitSourceForImageAttributes):
LayoutTests:
>From the srcset spec: "If there are any entries in candidates that have an associated pixel density that is less than a
user-agent-defined value giving the nominal pixel density of the display, then remove them, unless that would remove all the
entries, in which case remove only the entries whose associated pixel density is less than the greatest such pixel density."
This test verifies that when all the candidates' qualifiers are smaller than the DPR, the highest one is returned.
Patch by Yoav Weiss <[email protected]> on 2013-08-23
Reviewed by Andreas Kling.
* fast/hidpi/image-srcset-fraction-expected.txt: Added.
* fast/hidpi/image-srcset-fraction.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (154496 => 154497)
--- trunk/LayoutTests/ChangeLog 2013-08-23 17:24:52 UTC (rev 154496)
+++ trunk/LayoutTests/ChangeLog 2013-08-23 17:41:26 UTC (rev 154497)
@@ -1,3 +1,19 @@
+2013-08-23 Yoav Weiss <[email protected]>
+
+ Fix srcset's image candidate algorithm when DPR exceeds all candidates
+ https://bugs.webkit.org/show_bug.cgi?id=120168
+
+ From the srcset spec: "If there are any entries in candidates that have an associated pixel density that is less than a
+ user-agent-defined value giving the nominal pixel density of the display, then remove them, unless that would remove all the
+ entries, in which case remove only the entries whose associated pixel density is less than the greatest such pixel density."
+
+ This test verifies that when all the candidates' qualifiers are smaller than the DPR, the highest one is returned.
+
+ Reviewed by Andreas Kling.
+
+ * fast/hidpi/image-srcset-fraction-expected.txt: Added.
+ * fast/hidpi/image-srcset-fraction.html: Added.
+
2013-08-23 Chris Fleizach <[email protected]>
<https://webkit.org/b/113895> Webkit exposes aria-expanded="undefined" as aria-expanded="false" (AXExpanded = NO)
Added: trunk/LayoutTests/fast/hidpi/image-srcset-fraction-expected.txt (0 => 154497)
--- trunk/LayoutTests/fast/hidpi/image-srcset-fraction-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-fraction-expected.txt 2013-08-23 17:41:26 UTC (rev 154497)
@@ -0,0 +1,8 @@
+blue-100-px-square.png has MIME type image/png
+image-srcset-fraction.html has MIME type text/html
+srcset-helper.js has MIME type text/_javascript_
+js-test-pre.js has MIME type text/_javascript_
+green-200-px-square.png has MIME type image/png
+PASS document.getElementById("testimg").clientWidth==200 is true
+This test passes if the srcset resource is loaded and displayed as the image
+
Added: trunk/LayoutTests/fast/hidpi/image-srcset-fraction.html (0 => 154497)
--- trunk/LayoutTests/fast/hidpi/image-srcset-fraction.html (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-fraction.html 2013-08-23 17:41:26 UTC (rev 154497)
@@ -0,0 +1,25 @@
+<html>
+<head>
+<script>
+ window.targetScaleFactor = 2.5;
+</script>
+<script src=""
+<script src=""
+<script>
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.dumpResourceResponseMIMETypes();
+ }
+
+ addEventListener("load", function() {
+ if (internals)
+ shouldBeTrue('document.getElementById("testimg").clientWidth==200');
+ }, false);
+</script>
+</head>
+<body>
+<div>This test passes if the srcset resource is loaded and displayed as the image</div>
+<img src="" srcset="resources/green-200-px-square.png 2x" id="testimg">
+</body>
+</html>
+
Modified: trunk/Source/WebCore/ChangeLog (154496 => 154497)
--- trunk/Source/WebCore/ChangeLog 2013-08-23 17:24:52 UTC (rev 154496)
+++ trunk/Source/WebCore/ChangeLog 2013-08-23 17:41:26 UTC (rev 154497)
@@ -1,3 +1,24 @@
+2013-08-23 Yoav Weiss <[email protected]>
+
+ Fix srcset's image candidate algorithm when DPR exceeds all candidates
+ https://bugs.webkit.org/show_bug.cgi?id=120168
+
+ When the DPR exceeded the 'x' qualifier of all image candidates, none was chosen.
+
+ From the srcset spec: "If there are any entries in candidates that have an associated pixel density that is less than a
+ user-agent-defined value giving the nominal pixel density of the display, then remove them, unless that would remove all the
+ entries, in which case remove only the entries whose associated pixel density is less than the greatest such pixel density."
+
+ Fixed by returning the last one in the list of candidates sorted by their qualifier, in case none of them is equal or greater than
+ DPR.
+
+ Reviewed by Andreas Kling.
+
+ Test: fast/hidpi/image-srcset-fraction.html
+
+ * html/parser/HTMLParserIdioms.cpp:
+ (WebCore::bestFitSourceForImageAttributes):
+
2013-08-23 Chris Fleizach <[email protected]>
<https://webkit.org/b/113895> Webkit exposes aria-expanded="undefined" as aria-expanded="false" (AXExpanded = NO)
Modified: trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp (154496 => 154497)
--- trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp 2013-08-23 17:24:52 UTC (rev 154496)
+++ trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp 2013-08-23 17:41:26 UTC (rev 154497)
@@ -357,13 +357,16 @@
imageCandidates.append(image);
}
+ if (imageCandidates.isEmpty())
+ return String();
+
std::stable_sort(imageCandidates.begin(), imageCandidates.end(), compareByScaleFactor);
for (size_t i = 0; i < imageCandidates.size(); ++i) {
if (imageCandidates[i].scaleFactor >= deviceScaleFactor)
return imageCandidates[i].imageURL;
}
- return String();
+ return imageCandidates.last().imageURL;
}
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes