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

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

Issue 10155006: Cancel unnecessary spellcheck requests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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
« no previous file with comments | « no previous file | chrome/renderer/spellchecker/spellcheck_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/spellchecker/spellcheck.cc
===================================================================
--- chrome/renderer/spellchecker/spellcheck.cc (revision 133081)
+++ chrome/renderer/spellchecker/spellcheck.cc (working copy)
@@ -223,7 +223,6 @@
std::vector<SpellCheckResult>* results) {
#if !defined(OS_MACOSX)
// Mac has its own spell checker, so this method will not be used.
-
DCHECK(results);
size_t length = text.length();
@@ -237,21 +236,24 @@
int misspelling_start = 0;
int misspelling_length = 0;
while (offset <= length) {
+ std::vector<string16> suggestions;
if (SpellCheckWord(&text[offset],
length - offset,
0,
&misspelling_start,
&misspelling_length,
- NULL)) {
+ &suggestions)) {
return true;
}
- if (results) {
- results->push_back(SpellCheckResult(
- SpellCheckResult::SPELLING,
- misspelling_start + offset,
- misspelling_length));
- }
+ string16 replacement;
+ if (!suggestions.empty())
+ replacement = JoinString(suggestions, '\n');
+ results->push_back(SpellCheckResult(
+ SpellCheckResult::SPELLING,
+ misspelling_start + offset,
+ misspelling_length,
+ replacement));
offset += misspelling_start + misspelling_length;
}
@@ -318,13 +320,11 @@
// Commented out on Mac, because SpellCheckRequest::PerformSpellCheck is not
// implemented on Mac. Mac uses its own spellchecker, so this method
// will not be used.
-
DCHECK(!is_using_platform_spelling_engine_);
// Clean up the previous request before starting a new request.
if (pending_request_param_.get()) {
- pending_request_param_->completion()->didFinishCheckingText(
- WebKit::WebVector<WebKit::WebTextCheckingResult>());
+ pending_request_param_->completion()->didCancelCheckingText();
pending_request_param_ = NULL;
}
@@ -428,8 +428,7 @@
return;
if (file_ == base::kInvalidPlatformFileValue) {
- pending_request_param_->completion()->didFinishCheckingText(
- WebKit::WebVector<WebKit::WebTextCheckingResult>());
+ pending_request_param_->completion()->didCancelCheckingText();
} else {
requested_params_.push(pending_request_param_);
base::MessageLoopProxy::current()->PostTask(FROM_HERE,
« no previous file with comments | « no previous file | chrome/renderer/spellchecker/spellcheck_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698