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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/spellchecker_mac.mm
diff --git a/chrome/browser/spellchecker_mac.mm b/chrome/browser/spellchecker_mac.mm
index ead554fd8292fc67c21834d33ef255643ec79d34..f182513abca84597925d19e303989148a992ccba 100644
--- a/chrome/browser/spellchecker_mac.mm
+++ b/chrome/browser/spellchecker_mac.mm
@@ -208,7 +208,32 @@ void IgnoreWord(const string16& word) {
void CloseDocumentWithTag(int tag) {
[[NSSpellChecker sharedSpellChecker]
- closeSpellDocumentWithTag:static_cast<NSInteger>(tag)];
+ closeSpellDocumentWithTag:static_cast<NSInteger>(tag)];
+}
+
+
Hironori Bono 2011/02/09 05:43:51 nit: need one line-break between functions.
gmorrita 2011/02/10 02:15:21 Done.
+void RequestTextCheck(
+ const string16& text, int tag,
+ 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.
+ // TODO(morrita): Use [NSSpellChecker requestCheckingOfString]
+ // when the build target goes upto 10.6
+ TextCheckingResultList check_results;
+ NSString* text_to_check = base::SysUTF16ToNSString(text);
+ 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.
+ while (startingAt < text.size()) {
+ NSRange range = [[NSSpellChecker sharedSpellChecker]
+ checkSpellingOfString:text_to_check startingAt:startingAt
+ language:nil wrap:NO inSpellDocumentWithTag:tag
+ 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
+ if (0 == range.length)
+ break;
+ check_results.push_back(TextCheckingResult(
+ TextCheckingResult::MISSPELLING, range.location, range.length));
+ startingAt = range.location + range.length;
+ }
+
+ callback->Run(check_results);
+ delete callback;
}
} // namespace SpellCheckerPlatform

Powered by Google App Engine
This is Rietveld 408576698