Changeset 195602 in webkit


Ignore:
Timestamp:
Jan 26, 2016 11:12:37 AM (8 years ago)
Author:
timothy_horton@apple.com
Message:

REGRESSION (r194557): Keyboard shortcuts stop working after the WKWebView is unparented and reparented
https://bugs.webkit.org/show_bug.cgi?id=153492
<rdar://problem/24138989>

Reviewed by Dan Bernstein.

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

(-[WKContentView canBecomeFirstResponder]):
(-[WKContentView becomeFirstResponder]):
(-[WKContentView resignFirstResponder]):
When WKWebView is unparented, WKContentView will attempt to resignFirstResponder upwards,
first asking WKWebView. After r194557, WKWebView will accept first responder and forward
it on to the WKContentView, which will happily accept it again, despite being the view
that's trying to resign. This will cause us to completely lose first responder,
where it was actually supposed to propagate up above WKWebView to the client.

Keep track of when WKContentView is resigning first responder, and don't
let it become first responder while it is doing so, breaking the cycle.

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r195600 r195602  
     12016-01-26  Tim Horton  <timothy_horton@apple.com>
     2
     3        REGRESSION (r194557): Keyboard shortcuts stop working after the WKWebView is unparented and reparented
     4        https://bugs.webkit.org/show_bug.cgi?id=153492
     5        <rdar://problem/24138989>
     6
     7        Reviewed by Dan Bernstein.
     8
     9        * UIProcess/ios/WKContentViewInteraction.h:
     10        * UIProcess/ios/WKContentViewInteraction.mm:
     11        (-[WKContentView canBecomeFirstResponder]):
     12        (-[WKContentView becomeFirstResponder]):
     13        (-[WKContentView resignFirstResponder]):
     14        When WKWebView is unparented, WKContentView will attempt to resignFirstResponder upwards,
     15        first asking WKWebView. After r194557, WKWebView will accept first responder and forward
     16        it on to the WKContentView, which will happily accept it again, despite being the view
     17        that's trying to resign. This will cause us to completely lose first responder,
     18        where it was actually supposed to propagate up above WKWebView to the client.
     19
     20        Keep track of when WKContentView is resigning first responder, and don't
     21        let it become first responder while it is doing so, breaking the cycle.
     22
    1232016-01-25  Ada Chan  <adachan@apple.com>
    224
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h

    r192432 r195602  
    162162    BOOL _isExpectingFastSingleTapCommit;
    163163    BOOL _showDebugTapHighlightsForFastClicking;
     164
     165    BOOL _isResigningFirstResponder;
    164166}
    165167
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r195574 r195602  
    670670- (BOOL)canBecomeFirstResponder
    671671{
     672    if (_isResigningFirstResponder)
     673        return NO;
    672674    // We might want to return something else
    673675    // if we decide to enable/disable interaction programmatically.
     
    677679- (BOOL)becomeFirstResponder
    678680{
     681    if (_isResigningFirstResponder)
     682        return NO;
    679683    BOOL didBecomeFirstResponder = [super becomeFirstResponder];
    680684    if (didBecomeFirstResponder)
     
    688692    // FIXME: Maybe we should call resignFirstResponder on the superclass
    689693    // and do nothing if the return value is NO.
     694
     695    _isResigningFirstResponder = YES;
    690696
    691697    if (!_webView->_activeFocusedStateRetainCount) {
     
    699705    [_textSelectionAssistant deactivateSelection];
    700706
    701     return [super resignFirstResponder];
     707    bool superDidResign = [super resignFirstResponder];
     708
     709    _isResigningFirstResponder = NO;
     710
     711    return superDidResign;
    702712}
    703713
Note: See TracChangeset for help on using the changeset viewer.