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

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>24055</bug_id>
          
          <creation_ts>2013-12-10 18:05:07 +0000</creation_ts>
          <short_desc>&lt;img&gt;: Making &lt;img&gt; processing model text reusable (see comment 5)</short_desc>
          <delta_ts>2019-03-29 20:36:51 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#the-img-element</bug_file_loc>
          <status_whiteboard>blocked on &lt;picture&gt;</status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          <dependson>26144</dependson>
    
    <dependson>26145</dependson>
    
    <dependson>26734</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>annevk</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>d</cc>
    
    <cc>dschulze</cc>
    
    <cc>gphemsley</cc>
    
    <cc>ian</cc>
    
    <cc>jackalmage</cc>
    
    <cc>krit</cc>
    
    <cc>mike</cc>
    
    <cc>roc</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>97414</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-12-10 18:05:07 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/
Multipage: http://www.whatwg.org/C#the-img-element
Complete: http://www.whatwg.org/c#the-img-element
Referrer: 

Comment:
Can we make some of the text here reusable in some way? E.g. notifications
need to support image fetching, including decoding and supporting SVG in the
same manner and using the list of available images. I assume the same goes for
CSS and SVG.

Posted from: 207.218.72.65
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1729.3 Safari/537.36</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97430</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-12-10 23:10:04 +0000</bug_when>
    <thetext>I don&apos;t know. The &lt;img&gt; behaviour is pretty wacked. I agree that SVG and CSS probably want to use some common rules, but I don&apos;t know if &lt;img&gt; is where I&apos;d take it from. Even &lt;input type=image&gt; doesn&apos;t reuse &lt;img&gt; logic.

There are other things in HTML that could reuse the same logic as SVG and CSS if there was common prose, e.g. icon=&quot;&quot; (which is currently underdefined IIRC).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97451</commentid>
    <comment_count>2</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2013-12-11 14:42:54 +0000</bug_when>
    <thetext>It seems type=image has a bug therefore. I&apos;m pretty sure browsers have the &quot;list of available images&quot; hack in place there too.

Also, where did the text go about first checking if the image is SVG through its Content-Type header and then sniffing? That&apos;s no longer covered it seems and is something we want to share.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97454</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-12-11 17:01:18 +0000</bug_when>
    <thetext>That&apos;s in mimesniff.spec.whatwg.org, I think.

It&apos;s quite possible that &lt;input type=image&gt; has bugs, yeah.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97533</commentid>
    <comment_count>4</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-12-12 21:04:22 +0000</bug_when>
    <thetext>I&apos;m not sure what to do for this bug. Do you have a concrete proposal?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97585</commentid>
    <comment_count>5</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2013-12-13 12:50:35 +0000</bug_when>
    <thetext>I think some kind of wrapper for fetch named &quot;image fetch&quot; that takes into account &quot;list of available images&quot;. Then some kind of shorthand for getting an image out of the retrieved resource and maybe an algorithm that wraps the whole thing if we don&apos;t need much variety among icons/notifications/CSS/SVG for this.

mimesniff does not seem to deal with Content-Type saying image/svg+xml at the moment.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97753</commentid>
    <comment_count>6</comment_count>
    <who name="Gordon P. Hemsley">gphemsley</who>
    <bug_when>2013-12-17 18:28:56 +0000</bug_when>
    <thetext>The SVG MIME type is an XML type, so it is not treated specially.

