Title: [246757] trunk
Revision
246757
Author
[email protected]
Date
2019-06-24 12:47:31 -0700 (Mon, 24 Jun 2019)

Log Message

m_focusedElement != &element in WebPage::elementDidBlur() sometimes
https://bugs.webkit.org/show_bug.cgi?id=198928
<rdar://problem/51814327>

Reviewed by Brent Fulgham.

Source/WebKit:

This can happen when the focused editable element is inside a nested frame and a person
taps outside that frame. For reasons that seem lost to time, WebKit2 on iOS would mutate
the focused frame whenever computing selection positioning information (say, for a tap).
This "quirk" was added in r163476, but that code has go through multiple iterations and
is no longer comparable to the current code. Yet, the original mutation of the focused
frame remained. As a result the UI process and Web process go out of sync with respect
to what each thinks is the focused element and this visually manifest itself in at least
two ways:

    1. A non-sensical DOM focus event would be dispatched at the frame tapped, but
    we would keep the focused element focused.

    2. Because we would keep the focused element focused in (1), even though its frame
    is not focused, the keyboard would be active (software keyboard on screen or candidate bar
    on screen if a hardware keyboard is attached), but appear unresponsive: any keys pressed
    would not cause text to be typed into the editable field.

Because of (1) it was possible for m_focusedElement != &element in WebPage::elementDidBlur().
When this happens the UI process would never receive an ElementDidBlur message and hence would
not clear out the focused element state and hide the keyboard.

We neither do this frame focus mutation in Legacy WebKit on iOS nor Mac. Let's remove this quirk.
If it turns out that it causes a compatibility issue then we will be in a better position to
understand its purpose and consider bringing this quirk back, if needed.

* Shared/ios/InteractionInformationRequest.cpp:
(WebKit::InteractionInformationRequest::encode const):
(WebKit::InteractionInformationRequest::decode):
(WebKit::InteractionInformationRequest::isValidForRequest):
(WebKit::InteractionInformationRequest::isApproximatelyValidForRequest):
* Shared/ios/InteractionInformationRequest.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _requestActivatedElementAtPosition:completionBlock:]):
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _webTouchEventsRecognized:]):
Remove the readOnly field.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::selectionPositionInformation): Remove code to mutate the focused frame.

LayoutTests:

Update test result now that we do not mutate the focused frame on tap.

* TestExpectations: Skip problematic test editing/deleting/smart-delete-paragraph-003.html;
See <https://bugs.webkit.org/show_bug.cgi?id=198928#c16>, <https://bugs.webkit.org/show_bug.cgi?id=198928#c17>,
and <https://bugs.webkit.org/show_bug.cgi?id=199039> for more details.
* fast/events/ios/should-be-able-to-dismiss-form-accessory-after-tapping-outside-iframe-with-focused-field-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (246756 => 246757)


--- trunk/LayoutTests/ChangeLog	2019-06-24 19:47:20 UTC (rev 246756)
+++ trunk/LayoutTests/ChangeLog	2019-06-24 19:47:31 UTC (rev 246757)
@@ -1,3 +1,18 @@
+2019-06-24  Daniel Bates  <[email protected]>
+
+        m_focusedElement != &element in WebPage::elementDidBlur() sometimes
+        https://bugs.webkit.org/show_bug.cgi?id=198928
+        <rdar://problem/51814327>
+
+        Reviewed by Brent Fulgham.
+
+        Update test result now that we do not mutate the focused frame on tap.
+
+        * TestExpectations: Skip problematic test editing/deleting/smart-delete-paragraph-003.html;
+        See <https://bugs.webkit.org/show_bug.cgi?id=198928#c16>, <https://bugs.webkit.org/show_bug.cgi?id=198928#c17>,
+        and <https://bugs.webkit.org/show_bug.cgi?id=199039> for more details.
+        * fast/events/ios/should-be-able-to-dismiss-form-accessory-after-tapping-outside-iframe-with-focused-field-expected.txt:
+
 2019-06-24  Antoine Quint  <[email protected]>
 
         [Pointer Events WPT] Unskip imported/w3c/web-platform-tests/pointerevents/pointerlock/pointerevent_coordinates_when_locked.html

Modified: trunk/LayoutTests/TestExpectations (246756 => 246757)


