No subject


Mon Jan 28 08:41:14 PST 2013


ave 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 den=
sity is less than the greatest such pixel density."

This test verifies that when all the candidates' qualifiers are smaller t=
han the DPR, the highest one is returned.

Patch by Yoav Weiss <yoav at yoav.ws> on 2013-08-23
Reviewed by Andreas Kling.

* fast/hidpi/image-srcset-fraction-expected.txt: Added.
* fast/hidpi/image-srcset-fraction.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href=3D"#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a=
></li>
<li><a href=3D"#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeL=
og</a></li>
<li><a href=3D"#trunkSourceWebCorehtmlparserHTMLParserIdiomscpp">trunk/So=
urce/WebCore/html/parser/HTMLParserIdioms.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href=3D"#trunkLayoutTestsfasthidpiimagesrcsetfractionexpectedtxt">=
trunk/LayoutTests/fast/hidpi/image-srcset-fraction-expected.txt</a></li>
<li><a href=3D"#trunkLayoutTestsfasthidpiimagesrcsetfractionhtml">trunk/L=
ayoutTests/fast/hidpi/image-srcset-fraction.html</a></li>
</ul>

</div>
<div id=3D"patch">
<h3>Diff</h3>
<a id=3D"trunkLayoutTestsChangeLog"></a>
<div class=3D"modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (154496 =
=3D> 154497)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/LayoutTests/ChangeLog	2013-08-23 17:24:52 =
UTC (rev 154496)
+++ trunk/LayoutTests/ChangeLog	2013-08-23 17:41:26 UTC (rev 154497)
</span><span class=3D"lines">@@ -1,3 +1,19 @@
</span><ins>+2013-08-23  Yoav Weiss  &lt;yoav at yoav.ws&gt;
+
+        Fix srcset's image candidate algorithm when DPR exceeds all cand=
idates
+        https://bugs.webkit.org/show_bug.cgi?id=3D120168
+
+        From the srcset spec: &quot;If there are any entries in candidat=
es 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.&quot;
+
+        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.
+
</ins><span class=3D"cx"> 2013-08-23  Chris Fleizach  &lt;cfleizach at apple=
.com&gt;
</span><span class=3D"cx">=20
</span><span class=3D"cx">         &lt;https://webkit.org/b/113895&gt; We=
bkit exposes aria-expanded=3D&quot;undefined&quot; as aria-expanded=3D&qu=
ot;false&quot; (AXExpanded =3D NO)
</span></span></pre></div>
<a id=3D"trunkLayoutTestsfasthidpiimagesrcsetfractionexpectedtxt"></a>
<div class=3D"addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcs=
et-fraction-expected.txt (0 =3D> 154497)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/LayoutTests/fast/hidpi/image-srcset-fracti=
on-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-fraction-expected.txt	2013-=
08-23 17:41:26 UTC (rev 154497)
</span><span class=3D"lines">@@ -0,0 +1,8 @@
</span><ins>+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(&quot;testimg&quot;).clientWidth=3D=3D200 i=
s true
+This test passes if the srcset resource is loaded and displayed as the i=
mage
+
</ins></span></pre></div>
<a id=3D"trunkLayoutTestsfasthidpiimagesrcsetfractionhtml"></a>
<div class=3D"addfile"><h4>Added: trunk/LayoutTests/fast/hidpi/image-srcs=
et-fraction.html (0 =3D> 154497)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/LayoutTests/fast/hidpi/image-srcset-fracti=
on.html	                        (rev 0)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-fraction.html	2013-08-23 17=
:41:26 UTC (rev 154497)
</span><span class=3D"lines">@@ -0,0 +1,25 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+    window.targetScaleFactor =3D 2.5;
+&lt;/script&gt;
+&lt;script src=3D&quot;resources/srcset-helper.js&quot;&gt;&lt;/script&g=
t;
+&lt;script src=3D&quot;../js/resources/js-test-pre.js&quot;&gt;&lt;/scri=
pt&gt;
+&lt;script&gt;
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.dumpResourceResponseMIMETypes();
+    }
+
+    addEventListener(&quot;load&quot;, function() {
+        if (internals)
+            shouldBeTrue('document.getElementById(&quot;testimg&quot;).c=
lientWidth=3D=3D200');
+    }, false);
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div&gt;This test passes if the srcset resource is loaded and display=
ed as the image&lt;/div&gt;
+&lt;img src=3D&quot;resources/blue-100-px-square.png&quot; srcset=3D&quo=
t;resources/green-200-px-square.png 2x&quot; id=3D&quot;testimg&quot;&gt;
+&lt;/body&gt;
+&lt;/html&gt;
+
</ins></span></pre></div>
<a id=3D"trunkSourceWebCoreChangeLog"></a>
<div class=3D"modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (1544=
96 =3D> 154497)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- 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)
</span><span class=3D"lines">@@ -1,3 +1,24 @@
</span><ins>+2013-08-23  Yoav Weiss  &lt;yoav at yoav.ws&gt;
+
+        Fix srcset's image candidate algorithm when DPR exceeds all cand=
idates
+        https://bugs.webkit.org/show_bug.cgi?id=3D120168
+
+        When the DPR exceeded the 'x' qualifier of all image candidates,=
 none was chosen.
+
+        From the srcset spec: &quot;If there are any entries in candidat=
es 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.&quot;
+
+        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.
+       =20
+        Reviewed by Andreas Kling.
+
+        Test: fast/hidpi/image-srcset-fraction.html
+
+        * html/parser/HTMLParserIdioms.cpp:
+        (WebCore::bestFitSourceForImageAttributes):
+
</ins><span class=3D"cx"> 2013-08-23  Chris Fleizach  &lt;cfleizach at apple=
.com&gt;
</span><span class=3D"cx">=20
</span><span class=3D"cx">         &lt;https://webkit.org/b/113895&gt; We=
bkit exposes aria-expanded=3D&quot;undefined&quot; as aria-expanded=3D&qu=
ot;false&quot; (AXExpanded =3D NO)
</span></span></pre></div>
<a id=3D"trunkSourceWebCorehtmlparserHTMLParserIdiomscpp"></a>
<div class=3D"modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTM=
LParserIdioms.cpp (154496 =3D> 154497)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/Source/WebCore/html/parser/HTMLParserIdiom=
s.cpp	2013-08-23 17:24:52 UTC (rev 154496)
+++ trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp	2013-08-23 17:4=
1:26 UTC (rev 154497)
</span><span class=3D"lines">@@ -357,13 +357,16 @@
</span><span class=3D"cx">         imageCandidates.append(image);
</span><span class=3D"cx">     }
</span><span class=3D"cx">=20
</span><ins>+    if (imageCandidates.isEmpty())
+        return String();
+
</ins><span class=3D"cx">     std::stable_sort(imageCandidates.begin(), i=
mageCandidates.end(), compareByScaleFactor);
</span><span class=3D"cx">=20
</span><span class=3D"cx">     for (size_t i =3D 0; i &lt; imageCandidate=
s.size(); ++i) {
</span><span class=3D"cx">         if (imageCandidates[i].scaleFactor &gt=
;=3D deviceScaleFactor)
</span><span class=3D"cx">             return imageCandidates[i].imageURL=
;
</span><span class=3D"cx">     }
</span><del>-    return String();
</del><ins>+    return imageCandidates.last().imageURL;
</ins><span class=3D"cx"> }
</span><span class=3D"cx">=20
</span><span class=3D"cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>


More information about the webkit-changes mailing list