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" |
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 "components/test_runner/test_runner.h" | 14 #include "components/test_runner/test_runner.h" |
14 #include "components/test_runner/web_task.h" | 15 #include "components/test_runner/web_task.h" |
15 #include "components/test_runner/web_test_delegate.h" | 16 #include "components/test_runner/web_test_delegate.h" |
16 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" | 17 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" |
17 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" | 18 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" |
18 | 19 |
19 namespace test_runner { | 20 namespace test_runner { |
20 | 21 |
21 SpellCheckClient::SpellCheckClient(TestRunner* test_runner) | 22 SpellCheckClient::SpellCheckClient(TestRunner* test_runner) |
22 : last_requested_text_checking_completion_(nullptr), | 23 : last_requested_text_checking_completion_(nullptr), |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 if (!misspelled_length) | 59 if (!misspelled_length) |
59 break; | 60 break; |
60 blink::WebTextCheckingResult result; | 61 blink::WebTextCheckingResult result; |
61 result.decoration = blink::WebTextDecorationTypeSpelling; | 62 result.decoration = blink::WebTextDecorationTypeSpelling; |
62 result.location = offset + misspelled_position; | 63 result.location = offset + misspelled_position; |
63 result.length = misspelled_length; | 64 result.length = misspelled_length; |
64 results.push_back(result); | 65 results.push_back(result); |
65 offset += misspelled_position + misspelled_length; | 66 offset += misspelled_position + misspelled_length; |
66 } | 67 } |
67 } | 68 } |
| 69 if (mask & blink::WebTextCheckingTypeGrammar) |
| 70 MockGrammarCheck::CheckGrammarOfString(text, &results); |
68 web_results->assign(results); | 71 web_results->assign(results); |
69 } | 72 } |
70 | 73 |
71 void SpellCheckClient::requestCheckingOfText( | 74 void SpellCheckClient::requestCheckingOfText( |
72 const blink::WebString& text, | 75 const blink::WebString& text, |
73 const blink::WebVector<uint32_t>& markers, | 76 const blink::WebVector<uint32_t>& markers, |
74 const blink::WebVector<unsigned>& marker_offsets, | 77 const blink::WebVector<unsigned>& marker_offsets, |
75 blink::WebTextCheckingCompletion* completion) { | 78 blink::WebTextCheckingCompletion* completion) { |
76 if (text.isEmpty()) { | 79 if (text.isEmpty()) { |
77 if (completion) | 80 if (completion) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 blink::WebString(text.substr(misspelled_position, misspelled_length)), | 115 blink::WebString(text.substr(misspelled_position, misspelled_length)), |
113 &suggestions); | 116 &suggestions); |
114 results.push_back(blink::WebTextCheckingResult( | 117 results.push_back(blink::WebTextCheckingResult( |
115 blink::WebTextDecorationTypeSpelling, | 118 blink::WebTextDecorationTypeSpelling, |
116 offset + misspelled_position, | 119 offset + misspelled_position, |
117 misspelled_length, | 120 misspelled_length, |
118 suggestions.isEmpty() ? blink::WebString() : suggestions[0])); | 121 suggestions.isEmpty() ? blink::WebString() : suggestions[0])); |
119 text = text.substr(misspelled_position + misspelled_length); | 122 text = text.substr(misspelled_position + misspelled_length); |
120 offset += misspelled_position + misspelled_length; | 123 offset += misspelled_position + misspelled_length; |
121 } | 124 } |
| 125 MockGrammarCheck::CheckGrammarOfString(last_requested_text_check_string_, |
| 126 &results); |
122 } | 127 } |
123 last_requested_text_checking_completion_->didFinishCheckingText(results); | 128 last_requested_text_checking_completion_->didFinishCheckingText(results); |
124 last_requested_text_checking_completion_ = 0; | 129 last_requested_text_checking_completion_ = 0; |
125 | 130 |
126 if (test_runner_->shouldDumpSpellCheckCallbacks()) | 131 if (test_runner_->shouldDumpSpellCheckCallbacks()) |
127 delegate_->PrintMessage("SpellCheckEvent: FinishLastTextCheck\n"); | 132 delegate_->PrintMessage("SpellCheckEvent: FinishLastTextCheck\n"); |
128 } | 133 } |
129 | 134 |
130 } // namespace test_runner | 135 } // namespace test_runner |
OLD | NEW |