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

Changeset 243221 in webkit


Ignore:
Timestamp:
Mar 20, 2019, 11:59:03 AM (7 years ago)
Author:
dbates@webkit.org
Message:

[iOS] Group UIWebFormAccessoryDelegate-related code and tighten it up a bit
https://bugs.webkit.org/show_bug.cgi?id=196018

Reviewed by Wenson Hsieh.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView accessoryClear]): Use uniform initializer syntax. Code could send the empty
string, but I resisted since null string, as we do now, likely encodes more compactly and we
avoid a per-process alloc.
(-[WKContentView accessoryTab:]): Fix style nit; missing space between capture list and arguments
in lambda. Also use lamdba capture initializer syntax and remove a local.
(-[WKContentView _updateAccessory]): Remove a FIXME as it can't be satified with the current
design without more bookkeeping. The design for showing and hiding an AutoFill button added in
r166933 requires knowing the title for the button when showing it via -setAccessoryViewCustomButtonTitle.
We could re-implement such that -setAccessoryViewCustomButtonTitle: stores the title and calls
-_updateAccessory, but that has the disadvantage of increasing the memory footprint of WKContentView
for the stored title and that seems worse than centralizing the logic in _updateAccessory. So,
let's not fix this FIXME. Now that we are removing the FIXME, change to use an early return style.
(-[WKContentView _hideKeyboard]): Micro optimization; only call _updateAccessory if we have
a form accessory view. This method is called everytime we load a page (more precisely when we
commit the load for a page) in addition to everytime we blur (defocus) an element. No need to
update an accessory if we don't have one.

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r243212 r243221  
     12019-03-20  Daniel Bates  <dabates@apple.com>
     2
     3        [iOS] Group UIWebFormAccessoryDelegate-related code and tighten it up a bit
     4        https://bugs.webkit.org/show_bug.cgi?id=196018
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        * UIProcess/ios/WKContentViewInteraction.mm:
     9        (-[WKContentView accessoryClear]): Use uniform initializer syntax. Code could send the empty
     10        string, but I resisted since null string, as we do now, likely encodes more compactly and we
     11        avoid a per-process alloc.
     12        (-[WKContentView accessoryTab:]): Fix style nit; missing space between capture list and arguments
     13        in lambda. Also use lamdba capture initializer syntax and remove a local.
     14        (-[WKContentView _updateAccessory]): Remove a FIXME as it can't be satified with the current
     15        design without more bookkeeping. The design for showing and hiding an AutoFill button added in
     16        r166933 requires knowing the title for the button when showing it via -setAccessoryViewCustomButtonTitle.
     17        We could re-implement such that -setAccessoryViewCustomButtonTitle: stores the title and calls
     18        -_updateAccessory, but that has the disadvantage of increasing the memory footprint of WKContentView
     19        for the stored title and that seems worse than centralizing the logic in _updateAccessory. So,
     20        let's not fix this FIXME. Now that we are removing the FIXME, change to use an early return style.
     21        (-[WKContentView _hideKeyboard]): Micro optimization; only call _updateAccessory if we have
     22        a form accessory view. This method is called everytime we load a page (more precisely when we
     23        commit the load for a page) in addition to everytime we blur (defocus) an element. No need to
     24        update an accessory if we don't have one.
     25 
    1262019-03-20  Olivier Robin  <olivierrobin@chromium.org>
    227
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r243195 r243221  
    36943694}
    36953695
    3696 // UIWebFormAccessoryDelegate
    3697 - (void)accessoryDone
    3698 {
    3699     SetForScope<BOOL> dismissingAccessoryScope { _dismissingAccessory, YES };
    3700     [self resignFirstResponder];
    3701 }
    3702 
    37033696#if !USE(UIKIT_KEYBOARD_ADDITIONS)
    37043697- (NSArray *)keyCommands
     
    37233716{
    37243717    [self accessoryTab:NO];
    3725 }
    3726 
    3727 - (void)accessoryTab:(BOOL)isNext
    3728 {
    3729     [self _endEditing];
    3730     _inputPeripheral = nil;
    3731 
    3732     _isChangingFocusUsingAccessoryTab = YES;
    3733     [self beginSelectionChange];
    3734     RetainPtr<WKContentView> view = self;
    3735     _page->focusNextFocusedElement(isNext, [view](WebKit::CallbackBase::Error) {
    3736         [view endSelectionChange];
    3737         [view reloadInputViews];
    3738         view->_isChangingFocusUsingAccessoryTab = NO;
    3739     });
    37403718}
    37413719
     
    37733751}
    37743752
     3753// MARK: UIWebFormAccessoryDelegate protocol and accessory methods
     3754
     3755- (void)accessoryClear
     3756{
     3757    _page->setFocusedElementValue({ });
     3758}
     3759
     3760- (void)accessoryDone
     3761{
     3762    SetForScope<BOOL> dismissingAccessoryScope { _dismissingAccessory, YES };
     3763    [self resignFirstResponder];
     3764}
     3765
     3766- (void)accessoryTab:(BOOL)isNext
     3767{
     3768    [self _endEditing];
     3769    _inputPeripheral = nil;
     3770
     3771    _isChangingFocusUsingAccessoryTab = YES;
     3772    [self beginSelectionChange];
     3773    _page->focusNextFocusedElement(isNext, [protectedSelf = retainPtr(self)] (WebKit::CallbackBase::Error) {
     3774        [protectedSelf endSelectionChange];
     3775        [protectedSelf reloadInputViews];
     3776        protectedSelf->_isChangingFocusUsingAccessoryTab = NO;
     3777    });
     3778}
     3779
    37753780- (void)accessoryAutoFill
    37763781{
     
    37803785}
    37813786
    3782 - (void)accessoryClear
    3783 {
    3784     _page->setFocusedElementValue(String());
    3785 }
    3786 
    37873787- (void)_updateAccessory
    37883788{
     
    37903790    [_formAccessoryView setPreviousEnabled:_focusedElementInformation.hasPreviousNode];
    37913791
    3792     if (currentUserInterfaceIdiomIsPad())
     3792    if (currentUserInterfaceIdiomIsPad()) {
    37933793        [_formAccessoryView setClearVisible:NO];
    3794     else {
    3795         switch (_focusedElementInformation.elementType) {
    3796         case WebKit::InputType::Date:
    3797         case WebKit::InputType::Month:
    3798         case WebKit::InputType::DateTimeLocal:
    3799         case WebKit::InputType::Time:
    3800             [_formAccessoryView setClearVisible:YES];
    3801             break;
    3802         default:
    3803             [_formAccessoryView setClearVisible:NO];
    3804             break;
    3805         }
    3806     }
    3807 
    3808     // FIXME: hide or show the AutoFill button as needed.
    3809 }
    3810 
    3811 // Keyboard interaction
     3794        return;
     3795    }
     3796
     3797    switch (_focusedElementInformation.elementType) {
     3798    case WebKit::InputType::Date:
     3799    case WebKit::InputType::Month:
     3800    case WebKit::InputType::DateTimeLocal:
     3801    case WebKit::InputType::Time:
     3802        [_formAccessoryView setClearVisible:YES];
     3803        return;
     3804    default:
     3805        [_formAccessoryView setClearVisible:NO];
     3806        return;
     3807    }
     3808}
     3809
     3810// MARK: Keyboard interaction
    38123811// UITextInput protocol implementation
    38133812
     
    47834782    // FIXME: Does it make sense to call -reloadInputViews on watchOS?
    47844783    [self reloadInputViews];
    4785     [self _updateAccessory];
     4784    if (_formAccessoryView)
     4785        [self _updateAccessory];
    47864786}
    47874787
Note: See TracChangeset for help on using the changeset viewer.