OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/shell/renderer/test_runner/SpellCheckClient.h" | 5 #include "content/shell/renderer/test_runner/SpellCheckClient.h" |
6 | 6 |
7 #include "content/shell/renderer/test_runner/MockGrammarCheck.h" | 7 #include "content/shell/renderer/test_runner/MockGrammarCheck.h" |
8 #include "content/shell/renderer/test_runner/WebTestDelegate.h" | 8 #include "content/shell/renderer/test_runner/WebTestDelegate.h" |
9 #include "content/shell/renderer/test_runner/WebTestProxy.h" | 9 #include "content/shell/renderer/test_runner/WebTestProxy.h" |
10 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" | 10 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 { | 53 { |
54 // Check the spelling of the given text. | 54 // Check the spelling of the given text. |
55 m_spellcheck.spellCheckWord(text, &misspelledOffset, &misspelledLength); | 55 m_spellcheck.spellCheckWord(text, &misspelledOffset, &misspelledLength); |
56 } | 56 } |
57 | 57 |
58 void SpellCheckClient::checkTextOfParagraph(const WebString& text, WebTextChecki
ngTypeMask mask, WebVector<WebTextCheckingResult>* webResults) | 58 void SpellCheckClient::checkTextOfParagraph(const WebString& text, WebTextChecki
ngTypeMask mask, WebVector<WebTextCheckingResult>* webResults) |
59 { | 59 { |
60 vector<WebTextCheckingResult> results; | 60 vector<WebTextCheckingResult> results; |
61 if (mask & WebTextCheckingTypeSpelling) { | 61 if (mask & WebTextCheckingTypeSpelling) { |
62 size_t offset = 0; | 62 size_t offset = 0; |
63 string16 data = text; | 63 base::string16 data = text; |
64 while (offset < data.length()) { | 64 while (offset < data.length()) { |
65 int misspelledPosition = 0; | 65 int misspelledPosition = 0; |
66 int misspelledLength = 0; | 66 int misspelledLength = 0; |
67 m_spellcheck.spellCheckWord(data.substr(offset), &misspelledPosition
, &misspelledLength); | 67 m_spellcheck.spellCheckWord(data.substr(offset), &misspelledPosition
, &misspelledLength); |
68 if (!misspelledLength) | 68 if (!misspelledLength) |
69 break; | 69 break; |
70 WebTextCheckingResult result; | 70 WebTextCheckingResult result; |
71 result.decoration = WebTextDecorationTypeSpelling; | 71 result.decoration = WebTextDecorationTypeSpelling; |
72 result.location = offset + misspelledPosition; | 72 result.location = offset + misspelledPosition; |
73 result.length = misspelledLength; | 73 result.length = misspelledLength; |
(...skipping 28 matching lines...) Expand all Loading... |
102 else | 102 else |
103 m_delegate->postDelayedTask(new HostMethodTask(this, &SpellCheckClient::
finishLastTextCheck), 0); | 103 m_delegate->postDelayedTask(new HostMethodTask(this, &SpellCheckClient::
finishLastTextCheck), 0); |
104 } | 104 } |
105 | 105 |
106 void SpellCheckClient::finishLastTextCheck() | 106 void SpellCheckClient::finishLastTextCheck() |
107 { | 107 { |
108 if (!m_lastRequestedTextCheckingCompletion) | 108 if (!m_lastRequestedTextCheckingCompletion) |
109 return; | 109 return; |
110 vector<WebTextCheckingResult> results; | 110 vector<WebTextCheckingResult> results; |
111 int offset = 0; | 111 int offset = 0; |
112 string16 text = m_lastRequestedTextCheckString; | 112 base::string16 text = m_lastRequestedTextCheckString; |
113 if (!m_spellcheck.isMultiWordMisspelling(WebString(text), &results)) { | 113 if (!m_spellcheck.isMultiWordMisspelling(WebString(text), &results)) { |
114 while (text.length()) { | 114 while (text.length()) { |
115 int misspelledPosition = 0; | 115 int misspelledPosition = 0; |
116 int misspelledLength = 0; | 116 int misspelledLength = 0; |
117 m_spellcheck.spellCheckWord(WebString(text), &misspelledPosition, &m
isspelledLength); | 117 m_spellcheck.spellCheckWord(WebString(text), &misspelledPosition, &m
isspelledLength); |
118 if (!misspelledLength) | 118 if (!misspelledLength) |
119 break; | 119 break; |
120 WebVector<WebString> suggestions; | 120 WebVector<WebString> suggestions; |
121 m_spellcheck.fillSuggestionList(WebString(text.substr(misspelledPosi
tion, misspelledLength)), &suggestions); | 121 m_spellcheck.fillSuggestionList(WebString(text.substr(misspelledPosi
tion, misspelledLength)), &suggestions); |
122 results.push_back(WebTextCheckingResult(WebTextDecorationTypeSpellin
g, offset + misspelledPosition, misspelledLength, suggestions.isEmpty() ? WebStr
ing() : suggestions[0])); | 122 results.push_back(WebTextCheckingResult(WebTextDecorationTypeSpellin
g, offset + misspelledPosition, misspelledLength, suggestions.isEmpty() ? WebStr
ing() : suggestions[0])); |
(...skipping 11 matching lines...) Expand all Loading... |
134 WebString SpellCheckClient::autoCorrectWord(const WebString&) | 134 WebString SpellCheckClient::autoCorrectWord(const WebString&) |
135 { | 135 { |
136 // Returns an empty string as Mac WebKit ('WebKitSupport/WebEditorClient.mm'
) | 136 // Returns an empty string as Mac WebKit ('WebKitSupport/WebEditorClient.mm'
) |
137 // does. (If this function returns a non-empty string, WebKit replaces the | 137 // does. (If this function returns a non-empty string, WebKit replaces the |
138 // given misspelled string with the result one. This process executes some | 138 // given misspelled string with the result one. This process executes some |
139 // editor commands and causes layout-test failures.) | 139 // editor commands and causes layout-test failures.) |
140 return WebString(); | 140 return WebString(); |
141 } | 141 } |
142 | 142 |
143 } | 143 } |
OLD | NEW |