Commit 9b32d8ac authored by aroben's avatar aroben

WebCore:

        Reviewed by Darin.

        Small context menu fixes.

        * platform/ContextMenu.cpp:
        (WebCore::ContextMenu::populate): Fix typo.
        (WebCore::ContextMenu::checkOrEnableIfNeeded): Disabled "No Guesses
        Found", and added all enum values explicitly.

WebKit:

        Reviewed by Darin.

        Fix: http://bugs.webkit.org/show_bug.cgi?id=12134
        REGRESSION: Assertion failure and crash when right clicking selection
        in forms

        * WebCoreSupport/WebContextMenuClient.mm:
        (fixMenusFromOldApps): Static helper to fix up menus from applications
        compiled against Tiger WebKit.
        (WebContextMenuClient::getCustomMenuFromDefaultItems): Call helper to
        fix menus.
        * WebView/WebUIDelegatePrivate.h: Fixed typo.



git-svn-id: svn://svn.chromium.org/blink/trunk@18864 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 85fa531d
2007-01-15 Adam Roben <aroben@apple.com>
Reviewed by Darin.
Small context menu fixes.
* platform/ContextMenu.cpp:
(WebCore::ContextMenu::populate): Fix typo.
(WebCore::ContextMenu::checkOrEnableIfNeeded): Disabled "No Guesses
Found", and added all enum values explicitly.
2007-01-15 Alexey Proskuryakov <ap@webkit.org> 2007-01-15 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Darin. Reviewed by Darin.
......
...@@ -187,7 +187,7 @@ void ContextMenu::populate() ...@@ -187,7 +187,7 @@ void ContextMenu::populate()
ContextMenuItem ReloadItem(ActionType, ContextMenuItemTagReload, contextMenuItemTagReload()); ContextMenuItem ReloadItem(ActionType, ContextMenuItemTagReload, contextMenuItemTagReload());
ContextMenuItem OpenFrameItem(ActionType, ContextMenuItemTagOpenFrameInNewWindow, ContextMenuItem OpenFrameItem(ActionType, ContextMenuItemTagOpenFrameInNewWindow,
contextMenuItemTagOpenFrameInNewWindow()); contextMenuItemTagOpenFrameInNewWindow());
ContextMenuItem NowGuessesItem(ActionType, ContextMenuItemTagNoGuessesFound, ContextMenuItem NoGuessesItem(ActionType, ContextMenuItemTagNoGuessesFound,
contextMenuItemTagNoGuessesFound()); contextMenuItemTagNoGuessesFound());
ContextMenuItem IgnoreSpellingItem(ActionType, ContextMenuItemTagIgnoreSpelling, ContextMenuItem IgnoreSpellingItem(ActionType, ContextMenuItemTagIgnoreSpelling,
contextMenuItemTagIgnoreSpelling()); contextMenuItemTagIgnoreSpelling());
...@@ -274,7 +274,7 @@ void ContextMenu::populate() ...@@ -274,7 +274,7 @@ void ContextMenu::populate()
// If there's bad grammar but no suggestions (e.g., repeated word), just leave off the suggestions // If there's bad grammar but no suggestions (e.g., repeated word), just leave off the suggestions
// list and trailing separator rather than adding a "No Guesses Found" item (matches AppKit) // list and trailing separator rather than adding a "No Guesses Found" item (matches AppKit)
if (misspelling) { if (misspelling) {
appendItem(NowGuessesItem); appendItem(NoGuessesItem);
appendItem(*separatorItem()); appendItem(*separatorItem());
} }
} else { } else {
...@@ -445,7 +445,49 @@ void ContextMenu::checkOrEnableIfNeeded(ContextMenuItem& item) const ...@@ -445,7 +445,49 @@ void ContextMenu::checkOrEnableIfNeeded(ContextMenuItem& item) const
shouldEnable = frame->editor()->canEdit(); shouldEnable = frame->editor()->canEdit();
break; break;
#endif #endif
default: case ContextMenuItemTagNoGuessesFound:
shouldEnable = false;
break;
case ContextMenuItemTagNoAction:
case ContextMenuItemTagOpenLinkInNewWindow:
case ContextMenuItemTagDownloadLinkToDisk:
case ContextMenuItemTagCopyLinkToClipboard:
case ContextMenuItemTagOpenImageInNewWindow:
case ContextMenuItemTagDownloadImageToDisk:
case ContextMenuItemTagCopyImageToClipboard:
case ContextMenuItemTagOpenFrameInNewWindow:
case ContextMenuItemTagGoBack:
case ContextMenuItemTagGoForward:
case ContextMenuItemTagStop:
case ContextMenuItemTagReload:
case ContextMenuItemTagSpellingGuess:
case ContextMenuItemTagOther:
case ContextMenuItemTagSearchInSpotlight:
case ContextMenuItemTagSearchWeb:
case ContextMenuItemTagOpenWithDefaultApplication:
case ContextMenuItemPDFActualSize:
case ContextMenuItemPDFZoomIn:
case ContextMenuItemPDFZoomOut:
case ContextMenuItemPDFAutoSize:
case ContextMenuItemPDFSinglePage:
case ContextMenuItemPDFFacingPages:
case ContextMenuItemPDFContinuous:
case ContextMenuItemPDFNextPage:
case ContextMenuItemPDFPreviousPage:
case ContextMenuItemTagOpenLink:
case ContextMenuItemTagIgnoreGrammar:
case ContextMenuItemTagSpellingMenu:
case ContextMenuItemTagCheckSpellingWhileTyping:
case ContextMenuItemTagCheckGrammarWithSpelling:
case ContextMenuItemTagFontMenu:
case ContextMenuItemTagShowFonts:
case ContextMenuItemTagStyles:
case ContextMenuItemTagShowColors:
case ContextMenuItemTagSpeechMenu:
case ContextMenuItemTagStartSpeaking:
case ContextMenuItemTagStopSpeaking:
case ContextMenuItemTagWritingDirectionMenu:
case ContextMenuItemBaseApplicationTag:
break; break;
} }
......
2007-01-15 Adam Roben <aroben@apple.com>
Reviewed by Darin.
Fix: http://bugs.webkit.org/show_bug.cgi?id=12134
REGRESSION: Assertion failure and crash when right clicking selection
in forms
* WebCoreSupport/WebContextMenuClient.mm:
(fixMenusFromOldApps): Static helper to fix up menus from applications
compiled against Tiger WebKit.
(WebContextMenuClient::getCustomMenuFromDefaultItems): Call helper to
fix menus.
* WebView/WebUIDelegatePrivate.h: Fixed typo.
2007-01-14 David Kilzer <ddkilzer@kilzer.net> 2007-01-14 David Kilzer <ddkilzer@kilzer.net>
Reviewed by Darin. Reviewed by Darin.
......
/* /*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -57,22 +57,18 @@ void WebContextMenuClient::contextMenuDestroyed() ...@@ -57,22 +57,18 @@ void WebContextMenuClient::contextMenuDestroyed()
delete this; delete this;
} }
NSMutableArray* WebContextMenuClient::getCustomMenuFromDefaultItems(ContextMenu* defaultMenu) static NSMutableArray* fixMenusFromOldApps(NSMutableArray *newMenuItems, NSMutableArray *defaultMenuItems)
{ {
id delegate = [m_webView UIDelegate]; // The WebMenuItemTag enum has changed since Tiger, so clients built against Tiger WebKit might reference incorrect values for tags.
if ([delegate respondsToSelector:@selector(webView:contextMenuItemsForElement:defaultMenuItems:)]) { // Here we fix up Tiger Mail and Tiger Safari.
NSDictionary *element = [[[WebElementDictionary alloc] initWithHitTestResult:defaultMenu->hitTestResult()] autorelease];
NSMutableArray *defaultMenuItems = defaultMenu->platformDescription(); if ([newMenuItems count] && [[newMenuItems objectAtIndex:0] isSeparatorItem]) {
NSMutableArray *newMenuItems = [[delegate webView:m_webView contextMenuItemsForElement:element defaultMenuItems:defaultMenuItems] mutableCopy]; if ([[newMenuItems objectAtIndex:1] isSeparatorItem]) {
// Versions of Mail compiled with older WebKits will end up without three context menu items,
// Versions of Mail compiled with older WebKits will end up without three context menu items, // though with the separators between them. Here we check for that problem and reinsert the
// though with the separators between them. Here we check for that problem and reinsert the // three missing items. This shouldn't affect any clients other than Mail since the tags for
// three missing items. This shouldn't affect any clients other than Mail since the tags for // the three items were not public API. We can remove this code when we no longer support
// the three items were not public API. We can remove this code when we no longer support // previously-built versions of Mail on Tiger. See 4498606 for more details.
// previously-built versions of Mail on Tiger. See 4498606 for more details.
if ([newMenuItems count] &&
([[defaultMenuItems objectAtIndex:0] tag] == WebMenuItemTagSearchInSpotlight) &&
([[newMenuItems objectAtIndex:0] isSeparatorItem])) {
ASSERT([[newMenuItems objectAtIndex:1] isSeparatorItem]); ASSERT([[newMenuItems objectAtIndex:1] isSeparatorItem]);
ASSERT([[defaultMenuItems objectAtIndex:1] tag] == WebMenuItemTagSearchWeb); ASSERT([[defaultMenuItems objectAtIndex:1] tag] == WebMenuItemTagSearchWeb);
ASSERT([[defaultMenuItems objectAtIndex:2] isSeparatorItem]); ASSERT([[defaultMenuItems objectAtIndex:2] isSeparatorItem]);
...@@ -81,11 +77,35 @@ NSMutableArray* WebContextMenuClient::getCustomMenuFromDefaultItems(ContextMenu* ...@@ -81,11 +77,35 @@ NSMutableArray* WebContextMenuClient::getCustomMenuFromDefaultItems(ContextMenu*
[newMenuItems insertObject:[defaultMenuItems objectAtIndex:0] atIndex:0]; [newMenuItems insertObject:[defaultMenuItems objectAtIndex:0] atIndex:0];
[newMenuItems insertObject:[defaultMenuItems objectAtIndex:1] atIndex:1]; [newMenuItems insertObject:[defaultMenuItems objectAtIndex:1] atIndex:1];
[newMenuItems insertObject:[defaultMenuItems objectAtIndex:3] atIndex:3]; [newMenuItems insertObject:[defaultMenuItems objectAtIndex:3] atIndex:3];
return [newMenuItems autorelease];
} }
return [newMenuItems autorelease]; unsigned defaultItemsCount = [defaultMenuItems count];
for (unsigned i = 0; i < defaultItemsCount; ++i)
if ([[defaultMenuItems objectAtIndex:i] tag] == WebMenuItemTagSpellingMenu) {
// Tiger Safari doesn't realize we're popping up an editing menu.
// http://bugs.webkit.org/show_bug.cgi?id=12134 has details.
[newMenuItems release];
return defaultMenuItems;
}
} }
return nil;
// Nothing needs to be done
return [newMenuItems autorelease];
}
NSMutableArray* WebContextMenuClient::getCustomMenuFromDefaultItems(ContextMenu* defaultMenu)
{
id delegate = [m_webView UIDelegate];
if (![delegate respondsToSelector:@selector(webView:contextMenuItemsForElement:defaultMenuItems:)])
return nil;
NSDictionary *element = [[[WebElementDictionary alloc] initWithHitTestResult:defaultMenu->hitTestResult()] autorelease];
NSMutableArray *defaultMenuItems = defaultMenu->platformDescription();
NSMutableArray *newMenuItems = [[delegate webView:m_webView contextMenuItemsForElement:element defaultMenuItems:defaultMenuItems] mutableCopy];
return fixMenusFromOldApps(newMenuItems, defaultMenuItems);
} }
void WebContextMenuClient::contextMenuItemSelected(ContextMenuItem* item, const ContextMenu* parentMenu) void WebContextMenuClient::contextMenuItemSelected(ContextMenuItem* item, const ContextMenu* parentMenu)
......
/* /*
* Copyright (C) 2005 Apple Computer, Inc. All rights reserved. * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
enum { enum {
WebMenuItemTagOpenLink = 1000, WebMenuItemTagOpenLink = 1000,
WebMenuItemTagIgnoreGrammar, WebMenuItemTagIgnoreGrammar,
WebtMenuItemTagSpellingMenu, WebMenuItemTagSpellingMenu,
WebMenuItemTagShowSpellingPanel, WebMenuItemTagShowSpellingPanel,
WebMenuItemTagCheckSpelling, WebMenuItemTagCheckSpelling,
WebMenuItemTagCheckSpellingWhileTyping, WebMenuItemTagCheckSpellingWhileTyping,
......
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