Create Swift overlay for WebKit framework
authorjames.savage@apple.com <james.savage@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 23 May 2020 00:52:00 +0000 (00:52 +0000)
committerjames.savage@apple.com <james.savage@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 23 May 2020 00:52:00 +0000 (00:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=211270
<rdar://problem/60549174>

Reviewed by Brady Eidson.

Provides Swift-only overlay methods for our NS_REFINED_FOR_SWIFT API.
The overlay does not provide different API than its Objective-C counterparts,
so overlay testing focuses on ensuring that the overlay produces the
expected interface, and provides the expected mappings to and from ObjC.

The overlay is defined in a separate Xcode project (from WebKit) by
recommendation from the Swift team. Due to build system constraints this
project cannot be a sibbling of WebKit.xcodeproj, and must live in a
subdirectory. However, because it generally acts as part of the WebKit
framework, it still uses the same Version.xcconfig and source file
locations as standard WebKit sources.

* SwiftOverlay/Configurations/Base.xcconfig: Added. Set some default
    warnings and product configuration.
* SwiftOverlay/Configurations/WebKitSwiftOverlay-maccatalyst.xcconfig: Added.
    Override SDK configurations to build for Catalyst.
* SwiftOverlay/Configurations/WebKitSwiftOverlay.xcconfig: Added.
    These flags were all provided by the Xcode template.
* SwiftOverlay/Configurations/WebKitSwiftOverlayTests-maccatalyst.xcconfig: Added.
    See above.
* SwiftOverlay/Configurations/WebKitSwiftOverlayTests.xcconfig: Added.
    See above.
* SwiftOverlay/SwiftOverlay/install-swiftmodules.sh: Added. Provided by the
    Swift team.
* SwiftOverlay/Tests/WebKitSwiftOverlayTests-Info.plist: Added.
* SwiftOverlay/Tests/WebKitTests.swift: Added.
(WebKitTests.testAPI): This ensures that the function names come through as we
    expect them to. It also ensures that the functions were correctly set to
    public visiblity.
(WebKitTests.testWKPDFConfigurationRect): This does the same as the above, but
    also exercises the null <-> nil conversion, and that regular values are
    correctly round tripped to Objective-C.
* SwiftOverlay/WebKitSwiftOverlay.xcodeproj/project.pbxproj: Added.
* SwiftOverlay/WebKitSwiftOverlay.xcodeproj/xcshareddata/xcschemes/Everything (Catalyst).xcscheme: Added.
* SwiftOverlay/WebKitSwiftOverlay.xcodeproj/xcshareddata/xcschemes/Everything.xcscheme: Added.
* UIProcess/API/Cocoa/WebKitSwiftOverlay.swift: Added.
(WKPDFConfiguration.rect): Provide mapping of CGRect.null to nil for Swift.
(WKWebView.callAsyncJavaScript(_:arguments:in:completion:)): Provide a Result
in the completion handler, and default value for arguments.
(WKWebView.evaluateJavaScript(_:in:completion:)): Ditto.
(WKWebView.createPDF(configuration:completionHandler:)): Provide a Swift function
    that takes a Result<Data, Error> instead of (Data?, Error?) tuple. Provide
    a default value for the configuration.
(WKWebView.createWebArchiveData(completionHandler:)): See above.
(WKWebView.find(_:configuration:completionHandler:)): See above.

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

13 files changed:
Source/WebKit/ChangeLog
Source/WebKit/SwiftOverlay/Configurations/Base.xcconfig [new file with mode: 0644]
Source/WebKit/SwiftOverlay/Configurations/WebKitSwiftOverlay-maccatalyst.xcconfig [new file with mode: 0644]
Source/WebKit/SwiftOverlay/Configurations/WebKitSwiftOverlay.xcconfig [new file with mode: 0644]
Source/WebKit/SwiftOverlay/Configurations/WebKitSwiftOverlayTests-maccatalyst.xcconfig [new file with mode: 0644]
Source/WebKit/SwiftOverlay/Configurations/WebKitSwiftOverlayTests.xcconfig [new file with mode: 0644]
Source/WebKit/SwiftOverlay/SwiftOverlay/install-swiftmodules.sh [new file with mode: 0755]
Source/WebKit/SwiftOverlay/Tests/WebKitSwiftOverlayTests-Info.plist [new file with mode: 0644]
Source/WebKit/SwiftOverlay/Tests/WebKitTests.swift [new file with mode: 0644]
Source/WebKit/SwiftOverlay/WebKitSwiftOverlay.xcodeproj/project.pbxproj [new file with mode: 0644]
Source/WebKit/SwiftOverlay/WebKitSwiftOverlay.xcodeproj/xcshareddata/xcschemes/Everything (Catalyst).xcscheme [new file with mode: 0644]
Source/WebKit/SwiftOverlay/WebKitSwiftOverlay.xcodeproj/xcshareddata/xcschemes/Everything.xcscheme [new file with mode: 0644]
Source/WebKit/UIProcess/API/Cocoa/WebKitSwiftOverlay.swift [new file with mode: 0644]

index 72c4c5b..e6056bf 100644 (file)
@@ -1,3 +1,57 @@
+2020-05-22  James Savage  <james.savage@apple.com>
+
+        Create Swift overlay for WebKit framework
+        https://bugs.webkit.org/show_bug.cgi?id=211270
+        <rdar://problem/60549174>
+
+        Reviewed by Brady Eidson.
+
+        Provides Swift-only overlay methods for our NS_REFINED_FOR_SWIFT API.
+        The overlay does not provide different API than its Objective-C counterparts,
+        so overlay testing focuses on ensuring that the overlay produces the
+        expected interface, and provides the expected mappings to and from ObjC.
+
+        The overlay is defined in a separate Xcode project (from WebKit) by
+        recommendation from the Swift team. Due to build system constraints this
+        project cannot be a sibbling of WebKit.xcodeproj, and must live in a
+        subdirectory. However, because it generally acts as part of the WebKit
+        framework, it still uses the same Version.xcconfig and source file
+        locations as standard WebKit sources.
+
+        * SwiftOverlay/Configurations/Base.xcconfig: Added. Set some default
+            warnings and product configuration.
+        * SwiftOverlay/Configurations/WebKitSwiftOverlay-maccatalyst.xcconfig: Added.
+            Override SDK configurations to build for Catalyst.
+        * SwiftOverlay/Configurations/WebKitSwiftOverlay.xcconfig: Added.
+            These flags were all provided by the Xcode template.
+        * SwiftOverlay/Configurations/WebKitSwiftOverlayTests-maccatalyst.xcconfig: Added.
+            See above.
+        * SwiftOverlay/Configurations/WebKitSwiftOverlayTests.xcconfig: Added.
+            See above.
+        * SwiftOverlay/SwiftOverlay/install-swiftmodules.sh: Added. Provided by the
+            Swift team.
+        * SwiftOverlay/Tests/WebKitSwiftOverlayTests-Info.plist: Added.
+        * SwiftOverlay/Tests/WebKitTests.swift: Added.
+        (WebKitTests.testAPI): This ensures that the function names come through as we
+            expect them to. It also ensures that the functions were correctly set to
+            public visiblity.
+        (WebKitTests.testWKPDFConfigurationRect): This does the same as the above, but
+            also exercises the null <-> nil conversion, and that regular values are
+            correctly round tripped to Objective-C.
+        * SwiftOverlay/WebKitSwiftOverlay.xcodeproj/project.pbxproj: Added.
+        * SwiftOverlay/WebKitSwiftOverlay.xcodeproj/xcshareddata/xcschemes/Everything (Catalyst).xcscheme: Added.
+        * SwiftOverlay/WebKitSwiftOverlay.xcodeproj/xcshareddata/xcschemes/Everything.xcscheme: Added.
+        * UIProcess/API/Cocoa/WebKitSwiftOverlay.swift: Added.
+        (WKPDFConfiguration.rect): Provide mapping of CGRect.null to nil for Swift.
+        (WKWebView.callAsyncJavaScript(_:arguments:in:completion:)): Provide a Result
+        in the completion handler, and default value for arguments.
+        (WKWebView.evaluateJavaScript(_:in:completion:)): Ditto.
+        (WKWebView.createPDF(configuration:completionHandler:)): Provide a Swift function
+            that takes a Result<Data, Error> instead of (Data?, Error?) tuple. Provide
+            a default value for the configuration.
+        (WKWebView.createWebArchiveData(completionHandler:)): See above.
+        (WKWebView.find(_:configuration:completionHandler:)): See above.
+
 2020-05-22  Chris Dumez  <cdumez@apple.com>
 
         RELEASE_ASSERT() that InitializeWebKit2() is getting called on the main thread
diff --git a/Source/WebKit/SwiftOverlay/Configurations/Base.xcconfig b/Source/WebKit/SwiftOverlay/Configurations/Base.xcconfig
new file mode 100644 (file)
index 0000000..0800fdd
--- /dev/null
@@ -0,0 +1,48 @@
+// Copyright (C) 2020 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. ``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
+// 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.
+
+#include "../Configurations/SDKVariant.xcconfig"
+#include "../Configurations/Version.xcconfig"
+
+ALWAYS_SEARCH_USER_PATHS = NO;
+CLANG_ENABLE_MODULES = YES;
+CLANG_ENABLE_OBJC_ARC = YES;
+CLANG_ENABLE_OBJC_WEAK = YES;
+ENABLE_TESTABILITY[config=Debug] = YES;
+ONLY_ACTIVE_ARCH[config=Debug] = YES;
+SWIFT_COMPILATION_MODE[config=Release] = wholemodule;
+SWIFT_VERSION = 5.0;
+
+SWIFT_OPTIMIZATION_LEVEL[config=Debug] = -Onone;
+SWIFT_OPTIMIZATION_LEVEL[config=Release] = -O;
+
+DEBUG_INFORMATION_FORMAT[config=Debug] = dwarf;
+DEBUG_INFORMATION_FORMAT[config=Release] = dwarf-with-dsym;
+
+ONLY_ACTIVE_ARCH[config=Debug] = YES;
+ONLY_ACTIVE_ARCH[config=Release] = NO;
+
+SDKROOT = macosx.internal;
+SDKROOT[sdk=iphoneos*] = iphoneos.internal;
+SDKROOT[sdk=appletv*] = appletvos.internal;
+SDKROOT[sdk=watchos*] = watchos.internal;
diff --git a/Source/WebKit/SwiftOverlay/Configurations/WebKitSwiftOverlay-maccatalyst.xcconfig b/Source/WebKit/SwiftOverlay/Configurations/WebKitSwiftOverlay-maccatalyst.xcconfig
new file mode 100644 (file)
index 0000000..853274b
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright (C) 2020 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. ``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
+// 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.
+
+#include "WebKitSwiftOverlay.xcconfig"
+
+SDK_VARIANT[sdk=mac*] = iosmac;
+SUPPORTED_PLATFORMS = macosx;
diff --git a/Source/WebKit/SwiftOverlay/Configurations/WebKitSwiftOverlay.xcconfig b/Source/WebKit/SwiftOverlay/Configurations/WebKitSwiftOverlay.xcconfig
new file mode 100644 (file)
index 0000000..91a4138
--- /dev/null
@@ -0,0 +1,60 @@
+// Copyright (C) 2020 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. ``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
+// 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.
+
+BUILD_LIBRARY_FOR_DISTRIBUTION = YES;
+CLANG_LINK_OBJC_RUNTIME = NO;
+EXECUTABLE_PREFIX = libswift;
+GENERATE_TEXT_BASED_STUBS = YES;
+IS_ZIPPERED = NO;
+OTHER_LDFLAGS = $(inherited) -weak_framework WebKit;
+PRODUCT_NAME = WebKit;
+STRIP_SWIFT_SYMBOLS = NO;
+SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator;
+SUPPORTS_TEXT_BASED_API = YES;
+SWIFT_IS_OVERLAY = YES;
+SWIFT_LINK_OBJC_RUNTIME = NO;
+SWIFT_OVERLAY_INSTALL_PATH=/usr/lib/swift;
+
+DYLIB_CURRENT_VERSION = $(FULL_VERSION);
+MODULE_VERSION = $(FULL_VERSION);
+
+// Disable code signing
+COPY_PHASE_STRIP = NO;
+CODE_SIGN_IDENTITY = -;
+CODE_SIGN_STYLE = Manual;
+
+// We need to run install-swiftmodules.sh during the installapi action.
+INSTALLHDRS_SCRIPT_PHASE = YES;
+
+// The install path is /usr/lib/swift except if we're building using the iosmac
+// SDK variant on macOS, in which case it's /System/iOSSupport/usr/lib/swift.
+INSTALL_PATH = $(WK_ALTERNATE_FRAMEWORKS_DIR)$(SWIFT_OVERLAY_INSTALL_PATH);
+
+OTHER_SWIFT_FLAGS = -module-link-name $(SWIFT_MODULE_LINK_NAME) -autolink-force-load -runtime-compatibility-version none -disable-autolinking-runtime-compatibility-dynamic-replacements;
+SWIFT_MODULE_LINK_NAME = swift$(PRODUCT_NAME);
+
+SWIFT_ENABLE_INCREMENTAL_COMPILATION = NO; // YES conflicts with -autolink-force-load
+
+// Custom build settings for install-swiftmodules.sh.
+SWIFT_INSTALL_MODULES = YES;
+SWIFT_MODULE_INSTALL_PATH = $(INSTALL_PATH);
diff --git a/Source/WebKit/SwiftOverlay/Configurations/WebKitSwiftOverlayTests-maccatalyst.xcconfig b/Source/WebKit/SwiftOverlay/Configurations/WebKitSwiftOverlayTests-maccatalyst.xcconfig
new file mode 100644 (file)
index 0000000..4de9f91
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright (C) 2020 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. ``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
+// 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.
+
+#include "WebKitSwiftOverlayTests.xcconfig"
+
+SDK_VARIANT[sdk=mac*] = iosmac;
+SUPPORTED_PLATFORMS = macosx;
+TARGETED_DEVICE_FAMILY[sdk=mac*] = 2;
+
diff --git a/Source/WebKit/SwiftOverlay/Configurations/WebKitSwiftOverlayTests.xcconfig b/Source/WebKit/SwiftOverlay/Configurations/WebKitSwiftOverlayTests.xcconfig
new file mode 100644 (file)
index 0000000..0a51754
--- /dev/null
@@ -0,0 +1,46 @@
+// Copyright (C) 2020 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. ``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
+// 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.
+
+ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
+CLANG_CXX_LANGUAGE_STANDARD = gnu++14;
+CLANG_CXX_LIBRARY = libc++;
+CODE_SIGN_STYLE = Automatic;
+COPY_PHASE_STRIP = NO;
+ENABLE_NS_ASSERTIONS = NO;
+ENABLE_STRICT_OBJC_MSGSEND = YES;
+GCC_C_LANGUAGE_STANDARD = gnu11;
+GCC_DYNAMIC_NO_PIC = NO;
+GCC_NO_COMMON_BLOCKS = YES;
+GCC_OPTIMIZATION_LEVEL = 0;
+GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1 $(inherited);
+INFOPLIST_FILE = Tests/WebKitSwiftOverlayTests-Info.plist;
+PRODUCT_BUNDLE_IDENTIFIER = com.apple.WebKitTests-macOS;
+PRODUCT_NAME = $(TARGET_NAME);
+SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator;
+SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=Debug] = DEBUG;
+SWIFT_COMPILATION_MODE = wholemodule;
+
+SDKROOT = macosx.internal
+SDKROOT[sdk=iphoneos*] = iphoneos.internal
+SDKROOT[sdk=appletv*] = appletvos.internal
+SDKROOT[sdk=watchos*] = watchos.internal
diff --git a/Source/WebKit/SwiftOverlay/SwiftOverlay/install-swiftmodules.sh b/Source/WebKit/SwiftOverlay/SwiftOverlay/install-swiftmodules.sh
new file mode 100755 (executable)
index 0000000..7dfbc7a
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+# Copyright (C) 2020 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. ``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
+# 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.
+
+set -e
+#set -xv
+
+# This only needs to run during installation, but that includes "installapi".
+[ "$ACTION" = "installapi" -o "$ACTION" = "install" ] || exit 0
+
+[ "$SKIP_INSTALL" != "YES" ] || exit 0
+[ "$SWIFT_INSTALL_MODULES" = "YES" ] || exit 0
+
+srcmodule="${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.swiftmodule"
+dstpath="${INSTALL_ROOT}/${INSTALL_PATH}/"
+
+if [ ! -d "$srcmodule" ]; then
+    echo "Cannot find Swift module at $srcmodule" >&2
+    exit 1
+fi
+
+mkdir -p "$dstpath"
+cp -r "$srcmodule" "$dstpath"
diff --git a/Source/WebKit/SwiftOverlay/Tests/WebKitSwiftOverlayTests-Info.plist b/Source/WebKit/SwiftOverlay/Tests/WebKitSwiftOverlayTests-Info.plist
new file mode 100644 (file)
index 0000000..64d65ca
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>CFBundleDevelopmentRegion</key>
+       <string>$(DEVELOPMENT_LANGUAGE)</string>
+       <key>CFBundleExecutable</key>
+       <string>$(EXECUTABLE_NAME)</string>
+       <key>CFBundleIdentifier</key>
+       <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+       <key>CFBundleInfoDictionaryVersion</key>
+       <string>6.0</string>
+       <key>CFBundleName</key>
+       <string>$(PRODUCT_NAME)</string>
+       <key>CFBundlePackageType</key>
+       <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
+       <key>CFBundleShortVersionString</key>
+       <string>1.0</string>
+       <key>CFBundleVersion</key>
+       <string>1</string>
+</dict>
+</plist>
diff --git a/Source/WebKit/SwiftOverlay/Tests/WebKitTests.swift b/Source/WebKit/SwiftOverlay/Tests/WebKitTests.swift
new file mode 100644 (file)
index 0000000..777bbb2
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2020 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 XCTest
+import WebKit
+
+class WebKitTests: XCTestCase {
+    /// This is a compile-time test that ensures the function names are what we expect.
+    func testAPI() {
+        _ = WKContentWorld.world(name:)
+        _ = WKWebView.callAsyncJavaScript(_:arguments:in:completion:)
+        _ = WKWebView.createPDF(configuration:completionHandler:)
+        _ = WKWebView.createWebArchiveData(completionHandler:)
+        _ = WKWebView.evaluateJavaScript(_:in:completion:)
+        _ = WKWebView.find(_:configuration:completionHandler:)
+    }
+
+    func testWKPDFConfigurationRect() {
+        let configuration = WKPDFConfiguration()
+
+        XCTAssert(type(of: configuration.rect) == Optional<CGRect>.self)
+
+        configuration.rect = nil
+        XCTAssertEqual(configuration.rect, nil)
+
+        configuration.rect = .null
+        XCTAssertEqual(configuration.rect, nil)
+
+        configuration.rect = CGRect.zero
+        XCTAssertEqual(configuration.rect, .zero)
+
+        let originalPhoneBounds = CGRect(x: 0, y: 0, width: 320, height: 480)
+        configuration.rect = originalPhoneBounds
+        XCTAssertEqual(configuration.rect, originalPhoneBounds)
+    }
+}
diff --git a/Source/WebKit/SwiftOverlay/WebKitSwiftOverlay.xcodeproj/project.pbxproj b/Source/WebKit/SwiftOverlay/WebKitSwiftOverlay.xcodeproj/project.pbxproj
new file mode 100644 (file)
index 0000000..5201756
--- /dev/null
@@ -0,0 +1,512 @@
+// !$*UTF8*$!
+{
+       archiveVersion = 1;
+       classes = {
+       };
+       objectVersion = 50;
+       objects = {
+
+/* Begin PBXBuildFile section */
+               7D20070C22F4EB72008DF640 /* libswiftWebKit.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D20067522F2652E008DF640 /* libswiftWebKit.dylib */; };
+               7D20071B22F4ECCA008DF640 /* libswiftWebKit.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D20068722F26721008DF640 /* libswiftWebKit.dylib */; };
+               B3A5D38F23F78F5400B17727 /* WebKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3A5D38823F78F5400B17727 /* WebKitTests.swift */; };
+               B3A5D39023F78F5400B17727 /* WebKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3A5D38823F78F5400B17727 /* WebKitTests.swift */; };
+               B3A5D39223F790DB00B17727 /* WebKitSwiftOverlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3A5D39123F790DB00B17727 /* WebKitSwiftOverlay.swift */; };
+               B3A5D39323F790DB00B17727 /* WebKitSwiftOverlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3A5D39123F790DB00B17727 /* WebKitSwiftOverlay.swift */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXContainerItemProxy section */
+               7D20070D22F4EB72008DF640 /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 7D81A8D522E936E700739BB9 /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = 7D20067422F2652E008DF640;
+                       remoteInfo = "WebKit-macOS";
+               };
+               7D20071C22F4ECCA008DF640 /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 7D81A8D522E936E700739BB9 /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = 7D20068622F26721008DF640;
+                       remoteInfo = "WebKit-iOS";
+               };
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXFileReference section */
+               7D20067522F2652E008DF640 /* libswiftWebKit.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libswiftWebKit.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
+               7D20068722F26721008DF640 /* libswiftWebKit.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libswiftWebKit.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
+               7D20070722F4EB72008DF640 /* WebKitSwiftOverlayTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WebKitSwiftOverlayTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
+               7D20071622F4ECCA008DF640 /* WebKitSwiftOverlayTests-maccatalyst.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "WebKitSwiftOverlayTests-maccatalyst.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
+               B3A5D38823F78F5400B17727 /* WebKitTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebKitTests.swift; sourceTree = "<group>"; };
+               B3A5D39123F790DB00B17727 /* WebKitSwiftOverlay.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WebKitSwiftOverlay.swift; path = ../UIProcess/API/Cocoa/WebKitSwiftOverlay.swift; sourceTree = SOURCE_ROOT; };
+               B3A5D39423F790E100B17727 /* WebKitSwiftOverlay.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = WebKitSwiftOverlay.xcconfig; sourceTree = "<group>"; };
+               B3A5D39523F790E100B17727 /* Base.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; };
+               B3A5D39623F790E100B17727 /* WebKitSwiftOverlay-maccatalyst.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "WebKitSwiftOverlay-maccatalyst.xcconfig"; sourceTree = "<group>"; };
+               B3A5D39723F790E100B17727 /* WebKitSwiftOverlayTests-maccatalyst.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "WebKitSwiftOverlayTests-maccatalyst.xcconfig"; sourceTree = "<group>"; };
+               B3A5D39823F790E100B17727 /* WebKitSwiftOverlayTests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = WebKitSwiftOverlayTests.xcconfig; sourceTree = "<group>"; };
+               B3A5D39923F790E100B17727 /* install-swiftmodules.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "install-swiftmodules.sh"; sourceTree = "<group>"; };
+               B3A5D39A23F790E700B17727 /* WebKitSwiftOverlayTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "WebKitSwiftOverlayTests-Info.plist"; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+               7D20067322F2652E008DF640 /* Frameworks */ = {
+                       isa = PBXFrameworksBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
+               7D20068522F26721008DF640 /* Frameworks */ = {
+                       isa = PBXFrameworksBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
+               7D20070422F4EB72008DF640 /* Frameworks */ = {
+                       isa = PBXFrameworksBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               7D20070C22F4EB72008DF640 /* libswiftWebKit.dylib in Frameworks */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
+               7D20071322F4ECCA008DF640 /* Frameworks */ = {
+                       isa = PBXFrameworksBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               7D20071B22F4ECCA008DF640 /* libswiftWebKit.dylib in Frameworks */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+               7D20067622F2652E008DF640 /* Swift Overlay */ = {
+                       isa = PBXGroup;
+                       children = (
+                               B3A5D39923F790E100B17727 /* install-swiftmodules.sh */,
+                               B3A5D39123F790DB00B17727 /* WebKitSwiftOverlay.swift */,
+                       );
+                       name = "Swift Overlay";
+                       path = SwiftOverlay;
+                       sourceTree = "<group>";
+               };
+               7D2006D622F3D3DA008DF640 /* Frameworks */ = {
+                       isa = PBXGroup;
+                       children = (
+                       );
+                       name = Frameworks;
+                       sourceTree = "<group>";
+               };
+               7D20070822F4EB72008DF640 /* Tests */ = {
+                       isa = PBXGroup;
+                       children = (
+                               B3A5D39A23F790E700B17727 /* WebKitSwiftOverlayTests-Info.plist */,
+                               B3A5D38823F78F5400B17727 /* WebKitTests.swift */,
+                       );
+                       path = Tests;
+                       sourceTree = "<group>";
+               };
+               7D81A8D422E936E700739BB9 = {
+                       isa = PBXGroup;
+                       children = (
+                               7DF02CBE22F4DF1A00C66A76 /* Configurations */,
+                               7D20067622F2652E008DF640 /* Swift Overlay */,
+                               7D20070822F4EB72008DF640 /* Tests */,
+                               7D81A8DE22E936E700739BB9 /* Products */,
+                               7D2006D622F3D3DA008DF640 /* Frameworks */,
+                       );
+                       sourceTree = "<group>";
+               };
+               7D81A8DE22E936E700739BB9 /* Products */ = {
+                       isa = PBXGroup;
+                       children = (
+                               7D20067522F2652E008DF640 /* libswiftWebKit.dylib */,
+                               7D20068722F26721008DF640 /* libswiftWebKit.dylib */,
+                               7D20071622F4ECCA008DF640 /* WebKitSwiftOverlayTests-maccatalyst.xctest */,
+                               7D20070722F4EB72008DF640 /* WebKitSwiftOverlayTests.xctest */,
+                       );
+                       name = Products;
+                       sourceTree = "<group>";
+               };
+               7DF02CBE22F4DF1A00C66A76 /* Configurations */ = {
+                       isa = PBXGroup;
+                       children = (
+                               B3A5D39523F790E100B17727 /* Base.xcconfig */,
+                               B3A5D39623F790E100B17727 /* WebKitSwiftOverlay-maccatalyst.xcconfig */,
+                               B3A5D39423F790E100B17727 /* WebKitSwiftOverlay.xcconfig */,
+                               B3A5D39723F790E100B17727 /* WebKitSwiftOverlayTests-maccatalyst.xcconfig */,
+                               B3A5D39823F790E100B17727 /* WebKitSwiftOverlayTests.xcconfig */,
+                       );
+                       path = Configurations;
+                       sourceTree = "<group>";
+               };
+/* End PBXGroup section */
+
+/* Begin PBXHeadersBuildPhase section */
+               7D20067122F2652E008DF640 /* Headers */ = {
+                       isa = PBXHeadersBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
+               7D20068322F26721008DF640 /* Headers */ = {
+                       isa = PBXHeadersBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
+/* End PBXHeadersBuildPhase section */
+
+/* Begin PBXNativeTarget section */
+               7D20067422F2652E008DF640 /* WebKitSwiftOverlay */ = {
+                       isa = PBXNativeTarget;
+                       buildConfigurationList = 7D20067B22F2652E008DF640 /* Build configuration list for PBXNativeTarget "WebKitSwiftOverlay" */;
+                       buildPhases = (
+                               7D20067122F2652E008DF640 /* Headers */,
+                               7D20067222F2652E008DF640 /* Sources */,
+                               7D20067322F2652E008DF640 /* Frameworks */,
+                               7D20069122F26787008DF640 /* Install Swift Module */,
+                       );
+                       buildRules = (
+                       );
+                       dependencies = (
+                       );
+                       name = WebKitSwiftOverlay;
+                       productName = SafariServices;
+                       productReference = 7D20067522F2652E008DF640 /* libswiftWebKit.dylib */;
+                       productType = "com.apple.product-type.library.dynamic";
+               };
+               7D20068622F26721008DF640 /* WebKitSwiftOverlay-maccatalyst */ = {
+                       isa = PBXNativeTarget;
+                       buildConfigurationList = 7D20068D22F26721008DF640 /* Build configuration list for PBXNativeTarget "WebKitSwiftOverlay-maccatalyst" */;
+                       buildPhases = (
+                               7D20068322F26721008DF640 /* Headers */,
+                               7D20068422F26721008DF640 /* Sources */,
+                               7D20068522F26721008DF640 /* Frameworks */,
+                               7D20069222F2679B008DF640 /* Install Swift Module */,
+                       );
+                       buildRules = (
+                       );
+                       dependencies = (
+                       );
+                       name = "WebKitSwiftOverlay-maccatalyst";
+                       productName = "WebKit-iOS";
+                       productReference = 7D20068722F26721008DF640 /* libswiftWebKit.dylib */;
+                       productType = "com.apple.product-type.library.dynamic";
+               };
+               7D20070622F4EB72008DF640 /* WebKitSwiftOverlayTests */ = {
+                       isa = PBXNativeTarget;
+                       buildConfigurationList = 7D20070F22F4EB72008DF640 /* Build configuration list for PBXNativeTarget "WebKitSwiftOverlayTests" */;
+                       buildPhases = (
+                               7D20070322F4EB72008DF640 /* Sources */,
+                               7D20070422F4EB72008DF640 /* Frameworks */,
+                               7D20070522F4EB72008DF640 /* Resources */,
+                       );
+                       buildRules = (
+                       );
+                       dependencies = (
+                               7D20070E22F4EB72008DF640 /* PBXTargetDependency */,
+                       );
+                       name = WebKitSwiftOverlayTests;
+                       productName = WebKitTests;
+                       productReference = 7D20070722F4EB72008DF640 /* WebKitSwiftOverlayTests.xctest */;
+                       productType = "com.apple.product-type.bundle.unit-test";
+               };
+               7D20071522F4ECCA008DF640 /* WebKitSwiftOverlayTests-maccatalyst */ = {
+                       isa = PBXNativeTarget;
+                       buildConfigurationList = 7D20071E22F4ECCA008DF640 /* Build configuration list for PBXNativeTarget "WebKitSwiftOverlayTests-maccatalyst" */;
+                       buildPhases = (
+                               7D20071222F4ECCA008DF640 /* Sources */,
+                               7D20071322F4ECCA008DF640 /* Frameworks */,
+                               7D20071422F4ECCA008DF640 /* Resources */,
+                       );
+                       buildRules = (
+                       );
+                       dependencies = (
+                               7D20071D22F4ECCA008DF640 /* PBXTargetDependency */,
+                       );
+                       name = "WebKitSwiftOverlayTests-maccatalyst";
+                       productName = "WebKitTests-iOS";
+                       productReference = 7D20071622F4ECCA008DF640 /* WebKitSwiftOverlayTests-maccatalyst.xctest */;
+                       productType = "com.apple.product-type.bundle.unit-test";
+               };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+               7D81A8D522E936E700739BB9 /* Project object */ = {
+                       isa = PBXProject;
+                       attributes = {
+                               LastSwiftUpdateCheck = 1100;
+                               LastUpgradeCheck = 1100;
+                               ORGANIZATIONNAME = Apple;
+                               TargetAttributes = {
+                                       7D20067422F2652E008DF640 = {
+                                               CreatedOnToolsVersion = 11.0;
+                                               LastSwiftMigration = 1200;
+                                       };
+                                       7D20068622F26721008DF640 = {
+                                               CreatedOnToolsVersion = 11.0;
+                                               LastSwiftMigration = 1200;
+                                       };
+                                       7D20070622F4EB72008DF640 = {
+                                               CreatedOnToolsVersion = 11.0;
+                                               LastSwiftMigration = 1200;
+                                       };
+                                       7D20071522F4ECCA008DF640 = {
+                                               CreatedOnToolsVersion = 11.0;
+                                               LastSwiftMigration = 1200;
+                                       };
+                               };
+                       };
+                       buildConfigurationList = 7D81A8D822E936E700739BB9 /* Build configuration list for PBXProject "WebKitSwiftOverlay" */;
+                       compatibilityVersion = "Xcode 9.3";
+                       developmentRegion = en;
+                       hasScannedForEncodings = 0;
+                       knownRegions = (
+                               en,
+                               Base,
+                       );
+                       mainGroup = 7D81A8D422E936E700739BB9;
+                       productRefGroup = 7D81A8DE22E936E700739BB9 /* Products */;
+                       projectDirPath = "";
+                       projectRoot = "";
+                       targets = (
+                               7D20067422F2652E008DF640 /* WebKitSwiftOverlay */,
+                               7D20068622F26721008DF640 /* WebKitSwiftOverlay-maccatalyst */,
+                               7D20070622F4EB72008DF640 /* WebKitSwiftOverlayTests */,
+                               7D20071522F4ECCA008DF640 /* WebKitSwiftOverlayTests-maccatalyst */,
+                       );
+               };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+               7D20070522F4EB72008DF640 /* Resources */ = {
+                       isa = PBXResourcesBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
+               7D20071422F4ECCA008DF640 /* Resources */ = {
+                       isa = PBXResourcesBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXShellScriptBuildPhase section */
+               7D20069122F26787008DF640 /* Install Swift Module */ = {
+                       isa = PBXShellScriptBuildPhase;
+                       buildActionMask = 12;
+                       files = (
+                       );
+                       inputFileListPaths = (
+                       );
+                       inputPaths = (
+                       );
+                       name = "Install Swift Module";
+                       outputFileListPaths = (
+                       );
+                       outputPaths = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+                       shellPath = /bin/sh;
+                       shellScript = "exec \"${SOURCE_ROOT}/SwiftOverlay/install-swiftmodules.sh\"\n";
+               };
+               7D20069222F2679B008DF640 /* Install Swift Module */ = {
+                       isa = PBXShellScriptBuildPhase;
+                       buildActionMask = 12;
+                       files = (
+                       );
+                       inputFileListPaths = (
+                       );
+                       inputPaths = (
+                       );
+                       name = "Install Swift Module";
+                       outputFileListPaths = (
+                       );
+                       outputPaths = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+                       shellPath = /bin/sh;
+                       shellScript = "exec \"${SOURCE_ROOT}/SwiftOverlay/install-swiftmodules.sh\"\n";
+               };
+/* End PBXShellScriptBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+               7D20067222F2652E008DF640 /* Sources */ = {
+                       isa = PBXSourcesBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               B3A5D39223F790DB00B17727 /* WebKitSwiftOverlay.swift in Sources */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
+               7D20068422F26721008DF640 /* Sources */ = {
+                       isa = PBXSourcesBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               B3A5D39323F790DB00B17727 /* WebKitSwiftOverlay.swift in Sources */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
+               7D20070322F4EB72008DF640 /* Sources */ = {
+                       isa = PBXSourcesBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               B3A5D38F23F78F5400B17727 /* WebKitTests.swift in Sources */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
+               7D20071222F4ECCA008DF640 /* Sources */ = {
+                       isa = PBXSourcesBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               B3A5D39023F78F5400B17727 /* WebKitTests.swift in Sources */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXTargetDependency section */
+               7D20070E22F4EB72008DF640 /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = 7D20067422F2652E008DF640 /* WebKitSwiftOverlay */;
+                       targetProxy = 7D20070D22F4EB72008DF640 /* PBXContainerItemProxy */;
+               };
+               7D20071D22F4ECCA008DF640 /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = 7D20068622F26721008DF640 /* WebKitSwiftOverlay-maccatalyst */;
+                       targetProxy = 7D20071C22F4ECCA008DF640 /* PBXContainerItemProxy */;
+               };
+/* End PBXTargetDependency section */
+
+/* Begin XCBuildConfiguration section */
+               7D20067C22F2652E008DF640 /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       baseConfigurationReference = B3A5D39423F790E100B17727 /* WebKitSwiftOverlay.xcconfig */;
+                       buildSettings = {
+                       };
+                       name = Debug;
+               };
+               7D20067D22F2652E008DF640 /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       baseConfigurationReference = B3A5D39423F790E100B17727 /* WebKitSwiftOverlay.xcconfig */;
+                       buildSettings = {
+                       };
+                       name = Release;
+               };
+               7D20068E22F26721008DF640 /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       baseConfigurationReference = B3A5D39623F790E100B17727 /* WebKitSwiftOverlay-maccatalyst.xcconfig */;
+                       buildSettings = {
+                       };
+                       name = Debug;
+               };
+               7D20068F22F26721008DF640 /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       baseConfigurationReference = B3A5D39623F790E100B17727 /* WebKitSwiftOverlay-maccatalyst.xcconfig */;
+                       buildSettings = {
+                       };
+                       name = Release;
+               };
+               7D20071022F4EB72008DF640 /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       baseConfigurationReference = B3A5D39823F790E100B17727 /* WebKitSwiftOverlayTests.xcconfig */;
+                       buildSettings = {
+                       };
+                       name = Debug;
+               };
+               7D20071122F4EB72008DF640 /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       baseConfigurationReference = B3A5D39823F790E100B17727 /* WebKitSwiftOverlayTests.xcconfig */;
+                       buildSettings = {
+                       };
+                       name = Release;
+               };
+               7D20071F22F4ECCA008DF640 /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       baseConfigurationReference = B3A5D39723F790E100B17727 /* WebKitSwiftOverlayTests-maccatalyst.xcconfig */;
+                       buildSettings = {
+                       };
+                       name = Debug;
+               };
+               7D20072022F4ECCA008DF640 /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       baseConfigurationReference = B3A5D39723F790E100B17727 /* WebKitSwiftOverlayTests-maccatalyst.xcconfig */;
+                       buildSettings = {
+                       };
+                       name = Release;
+               };
+               7D81A8E422E936E700739BB9 /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       baseConfigurationReference = B3A5D39523F790E100B17727 /* Base.xcconfig */;
+                       buildSettings = {
+                       };
+                       name = Debug;
+               };
+               7D81A8E522E936E700739BB9 /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       baseConfigurationReference = B3A5D39523F790E100B17727 /* Base.xcconfig */;
+                       buildSettings = {
+                       };
+                       name = Release;
+               };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+               7D20067B22F2652E008DF640 /* Build configuration list for PBXNativeTarget "WebKitSwiftOverlay" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               7D20067C22F2652E008DF640 /* Debug */,
+                               7D20067D22F2652E008DF640 /* Release */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = Release;
+               };
+               7D20068D22F26721008DF640 /* Build configuration list for PBXNativeTarget "WebKitSwiftOverlay-maccatalyst" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               7D20068E22F26721008DF640 /* Debug */,
+                               7D20068F22F26721008DF640 /* Release */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = Release;
+               };
+               7D20070F22F4EB72008DF640 /* Build configuration list for PBXNativeTarget "WebKitSwiftOverlayTests" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               7D20071022F4EB72008DF640 /* Debug */,
+                               7D20071122F4EB72008DF640 /* Release */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = Release;
+               };
+               7D20071E22F4ECCA008DF640 /* Build configuration list for PBXNativeTarget "WebKitSwiftOverlayTests-maccatalyst" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               7D20071F22F4ECCA008DF640 /* Debug */,
+                               7D20072022F4ECCA008DF640 /* Release */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = Release;
+               };
+               7D81A8D822E936E700739BB9 /* Build configuration list for PBXProject "WebKitSwiftOverlay" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               7D81A8E422E936E700739BB9 /* Debug */,
+                               7D81A8E522E936E700739BB9 /* Release */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = Release;
+               };
+/* End XCConfigurationList section */
+       };
+       rootObject = 7D81A8D522E936E700739BB9 /* Project object */;
+}
diff --git a/Source/WebKit/SwiftOverlay/WebKitSwiftOverlay.xcodeproj/xcshareddata/xcschemes/Everything (Catalyst).xcscheme b/Source/WebKit/SwiftOverlay/WebKitSwiftOverlay.xcodeproj/xcshareddata/xcschemes/Everything (Catalyst).xcscheme
new file mode 100644 (file)
index 0000000..155393f
--- /dev/null
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+   LastUpgradeVersion = "1200"
+   version = "1.7">
+   <BuildAction
+      parallelizeBuildables = "YES"
+      buildImplicitDependencies = "NO">
+      <BuildActionEntries>
+         <BuildActionEntry
+            buildForTesting = "YES"
+            buildForRunning = "YES"
+            buildForProfiling = "YES"
+            buildForArchiving = "YES"
+            buildForAnalyzing = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "7D20068622F26721008DF640"
+               BuildableName = "libswiftWebKit.dylib"
+               BlueprintName = "WebKitSwiftOverlay-maccatalyst"
+               ReferencedContainer = "container:WebKitSwiftOverlay.xcodeproj">
+            </BuildableReference>
+         </BuildActionEntry>
+      </BuildActionEntries>
+   </BuildAction>
+   <TestAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      shouldUseLaunchSchemeArgsEnv = "YES">
+      <Testables>
+         <TestableReference
+            skipped = "NO">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "7D20071522F4ECCA008DF640"
+               BuildableName = "WebKitSwiftOverlayTests-maccatalyst.xctest"
+               BlueprintName = "WebKitSwiftOverlayTests-maccatalyst"
+               ReferencedContainer = "container:WebKitSwiftOverlay.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+      </Testables>
+   </TestAction>
+   <LaunchAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      launchStyle = "0"
+      useCustomWorkingDirectory = "NO"
+      ignoresPersistentStateOnLaunch = "NO"
+      debugDocumentVersioning = "YES"
+      debugServiceExtension = "internal"
+      allowLocationSimulation = "YES">
+   </LaunchAction>
+   <ProfileAction
+      buildConfiguration = "Release"
+      shouldUseLaunchSchemeArgsEnv = "YES"
+      savedToolIdentifier = ""
+      useCustomWorkingDirectory = "NO"
+      debugDocumentVersioning = "YES">
+      <MacroExpansion>
+         <BuildableReference
+            BuildableIdentifier = "primary"
+            BlueprintIdentifier = "7D20068622F26721008DF640"
+            BuildableName = "libswiftWebKit.dylib"
+            BlueprintName = "WebKitSwiftOverlay-maccatalyst"
+            ReferencedContainer = "container:WebKitSwiftOverlay.xcodeproj">
+         </BuildableReference>
+      </MacroExpansion>
+   </ProfileAction>
+   <AnalyzeAction
+      buildConfiguration = "Debug">
+   </AnalyzeAction>
+   <ArchiveAction
+      buildConfiguration = "Release"
+      revealArchiveInOrganizer = "YES">
+   </ArchiveAction>
+   <InstallAction
+      buildConfiguration = "Release">
+   </InstallAction>
+</Scheme>
diff --git a/Source/WebKit/SwiftOverlay/WebKitSwiftOverlay.xcodeproj/xcshareddata/xcschemes/Everything.xcscheme b/Source/WebKit/SwiftOverlay/WebKitSwiftOverlay.xcodeproj/xcshareddata/xcschemes/Everything.xcscheme
new file mode 100644 (file)
index 0000000..ee2c993
--- /dev/null
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+   LastUpgradeVersion = "1200"
+   version = "1.7">
+   <BuildAction
+      parallelizeBuildables = "YES"
+      buildImplicitDependencies = "NO">
+      <BuildActionEntries>
+         <BuildActionEntry
+            buildForTesting = "YES"
+            buildForRunning = "YES"
+            buildForProfiling = "YES"
+            buildForArchiving = "YES"
+            buildForAnalyzing = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "7D20067422F2652E008DF640"
+               BuildableName = "libswiftWebKit.dylib"
+               BlueprintName = "WebKitSwiftOverlay"
+               ReferencedContainer = "container:WebKitSwiftOverlay.xcodeproj">
+            </BuildableReference>
+         </BuildActionEntry>
+         <BuildActionEntry
+            buildForTesting = "YES"
+            buildForRunning = "NO"
+            buildForProfiling = "NO"
+            buildForArchiving = "NO"
+            buildForAnalyzing = "NO">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "7D20070622F4EB72008DF640"
+               BuildableName = "WebKitSwiftOverlayTests.xctest"
+               BlueprintName = "WebKitSwiftOverlayTests"
+               ReferencedContainer = "container:WebKitSwiftOverlay.xcodeproj">
+            </BuildableReference>
+         </BuildActionEntry>
+      </BuildActionEntries>
+   </BuildAction>
+   <TestAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      shouldUseLaunchSchemeArgsEnv = "YES">
+      <Testables>
+         <TestableReference
+            skipped = "NO">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "7D20070622F4EB72008DF640"
+               BuildableName = "WebKitSwiftOverlayTests.xctest"
+               BlueprintName = "WebKitSwiftOverlayTests"
+               ReferencedContainer = "container:WebKitSwiftOverlay.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+      </Testables>
+   </TestAction>
+   <LaunchAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      launchStyle = "0"
+      useCustomWorkingDirectory = "NO"
+      ignoresPersistentStateOnLaunch = "NO"
+      debugDocumentVersioning = "YES"
+      debugServiceExtension = "internal"
+      allowLocationSimulation = "YES">
+   </LaunchAction>
+   <ProfileAction
+      buildConfiguration = "Release"
+      shouldUseLaunchSchemeArgsEnv = "YES"
+      savedToolIdentifier = ""
+      useCustomWorkingDirectory = "NO"
+      debugDocumentVersioning = "YES">
+      <MacroExpansion>
+         <BuildableReference
+            BuildableIdentifier = "primary"
+            BlueprintIdentifier = "7D20067422F2652E008DF640"
+            BuildableName = "libswiftWebKit.dylib"
+            BlueprintName = "WebKitSwiftOverlay"
+            ReferencedContainer = "container:WebKitSwiftOverlay.xcodeproj">
+         </BuildableReference>
+      </MacroExpansion>
+   </ProfileAction>
+   <AnalyzeAction
+      buildConfiguration = "Debug">
+   </AnalyzeAction>
+   <ArchiveAction
+      buildConfiguration = "Release"
+      revealArchiveInOrganizer = "YES">
+   </ArchiveAction>
+   <InstallAction
+      buildConfiguration = "Release">
+   </InstallAction>
+</Scheme>
diff --git a/Source/WebKit/UIProcess/API/Cocoa/WebKitSwiftOverlay.swift b/Source/WebKit/UIProcess/API/Cocoa/WebKitSwiftOverlay.swift
new file mode 100644 (file)
index 0000000..805768d
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+@_exported import WebKit
+
+@available(iOS 14.0, macOS 10.16, *)
+extension WKPDFConfiguration {
+    public var rect: CGRect? {
+        get { __rect == .null ? nil : __rect }
+        set { __rect = newValue == nil ? .null : newValue! }
+    }
+}
+
+@available(iOS 14.0, macOS 10.16, *)
+extension WKWebView {
+    public func callAsyncJavaScript(_ functionBody: String, arguments: [String:Any] = [:], in contentWorld: WKContentWorld, completion: @escaping(Result<Any, Error>) -> Void) {
+        __callAsyncJavaScript(functionBody, arguments: arguments, in: contentWorld, completionHandler: makeResultHandler(completion))
+    }
+
+    public func createPDF(configuration: WKPDFConfiguration = .init(), completionHandler: @escaping (Result<Data, Error>) -> Void) {
+        __createPDF(with: configuration, completionHandler: makeResultHandler(completionHandler))
+    }
+
+    public func createWebArchiveData(completionHandler: @escaping (Result<Data, Error>) -> Void) {
+        __createWebArchiveData(completionHandler: makeResultHandler(completionHandler))
+    }
+
+    public func evaluateJavaScript(_ javaScript: String, in contentWorld: WKContentWorld, completion: @escaping (Result<Any, Error>) -> Void) {
+        __evaluateJavaScript(javaScript, in: contentWorld, completionHandler: makeResultHandler(completion))
+    }
+
+    public func find(_ string: String, configuration: WKFindConfiguration = .init(), completionHandler: @escaping (WKFindResult) -> Void) {
+        __find(string, with: configuration, completionHandler: completionHandler)
+    }
+}
+
+func makeResultHandler<Success, Failure>(_ handler: @escaping (Result<Success, Failure>) -> Void) -> (Success?, Failure?) -> Void {
+    return { success, failure in
+        if let success = success {
+            handler(.success(success))
+        } else if let failure = failure {
+            handler(.failure(failure))
+        } else {
+            fatalError("Bug in WebKit: Received neither result or failure.")
+        }
+    }
+}