⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 181836 in webkit


Ignore:
Timestamp:
Mar 22, 2015, 2:44:50 PM (11 years ago)
Author:
mitz@apple.com
Message:

[iOS] Expose WebPageProxy::setInitialFocus as SPI
https://bugs.webkit.org/show_bug.cgi?id=142951

Reviewed by Anders Carlsson.

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _becomeFirstResponderWithSelectionMovingForward:completionHandler:]): New SPI.
Just calls through to WKWebContentView, but allows a nil completion handler.

  • UIProcess/API/Cocoa/WKWebViewPrivate.h:
  • UIProcess/API/mac/WKView.mm:

(-[WKView becomeFirstResponder]): Pass an empty lambda for the new callback parameter to
WebPageProxy::setInitialFocus.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::setInitialFocus): Added a void callback parameter and made sure to
call it.

  • UIProcess/WebPageProxy.h:
  • UIProcess/ios/WKContentViewInteraction.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _becomeFirstResponderWithSelectionMovingForward:completionHandler:]):
Added. Calls WebPageProxy::setInitialFocus, and once that completes, checks if anything was
focused and if so, becomes first responder, then calls the completion handler.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::setInitialFocus): Added a callbackID parameter, and made sure to send the
callback message. Added a temporary change of m_userIsInteracting to true, so that the UI
process won’t ignore any StartAssistingNode message resulting from the focus change.

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in: Added a callbackID parameter to SetInitialFocus.
Location:
trunk/Source/WebKit2
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r181832 r181836  
     12015-03-22  Dan Bernstein  <mitz@apple.com>
     2
     3        [iOS] Expose WebPageProxy::setInitialFocus as SPI
     4        https://bugs.webkit.org/show_bug.cgi?id=142951
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * UIProcess/API/Cocoa/WKWebView.mm:
     9        (-[WKWebView _becomeFirstResponderWithSelectionMovingForward:completionHandler:]): New SPI.
     10        Just calls through to WKWebContentView, but allows a nil completion handler.
     11        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
     12
     13        * UIProcess/API/mac/WKView.mm:
     14        (-[WKView becomeFirstResponder]): Pass an empty lambda for the new callback parameter to
     15        WebPageProxy::setInitialFocus.
     16
     17        * UIProcess/WebPageProxy.cpp:
     18        (WebKit::WebPageProxy::setInitialFocus): Added a void callback parameter and made sure to
     19        call it.
     20        * UIProcess/WebPageProxy.h:
     21
     22        * UIProcess/ios/WKContentViewInteraction.h:
     23        * UIProcess/ios/WKContentViewInteraction.mm:
     24        (-[WKContentView _becomeFirstResponderWithSelectionMovingForward:completionHandler:]):
     25        Added. Calls WebPageProxy::setInitialFocus, and once that completes, checks if anything was
     26        focused and if so, becomes first responder, then calls the completion handler.
     27
     28        * WebProcess/WebPage/WebPage.cpp:
     29        (WebKit::WebPage::setInitialFocus): Added a callbackID parameter, and made sure to send the
     30        callback message. Added a temporary change of m_userIsInteracting to true, so that the UI
     31        process won’t ignore any StartAssistingNode message resulting from the focus change.
     32        * WebProcess/WebPage/WebPage.h:
     33
     34        * WebProcess/WebPage/WebPage.messages.in: Added a callbackID parameter to SetInitialFocus.
     35
    1362015-03-21  Dean Jackson  <dino@apple.com>
    237
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r181511 r181836  
    9191#import "RemoteScrollingCoordinatorProxy.h"
    9292#import "UIKitSPI.h"
     93#import "WKContentViewInteraction.h"
    9394#import "WKPDFView.h"
    9495#import "WKScrollView.h"
     
    17851786        --_activeFocusedStateRetainCount;
    17861787    } copy] autorelease];
     1788}
     1789
     1790- (void)_becomeFirstResponderWithSelectionMovingForward:(BOOL)selectingForward completionHandler:(void (^)(BOOL didBecomeFirstResponder))completionHandler
     1791{
     1792    typeof(completionHandler) completionHandlerCopy = nil;
     1793    if (completionHandler)
     1794        completionHandlerCopy = Block_copy(completionHandler);
     1795
     1796    [_contentView _becomeFirstResponderWithSelectionMovingForward:selectingForward completionHandler:[completionHandlerCopy](BOOL didBecomeFirstResponder) {
     1797        if (!completionHandlerCopy)
     1798            return;
     1799
     1800        completionHandlerCopy(didBecomeFirstResponder);
     1801        Block_release(completionHandlerCopy);
     1802    }];
    17871803}
    17881804
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h

    r181511 r181836  
    156156- (void (^)(void))_retainActiveFocusedState WK_AVAILABLE(NA, WK_IOS_TBA);
    157157
     158- (void)_becomeFirstResponderWithSelectionMovingForward:(BOOL)selectingForward completionHandler:(void (^)(BOOL didBecomeFirstResponder))completionHandler WK_AVAILABLE(NA, WK_IOS_TBA);
     159
    158160#else
    159161@property (readonly) NSColor *_pageExtendedBackgroundColor;
  • trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm

    r181812 r181836  
    402402        if ([event type] == NSKeyDown || [event type] == NSKeyUp)
    403403            keyboardEvent = event;
    404         _data->_page->setInitialFocus(direction == NSSelectingNext, keyboardEvent != nil, NativeWebKeyboardEvent(keyboardEvent, false, Vector<KeypressCommand>()));
     404        _data->_page->setInitialFocus(direction == NSSelectingNext, keyboardEvent != nil, NativeWebKeyboardEvent(keyboardEvent, false, Vector<KeypressCommand>()), [](CallbackBase::Error) { });
    405405    }
    406406    return YES;
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r181815 r181836  
    14201420}
    14211421
    1422 void WebPageProxy::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& keyboardEvent)
    1423 {
    1424     if (!isValid())
    1425         return;
    1426     m_process->send(Messages::WebPage::SetInitialFocus(forward, isKeyboardEventValid, keyboardEvent), m_pageID);
     1422void WebPageProxy::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& keyboardEvent, std::function<void (CallbackBase::Error)> callbackFunction)
     1423{
     1424    if (!isValid()) {
     1425        callbackFunction(CallbackBase::Error::OwnerWasInvalidated);
     1426        return;
     1427    }
     1428
     1429    uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), m_process->throttler().backgroundActivityToken());
     1430    m_process->send(Messages::WebPage::SetInitialFocus(forward, isKeyboardEventValid, keyboardEvent, callbackID), m_pageID);
    14271431}
    14281432
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r181815 r181836  
    390390    void viewWillEndLiveResize();
    391391
    392     void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&);
     392    void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&, std::function<void (CallbackBase::Error)>);
    393393    void setWindowResizerSize(const WebCore::IntSize&);
    394394   
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h

    r180441 r181836  
    197197- (void)_enableInspectorNodeSearch;
    198198- (void)_disableInspectorNodeSearch;
     199- (void)_becomeFirstResponderWithSelectionMovingForward:(BOOL)selectingForward completionHandler:(void (^)(BOOL didBecomeFirstResponder))completionHandler;
    199200@end
    200201
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r181511 r181836  
    20542054}
    20552055
     2056- (void)_becomeFirstResponderWithSelectionMovingForward:(BOOL)selectingForward completionHandler:(void (^)(BOOL didBecomeFirstResponder))completionHandler
     2057{
     2058    auto completionHandlerCopy = Block_copy(completionHandler);
     2059    _page->setInitialFocus(selectingForward, false, WebKit::WebKeyboardEvent(), [self, completionHandlerCopy](WebKit::CallbackBase::Error) {
     2060        BOOL didBecomeFirstResponder = _assistedNodeInformation.elementType != InputType::None && [self becomeFirstResponder];
     2061        completionHandlerCopy(didBecomeFirstResponder);
     2062        Block_release(completionHandlerCopy);
     2063    });
     2064}
     2065
    20562066- (void)accessoryAutoFill
    20572067{
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r181815 r181836  
    168168#include <runtime/JSLock.h>
    169169#include <wtf/RunLoop.h>
     170#include <wtf/TemporaryChange.h>
    170171
    171172#if ENABLE(MHTML)
     
    22082209}
    22092210
    2210 void WebPage::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& event)
     2211void WebPage::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& event, uint64_t callbackID)
    22112212{
    22122213    if (!m_page)
    22132214        return;
     2215
     2216#if PLATFORM(IOS)
     2217    TemporaryChange<bool> userIsInteractingChange { m_userIsInteracting, true };
     2218#endif
    22142219
    22152220    Frame& frame = m_page->focusController().focusedOrMainFrame();
     
    22202225        platformEvent.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown);
    22212226        m_page->focusController().setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, &KeyboardEvent::create(platformEvent, frame.document()->defaultView()).get());
     2227
     2228        send(Messages::WebPageProxy::VoidCallback(callbackID));
    22222229        return;
    22232230    }
    22242231
    22252232    m_page->focusController().setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, 0);
     2233    send(Messages::WebPageProxy::VoidCallback(callbackID));
    22262234}
    22272235
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r181815 r181836  
    929929    void goToBackForwardItem(uint64_t navigationID, uint64_t);
    930930    void tryRestoreScrollPosition();
    931     void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&);
     931    void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&, uint64_t callbackID);
    932932    void setWindowResizerSize(const WebCore::IntSize&);
    933933    void updateIsInWindow(bool isInitialState = false);
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

    r181815 r181836  
    2222
    2323messages -> WebPage LegacyReceiver {
    24     SetInitialFocus(bool forward, bool isKeyboardEventValid, WebKit::WebKeyboardEvent event)
     24    SetInitialFocus(bool forward, bool isKeyboardEventValid, WebKit::WebKeyboardEvent event, uint64_t callbackID)
    2525    SetViewState(unsigned viewState, bool wantsDidUpdateViewState, Vector<uint64_t> callbackIDs)
    2626    SetLayerHostingMode(unsigned layerHostingMode)
Note: See TracChangeset for help on using the changeset viewer.