Title: [244559] trunk/Source/WebKit
Revision
244559
Author
pvol...@apple.com
Date
2019-04-23 13:27:24 -0700 (Tue, 23 Apr 2019)

Log Message

[iOS] Input field on ddg.gg is auto focused when url is entered with the software keyboard
https://bugs.webkit.org/show_bug.cgi?id=196740

Reviewed by Megan Gardner.

When an url for a page with an autofocused input field  is entered with the software keyboard,
the input field is auto selected, and the software keyboard reappears. This does not happen
when picking the url from favorites. After using the software keyboard to enter the url, the
activity state is being changed to focused. The method '_elementDidFocus' checks whether the
activity state changed, and allows the software keyboard to be shown in this case. To avoid
showing the software keyboard in this case, send the changing activity state bitfield to the
UI process, and check if the focus flag is the only flag set.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (244558 => 244559)


--- trunk/Source/WebKit/ChangeLog	2019-04-23 20:25:59 UTC (rev 244558)
+++ trunk/Source/WebKit/ChangeLog	2019-04-23 20:27:24 UTC (rev 244559)
@@ -1,3 +1,21 @@
+2019-04-23  Per Arne Vollan  <pvol...@apple.com>
+
+        [iOS] Input field on ddg.gg is auto focused when url is entered with the software keyboard
+        https://bugs.webkit.org/show_bug.cgi?id=196740
+
+        Reviewed by Megan Gardner.
+
+        When an url for a page with an autofocused input field  is entered with the software keyboard,
+        the input field is auto selected, and the software keyboard reappears. This does not happen
+        when picking the url from favorites. After using the software keyboard to enter the url, the
+        activity state is being changed to focused. The method '_elementDidFocus' checks whether the
+        activity state changed, and allows the software keyboard to be shown in this case. To avoid
+        showing the software keyboard in this case, send the changing activity state bitfield to the
+        UI process, and check if the focus flag is the only flag set.
+  
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
+
 2019-04-23  Guy Lewin  <g...@lewin.co.il>
 
         Multiple File Input Icon Set Regardless of File List

Modified: trunk/Source/WebKit/UIProcess/PageClient.h (244558 => 244559)


--- trunk/Source/WebKit/UIProcess/PageClient.h	2019-04-23 20:25:59 UTC (rev 244558)
+++ trunk/Source/WebKit/UIProcess/PageClient.h	2019-04-23 20:27:24 UTC (rev 244559)
@@ -31,6 +31,7 @@
 #include "WebColorPicker.h"
 #include "WebDataListSuggestionsDropdown.h"
 #include "WebPopupMenuProxy.h"
+#include <WebCore/ActivityState.h>
 #include <WebCore/AlternativeTextClient.h>
 #include <WebCore/DragActions.h>
 #include <WebCore/EditorClient.h>
@@ -382,7 +383,7 @@
     virtual void restorePageState(Optional<WebCore::FloatPoint> scrollPosition, const WebCore::FloatPoint& scrollOrigin, const WebCore::FloatBoxExtent& obscuredInsetsOnSave, double scale) = 0;
     virtual void restorePageCenterAndScale(Optional<WebCore::FloatPoint> center, double scale) = 0;
 
-    virtual void elementDidFocus(const FocusedElementInformation&, bool userIsInteracting, bool blurPreviousNode, bool changingActivityState, API::Object* userData) = 0;
+    virtual void elementDidFocus(const FocusedElementInformation&, bool userIsInteracting, bool blurPreviousNode, OptionSet<WebCore::ActivityState::Flag> activityStateChanges, API::Object* userData) = 0;
     virtual void elementDidBlur() = 0;
     virtual void focusedElementDidChangeInputMode(WebCore::InputMode) = 0;
     virtual void didReceiveEditorStateUpdateAfterFocus() = 0;

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (244558 => 244559)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-04-23 20:25:59 UTC (rev 244558)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-04-23 20:27:24 UTC (rev 244559)
@@ -347,7 +347,7 @@
     FocusedElementInformation information;
     bool userIsInteracting;
     bool blurPreviousNode;
-    bool changingActivityState;
+    OptionSet<WebCore::ActivityState::Flag> activityStateChanges;
     RefPtr<API::Object> userData;
 };
 
@@ -1907,7 +1907,7 @@
 
     void didGetTapHighlightGeometries(uint64_t requestID, const WebCore::Color& color, const Vector<WebCore::FloatQuad>& geometries, const WebCore::IntSize& topLeftRadius, const WebCore::IntSize& topRightRadius, const WebCore::IntSize& bottomLeftRadius, const WebCore::IntSize& bottomRightRadius, bool nodeHasBuiltInClickHandling);
 
-    void elementDidFocus(const FocusedElementInformation&, bool userIsInteracting, bool blurPreviousNode, bool changingActivityState, const UserData&);
+    void elementDidFocus(const FocusedElementInformation&, bool userIsInteracting, bool blurPreviousNode, OptionSet<WebCore::ActivityState::Flag> activityStateChanges, const UserData&);
     void elementDidBlur();
     void focusedElementDidChangeInputMode(WebCore::InputMode);
     void didReceiveEditorStateUpdateAfterFocus();

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (244558 => 244559)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2019-04-23 20:25:59 UTC (rev 244558)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2019-04-23 20:27:24 UTC (rev 244559)
@@ -404,7 +404,7 @@
     RestorePageCenterAndScale(Optional<WebCore::FloatPoint> unobscuredCenter, double scale)
     DidGetTapHighlightGeometries(uint64_t requestID, WebCore::Color color, Vector<WebCore::FloatQuad> geometries, WebCore::IntSize topLeftRadius, WebCore::IntSize topRightRadius, WebCore::IntSize bottomLeftRadius, WebCore::IntSize bottomRightRadius, bool nodeHasBuiltInClickHandling)
 
-    ElementDidFocus(struct WebKit::FocusedElementInformation information, bool userIsInteracting, bool blurPreviousNode, bool changingActivityState, WebKit::UserData userData)
+    ElementDidFocus(struct WebKit::FocusedElementInformation information, bool userIsInteracting, bool blurPreviousNode, OptionSet<WebCore::ActivityState::Flag> activityStateChanges, WebKit::UserData userData)
     ElementDidBlur()
     FocusedElementDidChangeInputMode(enum:uint8_t WebCore::InputMode mode)
     ScrollingNodeScrollWillStartScroll()

Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h (244558 => 244559)


--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h	2019-04-23 20:25:59 UTC (rev 244558)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h	2019-04-23 20:27:24 UTC (rev 244559)
@@ -149,7 +149,7 @@
     void restorePageState(Optional<WebCore::FloatPoint>, const WebCore::FloatPoint&, const WebCore::FloatBoxExtent&, double) override;
     void restorePageCenterAndScale(Optional<WebCore::FloatPoint>, double) override;
 
-    void elementDidFocus(const FocusedElementInformation&, bool userIsInteracting, bool blurPreviousNode, bool changingActivityState, API::Object* userData) override;
+    void elementDidFocus(const FocusedElementInformation&, bool userIsInteracting, bool blurPreviousNode, OptionSet<WebCore::ActivityState::Flag> activityStateChanges, API::Object* userData) override;
     void elementDidBlur() override;
     void focusedElementDidChangeInputMode(WebCore::InputMode) override;
     void didReceiveEditorStateUpdateAfterFocus() override;

Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (244558 => 244559)


--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm	2019-04-23 20:25:59 UTC (rev 244558)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm	2019-04-23 20:27:24 UTC (rev 244559)
@@ -535,7 +535,7 @@
     [m_webView _restorePageStateToUnobscuredCenter:center scale:scale];
 }
 
-void PageClientImpl::elementDidFocus(const FocusedElementInformation& nodeInformation, bool userIsInteracting, bool blurPreviousNode, bool changingActivityState, API::Object* userData)
+void PageClientImpl::elementDidFocus(const FocusedElementInformation& nodeInformation, bool userIsInteracting, bool blurPreviousNode, OptionSet<WebCore::ActivityState::Flag> activityStateChanges, API::Object* userData)
 {
     MESSAGE_CHECK(!userData || userData->type() == API::Object::Type::Data);
 
@@ -550,7 +550,7 @@
         }
     }
 
