| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/test_runner/spell_check_client.h" | 5 #include "components/test_runner/spell_check_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 return; | 93 return; |
| 94 last_requested_text_checking_completion_->didCancelCheckingText(); | 94 last_requested_text_checking_completion_->didCancelCheckingText(); |
| 95 last_requested_text_checking_completion_ = nullptr; | 95 last_requested_text_checking_completion_ = nullptr; |
| 96 } | 96 } |
| 97 | 97 |
| 98 void SpellCheckClient::FinishLastTextCheck() { | 98 void SpellCheckClient::FinishLastTextCheck() { |
| 99 if (!last_requested_text_checking_completion_) | 99 if (!last_requested_text_checking_completion_) |
| 100 return; | 100 return; |
| 101 std::vector<blink::WebTextCheckingResult> results; | 101 std::vector<blink::WebTextCheckingResult> results; |
| 102 int offset = 0; | 102 int offset = 0; |
| 103 base::string16 text = last_requested_text_check_string_; | 103 if (!spell_check_.IsMultiWordMisspelling(last_requested_text_check_string_, |
| 104 if (!spell_check_.IsMultiWordMisspelling(blink::WebString(text), &results)) { | 104 &results)) { |
| 105 base::string16 text = last_requested_text_check_string_.utf16(); |
| 105 while (text.length()) { | 106 while (text.length()) { |
| 106 int misspelled_position = 0; | 107 int misspelled_position = 0; |
| 107 int misspelled_length = 0; | 108 int misspelled_length = 0; |
| 108 spell_check_.SpellCheckWord( | 109 spell_check_.SpellCheckWord(blink::WebString::fromUTF16(text), |
| 109 blink::WebString(text), &misspelled_position, &misspelled_length); | 110 &misspelled_position, &misspelled_length); |
| 110 if (!misspelled_length) | 111 if (!misspelled_length) |
| 111 break; | 112 break; |
| 112 blink::WebVector<blink::WebString> suggestions; | 113 blink::WebVector<blink::WebString> suggestions; |
| 113 spell_check_.FillSuggestionList( | 114 spell_check_.FillSuggestionList( |
| 114 blink::WebString(text.substr(misspelled_position, misspelled_length)), | 115 blink::WebString::fromUTF16( |
| 116 text.substr(misspelled_position, misspelled_length)), |
| 115 &suggestions); | 117 &suggestions); |
| 116 results.push_back(blink::WebTextCheckingResult( | 118 results.push_back(blink::WebTextCheckingResult( |
| 117 blink::WebTextDecorationTypeSpelling, | 119 blink::WebTextDecorationTypeSpelling, |
| 118 offset + misspelled_position, | 120 offset + misspelled_position, |
| 119 misspelled_length, | 121 misspelled_length, |
| 120 suggestions.isEmpty() ? blink::WebString() : suggestions[0])); | 122 suggestions.isEmpty() ? blink::WebString() : suggestions[0])); |
| 121 text = text.substr(misspelled_position + misspelled_length); | 123 text = text.substr(misspelled_position + misspelled_length); |
| 122 offset += misspelled_position + misspelled_length; | 124 offset += misspelled_position + misspelled_length; |
| 123 } | 125 } |
| 124 MockGrammarCheck::CheckGrammarOfString(last_requested_text_check_string_, | 126 MockGrammarCheck::CheckGrammarOfString(last_requested_text_check_string_, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 return; | 159 return; |
| 158 | 160 |
| 159 v8::Context::Scope context_scope(context); | 161 v8::Context::Scope context_scope(context); |
| 160 | 162 |
| 161 frame->callFunctionEvenIfScriptDisabled( | 163 frame->callFunctionEvenIfScriptDisabled( |
| 162 v8::Local<v8::Function>::New(isolate, resolved_callback_), | 164 v8::Local<v8::Function>::New(isolate, resolved_callback_), |
| 163 context->Global(), 0, nullptr); | 165 context->Global(), 0, nullptr); |
| 164 } | 166 } |
| 165 | 167 |
| 166 } // namespace test_runner | 168 } // namespace test_runner |
| OLD | NEW |