OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 { | 79 { |
80 // Check the spelling of the given text. | 80 // Check the spelling of the given text. |
81 m_spellcheck.spellCheckWord(text, &misspelledOffset, &misspelledLength); | 81 m_spellcheck.spellCheckWord(text, &misspelledOffset, &misspelledLength); |
82 } | 82 } |
83 | 83 |
84 void SpellCheckClient::checkTextOfParagraph(const WebString& text, WebTextChecki
ngTypeMask mask, WebVector<WebTextCheckingResult>* webResults) | 84 void SpellCheckClient::checkTextOfParagraph(const WebString& text, WebTextChecki
ngTypeMask mask, WebVector<WebTextCheckingResult>* webResults) |
85 { | 85 { |
86 vector<WebTextCheckingResult> results; | 86 vector<WebTextCheckingResult> results; |
87 if (mask & WebTextCheckingTypeSpelling) { | 87 if (mask & WebTextCheckingTypeSpelling) { |
88 size_t offset = 0; | 88 size_t offset = 0; |
89 string16 data = text; | 89 base::string16 data = text; |
90 while (offset < data.length()) { | 90 while (offset < data.length()) { |
91 int misspelledPosition = 0; | 91 int misspelledPosition = 0; |
92 int misspelledLength = 0; | 92 int misspelledLength = 0; |
93 m_spellcheck.spellCheckWord(data.substr(offset), &misspelledPosition
, &misspelledLength); | 93 m_spellcheck.spellCheckWord(data.substr(offset), &misspelledPosition
, &misspelledLength); |
94 if (!misspelledLength) | 94 if (!misspelledLength) |
95 break; | 95 break; |
96 WebTextCheckingResult result; | 96 WebTextCheckingResult result; |
97 result.decoration = WebTextDecorationTypeSpelling; | 97 result.decoration = WebTextDecorationTypeSpelling; |
98 result.location = offset + misspelledPosition; | 98 result.location = offset + misspelledPosition; |
99 result.length = misspelledLength; | 99 result.length = misspelledLength; |
(...skipping 28 matching lines...) Expand all Loading... |
128 else | 128 else |
129 m_delegate->postDelayedTask(new HostMethodTask(this, &SpellCheckClient::
finishLastTextCheck), 0); | 129 m_delegate->postDelayedTask(new HostMethodTask(this, &SpellCheckClient::
finishLastTextCheck), 0); |
130 } | 130 } |
131 | 131 |
132 void SpellCheckClient::finishLastTextCheck() | 132 void SpellCheckClient::finishLastTextCheck() |
133 { | 133 { |
134 if (!m_lastRequestedTextCheckingCompletion) | 134 if (!m_lastRequestedTextCheckingCompletion) |
135 return; | 135 return; |
136 vector<WebTextCheckingResult> results; | 136 vector<WebTextCheckingResult> results; |
137 int offset = 0; | 137 int offset = 0; |
138 string16 text = m_lastRequestedTextCheckString; | 138 base::string16 text = m_lastRequestedTextCheckString; |
139 if (!m_spellcheck.isMultiWordMisspelling(WebString(text), &results)) { | 139 if (!m_spellcheck.isMultiWordMisspelling(WebString(text), &results)) { |
140 while (text.length()) { | 140 while (text.length()) { |
141 int misspelledPosition = 0; | 141 int misspelledPosition = 0; |
142 int misspelledLength = 0; | 142 int misspelledLength = 0; |
143 m_spellcheck.spellCheckWord(WebString(text), &misspelledPosition, &m
isspelledLength); | 143 m_spellcheck.spellCheckWord(WebString(text), &misspelledPosition, &m
isspelledLength); |
144 if (!misspelledLength) | 144 if (!misspelledLength) |
145 break; | 145 break; |
146 WebVector<WebString> suggestions; | 146 WebVector<WebString> suggestions; |
147 m_spellcheck.fillSuggestionList(WebString(text.substr(misspelledPosi
tion, misspelledLength)), &suggestions); | 147 m_spellcheck.fillSuggestionList(WebString(text.substr(misspelledPosi
tion, misspelledLength)), &suggestions); |
148 results.push_back(WebTextCheckingResult(WebTextDecorationTypeSpellin
g, offset + misspelledPosition, misspelledLength, suggestions.isEmpty() ? WebStr
ing() : suggestions[0])); | 148 results.push_back(WebTextCheckingResult(WebTextDecorationTypeSpellin
g, offset + misspelledPosition, misspelledLength, suggestions.isEmpty() ? WebStr
ing() : suggestions[0])); |
(...skipping 11 matching lines...) Expand all Loading... |
160 WebString SpellCheckClient::autoCorrectWord(const WebString&) | 160 WebString SpellCheckClient::autoCorrectWord(const WebString&) |
161 { | 161 { |
162 // Returns an empty string as Mac WebKit ('WebKitSupport/WebEditorClient.mm'
) | 162 // Returns an empty string as Mac WebKit ('WebKitSupport/WebEditorClient.mm'
) |
163 // does. (If this function returns a non-empty string, WebKit replaces the | 163 // does. (If this function returns a non-empty string, WebKit replaces the |
164 // given misspelled string with the result one. This process executes some | 164 // given misspelled string with the result one. This process executes some |
165 // editor commands and causes layout-test failures.) | 165 // editor commands and causes layout-test failures.) |
166 return WebString(); | 166 return WebString(); |
167 } | 167 } |
168 | 168 |
169 } | 169 } |
OLD | NEW |