Commit fac725ca authored by timothy@apple.com's avatar timothy@apple.com

Update the order of the context menu to better match AppKit on Mac.

<rdar://problem/9054893>

Reviewed by John Sullivan.

Source/WebCore:

* English.lproj/Localizable.strings: Updated.
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::populate): Update the order of items on Mac.
* platform/LocalizationStrategy.h:
* platform/LocalizedStrings.cpp:
(WebCore::contextMenuItemTagLookUpInDictionary): Added argument for selected string.
* platform/LocalizedStrings.h:
* platform/android/LocalizedStringsAndroid.cpp:
(WebCore::contextMenuItemTagLookUpInDictionary): Ditto.
* platform/brew/LocalizedStringsBrew.cpp:
(WebCore::contextMenuItemTagLookUpInDictionary): Ditto.
* platform/efl/LocalizedStringsEfl.cpp:
(WebCore::contextMenuItemTagLookUpInDictionary): Ditto.
* platform/gtk/LocalizedStringsGtk.cpp:
(WebCore::contextMenuItemTagLookUpInDictionary): Ditto.
* platform/haiku/LocalizedStringsHaiku.cpp:
(WebCore::contextMenuItemTagLookUpInDictionary): Ditto.
* platform/wx/LocalizedStringsWx.cpp:
(WebCore::contextMenuItemTagLookUpInDictionary): Ditto.

Source/WebKit/mac:

* DefaultDelegates/WebDefaultContextMenuDelegate.mm:
(-[WebDefaultUIDelegate webView:contextMenuItemsForElement:defaultMenuItems:]): Update the order of items.
* WebCoreSupport/WebPlatformStrategies.h:
* WebCoreSupport/WebPlatformStrategies.mm:
(WebPlatformStrategies::contextMenuItemTagLookUpInDictionary): Added argument for selected string.

Source/WebKit2:

* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::contextMenuItemTagLookUpInDictionary): Added argument for selected string.
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@82337 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 77300e31
2011-03-29 Timothy Hatcher <timothy@apple.com>
Update the order of the context menu to better match AppKit on Mac.
<rdar://problem/9054893>
Reviewed by John Sullivan.
* English.lproj/Localizable.strings: Updated.
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::populate): Update the order of items on Mac.
* platform/LocalizationStrategy.h:
* platform/LocalizedStrings.cpp:
(WebCore::contextMenuItemTagLookUpInDictionary): Added argument for selected string.
* platform/LocalizedStrings.h:
* platform/android/LocalizedStringsAndroid.cpp:
(WebCore::contextMenuItemTagLookUpInDictionary): Ditto.
* platform/brew/LocalizedStringsBrew.cpp:
(WebCore::contextMenuItemTagLookUpInDictionary): Ditto.
* platform/efl/LocalizedStringsEfl.cpp:
(WebCore::contextMenuItemTagLookUpInDictionary): Ditto.
* platform/gtk/LocalizedStringsGtk.cpp:
(WebCore::contextMenuItemTagLookUpInDictionary): Ditto.
* platform/haiku/LocalizedStringsHaiku.cpp:
(WebCore::contextMenuItemTagLookUpInDictionary): Ditto.
* platform/wx/LocalizedStringsWx.cpp:
(WebCore::contextMenuItemTagLookUpInDictionary): Ditto.
2011-03-29 Dean Jackson <dino@apple.com>
Reviewed by Chris Marrin and Ken Russell.
B/* accessibility help text for media controller time value >= 1 day */
......
......@@ -633,6 +633,14 @@ static bool selectionContainsPossibleWord(Frame* frame)
return false;
}
#if PLATFORM(MAC)
#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
#define INCLUDE_SPOTLIGHT_CONTEXT_MENU_ITEM 1
#else
#define INCLUDE_SPOTLIGHT_CONTEXT_MENU_ITEM 0
#endif
#endif
void ContextMenuController::populate()
{
ContextMenuItem OpenLinkItem(ActionType, ContextMenuItemTagOpenLink, contextMenuItemTagOpenLink());
......@@ -668,8 +676,6 @@ void ContextMenuController::populate()
#if PLATFORM(MAC)
ContextMenuItem SearchSpotlightItem(ActionType, ContextMenuItemTagSearchInSpotlight,
contextMenuItemTagSearchInSpotlight());
ContextMenuItem LookInDictionaryItem(ActionType, ContextMenuItemTagLookUpInDictionary,
contextMenuItemTagLookUpInDictionary());
#endif
#if !PLATFORM(GTK)
ContextMenuItem SearchWebItem(ActionType, ContextMenuItemTagSearchWeb, contextMenuItemTagSearchWeb());
......@@ -759,20 +765,31 @@ void ContextMenuController::populate()
if (m_hitTestResult.isSelected()) {
if (selectionContainsPossibleWord(frame)) {
#if PLATFORM(MAC)
String selectedString = frame->displayStringModifiedByEncoding(frame->editor()->selectedText());
ContextMenuItem LookUpInDictionaryItem(ActionType, ContextMenuItemTagLookUpInDictionary, contextMenuItemTagLookUpInDictionary(selectedString));
#if INCLUDE_SPOTLIGHT_CONTEXT_MENU_ITEM
appendItem(SearchSpotlightItem, m_contextMenu.get());
#else
appendItem(LookUpInDictionaryItem, m_contextMenu.get());
#endif
#endif
#if !PLATFORM(GTK)
appendItem(SearchWebItem, m_contextMenu.get());
appendItem(*separatorItem(), m_contextMenu.get());
#endif
#if PLATFORM(MAC)
appendItem(LookInDictionaryItem, m_contextMenu.get());
#if PLATFORM(MAC) && INCLUDE_SPOTLIGHT_CONTEXT_MENU_ITEM
appendItem(LookUpInDictionaryItem, m_contextMenu.get());
appendItem(*separatorItem(), m_contextMenu.get());
#endif
}
appendItem(CopyItem, m_contextMenu.get());
#if PLATFORM(MAC)
appendItem(*separatorItem(), m_contextMenu.get());
ContextMenuItem SpeechMenuItem(SubmenuType, ContextMenuItemTagSpeechMenu, contextMenuItemTagSpeechMenu());
createAndAppendSpeechSubMenu(SpeechMenuItem);
appendItem(SpeechMenuItem, m_contextMenu.get());
......@@ -814,7 +831,7 @@ void ContextMenuController::populate()
SelectionController* selection = frame->selection();
bool inPasswordField = selection->isInPasswordField();
bool spellCheckingEnabled = frame->editor()->isSpellCheckingEnabledFor(node);
if (!inPasswordField && spellCheckingEnabled) {
// Consider adding spelling-related or grammar-related context menu items (never both, since a single selected range
// is never considered a misspelling and bad grammar at the same time)
......@@ -874,15 +891,23 @@ void ContextMenuController::populate()
if (m_hitTestResult.isSelected() && !inPasswordField && selectionContainsPossibleWord(frame)) {
#if PLATFORM(MAC)
String selectedString = frame->displayStringModifiedByEncoding(frame->editor()->selectedText());
ContextMenuItem LookUpInDictionaryItem(ActionType, ContextMenuItemTagLookUpInDictionary, contextMenuItemTagLookUpInDictionary(selectedString));
#if INCLUDE_SPOTLIGHT_CONTEXT_MENU_ITEM
appendItem(SearchSpotlightItem, m_contextMenu.get());
#else
appendItem(LookUpInDictionaryItem, m_contextMenu.get());
#endif
#endif
#if !PLATFORM(GTK)
appendItem(SearchWebItem, m_contextMenu.get());
appendItem(*separatorItem(), m_contextMenu.get());
#endif
#if PLATFORM(MAC)
appendItem(LookInDictionaryItem, m_contextMenu.get());
#if PLATFORM(MAC) && INCLUDE_SPOTLIGHT_CONTEXT_MENU_ITEM
appendItem(LookUpInDictionaryItem, m_contextMenu.get());
appendItem(*separatorItem(), m_contextMenu.get());
#endif
}
......
......@@ -79,7 +79,7 @@ public:
virtual String contextMenuItemTagIgnoreSpelling() = 0;
virtual String contextMenuItemTagLearnSpelling() = 0;
virtual String contextMenuItemTagSearchWeb() = 0;
virtual String contextMenuItemTagLookUpInDictionary() = 0;
virtual String contextMenuItemTagLookUpInDictionary(const String& selectedString) = 0;
virtual String contextMenuItemTagOpenLink() = 0;
virtual String contextMenuItemTagIgnoreGrammar() = 0;
virtual String contextMenuItemTagSpellingMenu() = 0;
......
......@@ -190,9 +190,9 @@ String contextMenuItemTagSearchWeb()
return platformStrategies()->localizationStrategy()->contextMenuItemTagSearchWeb();
}
String contextMenuItemTagLookUpInDictionary()
String contextMenuItemTagLookUpInDictionary(const String& selectedString)
{
return platformStrategies()->localizationStrategy()->contextMenuItemTagLookUpInDictionary();
return platformStrategies()->localizationStrategy()->contextMenuItemTagLookUpInDictionary(selectedString);
}
String contextMenuItemTagOpenLink()
......
......@@ -75,7 +75,7 @@ namespace WebCore {
String contextMenuItemTagIgnoreSpelling();
String contextMenuItemTagLearnSpelling();
String contextMenuItemTagSearchWeb();
String contextMenuItemTagLookUpInDictionary();
String contextMenuItemTagLookUpInDictionary(const String& selectedString);
String contextMenuItemTagOpenLink();
String contextMenuItemTagIgnoreGrammar();
String contextMenuItemTagSpellingMenu();
......
......@@ -213,7 +213,7 @@ String contextMenuItemTagSearchWeb()
return String();
}
String contextMenuItemTagLookUpInDictionary()
String contextMenuItemTagLookUpInDictionary(const String&)
{
notImplemented();
return String();
......
......@@ -206,7 +206,7 @@ String contextMenuItemTagSearchWeb()
return "Search web";
}
String contextMenuItemTagLookUpInDictionary()
String contextMenuItemTagLookUpInDictionary(const String&)
{
return "Lookup in dictionary";
}
......
......@@ -241,7 +241,7 @@ String contextMenuItemTagSearchWeb()
return String::fromUTF8("Search the Web");
}
String contextMenuItemTagLookUpInDictionary()
String contextMenuItemTagLookUpInDictionary(const String&)
{
return String::fromUTF8("Look Up in Dictionary");
}
......
......@@ -259,7 +259,7 @@ String contextMenuItemTagSearchWeb()
return String::fromUTF8(_("_Search the Web"));
}
String contextMenuItemTagLookUpInDictionary()
String contextMenuItemTagLookUpInDictionary(const String&)
{
return String::fromUTF8(_("_Look Up in Dictionary"));
}
......
......@@ -213,7 +213,7 @@ String contextMenuItemTagSearchWeb()
return "Search web";
}
String contextMenuItemTagLookUpInDictionary()
String contextMenuItemTagLookUpInDictionary(const String&)
{
return "Lookup in dictionary";
}
......
......@@ -212,7 +212,7 @@ String contextMenuItemTagSearchWeb()
return String("Search Web");
}
String contextMenuItemTagLookUpInDictionary()
String contextMenuItemTagLookUpInDictionary(const String&)
{
return String("Look Up in Dictionary");
}
......
2011-03-29 Timothy Hatcher <timothy@apple.com>
Update the order of the context menu to better match AppKit on Mac.
<rdar://problem/9054893>
Reviewed by John Sullivan.
* DefaultDelegates/WebDefaultContextMenuDelegate.mm:
(-[WebDefaultUIDelegate webView:contextMenuItemsForElement:defaultMenuItems:]): Update the order of items.
* WebCoreSupport/WebPlatformStrategies.h:
* WebCoreSupport/WebPlatformStrategies.mm:
(WebPlatformStrategies::contextMenuItemTagLookUpInDictionary): Added argument for selected string.
2011-03-29 Alexey Proskuryakov <ap@apple.com>
Reviewed by Darin Adler.
......
......@@ -129,6 +129,12 @@
}
}
#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
#define INCLUDE_SPOTLIGHT_CONTEXT_MENU_ITEM 1
#else
#define INCLUDE_SPOTLIGHT_CONTEXT_MENU_ITEM 0
#endif
- (NSArray *)webView:(WebView *)wv contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems
{
// The defaultMenuItems here are ones supplied by the WebDocumentView protocol implementation. WebPDFView is
......@@ -141,16 +147,29 @@
// The Spotlight and Google items are implemented in WebView, and require that the
// current document view conforms to WebDocumentText
ASSERT([[[webFrame frameView] documentView] conformsToProtocol:@protocol(WebDocumentText)]);
[menuItems addObject:[self menuItemWithTag:WebMenuItemTagSearchInSpotlight target:nil representedObject:element]];
[menuItems addObject:[self menuItemWithTag:WebMenuItemTagSearchWeb target:nil representedObject:element]];
[menuItems addObject:[NSMenuItem separatorItem]];
// FIXME 4184640: The Look Up in Dictionary item is only implemented in WebHTMLView, and so is present but
// dimmed for other cases where WebElementIsSelectedKey is present. It would probably
// be better not to include it in the menu if the documentView isn't a WebHTMLView, but that could break
// existing clients that have code that relies on it being present (unlikely for clients outside of Apple,
// but Safari has such code).
[menuItems addObject:[self menuItemWithTag:WebMenuItemTagLookUpInDictionary target:nil representedObject:element]];
#if INCLUDE_SPOTLIGHT_CONTEXT_MENU_ITEM
[menuItems addObject:[self menuItemWithTag:WebMenuItemTagSearchInSpotlight target:nil representedObject:element]];
#else
NSMenuItem *lookupMenuItem = [self menuItemWithTag:WebMenuItemTagLookUpInDictionary target:nil representedObject:element];
NSString *selectedString = [(id <WebDocumentText>)[[webFrame frameView] documentView] selectedString];
[lookupMenuItem setTitle:[NSString stringWithFormat:UI_STRING_INTERNAL("Look Up “%@”", "Look Up context menu item with selected word"), selectedString]];
[menuItems addObject:lookupMenuItem];
#endif
[menuItems addObject:[self menuItemWithTag:WebMenuItemTagSearchWeb target:nil representedObject:element]];
#if INCLUDE_SPOTLIGHT_CONTEXT_MENU_ITEM
[menuItems addObject:[NSMenuItem separatorItem]];
[menuItems addObject:[self menuItemWithTag:WebMenuItemTagLookUpInDictionary target:nil representedObject:element]];
#endif
[menuItems addObject:[NSMenuItem separatorItem]];
[menuItems addObject:[self menuItemWithTag:WebMenuItemTagCopy target:nil representedObject:element]];
} else {
......
......@@ -80,7 +80,7 @@ private:
virtual WTF::String contextMenuItemTagIgnoreSpelling();
virtual WTF::String contextMenuItemTagLearnSpelling();
virtual WTF::String contextMenuItemTagSearchWeb();
virtual WTF::String contextMenuItemTagLookUpInDictionary();
virtual WTF::String contextMenuItemTagLookUpInDictionary(const WTF::String& selectedString);
virtual WTF::String contextMenuItemTagOpenLink();
virtual WTF::String contextMenuItemTagIgnoreGrammar();
virtual WTF::String contextMenuItemTagSpellingMenu();
......
......@@ -274,9 +274,13 @@ String WebPlatformStrategies::contextMenuItemTagSearchWeb()
return UI_STRING_INTERNAL("Search in Google", "Search in Google context menu item");
}
String WebPlatformStrategies::contextMenuItemTagLookUpInDictionary()
String WebPlatformStrategies::contextMenuItemTagLookUpInDictionary(const String& selectedString)
{
#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
return UI_STRING_INTERNAL("Look Up in Dictionary", "Look Up in Dictionary context menu item");
#else
return [NSString stringWithFormat:UI_STRING_INTERNAL("Look Up “%@”", "Look Up context menu item with selected word"), (NSString *)selectedString];
#endif
}
String WebPlatformStrategies::contextMenuItemTagOpenLink()
......
2011-03-29 Timothy Hatcher <timothy@apple.com>
Update the order of the context menu to better match AppKit on Mac.
<rdar://problem/9054893>
Reviewed by John Sullivan.
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::contextMenuItemTagLookUpInDictionary): Added argument for selected string.
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:
2011-03-29 Jeff Miller <jeffm@apple.com>
Fix formatting of WebKit2.vcproj after r82283.
......
......@@ -376,9 +376,13 @@ String WebPlatformStrategies::contextMenuItemTagSearchWeb()
return UI_STRING("Search in Google", "Search in Google context menu item");
}
String WebPlatformStrategies::contextMenuItemTagLookUpInDictionary()
String WebPlatformStrategies::contextMenuItemTagLookUpInDictionary(const String& selectedString)
{
#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
return UI_STRING("Look Up in Dictionary", "Look Up in Dictionary context menu item");
#else
return UI_STRING("Look Up “<selection>”", "Look Up context menu item with selected word").replace("<selection>", selectedString);
#endif
}
String WebPlatformStrategies::contextMenuItemTagOpenLink()
......
......@@ -97,7 +97,7 @@ private:
virtual String contextMenuItemTagIgnoreSpelling();
virtual String contextMenuItemTagLearnSpelling();
virtual String contextMenuItemTagSearchWeb();
virtual String contextMenuItemTagLookUpInDictionary();
virtual String contextMenuItemTagLookUpInDictionary(const String& selectedString);
virtual String contextMenuItemTagOpenLink();
virtual String contextMenuItemTagIgnoreGrammar();
virtual String contextMenuItemTagSpellingMenu();
......
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