NSSpellChecker's recordResponse isn't called for unseen automatic corrections
https://bugs.webkit.org/show_bug.cgi?id=166450
<rdar://problem/29447824>
Reviewed by Darin Adler.
Source/WebCore:
Test: editing/mac/spelling/accept-unseen-candidate-records-acceptance.html
* editing/AlternativeTextController.cpp:
(WebCore::AlternativeTextController::recordAutocorrectionResponse):
(WebCore::AlternativeTextController::recordAutocorrectionResponseReversed): Deleted.
* editing/AlternativeTextController.h:
Add recordAutocorrectionResponse, which takes a AutocorrectionResponseType, instead of having
a function specifically for reverted autocorrections. Also, get rid of the unnecessary indirection
of the private overload of recordAutocorrectionResponseReversed, since there's only one caller.
* editing/Editor.cpp:
(WebCore::Editor::markAndReplaceFor):
Call recordAutocorrectionResponse with Accepted when performing an auto-autocorrection.
(WebCore::Editor::changeBackToReplacedString):
Adopt recordAutocorrectionResponse.
* page/AlternativeTextClient.h:
Add an "AutocorrectionAccepted" response type.
Source/WebKit/mac:
* WebCoreSupport/CorrectionPanel.h:
* WebCoreSupport/CorrectionPanel.mm:
(CorrectionPanel::recordAutocorrectionResponse):
(CorrectionPanel::handleAcceptedReplacement):
* WebCoreSupport/WebAlternativeTextClient.mm:
(toCorrectionResponse):
(WebAlternativeTextClient::recordAutocorrectionResponse):
Funnel all calls to recordResponse:toCorrection:forWord:language:inSpellDocumentWithTag:
through recordAutocorrectionResponse, for debugging's sake.
Drop the NSView parameter because we don't need it, just the tag.
Convert the new AutocorrectionResponseType value to its corresponding
NSCorrectionResponse value.
Source/WebKit2:
* UIProcess/mac/CorrectionPanel.h:
* UIProcess/mac/CorrectionPanel.mm:
(WebKit::CorrectionPanel::recordAutocorrectionResponse):
(WebKit::CorrectionPanel::handleAcceptedReplacement):
Funnel all calls to recordResponse:toCorrection:forWord:language:inSpellDocumentWithTag:
through recordAutocorrectionResponse, for debugging's sake.
Drop the NSView parameter because we don't need it, just the tag.
* UIProcess/mac/PageClientImpl.mm:
(WebKit::toCorrectionResponse):
(WebKit::PageClientImpl::recordAutocorrectionResponse):
Convert the new AutocorrectionResponseType value to its corresponding
NSCorrectionResponse value.
Tools:
* DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
* DumpRenderTree/TestRunner.cpp:
(TestRunner::staticFunctions):
* DumpRenderTree/mac/TestRunnerMac.mm:
(setSpellCheckerLoggingEnabledCallback):
* DumpRenderTree/win/TestRunnerWin.cpp:
(setSpellCheckerLoggingEnabledCallback):
* DumpRenderTree/mac/DumpRenderTree.mm:
(resetWebViewToConsistentStateBeforeTesting):
* DumpRenderTree/mac/DumpRenderTreeSpellChecker.h: Added.
* DumpRenderTree/mac/DumpRenderTreeSpellChecker.mm: Added.
(stringForCorrectionResponse):
(drt_NSSpellChecker_recordResponseToCorrection):
(swizzleNSSpellCheckerMethodsIfNeeded):
(setSpellCheckerLoggingEnabled):
Add a new testRunner method, setSpellCheckerLoggingEnabled, which, when
set to true, logs to stdout (which ends up in the test result) whenever
NSSpellChecker recordResponse:toCorrection:forWord:language:inSpellDocumentWithTag:
is called, and then calls the original method. It is reset to false between tests.
LayoutTests:
* editing/editing.js:
(runEditingTest):
(runEditingTestWithCallbackLogging):
Add a way to run an editing test without enabling noisy editing callback logging.
* editing/mac/spelling/accept-unseen-candidate-records-acceptance-expected.txt: Added.
* editing/mac/spelling/accept-unseen-candidate-records-acceptance.html: Added.
Add a test that ensures that we correctly inform NSSpellChecker of an
accepted unseen correction.
* platform/mac-wk2/TestExpectations:
Disable the test because spelling tests don't work in WebKit2 at all.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@210266 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/editing/editing.js b/LayoutTests/editing/editing.js
index 8f4e3d2..ec3221d 100644
--- a/LayoutTests/editing/editing.js
+++ b/LayoutTests/editing/editing.js
@@ -894,7 +894,11 @@
})();
function runEditingTest() {
- if (window.testRunner)
+ runEditingTestWithCallbackLogging(true);
+}
+
+function runEditingTestWithCallbackLogging(enableCallbackLogging) {
+ if (window.testRunner && enableCallbackLogging)
testRunner.dumpEditingCallbacks();
var elem = document.getElementById("test");