Title: [241311] trunk/Source/WebKit
Revision
241311
Author
[email protected]
Date
2019-02-12 12:30:20 -0800 (Tue, 12 Feb 2019)

Log Message

Switching focus from a UITextField to an editable WKWebView causes the keyboard to dance
https://bugs.webkit.org/show_bug.cgi?id=194524
<rdar://problem/35481797>

Reviewed by Wenson Hsieh.

* Platform/spi/ios/UIKitSPI.h:
* UIProcess/ios/InputViewUpdateDeferrer.h:
* UIProcess/ios/InputViewUpdateDeferrer.mm:
(WebKit::InputViewUpdateDeferrer::InputViewUpdateDeferrer):
(WebKit::InputViewUpdateDeferrer::~InputViewUpdateDeferrer):
Make use of the per-responder and much safer input view pinning mechanism.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView becomeFirstResponderForWebView]):
(-[WKContentView _singleTapCommited:]):
(-[WKContentView _attemptClickAtLocation:modifierFlags:]):
Always temporarily pin input views when becoming first responder; there are
many paths (such as through the text interaction assistant) that can
focus us on tap, trying to cover them all is a fool's errand. We'll
just get out the big hammer and call it in becomeFirstResponder.
This also means we can remove it from _singleTapCommitted and _attemptClick...

(-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
Don't release the input view pinning until we return from _elementDidFocus;
it does the rebuilding synchronously, so we need to have actually updated
all of the prerequisites of -inputView before depinning.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (241310 => 241311)


--- trunk/Source/WebKit/ChangeLog	2019-02-12 20:11:49 UTC (rev 241310)
+++ trunk/Source/WebKit/ChangeLog	2019-02-12 20:30:20 UTC (rev 241311)
@@ -1,3 +1,33 @@
+2019-02-12  Tim Horton  <[email protected]>
+
+        Switching focus from a UITextField to an editable WKWebView causes the keyboard to dance
+        https://bugs.webkit.org/show_bug.cgi?id=194524
+        <rdar://problem/35481797>
+
+        Reviewed by Wenson Hsieh.
+
+        * Platform/spi/ios/UIKitSPI.h:
+        * UIProcess/ios/InputViewUpdateDeferrer.h:
+        * UIProcess/ios/InputViewUpdateDeferrer.mm:
+        (WebKit::InputViewUpdateDeferrer::InputViewUpdateDeferrer):
+        (WebKit::InputViewUpdateDeferrer::~InputViewUpdateDeferrer):
+        Make use of the per-responder and much safer input view pinning mechanism.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView becomeFirstResponderForWebView]):
+        (-[WKContentView _singleTapCommited:]):
+        (-[WKContentView _attemptClickAtLocation:modifierFlags:]):
+        Always temporarily pin input views when becoming first responder; there are
+        many paths (such as through the text interaction assistant) that can
+        focus us on tap, trying to cover them all is a fool's errand. We'll
+        just get out the big hammer and call it in becomeFirstResponder.
+        This also means we can remove it from _singleTapCommitted and _attemptClick...
+
+        (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
+        Don't release the input view pinning until we return from _elementDidFocus;
+        it does the rebuilding synchronously, so we need to have actually updated
+        all of the prerequisites of -inputView before depinning.
+
 2019-02-12  Youenn Fablet  <[email protected]>
 
         Make use of is<SubresourceLoader>

Modified: trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h (241310 => 241311)


--- trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h	2019-02-12 20:11:49 UTC (rev 241310)
+++ trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h	2019-02-12 20:30:20 UTC (rev 241311)
@@ -321,6 +321,8 @@
 @interface UIResponder ()
 - (void)_handleKeyUIEvent:(UIEvent *)event;
 - (void)_wheelChangedWithEvent:(UIEvent *)event;
+- (void)_beginPinningInputViews;
+- (void)_endPinningInputViews;
 @end
 
 @class FBSDisplayConfiguration;
@@ -1078,9 +1080,6 @@
 @end
 
 @interface UIPeripheralHost (IPI)
-- (void)_beginIgnoringReloadInputViews;
-- (int)_endIgnoringReloadInputViews;
-- (void)forceReloadInputViews;
 - (CGFloat)getVerticalOverlapForView:(UIView *)view usingKeyboardInfo:(NSDictionary *)info;
 @end
 

Modified: trunk/Source/WebKit/UIProcess/ios/InputViewUpdateDeferrer.h (241310 => 241311)


--- trunk/Source/WebKit/UIProcess/ios/InputViewUpdateDeferrer.h	2019-02-12 20:11:49 UTC (rev 241310)
+++ trunk/Source/WebKit/UIProcess/ios/InputViewUpdateDeferrer.h	2019-02-12 20:30:20 UTC (rev 241311)
@@ -24,16 +24,21 @@
  */
 
 #import <wtf/Noncopyable.h>
+#import <wtf/WeakObjCPtr.h>
 
 #if PLATFORM(IOS_FAMILY)
 
+OBJC_CLASS UIView;
+
 namespace WebKit {
 
 class InputViewUpdateDeferrer {
     WTF_MAKE_NONCOPYABLE(InputViewUpdateDeferrer);
 public:
-    InputViewUpdateDeferrer();
+    explicit InputViewUpdateDeferrer(UIView *);
     ~InputViewUpdateDeferrer();
+
+    WeakObjCPtr<UIView> m_view;
 };
 
 }

Modified: trunk/Source/WebKit/UIProcess/ios/InputViewUpdateDeferrer.mm (241310 => 241311)


--- trunk/Source/WebKit/UIProcess/ios/InputViewUpdateDeferrer.mm	2019-02-12 20:11:49 UTC (rev 241310)
+++ trunk/Source/WebKit/UIProcess/ios/InputViewUpdateDeferrer.mm	2019-02-12 20:30:20 UTC (rev 241311)
@@ -32,15 +32,15 @@
 
 namespace WebKit {
 
-InputViewUpdateDeferrer::InputViewUpdateDeferrer()
+InputViewUpdateDeferrer::InputViewUpdateDeferrer(UIView *view)
+    : m_view(view)
 {
-    [[UIPeripheralHost sharedInstance] _beginIgnoringReloadInputViews];
+    [m_view _beginPinningInputViews];
 }
 
 InputViewUpdateDeferrer::~InputViewUpdateDeferrer()
 {
-    if ([[UIPeripheralHost sharedInstance] _endIgnoringReloadInputViews])
-        [[UIPeripheralHost sharedInstance] forceReloadInputViews];
+    [m_view _endPinningInputViews];
 }
     
 }

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (241310 => 241311)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-02-12 20:11:49 UTC (rev 241310)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-02-12 20:30:20 UTC (rev 241311)
@@ -1091,6 +1091,9 @@
     if (_resigningFirstResponder)
         return NO;
 
+    if (!_inputViewUpdateDeferrer)
+        _inputViewUpdateDeferrer = std::make_unique<WebKit::InputViewUpdateDeferrer>(self);
+
     BOOL didBecomeFirstResponder;
     {
         SetForScope<BOOL> becomingFirstResponder { _becomingFirstResponder, YES };
@@ -1097,11 +1100,13 @@
         didBecomeFirstResponder = [super becomeFirstResponder];
     }
 
-    if (didBecomeFirstResponder)
+    if (didBecomeFirstResponder) {
         _page->activityStateDidChange(WebCore::ActivityState::IsFocused);
 
-    if (didBecomeFirstResponder && [self canShowNonEmptySelectionView])
-        [_textSelectionAssistant activateSelection];
+        if ([self canShowNonEmptySelectionView])
+            [_textSelectionAssistant activateSelection];
+    } else
+        _inputViewUpdateDeferrer = nullptr;
 
     return didBecomeFirstResponder;
 }
@@ -2177,11 +2182,8 @@
 {
     ASSERT(gestureRecognizer == _singleTapGestureRecognizer);
 
-    if (![self isFirstResponder]) {
-        if (!_inputViewUpdateDeferrer)
-            _inputViewUpdateDeferrer = std::make_unique<WebKit::InputViewUpdateDeferrer>();
+    if (![self isFirstResponder])
         [self becomeFirstResponder];
-    }
 
     ASSERT(_potentialTapInProgress);
 
@@ -2236,11 +2238,8 @@
 
 - (void)_attemptClickAtLocation:(CGPoint)location modifierFlags:(UIKeyModifierFlags)modifierFlags
 {
-    if (![self isFirstResponder]) {
-        if (!_inputViewUpdateDeferrer)
-            _inputViewUpdateDeferrer = std::make_unique<WebKit::InputViewUpdateDeferrer>();
+    if (![self isFirstResponder])
         [self becomeFirstResponder];
-    }
 
     [_inputPeripheral endEditing];
     _page->handleTap(location, WebKit::webEventModifierFlags(modifierFlags), _layerTreeTransactionIdAtLastTouchStart);
@@ -4591,7 +4590,7 @@
 - (void)_elementDidFocus:(const WebKit::FocusedElementInformation&)information userIsInteracting:(BOOL)userIsInteracting blurPreviousNode:(BOOL)blurPreviousNode changingActivityState:(BOOL)changingActivityState userObject:(NSObject <NSSecureCoding> *)userObject
 {
     SetForScope<BOOL> isChangingFocusForScope { _isChangingFocus, hasFocusedElement(_focusedElementInformation) };
-    _inputViewUpdateDeferrer = nullptr;
+    auto inputViewUpdateDeferrer = std::exchange(_inputViewUpdateDeferrer, nullptr);
 
     _didAccessoryTabInitiateFocus = _isChangingFocusUsingAccessoryTab;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to