<?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>144077</bug_id>
          
          <creation_ts>2015-04-22 16:08:26 -0700</creation_ts>
          <short_desc>Support share button</short_desc>
          <delta_ts>2015-04-23 15:01:35 -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>iOS 8.2</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>commit-queue</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1087625</commentid>
    <comment_count>0</comment_count>
    <who name="Enrica Casucci">enrica</who>
    <bug_when>2015-04-22 16:08:26 -0700</bug_when>
    <thetext>We should add support to display the share button in the callout menu.

rdar://problem/19772892</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1087628</commentid>
    <comment_count>1</comment_count>
      <attachid>251378</attachid>
    <who name="Enrica Casucci">enrica</who>
    <bug_when>2015-04-22 16:11:03 -0700</bug_when>
    <thetext>Created attachment 251378
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1087630</commentid>
    <comment_count>2</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2015-04-22 16:12:51 -0700</bug_when>
    <thetext>Attachment 251378 did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm:1310:  One line control clauses should not use braces.  [whitespace/braces] [4]
ERROR: Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm:1314:  One line control clauses should not use braces.  [whitespace/braces] [4]
Total errors found: 2 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1087640</commentid>
    <comment_count>3</comment_count>
    <who name="Enrica Casucci">enrica</who>
    <bug_when>2015-04-22 16:28:18 -0700</bug_when>
    <thetext>Fixed the style.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1087666</commentid>
    <comment_count>4</comment_count>
      <attachid>251378</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2015-04-22 18:02:39 -0700</bug_when>
    <thetext>Comment on attachment 251378
Patch

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

