Changeset 221164 in webkit


Ignore:
Timestamp:
Aug 24, 2017 3:10:57 PM (7 years ago)
Author:
achristensen@apple.com
Message:

Add WKUIDelegatePrivate callback corresponding to PageUIClient's didNotHandleWheelEvent
https://bugs.webkit.org/show_bug.cgi?id=175957
<rdar://problem/29270035>

Reviewed by Geoffrey Garen.

Source/WebKit:

  • UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
  • UIProcess/Cocoa/UIDelegate.h:
  • UIProcess/Cocoa/UIDelegate.mm:

(WebKit::UIDelegate::setDelegate):
(WebKit::UIDelegate::UIClient::didNotHandleWheelEvent):

Tools:

  • TestWebKitAPI/Tests/WebKit2Cocoa/UIDelegate.mm:

(synthesizeWheelEvents):
(-[WheelDelegate _webView:didNotHandleWheelEvent:]):
(-[WheelDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
(TEST):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r221161 r221164  
     12017-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
    1152017-08-24  Tim Horton  <timothy_horton@apple.com>
    216
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h

    r221099 r221164  
    130130- (void)_unfocusWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    131131- (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));
    132133- (NSMenu *)_webView:(WKWebView *)webView contextMenu:(NSMenu *)menu forElement:(_WKContextMenuElementInfo *)element WK_API_AVAILABLE(macosx(10.12));
    133134- (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  
    101101        void focus(WebPageProxy*) final;
    102102        void unfocus(WebPageProxy*) final;
     103        void didNotHandleWheelEvent(WebKit::WebPageProxy*, const WebKit::NativeWebWheelEvent&) final;
    103104        bool runOpenPanel(WebPageProxy*, WebFrameProxy*, const WebCore::SecurityOriginData&, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) final;
    104105#endif
     
    145146        bool unfocusWebView : 1;
    146147        bool webViewTakeFocus : 1;
     148        bool webViewDidNotHandleWheelEvent : 1;
    147149        bool webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler : 1;
    148150#endif
  • trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm

    r221099 r221164  
    3131#import "APIFrameInfo.h"
    3232#import "CompletionHandlerCallChecker.h"
     33#import "NativeWebWheelEvent.h"
    3334#import "NavigationActionData.h"
    3435#import "UserMediaPermissionCheckProxy.h"
     
    105106    m_delegateMethods.unfocusWebView = [delegate respondsToSelector:@selector(_unfocusWebView:)];
    106107    m_delegateMethods.webViewTakeFocus = [delegate respondsToSelector:@selector(_webView:takeFocus:)];
     108    m_delegateMethods.webViewDidNotHandleWheelEvent = [delegate respondsToSelector:@selector(_webView:didNotHandleWheelEvent:)];
    107109    m_delegateMethods.webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:)];
    108110#endif
     
    422424   
    423425    [(id <WKUIDelegatePrivate>)delegate _unfocusWebView:m_uiDelegate.m_webView];
     426}
     427
     428void 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()];
    424438}
    425439
  • trunk/Tools/ChangeLog

    r221153 r221164  
     12017-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
    1152017-08-24  Tim Horton  <timothy_horton@apple.com>
    216
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/UIDelegate.mm

    r221099 r221164  
    137137}
    138138
     139static 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
     169TEST(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
    139178#endif // PLATFORM(MAC)
    140179
Note: See TracChangeset for help on using the changeset viewer.