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

Side by Side Diff: third_party/WebKit/Source/web/SpellCheckerClientImpl.cpp

Issue 2211813002: Revert removal of grammar checking and marking code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor fix Created 4 years, 4 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 /* 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
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
150 void SpellCheckerClientImpl::updateSpellingUIWithMisspelledWord(const String& mi sspelledWord) 185 void SpellCheckerClientImpl::updateSpellingUIWithMisspelledWord(const String& mi sspelledWord)
151 { 186 {
152 if (m_webView->spellCheckClient()) 187 if (m_webView->spellCheckClient())
153 m_webView->spellCheckClient()->updateSpellingUIWithMisspelledWord(WebStr ing(misspelledWord)); 188 m_webView->spellCheckClient()->updateSpellingUIWithMisspelledWord(WebStr ing(misspelledWord));
154 } 189 }
155 190
156 void SpellCheckerClientImpl::showSpellingUI(bool show) 191 void SpellCheckerClientImpl::showSpellingUI(bool show)
157 { 192 {
158 if (m_webView->spellCheckClient()) 193 if (m_webView->spellCheckClient())
159 m_webView->spellCheckClient()->showSpellingUI(show); 194 m_webView->spellCheckClient()->showSpellingUI(show);
160 } 195 }
161 196
162 bool SpellCheckerClientImpl::spellingUIIsShowing() 197 bool SpellCheckerClientImpl::spellingUIIsShowing()
163 { 198 {
164 if (m_webView->spellCheckClient()) 199 if (m_webView->spellCheckClient())
165 return m_webView->spellCheckClient()->isShowingSpellingUI(); 200 return m_webView->spellCheckClient()->isShowingSpellingUI();
166 return false; 201 return false;
167 } 202 }
168 203
169 } // namespace blink 204 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/SpellCheckerClientImpl.h ('k') | third_party/WebKit/Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698