Title: [210355] branches/safari-603-branch
Revision
210355
Author
matthew_han...@apple.com
Date
2017-01-05 09:09:49 -0800 (Thu, 05 Jan 2017)

Log Message

Merge r210266. rdar://problem/29447824

Modified Paths

Added Paths

Diff

Modified: branches/safari-603-branch/LayoutTests/ChangeLog (210354 => 210355)


--- branches/safari-603-branch/LayoutTests/ChangeLog	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/LayoutTests/ChangeLog	2017-01-05 17:09:49 UTC (rev 210355)
@@ -1,5 +1,30 @@
 2017-01-05  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r210266. rdar://problem/29447824
+
+    2017-01-03  Tim Horton  <timothy_hor...@apple.com>
+
+            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.
+
+            * 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.
+
+2017-01-05  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r210142. rdar://problem/29109053
 
     2016-12-23  Andreas Kling  <akl...@apple.com>

Modified: branches/safari-603-branch/LayoutTests/editing/editing.js (210354 => 210355)


--- branches/safari-603-branch/LayoutTests/editing/editing.js	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/LayoutTests/editing/editing.js	2017-01-05 17:09:49 UTC (rev 210355)
@@ -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");

Added: branches/safari-603-branch/LayoutTests/editing/mac/spelling/accept-unseen-candidate-records-acceptance-expected.txt (0 => 210355)


--- branches/safari-603-branch/LayoutTests/editing/mac/spelling/accept-unseen-candidate-records-acceptance-expected.txt	                        (rev 0)
+++ branches/safari-603-branch/LayoutTests/editing/mac/spelling/accept-unseen-candidate-records-acceptance-expected.txt	2017-01-05 17:09:49 UTC (rev 210355)
@@ -0,0 +1,4 @@
+NSSpellChecker recordResponseToCorrection: notationl -> notational (response: accepted)
+This test verifies that accepted candidates that were accepted immediately and unseen by the user still trigger NSSpellChecker reporting. A single "recordResponseToCorrection" logging should be output by this test, correcting "notationl" to "notational", and should be accepted.
+
+the notational 

Added: branches/safari-603-branch/LayoutTests/editing/mac/spelling/accept-unseen-candidate-records-acceptance.html (0 => 210355)


--- branches/safari-603-branch/LayoutTests/editing/mac/spelling/accept-unseen-candidate-records-acceptance.html	                        (rev 0)
+++ branches/safari-603-branch/LayoutTests/editing/mac/spelling/accept-unseen-candidate-records-acceptance.html	2017-01-05 17:09:49 UTC (rev 210355)
@@ -0,0 +1,40 @@
+<html> 
+<head>
+<script src="" language="_javascript_" type="text/_javascript_" ></script>
+<script>
+function editingTest() {
+    if (window.testRunner) {
+        testRunner.setSpellCheckerLoggingEnabled(true);
+        testRunner.dumpAsText();
+    }
+
+    typeCharacterCommand('t');
+    typeCharacterCommand('h');
+    typeCharacterCommand('e');
+    typeCharacterCommand(' ');
+    typeCharacterCommand('n');
+    typeCharacterCommand('o');
+    typeCharacterCommand('t');
+    typeCharacterCommand('a');
+    typeCharacterCommand('t');
+    typeCharacterCommand('i');
+    typeCharacterCommand('o');
+    typeCharacterCommand('n');
+    typeCharacterCommand('l');
+    typeCharacterCommand(' ');
+}
+</script>
+
+</head>
+<body>
+<p>This test verifies that accepted candidates that were accepted immediately and unseen by the user still trigger NSSpellChecker reporting. A single "recordResponseToCorrection" logging should be output by this test, correcting "notationl" to "notational", and should be accepted.</p>
+<div contenteditable id="root" class="editing">
+<span id="test"></span>
+</div>
+
+<script>
+runEditingTestWithCallbackLogging(false);
+</script>
+
+</body>
+</html>

Modified: branches/safari-603-branch/LayoutTests/platform/mac-wk2/TestExpectations (210354 => 210355)


--- branches/safari-603-branch/LayoutTests/platform/mac-wk2/TestExpectations	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/LayoutTests/platform/mac-wk2/TestExpectations	2017-01-05 17:09:49 UTC (rev 210355)
@@ -171,6 +171,7 @@
 webkit.org/b/105616 editing/mac/spelling/move-cursor-to-beginning-of-autocorrected-word.html [ Failure ]
 webkit.org/b/105616 editing/mac/spelling/removing-underline-after-accepting-autocorrection-using-punctuation.html [ Failure ]
 webkit.org/b/105616 editing/mac/spelling/accept-candidate-allows-autocorrect-on-next-word.html [ Failure ]
+webkit.org/b/105616 editing/mac/spelling/accept-unseen-candidate-records-acceptance.html [ Failure ]
 
 # [WK2] [Mac] Support drag in mouse events for WebKit2 EventSender
 # <https://bugs.webkit.org/show_bug.cgi?id=68552>

Modified: branches/safari-603-branch/Source/WebCore/ChangeLog (210354 => 210355)


--- branches/safari-603-branch/Source/WebCore/ChangeLog	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebCore/ChangeLog	2017-01-05 17:09:49 UTC (rev 210355)
@@ -1,5 +1,37 @@
 2017-01-05  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r210266. rdar://problem/29447824
+
+    2017-01-03  Tim Horton  <timothy_hor...@apple.com>
+
+            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.
+
+            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.
+
+2017-01-05  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r210142. rdar://problem/29109053
 
     2016-12-23  Andreas Kling  <akl...@apple.com>

Modified: branches/safari-603-branch/Source/WebCore/editing/AlternativeTextController.cpp (210354 => 210355)


--- branches/safari-603-branch/Source/WebCore/editing/AlternativeTextController.cpp	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebCore/editing/AlternativeTextController.cpp	2017-01-05 17:09:49 UTC (rev 210355)
@@ -314,7 +314,7 @@
 void AlternativeTextController::respondToUnappliedSpellCorrection(const VisibleSelection& selectionOfCorrected, const String& corrected, const String& correction)
 {
     if (AlternativeTextClient* client = alternativeTextClient())
-        client->recordAutocorrectionResponse(AutocorrectionReverted, corrected, correction);
+        client->recordAutocorrectionResponse(AutocorrectionResponse::Reverted, corrected, correction);
 
     Ref<Frame> protector(m_frame);
     m_frame.document()->updateLayout();
@@ -516,17 +516,12 @@
     return nullptr;
 }
 
-void AlternativeTextController::recordAutocorrectionResponseReversed(const String& replacedString, const String& replacementString)
+void AlternativeTextController::recordAutocorrectionResponse(AutocorrectionResponse response, const String& replacedString, PassRefPtr<Range> replacementRange)
 {
-    if (AlternativeTextClient* client = alternativeTextClient())
-        client->recordAutocorrectionResponse(AutocorrectionReverted, replacedString, replacementString);
+    if (auto client = alternativeTextClient())
+        client->recordAutocorrectionResponse(response, replacedString, plainText(replacementRange.get()));
 }
 
-void AlternativeTextController::recordAutocorrectionResponseReversed(const String& replacedString, PassRefPtr<Range> replacementRange)
-{
-    recordAutocorrectionResponseReversed(replacedString, plainText(replacementRange.get()));
-}
-
 void AlternativeTextController::markReversed(PassRefPtr<Range> changedRange)
 {
     changedRange->startContainer().document().markers().removeMarkers(changedRange.get(), DocumentMarker::Autocorrected, DocumentMarkerController::RemovePartiallyOverlappingMarker);
@@ -557,9 +552,9 @@
         // Spelling corrected text has been edited. We need to determine whether user has reverted it to original text or
         // edited it to something else, and notify spellchecker accordingly.
         if (markersHaveIdenticalDescription(correctedOnceMarkers) && correctedOnceMarkers[0]->description() == corrected)
-            client->recordAutocorrectionResponse(AutocorrectionReverted, corrected, correction);
+            client->recordAutocorrectionResponse(AutocorrectionResponse::Reverted, corrected, correction);
         else
-            client->recordAutocorrectionResponse(AutocorrectionEdited, corrected, correction);
+            client->recordAutocorrectionResponse(AutocorrectionResponse::Edited, corrected, correction);
     }
 
     markers.removeMarkers(rangeOfCorrection, DocumentMarker::Autocorrected, DocumentMarkerController::RemovePartiallyOverlappingMarker);

Modified: branches/safari-603-branch/Source/WebCore/editing/AlternativeTextController.h (210354 => 210355)


--- branches/safari-603-branch/Source/WebCore/editing/AlternativeTextController.h	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebCore/editing/AlternativeTextController.h	2017-01-05 17:09:49 UTC (rev 210355)
@@ -120,7 +120,7 @@
     bool isAutomaticSpellingCorrectionEnabled() UNLESS_ENABLED({ return false; })
     bool shouldRemoveMarkersUponEditing();
 
-    void recordAutocorrectionResponseReversed(const String& replacedString, PassRefPtr<Range> replacementRange) UNLESS_ENABLED({ UNUSED_PARAM(replacedString); UNUSED_PARAM(replacementRange); })
+    void recordAutocorrectionResponse(AutocorrectionResponse, const String& replacedString, PassRefPtr<Range> replacementRange) UNLESS_ENABLED({ UNUSED_PARAM(replacedString); UNUSED_PARAM(replacementRange); })
     void markReversed(PassRefPtr<Range> changedRange) UNLESS_ENABLED({ UNUSED_PARAM(changedRange); })
     void markCorrection(PassRefPtr<Range> replacedRange, const String& replacedString) UNLESS_ENABLED({ UNUSED_PARAM(replacedRange); UNUSED_PARAM(replacedString); })
 
@@ -138,7 +138,6 @@
     String dismissSoon(ReasonForDismissingAlternativeText);
     void applyAlternativeTextToRange(const Range*, const String& alternative, AlternativeTextType, const Vector<DocumentMarker::MarkerType>&);
     void timerFired();
-    void recordAutocorrectionResponseReversed(const String& replacedString, const String& replacementString);
     void recordSpellcheckerResponseForModifiedCorrection(Range* rangeOfCorrection, const String& corrected, const String& correction);
     String markerDescriptionForAppliedAlternativeText(AlternativeTextType, DocumentMarker::MarkerType);
 

Modified: branches/safari-603-branch/Source/WebCore/editing/Editor.cpp (210354 => 210355)


--- branches/safari-603-branch/Source/WebCore/editing/Editor.cpp	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebCore/editing/Editor.cpp	2017-01-05 17:09:49 UTC (rev 210355)
@@ -2577,9 +2577,13 @@
                 if (resultLocation < selectionOffset)
                     selectionOffset += replacement.length() - resultLength;
 
-                // Add a marker so that corrections can easily be undone and won't be re-corrected.
-                if (resultType == TextCheckingTypeCorrection)
-                    m_alternativeTextController->markCorrection(paragraph.subrange(resultLocation, replacement.length()), replacedString);
+                if (resultType == TextCheckingTypeCorrection) {
+                    RefPtr<Range> replacementRange = paragraph.subrange(resultLocation, replacement.length());
+                    m_alternativeTextController->recordAutocorrectionResponse(AutocorrectionResponse::Accepted, replacedString, replacementRange);
+
+                    // Add a marker so that corrections can easily be undone and won't be re-corrected.
+                    m_alternativeTextController->markCorrection(WTFMove(replacementRange), replacedString);
+                }
             }
         }
     }
