<?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>131486</bug_id>
          
          <creation_ts>2014-04-10 01:51:06 -0700</creation_ts>
          <short_desc>Percentage height on replaced elements is computed wildly incorrectly</short_desc>
          <delta_ts>2014-04-10 01:51:06 -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>New Bugs</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Mac (Intel)</rep_platform>
          <op_sys>OS X 10.9</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Marc Hoyois">marc.hoyois</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>999476</commentid>
    <comment_count>0</comment_count>
      <attachid>229032</attachid>
    <who name="Marc Hoyois">marc.hoyois</who>
    <bug_when>2014-04-10 01:51:06 -0700</bug_when>
    <thetext>Created attachment 229032
Reduced test case

Overview:

Percentage height on non-absolutely positioned replaced elements (like &lt;img&gt;, &lt;video&gt;, &lt;object&gt;, etc.) should be computed relative to the height property of the parent element (replaced elements are just like any other element here). However, WebKit computes it with respect to the parent element&apos;s height OR its vertical padding, whichever is bigger. That makes no sense... By vertical padding I mean &quot;padding-top + padding-bottom&quot;, NOT the padding-box&apos;s height.

Steps to reproduce:

Inspect the attached reduced test case:

&lt;div style=&quot;background-color:red; height:50px; padding-bottom:100px;&quot;&gt;
&lt;img style=&quot;background-color:yellow; width:100%; height:100%;&quot; src=&quot;&quot;&gt;

Here the height of the &lt;img&gt; element should be 50px, but WebKit incorrectly sets it to 100px. You can play around with the numbers and add a padding-top to convince yourself that the height is computed as a percentage of the total vertical padding, provided this is larger than the height.

This bug affects the latest nightly build at the time of this post, and also Safari 7.0.3.

Notes:

1. This affects height only, not width
2. This only affects replaced elements, not ordinary elements like &lt;div&gt;
3. If the replaced element has position:absolute, then the height is correctly computed as a percentage of the parent&apos;s padding-box (in accordance with the spec http://www.w3.org/TR/CSS2/visudet.html)
4. Firefox computes the height correctly in all cases</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>229032</attachid>
            <date>2014-04-10 01:51:06 -0700</date>
            <delta_ts>2014-04-10 01:51:06 -0700</delta_ts>
            <desc>Reduced test case</desc>
            <filename>test.html</filename>
            <type>text/html</type>
            <size>207</size>
            <attacher name="Marc Hoyois">marc.hoyois</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+DTxodG1sPg08aGVhZD4NPC9oZWFkPg08Ym9keT4NPGRpdiBzdHlsZT0i
YmFja2dyb3VuZC1jb2xvcjpyZWQ7aGVpZ2h0OjUwcHg7cGFkZGluZy1ib3R0b206MTAwcHg7Ij4N
PGltZyBzdHlsZT0iYmFja2dyb3VuZC1jb2xvcjp5ZWxsb3c7d2lkdGg6MTAwJTsgaGVpZ2h0OjEw
MCU7IiBzcmM9IiI+DTwvZGl2Pg08L2JvZHk+DTwvaHRtbD4N
</data>

          </attachment>
      

    </bug>

</bugzilla>