WebKit2: Spelling and Grammar Checking: Make sure to remove the markings from the...
authorjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Apr 2011 20:14:20 +0000 (20:14 +0000)
committerjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Apr 2011 20:14:20 +0000 (20:14 +0000)
when spelling and/or grammar checking is disabled.
https://bugs.webkit.org/show_bug.cgi?id=58350

Reviewed by Anders Carlsson.

* UIProcess/API/mac/WKView.mm:
(-[WKView toggleContinuousSpellChecking:]):
Move the call to unmark the errors to the WebProcess.
(-[WKView setGrammarCheckingEnabled:]):
Ditto.
(-[WKView toggleGrammarChecking:]):
Ditto.

* UIProcess/WebPageProxy.cpp:
Remove unused functions.
* UIProcess/WebPageProxy.h:
Ditto.
* WebProcess/WebPage/WebPage.messages.in:
Ditto.
* WebProcess/WebPage/WebPage.h:

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::setTextCheckerState):
If grammar or spelling checking is disabled, unmark all the pages.
Doing it here allows makes it possible to unmark all pages in a cross-platform way that is
triggered both by selecting the the context menu items and by any other methods of updating
the enabled / disabled state.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Source/WebKit2/WebProcess/WebProcess.cpp

index 75aa59d..dbf20c0 100644 (file)
@@ -1,3 +1,34 @@
+2011-04-12  Jessie Berlin  <jberlin@apple.com>
+
+        Reviewed by Anders Carlsson.
+
+        WebKit2: Spelling and Grammar Checking: Make sure to remove the markings from the document
+        when spelling and/or grammar checking is disabled.
+        https://bugs.webkit.org/show_bug.cgi?id=58350
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView toggleContinuousSpellChecking:]):
+        Move the call to unmark the errors to the WebProcess.
+        (-[WKView setGrammarCheckingEnabled:]):
+        Ditto.
+        (-[WKView toggleGrammarChecking:]):
+        Ditto.
+
+        * UIProcess/WebPageProxy.cpp:
+        Remove unused functions.
+        * UIProcess/WebPageProxy.h:
+        Ditto.
+        * WebProcess/WebPage/WebPage.messages.in:
+        Ditto.
+        * WebProcess/WebPage/WebPage.h:
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::setTextCheckerState):
+        If grammar or spelling checking is disabled, unmark all the pages.
+        Doing it here allows makes it possible to unmark all pages in a cross-platform way that is
+        triggered both by selecting the the context menu items and by any other methods of updating
+        the enabled / disabled state.
+
 2011-04-12  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Sam Weinig.
index d2f4bfa..3b76d03 100644 (file)
@@ -758,9 +758,6 @@ static void speakString(WKStringRef string, WKErrorRef error, void*)
     TextChecker::setContinuousSpellCheckingEnabled(spellCheckingEnabled);
 
     _data->_page->process()->updateTextCheckerState();
-
-    if (!spellCheckingEnabled)
-        _data->_page->unmarkAllMisspellings();
 }
 
 - (BOOL)isGrammarCheckingEnabled
@@ -775,9 +772,6 @@ static void speakString(WKStringRef string, WKErrorRef error, void*)
     
     TextChecker::setGrammarCheckingEnabled(flag);
     _data->_page->process()->updateTextCheckerState();
-
-    if (!flag)
-        _data->_page->unmarkAllBadGrammar();
 }
 
 - (IBAction)toggleGrammarChecking:(id)sender
@@ -786,9 +780,6 @@ static void speakString(WKStringRef string, WKErrorRef error, void*)
     TextChecker::setGrammarCheckingEnabled(grammarCheckingEnabled);
 
     _data->_page->process()->updateTextCheckerState();
-
-    if (!grammarCheckingEnabled)
-        _data->_page->unmarkAllBadGrammar();
 }
 
 - (IBAction)toggleAutomaticSpellingCorrection:(id)sender
index 2971fe1..c865c23 100644 (file)
@@ -2382,16 +2382,6 @@ void WebPageProxy::changeSpellingToWord(const String& word) const
     process()->send(Messages::WebPage::ChangeSpellingToWord(word), m_pageID);
 }
 
-void WebPageProxy::unmarkAllMisspellings()
-{
-    process()->send(Messages::WebPage::UnmarkAllMisspellings(), m_pageID);
-}
-
-void WebPageProxy::unmarkAllBadGrammar()
-{
-    process()->send(Messages::WebPage::UnmarkAllBadGrammar(), m_pageID);
-}
-
 void WebPageProxy::registerEditCommand(PassRefPtr<WebEditCommandProxy> commandProxy, UndoOrRedo undoOrRedo)
 {
     m_pageClient->registerEditCommand(commandProxy, undoOrRedo);
index 78e5645..278ade0 100644 (file)
@@ -450,8 +450,6 @@ public:
 
     void advanceToNextMisspelling(bool startBeforeSelection) const;
     void changeSpellingToWord(const String& word) const;
-    void unmarkAllMisspellings();
-    void unmarkAllBadGrammar();
 #if PLATFORM(MAC)
     void uppercaseWord();
     void lowercaseWord();
index c193027..149f52f 100644 (file)
@@ -385,6 +385,9 @@ public:
 
     void forceRepaintWithoutCallback();
 
+    void unmarkAllMisspellings();
+    void unmarkAllBadGrammar();
+
 #if PLATFORM(MAC)
     void setDragSource(NSObject *);
 #endif
@@ -517,8 +520,6 @@ private:
 
     void advanceToNextMisspelling(bool startBeforeSelection);
     void changeSpellingToWord(const String& word);
-    void unmarkAllMisspellings();
-    void unmarkAllBadGrammar();
 #if PLATFORM(MAC)
     void uppercaseWord();
     void lowercaseWord();
index 94d3ad7..e071ffa 100644 (file)
@@ -141,8 +141,6 @@ messages -> WebPage {
     # Spelling and grammar.
     AdvanceToNextMisspelling(bool startBeforeSelection)
     ChangeSpellingToWord(WTF::String word)
-    UnmarkAllMisspellings()
-    UnmarkAllBadGrammar()
 #if PLATFORM(MAC)
     UppercaseWord();
     LowercaseWord();
index 03aa87c..4d59377 100644 (file)
@@ -802,7 +802,22 @@ void WebProcess::stopMemorySampler()
 
 void WebProcess::setTextCheckerState(const TextCheckerState& textCheckerState)
 {
+    bool continuousSpellCheckingTurnedOff = !textCheckerState.isContinuousSpellCheckingEnabled && m_textCheckerState.isContinuousSpellCheckingEnabled;
+    bool grammarCheckingTurnedOff = !textCheckerState.isGrammarCheckingEnabled && m_textCheckerState.isGrammarCheckingEnabled;
+
     m_textCheckerState = textCheckerState;
+
+    if (!continuousSpellCheckingTurnedOff && !grammarCheckingTurnedOff)
+        return;
+
+    HashMap<uint64_t, RefPtr<WebPage> >::iterator end = m_pageMap.end();
+    for (HashMap<uint64_t, RefPtr<WebPage> >::iterator it = m_pageMap.begin(); it != end; ++it) {
+        WebPage* page = (*it).second.get();
+        if (continuousSpellCheckingTurnedOff)
+            page->unmarkAllMisspellings();
+        if (grammarCheckingTurnedOff)
+            page->unmarkAllBadGrammar();
+    }
 }
 
 } // namespace WebKit