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

Unified Diff: chrome/browser/spellchecker_mac.mm

Issue 160565: Adds support for the os x spelling panel to chromium. Users can... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 3 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
« no previous file with comments | « chrome/browser/spellchecker_linux.cc ('k') | chrome/browser/spellchecker_platform_engine.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/spellchecker_mac.mm
===================================================================
--- chrome/browser/spellchecker_mac.mm (revision 25643)
+++ chrome/browser/spellchecker_mac.mm (working copy)
@@ -92,11 +92,29 @@
return true;
}
-bool SpellCheckerPanelVisible() {
- return [[[NSSpellChecker sharedSpellChecker] spellingPanel]
- isVisible] ? true : false;
+bool SpellingPanelVisible() {
+ // This should only be called from the main thread.
+ return [[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible];
}
+void ShowSpellingPanel(bool show) {
+ if (show) {
+ [[[NSSpellChecker sharedSpellChecker] spellingPanel]
+ performSelectorOnMainThread:@selector(makeKeyAndOrderFront:) withObject:nil
+ waitUntilDone:YES];
+ } else {
+ [[[NSSpellChecker sharedSpellChecker] spellingPanel]
+ performSelectorOnMainThread:@selector(close) withObject:nil
+ waitUntilDone:YES];
+ }
+}
+
+void UpdateSpellingPanelWithMisspelledWord(const std::wstring& word) {
+ NSString * word_to_display = base::SysWideToNSString(word);
+ [[NSSpellChecker sharedSpellChecker]
+ updateSpellingPanelWithMisspelledWord:word_to_display];
+}
+
void Init() {
// This call must be made before the call to
// [NSSpellchecker sharedSpellChecker] or it will return nil.
@@ -121,7 +139,11 @@
[[NSSpellChecker sharedSpellChecker] setLanguage:NS_lang_to_set];
}
-bool CheckSpelling(const std::string& word_to_check) {
+static int last_seen_tag_;
+
+bool CheckSpelling(const std::string& word_to_check, int tag) {
+ last_seen_tag_ = tag;
+
// [[NSSpellChecker sharedSpellChecker] checkSpellingOfString] returns an
// NSRange that we can look at to determine if a word is misspelled.
NSRange spell_range = {0,0};
@@ -130,7 +152,9 @@
NSString* NS_word_to_check = base::SysUTF8ToNSString(word_to_check);
// Check the spelling, starting at the beginning of the word.
spell_range = [[NSSpellChecker sharedSpellChecker]
- checkSpellingOfString:NS_word_to_check startingAt:0];
+ checkSpellingOfString:NS_word_to_check startingAt:0
+ language:nil wrap:NO inSpellDocumentWithTag:tag
+ wordCount:NULL];
// If the length of the misspelled word == 0,
// then there is no misspelled word.
@@ -165,5 +189,20 @@
NSString *word_to_remove = base::SysWideToNSString(word);
[[NSSpellChecker sharedSpellChecker] unlearnWord:word_to_remove];
}
+
+int GetDocumentTag() {
+ NSInteger doc_tag = [NSSpellChecker uniqueSpellDocumentTag];
+ return static_cast<int>(doc_tag);
+}
+
+void IgnoreWord(const std::string& word) {
+ [[NSSpellChecker sharedSpellChecker] ignoreWord:base::SysUTF8ToNSString(word)
+ inSpellDocumentWithTag:last_seen_tag_];
+}
+
+void CloseDocumentWithTag(int tag) {
+ [[NSSpellChecker sharedSpellChecker]
+ closeSpellDocumentWithTag:static_cast<NSInteger>(tag)];
+}
} // namespace SpellCheckerPlatform
« no previous file with comments | « chrome/browser/spellchecker_linux.cc ('k') | chrome/browser/spellchecker_platform_engine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698