@@ -2613,7 +2617,7 @@
     if (!shouldInsertText(replacedString, selection.get(), EditorInsertActionPasted))
         return;
     
-    m_alternativeTextController->recordAutocorrectionResponseReversed(replacedString, selection);
+    m_alternativeTextController->recordAutocorrectionResponse(AutocorrectionResponse::Reverted, replacedString, selection);
     TextCheckingParagraph paragraph(selection);
     replaceSelectionWithText(replacedString, false, false, EditActionInsert);
     RefPtr<Range> changedRange = paragraph.subrange(paragraph.checkingStart(), replacedString.length());

Modified: branches/safari-603-branch/Source/WebCore/page/AlternativeTextClient.h (210354 => 210355)


--- branches/safari-603-branch/Source/WebCore/page/AlternativeTextClient.h	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebCore/page/AlternativeTextClient.h	2017-01-05 17:09:49 UTC (rev 210355)
@@ -50,9 +50,10 @@
     AlternativeTextTypeDictationAlternatives
 };
 
-enum AutocorrectionResponseType {
-    AutocorrectionEdited,
-    AutocorrectionReverted
+enum class AutocorrectionResponse {
+    Edited,
+    Reverted,
+    Accepted
 };
 
 class AlternativeTextClient {
@@ -63,7 +64,7 @@
     virtual void showCorrectionAlternative(AlternativeTextType, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacmentString, const Vector<String>& alternativeReplacementStrings) = 0;
     virtual void dismissAlternative(ReasonForDismissingAlternativeText) = 0;
     virtual String dismissAlternativeSoon(ReasonForDismissingAlternativeText) = 0;
-    virtual void recordAutocorrectionResponse(AutocorrectionResponseType, const String& replacedString, const String& replacementString) = 0;
+    virtual void recordAutocorrectionResponse(AutocorrectionResponse, const String& replacedString, const String& replacementString) = 0;
 #endif
 #if USE(DICTATION_ALTERNATIVES)
     virtual void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext) = 0;

Modified: branches/safari-603-branch/Source/WebKit/mac/ChangeLog (210354 => 210355)


--- branches/safari-603-branch/Source/WebKit/mac/ChangeLog	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebKit/mac/ChangeLog	2017-01-05 17:09:49 UTC (rev 210355)
@@ -1,3 +1,28 @@
+2017-01-05  Matthew Hanson  <matthew_han...@apple.com>
+
+        Merge r210266. rdar://problem/29447824
+
+    2017-01-03  Tim Horton  <timothy_hor...@apple.com>
+
+            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.
+
+            * 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.
+
 2016-12-19  Dean Jackson  <d...@apple.com>
 
         Merge another patch for rdar://problem/29466493.

Modified: branches/safari-603-branch/Source/WebKit/mac/WebCoreSupport/CorrectionPanel.h (210354 => 210355)


--- branches/safari-603-branch/Source/WebKit/mac/WebCoreSupport/CorrectionPanel.h	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebKit/mac/WebCoreSupport/CorrectionPanel.h	2017-01-05 17:09:49 UTC (rev 210355)
@@ -41,7 +41,7 @@
     ~CorrectionPanel();
     void show(WebView*, WebCore::AlternativeTextType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings);
     String dismiss(WebCore::ReasonForDismissingAlternativeText);
-    static void recordAutocorrectionResponse(WebView*, NSCorrectionResponse, const String& replacedString, const String& replacementString);
+    static void recordAutocorrectionResponse(NSInteger spellCheckerDocumentTag, NSCorrectionResponse, const String& replacedString, const String& replacementString);
 
 private:
     bool isShowing() const { return m_view; }

Modified: branches/safari-603-branch/Source/WebKit/mac/WebCoreSupport/CorrectionPanel.mm (210354 => 210355)


--- branches/safari-603-branch/Source/WebKit/mac/WebCoreSupport/CorrectionPanel.mm	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebKit/mac/WebCoreSupport/CorrectionPanel.mm	2017-01-05 17:09:49 UTC (rev 210355)
@@ -99,9 +99,9 @@
     return m_resultForDismissal.get();
 }
 
-void CorrectionPanel::recordAutocorrectionResponse(WebView* view, NSCorrectionResponse response, const String& replacedString, const String& replacementString)
+void CorrectionPanel::recordAutocorrectionResponse(NSInteger spellCheckerDocumentTag, NSCorrectionResponse response, const String& replacedString, const String& replacementString)
 {
-    [[NSSpellChecker sharedSpellChecker] recordResponse:response toCorrection:replacementString forWord:replacedString language:nil inSpellDocumentWithTag:[view spellCheckerDocumentTag]];
+    [[NSSpellChecker sharedSpellChecker] recordResponse:response toCorrection:replacementString forWord:replacedString language:nil inSpellDocumentWithTag:spellCheckerDocumentTag];
 }
 
 void CorrectionPanel::handleAcceptedReplacement(NSString* acceptedReplacement, NSString* replaced, NSString* proposedReplacement,  NSCorrectionIndicatorType correctionIndicatorType)
@@ -109,27 +109,26 @@
     if (!m_view)
         return;
     
