Use SFSafariViewController for previews
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Jun 2015 17:52:35 +0000 (17:52 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Jun 2015 17:52:35 +0000 (17:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=146092

Reviewed by Darin Adler.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView previewViewControllerForPosition:inSourceView:]):
(-[WKContentView commitPreviewViewController:]):
* WebKit2.xcodeproj/project.pbxproj:
* Source/WebKit2/Platform/spi/ios/SafariServicesSPI.h:

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

Source/WebKit2/ChangeLog
Source/WebKit2/Platform/spi/ios/SafariServicesSPI.h [new file with mode: 0644]
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

index 30e3ca1..5dcf1a0 100644 (file)
@@ -1,3 +1,16 @@
+2015-06-18  Tim Horton  <timothy_horton@apple.com>
+
+        Use SFSafariViewController for previews
+        https://bugs.webkit.org/show_bug.cgi?id=146092
+
+        Reviewed by Darin Adler.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView previewViewControllerForPosition:inSourceView:]):
+        (-[WKContentView commitPreviewViewController:]):
+        * WebKit2.xcodeproj/project.pbxproj:
+        * Source/WebKit2/Platform/spi/ios/SafariServicesSPI.h:
+
 2015-06-18  Antti Koivisto  <antti@apple.com>
 
         ~4% Membuster regression after WebKit r185452
diff --git a/Source/WebKit2/Platform/spi/ios/SafariServicesSPI.h b/Source/WebKit2/Platform/spi/ios/SafariServicesSPI.h
new file mode 100644 (file)
index 0000000..d0240bf
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+#if HAVE(SAFARI_SERVICES_FRAMEWORK) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000
+
+#import <WebCore/SoftLinking.h>
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <SafariServices/SFSafariViewControllerPrivate.h>
+
+#else
+
+@interface SFSafariViewController ()
+
+@property (nonatomic, setter=_setShowingLinkPreview:) BOOL _showingLinkPreview;
+
+@end
+
+#endif
+
+SOFT_LINK_FRAMEWORK(SafariServices);
+SOFT_LINK_CLASS(SafariServices, SFSafariViewController);
+
+#endif
index 2306ca8..75009bc 100644 (file)
@@ -34,6 +34,7 @@
 #import "ManagedConfigurationSPI.h"
 #import "NativeWebKeyboardEvent.h"
 #import "NativeWebTouchEvent.h"
+#import "SafariServicesSPI.h"
 #import "SmartMagnificationController.h"
 #import "TextInputSPI.h"
 #import "UIKitSPI.h"
@@ -3131,7 +3132,9 @@ static bool isAssistableInputType(InputType type)
     if ([uiDelegate respondsToSelector:@selector(_webView:previewViewControllerForURL:)])
         return [uiDelegate _webView:_webView previewViewControllerForURL:targetURL];
 
-    return WKGetPreviewViewController(targetURL);
+    SFSafariViewController *previewViewController = [allocSFSafariViewControllerInstance() initWithURL:targetURL];
+    previewViewController._showingLinkPreview = YES;
+    return previewViewController;
 }
 
 - (void)commitPreviewViewController:(UIViewController *)viewController
@@ -3142,11 +3145,16 @@ static bool isAssistableInputType(InputType type)
         return;
     }
 
-    UIViewController *presentingViewController = viewController.presentingViewController ?: self.window.rootViewController;
-    WKWillCommitPreviewViewController(viewController);
+    if (![viewController isKindOfClass:getSFSafariViewControllerClass()])
+        return;
+
+    SFSafariViewController *safariViewController = (SFSafariViewController *)viewController;
+    safariViewController._showingLinkPreview = NO;
 
     viewController.transitioningDelegate = nil;
     viewController.modalPresentationStyle = UIModalPresentationFullScreen;
+
+    UIViewController *presentingViewController = viewController.presentingViewController ?: self.window.rootViewController;
     [presentingViewController presentViewController:viewController animated:NO completion:nil];
 }
 
