<?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>155569</bug_id>
          
          <creation_ts>2016-03-16 17:05:09 -0700</creation_ts>
          <short_desc>Recognize mailto and tel url as data detector links</short_desc>
          <delta_ts>2016-03-17 08:56:57 -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>WebKit Misc.</component>
          <version>WebKit 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="Enrica Casucci">enrica</reporter>
          <assigned_to name="Enrica Casucci">enrica</assigned_to>
          <cc>sam</cc>
    
    <cc>thorton</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1175573</commentid>
    <comment_count>0</comment_count>
    <who name="Enrica Casucci">enrica</who>
    <bug_when>2016-03-16 17:05:09 -0700</bug_when>
    <thetext>When we check if the element is a data detector link, we should return true also for URL with mailto: and tel: scheme.

rdar://problem/24836185</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1175578</commentid>
    <comment_count>1</comment_count>
      <attachid>274242</attachid>
    <who name="Enrica Casucci">enrica</who>
    <bug_when>2016-03-16 17:08:28 -0700</bug_when>
    <thetext>Created attachment 274242
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1175583</commentid>
    <comment_count>2</comment_count>
      <attachid>274242</attachid>
    <who name="Sam Weinig">sam</who>
    <bug_when>2016-03-16 17:20:41 -0700</bug_when>
    <thetext>Comment on attachment 274242
Patch

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

We really need to find a way to test this stuff.

&gt; Source/WebCore/editing/cocoa/DataDetection.mm:58
&gt;  bool DataDetection::isDataDetectorLink(Element* element)

Maybe this function should be called isHandledByDataDetectors.  In my mind, isDataDetectorLink sounds like a link created by data detectors.

&gt; Source/WebCore/editing/cocoa/DataDetection.mm:65
&gt; +    String protocol = downcast&lt;HTMLAnchorElement&gt;(*element).href().protocol();
&gt; +    return element-&gt;getAttribute(dataDetectorsURLScheme) == &quot;true&quot; || protocol == &quot;mailto&quot; || protocol == &quot;tel&quot;;

This is slightly inefficient since you are computing the protocol prior to needing it.  I would break it up:

if (element-&gt;getAttribute(dataDetectorsURLScheme) == &quot;true&quot;)
    return true;

URL url = downcast&lt;HTMLAnchorElement&gt;(*element).href();
return url.protocolIs(&quot;mailto&quot;) || url.protocolIs(&quot;tel&quot;);

&gt; Source/WebCore/editing/cocoa/DataDetection.mm:84
&gt; +    // FIXME: We should be able to retrieve this informatio from DataDetectorsCore when rdar://problem/25169133 is fixed.

information -&gt; information</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1175589</commentid>
    <comment_count>3</comment_count>
    <who name="Enrica Casucci">enrica</who>
    <bug_when>2016-03-16 17:56:28 -0700</bug_when>
    <thetext>Committed revision 198311.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1175741</commentid>
    <comment_count>4</comment_count>
      <attachid>274242</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2016-03-17 08:56:57 -0700</bug_when>
    <thetext>Comment on attachment 274242
Patch

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

&gt;&gt; Source/WebCore/editing/cocoa/DataDetection.mm:58
&gt;&gt;  bool DataDetection::isDataDetectorLink(Element* element)
&gt; 
&gt; Maybe this function should be called isHandledByDataDetectors.  In my mind, isDataDetectorLink sounds like a link created by data detectors.

This function always dereferences the pointer, so a null pointer is not allowed. Thus, the function argument should be Element&amp; rather than Element*. Same applies to many other functions in this file, I think.

&gt;&gt; Source/WebCore/editing/cocoa/DataDetection.mm:65
&gt;&gt; +    return element-&gt;getAttribute(dataDetectorsURLScheme) == &quot;true&quot; || protocol == &quot;mailto&quot; || protocol == &quot;tel&quot;;
&gt; 
&gt; This is slightly inefficient since you are computing the protocol prior to needing it.  I would break it up:
&gt; 
&gt; if (element-&gt;getAttribute(dataDetectorsURLScheme) == &quot;true&quot;)
&gt;     return true;
&gt; 
&gt; URL url = downcast&lt;HTMLAnchorElement&gt;(*element).href();
&gt; return url.protocolIs(&quot;mailto&quot;) || url.protocolIs(&quot;tel&quot;);

Should use the poorly named but almost always better to use fastGetAttribute.

Almost everywhere we check if a DOM attribute is true, we do it in a case folding way: equalLettersIgnoringASCIICase(x, &quot;true&quot;). It’s unusual to check in a case sensitive way; there are only 1 or 2 cases of that in all of WebCore, and 20 or more cases of the case folding version. But since this is something we are invented, I suppose we can make it case sensitive and it would be arbitrary to change it now.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>274242</attachid>
            <date>2016-03-16 17:08:28 -0700</date>
            <delta_ts>2016-03-16 17:20:41 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>mailpreview.txt</filename>
            <type>text/plain</type>
            <size>2138</size>
            <attacher name="Enrica Casucci">enrica</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBTb3VyY2UvV2Vi
Q29yZS9DaGFuZ2VMb2cJKHJldmlzaW9uIDE5ODMwOCkKKysrIFNvdXJjZS9XZWJDb3JlL0NoYW5n
ZUxvZwkod29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Ci0gICAgLy8gRklYTUU6IFdlIHNob3VsZCBh
bHNvIGNvbXB1dGUgdGhlIEREUmVzdWx0UmVmIGFuZCBjaGVjayB0aGUgcmVzdWx0IGNhdGVnb3J5
LgorICAgIC8vIEZJWE1FOiBXZSBzaG91bGQgYmUgYWJsZSB0byByZXRyaWV2ZSB0aGlzIGluZm9y
bWF0aW8gZnJvbSBEYXRhRGV0ZWN0b3JzQ29yZSB3aGVuIHJkYXI6Ly9wcm9ibGVtLzI1MTY5MTMz
IGlzIGZpeGVkLgogICAgIGlmICghaXM8SFRNTEFuY2hvckVsZW1lbnQ+KCplbGVtZW50KSkKICAg
ICAgICAgcmV0dXJuIGZhbHNlOwogICAgIGlmIChlbGVtZW50LT5nZXRBdHRyaWJ1dGUoZGF0YURl
dGVjdG9yc1VSTFNjaGVtZSkgIT0gInRydWUiKQo=
</data>
<flag name="review"
          id="298729"
          type_id="1"
          status="+"
          setter="sam"
    />
          </attachment>
      

    </bug>

</bugzilla>