-    NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker];
     NSInteger documentTag = [m_view.get() spellCheckerDocumentTag];
 
     switch (correctionIndicatorType) {
     case NSCorrectionIndicatorTypeDefault:
         if (acceptedReplacement)
-            [spellChecker recordResponse:NSCorrectionResponseAccepted toCorrection:acceptedReplacement forWord:replaced language:nil inSpellDocumentWithTag:documentTag];
+            recordAutocorrectionResponse(documentTag, NSCorrectionResponseAccepted, replaced, acceptedReplacement);
         else {
             if (!m_wasDismissedExternally || m_reasonForDismissing == ReasonForDismissingAlternativeTextCancelled)
-                [spellChecker recordResponse:NSCorrectionResponseRejected toCorrection:proposedReplacement forWord:replaced language:nil inSpellDocumentWithTag:documentTag];
+                recordAutocorrectionResponse(documentTag, NSCorrectionResponseRejected, replaced, proposedReplacement);
             else
-                [spellChecker recordResponse:NSCorrectionResponseIgnored toCorrection:proposedReplacement forWord:replaced language:nil inSpellDocumentWithTag:documentTag];
+                recordAutocorrectionResponse(documentTag, NSCorrectionResponseIgnored, replaced, proposedReplacement);
         }
         break;
     case NSCorrectionIndicatorTypeReversion:
         if (acceptedReplacement)
-            [spellChecker recordResponse:NSCorrectionResponseReverted toCorrection:replaced forWord:acceptedReplacement language:nil inSpellDocumentWithTag:documentTag];
+            recordAutocorrectionResponse(documentTag, NSCorrectionResponseReverted, replaced, acceptedReplacement);
         break;
     case NSCorrectionIndicatorTypeGuesses:
         if (acceptedReplacement)
-            [spellChecker recordResponse:NSCorrectionResponseAccepted toCorrection:acceptedReplacement forWord:replaced language:nil inSpellDocumentWithTag:documentTag];
+            recordAutocorrectionResponse(documentTag, NSCorrectionResponseAccepted, replaced, acceptedReplacement);
         break;
     }
     

Modified: branches/safari-603-branch/Source/WebKit/mac/WebCoreSupport/WebAlternativeTextClient.h (210354 => 210355)


--- branches/safari-603-branch/Source/WebKit/mac/WebCoreSupport/WebAlternativeTextClient.h	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebKit/mac/WebCoreSupport/WebAlternativeTextClient.h	2017-01-05 17:09:49 UTC (rev 210355)
@@ -41,7 +41,7 @@
     void showCorrectionAlternative(WebCore::AlternativeTextType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) override;
     void dismissAlternative(WebCore::ReasonForDismissingAlternativeText) override;
     String dismissAlternativeSoon(WebCore::ReasonForDismissingAlternativeText) override;
-    void recordAutocorrectionResponse(WebCore::AutocorrectionResponseType, const String& replacedString, const String& replacementString) override;
+    void recordAutocorrectionResponse(WebCore::AutocorrectionResponse, const String& replacedString, const String& replacementString) override;
 #endif
 #if USE(DICTATION_ALTERNATIVES)
     void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext) override;

Modified: branches/safari-603-branch/Source/WebKit/mac/WebCoreSupport/WebAlternativeTextClient.mm (210354 => 210355)


--- branches/safari-603-branch/Source/WebKit/mac/WebCoreSupport/WebAlternativeTextClient.mm	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebKit/mac/WebCoreSupport/WebAlternativeTextClient.mm	2017-01-05 17:09:49 UTC (rev 210355)
@@ -62,11 +62,25 @@
     return m_correctionPanel.dismiss(reason);
 }
 
-void WebAlternativeTextClient::recordAutocorrectionResponse(AutocorrectionResponseType responseType, const String& replacedString, const String& replacementString)
+static inline NSCorrectionResponse toCorrectionResponse(AutocorrectionResponse response)
 {
-    NSCorrectionResponse response = responseType == AutocorrectionReverted ? NSCorrectionResponseReverted : NSCorrectionResponseEdited;
-    CorrectionPanel::recordAutocorrectionResponse(m_webView, response, replacedString, replacementString);
+    switch (response) {
+    case WebCore::AutocorrectionResponse::Reverted:
+        return NSCorrectionResponseReverted;
+    case WebCore::AutocorrectionResponse::Edited:
+        return NSCorrectionResponseEdited;
+    case WebCore::AutocorrectionResponse::Accepted:
+        return NSCorrectionResponseAccepted;
+    }
+
+    ASSERT_NOT_REACHED();
+    return NSCorrectionResponseAccepted;
 }
+
+void WebAlternativeTextClient::recordAutocorrectionResponse(AutocorrectionResponse response, const String& replacedString, const String& replacementString)
+{
+    CorrectionPanel::recordAutocorrectionResponse([m_webView spellCheckerDocumentTag], toCorrectionResponse(response), replacedString, replacementString);
+}
 #endif
 
 #if USE(DICTATION_ALTERNATIVES)

Modified: branches/safari-603-branch/Source/WebKit2/ChangeLog (210354 => 210355)


--- branches/safari-603-branch/Source/WebKit2/ChangeLog	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebKit2/ChangeLog	2017-01-05 17:09:49 UTC (rev 210355)
@@ -1,5 +1,31 @@
 2017-01-05  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r210266. rdar://problem/29447824
+
+    2017-01-03  Tim Horton  <timothy_hor...@apple.com>
+
+            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.
+
+            * 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.
+
+2017-01-05  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r210118. rdar://problem/29732407
 
     2016-12-22  Tim Horton  <timothy_hor...@apple.com>

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/PageClient.h (210354 => 210355)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/PageClient.h	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/PageClient.h	2017-01-05 17:09:49 UTC (rev 210355)
@@ -249,7 +249,7 @@
     virtual void showCorrectionPanel(WebCore::AlternativeTextType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) = 0;
     virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingAlternativeText) = 0;
     virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingAlternativeText) = 0;
-    virtual void recordAutocorrectionResponse(WebCore::AutocorrectionResponseType, const String& replacedString, const String& replacementString) = 0;
+    virtual void recordAutocorrectionResponse(WebCore::AutocorrectionResponse, const String& replacedString, const String& replacementString) = 0;
     virtual void recommendedScrollbarStyleDidChange(WebCore::ScrollbarStyle) = 0;
     virtual void removeNavigationGestureSnapshot() = 0;
     virtual void handleControlledElementIDResponse(const String&) = 0;

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp (210354 => 210355)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp	2017-01-05 17:09:49 UTC (rev 210355)
@@ -6101,9 +6101,9 @@
     result = m_pageClient.dismissCorrectionPanelSoon((ReasonForDismissingAlternativeText)reason);
 }
 
-void WebPageProxy::recordAutocorrectionResponse(int32_t responseType, const String& replacedString, const String& replacementString)
+void WebPageProxy::recordAutocorrectionResponse(int32_t response, const String& replacedString, const String& replacementString)
 {
-    m_pageClient.recordAutocorrectionResponse((AutocorrectionResponseType)responseType, replacedString, replacementString);
+    m_pageClient.recordAutocorrectionResponse(static_cast<AutocorrectionResponse>(response), replacedString, replacementString);
 }
 
 void WebPageProxy::handleAlternativeTextUIResult(const String& result)

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/WebPageProxy.messages.in (210354 => 210355)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2017-01-05 17:09:49 UTC (rev 210355)
@@ -358,7 +358,7 @@
     ShowCorrectionPanel(int32_t panelType, WebCore::FloatRect boundingBoxOfReplacedString, String replacedString, String replacementString, Vector<String> alternativeReplacementStrings)
     DismissCorrectionPanel(int32_t reason)
     DismissCorrectionPanelSoon(int32_t reason) -> (String result)
-    RecordAutocorrectionResponse(int32_t responseType, String replacedString, String replacementString);
+    RecordAutocorrectionResponse(int32_t response, String replacedString, String replacementString);
 
     SetEditableElementIsFocused(bool editableElementIsFocused)
 #endif

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/mac/CorrectionPanel.h (210354 => 210355)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/mac/CorrectionPanel.h	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/mac/CorrectionPanel.h	2017-01-05 17:09:49 UTC (rev 210355)
@@ -44,7 +44,7 @@
     ~CorrectionPanel();
     void show(NSView *, WebViewImpl&, WebCore::AlternativeTextType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings);
     String dismiss(WebCore::ReasonForDismissingAlternativeText);
-    static void recordAutocorrectionResponse(NSView *, NSInteger spellCheckerDocumentTag, NSCorrectionResponse, const String& replacedString, const String& replacementString);
+    static void recordAutocorrectionResponse(NSInteger spellCheckerDocumentTag, NSCorrectionResponse, const String& replacedString, const String& replacementString);
 
 private:
     bool isShowing() const { return m_view; }

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/mac/CorrectionPanel.mm (210354 => 210355)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/mac/CorrectionPanel.mm	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/mac/CorrectionPanel.mm	2017-01-05 17:09:49 UTC (rev 210355)
@@ -109,7 +109,7 @@
     return m_resultForDismissal.get();
 }
 
-void CorrectionPanel::recordAutocorrectionResponse(NSView *view, NSInteger spellCheckerDocumentTag, NSCorrectionResponse response, const String& replacedString, const String& replacementString)
+void CorrectionPanel::recordAutocorrectionResponse(NSInteger spellCheckerDocumentTag, NSCorrectionResponse response, const String& replacedString, const String& replacementString)
 {
     [[NSSpellChecker sharedSpellChecker] recordResponse:response toCorrection:replacementString forWord:replacedString language:nil inSpellDocumentWithTag:spellCheckerDocumentTag];
 }
@@ -119,26 +119,24 @@
     if (!m_view)
         return;
 
-    NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker];
-    
     switch (correctionIndicatorType) {
     case NSCorrectionIndicatorTypeDefault:
         if (acceptedReplacement)
-            [spellChecker recordResponse:NSCorrectionResponseAccepted toCorrection:acceptedReplacement forWord:replaced language:nil inSpellDocumentWithTag:m_spellCheckerDocumentTag];
+            recordAutocorrectionResponse(m_spellCheckerDocumentTag, NSCorrectionResponseAccepted, replaced, acceptedReplacement);
         else {
             if (!m_wasDismissedExternally || m_reasonForDismissing == ReasonForDismissingAlternativeTextCancelled)
-                [spellChecker recordResponse:NSCorrectionResponseRejected toCorrection:proposedReplacement forWord:replaced language:nil inSpellDocumentWithTag:m_spellCheckerDocumentTag];
+                recordAutocorrectionResponse(m_spellCheckerDocumentTag, NSCorrectionResponseRejected, replaced, proposedReplacement);
             else
-                [spellChecker recordResponse:NSCorrectionResponseIgnored toCorrection:proposedReplacement forWord:replaced language:nil inSpellDocumentWithTag:m_spellCheckerDocumentTag];
+                recordAutocorrectionResponse(m_spellCheckerDocumentTag, NSCorrectionResponseIgnored, replaced, proposedReplacement);
         }
         break;
     case NSCorrectionIndicatorTypeReversion:
         if (acceptedReplacement)
-            [spellChecker recordResponse:NSCorrectionResponseReverted toCorrection:replaced forWord:acceptedReplacement language:nil inSpellDocumentWithTag:m_spellCheckerDocumentTag];
+            recordAutocorrectionResponse(m_spellCheckerDocumentTag, NSCorrectionResponseReverted, replaced, acceptedReplacement);
         break;
     case NSCorrectionIndicatorTypeGuesses:
         if (acceptedReplacement)
-            [spellChecker recordResponse:NSCorrectionResponseAccepted toCorrection:acceptedReplacement forWord:replaced language:nil inSpellDocumentWithTag:m_spellCheckerDocumentTag];
+            recordAutocorrectionResponse(m_spellCheckerDocumentTag, NSCorrectionResponseAccepted, replaced, acceptedReplacement);
         break;
     }
 

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.h (210354 => 210355)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.h	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.h	2017-01-05 17:09:49 UTC (rev 210355)
@@ -160,7 +160,7 @@
     void showCorrectionPanel(WebCore::AlternativeTextType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) override;
     void dismissCorrectionPanel(WebCore::ReasonForDismissingAlternativeText) override;
     String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingAlternativeText) override;
