- Revision
- 199040
- Author
- [email protected]
- Date
- 2016-04-04 21:22:54 -0700 (Mon, 04 Apr 2016)
Log Message
[iOS] Allow clients in the bundle to know whether a field was focused by user interaction
https://bugs.webkit.org/show_bug.cgi?id=156118
Patch by Chelsea Pugh <[email protected]> on 2016-04-04
Reviewed by Dan Bernstein.
* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFormDelegatePrivate.h: Add delegate method that takes userIsInteracting bool so that bundle clients get this information.
* WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm: Call API with userIsInteracting property if delegate implements it, otherwise call existing API if
userIsInteracting is true, as we previously did in WebKit::WebPage::elementDidFocus. Move FIXME from WebKit::WebPage::elementDidFocus to here, since we are checking userIsInteracting.
* WebProcess/InjectedBundle/APIInjectedBundleFormClient.h:
(API::InjectedBundle::FormClient::willBeginInputSession): Add userIsInteracting bool to arguments so we can use it for call to the new API as well as preserving behavior of the old API.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::elementDidFocus): Remove check if user is interacting and call willBeginInputSession unconditionally. Move FIXME to where we check
userIsInteracting. Pass m_userIsInteracting to willBeginInputSession so we can use it there.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (199039 => 199040)
--- trunk/Source/WebKit2/ChangeLog 2016-04-05 04:12:48 UTC (rev 199039)
+++ trunk/Source/WebKit2/ChangeLog 2016-04-05 04:22:54 UTC (rev 199040)
@@ -1,3 +1,19 @@
+2016-04-04 Chelsea Pugh <[email protected]>
+
+ [iOS] Allow clients in the bundle to know whether a field was focused by user interaction
+ https://bugs.webkit.org/show_bug.cgi?id=156118
+
+ Reviewed by Dan Bernstein.
+
+ * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFormDelegatePrivate.h: Add delegate method that takes userIsInteracting bool so that bundle clients get this information.
+ * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm: Call API with userIsInteracting property if delegate implements it, otherwise call existing API if
+ userIsInteracting is true, as we previously did in WebKit::WebPage::elementDidFocus. Move FIXME from WebKit::WebPage::elementDidFocus to here, since we are checking userIsInteracting.
+ * WebProcess/InjectedBundle/APIInjectedBundleFormClient.h:
+ (API::InjectedBundle::FormClient::willBeginInputSession): Add userIsInteracting bool to arguments so we can use it for call to the new API as well as preserving behavior of the old API.
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::elementDidFocus): Remove check if user is interacting and call willBeginInputSession unconditionally. Move FIXME to where we check
+ userIsInteracting. Pass m_userIsInteracting to willBeginInputSession so we can use it there.
+
2016-04-04 Michael Catanzaro <[email protected]>
Unreviewed GTK build fix after r199020
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFormDelegatePrivate.h (199039 => 199040)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFormDelegatePrivate.h 2016-04-05 04:12:48 UTC (rev 199039)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFormDelegatePrivate.h 2016-04-05 04:22:54 UTC (rev 199040)
@@ -44,6 +44,7 @@
// The return value is exposed in the UI process via the userObject property of the _WKFormInputSession object.
- (NSObject <NSSecureCoding> *)_webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller willBeginInputSessionForElement:(WKWebProcessPlugInNodeHandle *)node inFrame:(WKWebProcessPlugInFrame *)frame;
+- (NSObject <NSSecureCoding> *)_webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller willBeginInputSessionForElement:(WKWebProcessPlugInNodeHandle *)node inFrame:(WKWebProcessPlugInFrame *)frame userIsInteracting:(BOOL)userIsInteracting WK_AVAILABLE(NA, WK_IOS_TBA);
- (BOOL)_webProcessPlugInBrowserContextControllerShouldNotifyOnFormChanges:(WKWebProcessPlugInBrowserContextController *)controller;
- (void)_webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller didAssociateFormControls:(NSArray *)elements;
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm (199039 => 199040)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm 2016-04-05 04:12:48 UTC (rev 199039)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm 2016-04-05 04:22:54 UTC (rev 199040)
@@ -515,15 +515,21 @@
[formDelegate _webProcessPlugInBrowserContextController:m_controller textDidChangeInTextField:wrapper(*WebKit::InjectedBundleNodeHandle::getOrCreate(inputElement)) inFrame:wrapper(*frame) initiatedByUserTyping:initiatedByUserTyping];
}
- void willBeginInputSession(WebPage*, Element* element, WebFrame* frame, RefPtr<API::Object>& userData) override
+ void willBeginInputSession(WebPage*, Element* element, WebFrame* frame, RefPtr<API::Object>& userData, bool userIsInteracting) override
{
auto formDelegate = m_controller->_formDelegate.get();
- if (![formDelegate respondsToSelector:@selector(_webProcessPlugInBrowserContextController:willBeginInputSessionForElement:inFrame:)])
- return;
-
- NSObject <NSSecureCoding> *userObject = [formDelegate _webProcessPlugInBrowserContextController:m_controller willBeginInputSessionForElement:wrapper(*WebKit::InjectedBundleNodeHandle::getOrCreate(element)) inFrame:wrapper(*frame)];
- encodeUserObject(userObject, userData);
+ if ([formDelegate respondsToSelector:@selector(_webProcessPlugInBrowserContextController:willBeginInputSessionForElement:inFrame:userIsInteracting:)]) {
+ NSObject<NSSecureCoding> *userObject = [formDelegate _webProcessPlugInBrowserContextController:m_controller willBeginInputSessionForElement:wrapper(*WebKit::InjectedBundleNodeHandle::getOrCreate(element)) inFrame:wrapper(*frame) userIsInteracting:userIsInteracting];
+ encodeUserObject(userObject, userData);
+ } else if (userIsInteracting && [formDelegate respondsToSelector:@selector(_webProcessPlugInBrowserContextController:willBeginInputSessionForElement:inFrame:)]) {
+ // FIXME: We check userIsInteracting so that we don't begin an input session for a
+ // programmatic focus that doesn't cause the keyboard to appear. But this misses the case of
+ // a programmatic focus happening while the keyboard is already shown. Once we have a way to
+ // know the keyboard state in the Web Process, we should refine the condition.
+ NSObject<NSSecureCoding> *userObject = [formDelegate _webProcessPlugInBrowserContextController:m_controller willBeginInputSessionForElement:wrapper(*WebKit::InjectedBundleNodeHandle::getOrCreate(element)) inFrame:wrapper(*frame)];
+ encodeUserObject(userObject, userData);
+ }
}
bool shouldNotifyOnFormChanges(WebKit::WebPage*) override
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/APIInjectedBundleFormClient.h (199039 => 199040)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/APIInjectedBundleFormClient.h 2016-04-05 04:12:48 UTC (rev 199039)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/APIInjectedBundleFormClient.h 2016-04-05 04:22:54 UTC (rev 199040)
@@ -72,7 +72,7 @@
virtual void willSendSubmitEvent(WebKit::WebPage*, WebCore::HTMLFormElement*, WebKit::WebFrame*, WebKit::WebFrame*, const Vector<std::pair<WTF::String, WTF::String>>&) { }
virtual void didAssociateFormControls(WebKit::WebPage*, const Vector<RefPtr<WebCore::Element>>&) { }
virtual bool shouldNotifyOnFormChanges(WebKit::WebPage*) { return false; }
- virtual void willBeginInputSession(WebKit::WebPage*, WebCore::Element*, WebKit::WebFrame*, RefPtr<API::Object>& userData) { UNUSED_PARAM(userData); }
+ virtual void willBeginInputSession(WebKit::WebPage*, WebCore::Element*, WebKit::WebFrame*, RefPtr<API::Object>& userData, bool userIsInteracting) { UNUSED_PARAM(userData); }
};
} // namespace InjectedBundle
Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (199039 => 199040)
--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm 2016-04-05 04:12:48 UTC (rev 199039)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm 2016-04-05 04:22:54 UTC (rev 199040)
@@ -2548,12 +2548,7 @@
getAssistedNodeInformation(information);
RefPtr<API::Object> userData;
- // FIXME: We check m_userIsInteracting so that we don't begin an input session for a
- // programmatic focus that doesn't cause the keyboard to appear. But this misses the case of
- // a programmatic focus happening while the keyboard is already shown. Once we have a way to
- // know the keyboard state in the Web Process, we should refine the condition.
- if (m_userIsInteracting)
- m_formClient->willBeginInputSession(this, downcast<Element>(node), WebFrame::fromCoreFrame(*node->document().frame()), userData);
+ m_formClient->willBeginInputSession(this, downcast<Element>(node), WebFrame::fromCoreFrame(*node->document().frame()), userData, m_userIsInteracting);
send(Messages::WebPageProxy::StartAssistingNode(information, m_userIsInteracting, m_hasPendingBlurNotification, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
m_hasPendingBlurNotification = false;