Changeset 221714 in webkit


Ignore:
Timestamp:
Sep 6, 2017 8:42:39 PM (7 years ago)
Author:
achristensen@apple.com
Message:

Add WKUIDelegatePrivate equivalent of WKPageUIClient's pageDidScroll
https://bugs.webkit.org/show_bug.cgi?id=176482
<rdar://problem/29270035>

Reviewed by Tim Horton.
Source/WebKit:


Covered by a new API test!

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

(WebKit::UIDelegate::setDelegate):
(WebKit::UIDelegate::UIClient::pageDidScroll):

Tools:

  • TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:

(-[DidScrollDelegate _webViewDidScroll:]):
(TEST):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r221710 r221714  
     12017-09-06  Alex Christensen  <achristensen@webkit.org>
     2
     3        Add WKUIDelegatePrivate equivalent of WKPageUIClient's pageDidScroll
     4        https://bugs.webkit.org/show_bug.cgi?id=176482
     5        <rdar://problem/29270035>
     6
     7        Reviewed by Tim Horton.
     8       
     9        Covered by a new API test!
     10
     11        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
     12        * UIProcess/Cocoa/UIDelegate.h:
     13        * UIProcess/Cocoa/UIDelegate.mm:
     14        (WebKit::UIDelegate::setDelegate):
     15        (WebKit::UIDelegate::UIClient::pageDidScroll):
     16
    1172017-09-06  Youenn Fablet  <youenn@apple.com>
    218
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h

    r221658 r221714  
    153153- (void)_focusWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    154154- (void)_unfocusWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA));
     155- (void)_webViewDidScroll:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    155156- (void)_webView:(WKWebView *)webView takeFocus:(_WKFocusDirection)direction WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    156157- (void)_webView:(WKWebView *)webView didNotHandleWheelEvent:(NSEvent *)event WK_API_AVAILABLE(macosx(WK_MAC_TBA));
  • trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h

    r221658 r221714  
    101101        void focus(WebPageProxy*) final;
    102102        void unfocus(WebPageProxy*) final;
     103        void pageDidScroll(WebPageProxy*) final;
    103104        void didNotHandleWheelEvent(WebPageProxy*, const NativeWebWheelEvent&) final;
    104105        void handleAutoplayEvent(WebPageProxy&, WebCore::AutoplayEvent, OptionSet<WebCore::AutoplayEventFlags>) final;
     
    153154        bool unfocusWebView : 1;
    154155        bool webViewTakeFocus : 1;
     156        bool webViewDidScroll : 1;
    155157        bool webViewDidNotHandleWheelEvent : 1;
    156158        bool webViewHandleAutoplayEventWithFlags : 1;
  • trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm

    r221658 r221714  
    110110    m_delegateMethods.unfocusWebView = [delegate respondsToSelector:@selector(_unfocusWebView:)];
    111111    m_delegateMethods.webViewTakeFocus = [delegate respondsToSelector:@selector(_webView:takeFocus:)];
     112    m_delegateMethods.webViewDidScroll = [delegate respondsToSelector:@selector(_webViewDidScroll:)];
    112113    m_delegateMethods.webViewGetToolbarsAreVisibleWithCompletionHandler = [delegate respondsToSelector:@selector(_webView:getToolbarsAreVisibleWithCompletionHandler:)];
    113114    m_delegateMethods.webViewDidNotHandleWheelEvent = [delegate respondsToSelector:@selector(_webView:didNotHandleWheelEvent:)];
     
    410411   
    411412    [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView takeFocus:toWKFocusDirection(direction)];
     413}
     414
     415void UIDelegate::UIClient::pageDidScroll(WebPageProxy*)
     416{
     417    if (!m_uiDelegate.m_delegateMethods.webViewDidScroll)
     418        return;
     419   
     420    auto delegate = m_uiDelegate.m_delegate.get();
     421    if (!delegate)
     422        return;
     423   
     424    [(id <WKUIDelegatePrivate>)delegate _webViewDidScroll:m_uiDelegate.m_webView];
    412425}
    413426
  • trunk/Tools/ChangeLog

    r221712 r221714  
     12017-09-06  Alex Christensen  <achristensen@webkit.org>
     2
     3        Add WKUIDelegatePrivate equivalent of WKPageUIClient's pageDidScroll
     4        https://bugs.webkit.org/show_bug.cgi?id=176482
     5        <rdar://problem/29270035>
     6
     7        Reviewed by Tim Horton.
     8
     9        * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:
     10        (-[DidScrollDelegate _webViewDidScroll:]):
     11        (TEST):
     12
    1132017-09-06  Eric Carlson  <eric.carlson@apple.com>
    214
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm

    r221707 r221714  
    250250}
    251251
    252 @interface PinnedStateObserver : NSObject <WKUIDelegatePrivate>
     252@interface PinnedStateObserver : NSObject
    253253@end
    254254
     
    272272    auto observer = adoptNS([[PinnedStateObserver alloc] init]);
    273273    [webView addObserver:observer.get() forKeyPath:@"_pinnedState" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil];
     274    [webView loadHTMLString:@"<body onload='scroll(100, 100)' style='height:10000vh;'/>" baseURL:[NSURL URLWithString:@"http://example.com/"]];
     275    TestWebKitAPI::Util::run(&done);
     276}
     277
     278@interface DidScrollDelegate : NSObject <WKUIDelegatePrivate>
     279@end
     280
     281@implementation DidScrollDelegate
     282
     283- (void)_webViewDidScroll:(WKWebView *)webView
     284{
     285    done = true;
     286}
     287
     288@end
     289
     290TEST(WebKit, DidScroll)
     291{
     292    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
     293    auto delegate = adoptNS([[DidScrollDelegate alloc] init]);
     294    [webView setUIDelegate:delegate.get()];
    274295    [webView loadHTMLString:@"<body onload='scroll(100, 100)' style='height:10000vh;'/>" baseURL:[NSURL URLWithString:@"http://example.com/"]];
    275296    TestWebKitAPI::Util::run(&done);
Note: See TracChangeset for help on using the changeset viewer.