<?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>98062</bug_id>
          
          <creation_ts>2012-10-01 13:43:44 -0700</creation_ts>
          <short_desc>[chromium] Subpixel text positioning causes incorrect inline-block layout.</short_desc>
          <delta_ts>2012-11-08 10:01:46 -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>Layout and Rendering</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</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>
          <dependson>101497</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Robert Flack">flackr</reporter>
          <assigned_to name="Terry Anderson">tdanderson</assigned_to>
          <cc>eae</cc>
    
    <cc>leviw</cc>
    
    <cc>rbyers</cc>
    
    <cc>tdanderson</cc>
    
    <cc>vollick</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>731938</commentid>
    <comment_count>0</comment_count>
    <who name="Robert Flack">flackr</who>
    <bug_when>2012-10-01 13:43:44 -0700</bug_when>
    <thetext>When the attached page is viewed with subpixel text positioning enabled it causes the page to have a horizontal scrollbar and a scrollWidth 1 greater than the offsetWidth even though all the content fits on the page. Interestingly the span&apos;s scrollWidth is also 1 greater than its offsetWidth.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>731940</commentid>
    <comment_count>1</comment_count>
    <who name="Levi Weintraub">leviw</who>
    <bug_when>2012-10-01 13:45:00 -0700</bug_when>
    <thetext>Super interesting. Can you give attaching the test page another try?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>731943</commentid>
    <comment_count>2</comment_count>
      <attachid>166534</attachid>
    <who name="Robert Flack">flackr</who>
    <bug_when>2012-10-01 13:50:22 -0700</bug_when>
    <thetext>Created attachment 166534
Test case showing the subpixel text positioning size problem</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>731954</commentid>
    <comment_count>3</comment_count>
    <who name="Levi Weintraub">leviw</who>
    <bug_when>2012-10-01 13:56:43 -0700</bug_when>
    <thetext>What version of Chrome are you repro-ing with? Emil and I tried to repro with 22, 23, and 24 on Windows, Mac, and Linux to no avail.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>731955</commentid>
    <comment_count>4</comment_count>
    <who name="Levi Weintraub">leviw</who>
    <bug_when>2012-10-01 13:57:18 -0700</bug_when>
    <thetext>Sorry, I missed the &quot;subpixel text positioning&quot; part. Sorry!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>733721</commentid>
    <comment_count>5</comment_count>
    <who name="">vollick</who>
    <bug_when>2012-10-03 08:22:10 -0700</bug_when>
    <thetext>This bug is possibly related to http://codereview.chromium.org/10996037/. We were doing some dodgy RectF to Rect conversions in chrome -- we were just flooring the position and size when we should have been taking either the enclosing or enclosed rect -- so I got rid of these conversions. There are a couple of spots where I&apos;d chosen ToEnclosingRect rather than the old conversion, and this might have been the wrong choice and may be causing some rects to be one pixel larger than they ought to be.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>752452</commentid>
    <comment_count>6</comment_count>
      <attachid>171021</attachid>
    <who name="Terry Anderson">tdanderson</who>
    <bug_when>2012-10-26 14:56:28 -0700</bug_when>
    <thetext>Created attachment 171021
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>752455</commentid>
    <comment_count>7</comment_count>
    <who name="Terry Anderson">tdanderson</who>
    <bug_when>2012-10-26 14:57:13 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; Created an attachment (id=171021) [details]
&gt; Patch

This issue only reproduces in some cases. In the attached test case, if you replace the span with &lt;span&gt;x&lt;/span&gt; the problem does not reproduce, but with &lt;span&gt;xx&lt;/span&gt; it does. The horizontal scrollbar appears because in ScrollView::updateScrollbars(), the contents width is reported as being 1 larger than the visible width.

I looked at the value of layoutOverflowRect().width() in RenderView::unscaledDocumentRect() after changing the text of the test case. Here is some data:

    (text on test page, layoutOverflowRect().width(), horizontal scrollbar present?)
    &apos;x&apos;, 575.296875, no
    &apos;xx&apos;, 575.609375, yes
    &apos;xxx&apos;, 575.906250, yes
    &apos;xxxx&apos;, 575.218750, no
    &apos;Hello, world!&apos;, 575.765625, yes

This seemed to indicate that rounding (rather than always taking the floor) may be responsible for the one pixel difference. This patch indeed fixes the bug but is likely not a landable solution.

