Title: [251553] trunk
Revision
251553
Author
beid...@apple.com
Date
2019-10-24 12:43:49 -0700 (Thu, 24 Oct 2019)

Log Message

Formalize PDF snapshot API.
https://bugs.webkit.org/show_bug.cgi?id=203374

Reviewed by Tim Horton.

Source/WebKit:

Covered by API tests and MiniBrowser usage.

* SourcesCocoa.txt:
* UIProcess/API/Cocoa/WKPDFConfiguration.h: Added.
* UIProcess/API/Cocoa/WKPDFConfiguration.mm: Added.
(-[WKPDFConfiguration init]):
(-[WKPDFConfiguration copyWithZone:]):

* UIProcess/API/Cocoa/WKWebView.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView createPDFWithConfiguration:completionHandler:]):
(-[WKWebView _takePDFSnapshotWithConfiguration:completionHandler:]):

* UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.h: Unified build strikes again.

* WebKit.xcodeproj/project.pbxproj:

Tools:

* MiniBrowser/mac/WK2BrowserWindowController.m:
(-[WK2BrowserWindowController saveAsPDF:]):

* TestWebKitAPI/Tests/WebKitCocoa/PDFSnapshot.mm:
(TestWebKitAPI::TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (251552 => 251553)


--- trunk/Source/WebKit/ChangeLog	2019-10-24 19:27:26 UTC (rev 251552)
+++ trunk/Source/WebKit/ChangeLog	2019-10-24 19:43:49 UTC (rev 251553)
@@ -1,3 +1,27 @@
+2019-10-24  Brady Eidson  <beid...@apple.com>
+
+        Formalize PDF snapshot API.
+        https://bugs.webkit.org/show_bug.cgi?id=203374
+
+        Reviewed by Tim Horton.
+
+        Covered by API tests and MiniBrowser usage.
+
+        * SourcesCocoa.txt:
+        * UIProcess/API/Cocoa/WKPDFConfiguration.h: Added.
+        * UIProcess/API/Cocoa/WKPDFConfiguration.mm: Added.
+        (-[WKPDFConfiguration init]):
+        (-[WKPDFConfiguration copyWithZone:]):
+
+        * UIProcess/API/Cocoa/WKWebView.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView createPDFWithConfiguration:completionHandler:]):
+        (-[WKWebView _takePDFSnapshotWithConfiguration:completionHandler:]):
+
+        * UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.h: Unified build strikes again.
+
+        * WebKit.xcodeproj/project.pbxproj:
+
 2019-10-24  Brent Fulgham  <bfulg...@apple.com>
 
         [iOS] Remove 'deny' rules that do not have a corresponding 'allow' rule

Modified: trunk/Source/WebKit/SourcesCocoa.txt (251552 => 251553)


--- trunk/Source/WebKit/SourcesCocoa.txt	2019-10-24 19:27:26 UTC (rev 251552)
+++ trunk/Source/WebKit/SourcesCocoa.txt	2019-10-24 19:43:49 UTC (rev 251553)
@@ -296,6 +296,7 @@
 UIProcess/API/Cocoa/WKNavigationResponse.mm
 UIProcess/API/Cocoa/WKNSURLAuthenticationChallenge.mm
 UIProcess/API/Cocoa/WKOpenPanelParameters.mm
+UIProcess/API/Cocoa/WKPDFConfiguration.mm
 UIProcess/API/Cocoa/WKPreferences.mm
 UIProcess/API/Cocoa/WKPreviewActionItem.mm
 UIProcess/API/Cocoa/WKPreviewActionItemIdentifiers.mm

Added: trunk/Source/WebKit/UIProcess/API/Cocoa/WKPDFConfiguration.h (0 => 251553)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKPDFConfiguration.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKPDFConfiguration.h	2019-10-24 19:43:49 UTC (rev 251553)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <WebKit/WKFoundation.h>
+
+#import <CoreGraphics/CGGeometry.h>
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+WK_CLASS_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA))
+@interface WKPDFConfiguration : NSObject <NSCopying>
+
+/*! @abstract The rect to capture in web page coordinates
+ @discussion If the rect is set to the null rect, the bounds of the currently displayed web page will be used.
+ The initial value is the null rect.
+ */
+@property (nonatomic) CGRect rect NS_REFINED_FOR_SWIFT;
+
+@end
+
+NS_ASSUME_NONNULL_END

