WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
138032
WebKit1 should support action menus
https://bugs.webkit.org/show_bug.cgi?id=138032
Summary
WebKit1 should support action menus
Beth Dakin
Reported
2014-10-23 17:35:56 PDT
WebKit1 should support action menus.
Attachments
Patch
(38.96 KB, patch)
2014-10-23 17:42 PDT
,
Beth Dakin
no flags
Details
Formatted Diff
Diff
Patch that addresses Dan's comments
(39.21 KB, patch)
2014-10-24 12:17 PDT
,
Beth Dakin
no flags
Details
Formatted Diff
Diff
Patch
(20.58 KB, patch)
2014-10-24 14:01 PDT
,
Beth Dakin
thorton
: review+
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Beth Dakin
Comment 1
2014-10-23 17:42:01 PDT
Created
attachment 240381
[details]
Patch
WebKit Commit Bot
Comment 2
2014-10-23 17:43:59 PDT
Attachment 240381
[details]
did not pass style-queue: ERROR: Source/WebKit/mac/WebView/WebActionMenuHelper.h:31: This { should be at the end of the previous line [whitespace/braces] [4] ERROR: Source/WebKit/mac/WebView/WebActionMenuHelper.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: 2 in 8 files If any of these errors are false positives, please file a bug against check-webkit-style.
mitz
Comment 3
2014-10-23 22:23:12 PDT
Comment on
attachment 240381
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=240381&action=review
> Source/WebKit/mac/WebView/WebActionMenuHelper.h:26 > +#import <Foundation/Foundation.h>
This shouldn’t be necessary thanks to the prefix header.
> Source/WebKit/mac/WebView/WebActionMenuHelper.h:31 > +@interface WebActionMenuHelper : NSObject > +{
More often than not, we put the curly brace on the same line as @interface. You should also add a @private line before the ivar declaration.
> Source/WebKit/mac/WebView/WebActionMenuHelper.mm:32 > +
No need for this newline
> Source/WebKit/mac/WebView/WebActionMenuHelper.mm:62 > + _webView = webView;
Like I asked Tim in the other patch: what keeps us from using this ivar after the WebView is deallocated?
> Source/WebKit/mac/WebView/WebActionMenuHelper.mm:69 > + if (menu != [_webView actionMenu])
_webView.actionMenu Maybe we should keep it in a local variable here so that we don’t call -actionMenu three times.
> Source/WebKit/mac/WebView/WebActionMenuHelper.mm:86 > + if (url == nil)
if (!url)
> Source/WebKit/mac/WebView/WebActionMenuHelper.mm:88 > +
Perhaps we should assert that url is really an NSURL.
> Source/WebKit/mac/WebView/WebActionMenuHelper.mm:95 > + if (url == nil)
Ditto
> Source/WebKit/mac/WebView/WebActionMenuHelper.mm:104 > + if (domElement == nil)
!domElement
> Source/WebKit/mac/WebView/WebActionMenuHelper.mm:121 > + NSDictionary *hitTestResult = [sender representedObject];
Perhaps we should assert that this is really an NSDictionary (or nil).
> Source/WebKit/mac/WebView/WebActionMenuHelper.mm:123 > + if (url == nil)
!url
> Source/WebKit/mac/WebView/WebActionMenuHelper.mm:127 > + if (domElement == nil)
!domElement
> Source/WebKit/mac/WebView/WebActionMenuHelper.mm:134 > + QuickLookUILibrary(); > + RetainPtr<QLPreviewBubble> bubble = adoptNS([[NSClassFromString(@"QLPreviewBubble") alloc] init]);
Instead of NSClassFromString(…), you should use getQLPreviewBubbleClass(), which takes care of loading the library, and remove the explicit QuickLookUILibrary.
> Source/WebKit/mac/WebView/WebActionMenuHelper.mm:149 > + SEL selector = nil;
SEL is not an id, so this should be nullptr, not nil.
> Source/WebKit/mac/WebView/WebActionMenuHelper.mm:191 > + return [[NSBundle bundleForClass:[WebView class]] imageForResource:name];
If you changed this to [WKView class], then it would look in the WebKit.framework bundle (rather than the WebKitLegacy.framework bundle) and you wouldn’t need to add the image to this project at all!
> Source/WebKit/mac/WebView/WebActionMenuHelper.mm:197 > + if (url == nil)
!url
> Source/WebKit/mac/WebView/WebActionMenuHelper.mm:207 > + return @[openLinkItem.get(), previewLinkItem.get(), [NSMenuItem separatorItem], readingListItem.get()];
Please add spaces after @[ and before ].
> Source/WebKit/mac/WebView/WebActionMenuHelper.mm:213 > + if (url != nil)
!url
> Source/WebKit/mac/WebView/WebActionMenuHelper.mm:216 > + return @[];
@[ ]
> Source/WebKit/mac/WebView/WebView.mm:1070 > + [self setActionMenu:actionMenu.get()];
self.actionMenu = …
> Source/WebKit/mac/WebView/WebView.mm:1071 > + _private->actionMenuHelper = [[[WebActionMenuHelper alloc] initWithWebView:self] retain];
This is an over-retain, because +alloc already gives you ownership of the object.
Beth Dakin
Comment 4
2014-10-24 12:14:48 PDT
Thank you for your comments, Dan! (In reply to
comment #3
)
> Comment on
attachment 240381
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=240381&action=review
> > > Source/WebKit/mac/WebView/WebActionMenuHelper.h:26 > > +#import <Foundation/Foundation.h> > > This shouldn’t be necessary thanks to the prefix header. >
Good to know! Fixed.
> > Source/WebKit/mac/WebView/WebActionMenuHelper.h:31 > > +@interface WebActionMenuHelper : NSObject > > +{ > > More often than not, we put the curly brace on the same line as @interface. > You should also add a @private line before the ivar declaration. >
Fixed.
> > Source/WebKit/mac/WebView/WebActionMenuHelper.mm:32 > > + > > No need for this newline >
Fixed.
> > Source/WebKit/mac/WebView/WebActionMenuHelper.mm:62 > > + _webView = webView; > > Like I asked Tim in the other patch: what keeps us from using this ivar > after the WebView is deallocated? >
Hopefully this whole class will be deallocated while the WebView is being deallocated. WebViewData has the reference to the WebActionMenuHelper, and the WebView releases the WebViewData in its dealloc, and the WebViewData releases the WebActionMenuHelper in its dealloc. So I think we're okay, but please correct me if I am wrong.
> > Source/WebKit/mac/WebView/WebActionMenuHelper.mm:69 > > + if (menu != [_webView actionMenu]) > > _webView.actionMenu > > Maybe we should keep it in a local variable here so that we don’t call > -actionMenu three times. >
Fixed.
> > Source/WebKit/mac/WebView/WebActionMenuHelper.mm:86 > > + if (url == nil) > > if (!url) >
Fixed.
> > Source/WebKit/mac/WebView/WebActionMenuHelper.mm:88 > > + > > Perhaps we should assert that url is really an NSURL. >
Fixed.
> > Source/WebKit/mac/WebView/WebActionMenuHelper.mm:95 > > + if (url == nil) > > Ditto >
Fixed.
> > Source/WebKit/mac/WebView/WebActionMenuHelper.mm:104 > > + if (domElement == nil) > > !domElement >
Fixed.
> > Source/WebKit/mac/WebView/WebActionMenuHelper.mm:121 > > + NSDictionary *hitTestResult = [sender representedObject]; > > Perhaps we should assert that this is really an NSDictionary (or nil). >
Fixed.
> > Source/WebKit/mac/WebView/WebActionMenuHelper.mm:123 > > + if (url == nil) > > !url >
Fixed.
> > Source/WebKit/mac/WebView/WebActionMenuHelper.mm:127 > > + if (domElement == nil) > > !domElement >
Fixed.
> > Source/WebKit/mac/WebView/WebActionMenuHelper.mm:134 > > + QuickLookUILibrary(); > > + RetainPtr<QLPreviewBubble> bubble = adoptNS([[NSClassFromString(@"QLPreviewBubble") alloc] init]); > > Instead of NSClassFromString(…), you should use getQLPreviewBubbleClass(), > which takes care of loading the library, and remove the explicit > QuickLookUILibrary. >
Oh, yay! Fixed.
> > Source/WebKit/mac/WebView/WebActionMenuHelper.mm:149 > > + SEL selector = nil; > > SEL is not an id, so this should be nullptr, not nil. >
Fixed.
> > Source/WebKit/mac/WebView/WebActionMenuHelper.mm:191 > > + return [[NSBundle bundleForClass:[WebView class]] imageForResource:name]; > > If you changed this to [WKView class], then it would look in the > WebKit.framework bundle (rather than the WebKitLegacy.framework bundle) and > you wouldn’t need to add the image to this project at all! >
WebKit did not want to build with this because it didn't know what a WKView does. Should I do something to forward declare it? Is that okay?
> > Source/WebKit/mac/WebView/WebActionMenuHelper.mm:197 > > + if (url == nil) > > !url >
Fixed.
> > Source/WebKit/mac/WebView/WebActionMenuHelper.mm:207 > > + return @[openLinkItem.get(), previewLinkItem.get(), [NSMenuItem separatorItem], readingListItem.get()]; > > Please add spaces after @[ and before ]. >
Fixed.
> > Source/WebKit/mac/WebView/WebActionMenuHelper.mm:213 > > + if (url != nil) > > !url >
Fixed.
> > Source/WebKit/mac/WebView/WebActionMenuHelper.mm:216 > > + return @[]; > > @[ ] >
Fixed.
> > Source/WebKit/mac/WebView/WebView.mm:1070 > > + [self setActionMenu:actionMenu.get()]; > > self.actionMenu = … >
Fixed.
> > Source/WebKit/mac/WebView/WebView.mm:1071 > > + _private->actionMenuHelper = [[[WebActionMenuHelper alloc] initWithWebView:self] retain]; > > This is an over-retain, because +alloc already gives you ownership of the > object.
Fixed!
Beth Dakin
Comment 5
2014-10-24 12:17:43 PDT
Created
attachment 240423
[details]
Patch that addresses Dan's comments
WebKit Commit Bot
Comment 6
2014-10-24 12:19:48 PDT
Attachment 240423
[details]
did not pass style-queue: ERROR: Source/WebKit/mac/WebView/WebActionMenuController.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 8 files If any of these errors are false positives, please file a bug against check-webkit-style.
mitz
Comment 7
2014-10-24 13:10:05 PDT
Comment on
attachment 240381
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=240381&action=review
>>> Source/WebKit/mac/WebView/WebActionMenuHelper.mm:62 >>> + _webView = webView; >> >> Like I asked Tim in the other patch: what keeps us from using this ivar after the WebView is deallocated? > > Hopefully this whole class will be deallocated while the WebView is being deallocated. WebViewData has the reference to the WebActionMenuHelper, and the WebView releases the WebViewData in its dealloc, and the WebViewData releases the WebActionMenuHelper in its dealloc. So I think we're okay, but please correct me if I am wrong.
My point is more that there are no hard guarantees about object lifetimes in Objective-C. Even if the WebViewData is released, and even if that release causes it to be deallocated, and that causes the helper to be released, it’s still possible that the helper won’t be deallocated immediately, because some other object got a strong reference to it, or it found its way into an autorelease pool. In practice, perhaps this won’t matter because at least we know that once the WebView is gone, nothing can message the helper and cause it to do anything that references the WebView. If we weren’t (or aren’t) sure of that, we could do something safer and have an explicit way for the WebView’s -dealloc (or -close) to tell the helper that it’s going away.
>>> Source/WebKit/mac/WebView/WebActionMenuHelper.mm:191 >>> + return [[NSBundle bundleForClass:[WebView class]] imageForResource:name]; >> >> If you changed this to [WKView class], then it would look in the WebKit.framework bundle (rather than the WebKitLegacy.framework bundle) and you wouldn’t need to add the image to this project at all! > > WebKit did not want to build with this because it didn't know what a WKView does. Should I do something to forward declare it? Is that okay?
No need to forward declare, just NSClassFromString() it!
Beth Dakin
Comment 8
2014-10-24 14:01:49 PDT
Created
attachment 240435
[details]
Patch
WebKit Commit Bot
Comment 9
2014-10-24 14:04:13 PDT
Attachment 240435
[details]
did not pass style-queue: ERROR: Source/WebKit/mac/WebView/WebActionMenuController.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 8 files If any of these errors are false positives, please file a bug against check-webkit-style.
Tim Horton
Comment 10
2014-10-24 14:38:53 PDT
Comment on
attachment 240435
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=240435&action=review
> Source/WebKit/mac/WebView/WebActionMenuController.mm:82 > + NSDictionary *hitTestResult = [_webView elementAtPoint:[_webView convertPoint:[event locationInWindow] fromView:nil]];
event.locationInWindow
> Source/WebKit/mac/WebView/WebActionMenuController.mm:96 > + NSURL *url = [sender representedObject];
dots.
Beth Dakin
Comment 11
2014-10-24 15:02:04 PDT
http://trac.webkit.org/changeset/175182
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug