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

Unified Diff: components/spellcheck/renderer/spellcheck.cc

Issue 2911253003: [Reland] Allow storing multiple replacements on SpellCheckResult (Closed)
Patch Set: Created 3 years, 7 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: components/spellcheck/renderer/spellcheck.cc
diff --git a/components/spellcheck/renderer/spellcheck.cc b/components/spellcheck/renderer/spellcheck.cc
index c34a181fe751b58f37622cce28d40b002db1dc86..1a0b9675fa73315ee7bf32305568045d4c7ba9e5 100644
--- a/components/spellcheck/renderer/spellcheck.cc
+++ b/components/spellcheck/renderer/spellcheck.cc
@@ -473,7 +473,8 @@ void SpellCheck::CreateTextCheckingResults(
const base::string16& misspelled_word =
line_text.substr(spellcheck_result.location, spellcheck_result.length);
- base::string16 replacement = spellcheck_result.replacement;
+ const std::vector<base::string16>& replacements =
+ spellcheck_result.replacements;
SpellCheckResult::Decoration decoration = spellcheck_result.decoration;
// Ignore words in custom dictionary.
@@ -482,11 +483,23 @@ void SpellCheck::CreateTextCheckingResults(
continue;
}
- // Use the same types of appostrophes as in the mispelled word.
- PreserveOriginalApostropheTypes(misspelled_word, &replacement);
+ std::vector<WebString> replacements_adjusted;
+ for (base::string16 replacement : replacements) {
+ // Use the same types of appostrophes as in the mispelled word.
+ PreserveOriginalApostropheTypes(misspelled_word, &replacement);
- // Ignore misspellings due the typographical apostrophe.
- if (misspelled_word == replacement)
+ // Ignore suggestions that are just changing the apostrophe type
+ // (straight vs. typographical)
+ if (replacement == misspelled_word)
+ continue;
+
+ replacements_adjusted.push_back(WebString::FromUTF16(replacement));
+ }
+
+ // If the spellchecker suggested replacements, but they were all just
+ // changing apostrophe styles, ignore this misspelling. If there were never
+ // any suggested replacements, keep the misspelling.
+ if (replacements_adjusted.empty() && !replacements.empty())
rlanday 2017/05/30 18:27:15 This is the fix for the bug: Old check: if (repla
continue;
if (filter == USE_NATIVE_CHECKER) {
@@ -504,10 +517,10 @@ void SpellCheck::CreateTextCheckingResults(
}
}
- results.push_back(WebTextCheckingResult(
- static_cast<WebTextDecorationType>(decoration),
- line_offset + spellcheck_result.location, spellcheck_result.length,
- blink::WebString::FromUTF16(replacement)));
+ results.push_back(
+ WebTextCheckingResult(static_cast<WebTextDecorationType>(decoration),
+ line_offset + spellcheck_result.location,
+ spellcheck_result.length, replacements_adjusted));
}
textcheck_results->Assign(results);

Powered by Google App Engine
This is Rietveld 408576698