haikuwebkit/LayoutTests/platform/ios
Wenson Hsieh cbf95252da REGRESSION (r271146): editing/selection/ios/scrolling-to-focused-element-inside-iframe.html is failing
https://bugs.webkit.org/show_bug.cgi?id=229376
rdar://80384683

Reviewed by Megan Gardner.

Source/WebKit:

This iOS-specific test verifies that tapping on an element that makes itself contenteditable inside of a click
event handler both (1) brings up the software keyboard, and (2) scrolls to reveal the focused, newly editable
element such that it is not obscured by the software keyboard. This test began failing after the changes in
r271146 -- specifically, the fact that the call to `Element::setFocus()` moved to before the focus event is
dispatched, rather than afterwards.

The following timeline of events (annotated with web and UI processes) illustrates why this happens:

(WEB)   1.  The click event on the element inside the subframe is handled; the element is made contentEditable,
            and we make it focused, by first calling `Element::setFocus` and then `Element::dispatchFocusEvent`.
            Right before dispatching the "focus" event, we call out to the client layer, via
            `WebPage::elementDidFocus`, and compute a FocusedElementInformation struct to encode and send to the
            UI process in the WebPageProxy::ElementDidFocus IPC message.

        2.  In the process of populating this struct in `WebPage::focusedElementInformation`, we observe that
            layout is dirty, and immediately compute and send an EditorState underneath
            `WebPage::sendEditorStateUpdate()`.

        3.  We then proceed to construct and send FocusedElementInformation to the UI process via
            `Messages::WebPageProxy::ElementDidFocus`.

(UI)    4.  We receive the EditorState that was computed and sent in step (2), which contains the up-to-date
            state corresponding to the newly focused contentEditable `div`.

        5.  We then receive the FocusedElementInformation computed and sent in step (3), which makes us begin
            waiting for the next post-layout EditorState update before zooming to reveal the focused element, by
            setting WebPageProxy's `m_waitingForPostLayoutEditorStateUpdateAfterFocusingElement` flag. However,
            this post-layout EditorState after focusing the `div` never arrives, since we've already computed it
            and sent it in step (2).

        6.  The software keyboard finishes animating in, causing us to resolve the UIScriptController promise
            that we began to await after calling `UIHelper.activateAndWaitForInputSessionAt` in the test.

(WEB)   7.  The test finishes, calls `testRunner.notifyDone()`, and we destroy the focused subframe and clear
            the editable selection as well. This selection change causes us to compute another post-layout
            editor state and send it to the UI process.

(UI)    8.  The UI process *finally* receives the post-layout EditorState computed in (7). However, it's too
            late, since (a) the test has already finished, and (b) the post-layout EditorState is computed after
            the editable selection has already been cleared, so it's missing selection rect information anyways.

Prior to r271146, the call to `Element::setFocus` came *after* step (3), and caused us to compute and send
another EditorState to the UI process, which ensured that an up-to-date post layout EditorState would arrive in
the UI process shortly after step (5).

To fix this, we should avoid immediately computing and sending an EditorState to the UI process in the middle of
`WebPage::focusedElementInformation`, and instead simply schedule an EditorState during the next rendering
update. This ensures that the editor state triggered during element focus will always arrive after
`WebPageProxy::ElementDidFocus` in the UI process, rather than before, which allows us to scroll to the correct
selection rect in the UI process when focusing an editable element.

This also has the additional benefit of avoiding redundant EditorState computation and updates in the case where
focus is programmatically thrashed between elements during the same rendering update, since all of the editor
state updates are effectively batched together and dispatched at the end of the current rendering update.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::focusedElementInformation):

LayoutTests:

Adjust test expectations for the layout test, which should now pass.

* platform/ios-wk2/TestExpectations:
* platform/ios/TestExpectations:


Canonical link: https://commits.webkit.org/240832@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281450 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-23 16:41:50 +00:00
..
accessibility Expose [WebAccessibilityObjectWrapper lineRectsAndText] on MacOS. 2021-08-16 21:04:19 +00:00
animations
compositing Separated models don't get opacity set on them at all 2021-04-20 23:21:06 +00:00
crypto/subtle
css-dark-mode
css1 [LFC][IFC] Add support for vertical-align: super 2021-08-23 03:55:38 +00:00
css2.1 [LFC][IFC] Add support for vertical-align: sub 2021-08-22 22:18:46 +00:00
css3 [iOS][FCR] Add borders for better control visibility 2021-04-27 20:28:09 +00:00
cssom
editing [LFC][IFC] Add support for vertical-align: sub 2021-08-22 22:18:46 +00:00
fast [LFC][IFC] Add support for vertical-align: sub 2021-08-22 22:18:46 +00:00
fonts [LFC][Integration] Enable inline box support (RenderInline) 2021-04-06 13:55:35 +00:00
http [LayoutTests] Convert http/tests/blink convert PHP to Python 2021-04-19 17:17:54 +00:00
ietestcenter/css3
imported REBASELINE : [ iOS ] 3X imported/w3c/web-platform-t ests/css/css-typed-om layout-tests are constant text failures 2021-08-17 22:54:13 +00:00
ios Enforce a quota in window.sessionStorage 2021-06-04 21:21:48 +00:00
js/dom
mathml
media Remove unused JS and CSS files of media controls 2021-03-22 22:17:49 +00:00
mediastream
platform
quicklook
scrollbars
scrollingcoordinator/ios
storage/domstorage/sessionstorage
svg Unreviewed, reverting r281009. 2021-08-13 18:58:23 +00:00
swipe
system-preview
tables [iOS] Increase contrast for textfields, checkboxes, and radio buttons 2021-07-09 21:47:15 +00:00
transforms [iOS] Increase contrast for textfields, checkboxes, and radio buttons 2021-07-09 21:47:15 +00:00
transitions
webanimations
webarchive/loading
webaudio
webgl
webrtc
TestExpectations REGRESSION (r271146): editing/selection/ios/scrolling-to-focused-element-inside-iframe.html is failing 2021-08-23 16:41:50 +00:00