Chromium Code Reviews| Index: chrome/renderer/spellchecker/spellcheck.cc |
| diff --git a/chrome/renderer/spellchecker/spellcheck.cc b/chrome/renderer/spellchecker/spellcheck.cc |
| index 2150dd2f91130e0522f74a3154e71b05ee9cca16..b054b2a13a58355ec3e51430acc0a60e316ab420 100644 |
| --- a/chrome/renderer/spellchecker/spellcheck.cc |
| +++ b/chrome/renderer/spellchecker/spellcheck.cc |
| @@ -13,15 +13,18 @@ |
| #include "chrome/common/spellcheck_result.h" |
| #include "chrome/renderer/spellchecker/spellcheck_language.h" |
| #include "chrome/renderer/spellchecker/spellcheck_provider.h" |
| +#include "content/public/renderer/render_frame.h" |
|
groby-ooo-7-16
2014/08/19 20:42:05
Do you need this?
Klemen Forstnerič
2014/08/20 20:07:16
Whoops, this is a relic from when I was still eval
|
| #include "content/public/renderer/render_thread.h" |
| #include "content/public/renderer/render_view.h" |
| #include "content/public/renderer/render_view_visitor.h" |
| +#include "third_party/WebKit/public/web/WebFrame.h" |
|
groby-ooo-7-16
2014/08/19 20:42:05
Or this?
Klemen Forstnerič
2014/08/20 20:07:16
Same as above. Removed.
|
| #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" |
| #include "third_party/WebKit/public/web/WebTextCheckingResult.h" |
| #include "third_party/WebKit/public/web/WebTextDecorationType.h" |
| #include "third_party/WebKit/public/web/WebView.h" |
| using blink::WebVector; |
| +using blink::WebString; |
| using blink::WebTextCheckingResult; |
| using blink::WebTextDecorationType; |
| @@ -67,6 +70,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() {} |
| + 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 +173,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); |
|
groby-ooo-7-16
2014/08/19 20:42:05
I'm slightly queasy about this. OnCustomDictionary
Klemen Forstnerič
2014/08/20 20:07:16
I opened 10 tabs, loaded 10 different websites and
|
| + content::RenderView::ForEach(&markersRemover); |
| } |
| void SpellCheck::OnEnableAutoSpellCorrect(bool enable) { |