--- trunk/LayoutTests/TestExpectations	2019-06-24 19:47:20 UTC (rev 246756)
+++ trunk/LayoutTests/TestExpectations	2019-06-24 19:47:31 UTC (rev 246757)
@@ -3438,3 +3438,5 @@
 
 # iOS only
 fast/dom/linkify-phone-numbers.html [ ImageOnlyFailure ]
+
+webkit.org/b/199039 editing/deleting/smart-delete-paragraph-003.html [ Skip ]

Modified: trunk/LayoutTests/fast/events/ios/should-be-able-to-dismiss-form-accessory-after-tapping-outside-iframe-with-focused-field-expected.txt (246756 => 246757)


--- trunk/LayoutTests/fast/events/ios/should-be-able-to-dismiss-form-accessory-after-tapping-outside-iframe-with-focused-field-expected.txt	2019-06-24 19:47:20 UTC (rev 246756)
+++ trunk/LayoutTests/fast/events/ios/should-be-able-to-dismiss-form-accessory-after-tapping-outside-iframe-with-focused-field-expected.txt	2019-06-24 19:47:31 UTC (rev 246757)
@@ -5,7 +5,7 @@
 
 dispatched blur to main frame
 dispatched focus to <input>
-dispatched focus to main frame
+dispatched blur to <input>
 PASS dismissed form accessory
 PASS successfullyParsed is true
 

Modified: trunk/Source/WebKit/ChangeLog (246756 => 246757)


--- trunk/Source/WebKit/ChangeLog	2019-06-24 19:47:20 UTC (rev 246756)
+++ trunk/Source/WebKit/ChangeLog	2019-06-24 19:47:31 UTC (rev 246757)
@@ -1,3 +1,51 @@
+2019-06-24  Daniel Bates  <[email protected]>
+
+        m_focusedElement != &element in WebPage::elementDidBlur() sometimes
+        https://bugs.webkit.org/show_bug.cgi?id=198928
+        <rdar://problem/51814327>
+
+        Reviewed by Brent Fulgham.
+
+        This can happen when the focused editable element is inside a nested frame and a person
+        taps outside that frame. For reasons that seem lost to time, WebKit2 on iOS would mutate
+        the focused frame whenever computing selection positioning information (say, for a tap).
+        This "quirk" was added in r163476, but that code has go through multiple iterations and
+        is no longer comparable to the current code. Yet, the original mutation of the focused
+        frame remained. As a result the UI process and Web process go out of sync with respect
+        to what each thinks is the focused element and this visually manifest itself in at least
+        two ways:
+
+            1. A non-sensical DOM focus event would be dispatched at the frame tapped, but
+            we would keep the focused element focused.
+
+            2. Because we would keep the focused element focused in (1), even though its frame
+            is not focused, the keyboard would be active (software keyboard on screen or candidate bar
+            on screen if a hardware keyboard is attached), but appear unresponsive: any keys pressed
+            would not cause text to be typed into the editable field.
+
+        Because of (1) it was possible for m_focusedElement != &element in WebPage::elementDidBlur().
+        When this happens the UI process would never receive an ElementDidBlur message and hence would
+        not clear out the focused element state and hide the keyboard.
+
+        We neither do this frame focus mutation in Legacy WebKit on iOS nor Mac. Let's remove this quirk.
+        If it turns out that it causes a compatibility issue then we will be in a better position to
+        understand its purpose and consider bringing this quirk back, if needed.
+
+        * Shared/ios/InteractionInformationRequest.cpp:
+        (WebKit::InteractionInformationRequest::encode const):
+        (WebKit::InteractionInformationRequest::decode):
+        (WebKit::InteractionInformationRequest::isValidForRequest):
+        (WebKit::InteractionInformationRequest::isApproximatelyValidForRequest):
+        * Shared/ios/InteractionInformationRequest.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _requestActivatedElementAtPosition:completionBlock:]):
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _webTouchEventsRecognized:]):
+        Remove the readOnly field.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::selectionPositionInformation): Remove code to mutate the focused frame.
+
 2019-06-24  Per Arne Vollan  <[email protected]>
 
         [Cocoa] Avoid creating a PlatformMediaSessionManager when the WebProcess is suspended or resumed

Modified: trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.cpp (246756 => 246757)


--- trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.cpp	2019-06-24 19:47:20 UTC (rev 246756)
+++ trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.cpp	2019-06-24 19:47:31 UTC (rev 246757)
@@ -39,7 +39,6 @@
     encoder << includeSnapshot;
     encoder << includeLinkIndicator;
     encoder << linkIndicatorShouldHaveLegacyMargins;
-    encoder << readonly;
 }
 
 bool InteractionInformationRequest::decode(IPC::Decoder& decoder, InteractionInformationRequest& result)
@@ -56,9 +55,6 @@
     if (!decoder.decode(result.linkIndicatorShouldHaveLegacyMargins))
         return false;
 
-    if (!decoder.decode(result.readonly))
-        return false;
-
     return true;
 }
 
@@ -76,9 +72,6 @@
     if (other.linkIndicatorShouldHaveLegacyMargins != linkIndicatorShouldHaveLegacyMargins)
         return false;
 
-    if (!other.readonly && readonly)
-        return false;
-
     return true;
 }
     
@@ -90,9 +83,6 @@
     if (other.includeLinkIndicator && !includeLinkIndicator)
         return false;
 
-    if (!other.readonly && readonly)
-        return false;
-
     if (other.linkIndicatorShouldHaveLegacyMargins != linkIndicatorShouldHaveLegacyMargins)
         return false;
     

Modified: trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.h (246756 => 246757)


--- trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.h	2019-06-24 19:47:20 UTC (rev 246756)
+++ trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.h	2019-06-24 19:47:31 UTC (rev 246757)
@@ -44,11 +44,6 @@
 
     bool linkIndicatorShouldHaveLegacyMargins { false };
 
-    // FIXME: This readonly flag ought to be true by default, but there are a number of interactions (e.g. selection) that currently
-    // rely on the fact that interaction information requests additionally change the focused frame. We should explicitly turn the
-    // readonly bit off in these scenarios, and make sure that all other position information requests don't move focus around.
-    bool readonly { false };
-
     InteractionInformationRequest() { }
     explicit InteractionInformationRequest(WebCore::IntPoint point)
     {

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


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2019-06-24 19:47:20 UTC (rev 246756)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2019-06-24 19:47:31 UTC (rev 246757)
@@ -6675,7 +6675,6 @@
 {
     auto infoRequest = WebKit::InteractionInformationRequest(WebCore::roundedIntPoint(position));
     infoRequest.includeSnapshot = true;
-    infoRequest.readonly = true;
 
     [_contentView doAfterPositionInformationUpdate:[capturedBlock = makeBlockPtr(block)] (WebKit::InteractionInformationAtPosition information) {
         capturedBlock([_WKActivatedElementInfo activatedElementInfoWithInteractionInformationAtPosition:information]);

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (246756 => 246757)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-06-24 19:47:20 UTC (rev 246756)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-06-24 19:47:31 UTC (rev 246757)
@@ -1316,7 +1316,6 @@
         _layerTreeTransactionIdAtLastTouchStart = downcast<WebKit::RemoteLayerTreeDrawingAreaProxy>(*_page->drawingArea()).lastCommittedLayerTreeTransactionID();
 
         WebKit::InteractionInformationRequest positionInformationRequest { WebCore::IntPoint(_lastInteractionLocation) };
-        positionInformationRequest.readonly = true;
         [self doAfterPositionInformationUpdate:[assistant = WeakObjCPtr<WKActionSheetAssistant>(_actionSheetAssistant.get())] (WebKit::InteractionInformationAtPosition information) {
             [assistant interactionDidStartWithPositionInformation:information];
         } forRequest:positionInformationRequest];

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (246756 => 246757)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-06-24 19:47:20 UTC (rev 246756)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-06-24 19:47:31 UTC (rev 246757)
@@ -2620,9 +2620,6 @@
         return;
 
     RenderObject* renderer = hitNode->renderer();
-    if (!request.readonly)
-        page.corePage()->focusController().setFocusedFrame(result.innerNodeFrame());
-
     info.bounds = renderer->absoluteBoundingBoxRect(true);
     // We don't want to select blocks that are larger than 97% of the visible area of the document.
     if (is<HTMLAttachmentElement>(*hitNode)) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to