diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/components/spellcheck/renderer/spellcheck.cc | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/spellcheck/renderer/spellcheck.cc')
-rw-r--r-- | chromium/components/spellcheck/renderer/spellcheck.cc | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/chromium/components/spellcheck/renderer/spellcheck.cc b/chromium/components/spellcheck/renderer/spellcheck.cc index 53f87d5caaf..9a036faa65e 100644 --- a/chromium/components/spellcheck/renderer/spellcheck.cc +++ b/chromium/components/spellcheck/renderer/spellcheck.cc @@ -297,7 +297,7 @@ bool SpellCheck::SpellCheckWord( suggestions_list.clear(); for (auto language = languages_.begin(); language != languages_.end();) { -#if BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER) +#if defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER) if (!(*language)->IsEnabled()) { // In the case of hybrid spell checking on Windows, languages that are // handled on the browser side are marked as disabled on the renderer @@ -306,7 +306,7 @@ bool SpellCheck::SpellCheckWord( language++; continue; } -#endif // BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER) +#endif // defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER) language_suggestions.clear(); SpellcheckLanguage::SpellcheckWordResult result = @@ -363,18 +363,18 @@ bool SpellCheck::SpellCheckWord( return false; } -#if BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER) +#if defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER) // If we're performing a hybrid spell check, we're only interested in // knowing whether some Hunspell languages considered this text range as // correctly spelled. If no misspellings were found, but the entire text was // skipped, it means that no Hunspell language considered this text // correct, so we should return false here. - if (spellcheck::UseWinHybridSpellChecker() && + if (spellcheck::UseBrowserSpellChecker() && EnabledLanguageCount() != LanguageCount() && agreed_skippable_len == text_length) { return false; } -#endif // BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER) +#endif // defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER) } NOTREACHED(); @@ -470,11 +470,11 @@ void SpellCheck::PerformSpellCheck(SpellcheckRequest* param) { WebVector<blink::WebTextCheckingResult> results; SpellCheckParagraph(param->text(), &results); param->completion()->DidFinishCheckingText(results); -#if BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER) +#if defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER) spellcheck_renderer_metrics::RecordSpellcheckDuration( base::TimeTicks::Now() - param->start_ticks(), /*used_hunspell=*/true, /*used_native=*/false); -#endif // BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER) +#endif // defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER) } } #endif @@ -501,6 +501,15 @@ void SpellCheck::CreateTextCheckingResults( spellcheck_result.replacements; SpellCheckResult::Decoration decoration = spellcheck_result.decoration; +#if defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER) + // Ignore words that are in a script not supported by any of the enabled + // spellcheck languages. + if (spellcheck::UseBrowserSpellChecker() && + !IsWordInSupportedScript(misspelled_word)) { + continue; + } +#endif // defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER) + // Ignore words in custom dictionary. if (custom_dictionary_.SpellCheckWord(misspelled_word, 0, misspelled_word.length())) { @@ -530,9 +539,9 @@ void SpellCheck::CreateTextCheckingResults( decoration = SpellCheckResult::GRAMMAR; } } -#if BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER) +#if defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER) else if (filter == USE_HUNSPELL_FOR_HYBRID_CHECK && - spellcheck::UseWinHybridSpellChecker() && + spellcheck::UseBrowserSpellChecker() && EnabledLanguageCount() > 0) { // Remove the suggestions that were generated by the native spell checker, // otherwise Blink will cache them without asking for the suggestions @@ -562,7 +571,7 @@ void SpellCheck::CreateTextCheckingResults( } } } -#endif // BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER) +#endif // defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER) results.push_back( WebTextCheckingResult(static_cast<WebTextDecorationType>(decoration), @@ -607,3 +616,10 @@ void SpellCheck::NotifyDictionaryObservers( observer.OnDictionaryUpdated(words_added); } } + +bool SpellCheck::IsWordInSupportedScript(const base::string16& word) const { + return std::find_if(languages_.begin(), languages_.end(), + [word](const auto& language) { + return language->IsTextInSameScript(word); + }) != languages_.end(); +} |