Changeset 266654 in webkit
- Timestamp:
- Sep 4, 2020, 9:07:47 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 30 edited
- 2 copied
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/wtf/PlatformEnableCocoa.h (modified) (1 diff)
-
Source/WebCore/PAL/pal/spi/mac/NSImageSPI.h (modified) (3 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/Scripts/webkit/messages.py (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/API/mac/WKWebViewPrivateForTestingMac.h (modified) (1 diff)
-
Source/WebKit/UIProcess/API/mac/WKWebViewTestingMac.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/Cocoa/WebViewImpl.h (modified) (4 diffs)
-
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (modified) (6 diffs)
-
Source/WebKit/UIProcess/PDF (added)
-
Source/WebKit/UIProcess/PDF/WKPDFHUDView.h (copied) (copied from trunk/Tools/TestWebKitAPI/cocoa/TestUIDelegate.h ) (1 diff)
-
Source/WebKit/UIProcess/PDF/WKPDFHUDView.mm (added)
-
Source/WebKit/UIProcess/PageClient.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebPageProxy.cpp (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebPageProxy.h (modified) (3 diffs)
-
Source/WebKit/UIProcess/WebPageProxy.messages.in (modified) (2 diffs)
-
Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/mac/PageClientImplMac.h (modified) (1 diff)
-
Source/WebKit/UIProcess/mac/PageClientImplMac.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (modified) (5 diffs)
-
Source/WebKit/WebKit.xcodeproj/project.pbxproj (modified) (6 diffs)
-
Source/WebKit/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h (modified) (1 diff)
-
Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.h (modified) (8 diffs)
-
Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm (modified) (9 diffs)
-
Source/WebKit/WebProcess/Plugins/PDFPluginIdentifier.h (copied) (copied from trunk/Tools/TestWebKitAPI/cocoa/TestUIDelegate.h ) (1 diff)
-
Source/WebKit/WebProcess/WebPage/WebPage.cpp (modified) (2 diffs)
-
Source/WebKit/WebProcess/WebPage/WebPage.h (modified) (4 diffs)
-
Source/WebKit/WebProcess/WebPage/WebPage.messages.in (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (modified) (2 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKPDFView.mm (modified) (3 diffs)
-
Tools/TestWebKitAPI/cocoa/TestUIDelegate.h (modified) (1 diff)
-
Tools/TestWebKitAPI/cocoa/TestUIDelegate.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r266579 r266654 1 2020-09-04 Alex Christensen <achristensen@webkit.org> 2 3 Move PDF heads-up display to UI process on macOS 4 https://bugs.webkit.org/show_bug.cgi?id=215780 5 <rdar://problem/58715847> 6 7 Reviewed by Tim Horton. 8 9 * wtf/PlatformHave.h: 10 1 11 2020-09-03 Ryosuke Niwa <rniwa@webkit.org> 2 12 -
trunk/Source/WTF/wtf/PlatformEnableCocoa.h
r265823 r266654 229 229 #endif 230 230 231 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 110000 232 #define ENABLE_UI_PROCESS_PDF_HUD 1 233 #endif 234 231 235 #if !defined(ENABLE_INDEXED_DATABASE) 232 236 #define ENABLE_INDEXED_DATABASE 1 -
trunk/Source/WebCore/PAL/pal/spi/mac/NSImageSPI.h
r265010 r266654 37 37 38 38 @interface NSImage () 39 + (instancetype)imageWithImageRep:(NSImageRep *)imageRep; 40 - (instancetype)_imageWithConfiguration:(NSDictionary *)configuration; 39 41 - (void)lockFocusWithRect:(NSRect)rect context:(nullable NSGraphicsContext *)context hints:(nullable NSDictionary *)hints flipped:(BOOL)flipped; 40 42 @end … … 43 45 + (nullable NSImage *)_imageWithSystemSymbolName:(NSString *) symbolName; 44 46 @end 47 48 WTF_EXTERN_C_BEGIN 49 50 extern const NSString *NSImageAlternateCriterionFont; 51 extern const NSString *NSImageAlternateCriterionSymbolScale; 52 53 WTF_EXTERN_C_END 45 54 46 55 NS_ASSUME_NONNULL_END … … 57 66 NS_ASSUME_NONNULL_END 58 67 59 #endif 68 #endif // HAVE(ALTERNATE_ICONS) 60 69 61 #endif 70 #endif // USE(APPLE_INTERNAL_SDK) -
trunk/Source/WebKit/ChangeLog
r266650 r266654 1 2020-09-04 Alex Christensen <achristensen@webkit.org> 2 3 Move PDF heads-up display to UI process on macOS 4 https://bugs.webkit.org/show_bug.cgi?id=215780 5 <rdar://problem/58715847> 6 7 Reviewed by Tim Horton. 8 9 This has many benefits including the one in the radar, testability, and moving WebKit-specific code from PDFKit to WebKit. 10 11 Now that the HUD is displayed in the UI process instead of in the web content, zooming in keeps the HUD the same size. 12 A 3d-transformed iframe with a PDF in it now shows the HUD in the place you can click on it, instead of in the transformed PDF. 13 Also, moving the mouse to the HUD within the first 3 seconds prevents it from hiding, which it does when the mouse leaves the HUD. 14 The rest of the behavior I think should be the same. Most users should not notice any difference. 15 16 Functionality covered by API tests, the first tests for PDF content interaction! 17 18 * Scripts/webkit/messages.py: 19 * UIProcess/API/Cocoa/WKWebViewInternal.h: 20 * UIProcess/API/mac/WKView.mm: 21 (-[WKView _createPDFHUD:rect:]): 22 (-[WKView _pdfHUD:changedLocation:]): 23 (-[WKView _removePDFHUD:]): 24 (-[WKView _removeAllPDFHUDs]): 25 * UIProcess/API/mac/WKWebViewMac.mm: 26 (-[WKWebView mouseMoved:]): 27 (-[WKWebView mouseDown:]): 28 (-[WKWebView mouseUp:]): 29 (-[WKWebView _createPDFHUD:rect:]): 30 (-[WKWebView _pdfHUD:changedLocation:]): 31 (-[WKWebView _removePDFHUD:]): 32 (-[WKWebView _removeAllPDFHUDs]): 33 * UIProcess/API/mac/WKWebViewPrivateForTestingMac.h: 34 * UIProcess/API/mac/WKWebViewTestingMac.mm: 35 (-[WKWebView pdfHUDs]): 36 * UIProcess/Cocoa/WebViewImpl.h: 37 * UIProcess/Cocoa/WebViewImpl.mm: 38 (WebKit::WebViewImpl::createPDFHUD): 39 (WebKit::WebViewImpl::updatePDFHUDLocation): 40 (WebKit::WebViewImpl::removePDFHUD): 41 (WebKit::WebViewImpl::removeAllPDFHUDs): 42 * UIProcess/PageClient.h: 43 * UIProcess/WebPageProxy.cpp: 44 (WebKit::WebPageProxy::didCommitLoadForFrame): 45 (WebKit::WebPageProxy::processDidTerminate): 46 * UIProcess/WebPageProxy.h: 47 * UIProcess/WebPageProxy.messages.in: 48 * UIProcess/ios/WebPageProxyIOS.mm: 49 (WebKit::WebPageProxy::savePDFToTemporaryFolderAndOpenWithNativeApplication): Deleted. 50 (WebKit::WebPageProxy::openPDFFromTemporaryFolderWithNativeApplication): Deleted. 51 * UIProcess/mac/PageClientImplMac.h: 52 * UIProcess/mac/PageClientImplMac.mm: 53 (WebKit::PageClientImpl::createPDFHUD): 54 (WebKit::PageClientImpl::updatePDFHUDLocation): 55 (WebKit::PageClientImpl::removePDFHUD): 56 (WebKit::PageClientImpl::removeAllPDFHUDs): 57 * UIProcess/mac/WebPageProxyMac.mm: 58 (WebKit::WebPageProxy::savePDFToTemporaryFolderAndOpenWithNativeApplication): 59 (WebKit::WebPageProxy::createPDFHUD): 60 (WebKit::WebPageProxy::removePDFHUD): 61 (WebKit::WebPageProxy::updatePDFHUDLocation): 62 (WebKit::WebPageProxy::pdfZoomIn): 63 (WebKit::WebPageProxy::pdfZoomOut): 64 (WebKit::WebPageProxy::pdfSaveToPDF): 65 (WebKit::WebPageProxy::pdfOpenWithPreview): 66 * WebKit.xcodeproj/project.pbxproj: 67 * WebProcess/Plugins/PDF/PDFLayerControllerSPI.h: 68 * WebProcess/Plugins/PDF/PDFPlugin.h: 69 * WebProcess/Plugins/PDF/PDFPlugin.mm: 70 (-[WKPDFLayerControllerDelegate openWithNativeApplication]): 71 (-[WKPDFLayerControllerDelegate saveToPDF]): 72 (WebKit::PDFPlugin::PDFPlugin): 73 (WebKit::PDFPlugin::~PDFPlugin): 74 (WebKit::PDFPlugin::frameForHUD const): 75 (WebKit::PDFPlugin::calculateSizes): 76 (WebKit::PDFPlugin::convertFromPDFViewToRootView const): 77 (WebKit::PDFPlugin::visibilityDidChange): 78 (WebKit::PDFPlugin::zoomIn): 79 (WebKit::PDFPlugin::zoomOut): 80 (WebKit::PDFPlugin::save): 81 (WebKit::PDFPlugin::openWithPreview): 82 * WebProcess/WebPage/WebPage.cpp: 83 * WebProcess/WebPage/WebPage.h: 84 * WebProcess/WebPage/WebPage.messages.in: 85 * WebProcess/WebPage/mac/WebPageMac.mm: 86 (WebKit::WebPage::zoomPDFIn): 87 (WebKit::WebPage::zoomPDFOut): 88 (WebKit::WebPage::savePDF): 89 (WebKit::WebPage::openPDFWithPreview): 90 (WebKit::WebPage::createPDFHUD): 91 (WebKit::WebPage::updatePDFHUDLocation): 92 (WebKit::WebPage::removePDFHUD): 93 1 94 2020-09-04 Chris Dumez <cdumez@apple.com> 2 95 -
trunk/Source/WebKit/Scripts/webkit/messages.py
r266467 r266654 245 245 'WebKit::MediaPlayerPrivateRemoteIdentifier', 246 246 'WebKit::MediaRecorderIdentifier', 247 'WebKit::PDFPluginIdentifier', 247 248 'WebKit::PlaybackSessionContextIdentifier', 248 249 'WebKit::PluginProcessType', -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h
r265284 r266654 24 24 */ 25 25 26 #import "WKWebViewPrivate.h" 27 26 #import "PDFPluginIdentifier.h" 28 27 #import "SameDocumentNavigationType.h" 29 28 #import "WKShareSheet.h" 30 29 #import "WKWebViewConfiguration.h" 30 #import "WKWebViewPrivate.h" 31 31 #import "_WKAttachmentInternal.h" 32 32 #import "_WKWebViewPrintFormatterInternal.h" … … 134 134 RetainPtr<WKScrollView> _scrollView; 135 135 RetainPtr<WKContentView> _contentView; 136 #endif 136 #endif // PLATFORM(MAC) 137 137 138 138 #if PLATFORM(IOS_FAMILY) -
trunk/Source/WebKit/UIProcess/API/mac/WKWebViewPrivateForTestingMac.h
r255322 r266654 51 51 - (void)_setHeaderBannerHeight:(int)height; 52 52 - (void)_setFooterBannerHeight:(int)height; 53 - (NSSet<NSView *> *)_pdfHUDs; 53 54 54 55 @end -
trunk/Source/WebKit/UIProcess/API/mac/WKWebViewTestingMac.mm
r266051 r266654 104 104 } 105 105 106 - (NSSet<NSView *> *)_pdfHUDs 107 { 108 #if ENABLE(UI_PROCESS_PDF_HUD) 109 return _impl->pdfHUDs(); 110 #else 111 return nil; 112 #endif 113 } 114 106 115 - (NSMenu *)_activeMenu 107 116 { -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h
r260186 r266654 28 28 #if PLATFORM(MAC) 29 29 30 #include "PDFPluginIdentifier.h" 30 31 #include "PluginComplexTextInputState.h" 31 32 #include "ShareableBitmap.h" … … 77 78 #endif // HAVE(TOUCH_BAR) 78 79 80 #if ENABLE(UI_PROCESS_PDF_HUD) 81 OBJC_CLASS WKPDFHUDView; 82 #endif 83 79 84 namespace API { 80 85 class HitTestResult; … … 190 195 void viewWillStartLiveResize(); 191 196 void viewDidEndLiveResize(); 197 198 #if ENABLE(UI_PROCESS_PDF_HUD) 199 void createPDFHUD(PDFPluginIdentifier, const WebCore::IntRect&); 200 void updatePDFHUDLocation(PDFPluginIdentifier, const WebCore::IntRect&); 201 void removePDFHUD(PDFPluginIdentifier); 202 void removeAllPDFHUDs(); 203 NSSet *pdfHUDs(); 204 #endif 192 205 193 206 void renewGState(); … … 730 743 RetainPtr<WKFullScreenWindowController> m_fullScreenWindowController; 731 744 #endif 732 745 746 #if ENABLE(UI_PROCESS_PDF_HUD) 747 HashMap<WebKit::PDFPluginIdentifier, RetainPtr<WKPDFHUDView>> _pdfHUDViews; 748 #endif 749 733 750 RetainPtr<WKShareSheet> _shareSheet; 734 751 -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
r266051 r266654 63 63 #import "WKFullScreenWindowController.h" 64 64 #import "WKImmediateActionController.h" 65 #import "WKPDFHUDView.h" 65 66 #import "WKPrintingView.h" 66 67 #import "WKSafeBrowsingWarning.h" … … 1719 1720 } 1720 1721 1722 #if ENABLE(UI_PROCESS_PDF_HUD) 1723 1724 void WebViewImpl::createPDFHUD(PDFPluginIdentifier identifier, const WebCore::IntRect& rect) 1725 { 1726 removePDFHUD(identifier); 1727 auto hud = adoptNS([[WKPDFHUDView alloc] initWithFrame:rect pluginIdentifier:identifier page:m_page.get()]); 1728 [m_view addSubview:hud.get()]; 1729 _pdfHUDViews.add(identifier, WTFMove(hud)); 1730 } 1731 1732 void WebViewImpl::updatePDFHUDLocation(PDFPluginIdentifier identifier, const WebCore::IntRect& rect) 1733 { 1734 if (auto hud = _pdfHUDViews.get(identifier)) 1735 [hud setFrame:rect]; 1736 } 1737 1738 void WebViewImpl::removePDFHUD(PDFPluginIdentifier identifier) 1739 { 1740 if (auto hud = _pdfHUDViews.take(identifier)) 1741 [hud removeFromSuperview]; 1742 } 1743 1744 void WebViewImpl::removeAllPDFHUDs() 1745 { 1746 for (auto& hud : _pdfHUDViews.values()) 1747 [hud removeFromSuperview]; 1748 _pdfHUDViews.clear(); 1749 } 1750 1751 NSSet *WebViewImpl::pdfHUDs() 1752 { 1753 NSMutableSet<NSView *> *set = [NSMutableSet setWithCapacity:_pdfHUDViews.size()]; 1754 for (auto& hud : _pdfHUDViews.values()) 1755 [set addObject:hud.get()]; 1756 return set; 1757 } 1758 1759 #endif // ENABLE(UI_PROCESS_PDF_HUD) 1760 1721 1761 void WebViewImpl::renewGState() 1722 1762 { … … 2150 2190 2151 2191 m_page->setIntrinsicDeviceScaleFactor(newBackingScaleFactor); 2192 #if ENABLE(UI_PROCESS_PDF_HUD) 2193 for (auto& hud : _pdfHUDViews.values()) 2194 [hud setDeviceScaleFactor:newBackingScaleFactor]; 2195 #endif 2152 2196 } 2153 2197 … … 5392 5436 return; 5393 5437 5438 #if ENABLE(UI_PROCESS_PDF_HUD) 5439 for (auto& hud : _pdfHUDViews.values()) 5440 [hud mouseMoved:event]; 5441 #endif 5442 5394 5443 // When a view is first responder, it gets mouse moved events even when the mouse is outside its visible rect. 5395 5444 if (m_view.getAutoreleased() == [m_view window].firstResponder && !NSPointInRect([m_view convertPoint:[event locationInWindow] fromView:nil], [m_view visibleRect])) … … 5440 5489 return; 5441 5490 5491 #if ENABLE(UI_PROCESS_PDF_HUD) 5492 for (auto& hud : _pdfHUDViews.values()) 5493 [hud mouseDown:event]; 5494 #endif 5495 5442 5496 setLastMouseDownEvent(event); 5443 5497 setIgnoresMouseDraggedEvents(false); … … 5450 5504 if (m_ignoresNonWheelEvents) 5451 5505 return; 5506 5507 #if ENABLE(UI_PROCESS_PDF_HUD) 5508 for (auto& hud : _pdfHUDViews.values()) 5509 [hud mouseUp:event]; 5510 #endif 5452 5511 5453 5512 setLastMouseDownEvent(nil); -
trunk/Source/WebKit/UIProcess/PDF/WKPDFHUDView.h
r266653 r266654 24 24 */ 25 25 26 #i mport <WebKit/WKUIDelegatePrivate.h>26 #if ENABLE(UI_PROCESS_PDF_HUD) 27 27 28 @interface TestUIDelegate : NSObject <WKUIDelegate> 28 #import "PDFPluginIdentifier.h" 29 29 30 @property (nonatomic, copy) void (^runJavaScriptAlertPanelWithMessage)(WKWebView *, NSString *, WKFrameInfo *, void (^)(void)); 31 #if PLATFORM(MAC) 32 @property (nonatomic, copy) void (^getContextMenuFromProposedMenu)(NSMenu *, _WKContextMenuElementInfo *, id <NSSecureCoding>, void (^)(NSMenu *)); 33 #endif 30 namespace WebKit { 31 class WebPageProxy; 32 } 34 33 35 - (NSString *)waitForAlert; 34 @interface WKPDFHUDView : NSView 35 36 - (instancetype)initWithFrame:(NSRect)frame pluginIdentifier:(WebKit::PDFPluginIdentifier)pluginIdentifier page:(WebKit::WebPageProxy&)page; 37 - (void)setFrame:(NSRect)frame; 38 - (void)mouseMoved:(NSEvent *)event; 39 - (void)mouseDown:(NSEvent *)event; 40 - (void)mouseUp:(NSEvent *)event; 41 - (void)setDeviceScaleFactor:(CGFloat)deviceScaleFactor; 36 42 37 43 @end 38 44 39 @interface WKWebView (TestUIDelegateExtras) 40 - (NSString *)_test_waitForAlert; 41 @end 45 #endif // ENABLE(UI_PROCESS_PDF_HUD) -
trunk/Source/WebKit/UIProcess/PageClient.h
r266342 r266654 27 27 28 28 #include "LayerTreeContext.h" 29 #include "PDFPluginIdentifier.h" 29 30 #include "SameDocumentNavigationType.h" 30 31 #include "ShareableBitmap.h" … … 242 243 virtual void didCommitLoadForMainFrame(const String& mimeType, bool useCustomContentProvider) = 0; 243 244 245 #if ENABLE(UI_PROCESS_PDF_HUD) 246 virtual void createPDFHUD(PDFPluginIdentifier, const WebCore::IntRect&) = 0; 247 virtual void updatePDFHUDLocation(PDFPluginIdentifier, const WebCore::IntRect&) = 0; 248 virtual void removePDFHUD(PDFPluginIdentifier) = 0; 249 virtual void removeAllPDFHUDs() = 0; 250 #endif 251 244 252 virtual void handleDownloadRequest(DownloadProxy&) = 0; 245 253 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r266634 r266654 4766 4766 m_mainFramePluginHandlesPageScaleGesture = false; 4767 4767 } 4768 }4769 4770 4768 #if ENABLE(POINTER_LOCK) 4771 if (frame->isMainFrame())4772 4769 requestPointerUnlock(); 4773 4770 #endif 4774 4775 if (frame->isMainFrame())4776 4771 pageClient().setMouseEventPolicy(mouseEventPolicy); 4772 #if ENABLE(UI_PROCESS_PDF_HUD) 4773 pageClient().removeAllPDFHUDs(); 4774 #endif 4775 } 4777 4776 4778 4777 m_pageLoadState.commitChanges(); … … 7447 7446 resetStateAfterProcessExited(reason); 7448 7447 stopAllURLSchemeTasks(m_process.ptr()); 7448 #if ENABLE(UI_PROCESS_PDF_HUD) 7449 pageClient().removeAllPDFHUDs(); 7450 #endif 7449 7451 7450 7452 // For bringup of process swapping, NavigationSwap termination will not go out to clients. -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r266634 r266654 41 41 #include "MessageSender.h" 42 42 #include "NotificationPermissionRequestManagerProxy.h" 43 #include "PDFPluginIdentifier.h" 43 44 #include "PageLoadState.h" 44 45 #include "PluginProcessAttributes.h" … … 1318 1319 void saveDataToFileInDownloadsFolder(String&& suggestedFilename, String&& mimeType, URL&& originatingURL, API::Data&); 1319 1320 void savePDFToFileInDownloadsFolder(String&& suggestedFilename, URL&& originatingURL, const IPC::DataReference&); 1320 #if PLATFORM(COCOA)1321 #if ENABLE(PDFKIT_PLUGIN) 1321 1322 void savePDFToTemporaryFolderAndOpenWithNativeApplication(const String& suggestedFilename, FrameInfoData&&, const IPC::DataReference&, const String& pdfUUID); 1323 #if !ENABLE(UI_PROCESS_PDF_HUD) 1322 1324 void openPDFFromTemporaryFolderWithNativeApplication(FrameInfoData&&, const String& pdfUUID); 1325 #endif 1323 1326 #endif 1324 1327 … … 1808 1811 bool canUseCredentialStorage() { return m_canUseCredentialStorage; } 1809 1812 void setCanUseCredentialStorage(bool); 1813 1814 #if ENABLE(UI_PROCESS_PDF_HUD) 1815 void createPDFHUD(PDFPluginIdentifier, const WebCore::IntRect&); 1816 void updatePDFHUDLocation(PDFPluginIdentifier, const WebCore::IntRect&); 1817 void removePDFHUD(PDFPluginIdentifier); 1818 void pdfZoomIn(PDFPluginIdentifier); 1819 void pdfZoomOut(PDFPluginIdentifier); 1820 void pdfSaveToPDF(PDFPluginIdentifier); 1821 void pdfOpenWithPreview(PDFPluginIdentifier); 1822 #endif 1810 1823 1811 1824 private: -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r266063 r266654 434 434 LoadRecentSearches(String name) -> (Vector<WebCore::RecentSearch> result) Synchronous 435 435 436 #if ENABLE(PDFKIT_PLUGIN) && !ENABLE(UI_PROCESS_PDF_HUD) 436 437 SavePDFToFileInDownloadsFolder(String suggestedFilename, URL originatingURL, IPC::DataReference data) 437 438 #if PLATFORM(COCOA)439 438 SavePDFToTemporaryFolderAndOpenWithNativeApplication(String suggestedFilename, struct WebKit::FrameInfoData sourceFrameInfo, IPC::DataReference data, String pdfUUID) 440 439 OpenPDFFromTemporaryFolderWithNativeApplication(struct WebKit::FrameInfoData sourceFrameInfo, String pdfUUID) … … 567 566 #endif 568 567 568 #if ENABLE(UI_PROCESS_PDF_HUD) 569 CreatePDFHUD(WebKit::PDFPluginIdentifier identifier, WebCore::IntRect boundingBox) 570 UpdatePDFHUDLocation(WebKit::PDFPluginIdentifier identifier, WebCore::IntRect boundingBox) 571 RemovePDFHUD(WebKit::PDFPluginIdentifier identifier) 572 #endif 573 569 574 ConfigureLoggingChannel(String channelName, enum:uint8_t WTFLogChannelState state, enum:uint8_t WTFLogLevel level) 570 575 -
trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
r266576 r266654 1089 1089 } 1090 1090 1091 void WebPageProxy::savePDFToTemporaryFolderAndOpenWithNativeApplication(const String&, FrameInfoData&&, const IPC::DataReference&, const String&)1092 {1093 notImplemented();1094 }1095 1096 void WebPageProxy::openPDFFromTemporaryFolderWithNativeApplication(FrameInfoData&&, const String&)1097 {1098 notImplemented();1099 }1100 1101 1091 void WebPageProxy::setRemoteLayerTreeRootNode(RemoteLayerTreeNode* rootNode) 1102 1092 { -
trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h
r266063 r266654 191 191 void registerInsertionUndoGrouping() override; 192 192 193 #if ENABLE(UI_PROCESS_PDF_HUD) 194 void createPDFHUD(PDFPluginIdentifier, const WebCore::IntRect&) override; 195 void updatePDFHUDLocation(PDFPluginIdentifier, const WebCore::IntRect&) override; 196 void removePDFHUD(PDFPluginIdentifier) override; 197 void removeAllPDFHUDs() override; 198 #endif 199 193 200 // Auxiliary Client Creation 194 201 #if ENABLE(FULLSCREEN_API) -
trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm
r266063 r266654 350 350 } 351 351 352 #if ENABLE(UI_PROCESS_PDF_HUD) 353 354 void PageClientImpl::createPDFHUD(PDFPluginIdentifier identifier, const WebCore::IntRect& rect) 355 { 356 m_impl->createPDFHUD(identifier, rect); 357 } 358 359 void PageClientImpl::updatePDFHUDLocation(PDFPluginIdentifier identifier, const WebCore::IntRect& rect) 360 { 361 m_impl->updatePDFHUDLocation(identifier, rect); 362 } 363 364 void PageClientImpl::removePDFHUD(PDFPluginIdentifier identifier) 365 { 366 m_impl->removePDFHUD(identifier); 367 } 368 369 void PageClientImpl::removeAllPDFHUDs() 370 { 371 m_impl->removeAllPDFHUDs(); 372 } 373 374 #endif // ENABLE(UI_PROCESS_PDF_HUD) 375 352 376 void PageClientImpl::clearAllEditCommands() 353 377 { -
trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm
r266576 r266654 481 481 void WebPageProxy::savePDFToTemporaryFolderAndOpenWithNativeApplication(const String& suggestedFilename, FrameInfoData&& frameInfo, const IPC::DataReference& data, const String& pdfUUID) 482 482 { 483 MESSAGE_CHECK(TemporaryPDFFileMap::isValidKey(pdfUUID));484 485 483 if (data.isEmpty()) { 486 484 WTFLogAlways("Cannot save empty PDF file to the temporary directory."); … … 510 508 FileSystem::setMetadataURL(nsPath.get(), originatingURLString); 511 509 512 m_temporaryPDFFiles.add(pdfUUID, nsPath.get()); 510 if (TemporaryPDFFileMap::isValidKey(pdfUUID)) 511 m_temporaryPDFFiles.add(pdfUUID, nsPath.get()); 513 512 514 513 auto pdfFileURL = URL::fileURLWithFileSystemPath(String(nsPath.get())); … … 520 519 } 521 520 521 #if ENABLE(PDFKIT_PLUGIN) && !ENABLE(UI_PROCESS_PDF_HUD) 522 522 void WebPageProxy::openPDFFromTemporaryFolderWithNativeApplication(FrameInfoData&& frameInfo, const String& pdfUUID) 523 523 { … … 536 536 }); 537 537 } 538 #endif 538 539 539 540 #if ENABLE(PDFKIT_PLUGIN) … … 679 680 } 680 681 682 #if ENABLE(UI_PROCESS_PDF_HUD) 683 684 void WebPageProxy::createPDFHUD(PDFPluginIdentifier identifier, const WebCore::IntRect& rect) 685 { 686 pageClient().createPDFHUD(identifier, rect); 687 } 688 689 void WebPageProxy::removePDFHUD(PDFPluginIdentifier identifier) 690 { 691 pageClient().removePDFHUD(identifier); 692 } 693 694 void WebPageProxy::updatePDFHUDLocation(PDFPluginIdentifier identifier, const WebCore::IntRect& rect) 695 { 696 pageClient().updatePDFHUDLocation(identifier, rect); 697 } 698 699 void WebPageProxy::pdfZoomIn(PDFPluginIdentifier identifier) 700 { 701 send(Messages::WebPage::ZoomPDFIn(identifier)); 702 } 703 704 void WebPageProxy::pdfZoomOut(PDFPluginIdentifier identifier) 705 { 706 send(Messages::WebPage::ZoomPDFOut(identifier)); 707 } 708 709 void WebPageProxy::pdfSaveToPDF(PDFPluginIdentifier identifier) 710 { 711 sendWithAsyncReply(Messages::WebPage::SavePDF(identifier), [this, protectedThis = makeRef(*this)] (String&& suggestedFilename, URL&& originatingURL, const IPC::DataReference& dataReference) { 712 savePDFToFileInDownloadsFolder(WTFMove(suggestedFilename), WTFMove(originatingURL), dataReference); 713 }); 714 } 715 716 void WebPageProxy::pdfOpenWithPreview(PDFPluginIdentifier identifier) 717 { 718 sendWithAsyncReply(Messages::WebPage::OpenPDFWithPreview(identifier), [this, protectedThis = makeRef(*this)] (String&& suggestedFilename, FrameInfoData&& frameInfo, const IPC::DataReference& data, const String& pdfUUID) { 719 savePDFToTemporaryFolderAndOpenWithNativeApplication(WTFMove(suggestedFilename), WTFMove(frameInfo), data, pdfUUID); 720 }); 721 } 722 723 #endif // ENABLE(UI_PROCESS_PDF_HUD) 724 681 725 } // namespace WebKit 682 726 -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r266467 r266654 1787 1787 DF462E0F23F22F5500EFF35F /* WKHTTPCookieStorePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = DF462E0E23F22F5300EFF35F /* WKHTTPCookieStorePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1788 1788 DF462E1223F338BE00EFF35F /* WKContentWorldPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = DF462E1123F338AD00EFF35F /* WKContentWorldPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1789 DF84CEE4249AA24D009096F6 /* WKPDFHUDView.mm in Sources */ = {isa = PBXBuildFile; fileRef = DF84CEE2249AA21F009096F6 /* WKPDFHUDView.mm */; }; 1789 1790 E105FE5418D7B9DE008F57A8 /* EditingRange.h in Headers */ = {isa = PBXBuildFile; fileRef = E105FE5318D7B9DE008F57A8 /* EditingRange.h */; }; 1790 1791 E11D35AE16B63D1B006D23D7 /* com.apple.WebProcess.sb in Resources */ = {isa = PBXBuildFile; fileRef = E1967E37150AB5E200C73169 /* com.apple.WebProcess.sb */; }; … … 5265 5266 DF58C6311371AC5800F9A37C /* NativeWebWheelEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeWebWheelEvent.h; sourceTree = "<group>"; }; 5266 5267 DF58C6351371ACA000F9A37C /* NativeWebWheelEventMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NativeWebWheelEventMac.mm; sourceTree = "<group>"; }; 5268 DF74275C24F4955000F8ABE9 /* PDFPluginIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PDFPluginIdentifier.h; sourceTree = "<group>"; }; 5269 DF84CEE2249AA21F009096F6 /* WKPDFHUDView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKPDFHUDView.mm; path = PDF/WKPDFHUDView.mm; sourceTree = "<group>"; }; 5270 DF84CEE3249AA21F009096F6 /* WKPDFHUDView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKPDFHUDView.h; path = PDF/WKPDFHUDView.h; sourceTree = "<group>"; }; 5267 5271 E105FE5318D7B9DE008F57A8 /* EditingRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditingRange.h; sourceTree = "<group>"; }; 5268 5272 E115C715190F8A2500ECC516 /* com.apple.WebKit.Storage.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = com.apple.WebKit.Storage.sb; path = DerivedSources/WebKit2/com.apple.WebKit.Storage.sb; sourceTree = BUILT_PRODUCTS_DIR; }; … … 5886 5890 1A6FB90811E66FB100DB1371 /* Netscape */, 5887 5891 E199875B142BF9CF00BB2DE7 /* PDF */, 5892 DF74275C24F4955000F8ABE9 /* PDFPluginIdentifier.h */, 5888 5893 1A6FB7D011E651E200DB1371 /* Plugin.cpp */, 5889 5894 1A6FB7D111E651E200DB1371 /* Plugin.h */, … … 8939 8944 510CC7E716138E7200D03ED3 /* Network */, 8940 8945 31A2EC401489973700810D71 /* Notifications */, 8946 DF84CEE1249AA200009096F6 /* PDF */, 8941 8947 1AEFCC0511D01F34008219D3 /* Plugins */, 8942 8948 2D1551A91F5A9B420006E3FE /* RemoteLayerTree */, … … 10424 10430 ); 10425 10431 path = ios; 10432 sourceTree = "<group>"; 10433 }; 10434 DF84CEE1249AA200009096F6 /* PDF */ = { 10435 isa = PBXGroup; 10436 children = ( 10437 DF84CEE3249AA21F009096F6 /* WKPDFHUDView.h */, 10438 DF84CEE2249AA21F009096F6 /* WKPDFHUDView.mm */, 10439 ); 10440 name = PDF; 10426 10441 sourceTree = "<group>"; 10427 10442 }; … … 13113 13128 5CE9120D2293C219005BEC78 /* WKMain.mm in Sources */, 13114 13129 4657D88A22664A2F005DE823 /* WKOrientationAccessAlert.mm in Sources */, 13130 DF84CEE4249AA24D009096F6 /* WKPDFHUDView.mm in Sources */, 13115 13131 5CA26D83217AD1B800F97A35 /* WKSafeBrowsingWarning.mm in Sources */, 13116 13132 1DB01944211CF005009FB3E8 /* WKShareSheet.mm in Sources */, -
trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h
r248697 r266654 87 87 88 88 - (void)snapshotInContext:(CGContextRef)context; 89 90 #if ENABLE(UI_PROCESS_PDF_HUD) 91 - (void)setDisplaysPDFHUDController:(BOOL)displaysController; 92 - (void)zoomIn:(id)atPoint; 93 - (void)zoomOut:(id)atPoint; 94 #endif 89 95 90 96 - (void)magnifyWithMagnification:(CGFloat)magnification atPoint:(CGPoint)point immediately:(BOOL)immediately; -
trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.h
r264945 r266654 29 29 30 30 #include "PDFKitImports.h" 31 #include "PDFPluginIdentifier.h" 31 32 #include "Plugin.h" 32 33 #include "WebEvent.h" … … 51 52 OBJC_CLASS NSAttributedString; 52 53 OBJC_CLASS NSData; 54 OBJC_CLASS NSEvent; 53 55 OBJC_CLASS NSString; 54 56 OBJC_CLASS PDFAnnotation; … … 78 80 class PluginView; 79 81 class WebFrame; 80 81 class PDFPlugin final : public Plugin, private WebCore::ScrollableArea 82 struct FrameInfoData; 83 84 class PDFPlugin final : public Plugin, public WebCore::ScrollableArea 82 85 #if HAVE(INCREMENTAL_PDF_APIS) 83 86 , private WebCore::NetscapePlugInStreamLoaderClient … … 104 107 void notifyCursorChanged(uint64_t /* PDFLayerControllerCursorType */); 105 108 109 #if ENABLE(UI_PROCESS_PDF_HUD) 110 void zoomIn(); 111 void zoomOut(); 112 void save(CompletionHandler<void(const String&, const URL&, const IPC::DataReference&)>&&); 113 void openWithPreview(CompletionHandler<void(const String&, FrameInfoData&&, const IPC::DataReference&, const String&)>&&); 114 PDFPluginIdentifier identifier() const { return m_identifier; } 115 #endif 116 106 117 void clickedLink(NSURL *); 118 #if !ENABLE(UI_PROCESS_PDF_HUD) 107 119 void saveToPDF(); 108 120 void openWithNativeApplication(); 121 #endif 109 122 void writeItemsToPasteboard(NSString *pasteboardName, NSArray *items, NSArray *types); 110 123 void showDefinitionForAttributedString(NSAttributedString *, CGPoint); … … 119 132 WebCore::FloatRect convertFromPDFViewToScreen(const WebCore::FloatRect&) const; 120 133 WebCore::IntPoint convertFromRootViewToPDFView(const WebCore::IntPoint&) const; 134 WebCore::IntPoint convertFromPDFViewToRootView(const WebCore::IntPoint&) const; 135 WebCore::IntRect convertFromPDFViewToRootView(const WebCore::IntRect&) const; 121 136 WebCore::IntRect boundsOnScreen() const; 137 WebCore::IntRect frameForHUD() const; 122 138 123 139 bool showContextMenuAtPoint(const WebCore::IntPoint&); … … 160 176 void geometryDidChange(const WebCore::IntSize& pluginSize, const WebCore::IntRect& clipRect, const WebCore::AffineTransform& pluginToRootViewTransform) final; 161 177 void contentsScaleFactorChanged(float) final; 162 void visibilityDidChange(bool) final { }178 void visibilityDidChange(bool) final; 163 179 void frameDidFinishLoading(uint64_t requestID) final; 164 180 void frameDidFail(uint64_t requestID, bool wasCancelled) final; … … 264 280 WebCore::IntPoint convertFromPluginToPDFView(const WebCore::IntPoint&) const; 265 281 WebCore::IntPoint convertFromRootViewToPlugin(const WebCore::IntPoint&) const; 266 WebCore::IntPoint convertFromPDFViewToRootView(const WebCore::IntPoint&) const;267 282 268 283 bool supportsForms(); … … 404 419 405 420 #endif // HAVE(INCREMENTAL_PDF_APIS) 421 #if ENABLE(UI_PROCESS_PDF_HUD) 422 PDFPluginIdentifier m_identifier; 423 #endif 406 424 }; 407 425 -
trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
r266099 r266654 434 434 - (void)openWithNativeApplication 435 435 { 436 #if !ENABLE(UI_PROCESS_PDF_HUD) 436 437 _pdfPlugin->openWithNativeApplication(); 438 #endif 437 439 } 438 440 439 441 - (void)saveToPDF 440 442 { 443 #if !ENABLE(UI_PROCESS_PDF_HUD) 441 444 _pdfPlugin->saveToPDF(); 445 #endif 442 446 } 443 447 … … 601 605 , m_incrementalPDFLoadingEnabled(WebCore::RuntimeEnabledFeatures::sharedFeatures().incrementalPDFLoadingEnabled()) 602 606 #endif 603 { 607 #if ENABLE(UI_PROCESS_PDF_HUD) 608 , m_identifier(PDFPluginIdentifier::generate()) 609 #endif 610 { 611 #if ENABLE(UI_PROCESS_PDF_HUD) 612 [m_pdfLayerController setDisplaysPDFHUDController:NO]; 613 #endif 604 614 m_pdfLayerController.get().delegate = m_pdfLayerControllerDelegate.get(); 605 615 m_pdfLayerController.get().parentLayer = m_contentLayer.get(); … … 641 651 PDFPlugin::~PDFPlugin() 642 652 { 653 #if ENABLE(UI_PROCESS_PDF_HUD) 654 if (auto* page = m_frame.page()) 655 page->removePDFHUD(*this); 656 #endif 643 657 } 644 658 … … 1781 1795 } 1782 1796 1797 IntRect PDFPlugin::frameForHUD() const 1798 { 1799 return convertFromPDFViewToRootView(IntRect(IntPoint(), size())); 1800 } 1801 1783 1802 void PDFPlugin::calculateSizes() 1784 1803 { … … 1791 1810 m_firstPageHeight = [m_pdfDocument pageCount] ? static_cast<unsigned>(CGCeiling([[m_pdfDocument pageAtIndex:0] boundsForBox:kPDFDisplayBoxCropBox].size.height)) : 0; 1792 1811 setPDFDocumentSize(IntSize([m_pdfLayerController contentSizeRespectingZoom])); 1812 1813 #if ENABLE(UI_PROCESS_PDF_HUD) 1814 m_frame.page()->updatePDFHUDLocation(*this, frameForHUD()); 1815 #endif 1793 1816 } 1794 1817 … … 1925 1948 return m_rootViewToPluginTransform.inverse().valueOr(AffineTransform()).mapPoint(pointInPluginCoordinates); 1926 1949 } 1927 1950 1951 IntRect PDFPlugin::convertFromPDFViewToRootView(const IntRect& rect) const 1952 { 1953 IntRect rectInPluginCoordinates(rect.x(), rect.y(), rect.width(), rect.height()); 1954 return m_rootViewToPluginTransform.inverse().valueOr(AffineTransform()).mapRect(rectInPluginCoordinates); 1955 } 1956 1928 1957 IntPoint PDFPlugin::convertFromRootViewToPDFView(const IntPoint& point) const 1929 1958 { … … 1954 1983 FloatRect rectInRootViewCoordinates = m_rootViewToPluginTransform.inverse().valueOr(AffineTransform()).mapRect(bounds); 1955 1984 return frameView->contentsToScreen(enclosingIntRect(rectInRootViewCoordinates)); 1985 } 1986 1987 void PDFPlugin::visibilityDidChange(bool visible) 1988 { 1989 #if ENABLE(UI_PROCESS_PDF_HUD) 1990 if (visible) 1991 m_frame.page()->createPDFHUD(*this, frameForHUD()); 1992 else 1993 m_frame.page()->removePDFHUD(*this); 1994 #else 1995 UNUSED_PARAM(visible); 1996 #endif 1956 1997 } 1957 1998 … … 2401 2442 } 2402 2443 2444 #if ENABLE(UI_PROCESS_PDF_HUD) 2445 2446 void PDFPlugin::zoomIn() 2447 { 2448 [m_pdfLayerController zoomIn:nil]; 2449 } 2450 2451 void PDFPlugin::zoomOut() 2452 { 2453 [m_pdfLayerController zoomOut:nil]; 2454 } 2455 2456 void PDFPlugin::save(CompletionHandler<void(const String&, const URL&, const IPC::DataReference&)>&& completionHandler) 2457 { 2458 NSData *data = liveData(); 2459 completionHandler(m_suggestedFilename, m_frame.url(), IPC:: DataReference(static_cast<const uint8_t*>(data.bytes), data.length)); 2460 } 2461 2462 void PDFPlugin::openWithPreview(CompletionHandler<void(const String&, FrameInfoData&&, const IPC::DataReference&, const String&)>&& completionHandler) 2463 { 2464 NSData *data = liveData(); 2465 completionHandler(m_suggestedFilename, m_frame.info(), IPC:: DataReference { static_cast<const uint8_t*>(data.bytes), data.length }, createCanonicalUUIDString()); 2466 } 2467 2468 #else // ENABLE(UI_PROCESS_PDF_HUD) 2403 2469 2404 2470 void PDFPlugin::saveToPDF() … … 2432 2498 m_frame.page()->send(Messages::WebPageProxy::OpenPDFFromTemporaryFolderWithNativeApplication(m_frame.info(), m_temporaryPDFUUID)); 2433 2499 } 2500 2501 #endif // ENABLE(UI_PROCESS_PDF_HUD) 2434 2502 2435 2503 void PDFPlugin::writeItemsToPasteboard(NSString *pasteboardName, NSArray *items, NSArray *types) -
trunk/Source/WebKit/WebProcess/Plugins/PDFPluginIdentifier.h
r266653 r266654 24 24 */ 25 25 26 # import <WebKit/WKUIDelegatePrivate.h>26 #pragma once 27 27 28 @interface TestUIDelegate : NSObject <WKUIDelegate>28 #include <wtf/ObjectIdentifier.h> 29 29 30 @property (nonatomic, copy) void (^runJavaScriptAlertPanelWithMessage)(WKWebView *, NSString *, WKFrameInfo *, void (^)(void)); 31 #if PLATFORM(MAC) 32 @property (nonatomic, copy) void (^getContextMenuFromProposedMenu)(NSMenu *, _WKContextMenuElementInfo *, id <NSSecureCoding>, void (^)(NSMenu *)); 30 namespace WebKit { 31 32 #if ENABLE(UI_PROCESS_PDF_HUD) 33 enum PDFPluginIdentifierType { }; 34 using PDFPluginIdentifier = ObjectIdentifier<PDFPluginIdentifierType>; 33 35 #endif 34 36 35 - (NSString *)waitForAlert; 36 37 @end 38 39 @interface WKWebView (TestUIDelegateExtras) 40 - (NSString *)_test_waitForAlert; 41 @end 37 } -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r266557 r266654 5121 5121 #endif 5122 5122 5123 #if ENABLE(PDFKIT_PLUGIN) && !ENABLE(UI_PROCESS_PDF_HUD) 5123 5124 void WebPage::savePDFToFileInDownloadsFolder(const String& suggestedFilename, const URL& originatingURL, const uint8_t* data, unsigned long size) 5124 5125 { … … 5126 5127 } 5127 5128 5128 #if PLATFORM(COCOA)5129 5129 void WebPage::savePDFToTemporaryFolderAndOpenWithNativeApplication(const String& suggestedFilename, FrameInfoData&& frameInfo, const uint8_t* data, unsigned long size, const String& pdfUUID) 5130 5130 { -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r266342 r266654 46 46 #include "MessageSender.h" 47 47 #include "OptionalCallbackID.h" 48 #include "PDFPluginIdentifier.h" 48 49 #include "Plugin.h" 49 50 #include "PolicyDecision.h" … … 346 347 void centerSelectionInVisibleArea(); 347 348 349 #if ENABLE(UI_PROCESS_PDF_HUD) 350 void createPDFHUD(PDFPlugin&, const WebCore::IntRect&); 351 void updatePDFHUDLocation(PDFPlugin&, const WebCore::IntRect&); 352 void removePDFHUD(PDFPlugin&); 353 void zoomPDFIn(PDFPluginIdentifier); 354 void zoomPDFOut(PDFPluginIdentifier); 355 void savePDF(PDFPluginIdentifier, CompletionHandler<void(const String&, const URL&, const IPC::DataReference&)>&&); 356 void openPDFWithPreview(PDFPluginIdentifier, CompletionHandler<void(const String&, FrameInfoData&&, const IPC::DataReference&, const String&)>&&); 357 #endif 358 348 359 #if PLATFORM(COCOA) 349 360 void willCommitLayerTree(RemoteLayerTreeTransaction&); … … 1074 1085 #endif 1075 1086 1087 #if ENABLE(PDFKIT_PLUGIN) && !ENABLE(UI_PROCESS_PDF_HUD) 1076 1088 void savePDFToFileInDownloadsFolder(const String& suggestedFilename, const URL& originatingURL, const uint8_t* data, unsigned long size); 1077 1078 #if PLATFORM(COCOA)1079 1089 void savePDFToTemporaryFolderAndOpenWithNativeApplication(const String& suggestedFilename, FrameInfoData&&, const uint8_t* data, unsigned long size, const String& pdfUUID); 1080 1090 #endif … … 1791 1801 WebCore::Color m_underlayColor; 1792 1802 1803 #if ENABLE(UI_PROCESS_PDF_HUD) 1804 HashMap<PDFPluginIdentifier, WeakPtr<PDFPlugin>> m_pdfPlugInsWithHUD; 1805 #endif 1806 1793 1807 bool m_isInRedo { false }; 1794 1808 bool m_isClosed { false }; -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r266342 r266654 576 576 SetDefersLoading(bool defersLoading) 577 577 578 #if ENABLE(UI_PROCESS_PDF_HUD) 579 ZoomPDFIn(WebKit::PDFPluginIdentifier identifier) 580 ZoomPDFOut(WebKit::PDFPluginIdentifier identifier) 581 SavePDF(WebKit::PDFPluginIdentifier identifier) -> (String filename, URL url, IPC::DataReference data) Async 582 OpenPDFWithPreview(WebKit::PDFPluginIdentifier identifier) -> (String filename, struct WebKit::FrameInfoData frameInfo, IPC::DataReference data, String uuid) Async 583 #endif 584 578 585 UpdateCurrentModifierState(OptionSet<WebCore::PlatformEvent::Modifier> modifiers) 579 586 SimulateDeviceOrientationChange(double alpha, double beta, double gamma) -
trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm
r266295 r266654 34 34 #import "EditorState.h" 35 35 #import "FontInfo.h" 36 #import "FrameInfoData.h" 36 37 #import "InjectedBundleHitTestResult.h" 37 38 #import "PDFKitImports.h" … … 1052 1053 } 1053 1054 1054 #endif 1055 #endif // HAVE(APP_ACCENT_COLORS) 1056 1057 #if ENABLE(UI_PROCESS_PDF_HUD) 1058 1059 void WebPage::zoomPDFIn(PDFPluginIdentifier identifier) 1060 { 1061 auto pdfPlugin = m_pdfPlugInsWithHUD.get(identifier); 1062 if (!pdfPlugin) 1063 return; 1064 pdfPlugin->zoomIn(); 1065 } 1066 1067 void WebPage::zoomPDFOut(PDFPluginIdentifier identifier) 1068 { 1069 auto pdfPlugin = m_pdfPlugInsWithHUD.get(identifier); 1070 if (!pdfPlugin) 1071 return; 1072 pdfPlugin->zoomOut(); 1073 } 1074 1075 void WebPage::savePDF(PDFPluginIdentifier identifier, CompletionHandler<void(const String&, const URL&, const IPC::DataReference&)>&& completionHandler) 1076 { 1077 auto pdfPlugin = m_pdfPlugInsWithHUD.get(identifier); 1078 if (!pdfPlugin) 1079 return completionHandler({ }, { }, { }); 1080 pdfPlugin->save(WTFMove(completionHandler)); 1081 } 1082 1083 void WebPage::openPDFWithPreview(PDFPluginIdentifier identifier, CompletionHandler<void(const String&, FrameInfoData&&, const IPC::DataReference&, const String&)>&& completionHandler) 1084 { 1085 auto pdfPlugin = m_pdfPlugInsWithHUD.get(identifier); 1086 if (!pdfPlugin) 1087 return completionHandler({ }, { }, { }, { }); 1088 pdfPlugin->openWithPreview(WTFMove(completionHandler)); 1089 } 1090 1091 void WebPage::createPDFHUD(PDFPlugin& plugin, const IntRect& boundingBox) 1092 { 1093 auto addResult = m_pdfPlugInsWithHUD.add(plugin.identifier(), makeWeakPtr(plugin)); 1094 if (addResult.isNewEntry) 1095 send(Messages::WebPageProxy::CreatePDFHUD(plugin.identifier(), boundingBox)); 1096 } 1097 1098 void WebPage::updatePDFHUDLocation(PDFPlugin& plugin, const IntRect& boundingBox) 1099 { 1100 if (m_pdfPlugInsWithHUD.contains(plugin.identifier())) 1101 send(Messages::WebPageProxy::UpdatePDFHUDLocation(plugin.identifier(), boundingBox)); 1102 } 1103 1104 void WebPage::removePDFHUD(PDFPlugin& plugin) 1105 { 1106 if (m_pdfPlugInsWithHUD.remove(plugin.identifier())) 1107 send(Messages::WebPageProxy::RemovePDFHUD(plugin.identifier())); 1108 } 1109 1110 #endif // ENABLE(UI_PROCESS_PDF_HUD) 1055 1111 1056 1112 } // namespace WebKit -
trunk/Tools/ChangeLog
r266640 r266654 1 2020-09-04 Alex Christensen <achristensen@webkit.org> 2 3 Move PDF heads-up display to UI process on macOS 4 https://bugs.webkit.org/show_bug.cgi?id=215780 5 <rdar://problem/58715847> 6 7 Reviewed by Tim Horton. 8 9 * TestWebKitAPI/Tests/WebKitCocoa/WKPDFView.mm: 10 (pdfData): 11 (TEST): 12 (checkFrame): 13 * TestWebKitAPI/cocoa/TestUIDelegate.h: 14 * TestWebKitAPI/cocoa/TestUIDelegate.mm: 15 (-[TestUIDelegate _webView:saveDataToFile:suggestedFilename:mimeType:originatingURL:]): 16 1 17 2020-09-04 Jonathan Bedard <jbedard@apple.com> 2 18 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKPDFView.mm
r261407 r266654 31 31 #import "Test.h" 32 32 #import "TestNavigationDelegate.h" 33 #import "TestUIDelegate.h" 34 #import "TestURLSchemeHandler.h" 35 #import "TestWKWebView.h" 33 36 #import <WebKit/WKWebView.h> 34 37 #import <WebKit/WKWebViewConfigurationPrivate.h> 38 #import <WebKit/WKWebViewPrivateForTesting.h> 35 39 #import <wtf/RetainPtr.h> 36 40 37 #if HAVE(PDFKIT) && PLATFORM(IOS) 41 #if PLATFORM(MAC) 42 #import <Carbon/Carbon.h> 43 #endif 44 45 #if PLATFORM(IOS) || ENABLE(UI_PROCESS_PDF_HUD) 46 static NSData *pdfData() 47 { 48 return [NSData dataWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"test" withExtension:@"pdf" subdirectory:@"TestWebKitAPI.resources"]]; 49 } 50 #endif 51 52 #if PLATFORM(IOS) 38 53 39 54 @interface PDFHostViewController : UIViewController … … 102 117 103 118 // Load a PDF, so we install a WKPDFView. 104 [webView loadData: [NSData dataWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"test" withExtension:@"pdf" subdirectory:@"TestWebKitAPI.resources"]]MIMEType:@"application/pdf" characterEncodingName:@"" baseURL:[NSURL URLWithString:@"https://www.apple.com/0"]];119 [webView loadData:pdfData() MIMEType:@"application/pdf" characterEncodingName:@"" baseURL:[NSURL URLWithString:@"https://www.apple.com/0"]]; 105 120 [webView _test_waitForDidFinishNavigation]; 106 121 … … 133 148 134 149 #endif 150 151 #if ENABLE(UI_PROCESS_PDF_HUD) 152 153 static void checkFrame(NSRect frame, CGFloat x, CGFloat y, CGFloat width, CGFloat height) 154 { 155 EXPECT_EQ(frame.origin.x, x); 156 EXPECT_EQ(frame.origin.y, y); 157 EXPECT_EQ(frame.size.width, width); 158 EXPECT_EQ(frame.size.height, height); 159 } 160 161 TEST(PDFHUD, MainResourcePDF) 162 { 163 TestWKWebView *webView = [[[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:[[WKWebViewConfiguration new] autorelease]] autorelease]; 164 [webView loadData:pdfData() MIMEType:@"application/pdf" characterEncodingName:@"" baseURL:[NSURL URLWithString:@"https://www.apple.com/testPath"]]; 165 EXPECT_EQ(webView._pdfHUDs.count, 0u); 166 [webView _test_waitForDidFinishNavigation]; 167 EXPECT_EQ(webView._pdfHUDs.count, 1u); 168 checkFrame(webView._pdfHUDs.anyObject.frame, 0, 0, 800, 600); 169 170 TestUIDelegate *delegate = [[TestUIDelegate new] autorelease]; 171 webView.UIDelegate = delegate; 172 __block bool saveRequestReceived = false; 173 delegate.saveDataToFile = ^(WKWebView *webViewFromDelegate, NSData *data, NSString *suggestedFilename, NSString *mimeType, NSURL *originatingURL) { 174 EXPECT_EQ(webView, webViewFromDelegate); 175 EXPECT_TRUE([data isEqualToData:pdfData()]); 176 EXPECT_WK_STREQ(suggestedFilename, "testPath.pdf"); 177 EXPECT_WK_STREQ(mimeType, "application/pdf"); 178 saveRequestReceived = true; 179 }; 180 [[webView _pdfHUDs].anyObject performSelector:NSSelectorFromString(@"_performActionForControl:") withObject:@"arrow.down.circle"]; 181 TestWebKitAPI::Util::run(&saveRequestReceived); 182 183 EXPECT_EQ(webView._pdfHUDs.count, 1u); 184 [webView _killWebContentProcess]; 185 while (webView._pdfHUDs.count) 186 TestWebKitAPI::Util::spinRunLoop(); 187 } 188 189 TEST(PDFHUD, MoveIFrame) 190 { 191 TestURLSchemeHandler *handler = [[TestURLSchemeHandler new] autorelease]; 192 handler.startURLSchemeTaskHandler = ^(WKWebView *, id<WKURLSchemeTask> task) { 193 if ([task.request.URL.path isEqualToString:@"/main.html"]) { 194 NSURLResponse *response = [[[NSURLResponse alloc] initWithURL:task.request.URL MIMEType:@"text/html" expectedContentLength:0 textEncodingName:nil] autorelease]; 195 const char* html = "<br/><iframe src='test.pdf' id='pdfframe'></iframe>"; 196 [task didReceiveResponse:response]; 197 [task didReceiveData:[NSData dataWithBytes:html length:strlen(html)]]; 198 [task didFinish]; 199 } else { 200 EXPECT_WK_STREQ(task.request.URL.path, "/test.pdf"); 201 NSData *data = pdfData(); 202 NSURLResponse *response = [[[NSURLResponse alloc] initWithURL:task.request.URL MIMEType:@"application/pdf" expectedContentLength:data.length textEncodingName:nil] autorelease]; 203 [task didReceiveResponse:response]; 204 [task didReceiveData:data]; 205 [task didFinish]; 206 } 207 }; 208 209 WKWebViewConfiguration *configuration = [[WKWebViewConfiguration new] autorelease]; 210 [configuration setURLSchemeHandler:handler forURLScheme:@"test"]; 211 TestWKWebView *webView = [[[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration] autorelease]; 212 [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"test:///main.html"]]]; 213 EXPECT_EQ(webView._pdfHUDs.count, 0u); 214 [webView _test_waitForDidFinishNavigation]; 215 EXPECT_EQ(webView._pdfHUDs.count, 1u); 216 checkFrame(webView._pdfHUDs.anyObject.frame, 10, 28, 300, 150); 217 218 [webView evaluateJavaScript:@"pdfframe.width=400" completionHandler:nil]; 219 while (webView._pdfHUDs.anyObject.frame.size.width != 400) 220 TestWebKitAPI::Util::spinRunLoop(); 221 checkFrame(webView._pdfHUDs.anyObject.frame, 10, 28, 400, 150); 222 223 [webView evaluateJavaScript:@"var frameReference = pdfframe; document.body.removeChild(pdfframe)" completionHandler:nil]; 224 while (webView._pdfHUDs.count) 225 TestWebKitAPI::Util::spinRunLoop(); 226 [webView evaluateJavaScript:@"document.body.appendChild(frameReference)" completionHandler:nil]; 227 while (!webView._pdfHUDs.count) 228 TestWebKitAPI::Util::spinRunLoop(); 229 EXPECT_EQ(webView._pdfHUDs.count, 1u); 230 checkFrame(webView._pdfHUDs.anyObject.frame, 0, 0, 0, 0); 231 while (webView._pdfHUDs.anyObject.frame.size.width != 400) 232 TestWebKitAPI::Util::spinRunLoop(); 233 EXPECT_EQ(webView._pdfHUDs.count, 1u); 234 checkFrame(webView._pdfHUDs.anyObject.frame, 10, 28, 400, 150); 235 236 webView.pageZoom = 1.4; 237 while (webView._pdfHUDs.anyObject.frame.size.width != 560) 238 TestWebKitAPI::Util::spinRunLoop(); 239 EXPECT_EQ(webView._pdfHUDs.count, 1u); 240 checkFrame(webView._pdfHUDs.anyObject.frame, 14, 40, 560, 210); 241 } 242 243 TEST(PDFHUD, NestedIFrames) 244 { 245 TestURLSchemeHandler *handler = [[TestURLSchemeHandler new] autorelease]; 246 handler.startURLSchemeTaskHandler = ^(WKWebView *, id<WKURLSchemeTask> task) { 247 NSURLResponse *htmlResponse = [[[NSURLResponse alloc] initWithURL:task.request.URL MIMEType:@"text/html" expectedContentLength:0 textEncodingName:nil] autorelease]; 248 if ([task.request.URL.path isEqualToString:@"/main.html"]) { 249 const char* html = "<iframe src='frame.html' id='parentframe'></iframe>"; 250 [task didReceiveResponse:htmlResponse]; 251 [task didReceiveData:[NSData dataWithBytes:html length:strlen(html)]]; 252 [task didFinish]; 253 } else if ([task.request.URL.path isEqualToString:@"/frame.html"]) { 254 const char* html = "<iframe src='test.pdf'></iframe>"; 255 [task didReceiveResponse:htmlResponse]; 256 [task didReceiveData:[NSData dataWithBytes:html length:strlen(html)]]; 257 [task didFinish]; 258 } else { 259 EXPECT_WK_STREQ(task.request.URL.path, "/test.pdf"); 260 NSData *data = pdfData(); 261 NSURLResponse *response = [[[NSURLResponse alloc] initWithURL:task.request.URL MIMEType:@"application/pdf" expectedContentLength:data.length textEncodingName:nil] autorelease]; 262 [task didReceiveResponse:response]; 263 [task didReceiveData:data]; 264 [task didFinish]; 265 } 266 }; 267 268 WKWebViewConfiguration *configuration = [[WKWebViewConfiguration new] autorelease]; 269 [configuration setURLSchemeHandler:handler forURLScheme:@"test"]; 270 TestWKWebView *webView = [[[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration] autorelease]; 271 [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"test:///main.html"]]]; 272 EXPECT_EQ(webView._pdfHUDs.count, 0u); 273 [webView _test_waitForDidFinishNavigation]; 274 EXPECT_EQ(webView._pdfHUDs.count, 1u); 275 checkFrame(webView._pdfHUDs.anyObject.frame, 20, 20, 300, 150); 276 277 [webView evaluateJavaScript:@"document.body.removeChild(parentframe)" completionHandler:nil]; 278 while (webView._pdfHUDs.count) 279 TestWebKitAPI::Util::spinRunLoop(); 280 } 281 282 TEST(PDFHUD, IFrame3DTransform) 283 { 284 TestURLSchemeHandler *handler = [[TestURLSchemeHandler new] autorelease]; 285 handler.startURLSchemeTaskHandler = ^(WKWebView *, id<WKURLSchemeTask> task) { 286 NSURLResponse *htmlResponse = [[[NSURLResponse alloc] initWithURL:task.request.URL MIMEType:@"text/html" expectedContentLength:0 textEncodingName:nil] autorelease]; 287 if ([task.request.URL.path isEqualToString:@"/main.html"]) { 288 const char* html = "<iframe src='test.pdf' height=500 width=500 style='transform:rotateY(235deg);'></iframe>"; 289 [task didReceiveResponse:htmlResponse]; 290 [task didReceiveData:[NSData dataWithBytes:html length:strlen(html)]]; 291 [task didFinish]; 292 } else { 293 EXPECT_WK_STREQ(task.request.URL.path, "/test.pdf"); 294 NSData *data = pdfData(); 295 NSURLResponse *response = [[[NSURLResponse alloc] initWithURL:task.request.URL MIMEType:@"application/pdf" expectedContentLength:data.length textEncodingName:nil] autorelease]; 296 [task didReceiveResponse:response]; 297 [task didReceiveData:data]; 298 [task didFinish]; 299 } 300 }; 301 302 WKWebViewConfiguration *configuration = [[WKWebViewConfiguration new] autorelease]; 303 [configuration setURLSchemeHandler:handler forURLScheme:@"test"]; 304 TestWKWebView *webView = [[[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration] autorelease]; 305 [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"test:///main.html"]]]; 306 EXPECT_EQ(webView._pdfHUDs.count, 0u); 307 [webView _test_waitForDidFinishNavigation]; 308 EXPECT_EQ(webView._pdfHUDs.count, 1u); 309 checkFrame(webView._pdfHUDs.anyObject.frame, 403, 10, 500, 500); 310 } 311 312 TEST(PDFHUD, MultipleIFrames) 313 { 314 TestURLSchemeHandler *handler = [[TestURLSchemeHandler new] autorelease]; 315 handler.startURLSchemeTaskHandler = ^(WKWebView *, id<WKURLSchemeTask> task) { 316 NSURLResponse *htmlResponse = [[[NSURLResponse alloc] initWithURL:task.request.URL MIMEType:@"text/html" expectedContentLength:0 textEncodingName:nil] autorelease]; 317 if ([task.request.URL.path isEqualToString:@"/main.html"]) { 318 const char* html = "<iframe src='test.pdf' height=100 width=150></iframe><iframe src='test.pdf' height=123 width=134></iframe>"; 319 [task didReceiveResponse:htmlResponse]; 320 [task didReceiveData:[NSData dataWithBytes:html length:strlen(html)]]; 321 [task didFinish]; 322 } else { 323 EXPECT_WK_STREQ(task.request.URL.path, "/test.pdf"); 324 NSData *data = pdfData(); 325 NSURLResponse *response = [[[NSURLResponse alloc] initWithURL:task.request.URL MIMEType:@"application/pdf" expectedContentLength:data.length textEncodingName:nil] autorelease]; 326 [task didReceiveResponse:response]; 327 [task didReceiveData:data]; 328 [task didFinish]; 329 } 330 }; 331 332 WKWebViewConfiguration *configuration = [[WKWebViewConfiguration new] autorelease]; 333 [configuration setURLSchemeHandler:handler forURLScheme:@"test"]; 334 TestWKWebView *webView = [[[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration] autorelease]; 335 [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"test:///main.html"]]]; 336 EXPECT_EQ(webView._pdfHUDs.count, 0u); 337 [webView _test_waitForDidFinishNavigation]; 338 EXPECT_EQ(webView._pdfHUDs.count, 2u); 339 bool hadLeftFrame = false; 340 bool hadRightFrame = false; 341 for (NSView *hud in webView._pdfHUDs) { 342 if (hud.frame.origin.x == 10) { 343 checkFrame(hud.frame, 10, 33, 150, 100); 344 hadLeftFrame = true; 345 } else { 346 checkFrame(hud.frame, 164, 10, 134, 123); 347 hadRightFrame = true; 348 } 349 } 350 EXPECT_TRUE(hadLeftFrame); 351 EXPECT_TRUE(hadRightFrame); 352 } 353 354 #endif -
trunk/Tools/TestWebKitAPI/cocoa/TestUIDelegate.h
r264113 r266654 32 32 @property (nonatomic, copy) void (^getContextMenuFromProposedMenu)(NSMenu *, _WKContextMenuElementInfo *, id <NSSecureCoding>, void (^)(NSMenu *)); 33 33 #endif 34 @property (nonatomic, copy) void (^saveDataToFile)(WKWebView *, NSData *, NSString *, NSString *, NSURL *); 34 35 35 36 - (NSString *)waitForAlert; -
trunk/Tools/TestWebKitAPI/cocoa/TestUIDelegate.mm
r264113 r266654 51 51 #endif // PLATFORM(MAC) 52 52 53 - (void)_webView:(WKWebView *)webView saveDataToFile:(NSData *)data suggestedFilename:(NSString *)suggestedFilename mimeType:(NSString *)mimeType originatingURL:(NSURL *)url 54 { 55 if (_saveDataToFile) 56 _saveDataToFile(webView, data, suggestedFilename, mimeType, url); 57 } 58 53 59 - (NSString *)waitForAlert 54 60 {
Note:
See TracChangeset
for help on using the changeset viewer.