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

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

Issue 1092243002: Handle typographical apostrophe with spelling service client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Slight refactor. Created 5 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_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/spellchecker/spellcheck.cc
diff --git a/chrome/renderer/spellchecker/spellcheck.cc b/chrome/renderer/spellchecker/spellcheck.cc
index e8e283a0bec76c02dd91554c1e1362b32b065ab6..6ec12f401dcc36bd48a89bd2aa14527beed420e7 100644
--- a/chrome/renderer/spellchecker/spellcheck.cc
+++ b/chrome/renderer/spellchecker/spellcheck.cc
@@ -4,6 +4,8 @@
#include "chrome/renderer/spellchecker/spellcheck.h"
+#include <algorithm>
+
#include "base/bind.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/strings/utf_string_conversions.h"
@@ -393,11 +395,26 @@ void SpellCheck::CreateTextCheckingResults(
int misspelling_length = 0;
if (decoration == SpellCheckResult::SPELLING &&
filter == USE_NATIVE_CHECKER) {
+ // Ignore typographical apostrophe misspellings.
groby-ooo-7-16 2015/04/20 21:02:22 Eeew. Are all languages handling typographic apost
please use gerrit instead 2015/04/20 23:05:31 SpellcheckWordIterator says it's using ICU for wor
please use gerrit instead 2015/04/20 23:40:17 By the way, we can remove this hack once the serve
+ static const base::char16 kTypographicalApostrophe = 0x2019;
+ static const base::char16 kTypewriterApostrophe = 0x0027;
+ if (line_text.find(kTypographicalApostrophe, word_location) <
+ static_cast<size_t>(word_location + word_length)) {
+ base::string16 no_typographical_apostrophe(line_text, word_location,
+ word_length);
+ std::replace(no_typographical_apostrophe.begin(),
+ no_typographical_apostrophe.end(),
+ kTypographicalApostrophe, kTypewriterApostrophe);
+ if (no_typographical_apostrophe == spellcheck_results[i].replacement)
+ continue;
+ }
+
if (SpellCheckWord(text + word_location, word_length, 0,
&misspelling_start, &misspelling_length, NULL)) {
decoration = SpellCheckResult::GRAMMAR;
}
}
+
if (!custom_dictionary_.SpellCheckWord(
line_text, word_location, word_length)) {
list.push_back(WebTextCheckingResult(
« no previous file with comments | « no previous file | chrome/renderer/spellchecker/spellcheck_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698