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

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

Issue 9169082: Asynchronous spellchecking on Win and Linux (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Build fix Created 8 years, 8 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
Index: chrome/renderer/spellchecker/spellcheck_provider.cc
diff --git a/chrome/renderer/spellchecker/spellcheck_provider.cc b/chrome/renderer/spellchecker/spellcheck_provider.cc
index 89b7cfccbffeb240542f4dd5ca4a9b41e0faa5a6..b3fd4a97656969b779c43f0491f2dd8e28d721c4 100644
--- a/chrome/renderer/spellchecker/spellcheck_provider.cc
+++ b/chrome/renderer/spellchecker/spellcheck_provider.cc
@@ -18,6 +18,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
+using spellcheck::ToWebResultList;
using WebKit::WebFrame;
using WebKit::WebString;
using WebKit::WebTextCheckingCompletion;
@@ -42,34 +43,6 @@ COMPILE_ASSERT(int(WebKit::WebTextCheckingTypeCorrection) ==
COMPILE_ASSERT(int(WebKit::WebTextCheckingTypeShowCorrectionPanel) ==
int(SpellCheckResult::SHOWCORRECTIONPANEL), mismatching_enums);
-namespace {
-
-void ToWebResultList(
- int offset,
- const std::vector<SpellCheckResult>& results,
- WebVector<WebTextCheckingResult>* web_results) {
- WebVector<WebTextCheckingResult> list(results.size());
- for (size_t i = 0; i < results.size(); ++i) {
- list[i] = WebTextCheckingResult(
- static_cast<WebTextCheckingType>(results[i].type),
- results[i].location + offset,
- results[i].length,
- results[i].replacement);
- }
-
- list.swap(*web_results);
-}
-
-WebVector<WebTextCheckingResult> ToWebResultList(
- int offset,
- const std::vector<SpellCheckResult>& results) {
- WebVector<WebTextCheckingResult> web_results;
- ToWebResultList(offset, results, &web_results);
- return web_results;
-}
-
-} // namespace
-
SpellCheckProvider::SpellCheckProvider(
content::RenderView* render_view,
chrome::ChromeContentRendererClient* renderer_client)
@@ -118,6 +91,7 @@ void SpellCheckProvider::RequestTextChecking(
completion->didFinishCheckingText(std::vector<WebTextCheckingResult>());
return;
}
+
last_line_ = line;
Send(new SpellCheckHostMsg_CallSpellingService(
routing_id(),
@@ -210,7 +184,6 @@ void SpellCheckProvider::checkTextOfParagraph(
std::vector<SpellCheckResult> tmp_results;
chrome_content_renderer_client_->spellcheck()->SpellCheckParagraph(
string16(text),
- document_tag_,
&tmp_results);
ToWebResultList(0, tmp_results, results);
#endif
@@ -257,12 +230,25 @@ void SpellCheckProvider::updateSpellingUIWithMisspelledWord(
void SpellCheckProvider::OnRespondSpellingService(
int identifier,
int offset,
+ bool succeeded,
+ const string16& text,
const std::vector<SpellCheckResult>& results) {
WebTextCheckingCompletion* completion =
text_check_completions_.Lookup(identifier);
if (!completion)
return;
text_check_completions_.Remove(identifier);
+
+ // If |succeeded| is false, we use local spellcheck as a fallback.
+ if (!succeeded) {
+ // |chrome_content_renderer_client| may be NULL in unit tests.
+ if (chrome_content_renderer_client_) {
+ chrome_content_renderer_client_->spellcheck()->RequestTextChecking(
+ text, offset, completion);
+ return;
+ }
+ }
+
completion->didFinishCheckingText(ToWebResultList(offset, results));
}
« no previous file with comments | « chrome/renderer/spellchecker/spellcheck_provider.h ('k') | chrome/renderer/spellchecker/spellcheck_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698