UIScriptControllerIOS.mm should not be soft-linking UIKit
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Oct 2016 16:32:53 +0000 (16:32 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Oct 2016 16:32:53 +0000 (16:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164171

Reviewed by Darin Adler.

Follow-up to r208090. Instead of soft-linking, we can simply grab UIKeyboardPredictionView by name instead.

* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::waitForTextPredictionsViewAndSelectCandidateAtIndex):

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

Tools/ChangeLog
Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

index ba1e41f..031ba1d 100644 (file)
@@ -1,3 +1,15 @@
+2016-10-29  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        UIScriptControllerIOS.mm should not be soft-linking UIKit
+        https://bugs.webkit.org/show_bug.cgi?id=164171
+
+        Reviewed by Darin Adler.
+
+        Follow-up to r208090. Instead of soft-linking, we can simply grab UIKeyboardPredictionView by name instead.
+
+        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::waitForTextPredictionsViewAndSelectCandidateAtIndex):
+
 2016-10-28  Darin Adler  <darin@apple.com>
 
         Move all classes in the HTML directory from ExceptionCode to Exception
index ea58134..c159ef2 100644 (file)
 #import <JavaScriptCore/OpaqueJSString.h>
 #import <UIKit/UIKit.h>
 #import <WebCore/FloatRect.h>
-#import <WebCore/SoftLinking.h>
 #import <WebKit/WKWebViewPrivate.h>
 #import <WebKit/WebKit.h>
 
-SOFT_LINK_FRAMEWORK(UIKit)
-SOFT_LINK_CLASS_OPTIONAL(UIKit, UIKeyboardPredictionView)
-
 namespace WTR {
 
 void UIScriptController::doAsyncTask(JSValueRef callback)
@@ -275,8 +271,12 @@ void UIScriptController::selectTextCandidateAtIndex(long index, JSValueRef callb
 
 void UIScriptController::waitForTextPredictionsViewAndSelectCandidateAtIndex(long index, unsigned callbackID, float interval)
 {
+    id UIKeyboardPredictionViewClass = NSClassFromString(@"UIKeyboardPredictionView");
+    if (!UIKeyboardPredictionViewClass)
+        return;
+
 #if USE(APPLE_INTERNAL_SDK)
-    if (![[getUIKeyboardPredictionViewClass() activeInstance] hasPredictions]) {
+    if (![[UIKeyboardPredictionViewClass activeInstance] hasPredictions]) {
         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, interval * NSEC_PER_SEC), dispatch_get_main_queue(), ^() {
             waitForTextPredictionsViewAndSelectCandidateAtIndex(index, callbackID, interval);
         });
@@ -284,10 +284,10 @@ void UIScriptController::waitForTextPredictionsViewAndSelectCandidateAtIndex(lon
     }
 
     PlatformWKView webView = TestController::singleton().mainWebView()->platformView();
-    CGRect predictionViewFrame = [[getUIKeyboardPredictionViewClass() activeInstance] frame];
+    CGRect predictionViewFrame = [[UIKeyboardPredictionViewClass activeInstance] frame];
     // This assumes there are 3 predicted text cells of equal width, which is the case on iOS.
     float offsetX = (index * 2 + 1) * CGRectGetWidth(predictionViewFrame) / 6;
-    float offsetY = CGRectGetHeight(webView.window.frame) - CGRectGetHeight([[[getUIKeyboardPredictionViewClass() activeInstance] superview] frame]) + CGRectGetHeight(predictionViewFrame) / 2;
+    float offsetY = CGRectGetHeight(webView.window.frame) - CGRectGetHeight([[[UIKeyboardPredictionViewClass activeInstance] superview] frame]) + CGRectGetHeight(predictionViewFrame) / 2;
     [[HIDEventGenerator sharedHIDEventGenerator] tap:CGPointMake(offsetX, offsetY) completionBlock:^{
         if (m_context)
             m_context->asyncTaskComplete(callbackID);