Title: [243302] trunk/Source/WebKit
Revision
243302
Author
[email protected]
Date
2019-03-21 11:14:57 -0700 (Thu, 21 Mar 2019)

Log Message

[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.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (243301 => 243302)


--- trunk/Source/WebKit/ChangeLog	2019-03-21 18:03:02 UTC (rev 243301)
+++ trunk/Source/WebKit/ChangeLog	2019-03-21 18:14:57 UTC (rev 243302)
@@ -1,3 +1,25 @@
+2019-03-21  Daniel Bates  <[email protected]>
+
+        [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  <[email protected]>
 
         Unreviewed, rolling out r243250.

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (243301 => 243302)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-03-21 18:03:02 UTC (rev 243301)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-03-21 18:14:57 UTC (rev 243302)
@@ -1665,7 +1665,6 @@
         // 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 @@
     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 @@
         [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 @@
     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 @@
     return _focusedElementInformation.selectOptions;
 }
 
-- (UIWebFormAccessory *)formAccessoryView
-{
-    [self _ensureFormAccessoryView];
-    return _formAccessoryView.get();
-}
-
 static bool shouldDeferZoomingToSelectionWhenRevealingFocusedElement(WebKit::InputType type)
 {
     switch (type) {
@@ -4986,7 +4981,6 @@
     if (!shouldDeferZoomingToSelectionWhenRevealingFocusedElement(_focusedElementInformation.elementType))
         [self _zoomToRevealFocusedElement];
 
-    [self _ensureFormAccessoryView];
     [self _updateAccessory];
 
 #if PLATFORM(WATCHOS)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to