2010-09-08 MORITA Hajime <morrita@google.com>
[WebKit.git] / WebCore / editing / Editor.cpp
index 9e41a62487c2173d525edd954c57819e537aa07d..d3b8376dbb5ca4ac7d5fdc7a510ca6cc61b44ba9 100644 (file)
@@ -2353,6 +2353,29 @@ bool Editor::spellingPanelIsShowing()
     return client()->spellingUIIsShowing();
 }
 
+void Editor::clearMisspellingsAndBadGrammar(const VisibleSelection &movingSelection)
+{
+    RefPtr<Range> selectedRange = movingSelection.toNormalizedRange();
+    if (selectedRange) {
+        frame()->document()->markers()->removeMarkers(selectedRange.get(), DocumentMarker::Spelling);
+        frame()->document()->markers()->removeMarkers(selectedRange.get(), DocumentMarker::Grammar);
+    }
+}
+
+void Editor::markMisspellingsAndBadGrammar(const VisibleSelection &movingSelection)
+{
+    bool markSpelling = isContinuousSpellCheckingEnabled();
+    bool markGrammar = markSpelling && isGrammarCheckingEnabled();
+
+    if (markSpelling) {
+        RefPtr<Range> unusedFirstMisspellingRange;
+        markMisspellings(movingSelection, unusedFirstMisspellingRange);
+    }
+
+    if (markGrammar)
+        markBadGrammar(movingSelection);
+}
+
 void Editor::markMisspellingsAfterTypingToPosition(const VisiblePosition &p)
 {
 #if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)