Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3420)

Unified Diff: chrome/renderer/spellchecker/spellcheck.cc

Issue 411393004: Adding a word to dictionary should remove spelling markers (Chrome part) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added OVERRIDE to DocumentMarkersRemover destructor Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/spellchecker/spellcheck.cc
diff --git a/chrome/renderer/spellchecker/spellcheck.cc b/chrome/renderer/spellchecker/spellcheck.cc
index 2150dd2f91130e0522f74a3154e71b05ee9cca16..f1de849dba5d0655d2e72d6636876d88218792b4 100644
--- a/chrome/renderer/spellchecker/spellcheck.cc
+++ b/chrome/renderer/spellchecker/spellcheck.cc
@@ -22,6 +22,7 @@
#include "third_party/WebKit/public/web/WebView.h"
using blink::WebVector;
+using blink::WebString;
using blink::WebTextCheckingResult;
using blink::WebTextDecorationType;
@@ -67,6 +68,30 @@ bool DocumentMarkersCollector::Visit(content::RenderView* render_view) {
return true;
}
+class DocumentMarkersRemover : public content::RenderViewVisitor {
+ public:
+ explicit DocumentMarkersRemover(const std::vector<std::string>& words);
+ virtual ~DocumentMarkersRemover() OVERRIDE {}
+ virtual bool Visit(content::RenderView* render_view) OVERRIDE;
+
+ private:
+ WebVector<WebString> words_;
+ DISALLOW_COPY_AND_ASSIGN(DocumentMarkersRemover);
+};
+
+DocumentMarkersRemover::DocumentMarkersRemover(
+ const std::vector<std::string>& words)
+ : words_(words.size()) {
+ for (size_t i = 0; i < words.size(); ++i)
+ words_[i] = WebString::fromUTF8(words[i]);
+}
+
+bool DocumentMarkersRemover::Visit(content::RenderView* render_view) {
+ if (render_view && render_view->GetWebView())
+ render_view->GetWebView()->removeSpellingMarkersUnderWords(words_);
+ return true;
+}
+
} // namespace
class SpellCheck::SpellcheckRequest {
@@ -146,6 +171,10 @@ void SpellCheck::OnCustomDictionaryChanged(
const std::vector<std::string>& words_added,
const std::vector<std::string>& words_removed) {
custom_dictionary_.OnCustomDictionaryChanged(words_added, words_removed);
+ if (words_added.empty())
+ return;
+ DocumentMarkersRemover markersRemover(words_added);
+ content::RenderView::ForEach(&markersRemover);
}
void SpellCheck::OnEnableAutoSpellCorrect(bool enable) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698