⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 266654 in webkit


Ignore:
Timestamp:
Sep 4, 2020, 9:07:47 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Move PDF heads-up display to UI process on macOS
https://bugs.webkit.org/show_bug.cgi?id=215780
<rdar://problem/58715847>

Patch by Alex Christensen <achristensen@webkit.org> on 2020-09-04
Reviewed by Tim Horton.

Source/WebKit:

This has many benefits including the one in the radar, testability, and moving WebKit-specific code from PDFKit to WebKit.

Now that the HUD is displayed in the UI process instead of in the web content, zooming in keeps the HUD the same size.
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.
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.
The rest of the behavior I think should be the same. Most users should not notice any difference.

Functionality covered by API tests, the first tests for PDF content interaction!

  • Scripts/webkit/messages.py:
  • UIProcess/API/Cocoa/WKWebViewInternal.h:
  • UIProcess/API/mac/WKView.mm:

(-[WKView _createPDFHUD:rect:]):
(-[WKView _pdfHUD:changedLocation:]):
(-[WKView _removePDFHUD:]):
(-[WKView _removeAllPDFHUDs]):

  • UIProcess/API/mac/WKWebViewMac.mm:

(-[WKWebView mouseMoved:]):
(-[WKWebView mouseDown:]):
(-[WKWebView mouseUp:]):
(-[WKWebView _createPDFHUD:rect:]):
(-[WKWebView _pdfHUD:changedLocation:]):
(-[WKWebView _removePDFHUD:]):
(-[WKWebView _removeAllPDFHUDs]):

  • UIProcess/API/mac/WKWebViewPrivateForTestingMac.h:
  • UIProcess/API/mac/WKWebViewTestingMac.mm:

(-[WKWebView pdfHUDs]):

  • UIProcess/Cocoa/WebViewImpl.h:
  • UIProcess/Cocoa/WebViewImpl.mm:

(WebKit::WebViewImpl::createPDFHUD):
(WebKit::WebViewImpl::updatePDFHUDLocation):
(WebKit::WebViewImpl::removePDFHUD):
(WebKit::WebViewImpl::removeAllPDFHUDs):

  • UIProcess/PageClient.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::didCommitLoadForFrame):
(WebKit::WebPageProxy::processDidTerminate):

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::WebPageProxy::savePDFToTemporaryFolderAndOpenWithNativeApplication): Deleted.
(WebKit::WebPageProxy::openPDFFromTemporaryFolderWithNativeApplication): Deleted.

  • UIProcess/mac/PageClientImplMac.h:
  • UIProcess/mac/PageClientImplMac.mm:

(WebKit::PageClientImpl::createPDFHUD):
(WebKit::PageClientImpl::updatePDFHUDLocation):
(WebKit::PageClientImpl::removePDFHUD):
(WebKit::PageClientImpl::removeAllPDFHUDs):

  • UIProcess/mac/WebPageProxyMac.mm:

(WebKit::WebPageProxy::savePDFToTemporaryFolderAndOpenWithNativeApplication):
(WebKit::WebPageProxy::createPDFHUD):
(WebKit::WebPageProxy::removePDFHUD):
(WebKit::WebPageProxy::updatePDFHUDLocation):
(WebKit::WebPageProxy::pdfZoomIn):
(WebKit::WebPageProxy::pdfZoomOut):
(WebKit::WebPageProxy::pdfSaveToPDF):
(WebKit::WebPageProxy::pdfOpenWithPreview):

  • WebKit.xcodeproj/project.pbxproj:
  • WebProcess/Plugins/PDF/PDFLayerControllerSPI.h:
  • WebProcess/Plugins/PDF/PDFPlugin.h:
  • WebProcess/Plugins/PDF/PDFPlugin.mm:

(-[WKPDFLayerControllerDelegate openWithNativeApplication]):
(-[WKPDFLayerControllerDelegate saveToPDF]):
(WebKit::PDFPlugin::PDFPlugin):
(WebKit::PDFPlugin::~PDFPlugin):
(WebKit::PDFPlugin::frameForHUD const):
(WebKit::PDFPlugin::calculateSizes):
(WebKit::PDFPlugin::convertFromPDFViewToRootView const):
(WebKit::PDFPlugin::visibilityDidChange):
(WebKit::PDFPlugin::zoomIn):
(WebKit::PDFPlugin::zoomOut):
(WebKit::PDFPlugin::save):
(WebKit::PDFPlugin::openWithPreview):

  • WebProcess/WebPage/WebPage.cpp:
  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:
  • WebProcess/WebPage/mac/WebPageMac.mm:

(WebKit::WebPage::zoomPDFIn):
(WebKit::WebPage::zoomPDFOut):
(WebKit::WebPage::savePDF):
(WebKit::WebPage::openPDFWithPreview):
(WebKit::WebPage::createPDFHUD):
(WebKit::WebPage::updatePDFHUDLocation):
(WebKit::WebPage::removePDFHUD):

Source/WTF:

  • wtf/PlatformHave.h:

Tools:

  • TestWebKitAPI/Tests/WebKitCocoa/WKPDFView.mm:

(pdfData):
(TEST):
(checkFrame):

  • TestWebKitAPI/cocoa/TestUIDelegate.h:
  • TestWebKitAPI/cocoa/TestUIDelegate.mm:

(-[TestUIDelegate _webView:saveDataToFile:suggestedFilename:mimeType:originatingURL:]):

Location:
trunk
Files:
2 added
30 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r266579 r266654  
     12020-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
    1112020-09-03  Ryosuke Niwa  <rniwa@webkit.org>
    212
  • trunk/Source/WTF/wtf/PlatformEnableCocoa.h

    r265823 r266654  
    229229#endif
    230230
     231#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 110000
     232#define ENABLE_UI_PROCESS_PDF_HUD 1
     233#endif
     234
    231235#if !defined(ENABLE_INDEXED_DATABASE)
    232236#define ENABLE_INDEXED_DATABASE 1
  • trunk/Source/WebCore/PAL/pal/spi/mac/NSImageSPI.h

    r265010 r266654  
    3737
    3838@interface NSImage ()
     39+ (instancetype)imageWithImageRep:(NSImageRep *)imageRep;
     40- (instancetype)_imageWithConfiguration:(NSDictionary *)configuration;
    3941- (void)lockFocusWithRect:(NSRect)rect context:(nullable NSGraphicsContext *)context hints:(nullable NSDictionary *)hints flipped:(BOOL)flipped;
    4042@end
     
    4345+ (nullable NSImage *)_imageWithSystemSymbolName:(NSString *) symbolName;
    4446@end
     47
     48WTF_EXTERN_C_BEGIN
     49
     50extern const NSString *NSImageAlternateCriterionFont;
     51extern const NSString *NSImageAlternateCriterionSymbolScale;
     52
     53WTF_EXTERN_C_END
    4554
    4655NS_ASSUME_NONNULL_END
     
    5766NS_ASSUME_NONNULL_END
    5867
    59 #endif
     68#endif // HAVE(ALTERNATE_ICONS)
    6069
    61 #endif
     70#endif // USE(APPLE_INTERNAL_SDK)
  • trunk/Source/WebKit/ChangeLog

    r266650 r266654  
     12020-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
    1942020-09-04  Chris Dumez  <cdumez@apple.com>
    295
  • trunk/Source/WebKit/Scripts/webkit/messages.py

    r266467 r266654  
    245245        'WebKit::MediaPlayerPrivateRemoteIdentifier',
    246246        'WebKit::MediaRecorderIdentifier',
     247        'WebKit::PDFPluginIdentifier',
    247248        'WebKit::PlaybackSessionContextIdentifier',
    248249        'WebKit::PluginProcessType',
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h

    r265284 r266654  
    2424 */
    2525
    26 #import "WKWebViewPrivate.h"
    27 
     26#import "PDFPluginIdentifier.h"
    2827#import "SameDocumentNavigationType.h"
    2928#import "WKShareSheet.h"
    3029#import "WKWebViewConfiguration.h"
     30#import "WKWebViewPrivate.h"
    3131#import "_WKAttachmentInternal.h"
    3232#import "_WKWebViewPrintFormatterInternal.h"
     
    134134    RetainPtr<WKScrollView> _scrollView;
    135135    RetainPtr<WKContentView> _contentView;
    136 #endif
     136#endif // PLATFORM(MAC)
    137137
    138138#if PLATFORM(IOS_FAMILY)
  • trunk/Source/WebKit/UIProcess/API/mac/WKWebViewPrivateForTestingMac.h

    r255322 r266654  
    5151- (void)_setHeaderBannerHeight:(int)height;
    5252- (void)_setFooterBannerHeight:(int)height;
     53- (NSSet<NSView *> *)_pdfHUDs;
    5354
    5455@end
  • trunk/Source/WebKit/UIProcess/API/mac/WKWebViewTestingMac.mm

    r266051 r266654  
    104104}
    105105
     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
    106115- (NSMenu *)_activeMenu
    107116{
  • trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h

    r260186 r266654  
    2828#if PLATFORM(MAC)
    2929
     30#include "PDFPluginIdentifier.h"
    3031#include "PluginComplexTextInputState.h"
    3132#include "ShareableBitmap.h"
     
    7778#endif // HAVE(TOUCH_BAR)
    7879
     80#if ENABLE(UI_PROCESS_PDF_HUD)
     81OBJC_CLASS WKPDFHUDView;
     82#endif
     83
    7984namespace API {
    8085class HitTestResult;
     
    190195    void viewWillStartLiveResize();
    191196    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
    192205
    193206    void renewGState();
     
    730743    RetainPtr<WKFullScreenWindowController> m_fullScreenWindowController;
    731744#endif
    732    
     745
     746#if ENABLE(UI_PROCESS_PDF_HUD)
     747    HashMap<WebKit::PDFPluginIdentifier, RetainPtr<WKPDFHUDView>> _pdfHUDViews;
     748#endif
     749
    733750    RetainPtr<WKShareSheet> _shareSheet;
    734751
  • trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm

    r266051 r266654  
    6363#import "WKFullScreenWindowController.h"
    6464#import "WKImmediateActionController.h"
     65#import "WKPDFHUDView.h"
    6566#import "WKPrintingView.h"
    6667#import "WKSafeBrowsingWarning.h"
     
    17191720}
    17201721
     1722#if ENABLE(UI_PROCESS_PDF_HUD)
     1723
     1724void 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
     1732void WebViewImpl::updatePDFHUDLocation(PDFPluginIdentifier identifier, const WebCore::IntRect& rect)
     1733{
     1734    if (auto hud = _pdfHUDViews.get(identifier))
     1735        [hud setFrame:rect];
     1736}
     1737
     1738void WebViewImpl::removePDFHUD(PDFPluginIdentifier identifier)
     1739{
     1740    if (auto hud = _pdfHUDViews.take(identifier))
     1741        [hud removeFromSuperview];
     1742}
     1743
     1744void WebViewImpl::removeAllPDFHUDs()
     1745{
     1746    for (auto& hud : _pdfHUDViews.values())
     1747        [hud removeFromSuperview];
     1748    _pdfHUDViews.clear();
     1749}
     1750
     1751NSSet *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
    17211761void WebViewImpl::renewGState()
    17221762{
     
    21502190
    21512191    m_page->setIntrinsicDeviceScaleFactor(newBackingScaleFactor);
     2192#if ENABLE(UI_PROCESS_PDF_HUD)
     2193    for (auto& hud : _pdfHUDViews.values())
     2194        [hud setDeviceScaleFactor:newBackingScaleFactor];
     2195#endif
    21522196}
    21532197
     
    53925436        return;
    53935437
     5438#if ENABLE(UI_PROCESS_PDF_HUD)
     5439    for (auto& hud : _pdfHUDViews.values())
     5440        [hud mouseMoved:event];
     5441#endif
     5442
    53945443    // When a view is first responder, it gets mouse moved events even when the mouse is outside its visible rect.
    53955444    if (m_view.getAutoreleased() == [m_view window].firstResponder && !NSPointInRect([m_view convertPoint:[event locationInWindow] fromView:nil], [m_view visibleRect]))
     
    54405489        return;
    54415490
     5491#if ENABLE(UI_PROCESS_PDF_HUD)
     5492    for (auto& hud : _pdfHUDViews.values())
     5493        [hud mouseDown:event];
     5494#endif
     5495
    54425496    setLastMouseDownEvent(event);
    54435497    setIgnoresMouseDraggedEvents(false);
     
    54505504    if (m_ignoresNonWheelEvents)
    54515505        return;
     5506
     5507#if ENABLE(UI_PROCESS_PDF_HUD)
     5508    for (auto& hud : _pdfHUDViews.values())
     5509        [hud mouseUp:event];
     5510#endif
    54525511
    54535512    setLastMouseDownEvent(nil);
  • trunk/Source/WebKit/UIProcess/PDF/WKPDFHUDView.h

    r266653 r266654  
    2424 */
    2525
    26 #import <WebKit/WKUIDelegatePrivate.h>
     26#if ENABLE(UI_PROCESS_PDF_HUD)
    2727
    28 @interface TestUIDelegate : NSObject <WKUIDelegate>
     28#import "PDFPluginIdentifier.h"
    2929
    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
     30namespace WebKit {
     31class WebPageProxy;
     32}
    3433
    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;
    3642
    3743@end
    3844
    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  
    2727
    2828#include "LayerTreeContext.h"
     29#include "PDFPluginIdentifier.h"
    2930#include "SameDocumentNavigationType.h"
    3031#include "ShareableBitmap.h"
     
    242243    virtual void didCommitLoadForMainFrame(const String& mimeType, bool useCustomContentProvider) = 0;
    243244
     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   
    244252    virtual void handleDownloadRequest(DownloadProxy&) = 0;
    245253
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r266634 r266654  
    47664766            m_mainFramePluginHandlesPageScaleGesture = false;
    47674767        }
    4768     }
    4769 
    47704768#if ENABLE(POINTER_LOCK)
    4771     if (frame->isMainFrame())
    47724769        requestPointerUnlock();
    47734770#endif
    4774 
    4775     if (frame->isMainFrame())
    47764771        pageClient().setMouseEventPolicy(mouseEventPolicy);
     4772#if ENABLE(UI_PROCESS_PDF_HUD)
     4773        pageClient().removeAllPDFHUDs();
     4774#endif
     4775    }
    47774776
    47784777    m_pageLoadState.commitChanges();
     
    74477446    resetStateAfterProcessExited(reason);
    74487447    stopAllURLSchemeTasks(m_process.ptr());
     7448#if ENABLE(UI_PROCESS_PDF_HUD)
     7449    pageClient().removeAllPDFHUDs();
     7450#endif
    74497451
    74507452    // For bringup of process swapping, NavigationSwap termination will not go out to clients.
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r266634 r266654  
    4141#include "MessageSender.h"
    4242#include "NotificationPermissionRequestManagerProxy.h"
     43#include "PDFPluginIdentifier.h"
    4344#include "PageLoadState.h"
    4445#include "PluginProcessAttributes.h"
     
    13181319    void saveDataToFileInDownloadsFolder(String&& suggestedFilename, String&& mimeType, URL&& originatingURL, API::Data&);
    13191320    void savePDFToFileInDownloadsFolder(String&& suggestedFilename, URL&& originatingURL, const IPC::DataReference&);
    1320 #if PLATFORM(COCOA)
     1321#if ENABLE(PDFKIT_PLUGIN)
    13211322    void savePDFToTemporaryFolderAndOpenWithNativeApplication(const String& suggestedFilename, FrameInfoData&&, const IPC::DataReference&, const String& pdfUUID);
     1323#if !ENABLE(UI_PROCESS_PDF_HUD)
    13221324    void openPDFFromTemporaryFolderWithNativeApplication(FrameInfoData&&, const String& pdfUUID);
     1325#endif
    13231326#endif
    13241327
     
    18081811    bool canUseCredentialStorage() { return m_canUseCredentialStorage; }
    18091812    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
    18101823
    18111824private:
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r266063 r266654  
    434434    LoadRecentSearches(String name) -> (Vector<WebCore::RecentSearch> result) Synchronous
    435435
     436#if ENABLE(PDFKIT_PLUGIN) && !ENABLE(UI_PROCESS_PDF_HUD)
    436437    SavePDFToFileInDownloadsFolder(String suggestedFilename, URL originatingURL, IPC::DataReference data)
    437 
    438 #if PLATFORM(COCOA)
    439438    SavePDFToTemporaryFolderAndOpenWithNativeApplication(String suggestedFilename, struct WebKit::FrameInfoData sourceFrameInfo, IPC::DataReference data, String pdfUUID)
    440439    OpenPDFFromTemporaryFolderWithNativeApplication(struct WebKit::FrameInfoData sourceFrameInfo, String pdfUUID)
     
    567566#endif
    568567
     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
    569574    ConfigureLoggingChannel(String channelName, enum:uint8_t WTFLogChannelState state, enum:uint8_t WTFLogLevel level)
    570575
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r266576 r266654  
    10891089}
    10901090
    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 
    11011091void WebPageProxy::setRemoteLayerTreeRootNode(RemoteLayerTreeNode* rootNode)
    11021092{
  • trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h

    r266063 r266654  
    191191    void registerInsertionUndoGrouping() override;
    192192
     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
    193200    // Auxiliary Client Creation
    194201#if ENABLE(FULLSCREEN_API)
  • trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm

    r266063 r266654  
    350350}
    351351
     352#if ENABLE(UI_PROCESS_PDF_HUD)
     353
     354void PageClientImpl::createPDFHUD(PDFPluginIdentifier identifier, const WebCore::IntRect& rect)
     355{
     356    m_impl->createPDFHUD(identifier, rect);
     357}
     358
     359void PageClientImpl::updatePDFHUDLocation(PDFPluginIdentifier identifier, const WebCore::IntRect& rect)
     360{
     361    m_impl->updatePDFHUDLocation(identifier, rect);
     362}
     363
     364void PageClientImpl::removePDFHUD(PDFPluginIdentifier identifier)
     365{
     366    m_impl->removePDFHUD(identifier);
     367}
     368
     369void PageClientImpl::removeAllPDFHUDs()
     370{
     371    m_impl->removeAllPDFHUDs();
     372}
     373
     374#endif // ENABLE(UI_PROCESS_PDF_HUD)
     375
    352376void PageClientImpl::clearAllEditCommands()
    353377{
  • trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm

    r266576 r266654  
    481481void WebPageProxy::savePDFToTemporaryFolderAndOpenWithNativeApplication(const String& suggestedFilename, FrameInfoData&& frameInfo, const IPC::DataReference& data, const String& pdfUUID)
    482482{
    483     MESSAGE_CHECK(TemporaryPDFFileMap::isValidKey(pdfUUID));
    484 
    485483    if (data.isEmpty()) {
    486484        WTFLogAlways("Cannot save empty PDF file to the temporary directory.");
     
    510508    FileSystem::setMetadataURL(nsPath.get(), originatingURLString);
    511509
    512     m_temporaryPDFFiles.add(pdfUUID, nsPath.get());
     510    if (TemporaryPDFFileMap::isValidKey(pdfUUID))
     511        m_temporaryPDFFiles.add(pdfUUID, nsPath.get());
    513512
    514513    auto pdfFileURL = URL::fileURLWithFileSystemPath(String(nsPath.get()));
     
    520519}
    521520
     521#if ENABLE(PDFKIT_PLUGIN) && !ENABLE(UI_PROCESS_PDF_HUD)
    522522void WebPageProxy::openPDFFromTemporaryFolderWithNativeApplication(FrameInfoData&& frameInfo, const String& pdfUUID)
    523523{
     
    536536    });
    537537}
     538#endif
    538539
    539540#if ENABLE(PDFKIT_PLUGIN)
     
    679680}
    680681
     682#if ENABLE(UI_PROCESS_PDF_HUD)
     683
     684void WebPageProxy::createPDFHUD(PDFPluginIdentifier identifier, const WebCore::IntRect& rect)
     685{
     686    pageClient().createPDFHUD(identifier, rect);
     687}
     688
     689void WebPageProxy::removePDFHUD(PDFPluginIdentifier identifier)
     690{
     691    pageClient().removePDFHUD(identifier);
     692}
     693
     694void WebPageProxy::updatePDFHUDLocation(PDFPluginIdentifier identifier, const WebCore::IntRect& rect)
     695{
     696    pageClient().updatePDFHUDLocation(identifier, rect);
     697}
     698
     699void WebPageProxy::pdfZoomIn(PDFPluginIdentifier identifier)
     700{
     701    send(Messages::WebPage::ZoomPDFIn(identifier));
     702}
     703
     704void WebPageProxy::pdfZoomOut(PDFPluginIdentifier identifier)
     705{
     706    send(Messages::WebPage::ZoomPDFOut(identifier));
     707}
     708
     709void 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
     716void 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
    681725} // namespace WebKit
    682726
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r266467 r266654  
    17871787                DF462E0F23F22F5500EFF35F /* WKHTTPCookieStorePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = DF462E0E23F22F5300EFF35F /* WKHTTPCookieStorePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17881788                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 */; };
    17891790                E105FE5418D7B9DE008F57A8 /* EditingRange.h in Headers */ = {isa = PBXBuildFile; fileRef = E105FE5318D7B9DE008F57A8 /* EditingRange.h */; };
    17901791                E11D35AE16B63D1B006D23D7 /* com.apple.WebProcess.sb in Resources */ = {isa = PBXBuildFile; fileRef = E1967E37150AB5E200C73169 /* com.apple.WebProcess.sb */; };
     
    52655266                DF58C6311371AC5800F9A37C /* NativeWebWheelEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeWebWheelEvent.h; sourceTree = "<group>"; };
    52665267                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>"; };
    52675271                E105FE5318D7B9DE008F57A8 /* EditingRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditingRange.h; sourceTree = "<group>"; };
    52685272                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; };
     
    58865890                                1A6FB90811E66FB100DB1371 /* Netscape */,
    58875891                                E199875B142BF9CF00BB2DE7 /* PDF */,
     5892                                DF74275C24F4955000F8ABE9 /* PDFPluginIdentifier.h */,
    58885893                                1A6FB7D011E651E200DB1371 /* Plugin.cpp */,
    58895894                                1A6FB7D111E651E200DB1371 /* Plugin.h */,
     
    89398944                                510CC7E716138E7200D03ED3 /* Network */,
    89408945                                31A2EC401489973700810D71 /* Notifications */,
     8946                                DF84CEE1249AA200009096F6 /* PDF */,
    89418947                                1AEFCC0511D01F34008219D3 /* Plugins */,
    89428948                                2D1551A91F5A9B420006E3FE /* RemoteLayerTree */,
     
    1042410430                        );
    1042510431                        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;
    1042610441                        sourceTree = "<group>";
    1042710442                };
     
    1311313128                                5CE9120D2293C219005BEC78 /* WKMain.mm in Sources */,
    1311413129                                4657D88A22664A2F005DE823 /* WKOrientationAccessAlert.mm in Sources */,
     13130                                DF84CEE4249AA24D009096F6 /* WKPDFHUDView.mm in Sources */,
    1311513131                                5CA26D83217AD1B800F97A35 /* WKSafeBrowsingWarning.mm in Sources */,
    1311613132                                1DB01944211CF005009FB3E8 /* WKShareSheet.mm in Sources */,
  • trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h

    r248697 r266654  
    8787
    8888- (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
    8995
    9096- (void)magnifyWithMagnification:(CGFloat)magnification atPoint:(CGPoint)point immediately:(BOOL)immediately;
  • trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.h

    r264945 r266654  
    2929
    3030#include "PDFKitImports.h"
     31#include "PDFPluginIdentifier.h"
    3132#include "Plugin.h"
    3233#include "WebEvent.h"
     
    5152OBJC_CLASS NSAttributedString;
    5253OBJC_CLASS NSData;
     54OBJC_CLASS NSEvent;
    5355OBJC_CLASS NSString;
    5456OBJC_CLASS PDFAnnotation;
     
    7880class PluginView;
    7981class WebFrame;
    80 
    81 class PDFPlugin final : public Plugin, private WebCore::ScrollableArea
     82struct FrameInfoData;
     83
     84class PDFPlugin final : public Plugin, public WebCore::ScrollableArea
    8285#if HAVE(INCREMENTAL_PDF_APIS)
    8386    , private WebCore::NetscapePlugInStreamLoaderClient
     
    104107    void notifyCursorChanged(uint64_t /* PDFLayerControllerCursorType */);
    105108
     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
    106117    void clickedLink(NSURL *);
     118#if !ENABLE(UI_PROCESS_PDF_HUD)
    107119    void saveToPDF();
    108120    void openWithNativeApplication();
     121#endif
    109122    void writeItemsToPasteboard(NSString *pasteboardName, NSArray *items, NSArray *types);
    110123    void showDefinitionForAttributedString(NSAttributedString *, CGPoint);
     
    119132    WebCore::FloatRect convertFromPDFViewToScreen(const WebCore::FloatRect&) const;
    120133    WebCore::IntPoint convertFromRootViewToPDFView(const WebCore::IntPoint&) const;
     134    WebCore::IntPoint convertFromPDFViewToRootView(const WebCore::IntPoint&) const;
     135    WebCore::IntRect convertFromPDFViewToRootView(const WebCore::IntRect&) const;
    121136    WebCore::IntRect boundsOnScreen() const;
     137    WebCore::IntRect frameForHUD() const;
    122138
    123139    bool showContextMenuAtPoint(const WebCore::IntPoint&);
     
    160176    void geometryDidChange(const WebCore::IntSize& pluginSize, const WebCore::IntRect& clipRect, const WebCore::AffineTransform& pluginToRootViewTransform) final;
    161177    void contentsScaleFactorChanged(float) final;
    162     void visibilityDidChange(bool) final { }
     178    void visibilityDidChange(bool) final;
    163179    void frameDidFinishLoading(uint64_t requestID) final;
    164180    void frameDidFail(uint64_t requestID, bool wasCancelled) final;
     
    264280    WebCore::IntPoint convertFromPluginToPDFView(const WebCore::IntPoint&) const;
    265281    WebCore::IntPoint convertFromRootViewToPlugin(const WebCore::IntPoint&) const;
    266     WebCore::IntPoint convertFromPDFViewToRootView(const WebCore::IntPoint&) const;
    267282   
    268283    bool supportsForms();
     
    404419
    405420#endif // HAVE(INCREMENTAL_PDF_APIS)
     421#if ENABLE(UI_PROCESS_PDF_HUD)
     422    PDFPluginIdentifier m_identifier;
     423#endif
    406424};
    407425
  • trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm

    r266099 r266654  
    434434- (void)openWithNativeApplication
    435435{
     436#if !ENABLE(UI_PROCESS_PDF_HUD)
    436437    _pdfPlugin->openWithNativeApplication();
     438#endif
    437439}
    438440
    439441- (void)saveToPDF
    440442{
     443#if !ENABLE(UI_PROCESS_PDF_HUD)
    441444    _pdfPlugin->saveToPDF();
     445#endif
    442446}
    443447
     
    601605    , m_incrementalPDFLoadingEnabled(WebCore::RuntimeEnabledFeatures::sharedFeatures().incrementalPDFLoadingEnabled())
    602606#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
    604614    m_pdfLayerController.get().delegate = m_pdfLayerControllerDelegate.get();
    605615    m_pdfLayerController.get().parentLayer = m_contentLayer.get();
     
    641651PDFPlugin::~PDFPlugin()
    642652{
     653#if ENABLE(UI_PROCESS_PDF_HUD)
     654    if (auto* page = m_frame.page())
     655        page->removePDFHUD(*this);
     656#endif
    643657}
    644658
     
    17811795}
    17821796
     1797IntRect PDFPlugin::frameForHUD() const
     1798{
     1799    return convertFromPDFViewToRootView(IntRect(IntPoint(), size()));
     1800}
     1801
    17831802void PDFPlugin::calculateSizes()
    17841803{
     
    17911810    m_firstPageHeight = [m_pdfDocument pageCount] ? static_cast<unsigned>(CGCeiling([[m_pdfDocument pageAtIndex:0] boundsForBox:kPDFDisplayBoxCropBox].size.height)) : 0;
    17921811    setPDFDocumentSize(IntSize([m_pdfLayerController contentSizeRespectingZoom]));
     1812
     1813#if ENABLE(UI_PROCESS_PDF_HUD)
     1814    m_frame.page()->updatePDFHUDLocation(*this, frameForHUD());
     1815#endif
    17931816}
    17941817
     
    19251948    return m_rootViewToPluginTransform.inverse().valueOr(AffineTransform()).mapPoint(pointInPluginCoordinates);
    19261949}
    1927    
     1950
     1951IntRect 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
    19281957IntPoint PDFPlugin::convertFromRootViewToPDFView(const IntPoint& point) const
    19291958{
     
    19541983    FloatRect rectInRootViewCoordinates = m_rootViewToPluginTransform.inverse().valueOr(AffineTransform()).mapRect(bounds);
    19551984    return frameView->contentsToScreen(enclosingIntRect(rectInRootViewCoordinates));
     1985}
     1986
     1987void 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
    19561997}
    19571998
     
    24012442}
    24022443
     2444#if ENABLE(UI_PROCESS_PDF_HUD)
     2445
     2446void PDFPlugin::zoomIn()
     2447{
     2448    [m_pdfLayerController zoomIn:nil];
     2449}
     2450
     2451void PDFPlugin::zoomOut()
     2452{
     2453    [m_pdfLayerController zoomOut:nil];
     2454}
     2455
     2456void 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
     2462void 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)
    24032469   
    24042470void PDFPlugin::saveToPDF()
     
    24322498    m_frame.page()->send(Messages::WebPageProxy::OpenPDFFromTemporaryFolderWithNativeApplication(m_frame.info(), m_temporaryPDFUUID));
    24332499}
     2500
     2501#endif // ENABLE(UI_PROCESS_PDF_HUD)
    24342502
    24352503void PDFPlugin::writeItemsToPasteboard(NSString *pasteboardName, NSArray *items, NSArray *types)
  • trunk/Source/WebKit/WebProcess/Plugins/PDFPluginIdentifier.h

    r266653 r266654  
    2424 */
    2525
    26 #import <WebKit/WKUIDelegatePrivate.h>
     26#pragma once
    2727
    28 @interface TestUIDelegate : NSObject <WKUIDelegate>
     28#include <wtf/ObjectIdentifier.h>
    2929
    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 *));
     30namespace WebKit {
     31
     32#if ENABLE(UI_PROCESS_PDF_HUD)
     33enum PDFPluginIdentifierType { };
     34using PDFPluginIdentifier = ObjectIdentifier<PDFPluginIdentifierType>;
    3335#endif
    3436
    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  
    51215121#endif
    51225122
     5123#if ENABLE(PDFKIT_PLUGIN) && !ENABLE(UI_PROCESS_PDF_HUD)
    51235124void WebPage::savePDFToFileInDownloadsFolder(const String& suggestedFilename, const URL& originatingURL, const uint8_t* data, unsigned long size)
    51245125{
     
    51265127}
    51275128
    5128 #if PLATFORM(COCOA)
    51295129void WebPage::savePDFToTemporaryFolderAndOpenWithNativeApplication(const String& suggestedFilename, FrameInfoData&& frameInfo, const uint8_t* data, unsigned long size, const String& pdfUUID)
    51305130{
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r266342 r266654  
    4646#include "MessageSender.h"
    4747#include "OptionalCallbackID.h"
     48#include "PDFPluginIdentifier.h"
    4849#include "Plugin.h"
    4950#include "PolicyDecision.h"
     
    346347    void centerSelectionInVisibleArea();
    347348
     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
    348359#if PLATFORM(COCOA)
    349360    void willCommitLayerTree(RemoteLayerTreeTransaction&);
     
    10741085#endif
    10751086
     1087#if ENABLE(PDFKIT_PLUGIN) && !ENABLE(UI_PROCESS_PDF_HUD)
    10761088    void savePDFToFileInDownloadsFolder(const String& suggestedFilename, const URL& originatingURL, const uint8_t* data, unsigned long size);
    1077 
    1078 #if PLATFORM(COCOA)
    10791089    void savePDFToTemporaryFolderAndOpenWithNativeApplication(const String& suggestedFilename, FrameInfoData&&, const uint8_t* data, unsigned long size, const String& pdfUUID);
    10801090#endif
     
    17911801    WebCore::Color m_underlayColor;
    17921802
     1803#if ENABLE(UI_PROCESS_PDF_HUD)
     1804    HashMap<PDFPluginIdentifier, WeakPtr<PDFPlugin>> m_pdfPlugInsWithHUD;
     1805#endif
     1806
    17931807    bool m_isInRedo { false };
    17941808    bool m_isClosed { false };
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r266342 r266654  
    576576    SetDefersLoading(bool defersLoading)
    577577
     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
    578585    UpdateCurrentModifierState(OptionSet<WebCore::PlatformEvent::Modifier> modifiers)
    579586    SimulateDeviceOrientationChange(double alpha, double beta, double gamma)
  • trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm

    r266295 r266654  
    3434#import "EditorState.h"
    3535#import "FontInfo.h"
     36#import "FrameInfoData.h"
    3637#import "InjectedBundleHitTestResult.h"
    3738#import "PDFKitImports.h"
     
    10521053}
    10531054
    1054 #endif
     1055#endif // HAVE(APP_ACCENT_COLORS)
     1056
     1057#if ENABLE(UI_PROCESS_PDF_HUD)
     1058
     1059void WebPage::zoomPDFIn(PDFPluginIdentifier identifier)
     1060{
     1061    auto pdfPlugin = m_pdfPlugInsWithHUD.get(identifier);
     1062    if (!pdfPlugin)
     1063        return;
     1064    pdfPlugin->zoomIn();
     1065}
     1066
     1067void WebPage::zoomPDFOut(PDFPluginIdentifier identifier)
     1068{
     1069    auto pdfPlugin = m_pdfPlugInsWithHUD.get(identifier);
     1070    if (!pdfPlugin)
     1071        return;
     1072    pdfPlugin->zoomOut();
     1073}
     1074
     1075void 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
     1083void 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
     1091void 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
     1098void 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
     1104void 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)
    10551111
    10561112} // namespace WebKit
  • trunk/Tools/ChangeLog

    r266640 r266654  
     12020-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
    1172020-09-04  Jonathan Bedard  <jbedard@apple.com>
    218
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKPDFView.mm

    r261407 r266654  
    3131#import "Test.h"
    3232#import "TestNavigationDelegate.h"
     33#import "TestUIDelegate.h"
     34#import "TestURLSchemeHandler.h"
     35#import "TestWKWebView.h"
    3336#import <WebKit/WKWebView.h>
    3437#import <WebKit/WKWebViewConfigurationPrivate.h>
     38#import <WebKit/WKWebViewPrivateForTesting.h>
    3539#import <wtf/RetainPtr.h>
    3640
    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)
     46static NSData *pdfData()
     47{
     48    return [NSData dataWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"test" withExtension:@"pdf" subdirectory:@"TestWebKitAPI.resources"]];
     49}
     50#endif
     51
     52#if PLATFORM(IOS)
    3853
    3954@interface PDFHostViewController : UIViewController
     
    102117
    103118    // 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"]];
    105120    [webView _test_waitForDidFinishNavigation];
    106121
     
    133148
    134149#endif
     150
     151#if ENABLE(UI_PROCESS_PDF_HUD)
     152
     153static 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
     161TEST(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
     189TEST(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
     243TEST(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
     282TEST(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
     312TEST(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  
    3232@property (nonatomic, copy) void (^getContextMenuFromProposedMenu)(NSMenu *, _WKContextMenuElementInfo *, id <NSSecureCoding>, void (^)(NSMenu *));
    3333#endif
     34@property (nonatomic, copy) void (^saveDataToFile)(WKWebView *, NSData *, NSString *, NSString *, NSURL *);
    3435
    3536- (NSString *)waitForAlert;
  • trunk/Tools/TestWebKitAPI/cocoa/TestUIDelegate.mm

    r264113 r266654  
    5151#endif // PLATFORM(MAC)
    5252
     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
    5359- (NSString *)waitForAlert
    5460{
Note: See TracChangeset for help on using the changeset viewer.