Reviewed by Kevin Decker
authorsullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Oct 2006 00:11:15 +0000 (00:11 +0000)
committersullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Oct 2006 00:11:15 +0000 (00:11 +0000)
        - fixed <rdar://problem/4801331> "Spelling..." menu item should be "Show/Hide Spelling" post-Tiger, to match AppKit

        * WebView/WebHTMLView.m:
        (-[NSArray validateUserInterfaceItem:]):
        post-Tiger, update the menu item text to "Show Spelling"/"Hide Spelling" based on whether
        the spelling panel is already showing. Also, removed else's after returns, and removed
        braces around one-line if clauses.
        (-[NSArray showGuessPanel:]):
        post-Tiger, make this item hide the spelling panel if it's already showing

        * English.lproj/Localizable.strings:
        updated for this change

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

WebKit/ChangeLog
WebKit/English.lproj/Localizable.strings
WebKit/English.lproj/StringsNotToBeLocalized.txt
WebKit/WebView/WebHTMLView.m

index 60330ccd696739d0489ad7a9854e2ab7aff1e6f8..124f22d5aeebb7dff805d42a6ef544ff44593fcd 100644 (file)
@@ -1,3 +1,20 @@
+2006-10-24  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Kevin Decker
+        
+        - fixed <rdar://problem/4801331> "Spelling..." menu item should be "Show/Hide Spelling" post-Tiger, to match AppKit
+
+        * WebView/WebHTMLView.m:
+        (-[NSArray validateUserInterfaceItem:]):
+        post-Tiger, update the menu item text to "Show Spelling"/"Hide Spelling" based on whether
+        the spelling panel is already showing. Also, removed else's after returns, and removed
+        braces around one-line if clauses.
+        (-[NSArray showGuessPanel:]):
+        post-Tiger, make this item hide the spelling panel if it's already showing
+
+        * English.lproj/Localizable.strings:
+        updated for this change
+        
 2006-10-24  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by Anders.
index 9745a2a57b021fc1a0c593e983b42031422c96c8..791f3efe88149fb5da69d9a67aac5faf3b3eef18 100644 (file)
Binary files a/WebKit/English.lproj/Localizable.strings and b/WebKit/English.lproj/Localizable.strings differ
index 07893298f822ff753d5e61f0820699815f4afe39..c108d5ac5dc721189e5ea3aa41f39be761cede1c 100644 (file)
@@ -88,6 +88,7 @@
 "Cache-Control"
 "Content-Length"
 "Courier"
+"DELEGATE METHODS"
 "DOCBASE"
 "DYLD_FRAMEWORK_PATH"
 "FrameName"
index a24e830557e2c97fb5f4990d2a003515b5952deb..a41ab7fc2c8bfc3d8c81f2b7df013ee43bafa17c 100644 (file)
@@ -2147,12 +2147,24 @@ static WebHTMLView *lastHitView = nil;
             || action == @selector(pageUp:)
             || action == @selector(pageUpAndModifySelection:)
             || action == @selector(pasteFont:)
-            || action == @selector(showGuessPanel:)
             || action == @selector(transpose:)
             || action == @selector(yank:)
-            || action == @selector(yankAndSelect:)) {
+            || action == @selector(yankAndSelect:))
         return [self _canEdit];
-    } else if (action == @selector(changeBaseWritingDirection:)) {
+    
+    if (action == @selector(showGuessPanel:)) {
+#if !BUILDING_ON_TIGER
+        // Match OS X AppKit behavior for post-Tiger. Don't change Tiger behavior.
+        NSMenuItem *menuItem = (NSMenuItem *)item;
+        if ([menuItem isKindOfClass:[NSMenuItem class]]) {
+            BOOL panelShowing = [[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible];
+            [menuItem setTitle:panelShowing ? UI_STRING("Hide Spelling", "menu item title") : UI_STRING("Show Spelling", "menu item title")];
+        }
+#endif
+        return [self _canEdit];
+    }
+    
+    if (action == @selector(changeBaseWritingDirection:)) {
         NSMenuItem *menuItem = (NSMenuItem *)item;
         if ([menuItem isKindOfClass:[NSMenuItem class]]) {
             NSWritingDirection writingDirection = [item tag];
@@ -2165,7 +2177,9 @@ static WebHTMLView *lastHitView = nil;
             [menuItem setState:[[self _bridge] selectionHasStyle:style]];
         }
         return [self _canEdit];
-    } else if (action == @selector(toggleBaseWritingDirection:)) {
+    }
+    
+    if (action == @selector(toggleBaseWritingDirection:)) {
         NSMenuItem *menuItem = (NSMenuItem *)item;
         if ([menuItem isKindOfClass:[NSMenuItem class]]) {
             DOMCSSStyleDeclaration* rtl = [self _emptyStyle];
@@ -2175,7 +2189,9 @@ static WebHTMLView *lastHitView = nil;
             [menuItem setTitle:[[self _bridge] selectionHasStyle:rtl] ? UI_STRING("Left to Right", "Left to Right context menu item") : UI_STRING("Right to Left", "Right to Left context menu item")];
         }
         return [self _canEdit];
-    } else if (action == @selector(alignCenter:)
+    } 
+    
+    if (action == @selector(alignCenter:)
             || action == @selector(alignLeft:)
             || action == @selector(alignJustified:)
             || action == @selector(alignRight:)
@@ -2183,40 +2199,52 @@ static WebHTMLView *lastHitView = nil;
             || action == @selector(changeColor:)        
             || action == @selector(changeFont:)
             || action == @selector(indent:)
-            || action == @selector(outdent:)) {
+            || action == @selector(outdent:))
         return [self _canEditRichly];
-    } else if (action == @selector(capitalizeWord:)
+    
+    if (action == @selector(capitalizeWord:)
                || action == @selector(lowercaseWord:)
-               || action == @selector(uppercaseWord:)) {
+               || action == @selector(uppercaseWord:))
         return [self _hasSelection] && [self _isEditable];
-    } else if (action == @selector(centerSelectionInVisibleArea:)
+    
+    if (action == @selector(centerSelectionInVisibleArea:)
                || action == @selector(jumpToSelection:)
                || action == @selector(copyFont:)
-               || action == @selector(setMark:)) {
+               || action == @selector(setMark:))
         return [self _hasSelection] || ([self _isEditable] && [self _hasInsertionPoint]);
-    } else if (action == @selector(changeDocumentBackgroundColor:)) {
+    
+    if (action == @selector(changeDocumentBackgroundColor:))
         return [[self _webView] isEditable] && [self _canEditRichly];
-    } else if (action == @selector(copy:)) {
+    
+    if (action == @selector(copy:))
         return [bridge mayDHTMLCopy] || [self _canCopy];
-    } else if (action == @selector(cut:)) {
+    
+    if (action == @selector(cut:))
         return [bridge mayDHTMLCut] || [self _canCut];
-    } else if (action == @selector(delete:)) {
+    
+    if (action == @selector(delete:))
         return [self _canDelete];
-    } else if (action == @selector(_ignoreSpellingFromMenu:)
+    
+    if (action == @selector(_ignoreSpellingFromMenu:)
             || action == @selector(_learnSpellingFromMenu:)
-            || action == @selector(takeFindStringFromSelection:)) {
+            || action == @selector(takeFindStringFromSelection:))
         return [self _hasSelection];
-    } else if (action == @selector(paste:) || action == @selector(pasteAsPlainText:)) {
+    
+    if (action == @selector(paste:) || action == @selector(pasteAsPlainText:))
         return [bridge mayDHTMLPaste] || [self _canPaste];
-    } else if (action == @selector(pasteAsRichText:)) {
+    
+    if (action == @selector(pasteAsRichText:))
         return [bridge mayDHTMLPaste] || ([self _canPaste] && [[self _bridge] isSelectionRichlyEditable]);
-    } else if (action == @selector(performFindPanelAction:)) {
+    
+    if (action == @selector(performFindPanelAction:))
         // FIXME: Not yet implemented.
         return NO;
-    } else if (action == @selector(selectToMark:)
-            || action == @selector(swapWithMark:)) {
+    
+    if (action == @selector(selectToMark:)
+            || action == @selector(swapWithMark:))
         return [self _hasSelectionOrInsertionPoint] && [[self _bridge] markDOMRange] != nil;
-    } else if (action == @selector(subscript:)) {
+    
+    if (action == @selector(subscript:)) {
         NSMenuItem *menuItem = (NSMenuItem *)item;
         if ([menuItem isKindOfClass:[NSMenuItem class]]) {
             DOMCSSStyleDeclaration *style = [self _emptyStyle];
@@ -2224,7 +2252,9 @@ static WebHTMLView *lastHitView = nil;
             [menuItem setState:[[self _bridge] selectionHasStyle:style]];
         }
         return [self _canEditRichly];
-    } else if (action == @selector(superscript:)) {
+    } 
+    
+    if (action == @selector(superscript:)) {
         NSMenuItem *menuItem = (NSMenuItem *)item;
         if ([menuItem isKindOfClass:[NSMenuItem class]]) {
             DOMCSSStyleDeclaration *style = [self _emptyStyle];
@@ -2232,7 +2262,9 @@ static WebHTMLView *lastHitView = nil;
             [menuItem setState:[[self _bridge] selectionHasStyle:style]];
         }
         return [self _canEditRichly];
-    } else if (action == @selector(underline:)) {
+    } 
+    
+    if (action == @selector(underline:)) {
         NSMenuItem *menuItem = (NSMenuItem *)item;
         if ([menuItem isKindOfClass:[NSMenuItem class]]) {
             DOMCSSStyleDeclaration *style = [self _emptyStyle];
@@ -2240,7 +2272,9 @@ static WebHTMLView *lastHitView = nil;
             [menuItem setState:[[self _bridge] selectionHasStyle:style]];
         }
         return [self _canEditRichly];
-    } else if (action == @selector(unscript:)) {
+    } 
+    
+    if (action == @selector(unscript:)) {
         NSMenuItem *menuItem = (NSMenuItem *)item;
         if ([menuItem isKindOfClass:[NSMenuItem class]]) {
             DOMCSSStyleDeclaration *style = [self _emptyStyle];
@@ -2248,10 +2282,14 @@ static WebHTMLView *lastHitView = nil;
             [menuItem setState:[[self _bridge] selectionHasStyle:style]];
         }
         return [self _canEditRichly];
-    } else if (action == @selector(_lookUpInDictionaryFromMenu:)) {
+    } 
+    
+    if (action == @selector(_lookUpInDictionaryFromMenu:)) {
         return [self _hasSelection];
+    } 
+    
 #if !BUILDING_ON_TIGER
-    } else if (action == @selector(toggleGrammarChecking:)) {
+    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.
@@ -2261,8 +2299,8 @@ static WebHTMLView *lastHitView = nil;
             [menuItem setState:checkMark ? NSOnState : NSOffState];
         }
         return YES;
-#endif
     }
+#endif
     
     return YES;
 }
@@ -4446,10 +4484,21 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
         LOG_ERROR("No NSSpellChecker");
         return;
     }
+    
+    NSPanel *spellingPanel = [checker spellingPanel];
+#if !BUILDING_ON_TIGER
+    // Post-Tiger, this menu item is a show/hide toggle, to match AppKit. Leave Tiger behavior alone
+    // to match rest of OS X.
+    if ([spellingPanel isVisible]) {
+        [spellingPanel orderOut:sender];
+        return;
+    }
+#endif
+    
     NSString *badWord = [[self _bridge] advanceToNextMisspellingStartingJustBeforeSelection];
     if (badWord)
         [checker updateSpellingPanelWithMisspelledWord:badWord];
-    [[checker spellingPanel] orderFront:sender];
+    [spellingPanel orderFront:sender];
 }
 
 - (void)_changeSpellingToWord:(NSString *)newWord