Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: content/shell/test_runner/spell_check_client.cc

Issue 2707183003: Move //components/test_runner back into //content/shell (Closed)
Patch Set: Trim DEPS Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/shell/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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "components/test_runner/mock_grammar_check.h" 13 #include "content/shell/test_runner/mock_grammar_check.h"
14 #include "components/test_runner/test_runner.h" 14 #include "content/shell/test_runner/test_runner.h"
15 #include "components/test_runner/web_test_delegate.h" 15 #include "content/shell/test_runner/web_test_delegate.h"
16 #include "third_party/WebKit/public/web/WebFrame.h" 16 #include "third_party/WebKit/public/web/WebFrame.h"
17 #include "third_party/WebKit/public/web/WebKit.h" 17 #include "third_party/WebKit/public/web/WebKit.h"
18 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" 18 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h"
19 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" 19 #include "third_party/WebKit/public/web/WebTextCheckingResult.h"
20 20
21 namespace test_runner { 21 namespace test_runner {
22 22
23 SpellCheckClient::SpellCheckClient(TestRunner* test_runner) 23 SpellCheckClient::SpellCheckClient(TestRunner* test_runner)
24 : last_requested_text_checking_completion_(nullptr), 24 : last_requested_text_checking_completion_(nullptr),
25 test_runner_(test_runner), 25 test_runner_(test_runner),
26 weak_factory_(this) { 26 weak_factory_(this) {
27 DCHECK(test_runner); 27 DCHECK(test_runner);
28 } 28 }
29 29
30 SpellCheckClient::~SpellCheckClient() { 30 SpellCheckClient::~SpellCheckClient() {}
31 }
32 31
33 void SpellCheckClient::SetDelegate(WebTestDelegate* delegate) { 32 void SpellCheckClient::SetDelegate(WebTestDelegate* delegate) {
34 delegate_ = delegate; 33 delegate_ = delegate;
35 } 34 }
36 35
37 void SpellCheckClient::SetEnabled(bool enabled) { 36 void SpellCheckClient::SetEnabled(bool enabled) {
38 enabled_ = enabled; 37 enabled_ = enabled;
39 } 38 }
40 39
41 void SpellCheckClient::Reset() { 40 void SpellCheckClient::Reset() {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 spell_check_.SpellCheckWord(blink::WebString::fromUTF16(text), 108 spell_check_.SpellCheckWord(blink::WebString::fromUTF16(text),
110 &misspelled_position, &misspelled_length); 109 &misspelled_position, &misspelled_length);
111 if (!misspelled_length) 110 if (!misspelled_length)
112 break; 111 break;
113 blink::WebVector<blink::WebString> suggestions; 112 blink::WebVector<blink::WebString> suggestions;
114 spell_check_.FillSuggestionList( 113 spell_check_.FillSuggestionList(
115 blink::WebString::fromUTF16( 114 blink::WebString::fromUTF16(
116 text.substr(misspelled_position, misspelled_length)), 115 text.substr(misspelled_position, misspelled_length)),
117 &suggestions); 116 &suggestions);
118 results.push_back(blink::WebTextCheckingResult( 117 results.push_back(blink::WebTextCheckingResult(
119 blink::WebTextDecorationTypeSpelling, 118 blink::WebTextDecorationTypeSpelling, offset + misspelled_position,
120 offset + misspelled_position,
121 misspelled_length, 119 misspelled_length,
122 suggestions.isEmpty() ? blink::WebString() : suggestions[0])); 120 suggestions.isEmpty() ? blink::WebString() : suggestions[0]));
123 text = text.substr(misspelled_position + misspelled_length); 121 text = text.substr(misspelled_position + misspelled_length);
124 offset += misspelled_position + misspelled_length; 122 offset += misspelled_position + misspelled_length;
125 } 123 }
126 MockGrammarCheck::CheckGrammarOfString(last_requested_text_check_string_, 124 MockGrammarCheck::CheckGrammarOfString(last_requested_text_check_string_,
127 &results); 125 &results);
128 } 126 }
129 last_requested_text_checking_completion_->didFinishCheckingText(results); 127 last_requested_text_checking_completion_->didFinishCheckingText(results);
130 last_requested_text_checking_completion_ = 0; 128 last_requested_text_checking_completion_ = 0;
(...skipping 28 matching lines...) Expand all
159 return; 157 return;
160 158
161 v8::Context::Scope context_scope(context); 159 v8::Context::Scope context_scope(context);
162 160
163 frame->callFunctionEvenIfScriptDisabled( 161 frame->callFunctionEvenIfScriptDisabled(
164 v8::Local<v8::Function>::New(isolate, resolved_callback_), 162 v8::Local<v8::Function>::New(isolate, resolved_callback_),
165 context->Global(), 0, nullptr); 163 context->Global(), 0, nullptr);
166 } 164 }
167 165
168 } // namespace test_runner 166 } // namespace test_runner
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698