<?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>122367</bug_id>
          
          <creation_ts>2013-10-04 18:04:31 -0700</creation_ts>
          <short_desc>[MathML] Use of floating point floor/ceil operations on LayoutUnits seems wrong</short_desc>
          <delta_ts>2013-10-08 13:41:18 -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>MathML</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>121416</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Brent Fulgham">bfulgham</reporter>
          <assigned_to name="Brent Fulgham">bfulgham</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>commit-queue</cc>
    
    <cc>dbarton</cc>
    
    <cc>esprehn+autocc</cc>
    
    <cc>fred.wang</cc>
    
    <cc>glenn</cc>
    
    <cc>hyatt</cc>
    
    <cc>kondapallykalyan</cc>
    
    <cc>mrobinson</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>936463</commentid>
    <comment_count>0</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2013-10-04 18:04:31 -0700</bug_when>
    <thetext>While investigating another problem, I noticed the following code in RenderMathMLOperator::paintCharacter:

    switch (trim) {
    case TrimTop:
        glyphPaintRect.shiftYEdgeTo(ceil(glyphPaintRect.y()) + 1);
        clipBounds.shiftYEdgeTo(glyphPaintRect.y());
        break;
    case TrimBottom:
        glyphPaintRect.shiftMaxYEdgeTo(floor(glyphPaintRect.maxY()) - 1);
        clipBounds.shiftMaxYEdgeTo(glyphPaintRect.maxY());
        break;
    case TrimTopAndBottom:
        glyphPaintRect.shiftYEdgeTo(ceil(glyphPaintRect.y() + 1));
        glyphPaintRect.shiftMaxYEdgeTo(floor(glyphPaintRect.maxY()) - 1);
        clipBounds.shiftYEdgeTo(glyphPaintRect.y());
        clipBounds.shiftMaxYEdgeTo(glyphPaintRect.maxY());
        break;
    }

The various paint rects in this code are LayoutRects, and the y()/maxY() methods return LayoutUnits.

The LayoutRect and LayoutUnit wrap an &apos;int&apos; type.  So the calls to the ceil/floor C API results in an implicit cast from LayoutUnit-&gt;float, then a call to floor/ceil.

Since we are already working with integer types, these calls seem at best wasteful.

Given that the layout units do some magic internally for dealing with sub-pixel layout for their ceil() and floor() methods, I feel like this code should be revised as outlined in the attached patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>936467</commentid>
    <comment_count>1</comment_count>
      <attachid>213428</attachid>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2013-10-04 18:08:26 -0700</bug_when>
    <thetext>Created attachment 213428
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>936486</commentid>
    <comment_count>2</comment_count>
    <who name="Martin Robinson">mrobinson</who>
    <bug_when>2013-10-04 19:47:06 -0700</bug_when>
    <thetext>landing I would like to verify that this fits not regress rendering quality on GTK+, if you don&apos;t mind.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>937325</commentid>
    <comment_count>3</comment_count>
    <who name="Martin Robinson">mrobinson</who>
    <bug_when>2013-10-07 19:13:37 -0700</bug_when>
    <thetext>This looks good on GTK+ so feel free to land this when it looks like the the patch for 12146 sticks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>937545</commentid>
    <comment_count>4</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2013-10-08 09:25:56 -0700</bug_when>
    <thetext>&lt;rdar://problem/15176294&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>937658</commentid>
    <comment_count>5</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2013-10-08 13:41:18 -0700</bug_when>
    <thetext>Committed r157135: &lt;http://trac.webkit.org/changeset/157135&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>213428</attachid>
            <date>2013-10-04 18:08:26 -0700</date>
            <delta_ts>2013-10-04 18:44:39 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-122367-20131004180825.patch</filename>
            <type>text/plain</type>
            <size>2148</size>
            <attacher name="Brent Fulgham">bfulgham</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBTb3VyY2UvV2Vi
Q29yZS9DaGFuZ2VMb2cJKHJldmlzaW9uIDE1NjkzOCkKKysrIFNvdXJjZS9XZWJDb3JlL0NoYW5n
ZUxvZwkod29ya2luZyBjb3B5KQpAQCAtMSwzICsxLDE2IEBACisyMDEzLTEwLTA0ICBCcmVudCBG
dWxnaGFtICA8YmZ1bGdoYW1AYXBwbGUuY29tPgorCisgICAgICAgIFtNYXRoTUxdIFVzZSBvZiBm
bG9hdGluZyBwb2ludCBmbG9vci9jZWlsIG9uIExheW91dFVuaXRzIHNlZW1zIHdyb25nCisgICAg
ICAgIGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9pZD0xMjIzNjcKKworICAg
ICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAgICBObyBuZXcgdGVzdHM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dC55KCkpOwogICAgICAgICBjbGlwQm91bmRzLnNoaWZ0TWF4WUVkZ2VUbyhn
bHlwaFBhaW50UmVjdC5tYXhZKCkpOwogICAgICAgICBicmVhazsK
</data>
<flag name="review"
          id="235789"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>