Changeset 221164 in webkit
- Timestamp:
- Aug 24, 2017 3:10:57 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r221161 r221164 1 2017-08-24 Alex Christensen <achristensen@webkit.org> 2 3 Add WKUIDelegatePrivate callback corresponding to PageUIClient's didNotHandleWheelEvent 4 https://bugs.webkit.org/show_bug.cgi?id=175957 5 <rdar://problem/29270035> 6 7 Reviewed by Geoffrey Garen. 8 9 * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: 10 * UIProcess/Cocoa/UIDelegate.h: 11 * UIProcess/Cocoa/UIDelegate.mm: 12 (WebKit::UIDelegate::setDelegate): 13 (WebKit::UIDelegate::UIClient::didNotHandleWheelEvent): 14 1 15 2017-08-24 Tim Horton <timothy_horton@apple.com> 2 16 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h
r221099 r221164 130 130 - (void)_unfocusWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 131 131 - (void)_webView:(WKWebView *)webView takeFocus:(_WKFocusDirection)direction WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 132 - (void)_webView:(WKWebView *)webView didNotHandleWheelEvent:(NSEvent *)event WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 132 133 - (NSMenu *)_webView:(WKWebView *)webView contextMenu:(NSMenu *)menu forElement:(_WKContextMenuElementInfo *)element WK_API_AVAILABLE(macosx(10.12)); 133 134 - (NSMenu *)_webView:(WKWebView *)webView contextMenu:(NSMenu *)menu forElement:(_WKContextMenuElementInfo *)element userInfo:(id <NSSecureCoding>)userInfo WK_API_AVAILABLE(macosx(10.12)); -
trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h
r221102 r221164 101 101 void focus(WebPageProxy*) final; 102 102 void unfocus(WebPageProxy*) final; 103 void didNotHandleWheelEvent(WebKit::WebPageProxy*, const WebKit::NativeWebWheelEvent&) final; 103 104 bool runOpenPanel(WebPageProxy*, WebFrameProxy*, const WebCore::SecurityOriginData&, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) final; 104 105 #endif … … 145 146 bool unfocusWebView : 1; 146 147 bool webViewTakeFocus : 1; 148 bool webViewDidNotHandleWheelEvent : 1; 147 149 bool webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler : 1; 148 150 #endif -
trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm
r221099 r221164 31 31 #import "APIFrameInfo.h" 32 32 #import "CompletionHandlerCallChecker.h" 33 #import "NativeWebWheelEvent.h" 33 34 #import "NavigationActionData.h" 34 35 #import "UserMediaPermissionCheckProxy.h" … … 105 106 m_delegateMethods.unfocusWebView = [delegate respondsToSelector:@selector(_unfocusWebView:)]; 106 107 m_delegateMethods.webViewTakeFocus = [delegate respondsToSelector:@selector(_webView:takeFocus:)]; 108 m_delegateMethods.webViewDidNotHandleWheelEvent = [delegate respondsToSelector:@selector(_webView:didNotHandleWheelEvent:)]; 107 109 m_delegateMethods.webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:)]; 108 110 #endif … … 422 424 423 425 [(id <WKUIDelegatePrivate>)delegate _unfocusWebView:m_uiDelegate.m_webView]; 426 } 427 428 void UIDelegate::UIClient::didNotHandleWheelEvent(WebKit::WebPageProxy*, const WebKit::NativeWebWheelEvent& event) 429 { 430 if (!m_uiDelegate.m_delegateMethods.webViewDidNotHandleWheelEvent) 431 return; 432 433 auto delegate = m_uiDelegate.m_delegate.get(); 434 if (!delegate) 435 return; 436 437 [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView didNotHandleWheelEvent:event.nativeEvent()]; 424 438 } 425 439 -
trunk/Tools/ChangeLog
r221153 r221164 1 2017-08-24 Alex Christensen <achristensen@webkit.org> 2 3 Add WKUIDelegatePrivate callback corresponding to PageUIClient's didNotHandleWheelEvent 4 https://bugs.webkit.org/show_bug.cgi?id=175957 5 <rdar://problem/29270035> 6 7 Reviewed by Geoffrey Garen. 8 9 * TestWebKitAPI/Tests/WebKit2Cocoa/UIDelegate.mm: 10 (synthesizeWheelEvents): 11 (-[WheelDelegate _webView:didNotHandleWheelEvent:]): 12 (-[WheelDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]): 13 (TEST): 14 1 15 2017-08-24 Tim Horton <timothy_horton@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/UIDelegate.mm
r221099 r221164 137 137 } 138 138 139 static void synthesizeWheelEvents(NSView *view, int x, int y) 140 { 141 RetainPtr<CGEventRef> cgScrollEvent = adoptCF(CGEventCreateScrollWheelEvent(nullptr, kCGScrollEventUnitLine, 2, y, x)); 142 NSEvent* event = [NSEvent eventWithCGEvent:cgScrollEvent.get()]; 143 [view scrollWheel:event]; 144 145 // Wheel events get coalesced sometimes. Make more events until one is not handled. 146 dispatch_async(dispatch_get_main_queue(), ^ { 147 synthesizeWheelEvents(view, x, y); 148 }); 149 } 150 151 @interface WheelDelegate : NSObject <WKUIDelegatePrivate> 152 @end 153 154 @implementation WheelDelegate 155 156 - (void)_webView:(WKWebView *)webView didNotHandleWheelEvent:(NSEvent *)event 157 { 158 done = true; 159 } 160 161 - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler 162 { 163 completionHandler(); 164 synthesizeWheelEvents(webView, 1, 1); 165 } 166 167 @end 168 169 TEST(WebKit2, DidNotHandleWheelEvent) 170 { 171 auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]); 172 auto delegate = adoptNS([[WheelDelegate alloc] init]); 173 [webView setUIDelegate:delegate.get()]; 174 [webView loadHTMLString:@"<body onload='alert(\"ready\")' onwheel='()=>{}' style='overflow:hidden; height:10000vh;'></body>" baseURL:[NSURL URLWithString:@"http://example.com/"]]; 175 TestWebKitAPI::Util::run(&done); 176 } 177 139 178 #endif // PLATFORM(MAC) 140 179
Note: See TracChangeset
for help on using the changeset viewer.