Reviewed by Darin
authorsullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Dec 2006 21:24:03 +0000 (21:24 +0000)
committersullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Dec 2006 21:24:03 +0000 (21:24 +0000)
        Grammar/Spelling code re-homing, baby step one: put isGrammarCheckingEnabled in Editor
        since that's where isContinousSpellCheckingEnabled lives.

        * editing/Editor.h:
        * editing/Editor.cpp:
        (WebCore::Editor::isGrammarCheckingEnabled):
        new method, calls through to client a la isContinuousSpellCheckingEnabled

        * bridge/mac/FrameMac.mm:
        (WebCore::FrameMac::advanceToNextMisspelling):
        call editor() rather than editor()->client()
        (WebCore::FrameMac::markMisspellings):
        ditto

        * platform/ContextMenu.cpp:
        (WebCore::ContextMenu::populate):
        ditto

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

WebCore/ChangeLog
WebCore/bridge/mac/FrameMac.mm
WebCore/editing/Editor.cpp
WebCore/editing/Editor.h
WebCore/platform/ContextMenu.cpp

index 3fe25460a2273a6464171ef802aa6f6e041743ea..317de8e3a10d269fb9cde5c3e2eca7a8c80fea53 100644 (file)
@@ -1,3 +1,25 @@
+2006-12-05  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Darin
+
+        Grammar/Spelling code re-homing, baby step one: put isGrammarCheckingEnabled in Editor
+        since that's where isContinousSpellCheckingEnabled lives.
+
+        * editing/Editor.h:
+        * editing/Editor.cpp:
+        (WebCore::Editor::isGrammarCheckingEnabled):
+        new method, calls through to client a la isContinuousSpellCheckingEnabled
+
+        * bridge/mac/FrameMac.mm:
+        (WebCore::FrameMac::advanceToNextMisspelling):
+        call editor() rather than editor()->client()
+        (WebCore::FrameMac::markMisspellings):
+        ditto
+
+        * platform/ContextMenu.cpp:
+        (WebCore::ContextMenu::populate):
+        ditto
+
 2006-12-05  Darin Adler  <darin@apple.com>
 
         Reviewed by Geoff.
index 36fcc1e9e65dabeca39810c235ca54b1173ed2fa..b32d53b56eb01a563c0154cca0c57d5eae525f97 100644 (file)
@@ -663,7 +663,7 @@ void FrameMac::advanceToNextMisspelling(bool startBeforeSelection)
     int searchEndOffsetAfterWrap = spellingSearchRange->endOffset(ec);
     
     int misspellingOffset;
-    NSString *misspelledWord = findFirstMisspellingInRange(checker, editor()->client()->spellCheckerDocumentTag(), spellingSearchRange.get(), misspellingOffset, false);
+    NSString *misspelledWord = findFirstMisspellingInRange(checker, editor()->spellCheckerDocumentTag(), spellingSearchRange.get(), misspellingOffset, false);
     
     NSString *badGrammarPhrase = nil;
 
@@ -680,8 +680,8 @@ void FrameMac::advanceToNextMisspelling(bool startBeforeSelection)
         grammarSearchRange->setEnd(chars.range()->startContainer(ec), chars.range()->startOffset(ec), ec);
     }
     
-    if (editor()->client()->isGrammarCheckingEnabled())
-        badGrammarPhrase = findFirstBadGrammarInRange(checker, editor()->client()->spellCheckerDocumentTag(), grammarSearchRange.get(), grammarDetail, grammarPhraseOffset, false);
+    if (editor()->isGrammarCheckingEnabled())
+        badGrammarPhrase = findFirstBadGrammarInRange(checker, editor()->spellCheckerDocumentTag(), grammarSearchRange.get(), grammarDetail, grammarPhraseOffset, false);
 #endif
     
     // If we found neither bad grammar nor a misspelled word, wrap and try again (but don't bother if we started at the beginning of the
@@ -691,7 +691,7 @@ void FrameMac::advanceToNextMisspelling(bool startBeforeSelection)
         // going until the end of the very first chunk we tested is far enough
         spellingSearchRange->setEnd(searchEndNodeAfterWrap, searchEndOffsetAfterWrap, ec);
         
-        misspelledWord = findFirstMisspellingInRange(checker, editor()->client()->spellCheckerDocumentTag(), spellingSearchRange.get(), misspellingOffset, false);
+        misspelledWord = findFirstMisspellingInRange(checker, editor()->spellCheckerDocumentTag(), spellingSearchRange.get(), misspellingOffset, false);
 
 #ifndef BUILDING_ON_TIGER
         grammarSearchRange = spellingSearchRange->cloneRange(ec);
@@ -701,8 +701,8 @@ void FrameMac::advanceToNextMisspelling(bool startBeforeSelection)
             chars.advance(misspellingOffset);
             grammarSearchRange->setEnd(chars.range()->startContainer(ec), chars.range()->startOffset(ec), ec);
         }
-        if (editor()->client()->isGrammarCheckingEnabled())
-            badGrammarPhrase = findFirstBadGrammarInRange(checker, editor()->client()->spellCheckerDocumentTag(), grammarSearchRange.get(), grammarDetail, grammarPhraseOffset, false);
+        if (editor()->isGrammarCheckingEnabled())
+            badGrammarPhrase = findFirstBadGrammarInRange(checker, editor()->spellCheckerDocumentTag(), grammarSearchRange.get(), grammarDetail, grammarPhraseOffset, false);
 #endif
     }
     
@@ -1398,7 +1398,7 @@ void FrameMac::markMisspellings(const Selection& selection)
     markAllMisspellingsInRange(checker, editor()->spellCheckerDocumentTag(), searchRange.get());
     
 #ifndef BUILDING_ON_TIGER
-    if (editor()->client()->isGrammarCheckingEnabled())
+    if (editor()->isGrammarCheckingEnabled())
         markAllBadGrammarInRange(checker, editor()->spellCheckerDocumentTag(), searchRange.get());
 #endif
 }
index 909f98f7b03ed054a49897099351cbcca3ab5b08..7fb3889eb4d36715398cd79d5956e2c8f815ae0d 100644 (file)
@@ -1076,6 +1076,13 @@ bool Editor::isContinuousSpellCheckingEnabled()
     return false;
 }
 
+bool Editor::isGrammarCheckingEnabled()
+{
+    if (client())
+        return client()->isGrammarCheckingEnabled();
+    return false;
+}
+
 int Editor::spellCheckerDocumentTag()
 {
     if (client())
index 87eb870269eec959de43364c06b41b8225fe1e19..e434ec1cb9369aaa0fa095a472019e1ef43fbf87 100644 (file)
@@ -117,6 +117,7 @@ public:
     bool execCommand(const String&);
     
     bool isContinuousSpellCheckingEnabled();
+    bool isGrammarCheckingEnabled();
     int spellCheckerDocumentTag();
 
     bool shouldBeginEditing(Range* range);
index 416a7a4aa55d6c2b8cd017f913ab37be5abf4905..220f985e84a2254b350d2e5b357bb5acdc4b5e86 100644 (file)
@@ -226,7 +226,7 @@ void ContextMenu::populate()
             // Consider adding spelling-related or grammar-related context menu items (never both, since a single selected range
             // is never considered a misspelling and bad grammar at the same time)
             bool misspelling = frame->isSelectionMisspelled();
-            bool badGrammar = !misspelling && (frame->editor()->client()->isGrammarCheckingEnabled() && frame->isSelectionUngrammatical());
+            bool badGrammar = !misspelling && (frame->editor()->isGrammarCheckingEnabled() && frame->isSelectionUngrammatical());
             
             if (misspelling || badGrammar) {
                 Vector<String> guesses = misspelling ? frame->guessesForMisspelledSelection() : frame->guessesForUngrammaticalSelection();