Should call checkTextOfParagraph() indirectly to make unifying spell-checking code...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Oct 2011 03:10:54 +0000 (03:10 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Oct 2011 03:10:54 +0000 (03:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69241

Patch by Shinya Kawanaka <shinyak@google.com> on 2011-10-03
Reviewed by Ryosuke Niwa.

WebCore has two different code paths for spell-checking:
  1) checkTextOfParagraph() for Snow Leopard or later
  2) checkSpellingOfString() for checkGrammarOfString() for other platforms.

At the first step, this patch introduces an indirect wrapper to call
checkTextOfParagraph() in Snow Leopard or later. This is intended to make it easy to
introduce a function for mimicing checkTextOfParagraph() in Chromium platform or
other non-SL or non-Lion platform.

No new tests because this patch does not change a behavior.

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::hasMisspelling): Calling checkTextOfParagraph() indirectly.
* accessibility/mac/WebAccessibilityObjectWrapper.mm:
(AXAttributeStringSetSpelling): ditto.
* editing/Editor.cpp:
(WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges): ditto.
* editing/TextCheckingHelper.cpp:
(WebCore::TextCheckingHelper::findFirstMisspellingOrBadGrammar): ditto.
(WebCore::TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange): ditto.
(WebCore::checkTextOfParagraph): Added.
* editing/TextCheckingHelper.h:

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

Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapper.mm
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/TextCheckingHelper.cpp
Source/WebCore/editing/TextCheckingHelper.h

index 6871c9d..f4504b6 100644 (file)
@@ -1,3 +1,33 @@
+2011-10-03  Shinya Kawanaka  <shinyak@google.com>
+
+        Should call checkTextOfParagraph() indirectly to make unifying spell-checking code path easy.
+        https://bugs.webkit.org/show_bug.cgi?id=69241
+
+        Reviewed by Ryosuke Niwa.
+
+        WebCore has two different code paths for spell-checking:
+          1) checkTextOfParagraph() for Snow Leopard or later
+          2) checkSpellingOfString() for checkGrammarOfString() for other platforms.
+
+        At the first step, this patch introduces an indirect wrapper to call
+        checkTextOfParagraph() in Snow Leopard or later. This is intended to make it easy to
+        introduce a function for mimicing checkTextOfParagraph() in Chromium platform or
+        other non-SL or non-Lion platform.
+
+        No new tests because this patch does not change a behavior.
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::hasMisspelling): Calling checkTextOfParagraph() indirectly.
+        * accessibility/mac/WebAccessibilityObjectWrapper.mm:
+        (AXAttributeStringSetSpelling): ditto.
+        * editing/Editor.cpp:
+        (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges): ditto.
+        * editing/TextCheckingHelper.cpp:
+        (WebCore::TextCheckingHelper::findFirstMisspellingOrBadGrammar): ditto.
+        (WebCore::TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange): ditto.
+        (WebCore::checkTextOfParagraph): Added.
+        * editing/TextCheckingHelper.h:
+
 2011-10-03  Darin Adler  <darin@apple.com>
 
         Change cursor to hand over missing plug-in message
index d55dd3b..159bf9d 100644 (file)
@@ -291,7 +291,7 @@ bool AccessibilityObject::hasMisspelling() const
     
 #if USE(UNIFIED_TEXT_CHECKING)
     Vector<TextCheckingResult> results;
-    textChecker->checkTextOfParagraph(chars, charsLength, TextCheckingTypeSpelling, results);
+    checkTextOfParagraph(textChecker, chars, charsLength, TextCheckingTypeSpelling, results);
     if (!results.isEmpty())
         isMisspelled = true;
 #else
index ac25ee0..18a5ca6 100644 (file)
@@ -694,7 +694,7 @@ static void AXAttributeStringSetSpelling(NSMutableAttributedString* attrString,
 
     // checkTextOfParagraph is the only spelling/grammar checker implemented in WK1 and WK2
     Vector<TextCheckingResult> results;
-    checker->checkTextOfParagraph(chars, charLength, TextCheckingTypeSpelling, results);
+    checkTextOfParagraph(checker, chars, charLength, TextCheckingTypeSpelling, results);
     
     size_t size = results.size();
     NSNumber* trueValue = [NSNumber numberWithBool:YES];
index 30c7755..7d59f44 100644 (file)
@@ -2142,10 +2142,10 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textC
 
     Vector<TextCheckingResult> results;
     if (shouldMarkGrammar)
-        textChecker()->checkTextOfParagraph(grammarParagraph.textCharacters(), grammarParagraph.textLength(), 
+        checkTextOfParagraph(textChecker(), grammarParagraph.textCharacters(), grammarParagraph.textLength(), 
                                             resolveTextCheckingTypeMask(textCheckingOptions), results);
     else
-        textChecker()->checkTextOfParagraph(spellingParagraph.textCharacters(), spellingParagraph.textLength(), 
+        checkTextOfParagraph(textChecker(), spellingParagraph.textCharacters(), spellingParagraph.textLength(), 
                                             resolveTextCheckingTypeMask(textCheckingOptions), results);
         
 
index 0bdfbd8..cfbaed3 100644 (file)
@@ -276,7 +276,7 @@ String TextCheckingHelper::findFirstMisspellingOrBadGrammar(bool checkGrammar, b
                 
                 Vector<TextCheckingResult> results;
                 TextCheckingTypeMask checkingTypes = checkGrammar ? (TextCheckingTypeSpelling | TextCheckingTypeGrammar) : TextCheckingTypeSpelling;
-                m_client->textChecker()->checkTextOfParagraph(paragraphString.characters(), paragraphString.length(), checkingTypes, results);
+                checkTextOfParagraph(m_client->textChecker(), paragraphString.characters(), paragraphString.length(), checkingTypes, results);
                 
                 for (unsigned i = 0; i < results.size(); i++) {
                     const TextCheckingResult* result = &results[i];
@@ -526,7 +526,7 @@ Vector<String> TextCheckingHelper::guessesForMisspelledOrUngrammaticalRange(bool
 
     Vector<TextCheckingResult> results;
     TextCheckingTypeMask checkingTypes = checkGrammar ? (TextCheckingTypeSpelling | TextCheckingTypeGrammar) : TextCheckingTypeSpelling;
-    m_client->textChecker()->checkTextOfParagraph(paragraph.textCharacters(), paragraph.textLength(), checkingTypes, results);
+    checkTextOfParagraph(m_client->textChecker(), paragraph.textCharacters(), paragraph.textLength(), checkingTypes, results);
     
     for (unsigned i = 0; i < results.size(); i++) {
         const TextCheckingResult* result = &results[i];
@@ -590,4 +590,21 @@ void TextCheckingHelper::markAllBadGrammar()
     findFirstBadGrammar(ignoredGrammarDetail, ignoredOffset, true);
 }
 
+void checkTextOfParagraph(TextCheckerClient* client, const UChar* text, int length,
+                          TextCheckingTypeMask checkingTypes, Vector<TextCheckingResult>& results)
+{
+#if USE(UNIFIED_TEXT_CHECKING)
+    client->checkTextOfParagraph(text, length, checkingTypes, results);
+#else
+    // Should implement later to unify unified spell-checking code path and
+    // legacy spell-checking code path.
+    ASSERT_NOT_REACHED();
+    UNUSED_PARAM(client);
+    UNUSED_PARAM(text);
+    UNUSED_PARAM(length);
+    UNUSED_PARAM(checkingTypes);
+    UNUSED_PARAM(results);
+#endif
+}
+
 }
index 8b5c691..e000062 100644 (file)
@@ -92,6 +92,9 @@ private:
     RefPtr<Range> m_range;
 };
 
+void checkTextOfParagraph(TextCheckerClient*, const UChar* text, int length,
+    TextCheckingTypeMask checkingTypes, Vector<TextCheckingResult>& results);
+
 } // namespace WebCore
 
 #endif // TextCheckingHelper_h