parent
ac609a3d78
commit
a7e2856bf0
1 changed files with 9 additions and 3 deletions
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "base/numerics/safe_conversions.h"
|
||||||
#include "base/threading/thread_task_runner_handle.h"
|
#include "base/threading/thread_task_runner_handle.h"
|
||||||
#include "components/spellcheck/renderer/spellcheck_worditerator.h"
|
#include "components/spellcheck/renderer/spellcheck_worditerator.h"
|
||||||
#include "native_mate/converter.h"
|
#include "native_mate/converter.h"
|
||||||
|
@ -146,17 +147,22 @@ void SpellCheckClient::SpellCheckText() {
|
||||||
|
|
||||||
SpellCheckScope scope(*this);
|
SpellCheckScope scope(*this);
|
||||||
base::string16 word;
|
base::string16 word;
|
||||||
|
size_t word_start;
|
||||||
|
size_t word_length;
|
||||||
std::vector<base::string16> words;
|
std::vector<base::string16> words;
|
||||||
auto& word_map = pending_request_param_->wordmap();
|
auto& word_map = pending_request_param_->wordmap();
|
||||||
blink::WebTextCheckingResult result;
|
blink::WebTextCheckingResult result;
|
||||||
for (;;) { // Run until end of text
|
for (;;) { // Run until end of text
|
||||||
const auto status =
|
const auto status =
|
||||||
text_iterator_.GetNextWord(&word, &result.location, &result.length);
|
text_iterator_.GetNextWord(&word, &word_start, &word_length);
|
||||||
if (status == SpellcheckWordIterator::IS_END_OF_TEXT)
|
if (status == SpellcheckWordIterator::IS_END_OF_TEXT)
|
||||||
break;
|
break;
|
||||||
if (status == SpellcheckWordIterator::IS_SKIPPABLE)
|
if (status == SpellcheckWordIterator::IS_SKIPPABLE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
result.location = base::checked_cast<int>(word_start);
|
||||||
|
result.length = base::checked_cast<int>(word_length);
|
||||||
|
|
||||||
// If the given word is a concatenated word of two or more valid words
|
// If the given word is a concatenated word of two or more valid words
|
||||||
// (e.g. "hello:hello"), we should treat it as a valid word.
|
// (e.g. "hello:hello"), we should treat it as a valid word.
|
||||||
std::vector<base::string16> contraction_words;
|
std::vector<base::string16> contraction_words;
|
||||||
|
@ -233,8 +239,8 @@ bool SpellCheckClient::IsContraction(
|
||||||
contraction_iterator_.SetText(contraction.c_str(), contraction.length());
|
contraction_iterator_.SetText(contraction.c_str(), contraction.length());
|
||||||
|
|
||||||
base::string16 word;
|
base::string16 word;
|
||||||
int word_start;
|
size_t word_start;
|
||||||
int word_length;
|
size_t word_length;
|
||||||
for (auto status =
|
for (auto status =
|
||||||
contraction_iterator_.GetNextWord(&word, &word_start, &word_length);
|
contraction_iterator_.GetNextWord(&word, &word_start, &word_length);
|
||||||
status != SpellcheckWordIterator::IS_END_OF_TEXT;
|
status != SpellcheckWordIterator::IS_END_OF_TEXT;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue