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

Side by Side Diff: chrome/renderer/spellchecker/spellcheck_provider.cc

Issue 2054723002: Spellchecking should not be cancelled if editing is done in between Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/spellchecker/spellcheck_provider.h" 5 #include "chrome/renderer/spellchecker/spellcheck_provider.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
10 #include "chrome/common/spellcheck_marker.h" 11 #include "chrome/common/spellcheck_marker.h"
11 #include "chrome/common/spellcheck_messages.h" 12 #include "chrome/common/spellcheck_messages.h"
12 #include "chrome/common/spellcheck_result.h" 13 #include "chrome/common/spellcheck_result.h"
13 #include "chrome/renderer/spellchecker/spellcheck.h" 14 #include "chrome/renderer/spellchecker/spellcheck.h"
14 #include "chrome/renderer/spellchecker/spellcheck_language.h" 15 #include "chrome/renderer/spellchecker/spellcheck_language.h"
15 #include "content/public/renderer/render_view.h" 16 #include "content/public/renderer/render_view.h"
16 #include "third_party/WebKit/public/platform/WebVector.h" 17 #include "third_party/WebKit/public/platform/WebVector.h"
17 #include "third_party/WebKit/public/web/WebDocument.h" 18 #include "third_party/WebKit/public/web/WebDocument.h"
18 #include "third_party/WebKit/public/web/WebElement.h" 19 #include "third_party/WebKit/public/web/WebElement.h"
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // the user editing the text. 309 // the user editing the text.
309 base::string16 request(text); 310 base::string16 request(text);
310 size_t text_length = request.length(); 311 size_t text_length = request.length();
311 if (text_length >= last_length && 312 if (text_length >= last_length &&
312 !request.compare(0, last_length, last_request_)) { 313 !request.compare(0, last_length, last_request_)) {
313 if (text_length == last_length || !HasWordCharacters(text, last_length)) { 314 if (text_length == last_length || !HasWordCharacters(text, last_length)) {
314 completion->didFinishCheckingText(last_results_); 315 completion->didFinishCheckingText(last_results_);
315 return true; 316 return true;
316 } 317 }
317 int code = 0; 318 int code = 0;
318 int length = static_cast<int>(text_length); 319 base::string16 requested_text = text + base::UTF8ToUTF16(" ");
319 U16_PREV(text.data(), 0, length, code); 320 int length = static_cast<int>(requested_text.length());
321 U16_PREV(requested_text.data(), 0, length, code);
320 UErrorCode error = U_ZERO_ERROR; 322 UErrorCode error = U_ZERO_ERROR;
321 if (uscript_getScript(code, &error) != USCRIPT_COMMON) { 323 if (uscript_getScript(code, &error) != USCRIPT_COMMON) {
322 completion->didCancelCheckingText(); 324 completion->didCancelCheckingText();
323 return true; 325 return true;
324 } 326 }
325 } 327 }
326 // Create a subset of the cached results and return it if the given text is a 328 // Create a subset of the cached results and return it if the given text is a
327 // substring of the cached text. 329 // substring of the cached text.
328 if (text_length < last_length && 330 if (text_length < last_length &&
329 !last_request_.compare(0, text_length, request)) { 331 !last_request_.compare(0, text_length, request)) {
(...skipping 12 matching lines...) Expand all
342 results[i].length = last_results_[i].length; 344 results[i].length = last_results_[i].length;
343 results[i].replacement = last_results_[i].replacement; 345 results[i].replacement = last_results_[i].replacement;
344 } 346 }
345 completion->didFinishCheckingText(results); 347 completion->didFinishCheckingText(results);
346 return true; 348 return true;
347 } 349 }
348 } 350 }
349 351
350 return false; 352 return false;
351 } 353 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698