[webkit-changes] [WebKit/WebKit] 817276: [macOS] Show correction panel for grammar errors
Aditya Keerthi
noreply at github.com
Fri Mar 3 09:54:12 PST 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 81727684efeb8846fc178d34aa3479307b2ab8ee
https://github.com/WebKit/WebKit/commit/81727684efeb8846fc178d34aa3479307b2ab8ee
Author: Aditya Keerthi <akeerthi at apple.com>
Date: 2023-03-03 (Fri, 03 Mar 2023)
Changed paths:
M Source/WebCore/editing/AlternativeTextController.cpp
M Source/WebCore/page/AlternativeTextClient.h
M Source/WebKit/UIProcess/mac/CorrectionPanel.mm
M Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp
M Source/WebKitLegacy/mac/WebCoreSupport/CorrectionPanel.mm
Log Message:
-----------
[macOS] Show correction panel for grammar errors
https://bugs.webkit.org/show_bug.cgi?id=253294
rdar://105738781
Reviewed by Wenson Hsieh.
Native text views on macOS display a correction panel when grammar checking is
enabled and the cursor is at the end of a grammar error, or when at the end of
a misspelled word.
Currently, WebKit only implements this behavior for misspelled words. This
patch adds support for showing a correction panel for grammar errors, matching
AppKit behavior.
* Source/WebCore/editing/AlternativeTextController.cpp:
(WebCore::AlternativeTextController::timerFired):
Obtain suggestions for an ungrammatical phrase.
(WebCore::AlternativeTextController::handleAlternativeTextUIResult):
Insert accepted suggestions the same way as spelling suggestions.
(WebCore::AlternativeTextController::shouldStartTimerFor const):
Add grammar markers to the allowlist of markers that can display alternative text.
Improve the readability of the method by using a switch statement.
(WebCore::AlternativeTextController::respondToMarkerAtEndOfWord):
Start the timer to get grammar suggestions for the current word.
* Source/WebCore/page/AlternativeTextClient.h:
* Source/WebKit/UIProcess/mac/CorrectionPanel.mm:
(correctionIndicatorType):
The correction panel for grammar suggestions should appear the same as the
panel for spelling suggestions.
* Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::shouldEraseMarkersAfterChangeSelection const):
Prevent grammar markers from being removed on selection changes, matching
native behavior.
* Source/WebKitLegacy/mac/WebCoreSupport/CorrectionPanel.mm:
(correctionIndicatorType):
The correction panel for grammar suggestions should appear the same as the
panel for spelling suggestions.
Canonical link: https://commits.webkit.org/261151@main
More information about the webkit-changes
mailing list