Title: [243630] trunk/Source/WebKit
Revision
243630
Author
[email protected]
Date
2019-03-28 16:30:52 -0700 (Thu, 28 Mar 2019)

Log Message

[iOS] Automatic focus of input field is flaky
https://bugs.webkit.org/show_bug.cgi?id=196302

Reviewed by Brent Fulgham.

Sometimes the status of whether a keyboard is connected can be incorrect, both in the UI process, and in
the WebContent process. Fix this by sending the keyboard status to the WebContent process as part of the
Web page creation parameters. Stop caching the keyboard status in the Web process proxy, and call
[UIKeyboard isInHardwareKeyboardMode] instead, since this method is swizzled in the test harness.

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode const):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(hardwareKeyboardAvailabilityChangedCallback):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::creationParameters):
* UIProcess/WebPageProxy.h:
* UIProcess/WebProcessProxy.cpp:
* UIProcess/WebProcessProxy.h:
(WebKit::WebProcessProxy::setKeyboardIsAttached): Deleted.
(WebKit::WebProcessProxy::keyboardIsAttached const): Deleted.
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::isInHardwareKeyboardMode):
(WebKit::WebPageProxy::applicationWillEnterForeground):
* WebProcess/WebPage/WebPage.cpp:
* WebProcess/WebPage/WebPage.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (243629 => 243630)


--- trunk/Source/WebKit/ChangeLog	2019-03-28 23:11:43 UTC (rev 243629)
+++ trunk/Source/WebKit/ChangeLog	2019-03-28 23:30:52 UTC (rev 243630)
@@ -1,3 +1,36 @@
+2019-03-28  Per Arne Vollan  <[email protected]>
+
+        [iOS] Automatic focus of input field is flaky
+        https://bugs.webkit.org/show_bug.cgi?id=196302
+
+        Reviewed by Brent Fulgham.
+
+        Sometimes the status of whether a keyboard is connected can be incorrect, both in the UI process, and in
+        the WebContent process. Fix this by sending the keyboard status to the WebContent process as part of the
+        Web page creation parameters. Stop caching the keyboard status in the Web process proxy, and call
+        [UIKeyboard isInHardwareKeyboardMode] instead, since this method is swizzled in the test harness.
+
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode const):
+        (WebKit::WebPageCreationParameters::decode):
+        * Shared/WebPageCreationParameters.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (hardwareKeyboardAvailabilityChangedCallback):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::creationParameters):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebProcessProxy.cpp:
+        * UIProcess/WebProcessProxy.h:
+        (WebKit::WebProcessProxy::setKeyboardIsAttached): Deleted.
+        (WebKit::WebProcessProxy::keyboardIsAttached const): Deleted.
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::isInHardwareKeyboardMode):
+        (WebKit::WebPageProxy::applicationWillEnterForeground):
+        * WebProcess/WebPage/WebPage.cpp:
+        * WebProcess/WebPage/WebPage.h:
+
 2019-03-28  Tim Horton  <[email protected]>
 
         Fix the build.

Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp (243629 => 243630)


--- trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp	2019-03-28 23:11:43 UTC (rev 243629)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp	2019-03-28 23:30:52 UTC (rev 243630)
@@ -93,6 +93,7 @@
     encoder << viewportConfigurationViewSize;
     encoder << maximumUnobscuredSize;
     encoder << deviceOrientation;
+    encoder << keyboardIsAttached;
 #endif
 #if PLATFORM(COCOA)
     encoder << smartInsertDeleteEnabled;
@@ -273,6 +274,8 @@
         return WTF::nullopt;
     if (!decoder.decode(parameters.deviceOrientation))
         return WTF::nullopt;
+    if (!decoder.decode(parameters.keyboardIsAttached))
+        return WTF::nullopt;
 #endif
 
 #if PLATFORM(COCOA)

Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.h (243629 => 243630)


--- trunk/Source/WebKit/Shared/WebPageCreationParameters.h	2019-03-28 23:11:43 UTC (rev 243629)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.h	2019-03-28 23:30:52 UTC (rev 243630)
@@ -151,6 +151,7 @@
     WebCore::FloatSize viewportConfigurationViewSize;
     WebCore::FloatSize maximumUnobscuredSize;
     int32_t deviceOrientation { 0 };
+    bool keyboardIsAttached { false };
 #endif
 #if PLATFORM(COCOA)
     bool smartInsertDeleteEnabled;

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (243629 => 243630)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2019-03-28 23:11:43 UTC (rev 243629)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2019-03-28 23:30:52 UTC (rev 243630)
@@ -3322,9 +3322,7 @@
 {
     ASSERT(observer);
     WKWebView *webView = (__bridge WKWebView *)observer;
-    auto keyboardIsAttached = GSEventIsHardwareKeyboardAttached();
-    webView._page->process().setKeyboardIsAttached(keyboardIsAttached);
-    webView._page->hardwareKeyboardAvailabilityChanged(keyboardIsAttached);
+    webView._page->hardwareKeyboardAvailabilityChanged(GSEventIsHardwareKeyboardAttached());
 }
 
 - (void)_windowDidRotate:(NSNotification *)notification

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (243629 => 243630)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-03-28 23:11:43 UTC (rev 243629)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-03-28 23:30:52 UTC (rev 243630)
@@ -7022,6 +7022,7 @@
     parameters.viewportConfigurationLayoutSizeScaleFactor = m_viewportConfigurationLayoutSizeScaleFactor;
     parameters.maximumUnobscuredSize = m_maximumUnobscuredSize;
     parameters.deviceOrientation = m_deviceOrientation;
+    parameters.keyboardIsAttached = isInHardwareKeyboardMode();
 #endif
 
 #if PLATFORM(MAC)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (243629 => 243630)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-03-28 23:11:43 UTC (rev 243629)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-03-28 23:30:52 UTC (rev 243630)
@@ -2050,6 +2050,10 @@
     SpeechSynthesisData& speechSynthesisData();
 #endif
 
+#if PLATFORM(IOS_FAMILY)
+    static bool isInHardwareKeyboardMode();
+#endif
+
     WeakPtr<PageClient> m_pageClient;
     Ref<API::PageConfiguration> m_configuration;
 

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.h (243629 => 243630)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2019-03-28 23:11:43 UTC (rev 243629)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2019-03-28 23:30:52 UTC (rev 243630)
@@ -275,11 +275,6 @@
     void sendProcessDidResume() override;
     void didSetAssertionState(AssertionState) override;
 
-#if PLATFORM(IOS_FAMILY)
-    void setKeyboardIsAttached(bool keyboardIsAttached) { m_keyboardIsAttached = keyboardIsAttached; }
-    bool keyboardIsAttached() const { return m_keyboardIsAttached; }
-#endif
-
 #if PLATFORM(COCOA)
     enum SandboxExtensionType : uint32_t {
         None = 0,
@@ -475,10 +470,6 @@
     ProcessThrottler::BackgroundActivityToken m_backgroundActivityTokenForFullscreenFormControls;
 #endif
 
-#if PLATFORM(IOS_FAMILY)
-    bool m_keyboardIsAttached { false };
-#endif
-
 #if PLATFORM(COCOA)
     MediaCaptureSandboxExtensions m_mediaCaptureSandboxExtensions { SandboxExtensionType::None };
 #endif

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (243629 => 243630)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-03-28 23:11:43 UTC (rev 243629)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-03-28 23:30:52 UTC (rev 243630)
@@ -4930,7 +4930,7 @@
                 if (_isChangingFocus)
                     return YES;
 
-                if (_page->process().keyboardIsAttached())
+                if ([UIKeyboard isInHardwareKeyboardMode])
                     return YES;
 #endif
             }

Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (243629 => 243630)


--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2019-03-28 23:11:43 UTC (rev 243629)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2019-03-28 23:30:52 UTC (rev 243630)
@@ -663,12 +663,16 @@
     m_process->send(Messages::WebPage::ApplicationDidFinishSnapshottingAfterEnteringBackground(), m_pageID);
 }
 
+bool WebPageProxy::isInHardwareKeyboardMode()
+{
+    return [UIKeyboard isInHardwareKeyboardMode];
+}
+
 void WebPageProxy::applicationWillEnterForeground()
 {
     bool isSuspendedUnderLock = [UIApp isSuspendedUnderLock];
     m_process->send(Messages::WebPage::ApplicationWillEnterForeground(isSuspendedUnderLock), m_pageID);
-    m_process->setKeyboardIsAttached([UIKeyboard isInHardwareKeyboardMode]);
-    m_process->send(Messages::WebPage::HardwareKeyboardAvailabilityChanged(m_process->keyboardIsAttached()), m_pageID);
+    m_process->send(Messages::WebPage::HardwareKeyboardAvailabilityChanged(isInHardwareKeyboardMode()), m_pageID);
 }
 
 void WebPageProxy::applicationWillResignActive()

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (243629 => 243630)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-03-28 23:11:43 UTC (rev 243629)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-03-28 23:30:52 UTC (rev 243630)
@@ -406,6 +406,7 @@
     , m_availableScreenSize(parameters.availableScreenSize)
     , m_overrideScreenSize(parameters.overrideScreenSize)
     , m_deviceOrientation(parameters.deviceOrientation)
+    , m_keyboardIsAttached(parameters.keyboardIsAttached)
 #endif
     , m_layerVolatilityTimer(*this, &WebPage::layerVolatilityTimerFired)
     , m_activityState(parameters.activityState)

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (243629 => 243630)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-03-28 23:11:43 UTC (rev 243629)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-03-28 23:30:52 UTC (rev 243630)
@@ -1804,6 +1804,7 @@
     WebCore::IntSize m_blockSelectionDesiredSize;
     WebCore::FloatSize m_maximumUnobscuredSize;
     int32_t m_deviceOrientation { 0 };
+    bool m_keyboardIsAttached { false };
     bool m_inDynamicSizeUpdate { false };
     HashMap<std::pair<WebCore::IntSize, double>, WebCore::IntPoint> m_dynamicSizeUpdateHistory;
     RefPtr<WebCore::Node> m_pendingSyntheticClickNode;
@@ -1884,9 +1885,6 @@
     OptionSet<LayerTreeFreezeReason> m_LayerTreeFreezeReasons;
     bool m_isSuspended { false };
     bool m_needsFontAttributes { false };
-#if PLATFORM(IOS_FAMILY)
-    bool m_keyboardIsAttached { false };
-#endif
 };
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to