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

Side by Side Diff: chrome/browser/spellchecker_mac.mm

Issue 6392045: Integrating Mac OS Grammar checker into Chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated the patch to catch up WebKit side changes. Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 // This file implements the interface defined in spellchecker_platform_engine.h 5 // This file implements the interface defined in spellchecker_platform_engine.h
6 // for the OS X platform. 6 // for the OS X platform.
7 7
8 #include "chrome/browser/spellchecker_platform_engine.h" 8 #include "chrome/browser/spellchecker_platform_engine.h"
9 9
10 #import <Cocoa/Cocoa.h> 10 #import <Cocoa/Cocoa.h>
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 return static_cast<int>(doc_tag); 201 return static_cast<int>(doc_tag);
202 } 202 }
203 203
204 void IgnoreWord(const string16& word) { 204 void IgnoreWord(const string16& word) {
205 [[NSSpellChecker sharedSpellChecker] ignoreWord:base::SysUTF16ToNSString(word) 205 [[NSSpellChecker sharedSpellChecker] ignoreWord:base::SysUTF16ToNSString(word)
206 inSpellDocumentWithTag:last_seen_tag_]; 206 inSpellDocumentWithTag:last_seen_tag_];
207 } 207 }
208 208
209 void CloseDocumentWithTag(int tag) { 209 void CloseDocumentWithTag(int tag) {
210 [[NSSpellChecker sharedSpellChecker] 210 [[NSSpellChecker sharedSpellChecker]
211 closeSpellDocumentWithTag:static_cast<NSInteger>(tag)]; 211 closeSpellDocumentWithTag:static_cast<NSInteger>(tag)];
212 }
213
214
Hironori Bono 2011/02/09 05:43:51 nit: need one line-break between functions.
gmorrita 2011/02/10 02:15:21 Done.
215 void RequestTextCheck(
216 const string16& text, int tag,
217 Callback1<const TextCheckingResultList&>::Type* callback) {
Hironori Bono 2011/02/09 05:43:51 nit: align parameters if possible.
gmorrita 2011/02/10 02:15:21 Done.
218 // TODO(morrita): Use [NSSpellChecker requestCheckingOfString]
219 // when the build target goes upto 10.6
220 TextCheckingResultList check_results;
221 NSString* text_to_check = base::SysUTF16ToNSString(text);
222 size_t startingAt = 0;
Hironori Bono 2011/02/09 05:43:51 nit: variable names are all lowercase. <http://goo
gmorrita 2011/02/10 02:15:21 Done.
223 while (startingAt < text.size()) {
224 NSRange range = [[NSSpellChecker sharedSpellChecker]
225 checkSpellingOfString:text_to_check startingAt:startingAt
226 language:nil wrap:NO inSpellDocumentWithTag:tag
227 wordCount:NULL];
Hironori Bono 2011/02/09 05:43:51 If I understand this change correctly, this code i
gmorrita 2011/02/10 02:15:21 Certainly. So I extracted the check into a task cl
228 if (0 == range.length)
229 break;
230 check_results.push_back(TextCheckingResult(
231 TextCheckingResult::MISSPELLING, range.location, range.length));
232 startingAt = range.location + range.length;
233 }
234
235 callback->Run(check_results);
236 delete callback;
212 } 237 }
213 238
214 } // namespace SpellCheckerPlatform 239 } // namespace SpellCheckerPlatform
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698