-    void recordAutocorrectionResponse(WebCore::AutocorrectionResponseType, const String& replacedString, const String& replacementString) override;
+    void recordAutocorrectionResponse(WebCore::AutocorrectionResponse, const String& replacedString, const String& replacementString) override;
 
     void recommendedScrollbarStyleDidChange(WebCore::ScrollbarStyle) override;
 

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (210354 => 210355)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm	2017-01-05 17:09:49 UTC (rev 210355)
@@ -568,12 +568,26 @@
 #endif
 }
 
-void PageClientImpl::recordAutocorrectionResponse(AutocorrectionResponseType responseType, const String& replacedString, const String& replacementString)
+static inline NSCorrectionResponse toCorrectionResponse(AutocorrectionResponse response)
 {
-    NSCorrectionResponse response = responseType == AutocorrectionReverted ? NSCorrectionResponseReverted : NSCorrectionResponseEdited;
-    CorrectionPanel::recordAutocorrectionResponse(m_view, m_impl->spellCheckerDocumentTag(), response, replacedString, replacementString);
+    switch (response) {
+    case WebCore::AutocorrectionResponse::Reverted:
+        return NSCorrectionResponseReverted;
+    case WebCore::AutocorrectionResponse::Edited:
+        return NSCorrectionResponseEdited;
+    case WebCore::AutocorrectionResponse::Accepted:
+        return NSCorrectionResponseAccepted;
+    }
+
+    ASSERT_NOT_REACHED();
+    return NSCorrectionResponseAccepted;
 }
 
+void PageClientImpl::recordAutocorrectionResponse(AutocorrectionResponse response, const String& replacedString, const String& replacementString)
+{
+    CorrectionPanel::recordAutocorrectionResponse(m_impl->spellCheckerDocumentTag(), toCorrectionResponse(response), replacedString, replacementString);
+}
+
 void PageClientImpl::recommendedScrollbarStyleDidChange(ScrollbarStyle newStyle)
 {
     // Now re-create a tracking area with the appropriate options given the new scrollbar style

Modified: branches/safari-603-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebAlternativeTextClient.h (210354 => 210355)


--- branches/safari-603-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebAlternativeTextClient.h	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebAlternativeTextClient.h	2017-01-05 17:09:49 UTC (rev 210355)
@@ -42,7 +42,7 @@
     void showCorrectionAlternative(WebCore::AlternativeTextType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) override;
     void dismissAlternative(WebCore::ReasonForDismissingAlternativeText) override;
     String dismissAlternativeSoon(WebCore::ReasonForDismissingAlternativeText) override;
-    void recordAutocorrectionResponse(WebCore::AutocorrectionResponseType, const String& replacedString, const String& replacementString) override;
+    void recordAutocorrectionResponse(WebCore::AutocorrectionResponse, const String& replacedString, const String& replacementString) override;
 #endif
 #if USE(DICTATION_ALTERNATIVES)
     void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext) override;

Modified: branches/safari-603-branch/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebAlternativeTextClient.cpp (210354 => 210355)


--- branches/safari-603-branch/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebAlternativeTextClient.cpp	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebAlternativeTextClient.cpp	2017-01-05 17:09:49 UTC (rev 210355)
@@ -69,9 +69,9 @@
     return result;
 }
 
-void WebAlternativeTextClient::recordAutocorrectionResponse(AutocorrectionResponseType responseType, const String& replacedString, const String& replacementString)
+void WebAlternativeTextClient::recordAutocorrectionResponse(AutocorrectionResponse response, const String& replacedString, const String& replacementString)
 {
-    m_page->send(Messages::WebPageProxy::RecordAutocorrectionResponse(responseType, replacedString, replacementString));
+    m_page->send(Messages::WebPageProxy::RecordAutocorrectionResponse(static_cast<int32_t>(response), replacedString, replacementString));
 }
 #endif
 

Modified: branches/safari-603-branch/Tools/ChangeLog (210354 => 210355)


--- branches/safari-603-branch/Tools/ChangeLog	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Tools/ChangeLog	2017-01-05 17:09:49 UTC (rev 210355)
@@ -1,5 +1,37 @@
 2017-01-05  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r210266. rdar://problem/29447824
+
+    2017-01-03  Tim Horton  <timothy_hor...@apple.com>
+
+            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.
+
+            * 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.
+
+2017-01-05  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r210101. rdar://problem/28475977
 
     2016-12-22  Wenson Hsieh  <wenson_hs...@apple.com>

Modified: branches/safari-603-branch/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj (210354 => 210355)


--- branches/safari-603-branch/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj	2017-01-05 17:09:49 UTC (rev 210355)
@@ -78,6 +78,7 @@
 		29CFBA2E12273A1000BC30C0 /* AccessibilityTextMarkerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 29CFBA2D12273A1000BC30C0 /* AccessibilityTextMarkerMac.mm */; };
 		2CE88FA217124D8C00734FC0 /* _javascript_Threading.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CE88FA117124CEE00734FC0 /* _javascript_Threading.cpp */; };
 		2D403F1B15087209005358D2 /* LayoutTestHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D403EA215087142005358D2 /* LayoutTestHelper.m */; };
