Adding a word to dictionary should remove spelling markers

(Chrome part).
This patch adds code for removing spelling markers under words on 
chrome's side.

BUG=3506

Review URL: https://codereview.chromium.org/411393004

Cr-Commit-Position: refs/heads/master@{#291232}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291232 0039d316-1c4b-4281-b951-d872f2087c98
parent 910182b9
......@@ -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) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment