diff options
-rw-r--r-- | chrome/renderer/spellchecker/spellcheck_provider.cc | 20 | ||||
-rw-r--r-- | chrome/renderer/spellchecker/spellcheck_provider.h | 9 | ||||
-rw-r--r-- | content/renderer/render_view.cc | 3 | ||||
-rw-r--r-- | webkit/glue/context_menu.cc | 8 |
4 files changed, 36 insertions, 4 deletions
diff --git a/chrome/renderer/spellchecker/spellcheck_provider.cc b/chrome/renderer/spellchecker/spellcheck_provider.cc index 5309ddf..e0b262f 100644 --- a/chrome/renderer/spellchecker/spellcheck_provider.cc +++ b/chrome/renderer/spellchecker/spellcheck_provider.cc @@ -20,6 +20,7 @@ using WebKit::WebFrame; using WebKit::WebString; using WebKit::WebTextCheckingCompletion; using WebKit::WebTextCheckingResult; +using WebKit::WebVector; SpellCheckProvider::SpellCheckProvider(RenderView* render_view, SpellCheck* spellcheck) @@ -76,21 +77,32 @@ bool SpellCheckProvider::OnMessageReceived(const IPC::Message& message) { return handled; } -void SpellCheckProvider::spellCheck(const WebString& text, - int& misspelled_offset, - int& misspelled_length) { +void SpellCheckProvider::spellCheck( + const WebString& text, + int& offset, + int& length, + WebVector<WebString>* optional_suggestions) { EnsureDocumentTag(); string16 word(text); RenderThread* thread = RenderThread::current(); // Will be NULL during unit tests. if (thread) { + std::vector<string16> suggestions; thread->spellchecker()->SpellCheckWord( word.c_str(), word.size(), document_tag_, - &misspelled_offset, &misspelled_length, NULL); + &offset, &length, optional_suggestions ? & suggestions : NULL); + if (optional_suggestions) + *optional_suggestions = suggestions; } } +void SpellCheckProvider::spellCheck(const WebString& text, + int& offset, + int& length) { + spellCheck(text, offset, length, NULL); +} + void SpellCheckProvider::requestCheckingOfText( const WebString& text, WebTextCheckingCompletion* completion) { diff --git a/chrome/renderer/spellchecker/spellcheck_provider.h b/chrome/renderer/spellchecker/spellcheck_provider.h index 9697d62..0713d01 100644 --- a/chrome/renderer/spellchecker/spellcheck_provider.h +++ b/chrome/renderer/spellchecker/spellcheck_provider.h @@ -12,6 +12,9 @@ #include "content/renderer/render_view_observer.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebSpellCheckClient.h" +// TODO(jam): remove me once WEBSPELLCHECKCLIENT_HAS_SUGGESTIONS is rolled +#include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" + class RenderView; class SpellCheck; @@ -54,6 +57,12 @@ class SpellCheckProvider : public RenderViewObserver, private: // WebKit::WebSpellCheckClient implementation. + virtual void spellCheck( + const WebKit::WebString& text, + int& offset, + int& length, + WebKit::WebVector<WebKit::WebString>* optional_suggestions); + // TODO(jam): remove me once WEBSPELLCHECKCLIENT_HAS_SUGGESTIONS is rolled virtual void spellCheck(const WebKit::WebString& text, int& offset, int& length); diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc index 3fa450b..44027a0 100644 --- a/content/renderer/render_view.cc +++ b/content/renderer/render_view.cc @@ -2224,6 +2224,7 @@ bool RenderView::runModalBeforeUnloadDialog( void RenderView::showContextMenu( WebFrame* frame, const WebContextMenuData& data) { ContextMenuParams params = ContextMenuParams(data); +#if !defined(WEBSPELLCHECKCLIENT_HAS_SUGGESTIONS) if (!params.misspelled_word.empty() && RenderThread::current()) { int misspelled_offset, misspelled_length; bool spelled_right = RenderThread::current()->spellchecker()-> @@ -2235,6 +2236,8 @@ void RenderView::showContextMenu( if (spelled_right) params.misspelled_word.clear(); } +#endif + // Serializing a GURL longer than content::kMaxURLChars will fail, so don't do // it. We replace it with an empty GURL so the appropriate items are disabled // in the context menu. diff --git a/webkit/glue/context_menu.cc b/webkit/glue/context_menu.cc index 317130e..0d68c03 100644 --- a/webkit/glue/context_menu.cc +++ b/webkit/glue/context_menu.cc @@ -5,6 +5,9 @@ #include "webkit/glue/context_menu.h" #include "webkit/glue/glue_serialize.h" +// TODO(jam): remove me once WebKit is merged. +#include "third_party/WebKit/Source/WebKit/chromium/public/WebSpellCheckClient.h" + namespace webkit_glue { const int32 CustomContextMenuContext::kCurrentRenderWidget = kint32max; @@ -43,6 +46,11 @@ ContextMenuParams::ContextMenuParams(const WebKit::WebContextMenuData& data) edit_flags(data.editFlags), security_info(data.securityInfo), frame_charset(data.frameEncoding.utf8()) { +#if defined(WEBSPELLCHECKCLIENT_HAS_SUGGESTIONS) + for (size_t i = 0; i < data.dictionarySuggestions.size(); ++i) + dictionary_suggestions.push_back(data.dictionarySuggestions[i]); +#endif + custom_context.is_pepper_menu = false; for (size_t i = 0; i < data.customItems.size(); ++i) custom_items.push_back(WebMenuItem(data.customItems[i])); |