Bug 137582 - Implement selection services menu for Legacy WebKit
Summary: Implement selection services menu for Legacy WebKit
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tim Horton
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-10-09 16:32 PDT by Tim Horton
Modified: 2014-10-16 13:13 PDT (History)
10 users (show)

See Also:


Attachments
patch (46.05 KB, patch)
2014-10-09 16:51 PDT, Tim Horton
no flags Details | Formatted Diff | Diff
patch (45.65 KB, patch)
2014-10-09 17:58 PDT, Tim Horton
no flags Details | Formatted Diff | Diff
try to fix mavericks/ml build (45.53 KB, patch)
2014-10-15 13:45 PDT, Tim Horton
beidson: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Horton 2014-10-09 16:32:54 PDT
Now that ServicesOverlayController lives in WebCore, we can implement the requisite ChromeClient callbacks in Legacy WebKit to make the menu appear, and hook up the system bits.
Comment 1 Radar WebKit Bug Importer 2014-10-09 16:33:05 PDT
<rdar://problem/18604241>
Comment 2 Tim Horton 2014-10-09 16:51:34 PDT
Created attachment 239580 [details]
patch
Comment 3 Tim Horton 2014-10-09 16:53:12 PDT
Comment on attachment 239580 [details]
patch

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

> Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.h:3
> + * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
> + * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies)

This is wrong.

> Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.h:14
> + * 3.  Neither the name of Apple Inc. ("Apple") nor the names of

This is wrong.

> Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm:3
> + * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
> + * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies)

This is wrong.

> Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm:14
> + * 3.  Neither the name of Apple Inc. ("Apple") nor the names of

This is wrong.
Comment 4 WebKit Commit Bot 2014-10-09 16:53:26 PDT
Attachment 239580 [details] did not pass style-queue:


ERROR: Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm:30:  Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
Total errors found: 1 in 23 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Anders Carlsson 2014-10-09 17:03:36 PDT
Comment on attachment 239580 [details]
patch

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

> Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.h:61
> +    virtual void sharingServicePickerWillBeDestroyed(WebSharingServicePickerController *) override;
> +    virtual WebCore::Page* pageForSharingServicePicker(WebSharingServicePickerController *) override;
> +    virtual NSWindow *windowForSharingServicePicker(WebSharingServicePickerController *) override;
> +    virtual WebCore::FloatRect screenRectForCurrentSharingServicePickerItem(WebSharingServicePickerController *) override;
> +    virtual NSImage *imageForCurrentSharingServicePickerItem(WebSharingServicePickerController *) override;

I think these should take the WebSharingServicePickerController& as a reference.

I think the functions that return Objective-C objects should return RetainPtrs to better indicate the lifetime.

Can pageForSharingServicePicker return a Page&? Maybe it should return a MainFrame& ?

> Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm:91
> +    static NeverDestroyed<NSAttributedString *> attributedString([[NSAttributedString alloc] initWithString:@"a"]);

Never use NeverDestroyed with pointers. Also, I think it's fine if this isn't static (No need for it to take up memory).

> Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm:97
> +    static NSAttributedString *attributedStringWithRichContent;

Ditto, I don't think this needs to be static.

> Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm:100
> +        static NeverDestroyed<NSImage *> image([[NSImage alloc] init]);

Same thing here.

> Source/WebKit/mac/WebView/WebView.mm:8496
> +- (WebSelectionServiceController*)_selectionServiceController

This should return a reference.
Comment 6 Anders Carlsson 2014-10-09 17:03:43 PDT
Comment on attachment 239580 [details]
patch

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

> Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.h:61
> +    virtual void sharingServicePickerWillBeDestroyed(WebSharingServicePickerController *) override;
> +    virtual WebCore::Page* pageForSharingServicePicker(WebSharingServicePickerController *) override;
> +    virtual NSWindow *windowForSharingServicePicker(WebSharingServicePickerController *) override;
> +    virtual WebCore::FloatRect screenRectForCurrentSharingServicePickerItem(WebSharingServicePickerController *) override;
> +    virtual NSImage *imageForCurrentSharingServicePickerItem(WebSharingServicePickerController *) override;

I think these should take the WebSharingServicePickerController& as a reference.

I think the functions that return Objective-C objects should return RetainPtrs to better indicate the lifetime.

Can pageForSharingServicePicker return a Page&? Maybe it should return a MainFrame& ?

> Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm:91
> +    static NeverDestroyed<NSAttributedString *> attributedString([[NSAttributedString alloc] initWithString:@"a"]);

Never use NeverDestroyed with pointers. Also, I think it's fine if this isn't static (No need for it to take up memory).

> Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm:97
> +    static NSAttributedString *attributedStringWithRichContent;

Ditto, I don't think this needs to be static.

> Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm:100
> +        static NeverDestroyed<NSImage *> image([[NSImage alloc] init]);

Same thing here.

> Source/WebKit/mac/WebView/WebView.mm:8496
> +- (WebSelectionServiceController*)_selectionServiceController

