Add SPI to give injected bundles access to displayed PDFDocuments
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Apr 2019 02:04:30 +0000 (02:04 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Apr 2019 02:04:30 +0000 (02:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196471
<rdar://problem/48080768>

Patch by Remy Demarest <rdemarest@apple.com> on 2019-04-01
Reviewed by Tim Horton.

* WebKit.xcodeproj/project.pbxproj:

* WebProcess/InjectedBundle/API/c/mac/WKBundlePageMac.h: Added.
* WebProcess/InjectedBundle/API/c/mac/WKBundlePageMac.mm: Added.
(WKBundlePageGetPDFDocumentInFrame):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243731 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/InjectedBundle/API/c/mac/WKBundlePageMac.h [new file with mode: 0644]
Source/WebKit/WebProcess/InjectedBundle/API/c/mac/WKBundlePageMac.mm [new file with mode: 0644]

index 644593e..3a4eb6b 100644 (file)
@@ -1,3 +1,17 @@
+2019-04-01  Remy Demarest  <rdemarest@apple.com>
+
+        Add SPI to give injected bundles access to displayed PDFDocuments
+        https://bugs.webkit.org/show_bug.cgi?id=196471
+        <rdar://problem/48080768>
+
+        Reviewed by Tim Horton.
+
+        * WebKit.xcodeproj/project.pbxproj:
+
+        * WebProcess/InjectedBundle/API/c/mac/WKBundlePageMac.h: Added.
+        * WebProcess/InjectedBundle/API/c/mac/WKBundlePageMac.mm: Added.
+        (WKBundlePageGetPDFDocumentInFrame):
+
 2019-04-01  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [WebKit2] Introduce a public version of WKWebsitePolicies
index f6fdfd6..7f5ffda 100644 (file)
                C5E1AFED16B21017006CC1F2 /* APIWebArchive.h in Headers */ = {isa = PBXBuildFile; fileRef = BC329D9A16ACCE9900316DE2 /* APIWebArchive.h */; };
                C5E1AFEF16B21029006CC1F2 /* APIWebArchiveResource.h in Headers */ = {isa = PBXBuildFile; fileRef = BC329D9F16ACD47800316DE2 /* APIWebArchiveResource.h */; };
                C5FA1ED318E1062200B3F402 /* WKAirPlayRoutePicker.h in Headers */ = {isa = PBXBuildFile; fileRef = C5FA1ED118E1062200B3F402 /* WKAirPlayRoutePicker.h */; };
+               C6A4CA0B2252899800169289 /* WKBundlePageMac.h in Headers */ = {isa = PBXBuildFile; fileRef = C6A4CA092252899800169289 /* WKBundlePageMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               C6A4CA0C2252899800169289 /* WKBundlePageMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6A4CA0A2252899800169289 /* WKBundlePageMac.mm */; };
                C98C48A61B6FD4C300145103 /* WebMediaSessionFocusManager.h in Headers */ = {isa = PBXBuildFile; fileRef = C98C48A41B6FD4C300145103 /* WebMediaSessionFocusManager.h */; };
                C98C48AA1B6FD5B500145103 /* WKMediaSessionFocusManager.h in Headers */ = {isa = PBXBuildFile; fileRef = C98C48A81B6FD5B500145103 /* WKMediaSessionFocusManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C9C1833C1B74026D007036A7 /* WebMediaSessionFocusManagerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = C9C183381B73FD6A007036A7 /* WebMediaSessionFocusManagerClient.h */; };
                C5BCE5DB1C50761D00CDE3FA /* InteractionInformationAtPosition.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = InteractionInformationAtPosition.mm; path = ios/InteractionInformationAtPosition.mm; sourceTree = "<group>"; };
                C5FA1ED118E1062200B3F402 /* WKAirPlayRoutePicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKAirPlayRoutePicker.h; path = ios/forms/WKAirPlayRoutePicker.h; sourceTree = "<group>"; };
                C5FA1ED218E1062200B3F402 /* WKAirPlayRoutePicker.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKAirPlayRoutePicker.mm; path = ios/forms/WKAirPlayRoutePicker.mm; sourceTree = "<group>"; };
+               C6A4CA092252899800169289 /* WKBundlePageMac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKBundlePageMac.h; sourceTree = "<group>"; };
+               C6A4CA0A2252899800169289 /* WKBundlePageMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKBundlePageMac.mm; sourceTree = "<group>"; };
                C98C48A31B6FD4C300145103 /* WebMediaSessionFocusManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebMediaSessionFocusManager.cpp; sourceTree = "<group>"; };
                C98C48A41B6FD4C300145103 /* WebMediaSessionFocusManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebMediaSessionFocusManager.h; sourceTree = "<group>"; };
                C98C48A71B6FD5B500145103 /* WKMediaSessionFocusManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKMediaSessionFocusManager.cpp; sourceTree = "<group>"; };
                        children = (
                                1A8B66B21BC45B010082DF77 /* WKBundleMac.h */,
                                1A8B66B11BC45B010082DF77 /* WKBundleMac.mm */,
+                               C6A4CA092252899800169289 /* WKBundlePageMac.h */,
+                               C6A4CA0A2252899800169289 /* WKBundlePageMac.mm */,
                                7CF47FFD17276AE3008ACB91 /* WKBundlePageBannerMac.h */,
                                7CF47FFC17276AE3008ACB91 /* WKBundlePageBannerMac.mm */,
                        );
                                1AB474DE184D44590051B622 /* WKBundlePageUIClient.h in Headers */,
                                BCF049E711FE20F600F86A58 /* WKBundlePrivate.h in Headers */,
                                BC60C5791240A546008C5E29 /* WKBundleRangeHandle.h in Headers */,
+                               C6A4CA0B2252899800169289 /* WKBundlePageMac.h in Headers */,
                                BC5D24C716CD73C5007D5461 /* WKBundleRangeHandlePrivate.h in Headers */,
                                BC14DF9F120B635F00826C0C /* WKBundleScriptWorld.h in Headers */,
                                BC4075F6124FF0270068F20A /* WKCertificateInfo.h in Headers */,
                                2D11B7A72126A283006F8878 /* UnifiedSource44-mm.mm in Sources */,
                                2D11B7A82126A283006F8878 /* UnifiedSource44.cpp in Sources */,
                                2D11B7A92126A283006F8878 /* UnifiedSource45-mm.mm in Sources */,
+                               C6A4CA0C2252899800169289 /* WKBundlePageMac.mm in Sources */,
                                2D11B7AA2126A283006F8878 /* UnifiedSource45.cpp in Sources */,
                                2D11B7AB2126A283006F8878 /* UnifiedSource46-mm.mm in Sources */,
                                2D11B7AC2126A283006F8878 /* UnifiedSource46.cpp in Sources */,
diff --git a/Source/WebKit/WebProcess/InjectedBundle/API/c/mac/WKBundlePageMac.h b/Source/WebKit/WebProcess/InjectedBundle/API/c/mac/WKBundlePageMac.h
new file mode 100644 (file)
index 0000000..c2ba9fe
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#ifdef __OBJC__
+
+#include <WebKit/WKBase.h>
+#include <WebKit/WKBundlePage.h>
+
+@class PDFDocument;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT PDFDocument *WKBundlePageGetPDFDocumentInFrame(WKBundlePageRef page, WKBundleFrameRef frame);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __OBJC__
diff --git a/Source/WebKit/WebProcess/InjectedBundle/API/c/mac/WKBundlePageMac.mm b/Source/WebKit/WebProcess/InjectedBundle/API/c/mac/WKBundlePageMac.mm
new file mode 100644 (file)
index 0000000..0df2f56
--- /dev/null
@@ -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 "WKBundlePageMac.h"
+
+#import "PluginView.h"
+#import "WKBundleAPICast.h"
+#import "WKBundleFrame.h"
+#import "WKBundlePage.h"
+#import "WKRetainPtr.h"
+#import "WebFrame.h"
+#import "WebPage.h"
+#import <WebCore/Frame.h>
+
+WK_EXPORT PDFDocument *WKBundlePageGetPDFDocumentInFrame(WKBundlePageRef page, WKBundleFrameRef frame)
+{
+    WebCore::Frame* coreFrame = WebKit::toImpl(frame)->coreFrame();
+    if (!coreFrame)
+        return nil;
+
+    WebKit::PluginView* pluginView = WebKit::toImpl(page)->pluginViewForFrame(coreFrame);
+    if (!pluginView)
+        return nil;
+
+    return pluginView->pdfDocumentForPrinting().autorelease();
+}