Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: aa6c1d4264f0176f1a925227bd3e80266ec7e2f6
      
https://github.com/WebKit/WebKit/commit/aa6c1d4264f0176f1a925227bd3e80266ec7e2f6
  Author: Wenson Hsieh <[email protected]>
  Date:   2024-06-23 (Sun, 23 Jun 2024)

  Changed paths:
    A 
LayoutTests/editing/selection/ios/navigating-in-subframe-does-not-dismiss-edit-menu-expected.txt
    A 
LayoutTests/editing/selection/ios/navigating-in-subframe-does-not-dismiss-edit-menu.html
    M LayoutTests/platform/ios/TestExpectations
    M Source/WebKit/Scripts/webkit/messages.py
    M Source/WebKit/UIProcess/API/gtk/PageClientImpl.h
    M Source/WebKit/UIProcess/API/wpe/PageClientImpl.h
    M Source/WebKit/UIProcess/PageClient.h
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/WebPageProxy.messages.in
    M Source/WebKit/UIProcess/ios/PageClientImplIOS.h
    M Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Source/WebKit/UIProcess/mac/PageClientImplMac.h
    M Source/WebKit/UIProcess/playstation/PageClientImpl.h
    M Source/WebKit/UIProcess/win/PageClientImpl.h
    M Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h

  Log Message:
  -----------
  REGRESSION (278484@main): Chinese Input Method (pinyin) is broken on 
ChatGPT/Google translate
https://bugs.webkit.org/show_bug.cgi?id=275754
rdar://130020224

Reviewed by Abrar Rahman Protyasha.

After the changes in 278484@main, navigations occurring in subframes that are 
not empty now cause us
to clear UI-side editor state, through 
`WebPage::clearEditorStateAfterPageTransition()`. The
intention in 278484@main was to only trigger this codepath when completing a 
page transition due to
mainframe navigation, but because the `InitializingIframe` flag is set when 
navigating away from
subframes that have already loaded content, this ended up sometimes clearing 
the UI-side selection
when loading subframes.

To fix this, this patch begins by reverting the "clear UI-side editor state 
during page transition"
approach that I previously attempted in 278484@main and 278902@main. Of course, 
this causes the API
test `ScrollViewScrollabilityTests.ScrollableWithOverflowHiddenWhenZoomed` to 
start failing again.

After investigating this test failure further, I discovered that this happens 
because having an up-
to-date `EditorState` with post-layout data means that logic which attempts to 
adjust the selection
views after scale changes in `-[WKContentView 
observeValueForKeyPath:ofObject:change:context:]` will
now call into `-_updateChangedSelection:` without returning immediately in that 
method. As a
consequence, we end up calling into UIKit code under `-selectionChanged`, which 
(internally)
instantiates the shared `UIKeyboardImpl` instance in the process of posting a 
notification for
`UITextInputResponderCapabilitiesChangedNotification`.

Instantiating a `UIKeyboardImpl` in the middle of a call to `-[WKScrollView 
setZoomScale:animated:]`
subsequently causes UIKit to install some native selection views under the 
scroll view, which (for
reasons that are still unclear) causes the scroll view to revert to a zoom 
scale of 1.

To keep this test passing after reverting 278484@main and 278902@main, we add a 
slight optimization
to `-[WKContentView observeValueForKeyPath:ofObject:change:context:]`, such 
that we avoid trying to
update UIKit's selection views (and therefore prevent `UIKeyboardImpl` from 
being instantiated) in
the case where the following conditions are both true:

1. There is no selection (i.e. the current `EditorState` has a selection type 
that is `None`).
2. No selection was previously shown (i.e. `_lastSelectionDrawingInfo`'s type 
is also `None`).

There should be no need to update platform selection state in this case, since 
nothing is visually
changing.

For easier bookkeeping — the full tree of fixes (and followup fixes) is 
currently:

```
rdar://102563363 (fixed in 276962@main)
    ↳ …caused: rdar://126280854 (fixed in 277910@main)
    ↳ …caused: rdar://127547621 (fixed in 278484@main)
        ↳ …caused: rdar://130020224 (fixed by this PR)
        ↳ …caused: rdar://128086114 (fixed in 278902@main)
            ↳ …caused: rdar://128497371 (fixed by this PR)
```

* 
LayoutTests/editing/selection/ios/navigating-in-subframe-does-not-dismiss-edit-menu-expected.txt:
 Added.
* 
LayoutTests/editing/selection/ios/navigating-in-subframe-does-not-dismiss-edit-menu.html:
 Added.

Add a new layout test to verify that UI-side editor state isn't cleared when 
navigating in subframes
that don't contain the selection (which is the root cause of the bug on 
ChatGPT/Google Translate).

* LayoutTests/platform/ios/TestExpectations:

Remove some layout test failure expectations, which are also fixed by this 
change.

* Source/WebKit/Scripts/webkit/messages.py:
(headers_for_type):
* Source/WebKit/UIProcess/API/gtk/PageClientImpl.h:
* Source/WebKit/UIProcess/API/wpe/PageClientImpl.h:
* Source/WebKit/UIProcess/PageClient.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::clearEditorStateAfterPageTransition): Deleted.

Revert all logic to clear the editor state between page transitions, added in 
278484@main.

* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.messages.in:
* Source/WebKit/UIProcess/ios/PageClientImplIOS.h:
* Source/WebKit/UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::didClearEditorStateAfterPageTransition): Deleted.
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView observeValueForKeyPath:ofObject:change:context:]):

Apply a mitigation to prevent 
`ScrollViewScrollabilityTests.ScrollableWithOverflowHiddenWhenZoomed`
from failing again, by preventing unnecessary instantiation of the 
`UIKeyboardImpl` when changing
the zoom scale.

(-[WKContentView _didClearEditorStateAfterPageTransition]): Deleted.
* Source/WebKit/UIProcess/mac/PageClientImplMac.h:
* Source/WebKit/UIProcess/playstation/PageClientImpl.h:
* Source/WebKit/UIProcess/win/PageClientImpl.h:
* Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp:
(WebKit::WebLocalFrameLoaderClient::transitionToCommittedForNewPage):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::clearEditorStateAfterPageTransition): Deleted.
* Source/WebKit/WebProcess/WebPage/WebPage.h:

Canonical link: https://commits.webkit.org/280291@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to