+		2DA2E3A51E1BA54100A3BBD0 /* DumpRenderTreeSpellChecker.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DA2E3A41E1BA54100A3BBD0 /* DumpRenderTreeSpellChecker.mm */; };
 		31117B3D15D9A56A00163BC8 /* MockWebNotificationProvider.mm in Sources */ = {isa = PBXBuildFile; fileRef = 31117B3B15D9A56A00163BC8 /* MockWebNotificationProvider.mm */; };
 		440590711268453800CFD48D /* WebArchiveDumpSupportMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 440590701268453800CFD48D /* WebArchiveDumpSupportMac.mm */; };
 		4437730E125CBC3600AAE02C /* WebArchiveDumpSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 44A997830FCDE86400580F10 /* WebArchiveDumpSupport.cpp */; };
@@ -291,6 +292,8 @@
 		2CE88FA117124CEE00734FC0 /* _javascript_Threading.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = _javascript_Threading.cpp; sourceTree = "<group>"; };
 		2D403EA215087142005358D2 /* LayoutTestHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LayoutTestHelper.m; path = mac/LayoutTestHelper.m; sourceTree = "<group>"; };
 		2D403F19150871F9005358D2 /* LayoutTestHelper */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = LayoutTestHelper; sourceTree = BUILT_PRODUCTS_DIR; };
+		2DA2E3A31E1BA54100A3BBD0 /* DumpRenderTreeSpellChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DumpRenderTreeSpellChecker.h; path = mac/DumpRenderTreeSpellChecker.h; sourceTree = "<group>"; };
+		2DA2E3A41E1BA54100A3BBD0 /* DumpRenderTreeSpellChecker.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = DumpRenderTreeSpellChecker.mm; path = mac/DumpRenderTreeSpellChecker.mm; sourceTree = "<group>"; };
 		31117B3A15D9A56A00163BC8 /* MockWebNotificationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MockWebNotificationProvider.h; path = mac/MockWebNotificationProvider.h; sourceTree = "<group>"; };
 		31117B3B15D9A56A00163BC8 /* MockWebNotificationProvider.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MockWebNotificationProvider.mm; path = mac/MockWebNotificationProvider.mm; sourceTree = "<group>"; };
 		32A70AAB03705E1F00C91783 /* DumpRenderTreePrefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DumpRenderTreePrefix.h; sourceTree = "<group>"; };
@@ -786,6 +789,8 @@
 			children = (
 				A8B91ADF0CF3B372008F91FF /* DumpRenderTreePasteboard.h */,
 				A8B91AD70CF3B32F008F91FF /* DumpRenderTreePasteboard.m */,
+				2DA2E3A31E1BA54100A3BBD0 /* DumpRenderTreeSpellChecker.h */,
+				2DA2E3A41E1BA54100A3BBD0 /* DumpRenderTreeSpellChecker.mm */,
 				A8B91ADD0CF3B372008F91FF /* DumpRenderTreeWindow.h */,
 				A8B91AD90CF3B32F008F91FF /* DumpRenderTreeWindow.mm */,
 			);
@@ -1096,6 +1101,7 @@
 			files = (
 				A134E53618905EFF00901D06 /* AccessibilityCommonMac.mm in Sources */,
 				BCD08B3A0E1057EF00A7D0C1 /* AccessibilityController.cpp in Sources */,
+				2DA2E3A51E1BA54100A3BBD0 /* DumpRenderTreeSpellChecker.mm in Sources */,
 				AA5A15EF16E15CD000F7C561 /* AccessibilityControllerIOS.mm in Sources */,
 				BCD08B710E1059D200A7D0C1 /* AccessibilityControllerMac.mm in Sources */,
 				80045AEE147718E7008290A8 /* AccessibilityNotificationHandler.mm in Sources */,

Modified: branches/safari-603-branch/Tools/DumpRenderTree/TestRunner.cpp (210354 => 210355)


--- branches/safari-603-branch/Tools/DumpRenderTree/TestRunner.cpp	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Tools/DumpRenderTree/TestRunner.cpp	2017-01-05 17:09:49 UTC (rev 210355)
@@ -1779,6 +1779,15 @@
     return JSValueMakeNumber(context, controller->imageCountInGeneralPasteboard());
 }
 
+static JSValueRef setSpellCheckerLoggingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+    TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
+    controller->setSpellCheckerLoggingEnabled(JSValueToBoolean(context, arguments[0]));
+    return JSValueMakeUndefined(context);
+}
+
 // Static Values
 
 static JSValueRef getTimeoutCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
@@ -2225,6 +2234,7 @@
         { "accummulateLogsForChannel", accummulateLogsForChannel, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "runUIScript", runUIScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "imageCountInGeneralPasteboard", imageCountInGeneralPasteboardCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setSpellCheckerLoggingEnabled", setSpellCheckerLoggingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { 0, 0, 0 }
     };
 

Modified: branches/safari-603-branch/Tools/DumpRenderTree/TestRunner.h (210354 => 210355)


--- branches/safari-603-branch/Tools/DumpRenderTree/TestRunner.h	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Tools/DumpRenderTree/TestRunner.h	2017-01-05 17:09:49 UTC (rev 210355)
@@ -373,6 +373,8 @@
     void setDumpJSConsoleLogInStdErr(bool inStdErr) { m_dumpJSConsoleLogInStdErr = inStdErr; }
     bool dumpJSConsoleLogInStdErr() const { return m_dumpJSConsoleLogInStdErr; }
 
+    void setSpellCheckerLoggingEnabled(bool);
+
 private:
     TestRunner(const std::string& testURL, const std::string& expectedPixelHash);
 

Modified: branches/safari-603-branch/Tools/DumpRenderTree/mac/DumpRenderTree.mm (210354 => 210355)


--- branches/safari-603-branch/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2017-01-05 17:09:49 UTC (rev 210355)
@@ -34,6 +34,7 @@
 #import "DefaultPolicyDelegate.h"
 #import "DumpRenderTreeDraggingInfo.h"
 #import "DumpRenderTreePasteboard.h"