Added: trunk/Source/WebKit/UIProcess/API/Cocoa/WKPDFConfiguration.mm (0 => 251553)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKPDFConfiguration.mm	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKPDFConfiguration.mm	2019-10-24 19:43:49 UTC (rev 251553)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKPDFConfiguration.h"
+
+@implementation WKPDFConfiguration
+
+- (instancetype)init
+{
+    if (!(self = [super init]))
+        return nil;
+
+    self.rect = CGRectNull;
+    return self;
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+    WKPDFConfiguration *pdfConfiguration = [(WKPDFConfiguration *)[[self class] allocWithZone:zone] init];
+
+    pdfConfiguration.rect = self.rect;
+
+    return pdfConfiguration;
+}
+
+@end

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.h (251552 => 251553)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.h	2019-10-24 19:27:26 UTC (rev 251552)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.h	2019-10-24 19:43:49 UTC (rev 251553)
@@ -36,6 +36,7 @@
 @class WKBackForwardList;
 @class WKBackForwardListItem;
 @class WKNavigation;
+@class WKPDFConfiguration;
 @class WKSnapshotConfiguration;
 @class WKWebViewConfiguration;
 
@@ -232,6 +233,16 @@
 - (void)takeSnapshotWithConfiguration:(nullable WKSnapshotConfiguration *)snapshotConfiguration completionHandler:(void (^)(NSImage * _Nullable snapshotImage, NSError * _Nullable error))completionHandler WK_API_AVAILABLE(macos(10.13));
 #endif
 
+/*! @abstract Create a PDF document representation from the web page currently displayed in the WKWebView
+@param pdfConfiguration An object that specifies how the PDF capture is configured.
+@param completionHandler A block to invoke when the pdf document data is ready.
+@discussion If the WKPDFConfiguration is nil, the method will create a PDF document representing the bounds of the currently displayed web page.
+The completionHandler is passed the resulting PDF document data or an error.
+The data can be used to create a PDFDocument object.
+If the data is written to a file the resulting file is a valid PDF document.
+*/
+- (void)createPDFWithConfiguration:(nullable WKPDFConfiguration *)pdfConfiguration completionHandler:(void (^)(NSData * _Nullable pdfDocumentData, NSError * _Nullable error))completionHandler NS_REFINED_FOR_SWIFT WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 /*! @abstract A Boolean value indicating whether horizontal swipe gestures
  will trigger back-forward list navigations.
  @discussion The default value is NO.

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (251552 => 251553)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2019-10-24 19:27:26 UTC (rev 251552)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2019-10-24 19:43:49 UTC (rev 251553)
@@ -65,6 +65,7 @@
 #import "WKNSURLExtras.h"
 #import "WKNavigationDelegate.h"
 #import "WKNavigationInternal.h"
+#import "WKPDFConfiguration.h"
 #import "WKPreferencesInternal.h"
 #import "WKProcessPoolInternal.h"
 #import "WKSafeBrowsingWarning.h"
@@ -4664,6 +4665,32 @@
     return _resolutionForShareSheetImmediateCompletionForTesting;
 }
 
+- (void)createPDFWithConfiguration:(WKPDFConfiguration *)pdfConfiguration completionHandler:(void (^)(NSData *pdfDocumentData, NSError *error))completionHandler
+{
+    WebCore::FrameIdentifier frameID;
+    if (auto mainFrame = _page->mainFrame())
+        frameID = mainFrame->frameID();
+    else {
+        completionHandler(nil, createNSError(WKErrorUnknown).get());
+        return;
+    }
+
+    Optional<WebCore::FloatRect> floatRect;
+    if (pdfConfiguration && !CGRectIsNull(pdfConfiguration.rect))
+        floatRect = WebCore::FloatRect(pdfConfiguration.rect);
+
+    auto handler = makeBlockPtr(completionHandler);
+    _page->drawToPDF(frameID, floatRect, [retainedSelf = retainPtr(self), handler = WTFMove(handler)](const IPC::DataReference& pdfData, WebKit::CallbackBase::Error error) {
+        if (error != WebKit::CallbackBase::Error::None) {
+            handler(nil, createNSError(WKErrorUnknown).get());
+            return;
+        }
+
+        auto data = "" pdfData.data(), pdfData.size()));
+        handler((NSData *)data.get(), nil);
+    });
+}
+
 @end
 
 @implementation WKWebView (WKPrivate)
@@ -5095,28 +5122,13 @@
 
 - (void)_takePDFSnapshotWithConfiguration:(WKSnapshotConfiguration *)snapshotConfiguration completionHandler:(void (^)(NSData *, NSError *))completionHandler
 {
-    WebCore::FrameIdentifier frameID;
-    if (auto mainFrame = _page->mainFrame())
-        frameID = mainFrame->frameID();
-    else {
-        completionHandler(nil, createNSError(WKErrorUnknown).get());
-        return;
+    WKPDFConfiguration *pdfConfiguration = nil;
+    if (snapshotConfiguration) {
+        pdfConfiguration = [[[WKPDFConfiguration alloc] init] autorelease];
+        pdfConfiguration.rect = snapshotConfiguration.rect;
     }
 
-    Optional<WebCore::FloatRect> floatRect;
-    if (snapshotConfiguration && !CGRectIsNull(snapshotConfiguration.rect))
-        floatRect = WebCore::FloatRect(snapshotConfiguration.rect);
-
-    auto handler = makeBlockPtr(completionHandler);
-    _page->drawToPDF(frameID, floatRect, [retainedSelf = retainPtr(self), handler = WTFMove(handler)](const IPC::DataReference& pdfData, WebKit::CallbackBase::Error error) {
-        if (error != WebKit::CallbackBase::Error::None) {
-            handler(nil, createNSError(WKErrorUnknown).get());
-            return;
-        }
-
-        auto data = "" pdfData.data(), pdfData.size()));
-        handler((NSData *)data.get(), nil);
-    });
+    [self createPDFWithConfiguration:pdfConfiguration completionHandler:completionHandler];
 }
 
 #if PLATFORM(MAC)

Modified: trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.h (251552 => 251553)


--- trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.h	2019-10-24 19:27:26 UTC (rev 251552)
+++ trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.h	2019-10-24 19:43:49 UTC (rev 251553)
@@ -29,6 +29,8 @@
 
 #include "FrameLoadState.h"
 #include "NavigationSOAuthorizationSession.h"
+#include <WebCore/FrameIdentifier.h>
+#include <wtf/Deque.h>
 
 namespace IPC {
 class DataReference;

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (251552 => 251553)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2019-10-24 19:27:26 UTC (rev 251552)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2019-10-24 19:43:49 UTC (rev 251553)
@@ -1009,6 +1009,7 @@
 		51D124991E763C01002B2820 /* WKHTTPCookieStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D124841E734AE3002B2820 /* WKHTTPCookieStore.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		51D130541382EAC000351EDD /* SecItemRequestData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D130501382EAC000351EDD /* SecItemRequestData.h */; };
 		51D130561382EAC000351EDD /* SecItemResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D130521382EAC000351EDD /* SecItemResponseData.h */; };
