summaryrefslogtreecommitdiff
path: root/chromium/components/spellcheck/renderer/spellcheck.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-09-18 14:34:04 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-10-04 11:15:27 +0000
commite6430e577f105ad8813c92e75c54660c4985026e (patch)
tree88115e5d1fb471fea807111924dcccbeadbf9e4f /chromium/components/spellcheck/renderer/spellcheck.cc
parent53d399fe6415a96ea6986ec0d402a9c07da72453 (diff)
downloadqtwebengine-chromium-e6430e577f105ad8813c92e75c54660c4985026e.tar.gz
BASELINE: Update Chromium to 61.0.3163.99
Change-Id: I8452f34574d88ca2b27af9bd56fc9ff3f16b1367 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/components/spellcheck/renderer/spellcheck.cc')
-rw-r--r--chromium/components/spellcheck/renderer/spellcheck.cc44
1 files changed, 32 insertions, 12 deletions
diff --git a/chromium/components/spellcheck/renderer/spellcheck.cc b/chromium/components/spellcheck/renderer/spellcheck.cc
index 4ef53a067a6..262a47063cd 100644
--- a/chromium/components/spellcheck/renderer/spellcheck.cc
+++ b/chromium/components/spellcheck/renderer/spellcheck.cc
@@ -30,7 +30,6 @@
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_frame_visitor.h"
#include "content/public/renderer/render_thread.h"
-#include "services/service_manager/public/cpp/bind_source_info.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebVector.h"
@@ -113,6 +112,25 @@ void PreserveOriginalApostropheTypes(const base::string16& misspelled_word,
}
}
+std::vector<WebString> FilterReplacementSuggestions(
+ const base::string16& misspelled_word,
+ const std::vector<base::string16>& replacements) {
+ std::vector<WebString> replacements_filtered;
+ for (base::string16 replacement : replacements) {
+ // Use the same types of apostrophes as in the mispelled word.
+ PreserveOriginalApostropheTypes(misspelled_word, &replacement);
+
+ // Ignore suggestions that are just changing the apostrophe type
+ // (straight vs. typographical)
+ if (replacement == misspelled_word)
+ continue;
+
+ replacements_filtered.push_back(WebString::FromUTF16(replacement));
+ }
+
+ return replacements_filtered;
+}
+
} // namespace
class SpellCheck::SpellcheckRequest {
@@ -201,9 +219,8 @@ void SpellCheck::FillSuggestions(
}
void SpellCheck::SpellCheckerRequest(
- const service_manager::BindSourceInfo& source_info,
spellcheck::mojom::SpellCheckerRequest request) {
- spellchecker_bindings_.AddBinding(this, std::move(request));
+ bindings_.AddBinding(this, std::move(request));
}
void SpellCheck::Initialize(
@@ -473,7 +490,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 +500,13 @@ void SpellCheck::CreateTextCheckingResults(
continue;
}
- // Use the same types of appostrophes as in the mispelled word.
- PreserveOriginalApostropheTypes(misspelled_word, &replacement);
+ std::vector<WebString> replacements_filtered =
+ FilterReplacementSuggestions(misspelled_word, replacements);
- // Ignore misspellings due the typographical apostrophe.
- if (misspelled_word == 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_filtered.empty() && !replacements.empty())
continue;
if (filter == USE_NATIVE_CHECKER) {
@@ -504,10 +524,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_filtered));
}
textcheck_results->Assign(results);