Changeset 253282 in webkit
- Timestamp:
- Dec 8, 2019 11:25:00 PM (4 years ago)
- Location:
- trunk/Tools
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r253268 r253282 1 2019-12-08 Tim Horton <timothy_horton@apple.com> 2 3 REGRESSION: Crash under UIScriptControllerIOS::simulateAccessibilitySettingsChangeNotification 4 https://bugs.webkit.org/show_bug.cgi?id=205002 5 6 Reviewed by Wenson Hsieh. 7 8 Keep a strong reference to the UIScriptController while running async tasks. 9 UIScriptContext will be nulled out if the view was torn down, but this way 10 we keep the UIScriptController itself and can find the null UIScriptContext 11 reliably. 12 13 * DumpRenderTree/ios/UIScriptControllerIOS.mm: 14 (WTR::UIScriptControllerIOS::doAsyncTask): 15 (WTR::UIScriptControllerIOS::zoomToScale): 16 * DumpRenderTree/mac/UIScriptControllerMac.mm: 17 (WTR::UIScriptControllerMac::doAsyncTask): 18 (WTR::UIScriptControllerMac::activateDataListSuggestion): 19 (WTR::UIScriptControllerMac::removeViewFromWindow): 20 (WTR::UIScriptControllerMac::addViewToWindow): 21 * WebKitTestRunner/ios/UIScriptControllerIOS.mm: 22 (WTR::UIScriptControllerIOS::doAfterPresentationUpdate): 23 (WTR::UIScriptControllerIOS::doAfterNextStablePresentationUpdate): 24 (WTR::UIScriptControllerIOS::ensurePositionInformationIsUpToDateAt): 25 (WTR::UIScriptControllerIOS::doAfterVisibleContentRectUpdate): 26 (WTR::UIScriptControllerIOS::zoomToScale): 27 (WTR::UIScriptControllerIOS::retrieveSpeakSelectionContent): 28 (WTR::UIScriptControllerIOS::simulateAccessibilitySettingsChangeNotification): 29 (WTR::UIScriptControllerIOS::touchDownAtPoint): 30 (WTR::UIScriptControllerIOS::liftUpAtPoint): 31 (WTR::UIScriptControllerIOS::twoFingerSingleTapAtPoint): 32 (WTR::UIScriptControllerIOS::doubleTapAtPoint): 33 (WTR::UIScriptControllerIOS::stylusDownAtPoint): 34 (WTR::UIScriptControllerIOS::stylusMoveToPoint): 35 (WTR::UIScriptControllerIOS::stylusUpAtPoint): 36 (WTR::UIScriptControllerIOS::stylusTapAtPointWithModifiers): 37 (WTR::UIScriptControllerIOS::dragFromPointToPoint): 38 (WTR::UIScriptControllerIOS::longPressAtPoint): 39 (WTR::UIScriptControllerIOS::typeCharacterUsingHardwareKeyboard): 40 (WTR::UIScriptControllerIOS::dismissFilePicker): 41 (WTR::UIScriptControllerIOS::applyAutocorrection): 42 (WTR::UIScriptControllerIOS::simulateRotation): 43 (WTR::UIScriptControllerIOS::simulateRotationLikeSafari): 44 (WTR::UIScriptControllerIOS::setDidStartFormControlInteractionCallback): 45 (WTR::UIScriptControllerIOS::setDidEndFormControlInteractionCallback): 46 (WTR::UIScriptControllerIOS::setDidShowContextMenuCallback): 47 (WTR::UIScriptControllerIOS::setDidDismissContextMenuCallback): 48 (WTR::UIScriptControllerIOS::setWillBeginZoomingCallback): 49 (WTR::UIScriptControllerIOS::setDidEndZoomingCallback): 50 (WTR::UIScriptControllerIOS::setDidShowKeyboardCallback): 51 (WTR::UIScriptControllerIOS::setDidHideKeyboardCallback): 52 (WTR::UIScriptControllerIOS::setWillPresentPopoverCallback): 53 (WTR::UIScriptControllerIOS::setDidDismissPopoverCallback): 54 (WTR::UIScriptControllerIOS::setDidEndScrollingCallback): 55 (WTR::UIScriptControllerIOS::activateDataListSuggestion): 56 (WTR::UIScriptControllerIOS::doAfterDoubleTapDelay): 57 * WebKitTestRunner/mac/UIScriptControllerMac.mm: 58 (WTR::UIScriptControllerMac::zoomToScale): 59 (WTR::UIScriptControllerMac::simulateAccessibilitySettingsChangeNotification): 60 (WTR::UIScriptControllerMac::chooseMenuAction): 61 (WTR::UIScriptControllerMac::activateAtPoint): 62 1 63 2019-12-07 Said Abou-Hallawa <sabouhallawa@apple.com> 2 64 -
trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm
r251377 r253282 33 33 #import <JavaScriptCore/OpaqueJSString.h> 34 34 #import <WebCore/FloatRect.h> 35 #import <wtf/BlockPtr.h> 35 36 #import <wtf/MainThread.h> 36 37 … … 49 50 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 50 51 51 dispatch_async(dispatch_get_main_queue(), ^{52 dispatch_async(dispatch_get_main_queue(), makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 52 53 if (!m_context) 53 54 return; 54 55 m_context->asyncTaskComplete(callbackID); 55 }) ;56 }).get()); 56 57 } 57 58 … … 62 63 RefPtr<UIScriptController> protectedThis(this); 63 64 dispatch_async(dispatch_get_main_queue(), ^{ 64 [gWebScrollView zoomToScale:scale animated:YES completionHandler: ^{65 [gWebScrollView zoomToScale:scale animated:YES completionHandler:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 65 66 if (!m_context) 66 67 return; 67 68 m_context->asyncTaskComplete(callbackID); 68 } ];69 }).get()]; 69 70 }); 70 71 } -
trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm
r252719 r253282 35 35 #import <WebKit/WebKit.h> 36 36 #import <WebKit/WebViewPrivate.h> 37 #import <wtf/BlockPtr.h> 37 38 38 39 #if PLATFORM(MAC) … … 51 52 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 52 53 53 dispatch_async(dispatch_get_main_queue(), ^{54 dispatch_async(dispatch_get_main_queue(), makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 54 55 if (!m_context) 55 56 return; 56 57 m_context->asyncTaskComplete(callbackID); 57 }) ;58 }).get()); 58 59 } 59 60 … … 107 108 108 109 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 109 dispatch_async(dispatch_get_main_queue(), ^{110 dispatch_async(dispatch_get_main_queue(), makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 110 111 if (!m_context) 111 112 return; 112 113 m_context->asyncTaskComplete(callbackID); 113 }) ;114 }).get()); 114 115 } 115 116 … … 130 131 [webView removeFromSuperview]; 131 132 132 dispatch_async(dispatch_get_main_queue(), ^{133 dispatch_async(dispatch_get_main_queue(), makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 133 134 if (!m_context) 134 135 return; 135 136 m_context->asyncTaskComplete(callbackID); 136 }) ;137 }).get()); 137 138 } 138 139 … … 144 145 [[mainWindow contentView] addSubview:webView]; 145 146 146 dispatch_async(dispatch_get_main_queue(), ^{147 dispatch_async(dispatch_get_main_queue(), makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 147 148 if (!m_context) 148 149 return; 149 150 m_context->asyncTaskComplete(callbackID); 150 }) ;151 }).get()); 151 152 } 152 153 -
trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm
r252719 r253282 121 121 { 122 122 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 123 [webView() _doAfterNextPresentationUpdate: ^{124 if (!m_context) 125 return; 126 m_context->asyncTaskComplete(callbackID); 127 } ];123 [webView() _doAfterNextPresentationUpdate:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 124 if (!m_context) 125 return; 126 m_context->asyncTaskComplete(callbackID); 127 }).get()]; 128 128 } 129 129 … … 131 131 { 132 132 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 133 [webView() _doAfterNextStablePresentationUpdate:^() { 134 if (m_context) 135 m_context->asyncTaskComplete(callbackID); 136 }]; 133 [webView() _doAfterNextStablePresentationUpdate:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 134 if (!m_context) 135 return; 136 m_context->asyncTaskComplete(callbackID); 137 }).get()]; 137 138 } 138 139 … … 140 141 { 141 142 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 142 [webView() _requestActivatedElementAtPosition:CGPointMake(x, y) completionBlock: ^(_WKActivatedElementInfo *) {143 if (!m_context) 144 return; 145 m_context->asyncTaskComplete(callbackID); 146 } ];143 [webView() _requestActivatedElementAtPosition:CGPointMake(x, y) completionBlock:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] (_WKActivatedElementInfo *) { 144 if (!m_context) 145 return; 146 m_context->asyncTaskComplete(callbackID); 147 }).get()]; 147 148 } 148 149 … … 150 151 { 151 152 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 152 [webView() _doAfterNextVisibleContentRectUpdate: ^{153 if (!m_context) 154 return; 155 m_context->asyncTaskComplete(callbackID); 156 } ];153 [webView() _doAfterNextVisibleContentRectUpdate:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 154 if (!m_context) 155 return; 156 m_context->asyncTaskComplete(callbackID); 157 }).get()]; 157 158 } 158 159 … … 161 162 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 162 163 163 [webView() zoomToScale:scale animated:YES completionHandler: ^{164 if (!m_context) 165 return; 166 m_context->asyncTaskComplete(callbackID); 167 } ];164 [webView() zoomToScale:scale animated:YES completionHandler:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 165 if (!m_context) 166 return; 167 m_context->asyncTaskComplete(callbackID); 168 }).get()]; 168 169 } 169 170 … … 172 173 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 173 174 174 [webView() accessibilityRetrieveSpeakSelectionContentWithCompletionHandler: ^(){175 if (!m_context) 176 return; 177 m_context->asyncTaskComplete(callbackID); 178 } ];175 [webView() accessibilityRetrieveSpeakSelectionContentWithCompletionHandler:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 176 if (!m_context) 177 return; 178 m_context->asyncTaskComplete(callbackID); 179 }).get()]; 179 180 } 180 181 … … 192 193 [center postNotificationName:UIAccessibilityInvertColorsStatusDidChangeNotification object:webView]; 193 194 194 [webView _doAfterNextPresentationUpdate: ^{195 if (!m_context) 196 return; 197 m_context->asyncTaskComplete(callbackID); 198 } ];195 [webView _doAfterNextPresentationUpdate:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 196 if (!m_context) 197 return; 198 m_context->asyncTaskComplete(callbackID); 199 }).get()]; 199 200 } 200 201 … … 218 219 219 220 auto location = globalToContentCoordinates(webView(), x, y); 220 [[HIDEventGenerator sharedHIDEventGenerator] touchDown:location touchCount:touchCount completionBlock: ^{221 if (!m_context) 222 return; 223 m_context->asyncTaskComplete(callbackID); 224 } ];221 [[HIDEventGenerator sharedHIDEventGenerator] touchDown:location touchCount:touchCount completionBlock:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 222 if (!m_context) 223 return; 224 m_context->asyncTaskComplete(callbackID); 225 }).get()]; 225 226 } 226 227 … … 230 231 231 232 auto location = globalToContentCoordinates(webView(), x, y); 232 [[HIDEventGenerator sharedHIDEventGenerator] liftUp:location touchCount:touchCount completionBlock: ^{233 if (!m_context) 234 return; 235 m_context->asyncTaskComplete(callbackID); 236 } ];233 [[HIDEventGenerator sharedHIDEventGenerator] liftUp:location touchCount:touchCount completionBlock:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 234 if (!m_context) 235 return; 236 m_context->asyncTaskComplete(callbackID); 237 }).get()]; 237 238 } 238 239 … … 261 262 262 263 auto location = globalToContentCoordinates(webView(), x, y); 263 [[HIDEventGenerator sharedHIDEventGenerator] twoFingerTap:location completionBlock: ^{264 if (!m_context) 265 return; 266 m_context->asyncTaskComplete(callbackID); 267 } ];264 [[HIDEventGenerator sharedHIDEventGenerator] twoFingerTap:location completionBlock:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 265 if (!m_context) 266 return; 267 m_context->asyncTaskComplete(callbackID); 268 }).get()]; 268 269 } 269 270 … … 300 301 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 301 302 302 [[HIDEventGenerator sharedHIDEventGenerator] doubleTap:globalToContentCoordinates(webView(), x, y) delay:delay completionBlock: ^{303 if (!m_context) 304 return; 305 m_context->asyncTaskComplete(callbackID); 306 } ];303 [[HIDEventGenerator sharedHIDEventGenerator] doubleTap:globalToContentCoordinates(webView(), x, y) delay:delay completionBlock:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 304 if (!m_context) 305 return; 306 m_context->asyncTaskComplete(callbackID); 307 }).get()]; 307 308 } 308 309 … … 312 313 313 314 auto location = globalToContentCoordinates(webView(), x, y); 314 [[HIDEventGenerator sharedHIDEventGenerator] stylusDownAtPoint:location azimuthAngle:azimuthAngle altitudeAngle:altitudeAngle pressure:pressure completionBlock: ^{315 if (!m_context) 316 return; 317 m_context->asyncTaskComplete(callbackID); 318 } ];315 [[HIDEventGenerator sharedHIDEventGenerator] stylusDownAtPoint:location azimuthAngle:azimuthAngle altitudeAngle:altitudeAngle pressure:pressure completionBlock:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 316 if (!m_context) 317 return; 318 m_context->asyncTaskComplete(callbackID); 319 }).get()]; 319 320 } 320 321 … … 324 325 325 326 auto location = globalToContentCoordinates(webView(), x, y); 326 [[HIDEventGenerator sharedHIDEventGenerator] stylusMoveToPoint:location azimuthAngle:azimuthAngle altitudeAngle:altitudeAngle pressure:pressure completionBlock: ^{327 if (!m_context) 328 return; 329 m_context->asyncTaskComplete(callbackID); 330 } ];327 [[HIDEventGenerator sharedHIDEventGenerator] stylusMoveToPoint:location azimuthAngle:azimuthAngle altitudeAngle:altitudeAngle pressure:pressure completionBlock:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 328 if (!m_context) 329 return; 330 m_context->asyncTaskComplete(callbackID); 331 }).get()]; 331 332 } 332 333 … … 336 337 337 338 auto location = globalToContentCoordinates(webView(), x, y); 338 [[HIDEventGenerator sharedHIDEventGenerator] stylusUpAtPoint:location completionBlock: ^{339 if (!m_context) 340 return; 341 m_context->asyncTaskComplete(callbackID); 342 } ];339 [[HIDEventGenerator sharedHIDEventGenerator] stylusUpAtPoint:location completionBlock:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 340 if (!m_context) 341 return; 342 m_context->asyncTaskComplete(callbackID); 343 }).get()]; 343 344 } 344 345 … … 359 360 360 361 auto location = globalToContentCoordinates(webView(), x, y); 361 [[HIDEventGenerator sharedHIDEventGenerator] stylusTapAtPoint:location azimuthAngle:azimuthAngle altitudeAngle:altitudeAngle pressure:pressure completionBlock: ^{362 [[HIDEventGenerator sharedHIDEventGenerator] stylusTapAtPoint:location azimuthAngle:azimuthAngle altitudeAngle:altitudeAngle pressure:pressure completionBlock:makeBlockPtr([this, strongThis = makeRef(*this), callbackID, modifierFlags = WTFMove(modifierFlags)] { 362 363 if (!m_context) 363 364 return; … … 366 367 [[HIDEventGenerator sharedHIDEventGenerator] keyUp:modifierFlags[i]]; 367 368 } 368 [[HIDEventGenerator sharedHIDEventGenerator] sendMarkerHIDEventWithCompletionBlock: ^{369 [[HIDEventGenerator sharedHIDEventGenerator] sendMarkerHIDEventWithCompletionBlock:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 369 370 if (!m_context) 370 371 return; 371 372 m_context->asyncTaskComplete(callbackID); 372 } ];373 } ];373 }).get()]; 374 }).get()]; 374 375 } 375 376 … … 429 430 CGPoint endPoint = globalToContentCoordinates(webView(), endX, endY); 430 431 431 [[HIDEventGenerator sharedHIDEventGenerator] dragWithStartPoint:startPoint endPoint:endPoint duration:durationSeconds completionBlock: ^{432 if (!m_context) 433 return; 434 m_context->asyncTaskComplete(callbackID); 435 } ];432 [[HIDEventGenerator sharedHIDEventGenerator] dragWithStartPoint:startPoint endPoint:endPoint duration:durationSeconds completionBlock:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 433 if (!m_context) 434 return; 435 m_context->asyncTaskComplete(callbackID); 436 }).get()]; 436 437 } 437 438 … … 440 441 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 441 442 442 [[HIDEventGenerator sharedHIDEventGenerator] longPress:globalToContentCoordinates(webView(), x, y) completionBlock: ^{443 if (!m_context) 444 return; 445 m_context->asyncTaskComplete(callbackID); 446 } ];443 [[HIDEventGenerator sharedHIDEventGenerator] longPress:globalToContentCoordinates(webView(), x, y) completionBlock:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 444 if (!m_context) 445 return; 446 m_context->asyncTaskComplete(callbackID); 447 }).get()]; 447 448 } 448 449 … … 458 459 459 460 // Assumes that the keyboard is already shown. 460 [[HIDEventGenerator sharedHIDEventGenerator] keyPress:toWTFString(toWK(character)) completionBlock: ^{461 if (!m_context) 462 return; 463 m_context->asyncTaskComplete(callbackID); 464 } ];461 [[HIDEventGenerator sharedHIDEventGenerator] keyPress:toWTFString(toWK(character)) completionBlock:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 462 if (!m_context) 463 return; 464 m_context->asyncTaskComplete(callbackID); 465 }).get()]; 465 466 } 466 467 … … 523 524 // Round-trip with the WebProcess to make sure it has been notified of the dismissal. 524 525 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 525 [webView evaluateJavaScript:@"" completionHandler:^(id result, NSError *error) { 526 if (m_context) 527 m_context->asyncTaskComplete(callbackID); 528 }]; 526 [webView evaluateJavaScript:@"" completionHandler:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] (id result, NSError *error) { 527 if (!m_context) 528 return; 529 m_context->asyncTaskComplete(callbackID); 530 }).get()]; 529 531 } 530 532 … … 655 657 656 658 TestRunnerWKWebView *webView = this->webView(); 657 [webView applyAutocorrection:toWTFString(toWK(newString)) toString:toWTFString(toWK(oldString)) withCompletionHandler: ^{658 // applyAutocorrection can call its completion handler synchronously,659 // which makes UIScriptController unhappy (see bug 172884).660 dispatch_async(dispatch_get_main_queue(), ^ {659 [webView applyAutocorrection:toWTFString(toWK(newString)) toString:toWTFString(toWK(oldString)) withCompletionHandler:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 660 dispatch_async(dispatch_get_main_queue(), makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 661 // applyAutocorrection can call its completion handler synchronously, 662 // which makes UIScriptController unhappy (see bug 172884). 661 663 if (!m_context) 662 664 return; 663 665 m_context->asyncTaskComplete(callbackID); 664 }); 665 }]; 666 }).get()); 667 if (!m_context) 668 return; 669 m_context->asyncTaskComplete(callbackID); 670 }).get()]; 666 671 } 667 672 … … 805 810 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 806 811 807 webView.rotationDidEndCallback = ^{808 if (!m_context) 809 return; 810 m_context->asyncTaskComplete(callbackID); 811 } ;812 webView.rotationDidEndCallback = makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 813 if (!m_context) 814 return; 815 m_context->asyncTaskComplete(callbackID); 816 }).get(); 812 817 813 818 [[UIDevice currentDevice] setOrientation:toUIDeviceOrientation(orientation) animated:YES]; … … 821 826 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 822 827 823 webView.rotationDidEndCallback = ^{824 if (!m_context) 825 return; 826 m_context->asyncTaskComplete(callbackID); 827 } ;828 webView.rotationDidEndCallback = makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 829 if (!m_context) 830 return; 831 m_context->asyncTaskComplete(callbackID); 832 }).get(); 828 833 829 834 [[UIDevice currentDevice] setOrientation:toUIDeviceOrientation(orientation) animated:YES]; … … 833 838 { 834 839 UIScriptController::setDidStartFormControlInteractionCallback(callback); 835 webView().didStartFormControlInteractionCallback = ^{840 webView().didStartFormControlInteractionCallback = makeBlockPtr([this, strongThis = makeRef(*this)] { 836 841 if (!m_context) 837 842 return; 838 843 m_context->fireCallback(CallbackTypeDidStartFormControlInteraction); 839 } ;844 }).get(); 840 845 } 841 846 … … 843 848 { 844 849 UIScriptController::setDidEndFormControlInteractionCallback(callback); 845 webView().didEndFormControlInteractionCallback = ^{850 webView().didEndFormControlInteractionCallback = makeBlockPtr([this, strongThis = makeRef(*this)] { 846 851 if (!m_context) 847 852 return; 848 853 m_context->fireCallback(CallbackTypeDidEndFormControlInteraction); 849 } ;854 }).get(); 850 855 } 851 856 … … 853 858 { 854 859 UIScriptController::setDidShowContextMenuCallback(callback); 855 webView().didShowContextMenuCallback = ^{860 webView().didShowContextMenuCallback = makeBlockPtr([this, strongThis = makeRef(*this)] { 856 861 if (!m_context) 857 862 return; 858 863 m_context->fireCallback(CallbackTypeDidShowContextMenu); 859 } ;864 }).get(); 860 865 } 861 866 … … 863 868 { 864 869 UIScriptController::setDidDismissContextMenuCallback(callback); 865 webView().didDismissContextMenuCallback = ^{870 webView().didDismissContextMenuCallback = makeBlockPtr([this, strongThis = makeRef(*this)] { 866 871 if (!m_context) 867 872 return; 868 873 m_context->fireCallback(CallbackTypeDidEndFormControlInteraction); 869 } ;874 }).get(); 870 875 } 871 876 … … 873 878 { 874 879 UIScriptController::setWillBeginZoomingCallback(callback); 875 webView().willBeginZoomingCallback = ^{880 webView().willBeginZoomingCallback = makeBlockPtr([this, strongThis = makeRef(*this)] { 876 881 if (!m_context) 877 882 return; 878 883 m_context->fireCallback(CallbackTypeWillBeginZooming); 879 } ;884 }).get(); 880 885 } 881 886 … … 883 888 { 884 889 UIScriptController::setDidEndZoomingCallback(callback); 885 webView().didEndZoomingCallback = ^{890 webView().didEndZoomingCallback = makeBlockPtr([this, strongThis = makeRef(*this)] { 886 891 if (!m_context) 887 892 return; 888 893 m_context->fireCallback(CallbackTypeDidEndZooming); 889 } ;894 }).get(); 890 895 } 891 896 … … 893 898 { 894 899 UIScriptController::setDidShowKeyboardCallback(callback); 895 webView().didShowKeyboardCallback = ^{900 webView().didShowKeyboardCallback = makeBlockPtr([this, strongThis = makeRef(*this)] { 896 901 if (!m_context) 897 902 return; 898 903 m_context->fireCallback(CallbackTypeDidShowKeyboard); 899 } ;904 }).get(); 900 905 } 901 906 … … 903 908 { 904 909 UIScriptController::setDidHideKeyboardCallback(callback); 905 webView().didHideKeyboardCallback = ^{910 webView().didHideKeyboardCallback = makeBlockPtr([this, strongThis = makeRef(*this)] { 906 911 if (!m_context) 907 912 return; 908 913 m_context->fireCallback(CallbackTypeDidHideKeyboard); 909 } ;914 }).get(); 910 915 } 911 916 … … 932 937 { 933 938 UIScriptController::setWillPresentPopoverCallback(callback); 934 webView().willPresentPopoverCallback = ^{939 webView().willPresentPopoverCallback = makeBlockPtr([this, strongThis = makeRef(*this)] { 935 940 if (!m_context) 936 941 return; 937 942 m_context->fireCallback(CallbackTypeWillPresentPopover); 938 } ;943 }).get(); 939 944 } 940 945 … … 942 947 { 943 948 UIScriptController::setDidDismissPopoverCallback(callback); 944 webView().didDismissPopoverCallback = ^{949 webView().didDismissPopoverCallback = makeBlockPtr([this, strongThis = makeRef(*this)] { 945 950 if (!m_context) 946 951 return; 947 952 m_context->fireCallback(CallbackTypeDidDismissPopover); 948 } ;953 }).get(); 949 954 } 950 955 … … 1005 1010 { 1006 1011 UIScriptController::setDidEndScrollingCallback(callback); 1007 webView().didEndScrollingCallback = ^{1012 webView().didEndScrollingCallback = makeBlockPtr([this, strongThis = makeRef(*this)] { 1008 1013 if (!m_context) 1009 1014 return; 1010 1015 m_context->fireCallback(CallbackTypeDidEndScrolling); 1011 } ;1016 }).get(); 1012 1017 } 1013 1018 … … 1039 1044 1040 1045 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 1041 dispatch_async(dispatch_get_main_queue(), ^{1042 if (!m_context) 1043 return; 1044 m_context->asyncTaskComplete(callbackID); 1045 }) ;1046 dispatch_async(dispatch_get_main_queue(), makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 1047 if (!m_context) 1048 return; 1049 m_context->asyncTaskComplete(callbackID); 1050 }).get()); 1046 1051 } 1047 1052 … … 1194 1199 } 1195 1200 1196 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(maximumIntervalBetweenSuccessiveTaps * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 1197 if (m_context) 1198 m_context->asyncTaskComplete(callbackID); 1199 }); 1201 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(maximumIntervalBetweenSuccessiveTaps * NSEC_PER_SEC)), dispatch_get_main_queue(), makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 1202 if (!m_context) 1203 return; 1204 m_context->asyncTaskComplete(callbackID); 1205 }).get()); 1200 1206 } 1201 1207 -
trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm
r252719 r253282 44 44 #import <JavaScriptCore/OpaqueJSString.h> 45 45 #import <WebKit/WKWebViewPrivate.h> 46 #import <wtf/BlockPtr.h> 46 47 47 48 namespace WTR { … … 69 70 [webView _setPageScale:scale withOrigin:CGPointZero]; 70 71 71 [webView _doAfterNextPresentationUpdate: ^{72 if (!m_context) 73 return; 74 m_context->asyncTaskComplete(callbackID); 75 } ];72 [webView _doAfterNextPresentationUpdate:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 73 if (!m_context) 74 return; 75 m_context->asyncTaskComplete(callbackID); 76 }).get()]; 76 77 } 77 78 … … 89 90 [center postNotificationName:NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification object:webView]; 90 91 91 [webView _doAfterNextPresentationUpdate: ^{92 if (!m_context) 93 return; 94 m_context->asyncTaskComplete(callbackID); 95 } ];92 [webView _doAfterNextPresentationUpdate:makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 93 if (!m_context) 94 return; 95 m_context->asyncTaskComplete(callbackID); 96 }).get()]; 96 97 } 97 98 … … 172 173 } 173 174 174 dispatch_async(dispatch_get_main_queue(), ^{ 175 if (m_context) 176 m_context->asyncTaskComplete(callbackID); 177 }); 175 dispatch_async(dispatch_get_main_queue(), makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 176 if (!m_context) 177 return; 178 m_context->asyncTaskComplete(callbackID); 179 }).get()); 178 180 } 179 181 … … 248 250 eventSender->mouseUp(0, 0); 249 251 250 dispatch_async(dispatch_get_main_queue(), ^{ 251 if (m_context) 252 m_context->asyncTaskComplete(callbackID); 253 }); 252 dispatch_async(dispatch_get_main_queue(), makeBlockPtr([this, strongThis = makeRef(*this), callbackID] { 253 if (!m_context) 254 return; 255 m_context->asyncTaskComplete(callbackID); 256 }).get()); 254 257 } 255 258
Note: See TracChangeset
for help on using the changeset viewer.