Changeset 270946 in webkit
- Timestamp:
- Dec 17, 2020 2:21:07 PM (19 months ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 8 edited
-
ChangeLog (modified) (1 diff)
-
Shared/mac/PDFContextMenu.h (modified) (2 diffs)
-
UIProcess/WebPageProxy.h (modified) (1 diff)
-
UIProcess/WebPageProxy.messages.in (modified) (1 diff)
-
UIProcess/mac/WebPageProxyMac.mm (modified) (4 diffs)
-
WebProcess/Plugins/PDF/PDFPlugin.h (modified) (1 diff)
-
WebProcess/Plugins/PDF/PDFPlugin.mm (modified) (3 diffs)
-
WebProcess/Plugins/PDFPluginIdentifier.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r270942 r270946 1 2020-12-17 Alex Christensen <achristensen@webkit.org> 2 3 Fix "Open with Preview" menu item in PDF context menus on Big Sur 4 https://bugs.webkit.org/show_bug.cgi?id=219986 5 <rdar://problem/72406073> 6 7 Reviewed by Geoffrey Garen. 8 9 In r266654 I removed the ability for the web process to open a PDF in Preview on Big Sur. 10 I overlooked the fact that context menus also allow you to open a PDF in Preview, 11 which this fixes by having the UI process initiate the Preview opening if the user clicks on 12 the context menu item with the correct index. 13 14 * Shared/mac/PDFContextMenu.h: 15 (WebKit::PDFContextMenu::encode const): 16 (WebKit::PDFContextMenu::decode): 17 * UIProcess/WebPageProxy.h: 18 * UIProcess/WebPageProxy.messages.in: 19 * UIProcess/mac/WebPageProxyMac.mm: 20 (WebKit::WebPageProxy::showPDFContextMenu): 21 * WebProcess/Plugins/PDF/PDFPlugin.mm: 22 (WebKit::PDFPlugin::handleContextMenuEvent): 23 1 24 2020-12-17 Kate Cheney <katherine_cheney@apple.com> 2 25 -
trunk/Source/WebKit/Shared/mac/PDFContextMenu.h
r239427 r270946 79 79 80 80 struct PDFContextMenu { 81 WebCore::IntPoint m_point; 82 Vector<PDFContextMenuItem> m_items; 81 WebCore::IntPoint point; 82 Vector<PDFContextMenuItem> items; 83 Optional<int> openInPreviewIndex; 83 84 84 85 template<class Encoder> void encode(Encoder& encoder) const 85 86 { 86 encoder << m_point << m_items;87 encoder << point << items << openInPreviewIndex; 87 88 } 88 89 … … 98 99 if (!items) 99 100 return WTF::nullopt; 100 101 return { { WTFMove(*point), WTFMove(*items) } }; 101 102 Optional<Optional<int>> openInPreviewIndex; 103 decoder >> openInPreviewIndex; 104 if (!openInPreviewIndex) 105 return WTF::nullopt; 106 107 return {{ 108 WTFMove(*point), 109 WTFMove(*items), 110 WTFMove(*openInPreviewIndex) 111 }}; 102 112 } 103 113 -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r270712 r270946 1335 1335 1336 1336 #if ENABLE(PDFKIT_PLUGIN) 1337 void showPDFContextMenu(const WebKit::PDFContextMenu&, CompletionHandler<void(Optional<int32_t>&&)>&&);1337 void showPDFContextMenu(const WebKit::PDFContextMenu&, PDFPluginIdentifier, CompletionHandler<void(Optional<int32_t>&&)>&&); 1338 1338 #endif 1339 1339 WebCore::IntRect visibleScrollerThumbRect() const { return m_visibleScrollerThumbRect; } -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r270577 r270946 441 441 442 442 #if ENABLE(PDFKIT_PLUGIN) 443 ShowPDFContextMenu(struct WebKit::PDFContextMenu contextMenu ) -> (Optional<int32_t> selectedItem) Synchronous443 ShowPDFContextMenu(struct WebKit::PDFContextMenu contextMenu, WebKit::PDFPluginIdentifier identifier) -> (Optional<int32_t> selectedItem) Synchronous 444 444 #endif 445 445 -
trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm
r270577 r270946 541 541 542 542 #if ENABLE(PDFKIT_PLUGIN) 543 void WebPageProxy::showPDFContextMenu(const WebKit::PDFContextMenu& contextMenu, CompletionHandler<void(Optional<int32_t>&&)>&& completionHandler)544 { 545 if (!contextMenu. m_items.size())543 void WebPageProxy::showPDFContextMenu(const WebKit::PDFContextMenu& contextMenu, PDFPluginIdentifier identifier, CompletionHandler<void(Optional<int32_t>&&)>&& completionHandler) 544 { 545 if (!contextMenu.items.size()) 546 546 return completionHandler(WTF::nullopt); 547 547 … … 549 549 RetainPtr<NSMenu> nsMenu = adoptNS([[NSMenu alloc] init]); 550 550 [nsMenu setAllowsContextMenuPlugIns:false]; 551 for (unsigned i = 0; i < contextMenu. m_items.size(); i++) {552 auto& item = contextMenu. m_items[i];551 for (unsigned i = 0; i < contextMenu.items.size(); i++) { 552 auto& item = contextMenu.items[i]; 553 553 554 554 if (item.separator) { … … 570 570 NSWindow *window = pageClient().platformWindow(); 571 571 auto windowNumber = [window windowNumber]; 572 auto location = [window convertRectFromScreen: { contextMenu. m_point, NSZeroSize }].origin;572 auto location = [window convertRectFromScreen: { contextMenu.point, NSZeroSize }].origin; 573 573 NSEvent* event = [NSEvent mouseEventWithType:NSEventTypeRightMouseDown location:location modifierFlags:0 timestamp:0 windowNumber:windowNumber context:0 eventNumber:0 clickCount:1 pressure:1]; 574 574 … … 576 576 [NSMenu popUpContextMenu:nsMenu.get() withEvent:event forView:view]; 577 577 578 if (auto selectedMenuItem = [menuTarget selectedMenuItem]) 579 return completionHandler([selectedMenuItem tag]); 578 if (auto selectedMenuItem = [menuTarget selectedMenuItem]) { 579 NSInteger tag = selectedMenuItem.tag; 580 #if ENABLE(UI_PROCESS_PDF_HUD) 581 if (contextMenu.openInPreviewIndex && *contextMenu.openInPreviewIndex == tag) 582 pdfOpenWithPreview(identifier); 583 #else 584 UNUSED_PARAM(identifier); 585 #endif 586 return completionHandler(tag); 587 } 580 588 completionHandler(WTF::nullopt); 581 589 } -
trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.h
r270573 r270946 428 428 429 429 #endif // HAVE(INCREMENTAL_PDF_APIS) 430 #if ENABLE(UI_PROCESS_PDF_HUD)431 430 PDFPluginIdentifier m_identifier; 432 #endif433 431 }; 434 432 -
trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
r270557 r270946 607 607 , m_incrementalPDFLoadingEnabled(WebCore::RuntimeEnabledFeatures::sharedFeatures().incrementalPDFLoadingEnabled()) 608 608 #endif 609 #if ENABLE(UI_PROCESS_PDF_HUD)610 609 , m_identifier(PDFPluginIdentifier::generate()) 611 #endif612 610 { 613 611 #if ENABLE(UI_PROCESS_PDF_HUD) … … 2319 2317 return false; 2320 2318 2319 Optional<int> openInPreviewIndex; 2321 2320 Vector<PDFContextMenuItem> items; 2322 2321 auto itemCount = [nsMenu numberOfItems]; … … 2325 2324 if ([item submenu]) 2326 2325 continue; 2326 if ([NSStringFromSelector(item.action) isEqualToString:@"openWithPreview"]) 2327 openInPreviewIndex = i; 2327 2328 PDFContextMenuItem menuItem { String([item title]), !![item isEnabled], !![item isSeparatorItem], static_cast<int>([item state]), !![item action], i }; 2328 2329 items.append(WTFMove(menuItem)); 2329 2330 } 2330 PDFContextMenu contextMenu { point, WTFMove(items) };2331 PDFContextMenu contextMenu { point, WTFMove(items), WTFMove(openInPreviewIndex) }; 2331 2332 2332 2333 Optional<int> selectedIndex = -1; 2333 webPage->sendSync(Messages::WebPageProxy::ShowPDFContextMenu(contextMenu ), Messages::WebPageProxy::ShowPDFContextMenu::Reply(selectedIndex));2334 webPage->sendSync(Messages::WebPageProxy::ShowPDFContextMenu(contextMenu, m_identifier), Messages::WebPageProxy::ShowPDFContextMenu::Reply(selectedIndex)); 2334 2335 2335 2336 if (selectedIndex && *selectedIndex >= 0 && *selectedIndex < itemCount) -
trunk/Source/WebKit/WebProcess/Plugins/PDFPluginIdentifier.h
r266654 r270946 30 30 namespace WebKit { 31 31 32 #if ENABLE(UI_PROCESS_PDF_HUD)33 32 enum PDFPluginIdentifierType { }; 34 33 using PDFPluginIdentifier = ObjectIdentifier<PDFPluginIdentifierType>; 35 #endif36 34 37 35 }
Note: See TracChangeset
for help on using the changeset viewer.