<?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>146468</bug_id>
          
          <creation_ts>2015-06-30 13:27:58 -0700</creation_ts>
          <short_desc>The bounds on InteractionInformationAtPosition should be more precise</short_desc>
          <delta_ts>2015-07-01 12:13:07 -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>WebKit2</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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Beth Dakin">bdakin</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bdakin</cc>
    
    <cc>commit-queue</cc>
    
    <cc>enrica</cc>
    
    <cc>esprehn+autocc</cc>
    
    <cc>glenn</cc>
    
    <cc>kondapallykalyan</cc>
    
    <cc>sam</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>thorton</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1105771</commentid>
    <comment_count>0</comment_count>
    <who name="Beth Dakin">bdakin</who>
    <bug_when>2015-06-30 13:27:58 -0700</bug_when>
    <thetext>The bounds on InteractionInformationAtPosition should be more precise. Specifically, the bound for links should correspond to the appropriate Range, and the bounds for an image should not include border/padding.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1105773</commentid>
    <comment_count>1</comment_count>
      <attachid>255843</attachid>
    <who name="Beth Dakin">bdakin</who>
    <bug_when>2015-06-30 13:31:23 -0700</bug_when>
    <thetext>Created attachment 255843
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1105791</commentid>
    <comment_count>2</comment_count>
      <attachid>255843</attachid>
    <who name="Enrica Casucci">enrica</who>
    <bug_when>2015-06-30 13:55:53 -0700</bug_when>
    <thetext>Comment on attachment 255843
Patch

That looks great!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1105793</commentid>
    <comment_count>3</comment_count>
      <attachid>255843</attachid>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2015-06-30 13:57:31 -0700</bug_when>
    <thetext>Comment on attachment 255843
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=255843&amp;action=review

&gt; Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm:2162
&gt; +            if (element-&gt;renderer())
&gt;                  info.touchCalloutEnabled = element-&gt;renderer()-&gt;style().touchCalloutEnabled();

Seems like you can just bail early from this function if element-&gt;renderer() is null.

&gt; Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm:2171
&gt; +                RefPtr&lt;Range&gt; linkRange = rangeOfContents(*linkElement);
&gt; +                Vector&lt;FloatQuad&gt; quads;
&gt; +                linkRange-&gt;textQuads(quads);
&gt; +                FloatRect linkBoundingBox;
&gt; +                for (const auto&amp; quad : quads)
&gt; +                    linkBoundingBox.unite(quad.enclosingBoundingBox());
&gt; +                info.bounds = IntRect(linkBoundingBox);

This is just Range::boundingRect(), but that forces layout.

