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

Side by Side Diff: components/spellcheck/renderer/spellcheck.cc

Issue 2651503003: Use explicit WebString conversions in spellcheck (Closed)
Patch Set: Created 3 years, 11 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 | components/spellcheck/renderer/spellcheck_multilingual_unittest.cc » ('j') | 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 "components/spellcheck/renderer/spellcheck.h" 5 #include "components/spellcheck/renderer/spellcheck.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 kNoTag, 392 kNoTag,
393 &misspelling_start, 393 &misspelling_start,
394 &misspelling_length, 394 &misspelling_length,
395 NULL)) { 395 NULL)) {
396 results->assign(textcheck_results); 396 results->assign(textcheck_results);
397 return true; 397 return true;
398 } 398 }
399 399
400 if (!custom_dictionary_.SpellCheckWord( 400 if (!custom_dictionary_.SpellCheckWord(
401 text, misspelling_start, misspelling_length)) { 401 text, misspelling_start, misspelling_length)) {
402 base::string16 replacement; 402 textcheck_results.push_back(
403 textcheck_results.push_back(WebTextCheckingResult( 403 WebTextCheckingResult(blink::WebTextDecorationTypeSpelling,
404 blink::WebTextDecorationTypeSpelling, 404 misspelling_start, misspelling_length));
kinuko 2017/01/23 04:37:49 If we omit replacement parameter the ctor will use
405 misspelling_start,
406 misspelling_length,
407 replacement));
408 } 405 }
409 position_in_text = misspelling_start + misspelling_length; 406 position_in_text = misspelling_start + misspelling_length;
410 } 407 }
411 results->assign(textcheck_results); 408 results->assign(textcheck_results);
412 return false; 409 return false;
413 #else 410 #else
414 // This function is only invoked for spell checker functionality that runs 411 // This function is only invoked for spell checker functionality that runs
415 // on the render thread. OSX and Android builds don't have that. 412 // on the render thread. OSX and Android builds don't have that.
416 NOTREACHED(); 413 NOTREACHED();
417 return true; 414 return true;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 misspelled_word.length(), kNoTag, 521 misspelled_word.length(), kNoTag,
525 &unused_misspelling_start, &unused_misspelling_length, 522 &unused_misspelling_start, &unused_misspelling_length,
526 nullptr)) { 523 nullptr)) {
527 decoration = SpellCheckResult::GRAMMAR; 524 decoration = SpellCheckResult::GRAMMAR;
528 } 525 }
529 } 526 }
530 527
531 results.push_back(WebTextCheckingResult( 528 results.push_back(WebTextCheckingResult(
532 static_cast<WebTextDecorationType>(decoration), 529 static_cast<WebTextDecorationType>(decoration),
533 line_offset + spellcheck_result.location, spellcheck_result.length, 530 line_offset + spellcheck_result.location, spellcheck_result.length,
534 replacement, spellcheck_result.hash)); 531 blink::WebString::fromUTF16(replacement), spellcheck_result.hash));
535 } 532 }
536 533
537 textcheck_results->assign(results); 534 textcheck_results->assign(results);
538 } 535 }
539 536
540 bool SpellCheck::IsSpellcheckEnabled() { 537 bool SpellCheck::IsSpellcheckEnabled() {
541 #if defined(OS_ANDROID) 538 #if defined(OS_ANDROID)
542 if (!spellcheck::IsAndroidSpellCheckFeatureEnabled()) return false; 539 if (!spellcheck::IsAndroidSpellCheckFeatureEnabled()) return false;
543 #endif 540 #endif
544 return spellcheck_enabled_; 541 return spellcheck_enabled_;
545 } 542 }
OLDNEW
« no previous file with comments | « no previous file | components/spellcheck/renderer/spellcheck_multilingual_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698