+		51D7E0AD2356555E00A67D3A /* WKPDFConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D7E0AC2356555400A67D3A /* WKPDFConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		51DD9F2816367DA2001578E9 /* NetworkConnectionToWebProcessMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51DD9F2616367DA2001578E9 /* NetworkConnectionToWebProcessMessageReceiver.cpp */; };
 		51DD9F2916367DA2001578E9 /* NetworkConnectionToWebProcessMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 51DD9F2716367DA2001578E9 /* NetworkConnectionToWebProcessMessages.h */; };
 		51E351CB180F2CCC00E53BE9 /* IDBUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E351C9180F2CCC00E53BE9 /* IDBUtilities.h */; };
@@ -3443,6 +3444,8 @@
 		51D130511382EAC000351EDD /* SecItemResponseData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SecItemResponseData.cpp; sourceTree = "<group>"; };
 		51D130521382EAC000351EDD /* SecItemResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecItemResponseData.h; sourceTree = "<group>"; };
 		51D130571382F10500351EDD /* WebProcessProxyMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessProxyMac.mm; sourceTree = "<group>"; };
+		51D7E0AC2356555400A67D3A /* WKPDFConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPDFConfiguration.h; sourceTree = "<group>"; };
+		51D7E0AE2356616300A67D3A /* WKPDFConfiguration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKPDFConfiguration.mm; sourceTree = "<group>"; };
 		51DD9F2616367DA2001578E9 /* NetworkConnectionToWebProcessMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkConnectionToWebProcessMessageReceiver.cpp; path = DerivedSources/WebKit2/NetworkConnectionToWebProcessMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
 		51DD9F2716367DA2001578E9 /* NetworkConnectionToWebProcessMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkConnectionToWebProcessMessages.h; path = DerivedSources/WebKit2/NetworkConnectionToWebProcessMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
 		51E351C8180F2CCC00E53BE9 /* IDBUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBUtilities.cpp; sourceTree = "<group>"; };
@@ -6442,6 +6445,8 @@
 				1ACC50EF1CBC381D003C7D03 /* WKOpenPanelParameters.mm */,
 				1A67CD2D1CBC513F00BFE3EA /* WKOpenPanelParametersInternal.h */,
 				5C26958420042F12005C439B /* WKOpenPanelParametersPrivate.h */,
+				51D7E0AC2356555400A67D3A /* WKPDFConfiguration.h */,
+				51D7E0AE2356616300A67D3A /* WKPDFConfiguration.mm */,
 				1AFDD3161891C94700153970 /* WKPreferences.h */,
 				1AFDD3181891CA1200153970 /* WKPreferences.mm */,
 				1A3C887F18A5ABAE00C4C962 /* WKPreferencesInternal.h */,
@@ -10328,6 +10333,7 @@
 				A5EFD38C16B0E88C00B2F0E8 /* WKPageVisibilityTypes.h in Headers */,
 				A15EEDE61E301CEE000069B0 /* WKPasswordView.h in Headers */,
 				A1798B49222E531D000764BD /* WKPaymentAuthorizationDelegate.h in Headers */,
+				51D7E0AD2356555E00A67D3A /* WKPDFConfiguration.h in Headers */,
 				2D6AB541192B1C4A003A9FD1 /* WKPDFPageNumberIndicator.h in Headers */,
 				A1046EA12079263100F0C5D8 /* WKPDFView.h in Headers */,
 				7C135AA9173B0BCA00586AE2 /* WKPluginInformation.h in Headers */,

Modified: trunk/Tools/ChangeLog (251552 => 251553)


--- trunk/Tools/ChangeLog	2019-10-24 19:27:26 UTC (rev 251552)
+++ trunk/Tools/ChangeLog	2019-10-24 19:43:49 UTC (rev 251553)
@@ -1,3 +1,16 @@
+2019-10-24  Brady Eidson  <beid...@apple.com>
+
+        Formalize PDF snapshot API.
+        https://bugs.webkit.org/show_bug.cgi?id=203374
+
+        Reviewed by Tim Horton.
+
+        * MiniBrowser/mac/WK2BrowserWindowController.m:
+        (-[WK2BrowserWindowController saveAsPDF:]):
+
+        * TestWebKitAPI/Tests/WebKitCocoa/PDFSnapshot.mm:
+        (TestWebKitAPI::TEST):
+
 2019-10-24  Andy Estes  <aes...@apple.com>
 
         [Cocoa] Make it possible to convert SharedBuffer segments and data views to NSData without copying

Modified: trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m (251552 => 251553)


--- trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m	2019-10-24 19:27:26 UTC (rev 251552)
+++ trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m	2019-10-24 19:43:49 UTC (rev 251553)
@@ -823,7 +823,7 @@
     panel.allowedFileTypes = @[ @"pdf" ];
     [panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
         if (result == NSModalResponseOK) {
-            [_webView _takePDFSnapshotWithConfiguration:nil completionHandler:^(NSData *pdfSnapshotData, NSError *error) {
+            [_webView createPDFWithConfiguration:nil completionHandler:^(NSData *pdfSnapshotData, NSError *error) {
                 [pdfSnapshotData writeToURL:[panel URL] options:0 error:nil];
             }];
         }

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PDFSnapshot.mm (251552 => 251553)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PDFSnapshot.mm	2019-10-24 19:27:26 UTC (rev 251552)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PDFSnapshot.mm	2019-10-24 19:43:49 UTC (rev 251553)
@@ -32,6 +32,7 @@
 #import "TestPDFDocument.h"
 #import "TestWKWebView.h"
 #import <WebCore/Color.h>
+#import <WebKit/WKPDFConfiguration.h>
 #import <WebKit/WKWebViewPrivate.h>
 
 using WebCore::Color;
@@ -46,7 +47,7 @@
 
     [webView synchronouslyLoadHTMLString:@"<meta name='viewport' content='width=device-width'><body bgcolor=#00ff00>Hello</body>"];
 
-    [webView _takePDFSnapshotWithConfiguration:nil completionHandler:^(NSData *pdfSnapshotData, NSError *error) {
+    [webView createPDFWithConfiguration:nil completionHandler:^(NSData *pdfSnapshotData, NSError *error) {
         EXPECT_NULL(error);
         auto document = TestPDFDocument::createFromData(pdfSnapshotData);
         EXPECT_EQ(document->pageCount(), 1u);
@@ -76,11 +77,10 @@
     [webView synchronouslyLoadHTMLString:@"<meta name='viewport' content='width=device-width'><body bgcolor=#00ff00>Hello</body>"];
 
     // Snapshot a subregion contained entirely within the view
-    auto snapshotConfiguration = adoptNS([[WKSnapshotConfiguration alloc] init]);
-    [snapshotConfiguration setRect:NSMakeRect(200, 150, 400, 300)];
-    [snapshotConfiguration setSnapshotWidth:@400];
+    auto configuration = adoptNS([[WKPDFConfiguration alloc] init]);
+    [configuration setRect:NSMakeRect(200, 150, 400, 300)];
 
-    [webView _takePDFSnapshotWithConfiguration:snapshotConfiguration.get() completionHandler:^(NSData *pdfSnapshotData, NSError *error) {
+    [webView createPDFWithConfiguration:configuration.get() completionHandler:^(NSData *pdfSnapshotData, NSError *error) {
         EXPECT_NULL(error);
         auto document = TestPDFDocument::createFromData(pdfSnapshotData);
         EXPECT_EQ(document->pageCount(), 1u);
@@ -100,10 +100,9 @@
     didTakeSnapshot = false;
 
     // Snapshot a region larger than the view
-    [snapshotConfiguration setRect:NSMakeRect(0, 0, 1200, 1200)];
-    [snapshotConfiguration setSnapshotWidth:@1200];
+    [configuration setRect:NSMakeRect(0, 0, 1200, 1200)];
 
-    [webView _takePDFSnapshotWithConfiguration:snapshotConfiguration.get() completionHandler:^(NSData *pdfSnapshotData, NSError *error) {
+    [webView createPDFWithConfiguration:configuration.get() completionHandler:^(NSData *pdfSnapshotData, NSError *error) {
         EXPECT_NULL(error);
         auto document = TestPDFDocument::createFromData(pdfSnapshotData);
         EXPECT_EQ(document->pageCount(), 1u);
@@ -133,7 +132,7 @@
 
     [webView synchronouslyLoadHTMLString:@"<meta name='viewport' content='width=device-width'><body bgcolor=#00ff00>Hello</body>"];
 
-    [webView _takePDFSnapshotWithConfiguration:nil completionHandler:^(NSData *pdfSnapshotData, NSError *error) {
+    [webView createPDFWithConfiguration:nil completionHandler:^(NSData *pdfSnapshotData, NSError *error) {
         EXPECT_NULL(error);
         auto document = TestPDFDocument::createFromData(pdfSnapshotData);
         EXPECT_EQ(document->pageCount(), 3u);
@@ -170,7 +169,7 @@
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 15000)]);
     [webView synchronouslyLoadHTMLString:@"<meta name='viewport' content='width=device-width'><div style=\"-webkit-line-box-contain: glyphs\"><a href="" me</a></div>"];
 
-    [webView _takePDFSnapshotWithConfiguration:nil completionHandler:^(NSData *pdfSnapshotData, NSError *error) {
+    [webView createPDFWithConfiguration:nil completionHandler:^(NSData *pdfSnapshotData, NSError *error) {
         EXPECT_NULL(error);
         auto document = TestPDFDocument::createFromData(pdfSnapshotData);
         EXPECT_EQ(document->pageCount(), 2u);
@@ -211,7 +210,7 @@
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
     [webView synchronouslyLoadHTMLString:@"<meta name='viewport' content='width=device-width'><a href="" me</a>"];
 
-    [webView _takePDFSnapshotWithConfiguration:nil completionHandler:^(NSData *pdfSnapshotData, NSError *error) {
+    [webView createPDFWithConfiguration:nil completionHandler:^(NSData *pdfSnapshotData, NSError *error) {
         EXPECT_NULL(error);
         auto document = TestPDFDocument::createFromData(pdfSnapshotData);
         EXPECT_EQ(document->pageCount(), 1u);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to