&gt; Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm:2172
&gt; +            } else if (element-&gt;renderer()) {

if (RenderElement* renderer = element-&gt;renderer())...

&gt; Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm:2177
&gt; +                    info.bounds = element-&gt;renderer()-&gt;absoluteBoundingBoxRect(true);

true is the default.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1105804</commentid>
    <comment_count>4</comment_count>
    <who name="Beth Dakin">bdakin</who>
    <bug_when>2015-06-30 14:11:29 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; Comment on attachment 255843 [details]
&gt; Patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=255843&amp;action=review
&gt; 
&gt; &gt; Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm:2162
&gt; &gt; +            if (element-&gt;renderer())
&gt; &gt;                  info.touchCalloutEnabled = element-&gt;renderer()-&gt;style().touchCalloutEnabled();
&gt; 
&gt; Seems like you can just bail early from this function if element-&gt;renderer()
&gt; is null.
&gt; 

There is more to the function that should be executed outside of an if (element) that this line of code is wrapped in. I could break; I suppose? I feel like we don&apos;t usually use breaks to break out of conditionals, but it&apos;s not covered by the style guide so maybe it&apos;s fine?

&gt; &gt; Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm:2171
&gt; &gt; +                RefPtr&lt;Range&gt; linkRange = rangeOfContents(*linkElement);
&gt; &gt; +                Vector&lt;FloatQuad&gt; quads;
&gt; &gt; +                linkRange-&gt;textQuads(quads);
&gt; &gt; +                FloatRect linkBoundingBox;
&gt; &gt; +                for (const auto&amp; quad : quads)
&gt; &gt; +                    linkBoundingBox.unite(quad.enclosingBoundingBox());
&gt; &gt; +                info.bounds = IntRect(linkBoundingBox);
&gt; 
&gt; This is just Range::boundingRect(), but that forces layout.
&gt; 

Layout should be up to date here, so that should;t be necessary. Unless we are sure it&apos;s smart enough to know things are up to date?

&gt; &gt; Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm:2172
&gt; &gt; +            } else if (element-&gt;renderer()) {
&gt; 
&gt; if (RenderElement* renderer = element-&gt;renderer())...
&gt; 

Fixed.

&gt; &gt; Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm:2177
&gt; &gt; +                    info.bounds = element-&gt;renderer()-&gt;absoluteBoundingBoxRect(true);
&gt; 
&gt; true is the default.

Fixed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1105820</commentid>
    <comment_count>5</comment_count>
    <who name="Beth Dakin">bdakin</who>
    <bug_when>2015-06-30 14:41:15 -0700</bug_when>
    <thetext>Thanks Simon and Enrica! http://trac.webkit.org/changeset/186132</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1105908</commentid>
    <comment_count>6</comment_count>
      <attachid>255843</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2015-06-30 17:32:56 -0700</bug_when>
    <thetext>Comment on attachment 255843
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=255843&amp;action=review

&gt; Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm:2175
&gt; +                    auto&amp; renderImage = downcast&lt;RenderImage&gt;(*(element-&gt;renderer()));
&gt; +                    info.bounds = renderImage.absoluteContentQuad().enclosingBoundingBox();

Now that you added a local variable, this is slightly nicer as a one-liner:

    info.bounds = downcast&lt;RenderImage&gt;(*renderer).absoluteContentQuad().enclosingBoundingBox();

I know you landed already, but I couldn’t resist.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1106147</commentid>
    <comment_count>7</comment_count>
    <who name="Beth Dakin">bdakin</who>
    <bug_when>2015-07-01 12:13:07 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; Comment on attachment 255843 [details]
&gt; Patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=255843&amp;action=review
&gt; 
&gt; &gt; Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm:2175
&gt; &gt; +                    auto&amp; renderImage = downcast&lt;RenderImage&gt;(*(element-&gt;renderer()));
&gt; &gt; +                    info.bounds = renderImage.absoluteContentQuad().enclosingBoundingBox();
&gt; 
&gt; Now that you added a local variable, this is slightly nicer as a one-liner:
&gt; 
&gt;     info.bounds =
&gt; downcast&lt;RenderImage&gt;(*renderer).absoluteContentQuad().
&gt; enclosingBoundingBox();
&gt; 
&gt; I know you landed already, but I couldn’t resist.

Hehe, turned this into a one-liner with http://trac.webkit.org/changeset/186184</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>255843</attachid>
            <date>2015-06-30 13:31:23 -0700</date>
            <delta_ts>2015-06-30 13:57:57 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>for-review.txt</filename>
            <type>text/plain</type>
            <size>4023</size>
            <attacher name="Beth Dakin">bdakin</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBTb3VyY2UvV2Vi
Q29yZS9DaGFuZ2VMb2cJKHJldmlzaW9uIDE4NjEyOCkKKysrIFNvdXJjZS9XZWJDb3JlL0NoYW5n
ZUxvZwkod29ya2luZyBjb3B5KQpAQCAtMSwzICsxLDE1IEBACisyMDE1LTA2LTMwICBCZXRoIERh
a2luICA8YmRha2luQGFwcGxlLmNvbT4KKworICAgICAgICBUaGUgYm91bmRzIG9uIEludGVyYWN0
aW9uSW5mb3JtYXRpb25BdFBvc2l0aW9uIHNob3VsZCBiZSBtb3JlIHByZWNpc2UKKyAgICAgICAg
aHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTE0NjQ2OAorICAgICAgICAt
YW5kIGNvcnJlc3BvbmRpbmctCisgICAgICAgIHJkYXI6Ly9wcm9ibGVtLzIwNzM5ODM0CisKKyAg
ICAgICAgUmV2aWV3ZWQgYnkgTk9CT0RZIChPT1BTISkuCisKKyAgICAgICAgRXhwb3J0IGFic29s
dXRlQ29udGVudFF1YWQoKS4KKyAgICAgICAgKiByZW5kZXJpbmcvUmVuZGVyQm94Lmg6CisKIDIw
MTUtMDYtMzAgIFphbGFuIEJ1anRhcyAgPHphbGFuQGFwcGxlLmNvbT4KIAogICAgICAgIC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AgIGluZm8udG91Y2hDYWxsb3V0RW5hYmxlZCA9IGVsZW1lbnQtPnJlbmRlcmVyKCktPnN0eWxl
KCkudG91Y2hDYWxsb3V0RW5hYmxlZCgpOworCisgICAgICAgICAgICBpZiAoZWxlbWVudCA9PSBs
aW5rRWxlbWVudCkgeworICAgICAgICAgICAgICAgIFJlZlB0cjxSYW5nZT4gbGlua1JhbmdlID0g
cmFuZ2VPZkNvbnRlbnRzKCpsaW5rRWxlbWVudCk7CisgICAgICAgICAgICAgICAgVmVjdG9yPEZs
b2F0UXVhZD4gcXVhZHM7CisgICAgICAgICAgICAgICAgbGlua1JhbmdlLT50ZXh0UXVhZHMocXVh
ZHMpOworICAgICAgICAgICAgICAgIEZsb2F0UmVjdCBsaW5rQm91bmRpbmdCb3g7CisgICAgICAg
ICAgICAgICAgZm9yIChjb25zdCBhdXRvJiBxdWFkIDogcXVhZHMpCisgICAgICAgICAgICAgICAg
ICAgIGxpbmtCb3VuZGluZ0JveC51bml0ZShxdWFkLmVuY2xvc2luZ0JvdW5kaW5nQm94KCkpOwor
ICAgICAgICAgICAgICAgIGluZm8uYm91bmRzID0gSW50UmVjdChsaW5rQm91bmRpbmdCb3gpOwor
ICAgICAgICAgICAgfSBlbHNlIGlmIChlbGVtZW50LT5yZW5kZXJlcigpKSB7CisgICAgICAgICAg
ICAgICAgaWYgKGVsZW1lbnQtPnJlbmRlcmVyKCktPmlzUmVuZGVySW1hZ2UoKSkgeworICAgICAg
ICAgICAgICAgICAgICBhdXRvJiByZW5kZXJJbWFnZSA9IGRvd25jYXN0PFJlbmRlckltYWdlPigq
KGVsZW1lbnQtPnJlbmRlcmVyKCkpKTsKKyAgICAgICAgICAgICAgICAgICAgaW5mby5ib3VuZHMg
PSByZW5kZXJJbWFnZS5hYnNvbHV0ZUNvbnRlbnRRdWFkKCkuZW5jbG9zaW5nQm91bmRpbmdCb3go
KTsKKyAgICAgICAgICAgICAgICB9IGVsc2UKKyAgICAgICAgICAgICAgICAgICAgaW5mby5ib3Vu
ZHMgPSBlbGVtZW50LT5yZW5kZXJlcigpLT5hYnNvbHV0ZUJvdW5kaW5nQm94UmVjdCh0cnVlKTsK
ICAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgIH0K
</data>
<flag name="review"
          id="280930"
          type_id="1"
          status="+"
          setter="simon.fraser"
    />
          </attachment>
      

    </bug>

</bugzilla>