+#import "DumpRenderTreeSpellChecker.h"
 #import "DumpRenderTreeWindow.h"
 #import "EditingDelegate.h"
 #import "EventSendingController.h"
@@ -1896,6 +1897,8 @@
 
     [mainFrame _clearOpener];
 
+    setSpellCheckerLoggingEnabled(false);
+
     resetAccumulatedLogs();
     WebCoreTestSupport::initializeLogChannelsIfNecessary();
 }

Added: branches/safari-603-branch/Tools/DumpRenderTree/mac/DumpRenderTreeSpellChecker.h (0 => 210355)


--- branches/safari-603-branch/Tools/DumpRenderTree/mac/DumpRenderTreeSpellChecker.h	                        (rev 0)
+++ branches/safari-603-branch/Tools/DumpRenderTree/mac/DumpRenderTreeSpellChecker.h	2017-01-05 17:09:49 UTC (rev 210355)
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+void setSpellCheckerLoggingEnabled(bool);

Added: branches/safari-603-branch/Tools/DumpRenderTree/mac/DumpRenderTreeSpellChecker.mm (0 => 210355)


--- branches/safari-603-branch/Tools/DumpRenderTree/mac/DumpRenderTreeSpellChecker.mm	                        (rev 0)
+++ branches/safari-603-branch/Tools/DumpRenderTree/mac/DumpRenderTreeSpellChecker.mm	2017-01-05 17:09:49 UTC (rev 210355)
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "DumpRenderTreeSpellChecker.h"
+
+#if PLATFORM(MAC)
+
+#import <AppKit/NSSpellChecker.h>
+#import <wtf/Assertions.h>
+#import <wtf/ObjcRuntimeExtras.h>
+
+static bool spellCheckerLoggingEnabled;
+static IMP appKitRecordResponseIMP;
+
+static const char *stringForCorrectionResponse(NSCorrectionResponse correctionResponse)
+{
+    switch (correctionResponse) {
+    case NSCorrectionResponseNone:
+        return "none";
+    case NSCorrectionResponseAccepted:
+        return "accepted";
+    case NSCorrectionResponseRejected:
+        return "rejected";
+    case NSCorrectionResponseIgnored:
+        return "ignored";
+    case NSCorrectionResponseEdited:
+        return "edited";
+    case NSCorrectionResponseReverted:
+        return "reverted";
+    }
+
+    return "invalid";
+}
+
+static void drt_NSSpellChecker_recordResponseToCorrection(id self, SEL _cmd, NSCorrectionResponse response, NSString *correction, NSString *word, NSString *language, NSInteger spellDocumentTag)
+{
+    if (spellCheckerLoggingEnabled)
+        printf("NSSpellChecker recordResponseToCorrection: %s -> %s (response: %s)\n", [word UTF8String], [correction UTF8String], stringForCorrectionResponse(response));
+
+    wtfCallIMP<void, NSCorrectionResponse, NSString *, NSString *, NSString *, NSInteger>(appKitRecordResponseIMP, self, _cmd, response, correction, word, language, spellDocumentTag);
+}
+
+static void swizzleNSSpellCheckerMethodsIfNeeded()
+{
+    static bool hasSwizzled;
+    if (hasSwizzled)
+        return;
+    hasSwizzled = true;
+
+    Method recordResponseMethod = class_getInstanceMethod(objc_getClass("NSSpellChecker"), @selector(recordResponse:toCorrection:forWord:language:inSpellDocumentWithTag:));
+
+    appKitRecordResponseIMP = method_setImplementation(recordResponseMethod, (IMP)drt_NSSpellChecker_recordResponseToCorrection);
+}
+
+void setSpellCheckerLoggingEnabled(bool enabled)
+{
+    swizzleNSSpellCheckerMethodsIfNeeded();
+
+    spellCheckerLoggingEnabled = enabled;
+}
+
+#else // PLATFORM(MAC)
+
+void setSpellCheckerLoggingEnabled(bool)
+{
+}
+
+#endif // PLATFORM(MAC)

Modified: branches/safari-603-branch/Tools/DumpRenderTree/mac/TestRunnerMac.mm (210354 => 210355)


--- branches/safari-603-branch/Tools/DumpRenderTree/mac/TestRunnerMac.mm	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Tools/DumpRenderTree/mac/TestRunnerMac.mm	2017-01-05 17:09:49 UTC (rev 210355)
@@ -31,6 +31,7 @@
 #import "TestRunner.h"
 
 #import "DefaultPolicyDelegate.h"
+#import "DumpRenderTreeSpellChecker.h"
 #import "EditingDelegate.h"
 #import "MockGeolocationProvider.h"
 #import "MockWebNotificationProvider.h"
@@ -210,6 +211,11 @@
     [WebStorageManager setStorageDatabaseIdleInterval:interval];
 }
 
+void TestRunner::setSpellCheckerLoggingEnabled(bool enabled)
+{
+    ::setSpellCheckerLoggingEnabled(enabled);
+}
+
 void TestRunner::closeIdleLocalStorageDatabases()
 {
     [WebStorageManager closeIdleLocalStorageDatabases];

Modified: branches/safari-603-branch/Tools/DumpRenderTree/win/TestRunnerWin.cpp (210354 => 210355)


--- branches/safari-603-branch/Tools/DumpRenderTree/win/TestRunnerWin.cpp	2017-01-05 17:09:38 UTC (rev 210354)
+++ branches/safari-603-branch/Tools/DumpRenderTree/win/TestRunnerWin.cpp	2017-01-05 17:09:49 UTC (rev 210355)
@@ -1392,3 +1392,7 @@
     return 0;
 }
 
+void TestRunner::setSpellCheckerLoggingEnabled(bool enabled)
+{
+    printf("ERROR: TestRunner::setSpellCheckerLoggingEnabled() not implemented\n");
+}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to