Reviewed by Darin
authorsullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Oct 2006 19:14:30 +0000 (19:14 +0000)
committersullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Oct 2006 19:14:30 +0000 (19:14 +0000)
        Initial plumbing for grammar checking. No actual grammar are checked at this time.

        * English.lproj/WebViewEditingContextMenu.nib/classes.nib:
        * English.lproj/WebViewEditingContextMenu.nib/info.nib:
        * English.lproj/WebViewEditingContextMenu.nib/objects.nib:
        Added grammar-checking item, reworded to match changes in framework. This will be used
        post-Tiger.

        * English.lproj/WebViewEditingContextMenuOld.nib/classes.nib: Added.
        * English.lproj/WebViewEditingContextMenuOld.nib/info.nib: Added.
        * English.lproj/WebViewEditingContextMenuOld.nib/objects.nib: Added.
        Copy of WebViewEditingContextMenu.nib, unchanged. This will be used on Tiger.

        * DefaultDelegates/WebDefaultContextMenuDelegate.m:
        (-[WebDefaultUIDelegate editingContextMenuItemsForElement:defaultMenuItems:]):
        Choose the right context menu based on BUILDING_ON_TIGER.

        * WebView/WebPreferenceKeysPrivate.h:
        declare grammar-related NSUserDefault value

        * WebView/WebViewPrivate.h:
        declare grammar-related methods

        * WebView/WebView.mm:
        declare static BOOL grammarCheckingEnabled
        (-[WebViewPrivate init]):
        initialize grammarCheckingEnabled to NSUserDefaults value
        (-[WebView validateUserInterfaceItem:]):
        validate toggleGrammarChecking: menu item
        (-[WebView isGrammarCheckingEnabled]):
        return value of grammarCheckingEnabled
        (-[WebView setGrammarCheckingEnabled:]):
        set value of grammarCheckingEnabled, call frame to remove existing bad grammar markers
        (-[WebView toggleGrammarChecking:]):
        flip the value

        * WebView/WebFrameInternal.h:
        * WebView/WebFrame.mm:
        (-[WebFrame _unmarkAllBadGrammar]):
        new placeholder method, does nothing yet

        * WebView/WebHTMLViewInternal.h:
        declare grammar-related methods

        * WebView/WebHTMLView.m:
        (-[NSArray validateUserInterfaceItem:]):
        validate toggleGrammarChecking: menu item
        (-[WebHTMLView isGrammarCheckingEnabled]):
        new method, calls through to WebView
        (-[WebHTMLView setGrammarCheckingEnabled:]):
        ditto
        (-[WebHTMLView toggleGrammarChecking:]):
        ditto

        * English.lproj/StringsNotToBeLocalized.txt:
        Updated for these changes

        * WebKit.xcodeproj/project.pbxproj:
        updated for new files

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17255 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
WebKit/ChangeLog
WebKit/DefaultDelegates/WebDefaultContextMenuDelegate.m
WebKit/English.lproj/StringsNotToBeLocalized.txt
WebKit/English.lproj/WebViewEditingContextMenu.nib/classes.nib
WebKit/English.lproj/WebViewEditingContextMenu.nib/info.nib
WebKit/English.lproj/WebViewEditingContextMenu.nib/objects.nib
WebKit/English.lproj/WebViewEditingContextMenuOld.nib/classes.nib [new file with mode: 0644]
WebKit/English.lproj/WebViewEditingContextMenuOld.nib/info.nib [new file with mode: 0644]
WebKit/English.lproj/WebViewEditingContextMenuOld.nib/objects.nib [new file with mode: 0644]
WebKit/WebKit.xcodeproj/project.pbxproj
WebKit/WebView/WebFrame.mm
WebKit/WebView/WebFrameInternal.h
WebKit/WebView/WebHTMLView.m
WebKit/WebView/WebHTMLViewInternal.h
WebKit/WebView/WebPreferenceKeysPrivate.h
WebKit/WebView/WebView.mm
WebKit/WebView/WebViewPrivate.h

index 098ce2d29b71f5e07df0f2edafd699c9d5df775f..fb31de7758fc7d1f104e6b3607c73a2c99bc4237 100644 (file)
@@ -1,3 +1,67 @@
+2006-10-24  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Darin
+        
+        Initial plumbing for grammar checking. No actual grammar are checked at this time.
+
+        * English.lproj/WebViewEditingContextMenu.nib/classes.nib:
+        * English.lproj/WebViewEditingContextMenu.nib/info.nib:
+        * English.lproj/WebViewEditingContextMenu.nib/objects.nib:
+        Added grammar-checking item, reworded to match changes in framework. This will be used
+        post-Tiger.
+
+        * English.lproj/WebViewEditingContextMenuOld.nib/classes.nib: Added.
+        * English.lproj/WebViewEditingContextMenuOld.nib/info.nib: Added.
+        * English.lproj/WebViewEditingContextMenuOld.nib/objects.nib: Added.
+        Copy of WebViewEditingContextMenu.nib, unchanged. This will be used on Tiger.
+
+        * DefaultDelegates/WebDefaultContextMenuDelegate.m:
+        (-[WebDefaultUIDelegate editingContextMenuItemsForElement:defaultMenuItems:]):
+        Choose the right context menu based on BUILDING_ON_TIGER.
+        
+        * WebView/WebPreferenceKeysPrivate.h:
+        declare grammar-related NSUserDefault value
+
+        * WebView/WebViewPrivate.h:
+        declare grammar-related methods
+
+        * WebView/WebView.mm:
+        declare static BOOL grammarCheckingEnabled
+        (-[WebViewPrivate init]):
+        initialize grammarCheckingEnabled to NSUserDefaults value
+        (-[WebView validateUserInterfaceItem:]):
+        validate toggleGrammarChecking: menu item
+        (-[WebView isGrammarCheckingEnabled]):
+        return value of grammarCheckingEnabled
+        (-[WebView setGrammarCheckingEnabled:]):
+        set value of grammarCheckingEnabled, call frame to remove existing bad grammar markers
+        (-[WebView toggleGrammarChecking:]):
+        flip the value
+        
+        * WebView/WebFrameInternal.h:
+        * WebView/WebFrame.mm:
+        (-[WebFrame _unmarkAllBadGrammar]):
+        new placeholder method, does nothing yet
+        
+        * WebView/WebHTMLViewInternal.h:
+        declare grammar-related methods
+
+        * WebView/WebHTMLView.m:
+        (-[NSArray validateUserInterfaceItem:]):
+        validate toggleGrammarChecking: menu item
+        (-[WebHTMLView isGrammarCheckingEnabled]):
+        new method, calls through to WebView
+        (-[WebHTMLView setGrammarCheckingEnabled:]):
+        ditto
+        (-[WebHTMLView toggleGrammarChecking:]):
+        ditto
+                
+        * English.lproj/StringsNotToBeLocalized.txt:
+        Updated for these changes
+        
+        * WebKit.xcodeproj/project.pbxproj:
+        updated for new files        
+
 2006-10-23  Darin Adler  <darin@apple.com>
 
         Reviewed by Geoff.
index 954b2933c513fb8b9d2ee830bca0c96ff63f29ee..eb9e3d78d9e041077467a0f5b4cc2cd05ec30568 100644 (file)
@@ -309,14 +309,20 @@ static NSString *localizedMenuTitleFromAppKit(NSString *key, NSString *comment)
     // Load our NSTextView-like context menu nib.
     if (defaultMenu == nil) {
         static NSNib *textViewMenuNib = nil;
-        if (textViewMenuNib == nil) {
-            textViewMenuNib = [[NSNib alloc] initWithNibNamed:@"WebViewEditingContextMenu" bundle:[NSBundle bundleForClass:[self class]]];
+        if (!textViewMenuNib) {
+#if BUILDING_ON_TIGER
+            NSString *contextMenuNibName = @"WebViewEditingContextMenuOld";
+#else
+            NSString *contextMenuNibName = @"WebViewEditingContextMenu";
+#endif
+            textViewMenuNib = [[NSNib alloc] initWithNibNamed:contextMenuNibName bundle:[NSBundle bundleForClass:[self class]]];
         }
         [textViewMenuNib instantiateNibWithOwner:self topLevelObjects:nil];
         ASSERT(defaultMenu != nil);
     }
     
     // Add tags to the menu items because this is what the WebUIDelegate expects.
+    // Also remove any future-looking items if appropriate.
     NSEnumerator *enumerator = [[defaultMenu itemArray] objectEnumerator];
     while ((item = [enumerator nextObject]) != nil) {
         item = [item copy];
@@ -331,12 +337,14 @@ static NSString *localizedMenuTitleFromAppKit(NSString *key, NSString *comment)
             tag = WebMenuItemTagPaste;
         } else {
             // FIXME 4158153: we should supply tags for each known item so clients can make
-            // sensible decisions, like we do with PDF context menu items (see WebPDFView.mm)
+            // sensible decisions, like we do with PDF context menu items (see WebPDFView.mm).
+            // FIXME: This ignores the contents of submenus entirely.
 
             // Once we have other tag names, we should reconsider if any of them are valid for password fields.
             tag = WebMenuItemTagOther;
             validForPassword = false;
         }
+        
         if (!inPasswordField || validForPassword) {
             [item setTag:tag];
             [menuItems addObject:item];
index 5ebdfcb8c00cc0cb307d89d360cf9f47278297a6..07893298f822ff753d5e61f0820699815f4afe39 100644 (file)
 "12px"
 "13"
 "16"
-"33554432"
 "1800"
 "1px"
 "3"
+"33554432"
 "420+"
 "7"
 "9"
 "WebViewDidChangeTypingStyleNotification"
 "WebViewDidEndEditingNotification"
 "WebViewEditingContextMenu"
+"WebViewEditingContextMenuOld"
 "\"@?"
 "\"\\"
 "\0"
index 9122007b57e3d0ee2f31581b489477e8cb17ae9d..0cdded5be4689573e76cf69f37277a2497f8de69 100644 (file)
@@ -8,6 +8,7 @@
                 startSpeaking = id; 
                 stopSpeaking = id; 
                 toggleBaseWritingDirection = id; 
+                toggleGrammarChecking = id; 
             }; 
             CLASS = FirstResponder; 
             LANGUAGE = ObjC; 
index 0e00bb4eb25c14eff02e3dbf8f1a5ebf3ba1121b..70fed511f591a79ad930c409258faef5b81feb19 100644 (file)
@@ -3,19 +3,19 @@
 <plist version="1.0">
 <dict>
        <key>IBDocumentLocation</key>
-       <string>462 52 356 240 0 0 1600 1178 </string>
+       <string>403 85 356 240 0 0 1440 878 </string>
        <key>IBEditorPositions</key>
        <dict>
                <key>5</key>
-               <string>81 355 170 175 0 0 1600 1178 </string>
+               <string>72 246 179 203 0 0 1440 878 </string>
        </dict>
        <key>IBFramework Version</key>
-       <string>375.0</string>
+       <string>453.0</string>
        <key>IBOpenObjects</key>
        <array>
                <integer>5</integer>
        </array>
        <key>IBSystem Version</key>
-       <string>8A96</string>
+       <string>9A288</string>
 </dict>
 </plist>
index 8d7b328a4a8db83798bd0c2aff4df217e4b125c4..a7815b79f431c39cf77378f47e87bbea4d25e726 100644 (file)
Binary files a/WebKit/English.lproj/WebViewEditingContextMenu.nib/objects.nib and b/WebKit/English.lproj/WebViewEditingContextMenu.nib/objects.nib differ
diff --git a/WebKit/English.lproj/WebViewEditingContextMenuOld.nib/classes.nib b/WebKit/English.lproj/WebViewEditingContextMenuOld.nib/classes.nib
new file mode 100644 (file)
index 0000000..0cdded5
--- /dev/null
@@ -0,0 +1,31 @@
+{
+    IBClasses = (
+        {
+            ACTIONS = {
+                changeBaseWritingDirection = id; 
+                myAction = id; 
+                outline = id; 
+                startSpeaking = id; 
+                stopSpeaking = id; 
+                toggleBaseWritingDirection = id; 
+                toggleGrammarChecking = id; 
+            }; 
+            CLASS = FirstResponder; 
+            LANGUAGE = ObjC; 
+            SUPERCLASS = NSObject; 
+        }, 
+        {
+            CLASS = MyObject; 
+            LANGUAGE = ObjC; 
+            OUTLETS = {defaultMenu = id; }; 
+            SUPERCLASS = NSObject; 
+        }, 
+        {
+            ACTIONS = {orderFrontFontOptionsPanel = id; orderFrontStylesPanel = id; }; 
+            CLASS = NSFontManager; 
+            LANGUAGE = ObjC; 
+            SUPERCLASS = NSObject; 
+        }
+    ); 
+    IBVersion = 1; 
+}
\ No newline at end of file
diff --git a/WebKit/English.lproj/WebViewEditingContextMenuOld.nib/info.nib b/WebKit/English.lproj/WebViewEditingContextMenuOld.nib/info.nib
new file mode 100644 (file)
index 0000000..70fed51
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>IBDocumentLocation</key>
+       <string>403 85 356 240 0 0 1440 878 </string>
+       <key>IBEditorPositions</key>
+       <dict>
+               <key>5</key>
+               <string>72 246 179 203 0 0 1440 878 </string>
+       </dict>
+       <key>IBFramework Version</key>
+       <string>453.0</string>
+       <key>IBOpenObjects</key>
+       <array>
+               <integer>5</integer>
+       </array>
+       <key>IBSystem Version</key>
+       <string>9A288</string>
+</dict>
+</plist>
diff --git a/WebKit/English.lproj/WebViewEditingContextMenuOld.nib/objects.nib b/WebKit/English.lproj/WebViewEditingContextMenuOld.nib/objects.nib
new file mode 100644 (file)
index 0000000..dc68b9b
Binary files /dev/null and b/WebKit/English.lproj/WebViewEditingContextMenuOld.nib/objects.nib differ
index f2fb13cb3f73c0c1d119b41b8bd3c4665f6ca199..a2cf4bd170e56592b5337a1d8450c072848a6405 100644 (file)
                ED6BE2E7088C32B50044DEDC /* WebNSAttributedStringExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = ED6BE2E5088C32B50044DEDC /* WebNSAttributedStringExtras.h */; };
                ED6BE2E8088C32B50044DEDC /* WebNSAttributedStringExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = ED6BE2E6088C32B50044DEDC /* WebNSAttributedStringExtras.m */; };
                ED7F6D8B0980683500C235ED /* WebNSDataExtrasPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = ED7F6D8A0980683500C235ED /* WebNSDataExtrasPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               EDD6132C0AED9990000B75CA /* WebViewEditingContextMenuOld.nib in Resources */ = {isa = PBXBuildFile; fileRef = EDD6132A0AED9990000B75CA /* WebViewEditingContextMenuOld.nib */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
                ED7F6D8A0980683500C235ED /* WebNSDataExtrasPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNSDataExtrasPrivate.h; sourceTree = "<group>"; };
                EDD1A5C605C83987008E3150 /* WebNSPrintOperationExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebNSPrintOperationExtras.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                EDD1A5C705C83987008E3150 /* WebNSPrintOperationExtras.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebNSPrintOperationExtras.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+               EDD6132B0AED9990000B75CA /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/WebViewEditingContextMenuOld.nib; sourceTree = "<group>"; };
                EDE850CD06ECC79E005FAB05 /* WebPreferenceKeysPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebPreferenceKeysPrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                F508946902B71D59018A9CD4 /* WebNSViewExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebNSViewExtras.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                F508946A02B71D59018A9CD4 /* WebNSViewExtras.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebNSViewExtras.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                                F5F732D202FF4D4F01A80180 /* WebKit.exp */,
                                9345D4E70365C58D008635CE /* WebJavaScriptTextInputPanel.nib */,
                                8476113206EF82DB00AB2914 /* WebViewEditingContextMenu.nib */,
+                               EDD6132A0AED9990000B75CA /* WebViewEditingContextMenuOld.nib */,
                                9325FBDC07D829AE00159862 /* IDNScriptWhiteList.txt */,
                        );
                        name = Resources;
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */;
+                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
                        productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
                        projectDirPath = "";
                        projectRoot = "";
+                       shouldCheckCompatibility = 1;
                        targets = (
                                9398100A0824BF01008DF038 /* WebKit */,
                        );
                                939810B90824BF01008DF038 /* WebViewEditingContextMenu.nib in Resources */,
                                939810BA0824BF01008DF038 /* IDNScriptWhiteList.txt in Resources */,
                                1C68F667095B5FC100C2984E /* webInspector in Resources */,
+                               EDD6132C0AED9990000B75CA /* WebViewEditingContextMenuOld.nib in Resources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        name = WebJavaScriptTextInputPanel.nib;
                        sourceTree = "<group>";
                };
+               EDD6132A0AED9990000B75CA /* WebViewEditingContextMenuOld.nib */ = {
+                       isa = PBXVariantGroup;
+                       children = (
+                               EDD6132B0AED9990000B75CA /* English */,
+                       );
+                       name = WebViewEditingContextMenuOld.nib;
+                       sourceTree = "<group>";
+               };
 /* End PBXVariantGroup section */
 
 /* Begin XCBuildConfiguration section */
index 62f4d913d3b0f43789029fc4e3eaca6908ac809b..8ca421f7cad7f515975ada37550b61f1bf7333cd 100644 (file)
@@ -932,6 +932,13 @@ static inline WebFrame *frame(WebCoreFrameBridge *bridge)
     return _private->internalLoadDelegate;
 }
 
+#if !BUILDING_ON_TIGER
+- (void)_unmarkAllBadGrammar
+{
+    // FIXME: Implement this across the bridge a la _unmarkAllMisspellings
+}
+#endif
+
 - (void)_unmarkAllMisspellings
 {
     for (WebFrame *frame = self; frame; frame = [frame _traverseNextFrameStayWithin:self])
index 249bf9e45a5908b72ad2ad69b9fec176ca9fe2d7..7d1e496c4c8e7e8cda3eb8cd365469d2ccb953a6 100644 (file)
@@ -54,6 +54,9 @@ typedef WebCore::FrameLoader WebCoreFrameLoader;
 - (void)_updateBackground;
 - (void)_setInternalLoadDelegate:(id)internalLoadDelegate;
 - (id)_internalLoadDelegate;
+#if !BUILDING_ON_TIGER
+- (void)_unmarkAllBadGrammar;
+#endif
 - (void)_unmarkAllMisspellings;
 // Note that callers should not perform any ops on these views that could change the set of frames
 - (NSArray *)_documentViews;
index 223f09e1583b5082a5b7b9646168e259bbfa2f9d..a24e830557e2c97fb5f4990d2a003515b5952deb 100644 (file)
@@ -2250,6 +2250,18 @@ static WebHTMLView *lastHitView = nil;
         return [self _canEditRichly];
     } else if (action == @selector(_lookUpInDictionaryFromMenu:)) {
         return [self _hasSelection];
+#if !BUILDING_ON_TIGER
+    } else if (action == @selector(toggleGrammarChecking:)) {
+        // FIXME 4799134: WebView is the bottleneck for this grammar-checking logic, but we must validate 
+        // the selector here because we implement it here, and we must implement it here because the AppKit 
+        // code checks the first responder.
+        BOOL checkMark = [self isGrammarCheckingEnabled];
+        if ([(NSObject *)item isKindOfClass:[NSMenuItem class]]) {
+            NSMenuItem *menuItem = (NSMenuItem *)item;
+            [menuItem setState:checkMark ? NSOnState : NSOffState];
+        }
+        return YES;
+#endif
     }
     
     return YES;
@@ -5075,6 +5087,31 @@ static DOMRange *unionDOMRanges(DOMRange *a, DOMRange *b)
     [self _pasteAsPlainTextWithPasteboard:[NSPasteboard generalPasteboard]];
 }
 
+#if !BUILDING_ON_TIGER
+
+- (BOOL)isGrammarCheckingEnabled
+{
+    // FIXME 4799134: WebView is the bottleneck for this grammar-checking logic, but we must implement the method here because
+    // the AppKit code checks the first responder.
+    return [[self _webView] isGrammarCheckingEnabled];
+}
+
+- (void)setGrammarCheckingEnabled:(BOOL)flag
+{
+    // FIXME 4799134: WebView is the bottleneck for this grammar-checking logic, but we must implement the method here because
+    // the AppKit code checks the first responder.
+    [[self _webView] setGrammarCheckingEnabled:flag];
+}
+
+- (void)toggleGrammarChecking:(id)sender
+{
+    // FIXME 4799134: WebView is the bottleneck for this grammar-checking logic, but we must implement the method here because
+    // the AppKit code checks the first responder.
+    [[self _webView] toggleGrammarChecking:sender];
+}
+
+#endif /* !BUILDING_ON_TIGER */
+
 @end
 
 @implementation WebHTMLView (WebNSTextInputSupport)
index ef659f84d5b497491d42815a070362e4962a583b..3faf57ed5827bf10193cae688140b04b96d77adc 100644 (file)
 - (void)cut:(id)sender;
 - (void)paste:(id)sender;
 - (void)pasteAsPlainText:(id)sender;
+#if !BUILDING_ON_TIGER
+- (BOOL)isGrammarCheckingEnabled;
+- (void)setGrammarCheckingEnabled:(BOOL)flag;
+- (void)toggleGrammarChecking:(id)sender;
+#endif
 @end
 
index 9f85ae0ce9cbabc8e9fa874254f2d7b190950c06..dc4d04fbf25080d485780a849eae8f5245b6b2d3 100644 (file)
@@ -58,6 +58,7 @@
 #define WebKitTabToLinksPreferenceKey @"WebKitTabToLinksPreferenceKey"
 #define WebKitPrivateBrowsingEnabledPreferenceKey @"WebKitPrivateBrowsingEnabled"
 #define WebContinuousSpellCheckingEnabled @"WebContinuousSpellCheckingEnabled"
+#define WebGrammarCheckingEnabled @"WebGrammarCheckingEnabled"
 
 // These are private both because callers should be using the cover methods and because the
 // cover methods themselves are private.
index 389aaa5b3f970276e41335620d292eadcf742bb2..bf94fd82eb5cc41b37463aa0d6eb6095097e6039 100644 (file)
@@ -373,6 +373,9 @@ NSString *_WebMainFrameDocumentKey =    @"mainFrameDocument";
 
 
 static BOOL continuousSpellCheckingEnabled;
+#if !BUILDING_ON_TIGER
+static BOOL grammarCheckingEnabled;
+#endif
 
 @implementation WebViewPrivate
 
@@ -391,7 +394,10 @@ static BOOL continuousSpellCheckingEnabled;
     tabKeyCyclesThroughElements = YES;
     shouldCloseWithWindow = objc_collecting_enabled();
     continuousSpellCheckingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebContinuousSpellCheckingEnabled];
-
+#if !BUILDING_ON_TIGER
+    grammarCheckingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebGrammarCheckingEnabled];
+#endif
+    
     return self;
 }
 
@@ -2809,6 +2815,15 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
             [menuItem setState:checkMark ? NSOnState : NSOffState];
         }
         return retVal;
+#if !BUILDING_ON_TIGER
+    } else if (action == @selector(toggleGrammarChecking:)) {
+        BOOL checkMark = [self isGrammarCheckingEnabled];
+        if ([(NSObject *)item isKindOfClass:[NSMenuItem class]]) {
+            NSMenuItem *menuItem = (NSMenuItem *)item;
+            [menuItem setState:checkMark ? NSOnState : NSOffState];
+        }
+        return YES;
+#endif
     }
     FOR_EACH_RESPONDER_SELECTOR(VALIDATE)
 
@@ -3261,6 +3276,39 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
 
 @end
 
+#if !BUILDING_ON_TIGER
+@implementation WebView (WebViewGrammarChecking)
+
+// FIXME: This method should be merged into WebViewEditing when we're not in API freeze
+- (BOOL)isGrammarCheckingEnabled
+{
+    return grammarCheckingEnabled;
+}
+
+// FIXME: This method should be merged into WebViewEditing when we're not in API freeze
+- (void)setGrammarCheckingEnabled:(BOOL)flag
+{
+    if (grammarCheckingEnabled != flag) {
+        grammarCheckingEnabled = flag;
+        [[NSUserDefaults standardUserDefaults] setBool:grammarCheckingEnabled forKey:WebGrammarCheckingEnabled];
+    }
+    
+    // We call _preflightSpellChecker when turning continuous spell checking on, but we don't need to do that here
+    // because grammar checking only occurs on code paths that already preflight spell checking appropriately.
+    
+    if (![self isGrammarCheckingEnabled])
+        [[self mainFrame] _unmarkAllBadGrammar];
+}
+
+// FIXME: This method should be merged into WebIBActions when we're not in API freeze
+- (void)toggleGrammarChecking:(id)sender
+{
+    [self setGrammarCheckingEnabled:![self isGrammarCheckingEnabled]];
+}
+
+@end
+#endif
+
 @implementation WebView (WebViewUndoableEditing)
 
 - (void)replaceSelectionWithNode:(DOMNode *)node
index b99eba5a309f236f55a9edc51b9bb6f968e3c215..9796f25cfe30d2526219a1aac8acf12e8256b969 100644 (file)
@@ -299,6 +299,18 @@ Could be worth adding to the API.
 - (void)_drawHeaderAndFooter;
 @end
 
+#if !BUILDING_ON_TIGER
+@interface WebView (WebViewGrammarChecking)
+
+// FIXME: These two methods should be merged into WebViewEditing when we're not in API freeze
+- (BOOL)isGrammarCheckingEnabled;
+- (void)setGrammarCheckingEnabled:(BOOL)flag;
+
+// FIXME: This method should be merged into WebIBActions when we're not in API freeze
+- (void)toggleGrammarChecking:(id)sender;
+@end
+#endif
+
 @interface WebView (WebViewEditingInMail)
 - (void)_insertNewlineInQuotedContent;
 - (BOOL)_selectWordBeforeMenuEvent;