Is there something you&apos;d like me to change in mimesniff?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98138</commentid>
    <comment_count>7</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-01-08 17:40:41 +0000</bug_when>
    <thetext>Well, in the image context you need to not pass the image to the bitmap decoders if that is the specified (not sniffed) MIME type. Otherwise the MIME type is ignored and it will be passed to the bitmap decoders. At some point that information was present in either HTML or MIME Sniffing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98175</commentid>
    <comment_count>8</comment_count>
    <who name="Gordon P. Hemsley">gphemsley</who>
    <bug_when>2014-01-09 03:01:32 +0000</bug_when>
    <thetext>(In reply to Anne from comment #7)
&gt; Well, in the image context you need to not pass the image to the bitmap
&gt; decoders if that is the specified (not sniffed) MIME type. Otherwise the
&gt; MIME type is ignored and it will be passed to the bitmap decoders. At some
&gt; point that information was present in either HTML or MIME Sniffing.

I&apos;m not sure I understand what you&apos;re asking of me. Currently, mimesniff only dictates how to determine the type of a file; it doesn&apos;t say anything about how to parse the file once that determination is made. In the case of SVG, if a file is tagged as image/svg+xml, that is assumed to be correct and no further sniffing is done.

Can you point to a particular section of mimesniff that you think describes incorrect behavior?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98452</commentid>
    <comment_count>9</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-01-14 19:27:58 +0000</bug_when>
    <thetext>So what are the places that should use the &quot;list of available images&quot; and related terminology? &lt;input type=image&gt; and &lt;img&gt;, and what else? What other specs have editors who are actually willing to reference this?

I&apos;d rather punt on this for a while if nobody&apos;s actually going to use this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98482</commentid>
    <comment_count>10</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-01-15 09:36:01 +0000</bug_when>
    <thetext>As far as I know CSS and SVG need this. Notifications API needs this. Browsers have one code path for dealing with image loading and decoding as I understand it.

If they would not reference a central &quot;image fetch &amp; decode&quot; algorithm those specifications would be telling lies.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98527</commentid>
    <comment_count>11</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-01-15 22:21:25 +0000</bug_when>
    <thetext>So you&apos;re planning on using this in http://notifications.spec.whatwg.org/ ?

I entirely agree that this should happen eventually, I&apos;m just trying to work out how to prioritise it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98562</commentid>
    <comment_count>12</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-01-16 10:48:16 +0000</bug_when>
    <thetext>Yes I would use it there. It&apos;s not high priority for me at all.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98811</commentid>
    <comment_count>13</comment_count>
    <who name="Gordon P. Hemsley">gphemsley</who>
    <bug_when>2014-01-21 03:02:23 +0000</bug_when>
    <thetext>Anne has suggested to me that, in an image context, only &quot;image/svg+xml&quot; is treated as canonical; other XML types are sniffed for image-ness. (I haven&apos;t tested this to confirm.)

It seems that the lack of this distinction in the mimesniff spec is the result of a misunderstanding on my part of the original text.

The offending change is here (dated 2012-11-03):

https://github.com/whatwg/mimesniff/commit/24098021f526233ad5ba7f69eaf387b696b7032a#diff-1feda49b40370635faef8b655f144f64L1601

The original text read (using the terminology and context):

&quot;&quot;&quot;
  If the &lt;var&gt;official-type&lt;/var&gt; is &quot;image/svg+xml&quot;, then let the
  &lt;var&gt;sniffed-type&lt;/var&gt; be the &lt;var&gt;official-type&lt;/var&gt; (an XML type) and
  abort these steps.
&quot;&quot;&quot;

This got changed to the following when the pattern matching algorithm was factored out:

&quot;&quot;&quot;
   If the &lt;span&gt;supplied media type&lt;/span&gt; is an &lt;span&gt;XML type&lt;/span&gt;, the
   &lt;span&gt;sniffed media type&lt;/span&gt; is the &lt;span&gt;supplied media type&lt;/span&gt;.

   Abort these steps.
&quot;&quot;&quot;

This step currently reads:

&quot;&quot;&quot;
   If the &lt;span&gt;supplied MIME type&lt;/span&gt; is an &lt;span&gt;XML type&lt;/span&gt;, the
   &lt;span&gt;sniffed MIME type&lt;/span&gt; is the &lt;span&gt;supplied MIME type&lt;/span&gt;.

   Abort these steps.
&quot;&quot;&quot;

If I understand correctly, this should be changed to read something along the lines of the following:

&quot;&quot;&quot;
   If the &lt;span&gt;supplied MIME type&lt;/span&gt; is &quot;&lt;code title&gt;image/svg+xml&lt;/code&gt;&quot; (an &lt;span&gt;XML type&lt;/span&gt;), the
   &lt;span&gt;sniffed MIME type&lt;/span&gt; is the &lt;span&gt;supplied MIME type&lt;/span&gt;.

   Abort these steps.
&quot;&quot;&quot;

Anne, is this the sort of change you are looking for?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98817</commentid>
    <comment_count>14</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-01-21 08:42:22 +0000</bug_when>
    <thetext>I&apos;m not Anne but that looks right to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100046</commentid>
    <comment_count>15</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-02-07 18:25:42 +0000</bug_when>
    <thetext>The idea back when this was in the HTML spec was that image/* would be processed as image, and then I had to explicitly carve out image/*+xml. I don&apos;t recall ever having an explicit test for image/svg+xml. But I could be wrong.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103710</commentid>
    <comment_count>16</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-04-10 22:06:26 +0000</bug_when>
    <thetext>Do the people who want to reuse this also want to reuse the &lt;img&gt; two-loads-in-parallel logic that browsers apparently do? (q.v. bug 24711 comment 20)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103725</commentid>
    <comment_count>17</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-04-11 08:40:32 +0000</bug_when>
    <thetext>Is that logic used for CSS background-image, SVG &lt;image&gt;, etc. too? Because if so, yes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103780</commentid>
    <comment_count>18</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-04-11 20:23:19 +0000</bug_when>
    <thetext>I&apos;ve no idea.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104908</commentid>
    <comment_count>19</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-05-01 12:53:51 +0000</bug_when>
    <thetext>*** Bug 22422 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106951</commentid>
    <comment_count>20</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-05-28 22:14:09 +0000</bug_when>
    <thetext>zcorpan, sending this to you so you can keep this in mind when doing edits. Don&apos;t worry about it if you don&apos;t want to actually do it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107924</commentid>
    <comment_count>21</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-06-17 09:18:06 +0000</bug_when>
    <thetext>SVG/CSS makes this harder. They have some constructs (&lt;feImage&gt;, &apos;mask&apos;) where a URL either references an element or an image. This can be just a fragment identifier for the element case. But somehow they probably end up using most of the same image logic as we do elsewhere.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107958</commentid>
    <comment_count>22</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-06-17 17:49:08 +0000</bug_when>
    <thetext>We might be able to refactor the cases in comment 21 to only do a fetch for an image (and handle external elements with different syntax).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108058</commentid>
    <comment_count>23</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-06-19 09:26:41 +0000</bug_when>
    <thetext>From annevk
[[
SVG in general wants to use that algorithm also for masks and paint servers and such
so the basic algorithm should probably either return an XML tree or an image
or failure
and the XML tree is only when the MIME type is image/svg+xml
and with scripting disabled
]]</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108071</commentid>
    <comment_count>24</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-06-19 12:48:44 +0000</bug_when>
    <thetext>Hrm.  SVG paint server caching rules are not the same as image caching rules (e.g. the former is cached per display document but the latter is cached per document), no?  They also have different restrictions in terms of same-origin requirements, as I recall.  I&apos;m not sure how similar the two cases really end up being.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108072</commentid>
    <comment_count>25</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-06-19 12:51:48 +0000</bug_when>
    <thetext>We want e.g. &apos;mask&apos; to support both images and SVG local and external &lt;mask&gt; elements without upfront distinction in code path.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108073</commentid>
    <comment_count>26</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-06-19 12:54:29 +0000</bug_when>
    <thetext>I distinctly recall there being spec discussion about UAs needing to know before starting the load whether they&apos;re doing one that follows the image rules or the SVG external resource rules.  Did that actually get resolved?  Because in practice those rules are _very_ different.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108074</commentid>
    <comment_count>27</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-06-19 12:59:08 +0000</bug_when>
    <thetext>Well, when I discussed it with roc yesterday we came to the same conclusion we came a year ago as to how to harmonize those rules. Of course, we could be missing something. But the idea was to apply the same restrictions to external elements as are applied to images today (e.g. we would start forbidding application/xml responses).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108075</commentid>
    <comment_count>28</comment_count>
    <who name="Robert O&apos;Callahan (Mozilla)">roc</who>
    <bug_when>2014-06-19 13:22:17 +0000</bug_when>
    <thetext>(In reply to Boris Zbarsky from comment #24)
&gt; Hrm.  SVG paint server caching rules are not the same as image caching rules
&gt; (e.g. the former is cached per display document but the latter is cached per
&gt; document), no?  They also have different restrictions in terms of
&gt; same-origin requirements, as I recall.  I&apos;m not sure how similar the two
&gt; cases really end up being.

Gecko currently implements them quite differently. I&apos;m proposing we change that both in specs and implementation to always use the image load behavior. Given that Webkit/Blink don&apos;t implement external resource loads at all (not sure about IE) I don&apos;t think we need to worry much about compatibility.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108076</commentid>
    <comment_count>29</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-06-19 14:10:59 +0000</bug_when>
    <thetext>Using the image load behavior (with per-document, not per-display-document caching) for external resources can easily lead to infinite load graphs when two external resource documents cross-reference each other.  Note that images don&apos;t have that problem, since we disallow external loads from SVG images.  Is the plan to forbid external loads from externally loaded paint servers as well, then?

If we don&apos;t plan to forbid that, we could move move to per-display-document caching for images and paint servers, which would help the cross-referencing situation, but then we can&apos;t share the same SVG image across multiple loading documents, since it needs to have a concept of unique &quot;display document&quot; it&apos;s associated with...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108077</commentid>
    <comment_count>30</comment_count>
    <who name="Dirk Schulze">dschulze</who>
    <bug_when>2014-06-19 14:32:41 +0000</bug_when>
    <thetext>(In reply to Boris Zbarsky from comment #29)
&gt; Using the image load behavior (with per-document, not per-display-document
&gt; caching) for external resources can easily lead to infinite load graphs when
&gt; two external resource documents cross-reference each other.  Note that
&gt; images don&apos;t have that problem, since we disallow external loads from SVG
&gt; images.  Is the plan to forbid external loads from externally loaded paint
&gt; servers as well, then?

Yes, that is what we plan. The exact same fetching model for external SVG resources (element references) and images. Including a restriction on loading further external resources.

Does this address you concerns?

&gt; 
&gt; If we don&apos;t plan to forbid that, we could move move to per-display-document
&gt; caching for images and paint servers, which would help the cross-referencing
&gt; situation, but then we can&apos;t share the same SVG image across multiple
&gt; loading documents, since it needs to have a concept of unique &quot;display
&gt; document&quot; it&apos;s associated with...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108078</commentid>
    <comment_count>31</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-06-19 14:46:28 +0000</bug_when>
    <thetext>Mostly, yes!

The only remaining concern I have is that the image cache, afaik, is a best-effort cache (in the sense that it can be cleared or just generally evicted) while the external resource thing is persistent over document lifetime (per spec and in Gecko&apos;s implementation).  I guess we could change that latter behavior, though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108100</commentid>
    <comment_count>32</comment_count>
    <who name="Robert O&apos;Callahan (Mozilla)">roc</who>
    <bug_when>2014-06-19 23:42:54 +0000</bug_when>
    <thetext>(In reply to Boris Zbarsky from comment #31)
&gt; The only remaining concern I have is that the image cache, afaik, is a
&gt; best-effort cache (in the sense that it can be cleared or just generally
&gt; evicted) while the external resource thing is persistent over document
&gt; lifetime (per spec and in Gecko&apos;s implementation).  I guess we could change
&gt; that latter behavior, though.

Yes, we&apos;d change that too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124081</commentid>
    <comment_count>33</comment_count>
      <attachid>1626</attachid>
    <who name="">rycowman2015</who>
    <bug_when>2015-11-04 16:30:41 +0000</bug_when>
    <thetext>Created attachment 1626
Check this out</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124147</commentid>
    <comment_count>34</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2015-11-10 01:14:32 +0000</bug_when>
    <thetext>The content of attachment 1626 has been deleted</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129679</commentid>
    <comment_count>35</comment_count>
    <who name="Domenic Denicola">d</who>
    <bug_when>2019-03-29 20:36:51 +0000</bug_when>
    <thetext>https://github.com/whatwg/html/issues/4474</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="0"
              isprivate="0"
          >
            <attachid>1626</attachid>
            <date>2015-11-04 16:30:41 +0000</date>
            <delta_ts>2015-11-04 16:30:41 +0000</delta_ts>
            <desc>Check this out</desc>
            <filename>widevinecdmadapter.dll</filename>
            <type>text/plain</type>
            <size>0</size>
            <attacher>rycowman2015</attacher>
            
              <data encoding="base64"></data>

          </attachment>
      

    </bug>

</bugzilla>