<?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>94077</bug_id>
          
          <creation_ts>2012-08-15 01:07:33 -0700</creation_ts>
          <short_desc>Width and height is ignored in the image element&apos;s UA shadow DOM</short_desc>
          <delta_ts>2019-10-04 22:16:09 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>DOM</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>12250</blocked>
    
    <blocked>82313</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Ryosuke Niwa">rniwa</reporter>
          <assigned_to name="Web Components Team">webcomponents-bugzilla</assigned_to>
          <cc>dglazkov</cc>
    
    <cc>dominicc</cc>
    
    <cc>esprehn</cc>
    
    <cc>morrita</cc>
    
    <cc>shinyak</cc>
    
    <cc>tabatkins</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>695812</commentid>
    <comment_count>0</comment_count>
      <attachid>158520</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-08-15 01:07:33 -0700</bug_when>
    <thetext>Created attachment 158520
demo

It appears that the UA shadow DOM doesn&apos;t reflect width and height of the image element so that setting those values doesn&apos;t change the intrinsic width and height of the image in the shadow element.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>695814</commentid>
    <comment_count>1</comment_count>
      <attachid>158521</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-08-15 01:09:04 -0700</bug_when>
    <thetext>Created attachment 158521
expected result

Oops, I just realized that these two files load icon.png so please place http://trac.webkit.org/chrome/site/icon.png in the same directory.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>695815</commentid>
    <comment_count>2</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-08-15 01:11:44 -0700</bug_when>
    <thetext>Arguably, the shadow content shouldn&apos;t be inhering the style of the host but for replaced elements, it&apos;s quite crucial for it to have the intrinsic width IMO.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>695839</commentid>
    <comment_count>3</comment_count>
    <who name="Shinya Kawanaka">shinyak</who>
    <bug_when>2012-08-15 01:57:11 -0700</bug_when>
    <thetext>I think we should discuss this more.

img.style.width = &apos;500px&apos; sets only the width of an img element literally, and it is not setting the inner element of the img element. If img.style.wdith = &apos;500px&apos; sets the width of inner image element, we don&apos;t have any method to set the width of image element itself.

I&apos;m not sure what is the best way to set the style of inner element. I&apos;ve filed a bug in the spec before...
https://www.w3.org/Bugs/Public/show_bug.cgi?id=18435

Anyway, we can use ::-webkit-image-inner-element now...though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>696100</commentid>
    <comment_count>4</comment_count>
    <who name="Dimitri Glazkov (Google)">dglazkov</who>
    <bug_when>2012-08-15 10:22:08 -0700</bug_when>
    <thetext>I agree, this is a problem. Need to talk to Tab about this and figure out the best way to fix this. The inner image needs to be this weird thing that always balloons to fill up the entire parent box. We don&apos;t have anything like this in normal CSS.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>696271</commentid>
    <comment_count>5</comment_count>
    <who name="Tab Atkins">tabatkins</who>
    <bug_when>2012-08-15 12:35:43 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; I agree, this is a problem. Need to talk to Tab about this and figure out the best way to fix this. The inner image needs to be this weird thing that always balloons to fill up the entire parent box. We don&apos;t have anything like this in normal CSS.

