| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007 Apple, Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple, Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Google, Inc. All rights reserved. | 3 * Copyright (C) 2012 Google, Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 void SpellCheckerClientImpl::requestCheckingOfString(TextCheckingRequest* reques
t) | 140 void SpellCheckerClientImpl::requestCheckingOfString(TextCheckingRequest* reques
t) |
| 141 { | 141 { |
| 142 if (!m_webView->spellCheckClient()) | 142 if (!m_webView->spellCheckClient()) |
| 143 return; | 143 return; |
| 144 const String& text = request->data().text(); | 144 const String& text = request->data().text(); |
| 145 const Vector<uint32_t>& markers = request->data().markers(); | 145 const Vector<uint32_t>& markers = request->data().markers(); |
| 146 const Vector<unsigned>& markerOffsets = request->data().offsets(); | 146 const Vector<unsigned>& markerOffsets = request->data().offsets(); |
| 147 m_webView->spellCheckClient()->requestCheckingOfText(text, markers, markerOf
fsets, new WebTextCheckingCompletionImpl(request)); | 147 m_webView->spellCheckClient()->requestCheckingOfText(text, markers, markerOf
fsets, new WebTextCheckingCompletionImpl(request)); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void SpellCheckerClientImpl::checkGrammarOfString(const String& text, WTF::Vecto
r<GrammarDetail>& details, int* badGrammarLocation, int* badGrammarLength) | |
| 151 { | |
| 152 if (badGrammarLocation) | |
| 153 *badGrammarLocation = -1; | |
| 154 if (badGrammarLength) | |
| 155 *badGrammarLength = 0; | |
| 156 | |
| 157 if (!m_webView->spellCheckClient()) | |
| 158 return; | |
| 159 WebVector<WebTextCheckingResult> webResults; | |
| 160 m_webView->spellCheckClient()->checkTextOfParagraph(text, WebTextCheckingTyp
eGrammar, &webResults); | |
| 161 if (!webResults.size()) | |
| 162 return; | |
| 163 | |
| 164 // Convert a list of WebTextCheckingResults to a list of GrammarDetails. If | |
| 165 // the converted vector of GrammarDetails has grammar errors, we set | |
| 166 // badGrammarLocation and badGrammarLength to tell WebKit that the input | |
| 167 // text has grammar errors. | |
| 168 for (size_t i = 0; i < webResults.size(); ++i) { | |
| 169 if (webResults[i].decoration == WebTextDecorationTypeGrammar) { | |
| 170 GrammarDetail detail; | |
| 171 detail.location = webResults[i].location; | |
| 172 detail.length = webResults[i].length; | |
| 173 detail.userDescription = webResults[i].replacement; | |
| 174 details.append(detail); | |
| 175 } | |
| 176 } | |
| 177 if (!details.size()) | |
| 178 return; | |
| 179 if (badGrammarLocation) | |
| 180 *badGrammarLocation = 0; | |
| 181 if (badGrammarLength) | |
| 182 *badGrammarLength = text.length(); | |
| 183 } | |
| 184 | |
| 185 void SpellCheckerClientImpl::updateSpellingUIWithMisspelledWord(const String& mi
sspelledWord) | 150 void SpellCheckerClientImpl::updateSpellingUIWithMisspelledWord(const String& mi
sspelledWord) |
| 186 { | 151 { |
| 187 if (m_webView->spellCheckClient()) | 152 if (m_webView->spellCheckClient()) |
| 188 m_webView->spellCheckClient()->updateSpellingUIWithMisspelledWord(WebStr
ing(misspelledWord)); | 153 m_webView->spellCheckClient()->updateSpellingUIWithMisspelledWord(WebStr
ing(misspelledWord)); |
| 189 } | 154 } |
| 190 | 155 |
| 191 void SpellCheckerClientImpl::showSpellingUI(bool show) | 156 void SpellCheckerClientImpl::showSpellingUI(bool show) |
| 192 { | 157 { |
| 193 if (m_webView->spellCheckClient()) | 158 if (m_webView->spellCheckClient()) |
| 194 m_webView->spellCheckClient()->showSpellingUI(show); | 159 m_webView->spellCheckClient()->showSpellingUI(show); |
| 195 } | 160 } |
| 196 | 161 |
| 197 bool SpellCheckerClientImpl::spellingUIIsShowing() | 162 bool SpellCheckerClientImpl::spellingUIIsShowing() |
| 198 { | 163 { |
| 199 if (m_webView->spellCheckClient()) | 164 if (m_webView->spellCheckClient()) |
| 200 return m_webView->spellCheckClient()->isShowingSpellingUI(); | 165 return m_webView->spellCheckClient()->isShowingSpellingUI(); |
| 201 return false; | 166 return false; |
| 202 } | 167 } |
| 203 | 168 |
| 204 } // namespace blink | 169 } // namespace blink |
| OLD | NEW |