[iOS] Inline -_ensureFormAccessoryView into -formAccessoryView and have -_updateAcces...
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2019 18:14:57 +0000 (18:14 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2019 18:14:57 +0000 (18:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196021

Reviewed by Wenson Hsieh.

Every caller of -_ensureFormAccessoryView, except -formAccessoryView, immediately follows the call
with a call to -_updateAccessory. Let's just have -_updateAccessory ensure we have a form accessory
view and inline the implementation of -_ensureFormAccessoryView into -formAccessoryView so we can
remove one method.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView inputView]): Remove call to -_ensureFormAccessoryView, -_updateAccessory will do
the equivalent work for us.
(-[WKContentView formAccessoryView]): Moved implementation of -_ensureFormAccessoryView into here.
(-[WKContentView _updateAccessory]): Call self.formAccessoryView to ensure we have a form accessory view.
(-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
Remove call to -_ensureFormAccessoryView, -_updateAccessory will do
the equivalent work for us.
(-[WKContentView _ensureFormAccessoryView]): Deleted.

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

index 988932e..df9348d 100644 (file)
@@ -1,3 +1,25 @@
+2019-03-21  Daniel Bates  <dabates@apple.com>
+
+        [iOS] Inline -_ensureFormAccessoryView into -formAccessoryView and have -_updateAccessory ensure we have a form accessory
+        https://bugs.webkit.org/show_bug.cgi?id=196021
+
+        Reviewed by Wenson Hsieh.
+
+        Every caller of -_ensureFormAccessoryView, except -formAccessoryView, immediately follows the call
+        with a call to -_updateAccessory. Let's just have -_updateAccessory ensure we have a form accessory
+        view and inline the implementation of -_ensureFormAccessoryView into -formAccessoryView so we can
+        remove one method.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView inputView]): Remove call to -_ensureFormAccessoryView, -_updateAccessory will do
+        the equivalent work for us.
+        (-[WKContentView formAccessoryView]): Moved implementation of -_ensureFormAccessoryView into here.
+        (-[WKContentView _updateAccessory]): Call self.formAccessoryView to ensure we have a form accessory view.
+        (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
+        Remove call to -_ensureFormAccessoryView, -_updateAccessory will do
+        the equivalent work for us.
+        (-[WKContentView _ensureFormAccessoryView]): Deleted.
+
 2019-03-21  Shawn Roberts  <sroberts@apple.com>
 
         Unreviewed, rolling out r243250.
index d58c467..edd13d1 100644 (file)
@@ -1665,7 +1665,6 @@ static NSValue *nsSizeForTapHighlightBorderRadius(WebCore::IntSize borderRadius,
         // For instance, one use case that currently relies on this detail is adjusting the zoom scale and viewport upon
         // rotation, when a select element is focused. See <https://webkit.org/b/192878> for more information.
         [self _zoomToRevealFocusedElement];
-        [self _ensureFormAccessoryView];
         [self _updateAccessory];
     }
 
@@ -2476,15 +2475,6 @@ static void cancelPotentialTapIfNecessary(WKContentView* contentView)
     return [super inputAssistantItem];
 }
 
-- (void)_ensureFormAccessoryView
-{
-    if (_formAccessoryView)
-        return;
-
-    _formAccessoryView = adoptNS([[UIWebFormAccessory alloc] initWithInputAssistantItem:self.inputAssistantItem]);
-    [_formAccessoryView setDelegate:self];
-}
-
 - (UIView *)inputAccessoryView
 {
     if (![self requiresAccessoryView])
@@ -3784,13 +3774,24 @@ static void selectionChangedWithTouch(WKContentView *view, const WebCore::IntPoi
         [inputDelegate _webView:_webView accessoryViewCustomButtonTappedInFormInputSession:_formInputSession.get()];
 }
 
+- (UIWebFormAccessory *)formAccessoryView
+{
+    if (_formAccessoryView)
+        return _formAccessoryView.get();
+    _formAccessoryView = adoptNS([[UIWebFormAccessory alloc] initWithInputAssistantItem:self.inputAssistantItem]);
+    [_formAccessoryView setDelegate:self];
+    return _formAccessoryView.get();
+}
+
 - (void)_updateAccessory
 {
-    [_formAccessoryView setNextEnabled:_focusedElementInformation.hasNextNode];
-    [_formAccessoryView setPreviousEnabled:_focusedElementInformation.hasPreviousNode];
+    auto* accessoryView = self.formAccessoryView; // Creates one, if needed.
+
+    [accessoryView setNextEnabled:_focusedElementInformation.hasNextNode];
+    [accessoryView setPreviousEnabled:_focusedElementInformation.hasPreviousNode];
 
     if (currentUserInterfaceIdiomIsPad()) {
-        [_formAccessoryView setClearVisible:NO];
+        [accessoryView setClearVisible:NO];
         return;
     }
 
@@ -3799,10 +3800,10 @@ static void selectionChangedWithTouch(WKContentView *view, const WebCore::IntPoi
     case WebKit::InputType::Month:
     case WebKit::InputType::DateTimeLocal:
     case WebKit::InputType::Time:
-        [_formAccessoryView setClearVisible:YES];
+        [accessoryView setClearVisible:YES];
         return;
     default:
-        [_formAccessoryView setClearVisible:NO];
+        [accessoryView setClearVisible:NO];
         return;
     }
 }
@@ -4795,12 +4796,6 @@ static NSString *contentTypeFromFieldName(WebCore::AutofillFieldName fieldName)
     return _focusedElementInformation.selectOptions;
 }
 
-- (UIWebFormAccessory *)formAccessoryView
-{
-    [self _ensureFormAccessoryView];
-    return _formAccessoryView.get();
-}
-
 static bool shouldDeferZoomingToSelectionWhenRevealingFocusedElement(WebKit::InputType type)
 {
     switch (type) {
@@ -4986,7 +4981,6 @@ static WebCore::FloatRect rectToRevealWhenZoomingToFocusedElement(const WebKit::
     if (!shouldDeferZoomingToSelectionWhenRevealingFocusedElement(_focusedElementInformation.elementType))
         [self _zoomToRevealFocusedElement];
 
-    [self _ensureFormAccessoryView];
     [self _updateAccessory];
 
 #if PLATFORM(WATCHOS)