-    [m_contentView _elementDidFocus:nodeInformation userIsInteracting:userIsInteracting blurPreviousNode:blurPreviousNode changingActivityState:changingActivityState userObject:userObject];
+    [m_contentView _elementDidFocus:nodeInformation userIsInteracting:userIsInteracting blurPreviousNode:blurPreviousNode activityStateChanges:activityStateChanges userObject:userObject];
 }
 
 bool PageClientImpl::isFocusingElement()

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (244558 => 244559)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2019-04-23 20:25:59 UTC (rev 244558)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2019-04-23 20:27:24 UTC (rev 244559)
@@ -47,6 +47,7 @@
 #import "WKSyntheticTapGestureRecognizer.h"
 #import "_WKFormInputSession.h"
 #import <UIKit/UIView.h>
+#import <WebCore/ActivityState.h>
 #import <WebCore/Color.h>
 #import <WebCore/FloatQuad.h>
 #import <wtf/BlockPtr.h>
@@ -424,7 +425,7 @@
 - (BOOL)_mayDisableDoubleTapGesturesDuringSingleTap;
 - (void)_disableDoubleTapGesturesDuringTapIfNecessary:(uint64_t)requestID;
 - (void)_handleSmartMagnificationInformationForPotentialTap:(uint64_t)requestID renderRect:(const WebCore::FloatRect&)renderRect fitEntireRect:(BOOL)fitEntireRect viewportMinimumScale:(double)viewportMinimumScale viewportMaximumScale:(double)viewportMaximumScale;
-- (void)_elementDidFocus:(const WebKit::FocusedElementInformation&)information userIsInteracting:(BOOL)userIsInteracting blurPreviousNode:(BOOL)blurPreviousNode changingActivityState:(BOOL)changingActivityState userObject:(NSObject <NSSecureCoding> *)userObject;
+- (void)_elementDidFocus:(const WebKit::FocusedElementInformation&)information userIsInteracting:(BOOL)userIsInteracting blurPreviousNode:(BOOL)blurPreviousNode activityStateChanges:(OptionSet<WebCore::ActivityState::Flag>)activityStateChanges userObject:(NSObject <NSSecureCoding> *)userObject;
 - (void)_elementDidBlur;
 - (void)_didUpdateInputMode:(WebCore::InputMode)mode;
 - (void)_didReceiveEditorStateUpdateAfterFocus;

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (244558 => 244559)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-04-23 20:25:59 UTC (rev 244558)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-04-23 20:27:24 UTC (rev 244559)
@@ -4946,7 +4946,7 @@
     }
 }
 
-- (void)_elementDidFocus:(const WebKit::FocusedElementInformation&)information userIsInteracting:(BOOL)userIsInteracting blurPreviousNode:(BOOL)blurPreviousNode changingActivityState:(BOOL)changingActivityState userObject:(NSObject <NSSecureCoding> *)userObject
+- (void)_elementDidFocus:(const WebKit::FocusedElementInformation&)information userIsInteracting:(BOOL)userIsInteracting blurPreviousNode:(BOOL)blurPreviousNode activityStateChanges:(OptionSet<WebCore::ActivityState::Flag>)activityStateChanges userObject:(NSObject <NSSecureCoding> *)userObject
 {
     SetForScope<BOOL> isChangingFocusForScope { _isChangingFocus, hasFocusedElement(_focusedElementInformation) };
     auto inputViewUpdateDeferrer = std::exchange(_inputViewUpdateDeferrer, nullptr);
@@ -4982,7 +4982,10 @@
 #endif
 
             if (self.isFirstResponder || _becomingFirstResponder) {
-                if (changingActivityState)
+                // When the software keyboard is being used to enter an url, only the focus activity state is changing.
+                // In this case, auto focus on the page being navigated to should be disabled, unless a hardware
+                // keyboard is attached.
+                if (activityStateChanges && activityStateChanges != WebCore::ActivityState::IsFocused)
                     return YES;
 
 #if PLATFORM(WATCHOS)

Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (244558 => 244559)


--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2019-04-23 20:25:59 UTC (rev 244558)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2019-04-23 20:27:24 UTC (rev 244559)
@@ -408,7 +408,7 @@
     }
 
     if (auto arguments = std::exchange(m_deferredElementDidFocusArguments, nullptr))
-        pageClient().elementDidFocus(arguments->information, arguments->userIsInteracting, arguments->blurPreviousNode, arguments->changingActivityState, arguments->userData.get());
+        pageClient().elementDidFocus(arguments->information, arguments->userIsInteracting, arguments->blurPreviousNode, arguments->activityStateChanges, arguments->userData.get());
 }
 
 bool WebPageProxy::updateLayoutViewportParameters(const WebKit::RemoteLayerTreeTransaction& layerTreeTransaction)
@@ -927,7 +927,7 @@
     process().send(Messages::WebPage::SetIsShowingInputViewForFocusedElement(showingInputView), m_pageID);
 }
 
-void WebPageProxy::elementDidFocus(const FocusedElementInformation& information, bool userIsInteracting, bool blurPreviousNode, bool changingActivityState, const UserData& userData)
+void WebPageProxy::elementDidFocus(const FocusedElementInformation& information, bool userIsInteracting, bool blurPreviousNode, OptionSet<WebCore::ActivityState::Flag> activityStateChanges, const UserData& userData)
 {
     m_waitingForPostLayoutEditorStateUpdateAfterFocusingElement = true;
 
@@ -934,11 +934,11 @@
     API::Object* userDataObject = process().transformHandlesToObjects(userData.object()).get();
     if (m_editorState.isMissingPostLayoutData) {
         // FIXME: We should try to eliminate m_deferredElementDidFocusArguments altogether, in favor of only deferring actions that are dependent on post-layout editor state information.
-        m_deferredElementDidFocusArguments = std::make_unique<ElementDidFocusArguments>(ElementDidFocusArguments { information, userIsInteracting, blurPreviousNode, changingActivityState, userDataObject });
+        m_deferredElementDidFocusArguments = std::make_unique<ElementDidFocusArguments>(ElementDidFocusArguments { information, userIsInteracting, blurPreviousNode, activityStateChanges, userDataObject });
         return;
     }
 
-    pageClient().elementDidFocus(information, userIsInteracting, blurPreviousNode, changingActivityState, userDataObject);
+    pageClient().elementDidFocus(information, userIsInteracting, blurPreviousNode, activityStateChanges, userDataObject);
 }
 
 void WebPageProxy::elementDidBlur()

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (244558 => 244559)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-04-23 20:25:59 UTC (rev 244558)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-04-23 20:27:24 UTC (rev 244559)
@@ -3130,7 +3130,7 @@
 
     ASSERT_WITH_MESSAGE(m_page, "setActivityState called on %" PRIu64 " but WebCore page was null", pageID());
     if (m_page) {
-        SetForScope<bool> currentlyChangingActivityState { m_changingActivityState, true };
+        SetForScope<OptionSet<ActivityState::Flag>> currentlyChangingActivityState { m_lastActivityStateChanges, changed };
         m_page->setActivityState(activityState);
     }
     
@@ -5406,7 +5406,7 @@
 
         m_formClient->willBeginInputSession(this, &element, WebFrame::fromCoreFrame(*element.document().frame()), m_userIsInteracting, userData);
 
-        send(Messages::WebPageProxy::ElementDidFocus(information, m_userIsInteracting, m_recentlyBlurredElement, m_changingActivityState, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
+        send(Messages::WebPageProxy::ElementDidFocus(information, m_userIsInteracting, m_recentlyBlurredElement, m_lastActivityStateChanges, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
 #elif PLATFORM(MAC)
         // FIXME: This can be unified with the iOS code above by bringing ElementDidFocus to macOS.
         // This also doesn't take other noneditable controls into account, such as input type color.

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (244558 => 244559)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-04-23 20:25:59 UTC (rev 244558)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-04-23 20:27:24 UTC (rev 244559)
@@ -1757,7 +1757,7 @@
     bool m_hasEverFocusedElementDueToUserInteractionSincePageTransition { false };
     bool m_isTouchBarUpdateSupressedForHiddenContentEditable { false };
     bool m_isNeverRichlyEditableForTouchBar { false };
-    bool m_changingActivityState { false };
+    OptionSet<WebCore::ActivityState::Flag> m_lastActivityStateChanges;
 
 #if ENABLE(CONTEXT_MENUS)
     bool m_isShowingContextMenu { false };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to