Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 50d7d248178dab94af78bd8a20e2cba1959dcb8a
      
https://github.com/WebKit/WebKit/commit/50d7d248178dab94af78bd8a20e2cba1959dcb8a
  Author: Wenson Hsieh <[email protected]>
  Date:   2023-06-12 (Mon, 12 Jun 2023)

  Changed paths:
    M Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm
    M Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h
    M Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.mm

  Log Message:
  -----------
  [Mac Catalyst] Disable spellchecking code in non-editable contexts
https://bugs.webkit.org/show_bug.cgi?id=257962
rdar://105576086

Reviewed by Aditya Keerthi.

On Mac Catalyst, the platform-driven text checking codepath is currently active 
even when selecting
non-editable web content (e.g. in the Books app). While this mostly has no 
observable effect (other
than unnecessarily calling into spellchecking APIs and attempting to fill 
spellchecking results back
into non-editable elements on the page), it sometimes causes the selection to 
change from underneath
the user, as we attempt to restore the previous text selection range underneath
`TextCheckingControllerProxy::replaceRelativeToSelection`.

To avoid this altogether, add a couple of editability checks in 
`TextCheckingControllerProxy`, such
that we return early in the case where the relevant selection or context range 
is not in editable
content. Since this annotation text is only used for platform spellchecking, 
there's no need to
extract this text via `TextIterator` upon every selection change.

Test: DocumentEditingContext.RequestAnnotationsForTextChecking

* Source/WebKit/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm:
(WebKit::TextCheckingControllerProxy::replaceRelativeToSelection):
(WebKit::TextCheckingControllerProxy::annotatedSubstringBetweenPositions):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm:
* Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h:
* Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.mm:

Additionally fix the TestWebKitAPI build on Catalyst. The build was failing 
with a linker error
because the main `@implementation` of `DragAndDropSimulator` is guarded by 
`!PLATFORM(MACCATALYST)`,
but the `DOMElementDrag` category is not. For now, we address this by adding 
`!PLATFORM(MACCATALYST)`
checks for consistency with the main iOS-specific implementation, but in the 
future, we should
refactor `DragAndDropSimulator` to work properly on Catalyst.

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


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to