An alternate solution could be to ensure that overflow is not falsely reported (perhaps using knownToHaveNoOverflow() ?). If |m_overflow| in RenderBox is never set, then layoutOverflowRect().width() will always be 575.000000.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>753005</commentid>
    <comment_count>8</comment_count>
    <who name="Terry Anderson">tdanderson</who>
    <bug_when>2012-10-28 16:35:08 -0700</bug_when>
    <thetext>Levi or Emil, are you able to provide any guidance about the best way to proceed here?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>754189</commentid>
    <comment_count>9</comment_count>
    <who name="Levi Weintraub">leviw</who>
    <bug_when>2012-10-30 04:03:49 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; I looked at the value of layoutOverflowRect().width() in RenderView::unscaledDocumentRect() after changing the text of the test case. Here is some data:
&gt; 
&gt;     (text on test page, layoutOverflowRect().width(), horizontal scrollbar present?)
&gt;     &apos;x&apos;, 575.296875, no
&gt;     &apos;xx&apos;, 575.609375, yes
&gt;     &apos;xxx&apos;, 575.906250, yes
&gt;     &apos;xxxx&apos;, 575.218750, no
&gt;     &apos;Hello, world!&apos;, 575.765625, yes
&gt; 
&gt; This seemed to indicate that rounding (rather than always taking the floor) may be responsible for the one pixel difference. This patch indeed fixes the bug but is likely not a landable solution.
&gt; 
&gt; An alternate solution could be to ensure that overflow is not falsely reported (perhaps using knownToHaveNoOverflow() ?). If |m_overflow| in RenderBox is never set, then layoutOverflowRect().width() will always be 575.000000.

Rounding is, of course, necessary for sub-pixel layout to work properly. Are you saying that we&apos;re only setting m_overflow in the fail case? We should be treating all values as LayoutUnits when determining if we overflow. What&apos;s the delta between the client rect and the value we&apos;re using to determine that we have overflow when it occurs? If you turn off sub-pixel layout (in Platform.h, not FractionalLayoutUnit.h), does the problem go away? Do we not set m_overflow in that case?

This is a step towards the problem, but it&apos;s not quite enough to understand the root cause yet.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>756690</commentid>
    <comment_count>10</comment_count>
    <who name="Terry Anderson">tdanderson</who>
    <bug_when>2012-11-01 15:41:47 -0700</bug_when>
    <thetext>(In reply to comment #9)
&gt; (In reply to comment #7)
&gt; &gt; I looked at the value of layoutOverflowRect().width() in RenderView::unscaledDocumentRect() after changing the text of the test case. Here is some data:
&gt; &gt; 
&gt; &gt;     (text on test page, layoutOverflowRect().width(), horizontal scrollbar present?)
&gt; &gt;     &apos;x&apos;, 575.296875, no
&gt; &gt;     &apos;xx&apos;, 575.609375, yes
&gt; &gt;     &apos;xxx&apos;, 575.906250, yes
&gt; &gt;     &apos;xxxx&apos;, 575.218750, no
&gt; &gt;     &apos;Hello, world!&apos;, 575.765625, yes
&gt; &gt; 
&gt; &gt; This seemed to indicate that rounding (rather than always taking the floor) may be responsible for the one pixel difference. This patch indeed fixes the bug but is likely not a landable solution.
&gt; &gt; 
&gt; &gt; An alternate solution could be to ensure that overflow is not falsely reported (perhaps using knownToHaveNoOverflow() ?). If |m_overflow| in RenderBox is never set, then layoutOverflowRect().width() will always be 575.000000.
&gt; 
&gt; Rounding is, of course, necessary for sub-pixel layout to work properly. Are you saying that we&apos;re only setting m_overflow in the fail case? We should be treating all values as LayoutUnits when determining if we overflow. What&apos;s the delta between the client rect and the value we&apos;re using to determine that we have overflow when it occurs? If you turn off sub-pixel layout (in Platform.h, not FractionalLayoutUnit.h), does the problem go away? Do we not set m_overflow in that case?
&gt; 
&gt; This is a step towards the problem, but it&apos;s not quite enough to understand the root cause yet.

On further investigation, |m_overflow| (in RenderBox and InlineFlowBox) is getting set in both the pass case (&apos;x&apos;) and the fail case (&apos;xx&apos;). When determining if we have overflow in the pass case, the overflow rect width is 0.296875 larger than the client rect. When determining if we have overflow in the fail case, the overflow rect width is 0.609375 larger than the client rect.

Despite having |m_overflow| set, the pass case does not invoke a horizontal scrollbar because the 0.296875 disappears as a result of rounding when setting the integer contents size.

If I disable sub-pixel layout as you suggested, the problem does indeed go away and |m_overflow| is never set in either RenderBox or InlineFlowBox.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>757167</commentid>
    <comment_count>11</comment_count>
    <who name="Levi Weintraub">leviw</who>
    <bug_when>2012-11-02 07:10:49 -0700</bug_when>
    <thetext>(In reply to comment #10)
&gt; If I disable sub-pixel layout as you suggested, the problem does indeed go away and |m_overflow| is never set in either RenderBox or InlineFlowBox.

Aha! That&apos;s most definitely a bug we can look into :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>761898</commentid>
    <comment_count>12</comment_count>
    <who name="Terry Anderson">tdanderson</who>
    <bug_when>2012-11-08 09:59:50 -0800</bug_when>
    <thetext>Fixed with http://trac.webkit.org/changeset/133903</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>761900</commentid>
    <comment_count>13</comment_count>
    <who name="Emil A Eklund">eae</who>
    <bug_when>2012-11-08 10:01:46 -0800</bug_when>
    <thetext>Awesome, thanks for verifying Terry!</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>166534</attachid>
            <date>2012-10-01 13:50:22 -0700</date>
            <delta_ts>2012-10-01 13:50:22 -0700</delta_ts>
            <desc>Test case showing the subpixel text positioning size problem</desc>
            <filename>subpixel.html</filename>
            <type>text/html</type>
            <size>230</size>
            <attacher name="Robert Flack">flackr</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8aGVhZD4KPHN0eWxlPgpib2R5IHsKICBmb250LXNpemU6
IHNtYWxsOwogIG1hcmdpbjogMDsKICB0ZXh0LWFsaWduOiByaWdodDsKfQoKc3BhbiB7CiAgZGlz
cGxheTogaW5saW5lLWJsb2NrOwp9Cjwvc3R5bGU+CjwvaGVhZD4KPGJvZHk+CiAgPHNwYW4+VGhp
cyBwYWdlIHNob3VsZCBub3QgaGF2ZSBhIHNjcm9sbGJhci48L3NwYW4+CjwvYm9keT4KPC9odG1s
Pgo=
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>171021</attachid>
            <date>2012-10-26 14:56:28 -0700</date>
            <delta_ts>2012-10-26 14:57:54 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-98062-20121026175500.patch</filename>
            <type>text/plain</type>
            <size>1523</size>
            <attacher name="Terry Anderson">tdanderson</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTMyNjk2CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggNGVlMGIzMjA0YzBlMzg4
ODVhOTUzZGJlODk1YjdhNTExYWU1M2E4OS4uNzNlZTYxODU1NDkxMTE2ZDgzOTkxODJkNDNhNjBi
ZGIwZGQyY2E0NiAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE3IEBACisyMDEyLTEwLTI2ICBUZXJy
eSBBbmRlcnNvbiAgPHRkYW5kZXJzb25AY2hyb21pdW0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29yZS9wbGF0Zm9ybS9GcmFjdGlvbmFsTGF5b3V0VW5p
dC5oCkBAIC04MTcsNyArODE3LDcgQEAgaW5saW5lIGZsb2F0JiBvcGVyYXRvci89KGZsb2F0JiBh
LCBjb25zdCBGcmFjdGlvbmFsTGF5b3V0VW5pdCYgYikKIGlubGluZSBpbnQgc25hcFNpemVUb1Bp
eGVsKEZyYWN0aW9uYWxMYXlvdXRVbml0IHNpemUsIEZyYWN0aW9uYWxMYXlvdXRVbml0IGxvY2F0
aW9uKSAKIHsKICAgICBGcmFjdGlvbmFsTGF5b3V0VW5pdCBmcmFjdGlvbiA9IGxvY2F0aW9uLmZy
YWN0aW9uKCk7Ci0gICAgcmV0dXJuIChmcmFjdGlvbiArIHNpemUpLnJvdW5kKCkgLSBmcmFjdGlv
bi5yb3VuZCgpOworICAgIHJldHVybiAoZnJhY3Rpb24gKyBzaXplKS5mbG9vcigpIC0gZnJhY3Rp
b24uZmxvb3IoKTsKIH0KIAogfSAvLyBuYW1lc3BhY2UgV2ViQ29yZQo=
</data>
<flag name="review"
          id="184791"
          type_id="1"
          status="-"
          setter="tdanderson"
    />
          </attachment>
      

    </bug>

</bugzilla>