Changeset 181511 in webkit


Ignore:
Timestamp:
Mar 15, 2015, 12:30:09 PM (10 years ago)
Author:
mitz@apple.com
Message:

[iOS] Presenting a modal sheet on top of a WKWebView causes it to lose focused, active state
https://bugs.webkit.org/show_bug.cgi?id=142702

Reviewed by Anders Carlsson.

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView becomeFirstResponder]): Override to delegate first responder status to the
WKContentView if possible.
(-[WKWebView _retainActiveFocusedState]): New SPI that prevents view hierarchy changes from
affecting the active and focused state of the view. Increments a counter ivar and returns a
completion block (which callers must call when they’re done) that decrements it back.

  • UIProcess/API/Cocoa/WKWebViewInternal.h: Declared new _activeFocusedStateRetainCount ivar

with @package access.

  • UIProcess/API/Cocoa/WKWebViewPrivate.h: Declared new method.
  • UIProcess/ios/PageClientImplIOS.mm:

(WebKit::PageClientImpl::isViewWindowActive): Return true if active/focused state is to be
maintained despite not being visible.
(WebKit::PageClientImpl::isViewFocused): Return true if active/focused state is to be
maintained despite not being active.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView resignFirstResponder]): Don’t blur the assisted node if active/focused
state is to be maintained.

Location:
trunk/Source/WebKit2
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r181505 r181511  
     12015-03-15  Dan Bernstein  <mitz@apple.com>
     2
     3        [iOS] Presenting a modal sheet on top of a WKWebView causes it to lose focused, active state
     4        https://bugs.webkit.org/show_bug.cgi?id=142702
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * UIProcess/API/Cocoa/WKWebView.mm:
     9        (-[WKWebView becomeFirstResponder]): Override to delegate first responder status to the
     10        WKContentView if possible.
     11        (-[WKWebView _retainActiveFocusedState]): New SPI that prevents view hierarchy changes from
     12        affecting the active and focused state of the view. Increments a counter ivar and returns a
     13        completion block (which callers must call when they’re done) that decrements it back.
     14        * UIProcess/API/Cocoa/WKWebViewInternal.h: Declared new _activeFocusedStateRetainCount ivar
     15        with @package access.
     16        * UIProcess/API/Cocoa/WKWebViewPrivate.h: Declared new method.
     17
     18        * UIProcess/ios/PageClientImplIOS.mm:
     19        (WebKit::PageClientImpl::isViewWindowActive): Return true if active/focused state is to be
     20        maintained despite not being visible.
     21        (WebKit::PageClientImpl::isViewFocused): Return true if active/focused state is to be
     22        maintained despite not being active.
     23
     24        * UIProcess/ios/WKContentViewInteraction.mm:
     25        (-[WKContentView resignFirstResponder]): Don’t blur the assisted node if active/focused
     26        state is to be maintained.
     27
    1282015-03-14  Simon Fraser  <simon.fraser@apple.com>
    229
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r181504 r181511  
    651651}
    652652
     653- (BOOL)becomeFirstResponder
     654{
     655    return [_contentView becomeFirstResponder] || [super becomeFirstResponder];
     656}
     657
    653658static inline CGFloat floorToDevicePixel(CGFloat input, float deviceScaleFactor)
    654659{
     
    17711776    return webView->_overridesInterfaceOrientation ? deviceOrientationForUIInterfaceOrientation(webView->_interfaceOrientationOverride) : webView->_page->deviceOrientation();
    17721777}
     1778
     1779- (void (^)(void))_retainActiveFocusedState
     1780{
     1781    ++_activeFocusedStateRetainCount;
     1782
     1783    // FIXME: Use something like CompletionHandlerCallChecker to ensure that the returned block is called before it's released.
     1784    return [[[self] {
     1785        --_activeFocusedStateRetainCount;
     1786    } copy] autorelease];
     1787}
     1788
    17731789#endif
    17741790
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h

    r180361 r181511  
    6161
    6262    RefPtr<WebKit::WebPageProxy> _page;
     63
     64#if PLATFORM(IOS)
     65    NSUInteger _activeFocusedStateRetainCount;
     66#endif
    6367}
    6468
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h

    r179752 r181511  
    152152- (void)_didRelaunchProcess;
    153153
     154// Puts the view into a state where being taken out of the view hierarchy and resigning first responder
     155// will not count as becoming inactive and unfocused. The returned block must be called to exit the state.
     156- (void (^)(void))_retainActiveFocusedState WK_AVAILABLE(NA, WK_IOS_TBA);
     157
    154158#else
    155159@property (readonly) NSColor *_pageExtendedBackgroundColor;
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm

    r181023 r181511  
    172172{
    173173    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=133098
    174     return isViewVisible();
     174    return isViewVisible() || m_webView->_activeFocusedStateRetainCount;
    175175}
    176176
     
    178178{
    179179    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=133098
    180     return isViewWindowActive();
     180    return isViewWindowActive() || m_webView->_activeFocusedStateRetainCount;
    181181}
    182182
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r181448 r181511  
    518518    // FIXME: Maybe we should call resignFirstResponder on the superclass
    519519    // and do nothing if the return value is NO.
    520     // We need to complete the editing operation before we blur the element.
    521     [_inputPeripheral endEditing];
    522     _page->blurAssistedNode();
     520
     521    if (!_webView->_activeFocusedStateRetainCount) {
     522        // We need to complete the editing operation before we blur the element.
     523        [_inputPeripheral endEditing];
     524        _page->blurAssistedNode();
     525    }
     526
    523527    [self _cancelInteraction];
    524528    [_webSelectionAssistant resignedFirstResponder];
Note: See TracChangeset for help on using the changeset viewer.