Fix compilation errors on OS X
This commit is contained in:
parent
4503aafe64
commit
5fae63a2f5
93 changed files with 242 additions and 317 deletions
|
@ -21,8 +21,6 @@ namespace api {
|
|||
|
||||
namespace {
|
||||
|
||||
const int kMaxAutoCorrectWordSize = 8;
|
||||
|
||||
bool HasWordCharacters(const base::string16& text, int index) {
|
||||
const base::char16* data = text.data();
|
||||
int length = text.length();
|
||||
|
@ -42,8 +40,7 @@ SpellCheckClient::SpellCheckClient(const std::string& language,
|
|||
bool auto_spell_correct_turned_on,
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> provider)
|
||||
: auto_spell_correct_turned_on_(auto_spell_correct_turned_on),
|
||||
isolate_(isolate),
|
||||
: isolate_(isolate),
|
||||
provider_(isolate, provider) {
|
||||
character_attributes_.SetDefaultLanguage(language);
|
||||
|
||||
|
@ -96,14 +93,6 @@ void SpellCheckClient::requestCheckingOfText(
|
|||
completionCallback->didFinishCheckingText(results);
|
||||
}
|
||||
|
||||
blink::WebString SpellCheckClient::autoCorrectWord(
|
||||
const blink::WebString& misspelledWord) {
|
||||
if (auto_spell_correct_turned_on_)
|
||||
return GetAutoCorrectionWord(base::string16(misspelledWord));
|
||||
else
|
||||
return blink::WebString();
|
||||
}
|
||||
|
||||
void SpellCheckClient::showSpellingUI(bool show) {
|
||||
}
|
||||
|
||||
|
@ -170,53 +159,6 @@ bool SpellCheckClient::SpellCheckWord(const base::string16& word_to_check) {
|
|||
return true;
|
||||
}
|
||||
|
||||
base::string16 SpellCheckClient::GetAutoCorrectionWord(
|
||||
const base::string16& word) {
|
||||
base::string16 autocorrect_word;
|
||||
|
||||
int word_length = static_cast<int>(word.size());
|
||||
if (word_length < 2 || word_length > kMaxAutoCorrectWordSize)
|
||||
return autocorrect_word;
|
||||
|
||||
base::char16 misspelled_word[kMaxAutoCorrectWordSize + 1];
|
||||
const base::char16* word_char = word.c_str();
|
||||
for (int i = 0; i <= kMaxAutoCorrectWordSize; ++i) {
|
||||
if (i >= word_length)
|
||||
misspelled_word[i] = 0;
|
||||
else
|
||||
misspelled_word[i] = word_char[i];
|
||||
}
|
||||
|
||||
// Swap adjacent characters and spellcheck.
|
||||
int misspelling_start, misspelling_len;
|
||||
for (int i = 0; i < word_length - 1; i++) {
|
||||
// Swap.
|
||||
std::swap(misspelled_word[i], misspelled_word[i + 1]);
|
||||
|
||||
// Check spelling.
|
||||
misspelling_start = misspelling_len = 0;
|
||||
spellCheck(blink::WebString(misspelled_word, word_length),
|
||||
misspelling_start,
|
||||
misspelling_len,
|
||||
NULL);
|
||||
|
||||
// Make decision: if only one swap produced a valid word, then we want to
|
||||
// return it. If we found two or more, we don't do autocorrection.
|
||||
if (misspelling_len == 0) {
|
||||
if (autocorrect_word.empty()) {
|
||||
autocorrect_word.assign(misspelled_word);
|
||||
} else {
|
||||
autocorrect_word.clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Restore the swapped characters.
|
||||
std::swap(misspelled_word[i], misspelled_word[i + 1]);
|
||||
}
|
||||
return autocorrect_word;
|
||||
}
|
||||
|
||||
// Returns whether or not the given string is a valid contraction.
|
||||
// This function is a fall-back when the SpellcheckWordIterator class
|
||||
// returns a concatenated word which is not in the selected dictionary
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue