<?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>157293</bug_id>
          
          <creation_ts>2016-05-02 19:10:40 -0700</creation_ts>
          <short_desc>Element with &quot;font-size: 0; overflow: hidden;&quot; is not fitted to the parent.</short_desc>
          <delta_ts>2016-06-08 11:44:12 -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>Layout and Rendering</component>
          <version>Safari 9</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</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="Eunmi Lee">enmi.lee</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>mackyle</cc>
    
    <cc>mmaxfield</cc>
    
    <cc>simon.fraser</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1189627</commentid>
    <comment_count>0</comment_count>
      <attachid>277960</attachid>
    <who name="Eunmi Lee">enmi.lee</who>
    <bug_when>2016-05-02 19:10:40 -0700</bug_when>
    <thetext>Created attachment 277960
simple test page

Element with &quot;font-size: 0&quot; is layout with top margin in the many browsers (ie, chrome, safari, firefox..),
and front-end developer can remove top margin by adding that element to the &quot;overflow: hidden&quot; element,
but it is not efficacious only in the safari browser.

chrome and safari results and test html are attached.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1189628</commentid>
    <comment_count>1</comment_count>
      <attachid>277961</attachid>
    <who name="Eunmi Lee">enmi.lee</who>
    <bug_when>2016-05-02 19:11:21 -0700</bug_when>
    <thetext>Created attachment 277961
result image</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1189788</commentid>
    <comment_count>2</comment_count>
      <attachid>278007</attachid>
    <who name="Myles C. Maxfield">mmaxfield</who>
    <bug_when>2016-05-03 10:07:51 -0700</bug_when>
    <thetext>Created attachment 278007
Slightly more reduced test case</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1189794</commentid>
    <comment_count>3</comment_count>
    <who name="Myles C. Maxfield">mmaxfield</who>
    <bug_when>2016-05-03 10:36:11 -0700</bug_when>
    <thetext>The slightly more reduced test case is invalid - it renders the same in other browsers as in Safari.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1189808</commentid>
    <comment_count>4</comment_count>
    <who name="Myles C. Maxfield">mmaxfield</who>
    <bug_when>2016-05-03 11:31:17 -0700</bug_when>
    <thetext>Let me explain what is going on here.

There are two pieces of information which are important here:

1. The CSS 2.1 spec [1] says: &quot;The baseline of an &apos;inline-block&apos; is the baseline of its last line box in the normal flow, unless it has either no in-flow line boxes or if its &apos;overflow&apos; property has a computed value other than &apos;visible&apos;, in which case the baseline is the bottom margin edge.”

Other browsers implement this behavior described above.

2. When placing inline elements inside a block element, we first calculate where the baseline of the entire line of inline elements should be (which is equal to the maximum ascent of all the elements in the line). Then, we calculate where the baseline of each inline element is, and we place all the baselines vertically on top of each other.

-----------------------------------

So, let&apos;s break it down: we have three divs. The outer one (#header) has a height of 45px, and a width of 100%. It doesn&apos;t have a font-family or font-size specified, so it defaults to 16px Times. This font (16px Times) has an ascent of 14px and a descent of 4px.

Inside, we have #wrapper, which is display: inline-block, and has overflow: hidden. Therefore, according to the spec, and because #wrapper has overflow: hidden, the baseline of #wrapper is its bottom margin edge. Because #wrapper is the only thing inside #header, the baseline for the first line of #header is therefore calculated to be at the bottom margin edge of #wrapper (which is 45px downward from the top). Therefore, when we align the baselines, the entire #wrapper is sitting on top of the baseline.

(An interesting side effect of this is that the first line of #header still has a 4px descent (below the baseline) because of that 16px Times font used. However, you don&apos;t see it in the example because the height of #header is explicitly set to 45px. Therefore, if there were any text inside #header, you would see the bottoms of the letters drop down below #wrapper)

Okay, so now let&apos;s consider #icon. This is an inline-block element without overflow: hidden, which means, according to the spec, its baseline is the baseline of its last line box. Its last line box comes from that &quot;A&quot; character inside it. That &quot;A&quot; character, however, has a font-size of 0px, which means that it lies all the way in the top left corner of #icon (but it&apos;s so small you don&apos;t see it). Therefore, the baseline of #icon lies at its very top.

The last piece remaining is how #icon gets placed within #wrapper. This placement follows the same logic as before - we line up the baseline of the first line of #wrapper with the baseline of #icon. We know that the baseline of #icon is at its very top. Because the font-size of #wrapper is 0px, and its only content is #icon, so the first line of #wrapper has a baseline at its very top. Placing these two baselines on top of each other makes #icon appear at the very top of #wrapper.

So, when all of this is done, the baseline of the first line of #header is at 45px (downward from the top); the baseline of the first line of #wrapper is at 0px from the top, and the baseline of the first line of #icon is at 0px from the top.

That is how the spec describes this, and that is what the other browsers do.

-----------------------------------

WebKit purposely does not implement the spec (as it appears above). We believe that putting overflow: hidden on #wrapper should not put its baseline at its bottom edge. Instead, we believe that a better behavior is to put #wrapper&apos;s baseline at the baseline of its last line box (which would come from the baseline of #icon, which is at 0px from its top).

In this situation, almost all of the above discussion is still valid. However, because we place #wrapper&apos;s baseline 0px from its top, this means that the baseline of the first line of #header is now at 14px (which is the ascent of the 16px Times font used inside it). Then, we align this baseline with the baseline of #wrapper (which is at its top edge), which leads to the 14px gap you saw in your screenshot.

This is rendering as we expect.

-----------------------------------

You are right, however, that there is a difference in rendering between other browsers and WebKit. Interoperability is definitely one of WebKit&apos;s goals. However, we feel strongly enough about this new baseline placement behavior that we (I) have petitioned successfully to have the spec changed. You can read more about it at [2], and you can see that the proposal was accepted at [3]. Therefore, other browsers will adopt this behavior in the future (hopefully soon!).

-----------------------------------

There are a few ways to adapt to this content to the new inline-block placement scheme. The most straightforward one is to style #header with font-size: 0px. Another one is to style #header with position: relative and style #wrapper with position: absolute. Another one is to use flexbox. Another one is to remove the font-size: 0px from all the divs, and wrap the &quot;A&quot; in a span and style the span with font-size: 0px. Or, you could use the same approach and style the span with display: none.

[1] http://www.w3.org/TR/CSS21/visudet.html#leading
[2] https://lists.w3.org/Archives/Public/www-style/2015Mar/0342.html
[3] https://lists.w3.org/Archives/Public/www-style/2015Apr/0144.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1200520</commentid>
    <comment_count>5</comment_count>
    <who name="Myles C. Maxfield">mmaxfield</who>
    <bug_when>2016-06-08 11:44:12 -0700</bug_when>
    <thetext>*** Bug 36084 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>277960</attachid>
            <date>2016-05-02 19:10:40 -0700</date>
            <delta_ts>2016-05-02 19:10:40 -0700</delta_ts>
            <desc>simple test page</desc>
            <filename>overflow-hidden-font-size-0.html</filename>
            <type>text/html</type>
            <size>498</size>
            <attacher name="Eunmi Lee">enmi.lee</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8aGVhZD4KPG1ldGEgaHR0cC1lcXVpdj0iQ29udGVudC1U
eXBlIiBjb250ZW50PSJ0ZXh0L2h0bWw7IGNoYXJzZXQ9VVRGLTgiIC8+CjxzdHlsZT4KI2hlYWRl
ciB7CgloZWlnaHQ6IDQ1cHg7Cgl3aWR0aDogMTAwJTsKCWJhY2tncm91bmQtY29sb3I6ICMwMGM3
M2M7Cn0KI3dyYXBwZXIgewoJZGlzcGxheTogaW5saW5lLWJsb2NrOwoJd2lkdGg6IDQ1cHg7Cglo
ZWlnaHQ6IDQ1cHg7Cglmb250LXNpemU6IDA7CglvdmVyZmxvdzogaGlkZGVuOwp9CiNpY29uIHsK
CWRpc3BsYXk6IGlubGluZS1ibG9jazsKCXdpZHRoOiA0NXB4OwoJaGVpZ2h0OiA0NXB4OwoJZm9u
dC1zaXplOiAwOwoJYmFja2dyb3VuZC1jb2xvcjogYmx1ZTsKfQo8L3N0eWxlPgo8L2hlYWQ+Cjxi
b2R5Pgo8ZGl2IGlkPSJoZWFkZXIiPgoJPGRpdiBpZD0id3JhcHBlciI+CgkJPGRpdiBpZD0iaWNv
biI+QTwvZGl2PgoJPC9kaXY+CjwvZGl2Pgo8L2JvZHk+CjwvaHRtbD4K
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>277961</attachid>
            <date>2016-05-02 19:11:21 -0700</date>
            <delta_ts>2016-05-02 19:11:21 -0700</delta_ts>
            <desc>result image</desc>
            <filename>compare_results.png</filename>
            <type>image/png</type>
            <size>2054</size>
            <attacher name="Eunmi Lee">enmi.lee</attacher>
            
              <data encoding="base64">iVBORw0KGgoAAAANSUhEUgAAAc0AAACECAIAAAB9B+daAAAAAXNSR0IArs4c6QAAAARnQU1BAACx
jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAebSURBVHhe7drhbey4GQVQ17VIPU4N6cKt5M8D
UkFqCF4LCbAdvEj2NyOKHHrHojnk6J2DC+yMLcmyfH3hXezL//71j4/8+c+/i6T5BXyHl/jn4r//
EdkF+A52VuoBvoOdlXqA72BnpR7gO9hZqQf4DsnOAtCBnQXoq7qzLy9z5N9/k1GJKgBt7KxUE1UA
2thZqSaqMIfs3kQelqhgAzsr1UQV5pDdm8jDEhVsYGelmqjCHLJ7E3lYooIN7KxUE1WYQ3ZvIg9L
VLCBnZVqogpzyO5N5GGJCjaws1JNVGEO2b2JPCxRwQZ2VqqJKswhuzeRhyUq2MDOSjVRhTlk9yby
sEQFG9hZqSaqMIfs3kQelqhgAzsr1UQV5pDdm8jDEhVsYGelmqjCHLJ7E3lYooIN7KxUE1WYQ3Zv
Ig9LVLCBnZVqogpzyO5N5GGJCjaws1JNVGEO2b2JPCxRwQZ2VqqJKsw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AASUVORK5C
YII=
</data>

          </attachment>
          <attachment
              isobsolete="1"
              ispatch="0"
              isprivate="0"
          >
            <attachid>278007</attachid>
            <date>2016-05-03 10:07:51 -0700</date>
            <delta_ts>2016-05-03 10:35:48 -0700</delta_ts>
            <desc>Slightly more reduced test case</desc>
            <filename>inlineblock.html</filename>
            <type>text/html</type>
            <size>337</size>
            <attacher name="Myles C. Maxfield">mmaxfield</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8aGVhZD4KPHN0eWxlPgojaGVhZGVyIHsKICAgIGhlaWdo
dDogNDVweDsKICAgIHdpZHRoOiAxMDAlOwogICAgYmFja2dyb3VuZC1jb2xvcjogIzAwYzczYzsK
fQojaWNvbiB7CiAgICBkaXNwbGF5OiBpbmxpbmUtYmxvY2s7CiAgICB3aWR0aDogNDVweDsKICAg
IGhlaWdodDogNDVweDsKICAgIGZvbnQtc2l6ZTogMDsKICAgIGJhY2tncm91bmQtY29sb3I6IGJs
dWU7Cn0KPC9zdHlsZT4KPC9oZWFkPgo8Ym9keSBzdHlsZT0ibWFyZ2luOiAwcHg7Ij48ZGl2IGlk
PSJoZWFkZXIiPjxkaXYgaWQ9Imljb24iPkE8L2Rpdj48L2Rpdj48L2JvZHk+PC9odG1sPg==
</data>

          </attachment>
      

    </bug>

</bugzilla>