Commit e95efb10 authored by andersca@apple.com's avatar andersca@apple.com

2011-01-04 Anders Carlsson <andersca@apple.com>

        Reviewed by John Sullivan.

        Add more spelling/grammar related methods
        https://bugs.webkit.org/show_bug.cgi?id=51886

        * UIProcess/API/mac/WKView.mm:
        (-[WKView validateUserInterfaceItem:]):
        Handle more selectors.

        (-[WKView showGuessPanel:]):
        Add stub.

        (-[WKView checkSpelling:]):
        Ditto.

        (-[WKView toggleAutomaticSpellingCorrection:]):
        Toggle automatic spelling correction.

        * UIProcess/TextChecker.h:
        Add setAutomaticSpellingCorrectionEnabled and isAutomaticSpellingCorrectionEnabled.

        * UIProcess/mac/TextCheckerMac.mm:
        (WebKit::TextChecker::setAutomaticSpellingCorrectionEnabled):
        (WebKit::TextChecker::isAutomaticSpellingCorrectionEnabled):
        Update the toggle.

        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
        * WebProcess/WebCoreSupport/mac/WebErrorsMac.mm:
        Add a Radar URL for the localization FIXMEs.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74989 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent fa16524f
2011-01-04 Anders Carlsson <andersca@apple.com>
Reviewed by John Sullivan.
Add more spelling/grammar related methods
https://bugs.webkit.org/show_bug.cgi?id=51886
* UIProcess/API/mac/WKView.mm:
(-[WKView validateUserInterfaceItem:]):
Handle more selectors.
(-[WKView showGuessPanel:]):
Add stub.
(-[WKView checkSpelling:]):
Ditto.
(-[WKView toggleAutomaticSpellingCorrection:]):
Toggle automatic spelling correction.
* UIProcess/TextChecker.h:
Add setAutomaticSpellingCorrectionEnabled and isAutomaticSpellingCorrectionEnabled.
* UIProcess/mac/TextCheckerMac.mm:
(WebKit::TextChecker::setAutomaticSpellingCorrectionEnabled):
(WebKit::TextChecker::isAutomaticSpellingCorrectionEnabled):
Update the toggle.
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
* WebProcess/WebCoreSupport/mac/WebErrorsMac.mm:
Add a Radar URL for the localization FIXMEs.
2011-01-04 Brent Fulgham <bfulgham@webkit.org>
Unreviewed build fix.
......@@ -54,6 +54,9 @@
#import <wtf/RefPtr.h>
#import <wtf/RetainPtr.h>
// FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized
#define UI_STRING(__str, __desc) [NSString stringWithUTF8String:__str]
@interface NSApplication (Details)
- (void)speakString:(NSString *)string;
@end
......@@ -330,8 +333,18 @@ static NSToolbarItem *toolbarItem(id <NSValidatedUserInterfaceItem> item)
{
SEL action = [item action];
if (action == @selector(stopSpeaking:))
return [NSApp isSpeaking];
if (action == @selector(showGuessPanel:)) {
if (NSMenuItem *menuItem = ::menuItem(item)) {
BOOL panelShowing = [[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible];
[menuItem setTitle:panelShowing
? UI_STRING("Hide Spelling and Grammar", "menu item title")
: UI_STRING("Show Spelling and Grammar", "menu item title")];
}
return _data->_page->selectionState().isContentEditable;
}
if (action == @selector(checkSpelling:))
return _data->_page->selectionState().isContentEditable;
if (action == @selector(toggleContinuousSpellChecking:)) {
bool enabled = TextChecker::isContinuousSpellCheckingAllowed();
......@@ -346,6 +359,15 @@ static NSToolbarItem *toolbarItem(id <NSValidatedUserInterfaceItem> item)
return YES;
}
if (action == @selector(toggleAutomaticSpellingCorrection:)) {
bool checked = TextChecker::isAutomaticSpellingCorrectionEnabled();
[menuItem(item) setState:checked ? NSOnState : NSOffState];
return _data->_page->selectionState().isContentEditable;
}
if (action == @selector(stopSpeaking:))
return [NSApp isSpeaking];
// Next, handle editor commands. Start by returning YES for anything that is not an editor command.
// Returning YES is the default thing to do in an AppKit validate method for any selector that is not recognized.
String commandName = commandNameForSelector([item action]);
......@@ -390,6 +412,16 @@ static void speakString(WKStringRef string, WKErrorRef error, void*)
[NSApp stopSpeaking:sender];
}
- (IBAction)showGuessPanel:(id)sender
{
// FIXME (WebKit2) <rdar://problem/8245958> Make Spelling/Grammar checking work in WebKit2
}
- (IBAction)checkSpelling:(id)sender
{
// FIXME (WebKit2) <rdar://problem/8245958> Make Spelling/Grammar checking work in WebKit2
}
- (IBAction)toggleContinuousSpellChecking:(id)sender
{
bool spellCheckingEnabled = !TextChecker::isContinuousSpellCheckingEnabled();
......@@ -408,6 +440,11 @@ static void speakString(WKStringRef string, WKErrorRef error, void*)
_data->_page->unmarkAllBadGrammar();
}
- (IBAction)toggleAutomaticSpellingCorrection:(id)sender
{
TextChecker::setAutomaticSpellingCorrectionEnabled(!TextChecker::isAutomaticSpellingCorrectionEnabled());
}
// Events
// Override this so that AppKit will send us arrow keys as key down events so we can
......
......@@ -36,6 +36,9 @@ public:
static bool isGrammarCheckingEnabled();
static void setGrammarCheckingEnabled(bool);
static void setAutomaticSpellingCorrectionEnabled(bool);
static bool isAutomaticSpellingCorrectionEnabled();
};
} // namespace WebKit
......
......@@ -29,6 +29,7 @@ namespace WebKit {
static bool continuousSpellCheckingEnabled;
static bool grammarCheckingEnabled;
static bool automaticSpellingCorrectionEnabled;
bool TextChecker::isContinuousSpellCheckingAllowed()
{
......@@ -72,4 +73,18 @@ void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled)
// because grammar checking only occurs on code paths that already preflight spell checking appropriately.
}
void TextChecker::setAutomaticSpellingCorrectionEnabled(bool isAutomaticSpellingCorrectionEnabled)
{
if (automaticSpellingCorrectionEnabled == isAutomaticSpellingCorrectionEnabled)
return;
automaticSpellingCorrectionEnabled = isAutomaticSpellingCorrectionEnabled;
[[NSSpellChecker sharedSpellChecker] updatePanels];
}
bool TextChecker::isAutomaticSpellingCorrectionEnabled()
{
return automaticSpellingCorrectionEnabled;
}
} // namespace WebKit
......@@ -41,7 +41,7 @@
#include <wtf/RetainPtr.h>
#endif
// FIXME: Implement localization.
// FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized
#define UI_STRING(string, description) String::fromUTF8(string, strlen(string))
#define UI_STRING_KEY(string, key, description) String::fromUTF8(string, strlen(string))
......
......@@ -40,6 +40,7 @@ static NSString * const WebKitErrorMIMETypeKey = @"WebKitErrorMIME
static NSString * const WebKitErrorPlugInNameKey = @"WebKitErrorPlugInNameKey";
static NSString * const WebKitErrorPlugInPageURLStringKey = @"WebKitErrorPlugInPageURLStringKey";
// FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized
#define UI_STRING(__str, __desc) [NSString stringWithUTF8String:__str]
// Policy errors
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment