[Mac] Text replacement should use correction indicator
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 May 2013 00:02:29 +0000 (00:02 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 May 2013 00:02:29 +0000 (00:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=115471

Reviewed by Darin Adler.

Support autocorrection panel for text replacements by making AlternativeTextTypeCorrection
handle text replacements as well as automatic spelling correction.

No new tests. Unfortunately this feature is not testable as is. We need to provide some
internals or testRunner methods to make this feature testable in the long term.

* editing/AlternativeTextController.cpp:
(WebCore::AlternativeTextController::timerFired): Trigger both TextCheckingTypeReplacement
and TextCheckingTypeShowCorrectionPanel.

* editing/Editor.cpp:
(WebCore::Editor::markAndReplaceFor): Autocorrection panel maybe used for both
TextCheckingTypeReplacement and TextCheckingTypeShowCorrectionPanel.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@149465 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/editing/AlternativeTextController.cpp
Source/WebCore/editing/Editor.cpp

index 50754617af740f8fad6b28d48bd0f84c05ad598e..8008bd6e91d58dd029c371a7515343593588c816 100644 (file)
@@ -1,3 +1,24 @@
+2013-05-01  Ryosuke Niwa  <rniwa@webkit.org>
+
+        [Mac] Text replacement should use correction indicator
+        https://bugs.webkit.org/show_bug.cgi?id=115471
+
+        Reviewed by Darin Adler.
+
+        Support autocorrection panel for text replacements by making AlternativeTextTypeCorrection
+        handle text replacements as well as automatic spelling correction.
+
+        No new tests. Unfortunately this feature is not testable as is. We need to provide some
+        internals or testRunner methods to make this feature testable in the long term.
+
+        * editing/AlternativeTextController.cpp:
+        (WebCore::AlternativeTextController::timerFired): Trigger both TextCheckingTypeReplacement
+        and TextCheckingTypeShowCorrectionPanel.
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::markAndReplaceFor): Autocorrection panel maybe used for both
+        TextCheckingTypeReplacement and TextCheckingTypeShowCorrectionPanel.
+
 2013-05-01  Tim Horton  <timothy_horton@apple.com>
 
         Move knowledge of PDF/PostScript MIME types into MIMETypeRegistry
index d648f6b5e323f88efa49af9b5b986044490080b7..613aaf988903b479135dfdbe1a8dbfe5dd748537 100644 (file)
@@ -339,7 +339,7 @@ void AlternativeTextController::timerFired(Timer<AlternativeTextController>*)
         VisiblePosition start(selection.start(), selection.affinity());
         VisiblePosition p = startOfWord(start, LeftWordIfOnBoundary);
         VisibleSelection adjacentWords = VisibleSelection(p, start);
-        m_frame->editor()->markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeSpelling | TextCheckingTypeShowCorrectionPanel, adjacentWords.toNormalizedRange().get(), 0);
+        m_frame->editor()->markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeSpelling | TextCheckingTypeReplacement | TextCheckingTypeShowCorrectionPanel, adjacentWords.toNormalizedRange().get(), 0);
     }
         break;
     case AlternativeTextTypeReversion: {
index 3277c1c2fd5d3d4df1357e0609ed29ef95a978d8..e77e104429b3ef243af7fab8698238e0128de625 100644 (file)
@@ -2246,7 +2246,8 @@ void Editor::markAndReplaceFor(PassRefPtr<SpellCheckRequest> request, const Vect
             // In this case the result range just has to touch the spelling range, so we can handle replacing non-word text such as punctuation.
             ASSERT(resultLength > 0 && resultLocation >= 0);
 
-            if (shouldShowCorrectionPanel && (resultEndLocation < spellingRangeEndOffset || resultType != TextCheckingTypeCorrection))
+            if (shouldShowCorrectionPanel && (resultEndLocation < spellingRangeEndOffset
+                || !(resultType & (TextCheckingTypeReplacement | TextCheckingTypeCorrection))))
                 continue;
 
             // Apply replacement if: