<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>28076</bug_id>
          
          <creation_ts>2009-08-07 11:32:07 -0700</creation_ts>
          <short_desc>[Qt] fast/images/icon-decoding.html needs results for Qt</short_desc>
          <delta_ts>2014-02-03 03:12:57 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Tools / Tests</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>Qt, QtTriaged</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Peter Kasting">pkasting</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>abecsi</cc>
    
    <cc>hausmann</cc>
    
    <cc>kenneth</cc>
    
    <cc>kent.hansen</cc>
    
    <cc>manyoso</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>138000</commentid>
    <comment_count>0</comment_count>
    <who name="Peter Kasting">pkasting</who>
    <bug_when>2009-08-07 11:32:07 -0700</bug_when>
    <thetext>Patch coming to skip this test for now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>138001</commentid>
    <comment_count>1</comment_count>
      <attachid>34298</attachid>
    <who name="Peter Kasting">pkasting</who>
    <bug_when>2009-08-07 11:33:49 -0700</bug_when>
    <thetext>Created attachment 34298
Add to Skipped list</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>138004</commentid>
    <comment_count>2</comment_count>
      <attachid>34298</attachid>
    <who name="Peter Kasting">pkasting</who>
    <bug_when>2009-08-07 11:38:54 -0700</bug_when>
    <thetext>Comment on attachment 34298
Add to Skipped list

Landed skip update in r46902.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>138618</commentid>
    <comment_count>3</comment_count>
    <who name="Andras Becsi">abecsi</who>
    <bug_when>2009-08-10 01:15:45 -0700</bug_when>
    <thetext>There seems to be a problem with the handling of ico files with multiple entries. I&apos;m working on a solution for this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>139277</commentid>
    <comment_count>4</comment_count>
    <who name="Andras Becsi">abecsi</who>
    <bug_when>2009-08-12 01:55:58 -0700</bug_when>
    <thetext>Here is a patch for qt which corrects the layout test, but the imlementation should be changed higher up in QIcon and QPixmap. This is only an expected behaviour change, which is more compilant to the ICO file format description (http://www.daubnet.com/en/file-format-ico) which says:

&quot;For general purpose ICOs there should be at least one 32x32 image using the 16 Windows colors.&quot;


diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp
index c9e04a4..77c68b7 100644
--- a/src/plugins/imageformats/ico/qicohandler.cpp
+++ b/src/plugins/imageformats/ico/qicohandler.cpp
@@ -802,7 +802,25 @@ bool QtIcoHandler::canRead(QIODevice *device)
 bool QtIcoHandler::read(QImage *image)
 {
     bool bSuccess = false;
-    QImage img = m_pICOReader-&gt;iconAt(m_currentIconIndex);
+
+    QIODevice *d = device();
+
+    QList&lt;QImage&gt; imgs = m_pICOReader-&gt;read(d);
+    QImage img = imgs[m_currentIconIndex];
+    QSize requestedSize(32,32);
+
+    if ( imgs.size() &gt; 1 ){
+
+    // if we have multiple icons in the file we return the first with 32x32 resolution because it is the reference size
+    // FIXME: there should be a proper way of handling all the files in an ICO file higher up in the abstraction
+    //        ie. to fill the caller QIcon with the icons in the ICO file automatically, and let the user decide which to use
+        for ( int i=0; i&lt;imgs.size(); ++i )
+            if ( imgs[i].size() == requestedSize ){
+                img = imgs[i];
+                break;
+            }
+
+    }

     // Make sure we only write to \a image when we succeed.
     if (!img.isNull()) {</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>139377</commentid>
    <comment_count>5</comment_count>
    <who name="Peter Kasting">pkasting</who>
    <bug_when>2009-08-12 10:01:51 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; Here is a patch for qt which corrects the layout test, but the imlementation
&gt; should be changed higher up in QIcon and QPixmap. This is only an expected
&gt; behaviour change, which is more compilant to the ICO file format description
&gt; (http://www.daubnet.com/en/file-format-ico) which says:
&gt; 
&gt; &quot;For general purpose ICOs there should be at least one 32x32 image using the 16
&gt; Windows colors.&quot;

That sentence is advisory, to note that if you only include smaller sizes, Windows has to scale them up, and they look bad.  However, 32x32 is not a &quot;reference&quot; size, and the first such entry found is not necessarily the best.  The layout test is testing that the decoder selects the icon entries in order of largest first, then highest bit depth first after that.  This is similar to how Windows itself behaves, especially on newer versions like Vista and 7, where the &quot;typical&quot; icon size is significantly larger than 32x32.

Note that for some applications (e.g. displaying favicons in a tab or session history list), you probably want to be able to select a 16x16 icon.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>139415</commentid>
    <comment_count>6</comment_count>
    <who name="Andras Becsi">abecsi</who>
    <bug_when>2009-08-12 10:45:58 -0700</bug_when>
    <thetext>&gt; The layout test is testing that the decoder selects the icon entries in order
&gt; of largest first, then highest bit depth first after that.  This is similar to
&gt; how Windows itself behaves, especially on newer versions like Vista and 7,
&gt; where the &quot;typical&quot; icon size is significantly larger than 32x32.
&gt; 
&gt; Note that for some applications (e.g. displaying favicons in a tab or session
&gt; history list), you probably want to be able to select a 16x16 icon.

Thank you very much for the information! I din&apos;t know which is the preferred order of selecting the icons, how ico exactly has to be handled. I will look into that and correct my patch.

According to that the behaviour of the Qt infrastructure is totally wrong, because only the 1st element in the ico file is handed upward to create a QIcon or QPixmap or QImage, and no feature is considered. The only way to handle ICO files correctly is to use QImageLoader an specify how to select the icon. In my opinion at least QIcon sould automatically fill himself with all the icons contained in the ico file, and then select which to retunrt on QIcon::pixmap(...) calls, according to the features and the given arguments. Do you agree?

WebKit converts the images to NativeImagePtr, which is QPixmap* in case of QtWebKit if I am not mistaken, so the information that it was an ico and had more entries is lost. I could write a patch to work around the test in QtWebKit, and to specifically handle ico files, but I think this is not a QtWebKit bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>139424</commentid>
    <comment_count>7</comment_count>
    <who name="Peter Kasting">pkasting</who>
    <bug_when>2009-08-12 10:58:19 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; According to that the behaviour of the Qt infrastructure is totally wrong,
&gt; because only the 1st element in the ico file is handed upward to create a QIcon
&gt; or QPixmap or QImage, and no feature is considered.

If you&apos;re only going to select one image, it should probably be the largest (and highest bit depth).

&gt; In my
&gt; opinion at least QIcon sould automatically fill himself with all the icons
&gt; contained in the ico file, and then select which to retunrt on
&gt; QIcon::pixmap(...) calls, according to the features and the given arguments. Do
&gt; you agree?

I am not familiar with the Qt API, so I can&apos;t comment usefully.  In the abstract, that sounds correct :)

&gt; WebKit converts the images to NativeImagePtr, which is QPixmap* in case of
&gt; QtWebKit if I am not mistaken, so the information that it was an ico and had
&gt; more entries is lost.

Things are only converted to a NativeImagePtr at the time when a client requests a frame at a particular index.  But an outside client can query ImageSource::frameCount() for the number of frames in an image, and then use ImageSource::frameSizeAtIndex() to determine which frame it wants before requesting the actual frame data.

Making this work depends on having your ImageDecoder return the right values for these calls.  If your icon decoder sorts the directory entries by size, and bit depth within size, with the highest quality image first, then callers who blindly grab the first frame will get the highest-quality icon (which is what this layout test is testing), and callers who want to pick an icon can use the functions described above.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>139838</commentid>
    <comment_count>8</comment_count>
    <who name="Andras Becsi">abecsi</who>
    <bug_when>2009-08-13 07:43:12 -0700</bug_when>
    <thetext>I have changed my patch according to pkasting&apos;s explanation. The patch can be found here: http://pastebin.com/f293c5c82</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>198620</commentid>
    <comment_count>9</comment_count>
    <who name="Kent Hansen">kent.hansen</who>
    <bug_when>2010-03-11 07:43:26 -0800</bug_when>
    <thetext>(In reply to comment #8)
&gt; I have changed my patch according to pkasting&apos;s explanation. The patch can be
&gt; found here: http://pastebin.com/f293c5c82

Could you please submit this patch as a merge request at http://qt.gitorious.org if you haven&apos;t already?
Additionally you could create a report at http://bugreports.qt.nokia.com and link to it from here, so the dependency becomes explicit.
Thanks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>225522</commentid>
    <comment_count>10</comment_count>
    <who name="Jesus Sanchez-Palencia">jesus</who>
    <bug_when>2010-05-13 14:58:58 -0700</bug_when>
    <thetext>(In reply to comment #9)
&gt; Could you please submit this patch as a merge request at http://qt.gitorious.org if you haven&apos;t already?
&gt; Additionally you could create a report at http://bugreports.qt.nokia.com and link to it from here, so the dependency becomes explicit.
&gt; Thanks.

Was this done?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>228917</commentid>
    <comment_count>11</comment_count>
    <who name="Andras Becsi">abecsi</who>
    <bug_when>2010-05-21 08:04:23 -0700</bug_when>
    <thetext>(In reply to comment #10)
&gt; (In reply to comment #9)
&gt; &gt; Could you please submit this patch as a merge request at http://qt.gitorious.org if you haven&apos;t already?
&gt; &gt; Additionally you could create a report at http://bugreports.qt.nokia.com and link to it from here, so the dependency becomes explicit.
&gt; &gt; Thanks.
&gt; 
&gt; Was this done?

I had a merge request for this on gitorious but there was ongoing work by Milan Burda on Qt image loader and icon handling already, apparently he wanted this done differently so I didn&apos;t create a bugreport.
Seems that the issue wasn&apos;t resolved, I&apos;ll recheck.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>975012</commentid>
    <comment_count>12</comment_count>
    <who name="Jocelyn Turcotte">jturcotte</who>
    <bug_when>2014-02-03 03:12:57 -0800</bug_when>
    <thetext>=== Bulk closing of Qt bugs ===

If you believe that this bug report is still relevant for a non-Qt port of webkit.org, please re-open it and remove [Qt] from the summary.

If you believe that this is still an important QtWebKit bug, please fill a new report at https://bugreports.qt-project.org and add a link to this issue. See http://qt-project.org/wiki/ReportingBugsInQt for additional guidelines.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>34298</attachid>
            <date>2009-08-07 11:33:49 -0700</date>
            <delta_ts>2009-08-07 11:38:53 -0700</delta_ts>
            <desc>Add to Skipped list</desc>
            <filename>patch</filename>
            <type>text/plain</type>
            <size>1084</size>
            <attacher name="Peter Kasting">pkasting</attacher>
            
              <data encoding="base64">SW5kZXg6IExheW91dFRlc3RzL0NoYW5nZUxvZw0KPT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLS0tIExheW91dFRlc3Rz
L0NoYW5nZUxvZwkocmV2aXNpb24gNDY5MDApCisrKyBMYXlvdXRUZXN0cy9DaGFuZ2VMb2cJKHdv
cmtpbmcgY29weSkKQEAgLTEsMyArMSwxMyBAQAorMjAwOS0wOC0wNyAgUGV0ZXIgS2FzdGluZyAg
PHBrYXN0aW5nQGdvb2dsZS5jb20+CisKKyAgICAgICAgUmV2aWV3ZWQgYnkgTk9CT0RZIChPT1BT
ISkuCisKKyAgICAgICAgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTI4
MDc2CisgICAgICAgIEFkZCBmYXN0L2ltYWdlcy9pY29uLWRlY29kaW5nLmh0bWwgdG8gUXQgc2tp
cCBsaXN0IHVudGlsIGl0IGhhcworICAgICAgICByZXN1bHRzLgorCisgICAgICAgICogcGxhdGZv
cm0vcXQvU2tpcHBlZDoKKwogMjAwOS0wOC0wNyAgTWlrZSBGZW50b24gIDxtaWtlLmZlbnRvbkB0
b3JjaG1vYmlsZS5jb20+CiAKICAgICAgICAgUmV2aWV3ZWQ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