Changeset 243221 in webkit
- Timestamp:
- Mar 20, 2019, 11:59:03 AM (7 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
UIProcess/ios/WKContentViewInteraction.mm (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r243212 r243221 1 2019-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 1 26 2019-03-20 Olivier Robin <olivierrobin@chromium.org> 2 27 -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r243195 r243221 3694 3694 } 3695 3695 3696 // UIWebFormAccessoryDelegate3697 - (void)accessoryDone3698 {3699 SetForScope<BOOL> dismissingAccessoryScope { _dismissingAccessory, YES };3700 [self resignFirstResponder];3701 }3702 3703 3696 #if !USE(UIKIT_KEYBOARD_ADDITIONS) 3704 3697 - (NSArray *)keyCommands … … 3723 3716 { 3724 3717 [self accessoryTab:NO]; 3725 }3726 3727 - (void)accessoryTab:(BOOL)isNext3728 {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 });3740 3718 } 3741 3719 … … 3773 3751 } 3774 3752 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 3775 3780 - (void)accessoryAutoFill 3776 3781 { … … 3780 3785 } 3781 3786 3782 - (void)accessoryClear3783 {3784 _page->setFocusedElementValue(String());3785 }3786 3787 3787 - (void)_updateAccessory 3788 3788 { … … 3790 3790 [_formAccessoryView setPreviousEnabled:_focusedElementInformation.hasPreviousNode]; 3791 3791 3792 if (currentUserInterfaceIdiomIsPad()) 3792 if (currentUserInterfaceIdiomIsPad()) { 3793 3793 [_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 3812 3811 // UITextInput protocol implementation 3813 3812 … … 4783 4782 // FIXME: Does it make sense to call -reloadInputViews on watchOS? 4784 4783 [self reloadInputViews]; 4785 [self _updateAccessory]; 4784 if (_formAccessoryView) 4785 [self _updateAccessory]; 4786 4786 } 4787 4787
Note:
See TracChangeset
for help on using the changeset viewer.