WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
57527
WebKit2: No "open in preview" contextual menu item for PDFs
https://bugs.webkit.org/show_bug.cgi?id=57527
Summary
WebKit2: No "open in preview" contextual menu item for PDFs
Jer Noble
Reported
2011-03-30 23:56:21 PDT
PDFs cannot be opened in Preview through the context menu in WebKit2.
Attachments
Patch
(4.74 KB, patch)
2011-03-31 00:03 PDT
,
Jer Noble
no flags
Details
Formatted Diff
Diff
Patch
(4.84 KB, patch)
2011-03-31 01:20 PDT
,
Jer Noble
mitz: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Jer Noble
Comment 1
2011-03-30 23:56:51 PDT
<
rdar://problem/9210368
>
Jer Noble
Comment 2
2011-03-31 00:03:49 PDT
Created
attachment 87674
[details]
Patch
mitz
Comment 3
2011-03-31 00:29:54 PDT
Comment on
attachment 87674
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=87674&action=review
Too many comments to r+. I suspect that this is leaking menu items.
> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:66 > + CFRelease (appURL);
Extra space after CFRelease. Given that you’re using this variable twice as a CFURLRef an only once as an NSURL *, I would define it as a CFURLRef and cast once.
> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:69 > + [*image setSize:NSMakeSize(16.f,16.f)];
Should be NSMakeSize(16, 16) without .f and with a space after the comma.
> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:71 > + NSString *appName = [[NSFileManager defaultManager] displayNameAtPath:appPath];
Not sure why this local is needed.
> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:224 > + NSMenu* menu = [[NSMenu alloc] initWithTitle:@""];
Space on the wrong side of the *.
> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:226 > + NSEnumerator *e = [[[_pdfView menuForEvent:theEvent] itemArray] objectEnumerator];
Please use a more descriptive name.
> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:228 > + while ((item = [e nextObject]) != nil) {
WebKit style is to omit “!= nil”
> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:230 > + NSMenuItem *itemCopy = [item copy]; > + [menu addItem:itemCopy];
Wow, we don’t need to release the item?
> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:242 > + if (!appName) > + // FIXME: Localize this. > + appName = @"Finder";
Need braces around these two lines.
> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:252 > + [menu addItem:item];
Don’t need to release item?
> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:265 > + return YES;
Strange that we copy the PDFView’s own items then decide for it that they’re always valid. But that’s what we do in WebKit1!
Jer Noble
Comment 4
2011-03-31 01:13:19 PDT
(In reply to
comment #3
)
> (From update of
attachment 87674
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=87674&action=review
> > Too many comments to r+. I suspect that this is leaking menu items.
You're right, I didn't check this nearly well enough when copying it from WebKit1.
>> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:66 >> + CFRelease (appURL); > > Extra space after CFRelease. Given that you’re using this variable twice as a CFURLRef an only once as an NSURL *, I would define it as a CFURLRef and cast once.
Absolutely. All changed.
>> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:69 >> + [*image setSize:NSMakeSize(16.f,16.f)]; > > Should be NSMakeSize(16, 16) without .f and with a space after the comma.
Changed.
>> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:71 >> + NSString *appName = [[NSFileManager defaultManager] displayNameAtPath:appPath]; > > Not sure why this local is needed.
Neither am I. Collapsed.
>> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:224 >> + NSMenu* menu = [[NSMenu alloc] initWithTitle:@""]; > > Space on the wrong side of the *.
Indeed. Swapped.
>> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:226 >> + NSEnumerator *e = [[[_pdfView menuForEvent:theEvent] itemArray] objectEnumerator]; > > Please use a more descriptive name.
Sure thing. "menuItemEnumerator".
>> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:228 >> + while ((item = [e nextObject]) != nil) { > > WebKit style is to omit “!= nil”
I think, in addition, the declaration can probably be pulled into the while conditional as well.
>> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:230 >> + [menu addItem:itemCopy]; > > Wow, we don’t need to release the item?
Totally untrue. We really do need to release the item. Good catch.
>> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:242 >> + appName = @"Finder"; > > Need braces around these two lines.
This was definitely my fault. Braced.
>> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:252 >> + [menu addItem:item]; > > Don’t need to release item?
I think we do. It was only above that we were doing the wrong thing.
>> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:265 >> + return YES; > > Strange that we copy the PDFView’s own items then decide for it that they’re always valid. But that’s what we do in WebKit1!
I think that the way this will work is: we don't change any of the copied menu items' targets, which are presumably the PDFView. So it will still get called on to validate those menu items. Posting a new patch shortly...
Jer Noble
Comment 5
2011-03-31 01:20:47 PDT
Created
attachment 87678
[details]
Patch
mitz
Comment 6
2011-04-03 16:21:15 PDT
Comment on
attachment 87678
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=87678&action=review
> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:62 > + CFURLRef appURL = nil;
Now that it’s a CF type, it should be = 0, not = nil.
> Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:68 > + NSString *appPath = [(NSURL*)appURL path];
Need space after NSURL
Jer Noble
Comment 7
2011-04-04 10:57:00 PDT
(In reply to
comment #6
)
> (From update of
attachment 87678
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=87678&action=review
> > > Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:62 > > + CFURLRef appURL = nil; > > Now that it’s a CF type, it should be = 0, not = nil.
Actually, since CFURLRef is a C-style opaque pointer, shouldn't it be NULL?
> > Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:68 > > + NSString *appPath = [(NSURL*)appURL path]; > > Need space after NSURL
Added. Thanks!
Jer Noble
Comment 8
2011-04-04 11:03:10 PDT
(In reply to
comment #7
)
> (In reply to
comment #6
) > > (From update of
attachment 87678
[details]
[details]) > > View in context:
https://bugs.webkit.org/attachment.cgi?id=87678&action=review
> > > > > Source/WebKit2/UIProcess/API/mac/PDFViewController.mm:62 > > > + CFURLRef appURL = nil; > > > > Now that it’s a CF type, it should be = 0, not = nil. > > Actually, since CFURLRef is a C-style opaque pointer, shouldn't it be NULL?
Looks like I'm confusing the language of the file with the language of the pointer. Changed.
Jer Noble
Comment 9
2011-04-04 12:19:50 PDT
Committed
r82852
: <
http://trac.webkit.org/changeset/82852
>
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