Changeset 237786 in webkit
- Timestamp:
- Nov 4, 2018 1:19:44 PM (6 years ago)
- Location:
- trunk/Tools
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r237784 r237786 1 2018-11-04 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [Cocoa] Fold common UIScriptController functionality on macOS and iOS into UIScriptControllerCocoa.mm 4 https://bugs.webkit.org/show_bug.cgi?id=191231 5 6 Reviewed by Simon Fraser. 7 8 Moves some UIScriptController method implementations specific to iOS and macOS into UIScriptControllerCocoa, so 9 it can be shared between iOS-family and macOS platforms. See below for more details. 10 11 No change in behavior. 12 13 * DumpRenderTree/ios/UIScriptControllerIOS.mm: 14 (WTR::UIScriptController::overridePreference): 15 16 Add a method stub for DumpRenderTree. 17 18 * TestRunnerShared/UIScriptContext/UIScriptController.cpp: 19 * WebKitTestRunner/UIScriptControllerCocoa.mm: 20 (WTR::UIScriptController::doAsyncTask): 21 (WTR::UIScriptController::setShareSheetCompletesImmediatelyWithResolution): 22 23 Unify these method implementations. 24 25 (WTR::UIScriptController::removeViewFromWindow): 26 (WTR::UIScriptController::addViewToWindow): 27 28 Move the macOS implementation to UIScriptControllerCocoa. On iOS, this method currently only adds the web view 29 to the window, and does not attempt to invoke the given completion block; additionally, invoking the completion 30 block after a presentation update (as done on macOS) causes pageoverlay/overlay-remove-reinsert-view.html to 31 begin failing consistently. This patch does not attempt to change behavior, but adds a FIXME describing this. 32 33 (WTR::UIScriptController::overridePreference): 34 (WTR::UIScriptController::findString): 35 (WTR::UIScriptController::contentsOfUserInterfaceItem const): 36 37 Move these from UIScriptControllerMac to UIScriptControllerCocoa, so that it is now implemented on iOS as well. 38 39 * WebKitTestRunner/ios/UIScriptControllerIOS.mm: 40 (WTR::UIScriptController::doAsyncTask): Deleted. 41 (WTR::UIScriptController::setShareSheetCompletesImmediatelyWithResolution): Deleted. 42 (WTR::UIScriptController::contentsOfUserInterfaceItem const): Deleted. 43 (WTR::UIScriptController::findString): Deleted. 44 (WTR::UIScriptController::removeViewFromWindow): Deleted. 45 (WTR::UIScriptController::addViewToWindow): Deleted. 46 * WebKitTestRunner/mac/UIScriptControllerMac.mm: 47 (WTR::UIScriptController::doAsyncTask): Deleted. 48 (WTR::UIScriptController::contentsOfUserInterfaceItem const): Deleted. 49 (WTR::UIScriptController::overridePreference): Deleted. 50 (WTR::UIScriptController::findString): Deleted. 51 (WTR::UIScriptController::removeViewFromWindow): Deleted. 52 (WTR::UIScriptController::addViewToWindow): Deleted. 53 (WTR::UIScriptController::setShareSheetCompletesImmediatelyWithResolution): Deleted. 54 1 55 2018-11-04 Eric Carlson <eric.carlson@apple.com> 2 56 -
trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm
r237328 r237786 395 395 } 396 396 397 void UIScriptController::overridePreference(JSStringRef, JSStringRef) 398 { 399 } 400 397 401 } 398 402 -
trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp
r237328 r237786 513 513 } 514 514 515 void UIScriptController::overridePreference(JSStringRef, JSStringRef) 516 { 517 } 518 515 519 #endif // !PLATFORM(COCOA) 516 520 517 521 #if !PLATFORM(MAC) 518 519 void UIScriptController::overridePreference(JSStringRef, JSStringRef)520 {521 }522 522 523 523 void UIScriptController::replaceTextAtRange(JSStringRef, int, int) -
trunk/Tools/WebKitTestRunner/UIScriptControllerCocoa.mm
r237305 r237786 28 28 29 29 #import "PlatformWebView.h" 30 #import "StringFunctions.h" 30 31 #import "TestController.h" 31 32 #import "TestRunnerWKWebView.h" 33 #import "UIScriptContext.h" 34 #import <JavaScriptCore/JavaScriptCore.h> 32 35 #import <WebKit/WKWebViewPrivate.h> 33 36 … … 50 53 } 51 54 55 void UIScriptController::doAsyncTask(JSValueRef callback) 56 { 57 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 58 59 dispatch_async(dispatch_get_main_queue(), ^{ 60 if (!m_context) 61 return; 62 m_context->asyncTaskComplete(callbackID); 63 }); 64 } 65 66 void UIScriptController::setShareSheetCompletesImmediatelyWithResolution(bool resolved) 67 { 68 #if WK_API_ENABLED 69 TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView(); 70 [webView _setShareSheetCompletesImmediatelyWithResolutionForTesting:resolved]; 71 #else 72 UNUSED_PARAM(resolved); 73 #endif 74 } 75 76 void UIScriptController::removeViewFromWindow(JSValueRef callback) 77 { 78 #if WK_API_ENABLED 79 // FIXME: On iOS, we never invoke the completion callback that's passed in. Fixing this causes the layout 80 // test pageoverlay/overlay-remove-reinsert-view.html to start failing consistently on iOS. It seems like 81 // this warrants some more investigation. 82 #if PLATFORM(MAC) 83 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 84 #else 85 UNUSED_PARAM(callback); 86 #endif 87 88 auto* mainWebView = TestController::singleton().mainWebView(); 89 mainWebView->removeFromWindow(); 90 91 #if PLATFORM(MAC) 92 [mainWebView->platformView() _doAfterNextPresentationUpdate:^{ 93 if (!m_context) 94 return; 95 m_context->asyncTaskComplete(callbackID); 96 }]; 97 #endif // PLATFORM(MAC) 98 #else 99 UNUSED_PARAM(callback); 100 #endif 101 } 102 103 void UIScriptController::addViewToWindow(JSValueRef callback) 104 { 105 #if WK_API_ENABLED 106 #if PLATFORM(MAC) 107 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 108 #else 109 UNUSED_PARAM(callback); 110 #endif 111 112 auto* mainWebView = TestController::singleton().mainWebView(); 113 mainWebView->addToWindow(); 114 115 #if PLATFORM(MAC) 116 [mainWebView->platformView() _doAfterNextPresentationUpdate:^{ 117 if (!m_context) 118 return; 119 m_context->asyncTaskComplete(callbackID); 120 }]; 121 #endif // PLATFORM(MAC) 122 #else 123 UNUSED_PARAM(callback); 124 #endif 125 } 126 127 void UIScriptController::overridePreference(JSStringRef preferenceRef, JSStringRef valueRef) 128 { 129 #if WK_API_ENABLED 130 TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView(); 131 WKPreferences *preferences = webView.configuration.preferences; 132 133 String preference = toWTFString(toWK(preferenceRef)); 134 String value = toWTFString(toWK(valueRef)); 135 if (preference == "WebKitMinimumFontSize") 136 preferences.minimumFontSize = value.toDouble(); 137 #else 138 UNUSED_PARAM(preferenceRef); 139 UNUSED_PARAM(valueRef); 140 #endif 141 } 142 143 void UIScriptController::findString(JSStringRef string, unsigned long options, unsigned long maxCount) 144 { 145 #if WK_API_ENABLED 146 TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView(); 147 [webView _findString:toWTFString(toWK(string)) options:options maxCount:maxCount]; 148 #else 149 UNUSED_PARAM(string); 150 UNUSED_PARAM(options); 151 UNUSED_PARAM(maxCount); 152 #endif 153 } 154 155 JSObjectRef UIScriptController::contentsOfUserInterfaceItem(JSStringRef interfaceItem) const 156 { 157 #if WK_API_ENABLED 158 TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView(); 159 NSDictionary *contentDictionary = [webView _contentsOfUserInterfaceItem:toWTFString(toWK(interfaceItem))]; 160 return JSValueToObject(m_context->jsContext(), [JSValue valueWithObject:contentDictionary inContext:[JSContext contextWithJSGlobalContextRef:m_context->jsContext()]].JSValueRef, nullptr); 161 #else 162 UNUSED_PARAM(interfaceItem); 163 return nullptr; 164 #endif 165 } 166 52 167 } // namespace WTR -
trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm
r237328 r237786 61 61 } 62 62 63 void UIScriptController::doAsyncTask(JSValueRef callback)64 {65 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);66 67 dispatch_async(dispatch_get_main_queue(), ^{68 if (!m_context)69 return;70 m_context->asyncTaskComplete(callbackID);71 });72 }73 74 63 void UIScriptController::doAfterPresentationUpdate(JSValueRef callback) 75 64 { … … 411 400 } 412 401 413 void UIScriptController::setShareSheetCompletesImmediatelyWithResolution(bool resolved)414 {415 TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();416 [webView _setShareSheetCompletesImmediatelyWithResolutionForTesting:resolved];417 }418 419 JSObjectRef UIScriptController::contentsOfUserInterfaceItem(JSStringRef interfaceItem) const420 {421 TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();422 NSDictionary *contentDictionary = [webView _contentsOfUserInterfaceItem:toWTFString(toWK(interfaceItem))];423 return JSValueToObject(m_context->jsContext(), [JSValue valueWithObject:contentDictionary inContext:[JSContext contextWithJSGlobalContextRef:m_context->jsContext()]].JSValueRef, nullptr);424 }425 426 402 static CGPoint contentOffsetBoundedInValidRange(UIScrollView *scrollView, CGPoint contentOffset) 427 403 { … … 638 614 } 639 615 640 void UIScriptController::findString(JSStringRef string, unsigned long options, unsigned long maxCount)641 {642 TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();643 [webView _findString:toWTFString(toWK(string)) options:options maxCount:maxCount];644 }645 646 void UIScriptController::removeViewFromWindow(JSValueRef callback)647 {648 TestController::singleton().mainWebView()->removeFromWindow();649 }650 651 void UIScriptController::addViewToWindow(JSValueRef callback)652 {653 TestController::singleton().mainWebView()->addToWindow();654 }655 656 616 void UIScriptController::platformSetDidStartFormControlInteractionCallback() 657 617 { -
trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm
r237012 r237786 48 48 { 49 49 return CFBridgingRelease(JSStringCopyCFString(kCFAllocatorDefault, string)); 50 }51 52 void UIScriptController::doAsyncTask(JSValueRef callback)53 {54 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);55 56 dispatch_async(dispatch_get_main_queue(), ^{57 if (!m_context)58 return;59 m_context->asyncTaskComplete(callbackID);60 });61 50 } 62 51 … … 126 115 } 127 116 128 JSObjectRef UIScriptController::contentsOfUserInterfaceItem(JSStringRef interfaceItem) const129 {130 #if WK_API_ENABLED131 TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();132 NSDictionary *contentDictionary = [webView _contentsOfUserInterfaceItem:toWTFString(toWK(interfaceItem))];133 return JSValueToObject(m_context->jsContext(), [JSValue valueWithObject:contentDictionary inContext:[JSContext contextWithJSGlobalContextRef:m_context->jsContext()]].JSValueRef, nullptr);134 #else135 UNUSED_PARAM(interfaceItem);136 return nullptr;137 #endif138 }139 140 void UIScriptController::overridePreference(JSStringRef preferenceRef, JSStringRef valueRef)141 {142 #if WK_API_ENABLED143 TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();144 WKPreferences *preferences = webView.configuration.preferences;145 146 String preference = toWTFString(toWK(preferenceRef));147 String value = toWTFString(toWK(valueRef));148 if (preference == "WebKitMinimumFontSize")149 preferences.minimumFontSize = value.toDouble();150 #else151 UNUSED_PARAM(preferenceRef);152 UNUSED_PARAM(valueRef);153 #endif154 }155 156 117 void UIScriptController::simulateRotation(DeviceOrientation*, JSValueRef) 157 118 { … … 159 120 160 121 void UIScriptController::simulateRotationLikeSafari(DeviceOrientation*, JSValueRef) 161 {162 }163 164 void UIScriptController::findString(JSStringRef, unsigned long options, unsigned long maxCount)165 122 { 166 123 } … … 176 133 #endif 177 134 return false; 178 }179 180 void UIScriptController::removeViewFromWindow(JSValueRef callback)181 {182 #if WK_API_ENABLED183 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);184 185 auto* mainWebView = TestController::singleton().mainWebView();186 mainWebView->removeFromWindow();187 188 [mainWebView->platformView() _doAfterNextPresentationUpdate: ^ {189 if (!m_context)190 return;191 m_context->asyncTaskComplete(callbackID);192 }];193 #else194 UNUSED_PARAM(callback);195 #endif196 }197 198 void UIScriptController::addViewToWindow(JSValueRef callback)199 {200 #if WK_API_ENABLED201 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);202 203 auto* mainWebView = TestController::singleton().mainWebView();204 mainWebView->addToWindow();205 206 [mainWebView->platformView() _doAfterNextPresentationUpdate: ^ {207 if (!m_context)208 return;209 m_context->asyncTaskComplete(callbackID);210 }];211 #else212 UNUSED_PARAM(callback);213 #endif214 135 } 215 136 … … 271 192 } 272 193 273 void UIScriptController::setShareSheetCompletesImmediatelyWithResolution(bool resolved)274 {275 #if WK_API_ENABLED276 TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();277 [webView _setShareSheetCompletesImmediatelyWithResolutionForTesting:resolved];278 #else279 UNUSED_PARAM(resolved);280 #endif281 }282 283 194 } // namespace WTR
Note: See TracChangeset
for help on using the changeset viewer.