I think you want &quot;width/height: fill-available;&quot; &lt;http://dev.w3.org/csswg/css3-sizing/#width-height-keywords&gt;, right?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>696273</commentid>
    <comment_count>6</comment_count>
    <who name="Tab Atkins">tabatkins</who>
    <bug_when>2012-08-15 12:36:25 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; (In reply to comment #4)
&gt; &gt; I agree, this is a problem. Need to talk to Tab about this and figure out the best way to fix this. The inner image needs to be this weird thing that always balloons to fill up the entire parent box. We don&apos;t have anything like this in normal CSS.
&gt; 
&gt; I think you want &quot;width/height: fill-available;&quot; &lt;http://dev.w3.org/csswg/css3-sizing/#width-height-keywords&gt;, right?

If so, esprehn is already working on this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>696279</commentid>
    <comment_count>7</comment_count>
    <who name="Dimitri Glazkov (Google)">dglazkov</who>
    <bug_when>2012-08-15 12:37:48 -0700</bug_when>
    <thetext>Tab, I &lt;3 you. Elliot, I will &lt;3 as soon as you land this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>696310</commentid>
    <comment_count>8</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-08-15 13:23:39 -0700</bug_when>
    <thetext>It&apos;s not simple as that. When you specify width, img&apos;s height should also change due to the intrinsic aspect ratio it has. However, this won&apos;t happen in a non-replaced render object (i.e. when img has a shadow DOM) so filling up the available space doesn&apos;t solve the problem. We need the shadow-ed img element&apos;s width and height to behave like the original img.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>696311</commentid>
    <comment_count>9</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-08-15 13:25:33 -0700</bug_when>
    <thetext>i.e. img&apos;s original intrinsic width, height, and aspect ratio needs to be propagated to the shadow content.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>696605</commentid>
    <comment_count>10</comment_count>
    <who name="Shinya Kawanaka">shinyak</who>
    <bug_when>2012-08-15 18:40:54 -0700</bug_when>
    <thetext>(In reply to comment #8)
&gt; It&apos;s not simple as that. When you specify width, img&apos;s height should also change due to the intrinsic aspect ratio it has. However, this won&apos;t happen in a non-replaced render object (i.e. when img has a shadow DOM) so filling up the available space doesn&apos;t solve the problem. We need the shadow-ed img element&apos;s width and height to behave like the original img.

Right. Filling up the available space doesn&apos;t solve the problem.

We have to care about that the width/height of &lt;img&gt; and the width/height of the inner element of &lt;img&gt; are different. Basically the inner element should fill the the host element, however as I said, we have to have some method to specify the style of the inner element.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>697460</commentid>
    <comment_count>11</comment_count>
    <who name="Dimitri Glazkov (Google)">dglazkov</who>
    <bug_when>2012-08-16 13:38:37 -0700</bug_when>
    <thetext>(In reply to comment #10)
&gt; (In reply to comment #8)
&gt; &gt; It&apos;s not simple as that. When you specify width, img&apos;s height should also change due to the intrinsic aspect ratio it has. However, this won&apos;t happen in a non-replaced render object (i.e. when img has a shadow DOM) so filling up the available space doesn&apos;t solve the problem. We need the shadow-ed img element&apos;s width and height to behave like the original img.
&gt; 
&gt; Right. Filling up the available space doesn&apos;t solve the problem.
&gt; 
&gt; We have to care about that the width/height of &lt;img&gt; and the width/height of the inner element of &lt;img&gt; are different. Basically the inner element should fill the the host element, however as I said, we have to have some method to specify the style of the inner element.

I understand. If you guys have any good ideas, please post them on the spec bug. I will try to tackle this early next week.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>697491</commentid>
    <comment_count>12</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-08-16 14:01:03 -0700</bug_when>
    <thetext>The problem might be even trickier. What if someone specified width/height on the shadow element?

e.g.
&lt;img src=&quot;myAwesomeImage.png&quot;&gt;
&lt;script&gt;
var img = document.querySelector(&apos;img&apos;);
var root = new ShadowRoot(img);
root.appendChild(document.createElement(&apos;shadow&apos;));
img.style.width = &apos;100px&apos;;
img.style.height = &apos;200px&apos;;
root.firstChidld.style.width = &apos;200px&apos;;
&lt;/script&gt;

where myAwesomeImage.png has the aspect ratio of 1 to 1.5 (width to height).

Should the image be 100px width or 200px width? What should the height of the image be? 200px as specified in the light DOM or 150px given the aspect ratio?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>697493</commentid>
    <comment_count>13</comment_count>
    <who name="Dimitri Glazkov (Google)">dglazkov</who>
    <bug_when>2012-08-16 14:03:02 -0700</bug_when>
    <thetext>(In reply to comment #12)
&gt; The problem might be even trickier. What if someone specified width/height on the shadow element?
&gt; 
&gt; e.g.
&gt; &lt;img src=&quot;myAwesomeImage.png&quot;&gt;
&gt; &lt;script&gt;
&gt; var img = document.querySelector(&apos;img&apos;);
&gt; var root = new ShadowRoot(img);
&gt; root.appendChild(document.createElement(&apos;shadow&apos;));
&gt; img.style.width = &apos;100px&apos;;
&gt; img.style.height = &apos;200px&apos;;
&gt; root.firstChidld.style.width = &apos;200px&apos;;

This line sets style.width on &lt;shadow&gt;, which isn&apos;t rendered. It&apos;s a no-op, effectively.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>697537</commentid>
    <comment_count>14</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-08-16 14:45:11 -0700</bug_when>
    <thetext>(In reply to comment #13)
&gt; (In reply to comment #12)
&gt; &gt; The problem might be even trickier. What if someone specified width/height on the shadow element?
&gt; &gt; 
&gt; &gt; e.g.
&gt; &gt; &lt;img src=&quot;myAwesomeImage.png&quot;&gt;
&gt; &gt; &lt;script&gt;
&gt; &gt; var img = document.querySelector(&apos;img&apos;);
&gt; &gt; var root = new ShadowRoot(img);
&gt; &gt; root.appendChild(document.createElement(&apos;shadow&apos;));
&gt; &gt; img.style.width = &apos;100px&apos;;
&gt; &gt; img.style.height = &apos;200px&apos;;
&gt; &gt; root.firstChidld.style.width = &apos;200px&apos;;
&gt; 
&gt; This line sets style.width on &lt;shadow&gt;, which isn&apos;t rendered. It&apos;s a no-op, effectively.

Ah, I see. I misunderstood what shadow element does. Thanks for the clarification. However, it&apos;s somewhat inconvenient that we can&apos;t change the width &amp; the height of the original content in the shadow DOM.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1577143</commentid>
    <comment_count>15</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-10-04 22:16:09 -0700</bug_when>
    <thetext>We&apos;re not gonna do this.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>158520</attachid>
            <date>2012-08-15 01:07:33 -0700</date>
            <delta_ts>2012-08-15 01:07:33 -0700</delta_ts>
            <desc>demo</desc>
            <filename>editable-content-with-img.html</filename>
            <type>text/html</type>
            <size>263</size>
            <attacher name="Ryosuke Niwa">rniwa</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8Ym9keT4KPGRpdiBjb250ZW50ZWRpdGFibGU+aGVsbG8g
d29ybGQuIDxpbWcgc3JjPSJpY29uLnBuZyI+PC9kaXY+CjxzY3JpcHQ+Cgp2YXIgaW1nID0gZG9j
dW1lbnQucXVlcnlTZWxlY3RvcignaW1nJyk7CmltZy5zdHlsZS53aWR0aCA9ICc1MDBweCc7CnZh
ciByb290ID0gbmV3IFdlYktpdFNoYWRvd1Jvb3QoaW1nKTsKcm9vdC5pbm5lckhUTUwgPSAnPHNo
YWRvdz4nOwoKPC9zY3JpcHQ+CjwvYm9keT4KPC9odG1sPgo=
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>158521</attachid>
            <date>2012-08-15 01:09:04 -0700</date>
            <delta_ts>2012-08-15 01:09:04 -0700</delta_ts>
            <desc>expected result</desc>
            <filename>editable-content-with-img.html</filename>
            <type>text/html</type>
            <size>267</size>
            <attacher name="Ryosuke Niwa">rniwa</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8Ym9keT4KPGRpdiBjb250ZW50ZWRpdGFibGU+aGVsbG8g
d29ybGQuIDxpbWcgc3JjPSJpY29uLnBuZyI+PC9kaXY+CjxzY3JpcHQ+Cgp2YXIgaW1nID0gZG9j
dW1lbnQucXVlcnlTZWxlY3RvcignaW1nJyk7CmltZy5zdHlsZS53aWR0aCA9ICc1MDBweCc7Ci8v
dmFyIHJvb3QgPSBuZXcgV2ViS2l0U2hhZG93Um9vdChpbWcpOwovL3Jvb3QuaW5uZXJIVE1MID0g
JzxzaGFkb3c+JzsKCjwvc2NyaXB0Pgo8L2JvZHk+CjwvaHRtbD4K
</data>

          </attachment>
      

    </bug>

</bugzilla>