This should return a reference.
Comment 7 Tim Horton 2014-10-09 17:25:14 PDT
(In reply to comment #5)
> (From update of attachment 239580 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=239580&action=review
> 
> > Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.h:61
> > +    virtual void sharingServicePickerWillBeDestroyed(WebSharingServicePickerController *) override;
> > +    virtual WebCore::Page* pageForSharingServicePicker(WebSharingServicePickerController *) override;
> > +    virtual NSWindow *windowForSharingServicePicker(WebSharingServicePickerController *) override;
> > +    virtual WebCore::FloatRect screenRectForCurrentSharingServicePickerItem(WebSharingServicePickerController *) override;
> > +    virtual NSImage *imageForCurrentSharingServicePickerItem(WebSharingServicePickerController *) override;
> 
> I think these should take the WebSharingServicePickerController& as a reference.
> 
> I think the functions that return Objective-C objects should return RetainPtrs to better indicate the lifetime.

Both seem reasonable.

> Can pageForSharingServicePicker return a Page&? Maybe it should return a MainFrame& ?

I'm totally unclear on this here.

> > Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm:91
> > +    static NeverDestroyed<NSAttributedString *> attributedString([[NSAttributedString alloc] initWithString:@"a"]);
> 
> Never use NeverDestroyed with pointers. Also, I think it's fine if this isn't static (No need for it to take up memory).

Fine with me. De-staticed everything.

> > Source/WebKit/mac/WebView/WebView.mm:8496
> > +- (WebSelectionServiceController*)_selectionServiceController
> 
> This should return a reference.

Sure.
Comment 8 Tim Horton 2014-10-09 17:58:57 PDT
Created attachment 239586 [details]
patch

With Anders' changes. However, Anders thinks I should look into putting more of this in WebCore to share with WebKit2 (so, having the Services ChromeClient overrides call directly back into WebCore in the Legacy WebKit case, or jump to the UI process and call back into WebCore in the WebKit2 case, and put the context menu code/NSSharingServicePicker code in WebCore). I'm not sure this is going to be super easy so I'm leaving this patch here in case I need to fall back to it.
Comment 9 Tim Horton 2014-10-09 18:00:02 PDT
Comment on attachment 239586 [details]
patch

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

> Source/WebKit2/ChangeLog:15
> +        Add a note that we should transition to using replaceSelectionWithAttributedString.

These comments are flipped :|
Comment 10 Tim Horton 2014-10-09 18:00:05 PDT
Comment on attachment 239586 [details]
patch

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

> Source/WebKit2/ChangeLog:15
> +        Add a note that we should transition to using replaceSelectionWithAttributedString.

These comments are flipped :|
Comment 11 Tim Horton 2014-10-09 18:00:17 PDT
Comment on attachment 239586 [details]
patch

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

> Source/WebKit2/ChangeLog:15
> +        Add a note that we should transition to using replaceSelectionWithAttributedString.

These comments are flipped :|
Comment 12 Tim Horton 2014-10-09 18:00:22 PDT
Comment on attachment 239586 [details]
patch

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

> Source/WebKit2/ChangeLog:15
> +        Add a note that we should transition to using replaceSelectionWithAttributedString.

These comments are flipped :|
Comment 13 WebKit Commit Bot 2014-10-09 18:00:26 PDT
Attachment 239586 [details] did not pass style-queue:


ERROR: Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm:26:  Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
Total errors found: 1 in 23 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 14 Tim Horton 2014-10-09 18:00:51 PDT
Yay, bugzilla success.
Comment 15 Tim Horton 2014-10-15 10:57:39 PDT
(In reply to comment #8)
> Created an attachment (id=239586) [details]
> patch
> 
> With Anders' changes. However, Anders thinks I should look into putting more of this in WebCore to share with WebKit2 (so, having the Services ChromeClient overrides call directly back into WebCore in the Legacy WebKit case, or jump to the UI process and call back into WebCore in the WebKit2 case, and put the context menu code/NSSharingServicePicker code in WebCore). I'm not sure this is going to be super easy so I'm leaving this patch here in case I need to fall back to it.

Doing this is pretty messy, and involves hugely changing how Legacy WebKit image services work, and image services and selection services and telephone number services for WebKit2, and is all in all a much much bigger change. I think we should do it separately, in the future, but try to get this patch landed sooner (it doesn't make things much worse, since WebKit1 already has a sharing service picker implementation there for image services).
Comment 16 Tim Horton 2014-10-15 13:45:53 PDT
Created attachment 239893 [details]
try to fix mavericks/ml build
Comment 17 WebKit Commit Bot 2014-10-15 13:48:57 PDT
Attachment 239893 [details] did not pass style-queue:


ERROR: Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm:26:  Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
Total errors found: 1 in 23 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 18 Brady Eidson 2014-10-16 12:59:03 PDT
Comment on attachment 239893 [details]
try to fix mavericks/ml build

Does this actually break the windows build?  Plz to not break.

Otherwise, okay.
Comment 19 Tim Horton 2014-10-16 13:13:59 PDT
http://trac.webkit.org/changeset/174791