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

Changeset 243791 in webkit


Ignore:
Timestamp:
Apr 2, 2019, 11:23:48 PM (7 years ago)
Author:
bshafiei@apple.com
Message:

Cherry-pick r243606. rdar://problem/49229632

[iPad] Tapping on a popup form control may not show a popover
https://bugs.webkit.org/show_bug.cgi?id=196322
<rdar://problem/49229632>

Reviewed by Wenson Hsieh.

Stop taking advantage of -[WKContentView inputView] being called when we invoke -reloadInputViews
to "lazily" allocate the input peripheral for the currently focused element. In theory, UIKit only
needs to call -inputView when it actually needs to display the input view (the keyboard). For
popup menu buttons, like <select>, no keyboard is needed. Instead we should create the peripheral
as part of the logic in the UI process to focus a new element before we call -reloadInputViews.

  • UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView inputView]): Extract logic to allocate the peripheral from here and moved it to createInputPeripheralWithView(). (-[WKContentView accessoryTab:]): While I am here, add a FIXME comment to explain why we need to end the input sessions and nullify the input peripheral before we tell the web process to switch focus as opposed to letting this happen after the web process tells us it focused a new element. (createInputPeripheralWithView): Added. (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]): Write in terms of createInputPeripheralWithView(). Create the input peripheral after becoming first responder because creating the peripheral has known side-effects: for popup buttons it tells the popup controller to present the popover. For key input to popovers to work from the get-go, the content view must be the first responder. See <https://bugs.webkit.org/show_bug.cgi?id=196272> for more details.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243606 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
