summaryrefslogtreecommitdiffstats
path: root/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-06-02 12:07:03 +0100
committerBen Murdoch <benm@google.com>2011-06-10 10:47:21 +0100
commit2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 (patch)
treee4964fbd1cb70599f7718ff03e50ea1dab33890b /Source/WebKit2/UIProcess/mac/TextCheckerMac.mm
parent87bdf0060a247bfbe668342b87e0874182e0ffa9 (diff)
downloadexternal_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.zip
external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.gz
external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.bz2
Merge WebKit at r84325: Initial merge by git.
Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b
Diffstat (limited to 'Source/WebKit2/UIProcess/mac/TextCheckerMac.mm')
-rw-r--r--Source/WebKit2/UIProcess/mac/TextCheckerMac.mm60
1 files changed, 54 insertions, 6 deletions
diff --git a/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm b/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm
index cef3a55..29493f9 100644
--- a/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm
+++ b/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm
@@ -27,10 +27,13 @@
#import "TextChecker.h"
#import "TextCheckerState.h"
+#import <WebCore/NotImplemented.h>
#import <wtf/RetainPtr.h>
#ifndef BUILDING_ON_SNOW_LEOPARD
-#import <AppKit/NSTextChecker.h>
+@interface NSSpellChecker (WebNSSpellCheckerDetails)
+- (NSString *)languageForWordRange:(NSRange)range inString:(NSString *)string orthography:(NSOrthography *)orthography;
+@end
#endif
static NSString* const WebAutomaticSpellingCorrectionEnabled = @"WebAutomaticSpellingCorrectionEnabled";
@@ -195,7 +198,22 @@ void TextChecker::setSmartInsertDeleteEnabled(bool flag)
[[NSUserDefaults standardUserDefaults] setBool:flag forKey:WebSmartInsertDeleteEnabled];
}
-int64_t TextChecker::uniqueSpellDocumentTag()
+bool TextChecker::substitutionsPanelIsShowing()
+{
+ return [[[NSSpellChecker sharedSpellChecker] substitutionsPanel] isVisible];
+}
+
+void TextChecker::toggleSubstitutionsPanelIsShowing()
+{
+ NSPanel *substitutionsPanel = [[NSSpellChecker sharedSpellChecker] substitutionsPanel];
+ if ([substitutionsPanel isVisible]) {
+ [substitutionsPanel orderOut:nil];
+ return;
+ }
+ [substitutionsPanel orderFront:nil];
+}
+
+int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy*)
{
return [NSSpellChecker uniqueSpellDocumentTag];
}
@@ -205,6 +223,8 @@ void TextChecker::closeSpellDocumentWithTag(int64_t tag)
[[NSSpellChecker sharedSpellChecker] closeSpellDocumentWithTag:tag];
}
+#if USE(UNIFIED_TEXT_CHECKING)
+
Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes)
{
Vector<TextCheckingResult> results;
@@ -292,12 +312,40 @@ Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocume
return results;
}
-void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
+#endif
+
+void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&)
+{
+ // Mac uses checkTextOfParagraph instead.
+ notImplemented();
+}
+
+void TextChecker::checkGrammarOfString(int64_t, const UChar*, uint32_t, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&)
+{
+ // Mac uses checkTextOfParagraph instead.
+ notImplemented();
+}
+
+bool TextChecker::spellingUIIsShowing()
+{
+ return [[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible];
+}
+
+void TextChecker::toggleSpellingUIIsShowing()
+{
+ NSPanel *spellingPanel = [[NSSpellChecker sharedSpellChecker] spellingPanel];
+ if ([spellingPanel isVisible])
+ [spellingPanel orderOut:nil];
+ else
+ [spellingPanel orderFront:nil];
+}
+
+void TextChecker::updateSpellingUIWithMisspelledWord(int64_t, const String& misspelledWord)
{
[[NSSpellChecker sharedSpellChecker] updateSpellingPanelWithMisspelledWord:misspelledWord];
}
-void TextChecker::updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const GrammarDetail& grammarDetail)
+void TextChecker::updateSpellingUIWithGrammarString(int64_t, const String& badGrammarPhrase, const GrammarDetail& grammarDetail)
{
RetainPtr<NSMutableArray> corrections(AdoptNS, [[NSMutableArray alloc] init]);
for (size_t i = 0; i < grammarDetail.guesses.size(); ++i) {
@@ -307,7 +355,7 @@ void TextChecker::updateSpellingUIWithGrammarString(const String& badGrammarPhra
NSRange grammarRange = NSMakeRange(grammarDetail.location, grammarDetail.length);
NSString *grammarUserDescription = grammarDetail.userDescription;
- RetainPtr<NSMutableDictionary> grammarDetailDict(AdoptNS, [[NSDictionary alloc] initWithObjectsAndKeys:[NSValue valueWithRange:grammarRange], NSGrammarRange, grammarUserDescription, NSGrammarUserDescription, corrections.get(), NSGrammarCorrections, nil]);
+ RetainPtr<NSDictionary> grammarDetailDict(AdoptNS, [[NSDictionary alloc] initWithObjectsAndKeys:[NSValue valueWithRange:grammarRange], NSGrammarRange, grammarUserDescription, NSGrammarUserDescription, corrections.get(), NSGrammarCorrections, nil]);
[[NSSpellChecker sharedSpellChecker] updateSpellingPanelWithGrammarString:badGrammarPhrase detail:grammarDetailDict.get()];
}
@@ -331,7 +379,7 @@ void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word
guesses.append(guess);
}
-void TextChecker::learnWord(const String& word)
+void TextChecker::learnWord(int64_t, const String& word)
{
[[NSSpellChecker sharedSpellChecker] learnWord:word];
}