-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unable to show text alternatives when tapping grammatical error in Ma…
…il compose https://bugs.webkit.org/show_bug.cgi?id=259008 rdar://111404885 Reviewed by Tim Horton and Abrar Rahman Protyasha. After the changes in 264745@main, we no longer perform sync IPC underneath `-requestAutocorrectionContextWithCompletionHandler:`, and instead just return an empty context when out-of-process keyboard is enabled. This is because UIKit now syncs document state by requesting `UIWKDocumentContext`s when OOPK is enabled, instead of `UIWKAutocorrectionContext`. However, there's still one instance where UIKit still depends on the legacy autocorrection context to drive platform features: the case of showing grammar text checking results when the user taps on a grammar correction in editable content (i.e. words with blue dotted underlines). Work around this for the time being by falling back to shipping behavior when grammar corrections are present in the document; we can remove this once rdar://111936621 is fixed. * LayoutTests/editing/selection/ios/show-grammar-replacements-on-tap-expected.txt: Added. * LayoutTests/editing/selection/ios/show-grammar-replacements-on-tap.html: Added. * LayoutTests/platform/ios-wk2/TestExpectations: Add a layout test to exercise the fix, building on the infrastructure added in 265869@main. Note that we use `runSingly=true` here because otherwise, `UIWKTextInteractionAssistant` might use a previously initialized and cached `UITextChecker` instance, rather than the `LayoutTestSpellChecker` that contains the canned text corrections that the test depends on. * Source/WebCore/dom/DocumentMarkerController.h: * Source/WebKit/Shared/EditorState.h: * Source/WebKit/Shared/EditorState.serialization.in: Add a new bit to `EditorState` here, indicating whether we have grammar markers inside the current editable root. * Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView requestAutocorrectionContextWithCompletionHandler:]): * Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::getPlatformEditorState const): Canonical link: https://commits.webkit.org/265880@main
- Loading branch information
Showing
8 changed files
with
103 additions
and
6 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
LayoutTests/editing/selection/ios/show-grammar-replacements-on-tap-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
This test verifies that tapping on an editable grammar text checking range shows the edit menu and selects the range encompassing the grammatical error. This test requires WebKitTestRunner to run. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS Presented edit menu | ||
PASS getSelection().toString() is "thing" | ||
PASS internals.hasGrammarMarker(0, 5) is true | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
I'll need to thing about it. | ||
|
||
|
69 changes: 69 additions & 0 deletions
69
LayoutTests/editing/selection/ios/show-grammar-replacements-on-tap.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true runSingly=true ] --> | ||
<html> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<head> | ||
<script src="../../../resources/js-test.js"></script> | ||
<script src="../../../resources/ui-helper.js"></script> | ||
<style> | ||
div[contenteditable] { | ||
font-family: monospace; | ||
font-size: 32px; | ||
border: 1px solid tomato; | ||
width: 100%; | ||
} | ||
</style> | ||
<script> | ||
jsTestIsAsync = true; | ||
description(`This test verifies that tapping on an editable grammar text checking range shows the | ||
edit menu and selects the range encompassing the grammatical error. This test requires | ||
WebKitTestRunner to run.`); | ||
|
||
addEventListener("load", async () => { | ||
const results = [ | ||
{ | ||
"type": "grammar", | ||
"from": 13, | ||
"to": 18, | ||
"details": [{ "from": 0, "to": 5, "corrections": ["think"] }], | ||
} | ||
]; | ||
await UIHelper.setSpellCheckerResults({ | ||
"I'll need to thing about it.\n": results, | ||
"I'll need to thing about it.": results | ||
}); | ||
|
||
let target = document.getElementById("target"); | ||
let editor = document.querySelector("div[contenteditable]"); | ||
|
||
await UIHelper.activateElementAndWaitForInputSession(editor); | ||
|
||
// First, trigger grammar checking by inserting a newline. | ||
getSelection().selectAllChildren(editor); | ||
getSelection().collapseToEnd(); | ||
document.execCommand("InsertText", true, "."); | ||
document.execCommand("InsertParagraph", true); | ||
await UIHelper.ensurePresentationUpdate(); | ||
|
||
// Then, tap the grammar error and wait for the edit menu to show up. | ||
await UIHelper.activateElement(target); | ||
await UIHelper.waitForMenuToShow(); | ||
|
||
testPassed("Presented edit menu"); | ||
shouldBeEqualToString("getSelection().toString()", "thing"); | ||
shouldBeTrue("internals.hasGrammarMarker(0, 5)"); | ||
|
||
editor.blur(); | ||
await UIHelper.waitForKeyboardToHide(); | ||
|
||
finishJSTest(); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<div contenteditable> | ||
I'll need to <span id="target">thing</span> about it | ||
</div> | ||
<pre id="description"></pre> | ||
<pre id="console"></pre> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters