Changeset 74376 in webkit


Ignore:
Timestamp:
Dec 20, 2010 4:35:16 PM (13 years ago)
Author:
andersca@apple.com
Message:

2010-12-20 Anders Carlsson <andersca@apple.com>

Reviewed by Sam Weinig.

Add a TextChecker class, hook up spelling and grammar toggling
https://bugs.webkit.org/show_bug.cgi?id=51363

  • UIProcess/API/mac/WKView.mm: (-[WKView validateUserInterfaceItem:]): (-[WKView toggleContinuousSpellChecking:]): (-[WKView toggleGrammarChecking:]):
  • UIProcess/TextChecker.h: Added.
  • UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::unmarkAllMisspellings): (WebKit::WebPageProxy::unmarkAllBadGrammar):
  • UIProcess/WebPageProxy.h:
  • UIProcess/mac/TextCheckerMac.mm: Added. (WebKit::TextChecker::isContinuousSpellCheckingAllowed): (WebKit::TextChecker::isContinuousSpellCheckingEnabled): (WebKit::TextChecker::setContinuousSpellCheckingEnabled): (WebKit::TextChecker::isGrammarCheckingEnabled): (WebKit::TextChecker::setGrammarCheckingEnabled):
  • UIProcess/qt/TextCheckerQt.cpp: Added. (WebKit::TextChecker::isContinuousSpellCheckingAllowed): (WebKit::TextChecker::isContinuousSpellCheckingEnabled): (WebKit::TextChecker::setContinuousSpellCheckingEnabled): (WebKit::TextChecker::isGrammarCheckingEnabled): (WebKit::TextChecker::setGrammarCheckingEnabled):
  • UIProcess/win/TextCheckerWin.cpp: Added. (WebKit::TextChecker::isContinuousSpellCheckingAllowed): (WebKit::TextChecker::isContinuousSpellCheckingEnabled): (WebKit::TextChecker::setContinuousSpellCheckingEnabled): (WebKit::TextChecker::isGrammarCheckingEnabled): (WebKit::TextChecker::setGrammarCheckingEnabled):
  • WebKit2.pro:
  • WebKit2.xcodeproj/project.pbxproj:
  • WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::unmarkAllMisspellings): (WebKit::WebPage::unmarkAllBadGrammar):
  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:
  • win/WebKit2.vcproj:
Location:
trunk/WebKit2
Files:
4 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r74359 r74376  
     12010-12-20  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Add a TextChecker class, hook up spelling and grammar toggling
     6        https://bugs.webkit.org/show_bug.cgi?id=51363
     7
     8        * UIProcess/API/mac/WKView.mm:
     9        (-[WKView validateUserInterfaceItem:]):
     10        (-[WKView toggleContinuousSpellChecking:]):
     11        (-[WKView toggleGrammarChecking:]):
     12        * UIProcess/TextChecker.h: Added.
     13        * UIProcess/WebPageProxy.cpp:
     14        (WebKit::WebPageProxy::unmarkAllMisspellings):
     15        (WebKit::WebPageProxy::unmarkAllBadGrammar):
     16        * UIProcess/WebPageProxy.h:
     17        * UIProcess/mac/TextCheckerMac.mm: Added.
     18        (WebKit::TextChecker::isContinuousSpellCheckingAllowed):
     19        (WebKit::TextChecker::isContinuousSpellCheckingEnabled):
     20        (WebKit::TextChecker::setContinuousSpellCheckingEnabled):
     21        (WebKit::TextChecker::isGrammarCheckingEnabled):
     22        (WebKit::TextChecker::setGrammarCheckingEnabled):
     23        * UIProcess/qt/TextCheckerQt.cpp: Added.
     24        (WebKit::TextChecker::isContinuousSpellCheckingAllowed):
     25        (WebKit::TextChecker::isContinuousSpellCheckingEnabled):
     26        (WebKit::TextChecker::setContinuousSpellCheckingEnabled):
     27        (WebKit::TextChecker::isGrammarCheckingEnabled):
     28        (WebKit::TextChecker::setGrammarCheckingEnabled):
     29        * UIProcess/win/TextCheckerWin.cpp: Added.
     30        (WebKit::TextChecker::isContinuousSpellCheckingAllowed):
     31        (WebKit::TextChecker::isContinuousSpellCheckingEnabled):
     32        (WebKit::TextChecker::setContinuousSpellCheckingEnabled):
     33        (WebKit::TextChecker::isGrammarCheckingEnabled):
     34        (WebKit::TextChecker::setGrammarCheckingEnabled):
     35        * WebKit2.pro:
     36        * WebKit2.xcodeproj/project.pbxproj:
     37        * WebProcess/WebPage/WebPage.cpp:
     38        (WebKit::WebPage::unmarkAllMisspellings):
     39        (WebKit::WebPage::unmarkAllBadGrammar):
     40        * WebProcess/WebPage/WebPage.h:
     41        * WebProcess/WebPage/WebPage.messages.in:
     42        * win/WebKit2.vcproj:
     43
    1442010-12-20  Anders Carlsson  <andersca@apple.com>
    245
  • trunk/WebKit2/UIProcess/API/mac/WKView.mm

    r74330 r74376  
    3939#import "PageClientImpl.h"
    4040#import "RunLoop.h"
     41#import "TextChecker.h"
    4142#import "WKTextInputWindowController.h"
    4243#import "WebContext.h"
     
    312313- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
    313314{
    314     String commandName = commandNameForSelector([item action]);
    315315    NSMenuItem *menuItem = (NSMenuItem *)item;
    316316    if (![menuItem isKindOfClass:[NSMenuItem class]])
    317317        return NO; // FIXME: We need to be able to handle other user interface elements.
    318    
     318
     319    SEL action = [item action];
     320
     321    if (action == @selector(toggleContinuousSpellChecking:)) {
     322        bool checkMark = false;
     323        bool returnValue = false;
     324        if (TextChecker::isContinuousSpellCheckingAllowed())
     325            checkMark = TextChecker::isContinuousSpellCheckingEnabled();
     326        returnValue = true;
     327
     328        [menuItem setState:checkMark ? NSOnState : NSOffState];
     329        return returnValue;
     330    }
     331
     332    if (action == @selector(toggleGrammarChecking:)) {
     333        bool checkMark = TextChecker::isGrammarCheckingEnabled();
     334        [menuItem setState:checkMark ? NSOnState : NSOffState];
     335        return YES;
     336    }
     337   
     338    String commandName = commandNameForSelector([item action]);
     339
    319340    if (_data->_menuItemsMap.find(commandName) == _data->_menuItemsMap.end()) {
    320341        _data->_menuItemsMap.add(commandName, menuItem);
     
    323344
    324345    return YES;
     346}
     347
     348- (IBAction)toggleContinuousSpellChecking:(id)sender
     349{
     350    bool spellCheckingEnabled = !TextChecker::isContinuousSpellCheckingEnabled();
     351    TextChecker::setContinuousSpellCheckingEnabled(spellCheckingEnabled);
     352
     353    if (!spellCheckingEnabled)
     354        _data->_page->unmarkAllMisspellings();
     355}
     356
     357- (void)toggleGrammarChecking:(id)sender
     358{
     359    bool grammarCheckingEnabled = !TextChecker::isGrammarCheckingEnabled();
     360    TextChecker::setGrammarCheckingEnabled(grammarCheckingEnabled);
     361
     362    if (!grammarCheckingEnabled)
     363        _data->_page->unmarkAllBadGrammar();
    325364}
    326365
  • trunk/WebKit2/UIProcess/WebPageProxy.cpp

    r74296 r74376  
    15441544}
    15451545
     1546void WebPageProxy::unmarkAllMisspellings()
     1547{
     1548    process()->send(Messages::WebPage::UnmarkAllMisspellings(), m_pageID);
     1549}
     1550
     1551void WebPageProxy::unmarkAllBadGrammar()
     1552{
     1553    process()->send(Messages::WebPage::UnmarkAllBadGrammar(), m_pageID);
     1554}
     1555
    15461556void WebPageProxy::registerEditCommand(PassRefPtr<WebEditCommandProxy> commandProxy, UndoOrRedo undoOrRedo)
    15471557{
  • trunk/WebKit2/UIProcess/WebPageProxy.h

    r74296 r74376  
    295295#endif
    296296
     297    void unmarkAllMisspellings();
     298    void unmarkAllBadGrammar();
     299
    297300private:
    298301    WebPageProxy(WebContext*, WebPageGroup*, uint64_t pageID);
  • trunk/WebKit2/WebKit2.pro

    r74139 r74376  
    329329    UIProcess/ProcessModel.h \
    330330    UIProcess/ResponsivenessTimer.h \
     331    UIProcess/TextChecker.h \
    331332    UIProcess/TiledDrawingAreaProxy.h \
    332333    UIProcess/VisitedLinkProvider.h \
     
    556557    UIProcess/qt/TiledDrawingAreaProxyQt.cpp \
    557558    UIProcess/qt/TiledDrawingAreaTileQt.cpp \
     559    UIProcess/qt/TextCheckerQt.cpp \
    558560    UIProcess/qt/WebContextMenuProxyQt.cpp \
    559561    UIProcess/qt/WebContextQt.cpp \
  • trunk/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r74139 r74376  
    156156                1AA1CC5D100FA1A10078DEBC /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1CC5C100FA1A10078DEBC /* QuartzCore.framework */; };
    157157                1AA1CD07100FA1BA0078DEBC /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1CD06100FA1BA0078DEBC /* Carbon.framework */; };
     158                1AA417CB12C00CCA002BE67B /* TextChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA417C912C00CCA002BE67B /* TextChecker.h */; };
     159                1AA417EF12C00D87002BE67B /* TextCheckerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AA417ED12C00D87002BE67B /* TextCheckerMac.mm */; };
    158160                1AA4792312A59FD9008236C3 /* PluginProcessMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AA4792212A59FD9008236C3 /* PluginProcessMac.mm */; };
    159161                1AA479B012A5A436008236C3 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1CD06100FA1BA0078DEBC /* Carbon.framework */; };
     
    808810                1AA1CC5C100FA1A10078DEBC /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = /System/Library/Frameworks/QuartzCore.framework; sourceTree = "<absolute>"; };
    809811                1AA1CD06100FA1BA0078DEBC /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
     812                1AA417C912C00CCA002BE67B /* TextChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextChecker.h; sourceTree = "<group>"; };
     813                1AA417ED12C00D87002BE67B /* TextCheckerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TextCheckerMac.mm; sourceTree = "<group>"; };
    810814                1AA4792212A59FD9008236C3 /* PluginProcessMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PluginProcessMac.mm; sourceTree = "<group>"; };
    811815                1AA56F2811E92BC80061B882 /* PluginController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginController.h; sourceTree = "<group>"; };
     
    18981902                                BC111B08112F5E3C00337BAB /* ResponsivenessTimer.cpp */,
    18991903                                1A30066C1110F4F70031937C /* ResponsivenessTimer.h */,
     1904                                1AA417C912C00CCA002BE67B /* TextChecker.h */,
    19001905                                1A0F29E1120B44420053D1B9 /* VisitedLinkProvider.cpp */,
    19011906                                1A0F29E2120B44420053D1B9 /* VisitedLinkProvider.h */,
     
    23062311                                BC2651F511825EF800243E12 /* ChunkedUpdateDrawingAreaProxyMac.mm */,
    23072312                                0F5265BB11DD37860006D33C /* LayerBackedDrawingAreaProxyMac.mm */,
     2313                                1AA417ED12C00D87002BE67B /* TextCheckerMac.mm */,
    23082314                                1A1C648611F415B700553C19 /* WebContextMac.mm */,
    23092315                                51ACBB9E127A8F2C00D203B9 /* WebContextMenuProxyMac.h */,
     
    27572763                                1A4A9C5612B816CF008FE984 /* NetscapePluginModule.h in Headers */,
    27582764                                1A4A9F3312B844E2008FE984 /* PluginQuirks.h in Headers */,
     2765                                1AA417CB12C00CCA002BE67B /* TextChecker.h in Headers */,
    27592766                        );
    27602767                        runOnlyForDeploymentPostprocessing = 0;
     
    31793186                                1A4A9C5512B816CF008FE984 /* NetscapePluginModule.cpp in Sources */,
    31803187                                1A4A9C9A12B821CD008FE984 /* NetscapePluginModuleMac.mm in Sources */,
     3188                                1AA417EF12C00D87002BE67B /* TextCheckerMac.mm in Sources */,
    31813189                        );
    31823190                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebKit2/WebProcess/WebPage/WebPage.cpp

    r74296 r74376  
    11271127}
    11281128
     1129void WebPage::unmarkAllMisspellings()
     1130{
     1131    for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
     1132        if (Document* document = frame->document())
     1133            document->markers()->removeMarkers(DocumentMarker::Spelling);
     1134    }
     1135}
     1136
     1137void WebPage::unmarkAllBadGrammar()
     1138{
     1139    for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
     1140        if (Document* document = frame->document())
     1141            document->markers()->removeMarkers(DocumentMarker::Grammar);
     1142    }
     1143}
     1144
    11291145void WebPage::setTextForActivePopupMenu(int32_t index)
    11301146{
  • trunk/WebKit2/WebProcess/WebPage/WebPage.h

    r74296 r74376  
    344344    void didCancelForOpenPanel();
    345345
     346    void unmarkAllMisspellings();
     347    void unmarkAllBadGrammar();
     348
    346349#if ENABLE(CONTEXT_MENUS)
    347350    void didSelectItemFromActiveContextMenu(const WebContextMenuItemData&);
  • trunk/WebKit2/WebProcess/WebPage/WebPage.messages.in

    r74296 r74376  
    9898    DidCancelForOpenPanel()
    9999
     100    # Speling and grammer.
     101    UnmarkAllMisspellings()
     102    UnmarkAllBadGrammar()
     103
    100104    SetWindowResizerSize(WebCore::IntSize intersectsView)
    101105
  • trunk/WebKit2/win/WebKit2.vcproj

    r74141 r74376  
    19161916                        </File>
    19171917                        <File
     1918                                RelativePath="..\UIProcess\TextChecker.h"
     1919                                >
     1920                        </File>
     1921                        <File
    19181922                                RelativePath="..\UIProcess\VisitedLinkProvider.cpp"
    19191923                                >
     
    25062510                                        >
    25072511                                </File>
     2512                        <File
     2513                                RelativePath="..\UIProcess\win\TextCheckerWin.cpp"
     2514                                >
     2515                        </File>
    25082516                                <File
    25092517                                        RelativePath="..\UIProcess\win\WebContextMenuProxyWin.cpp"
Note: See TracChangeset for help on using the changeset viewer.