tags/Safari-608.1.13.5/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tags/Safari-608.1.13.5/Source/WebKit/ChangeLog

    r243790 r243791  
     12019-04-02  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Cherry-pick r243606. rdar://problem/49229632
     4
     5    [iPad] Tapping on a popup form control may not show a popover
     6    https://bugs.webkit.org/show_bug.cgi?id=196322
     7    <rdar://problem/49229632>
     8   
     9    Reviewed by Wenson Hsieh.
     10   
     11    Stop taking advantage of -[WKContentView inputView] being called when we invoke -reloadInputViews
     12    to "lazily" allocate the input peripheral for the currently focused element. In theory, UIKit only
     13    needs to call -inputView when it actually needs to display the input view (the keyboard). For
     14    popup menu buttons, like <select>, no keyboard is needed. Instead we should create the peripheral
     15    as part of the logic in the UI process to focus a new element before we call -reloadInputViews.
     16   
     17    * UIProcess/ios/WKContentViewInteraction.mm:
     18    (-[WKContentView inputView]): Extract logic to allocate the peripheral from here and moved it to createInputPeripheralWithView().
     19    (-[WKContentView accessoryTab:]): While I am here, add a FIXME comment to explain why we need to
     20    end the input sessions and nullify the input peripheral before we tell the web process to switch
     21    focus as opposed to letting this happen after the web process tells us it focused a new element.
     22    (createInputPeripheralWithView): Added.
     23    (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
     24    Write in terms of createInputPeripheralWithView(). Create the input peripheral after becoming
     25    first responder because creating the peripheral has known side-effects: for popup buttons it
     26    tells the popup controller to present the popover. For key input to popovers to work from the get-go,
     27    the content view must be the first responder. See <https://bugs.webkit.org/show_bug.cgi?id=196272>
     28    for more details.
     29   
     30    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243606 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     31
     32    2019-03-28  Daniel Bates  <dabates@apple.com>
     33
     34            [iPad] Tapping on a popup form control may not show a popover
     35            https://bugs.webkit.org/show_bug.cgi?id=196322
     36            <rdar://problem/49229632>
     37
     38            Reviewed by Wenson Hsieh.
     39
     40            Stop taking advantage of -[WKContentView inputView] being called when we invoke -reloadInputViews
     41            to "lazily" allocate the input peripheral for the currently focused element. In theory, UIKit only
     42            needs to call -inputView when it actually needs to display the input view (the keyboard). For
     43            popup menu buttons, like <select>, no keyboard is needed. Instead we should create the peripheral
     44            as part of the logic in the UI process to focus a new element before we call -reloadInputViews.
     45
     46            * UIProcess/ios/WKContentViewInteraction.mm:
     47            (-[WKContentView inputView]): Extract logic to allocate the peripheral from here and moved it to createInputPeripheralWithView().
     48            (-[WKContentView accessoryTab:]): While I am here, add a FIXME comment to explain why we need to
     49            end the input sessions and nullify the input peripheral before we tell the web process to switch
     50            focus as opposed to letting this happen after the web process tells us it focused a new element.
     51            (createInputPeripheralWithView): Added.
     52            (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
     53            Write in terms of createInputPeripheralWithView(). Create the input peripheral after becoming
     54            first responder because creating the peripheral has known side-effects: for popup buttons it
     55            tells the popup controller to present the popover. For key input to popovers to work from the get-go,
     56            the content view must be the first responder. See <https://bugs.webkit.org/show_bug.cgi?id=196272>
     57            for more details.
     58
    1592019-04-02  Babak Shafiei  <bshafiei@apple.com>
    260
  • tags/Safari-608.1.13.5/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r243543 r243791  
    16441644        return nil;
    16451645
    1646     if (!_inputPeripheral) {
    1647         switch (_focusedElementInformation.elementType) {
    1648         case WebKit::InputType::Select:
    1649             _inputPeripheral = adoptNS([[WKFormSelectControl alloc] initWithView:self]);
    1650             break;
    1651 #if ENABLE(INPUT_TYPE_COLOR)
    1652         case WebKit::InputType::Color:
    1653             _inputPeripheral = adoptNS([[WKFormColorControl alloc] initWithView:self]);
    1654             break;
    1655 #endif
    1656         default:
    1657             _inputPeripheral = adoptNS([[WKFormInputControl alloc] initWithView:self]);
    1658             break;
    1659         }
    1660     } else {
     1646    if (_inputPeripheral) {
    16611647        // FIXME: UIKit may invoke -[WKContentView inputView] at any time when WKContentView is the first responder;
    16621648        // as such, it doesn't make sense to change the enclosing scroll view's zoom scale and content offset to reveal
     
    16681654        // rotation, when a select element is focused. See <https://webkit.org/b/192878> for more information.
    16691655        [self _zoomToRevealFocusedElement];
     1656
    16701657        [self _updateAccessory];
    16711658    }
     
    37643751- (void)accessoryTab:(BOOL)isNext
    37653752{
     3753    // The input peripheral may need to update the focused DOM node before we switch focus. The UI process does
     3754    // not maintain a handle to the actual focused DOM node – only the web process has such a handle. So, we need
     3755    // to end the editing session now before we tell the web process to switch focus. Once the web process tells
     3756    // us the newly focused element we are no longer are in a position to effect the previously focused element.
     3757    // See <https://bugs.webkit.org/show_bug.cgi?id=134409>.
    37663758    [self _endEditing];
    3767     _inputPeripheral = nil;
     3759    _inputPeripheral = nil; // Nullify so that we don't tell the input peripheral to end editing again in -_elementDidBlur.
    37683760
    37693761    _isChangingFocusUsingAccessoryTab = YES;
     
    48534845}
    48544846
     4847static RetainPtr<NSObject <WKFormPeripheral>> createInputPeripheralWithView(WebKit::InputType type, WKContentView *view)
     4848{
     4849    switch (type) {
     4850    case WebKit::InputType::Select:
     4851        return adoptNS([[WKFormSelectControl alloc] initWithView:view]);
     4852#if ENABLE(INPUT_TYPE_COLOR)
     4853    case WebKit::InputType::Color:
     4854        return adoptNS([[WKFormColorControl alloc] initWithView:view]);
     4855#endif
     4856    default:
     4857        return adoptNS([[WKFormInputControl alloc] initWithView:view]);
     4858    }
     4859}
     4860
    48554861- (void)_elementDidFocus:(const WebKit::FocusedElementInformation&)information userIsInteracting:(BOOL)userIsInteracting blurPreviousNode:(BOOL)blurPreviousNode changingActivityState:(BOOL)changingActivityState userObject:(NSObject <NSSecureCoding> *)userObject
    48564862{
     
    49534959    BOOL editableChanged = [self setIsEditable:YES];
    49544960    _focusedElementInformation = information;
    4955     _inputPeripheral = nil;
    49564961    _traits = nil;
    49574962
    49584963    if (![self isFirstResponder])
    49594964        [self becomeFirstResponder];
     4965
     4966    _inputPeripheral = createInputPeripheralWithView(_focusedElementInformation.elementType, self);
    49604967
    49614968#if PLATFORM(WATCHOS)
Note: See TracChangeset for help on using the changeset viewer.