Changeset 74989 in webkit


Ignore:
Timestamp:
Jan 4, 2011 11:49:18 AM (13 years ago)
Author:
andersca@apple.com
Message:

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.
Location:
trunk/WebKit2
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r74988 r74989  
     12011-01-04  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by John Sullivan.
     4
     5        Add more spelling/grammar related methods
     6        https://bugs.webkit.org/show_bug.cgi?id=51886
     7
     8        * UIProcess/API/mac/WKView.mm:
     9        (-[WKView validateUserInterfaceItem:]):
     10        Handle more selectors.
     11
     12        (-[WKView showGuessPanel:]):
     13        Add stub.
     14
     15        (-[WKView checkSpelling:]):
     16        Ditto.
     17
     18        (-[WKView toggleAutomaticSpellingCorrection:]):
     19        Toggle automatic spelling correction.
     20
     21        * UIProcess/TextChecker.h:
     22        Add setAutomaticSpellingCorrectionEnabled and isAutomaticSpellingCorrectionEnabled.
     23
     24        * UIProcess/mac/TextCheckerMac.mm:
     25        (WebKit::TextChecker::setAutomaticSpellingCorrectionEnabled):
     26        (WebKit::TextChecker::isAutomaticSpellingCorrectionEnabled):
     27        Update the toggle.
     28
     29        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
     30        * WebProcess/WebCoreSupport/mac/WebErrorsMac.mm:
     31        Add a Radar URL for the localization FIXMEs.
     32
    1332011-01-04  Brent Fulgham  <bfulgham@webkit.org>
    234
  • trunk/WebKit2/UIProcess/API/mac/WKView.mm

    r74893 r74989  
    5555#import <wtf/RetainPtr.h>
    5656
     57// FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized
     58#define UI_STRING(__str, __desc) [NSString stringWithUTF8String:__str]
     59
    5760@interface NSApplication (Details)
    5861- (void)speakString:(NSString *)string;
     
    331334    SEL action = [item action];
    332335
    333     if (action == @selector(stopSpeaking:))
    334         return [NSApp isSpeaking];
     336    if (action == @selector(showGuessPanel:)) {
     337        if (NSMenuItem *menuItem = ::menuItem(item)) {
     338            BOOL panelShowing = [[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible];
     339            [menuItem setTitle:panelShowing
     340                ? UI_STRING("Hide Spelling and Grammar", "menu item title")
     341                : UI_STRING("Show Spelling and Grammar", "menu item title")];
     342        }
     343        return _data->_page->selectionState().isContentEditable;
     344    }
     345
     346    if (action == @selector(checkSpelling:))
     347        return _data->_page->selectionState().isContentEditable;
    335348
    336349    if (action == @selector(toggleContinuousSpellChecking:)) {
     
    346359        return YES;
    347360    }
     361
     362    if (action == @selector(toggleAutomaticSpellingCorrection:)) {
     363        bool checked = TextChecker::isAutomaticSpellingCorrectionEnabled();
     364        [menuItem(item) setState:checked ? NSOnState : NSOffState];
     365        return _data->_page->selectionState().isContentEditable;
     366    }
     367
     368    if (action == @selector(stopSpeaking:))
     369        return [NSApp isSpeaking];
    348370
    349371    // Next, handle editor commands. Start by returning YES for anything that is not an editor command.
     
    391413}
    392414
     415- (IBAction)showGuessPanel:(id)sender
     416{
     417    // FIXME (WebKit2) <rdar://problem/8245958> Make Spelling/Grammar checking work in WebKit2
     418}
     419
     420- (IBAction)checkSpelling:(id)sender
     421{
     422    // FIXME (WebKit2) <rdar://problem/8245958> Make Spelling/Grammar checking work in WebKit2
     423}
     424
    393425- (IBAction)toggleContinuousSpellChecking:(id)sender
    394426{
     
    407439    if (!grammarCheckingEnabled)
    408440        _data->_page->unmarkAllBadGrammar();
     441}
     442
     443- (IBAction)toggleAutomaticSpellingCorrection:(id)sender
     444{
     445    TextChecker::setAutomaticSpellingCorrectionEnabled(!TextChecker::isAutomaticSpellingCorrectionEnabled());
    409446}
    410447
  • trunk/WebKit2/UIProcess/TextChecker.h

    r74376 r74989  
    3737    static bool isGrammarCheckingEnabled();
    3838    static void setGrammarCheckingEnabled(bool);
     39
     40    static void setAutomaticSpellingCorrectionEnabled(bool);
     41    static bool isAutomaticSpellingCorrectionEnabled();
    3942};
    4043
  • trunk/WebKit2/UIProcess/mac/TextCheckerMac.mm

    r74376 r74989  
    3030static bool continuousSpellCheckingEnabled;
    3131static bool grammarCheckingEnabled;
     32static bool automaticSpellingCorrectionEnabled;
    3233   
    3334bool TextChecker::isContinuousSpellCheckingAllowed()
     
    7374}
    7475
     76void TextChecker::setAutomaticSpellingCorrectionEnabled(bool isAutomaticSpellingCorrectionEnabled)
     77{
     78    if (automaticSpellingCorrectionEnabled == isAutomaticSpellingCorrectionEnabled)
     79        return;
     80
     81    automaticSpellingCorrectionEnabled = isAutomaticSpellingCorrectionEnabled;
     82    [[NSSpellChecker sharedSpellChecker] updatePanels];
     83}
     84
     85bool TextChecker::isAutomaticSpellingCorrectionEnabled()
     86{
     87    return automaticSpellingCorrectionEnabled;
     88}
     89
    7590} // namespace WebKit
  • trunk/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp

    r74941 r74989  
    4242#endif
    4343
    44 // FIXME: Implement localization.
     44// FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized
    4545#define UI_STRING(string, description) String::fromUTF8(string, strlen(string))
    4646#define UI_STRING_KEY(string, key, description) String::fromUTF8(string, strlen(string))
  • trunk/WebKit2/WebProcess/WebCoreSupport/mac/WebErrorsMac.mm

    r71033 r74989  
    4141static NSString * const WebKitErrorPlugInPageURLStringKey =    @"WebKitErrorPlugInPageURLStringKey";
    4242
     43// FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized
    4344#define UI_STRING(__str, __desc) [NSString stringWithUTF8String:__str]
    4445
Note: See TracChangeset for help on using the changeset viewer.