index ccdebf8..dcee894 100644 (file)
                2DACE64E18ADBFF000E4CA76 /* _WKThumbnailViewInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DACE64D18ADBFF000E4CA76 /* _WKThumbnailViewInternal.h */; };
                2DAF06D618BD1A470081CEB1 /* SmartMagnificationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DAF06D418BD1A470081CEB1 /* SmartMagnificationController.h */; };
                2DAF06D718BD1A470081CEB1 /* SmartMagnificationController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DAF06D518BD1A470081CEB1 /* SmartMagnificationController.mm */; };
+               2DB9C4AC1B3251BD0070F27F /* SafariServicesSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DB9C4AB1B3251BD0070F27F /* SafariServicesSPI.h */; };
                2DC6D9C318C44A610043BAD4 /* WKWebViewContentProviderRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DC6D9C118C44A610043BAD4 /* WKWebViewContentProviderRegistry.h */; };
                2DC6D9C418C44A610043BAD4 /* WKWebViewContentProviderRegistry.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DC6D9C218C44A610043BAD4 /* WKWebViewContentProviderRegistry.mm */; };
                2DD12A081A8177F3002C74E6 /* WKPageRenderingProgressEvents.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DD12A071A8177F3002C74E6 /* WKPageRenderingProgressEvents.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2DAF06D418BD1A470081CEB1 /* SmartMagnificationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SmartMagnificationController.h; path = ios/SmartMagnificationController.h; sourceTree = "<group>"; };
                2DAF06D518BD1A470081CEB1 /* SmartMagnificationController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SmartMagnificationController.mm; path = ios/SmartMagnificationController.mm; sourceTree = "<group>"; };
                2DAF06D818BD23BA0081CEB1 /* SmartMagnificationController.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; name = SmartMagnificationController.messages.in; path = ios/SmartMagnificationController.messages.in; sourceTree = "<group>"; };
+               2DB9C4AB1B3251BD0070F27F /* SafariServicesSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SafariServicesSPI.h; sourceTree = "<group>"; };
                2DC6D9C118C44A610043BAD4 /* WKWebViewContentProviderRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewContentProviderRegistry.h; sourceTree = "<group>"; };
                2DC6D9C218C44A610043BAD4 /* WKWebViewContentProviderRegistry.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewContentProviderRegistry.mm; sourceTree = "<group>"; };
                2DD12A071A8177F3002C74E6 /* WKPageRenderingProgressEvents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPageRenderingProgressEvents.h; sourceTree = "<group>"; };
                                CE1A0BCD1A48E6C60054EF74 /* CorePDFSPI.h */,
                                CE1A0BCE1A48E6C60054EF74 /* DataDetectorsUISPI.h */,
                                CE1A0BCF1A48E6C60054EF74 /* ManagedConfigurationSPI.h */,
+                               2DB9C4AB1B3251BD0070F27F /* SafariServicesSPI.h */,
                                CE1A0BD01A48E6C60054EF74 /* TCCSPI.h */,
                                CE1A0BD11A48E6C60054EF74 /* TextInputSPI.h */,
                                CEE4AE2A1A5DCF430002F49B /* UIKitSPI.h */,
                                1A043A09124D11A900FFBFB5 /* WebProcessConnection.h in Headers */,
                                1A043F6A12514D8B00FFBFB5 /* WebProcessConnectionMessages.h in Headers */,
                                BC306824125A6B9400E71278 /* WebProcessCreationParameters.h in Headers */,
+                               2DB9C4AC1B3251BD0070F27F /* SafariServicesSPI.h in Headers */,
                                1AFA4B901A65A9E2006C4AB4 /* WebProcessLifetimeObserver.h in Headers */,
                                1AFA4B8C1A65A1D0006C4AB4 /* WebProcessLifetimeTracker.h in Headers */,
                                BC3066BF125A442100E71278 /* WebProcessMessages.h in Headers */,