&gt; Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm:1299
&gt; +    _page-&gt;getSelectionOrContentsAsString([self](const String&amp; string, CallbackBase::Error error) {

Since this uses lambda syntax, not Objective-C block syntax, we need to explicitly retain/release self, otherwise we could access the view after it has been destroyed. May also need some checks if the thing is still up and frontmost and everything when the callback comes back.

&gt; Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm:1307
&gt; +        if (_textSelectionAssistant) {

Should write:

    id assistant = _textSelectionAssistant ? : _webSelectionAssistant;
    if ([assistant respondsToSelector:@selector(showShareSheetFor:fromRect:)])
        [assistant showShareSheetFor:string fromRect:presentationRect];

Nicer than repeating all the code twice, and no need for an explicit null check either if you write it this way. Might need some typecasts to id on that first line.

&gt; Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm:1310
&gt; +            if ([_textSelectionAssistant respondsToSelector:@selector(showShareSheetFor:fromRect:)]) {
&gt; +                [(id)_textSelectionAssistant showShareSheetFor:string fromRect:presentationRect];
&gt; +            }

WebKit style says no braces for single line if statement.

&gt; Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm:1314
&gt; +            if ([_webSelectionAssistant respondsToSelector:@selector(showShareSheetFor:fromRect:)]) {
&gt; +                [(id)_webSelectionAssistant showShareSheetFor:string fromRect:presentationRect];
&gt; +            }

WebKit style says no braces for single line if statement.

&gt; Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm:1454
&gt; +        if (!textLength || textLength &gt; 200)

Where does this constant 200 come from? This should be a named constant, probably at the top of the file, along with a comment explaining where the number came from.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1087670</commentid>
    <comment_count>5</comment_count>
      <attachid>251378</attachid>
    <who name="Enrica Casucci">enrica</who>
    <bug_when>2015-04-22 18:26:41 -0700</bug_when>
    <thetext>Comment on attachment 251378
Patch

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

&gt;&gt; Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm:1307
&gt;&gt; +        if (_textSelectionAssistant) {
&gt; 
&gt; Should write:
&gt; 
&gt;     id assistant = _textSelectionAssistant ? : _webSelectionAssistant;
&gt;     if ([assistant respondsToSelector:@selector(showShareSheetFor:fromRect:)])
&gt;         [assistant showShareSheetFor:string fromRect:presentationRect];
&gt; 
&gt; Nicer than repeating all the code twice, and no need for an explicit null check either if you write it this way. Might need some typecasts to id on that first line.

Not sure I can do this since _textSelectionAssistant and _webSelectionAssistant don&apos;t share a common interface or protocol.

&gt;&gt; Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm:1310
&gt;&gt; +            }
&gt; 
&gt; WebKit style says no braces for single line if statement.

Already done

&gt;&gt; Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm:1454
&gt;&gt; +        if (!textLength || textLength &gt; 200)
&gt; 
&gt; Where does this constant 200 come from? This should be a named constant, probably at the top of the file, along with a comment explaining where the number came from.

There is a fixme few lines above that references the radar tracking the request to expose this constant. I&apos;ll add a comment referencing the above FIXME</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1087675</commentid>
    <comment_count>6</comment_count>
      <attachid>251378</attachid>
    <who name="Enrica Casucci">enrica</who>
    <bug_when>2015-04-22 18:40:42 -0700</bug_when>
    <thetext>Comment on attachment 251378
Patch

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

&gt;&gt; Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm:1299
&gt;&gt; +    _page-&gt;getSelectionOrContentsAsString([self](const String&amp; string, CallbackBase::Error error) {
&gt; 
&gt; Since this uses lambda syntax, not Objective-C block syntax, we need to explicitly retain/release self, otherwise we could access the view after it has been destroyed. May also need some checks if the thing is still up and frontmost and everything when the callback comes back.

There are several other places in this file where this is used without retain/release. I&apos;ll fix all of them.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1088021</commentid>
    <comment_count>7</comment_count>
    <who name="Enrica Casucci">enrica</who>
    <bug_when>2015-04-23 15:01:35 -0700</bug_when>
    <thetext>WebKit: Committed revision 183208.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>251378</attachid>
            <date>2015-04-22 16:11:03 -0700</date>
            <delta_ts>2015-04-22 18:02:39 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>WK2-share-sheet-webkit.txt</filename>
            <type>text/plain</type>
            <size>3215</size>
            <attacher name="Enrica Casucci">enrica</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJLaXQyL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBTb3VyY2UvV2Vi
S2l0Mi9DaGFuZ2VMb2cJKHJldmlzaW9uIDE4MzE0MykKKysrIFNvdXJjZS9XZWJLaXQyL0NoYW5n
ZUxvZwkod29ya2luZyBjb3B5KQpAQCAtMSwzICsxLDE1IEBACisyMDE1LTA0LTIyICBFb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dGlvbiA9PSBAc2VsZWN0b3IoX3NoYXJl
OikpIHsKKyAgICAgICAgaWYgKF9wYWdlLT5lZGl0b3JTdGF0ZSgpLmlzSW5QYXNzd29yZEZpZWxk
IHx8ICEoaGFzV2ViU2VsZWN0aW9uIHx8IF9wYWdlLT5lZGl0b3JTdGF0ZSgpLnNlbGVjdGlvbklz
UmFuZ2UpKQorICAgICAgICAgICAgcmV0dXJuIE5POworCisgICAgICAgIE5TVUludGVnZXIgdGV4
dExlbmd0aCA9IF9wYWdlLT5lZGl0b3JTdGF0ZSgpLnBvc3RMYXlvdXREYXRhKCkuc2VsZWN0ZWRU
ZXh0TGVuZ3RoOworICAgICAgICBpZiAoIXRleHRMZW5ndGggfHwgdGV4dExlbmd0aCA+IDIwMCkK
KyAgICAgICAgICAgIHJldHVybiBOTzsKKyAgICAgICAgCisgICAgICAgIHJldHVybiBZRVM7Cisg
ICAgfQorCiAgICAgaWYgKGFjdGlvbiA9PSBAc2VsZWN0b3IoX2FkZFNob3J0Y3V0OikpIHsKICAg
ICAgICAgaWYgKF9wYWdlLT5lZGl0b3JTdGF0ZSgpLmlzSW5QYXNzd29yZEZpZWxkIHx8ICEoaGFz
V2ViU2VsZWN0aW9uIHx8IF9wYWdlLT5lZGl0b3JTdGF0ZSgpLnNlbGVjdGlvbklzUmFuZ2UpKQog
ICAgICAgICAgICAgcmV0dXJuIE5POwo=
</data>
<flag name="review"
          id="276171"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>