Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 3f38324c4333005e30ae69af38d8640fb013251b
https://github.com/WebKit/WebKit/commit/3f38324c4333005e30ae69af38d8640fb013251b
Author: Megan Gardner <[email protected]>
Date: 2026-06-18 (Thu, 18 Jun 2026)
Changed paths:
M Source/WebCore/editing/AlternativeTextController.cpp
M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
A Tools/TestWebKitAPI/Tests/WebKit/WKWebView/mac/GrammarMarkerPrecedence.mm
Log Message:
-----------
Text that has been autocorrected and also has a grammar suggestion shows the
autocorrected UI and not the grammar suggestion.
https://bugs.webkit.org/show_bug.cgi?id=317189
rdar://179382273
Reviewed by Abrar Rahman Protyasha.
When the caret lands at the end of a word that has both a grammar marker
and another marker (e.g., a Replacement marker from a recent autocorrection)
ending at the same offset, AlternativeTextController::respondToChangedSelection
iterated all markers in start-offset order and used the first match. The
resulting UI depended on insertion order, and the autocorrect reversion UI
typically won — hiding the grammar suggestion.
Check Grammar markers first. If no grammar marker handles the end-of-word
position, fall back to the existing multi-word grammar covering-the-selection
check, then to the previous "any marker" loop. The multi-word fallback now
also propagates `handled` so the new "any marker" loop doesn't double-fire.
Test:
Tools/TestWebKitAPI/Tests/WebKit/WKWebView/mac/GrammarMarkerPrecedenceOverSpelling.mm
* Source/WebCore/editing/AlternativeTextController.cpp:
(WebCore::AlternativeTextController::respondToChangedSelection):
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/mac/GrammarMarkerPrecedence.mm:
Added.
(TestWebKitAPI::swizzledShowCorrectionIndicator):
(TestWebKitAPI::TEST(GrammarMarkerPrecedence,
GrammarTakesPrecedenceOverOverlappingSpellingMarker)):
Canonical link: https://commits.webkit.org/315507@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications