summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/ContextMenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/ContextMenu.cpp')
-rw-r--r--WebCore/platform/ContextMenu.cpp139
1 files changed, 15 insertions, 124 deletions
diff --git a/WebCore/platform/ContextMenu.cpp b/WebCore/platform/ContextMenu.cpp
index 6218597..a9c64df 100644
--- a/WebCore/platform/ContextMenu.cpp
+++ b/WebCore/platform/ContextMenu.cpp
@@ -27,10 +27,11 @@
#include "config.h"
#include "ContextMenu.h"
+#include "ContextMenuController.h"
#include "CSSComputedStyleDeclaration.h"
#include "CSSProperty.h"
#include "CSSPropertyNames.h"
-#include "ContextMenuController.h"
+#include "CString.h"
#include "Document.h"
#include "DocumentLoader.h"
#include "Editor.h"
@@ -40,20 +41,11 @@
#include "LocalizedStrings.h"
#include "Node.h"
#include "Page.h"
-#include "CString.h"
#include "ResourceRequest.h"
#include "SelectionController.h"
#include "TextIterator.h"
#include <memory>
-#if PLATFORM(GTK)
-// FIXME: We shouldn't use WebKit from WebCore.
-#include "webkitprivate.h"
-#include "webkitwebview.h"
-#include <glib/gi18n.h>
-#include "NotImplemented.h"
-#endif
-
using namespace std;
using namespace WTF;
using namespace Unicode;
@@ -162,95 +154,8 @@ static void createAndAppendSpeechSubMenu(const HitTestResult& result, ContextMen
speechMenuItem.setSubMenu(&speechMenu);
}
#endif
-
-#if PLATFORM(GTK)
-static bool createAndAppendInputMethodsSubMenu(const HitTestResult& result, ContextMenuItem& inputMethodsMenuItem)
-{
- WebKitWebView* webView = WebKit::kit(result.innerNonSharedNode()->document()->frame()->page());
- if (!webView)
- return false;
-
- GdkScreen* screen = gtk_widget_has_screen(GTK_WIDGET(webView)) ? gtk_widget_get_screen(GTK_WIDGET(webView)) : gdk_screen_get_default();
- if (!screen)
- return false;
-
- GtkSettings* settings = gtk_settings_get_for_screen(screen);
- gboolean showMenu;
- g_object_get(G_OBJECT(settings), "gtk-show-input-method-menu", &showMenu, NULL);
- if (!showMenu)
- return false;
-
- WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
- GtkWidget* imContextMenu = gtk_menu_new();
- gtk_im_multicontext_append_menuitems(GTK_IM_MULTICONTEXT(priv->imContext), GTK_MENU_SHELL(imContextMenu));
-
- ContextMenu inputMethodsMenu(result);
- inputMethodsMenu.setPlatformDescription(GTK_MENU(imContextMenu));
- inputMethodsMenuItem.setSubMenu(&inputMethodsMenu);
-
- return true;
-}
-
-// Values taken from gtktextutil.c
-typedef struct {
- const char *label;
- gunichar ch;
-} GtkUnicodeMenuEntry;
-static const GtkUnicodeMenuEntry bidi_menu_entries[] = {
- { N_("LRM _Left-to-right mark"), 0x200E },
- { N_("RLM _Right-to-left mark"), 0x200F },
- { N_("LRE Left-to-right _embedding"), 0x202A },
- { N_("RLE Right-to-left e_mbedding"), 0x202B },
- { N_("LRO Left-to-right _override"), 0x202D },
- { N_("RLO Right-to-left o_verride"), 0x202E },
- { N_("PDF _Pop directional formatting"), 0x202C },
- { N_("ZWS _Zero width space"), 0x200B },
- { N_("ZWJ Zero width _joiner"), 0x200D },
- { N_("ZWNJ Zero width _non-joiner"), 0x200C }
-};
-
-static void insertControlCharacter(GtkWidget* widget, Frame* frame)
-{
- GtkUnicodeMenuEntry* entry = (GtkUnicodeMenuEntry*)g_object_get_data(G_OBJECT(widget), "gtk-unicode-menu-entry");
- notImplemented();
-}
-
-static bool createAndAppendUnicodeSubMenu(const HitTestResult& result, ContextMenuItem& unicodeMenuItem)
-{
- WebKitWebView* webView = WebKit::kit(result.innerNonSharedNode()->document()->frame()->page());
- if (!webView)
- return false;
-
- GdkScreen* screen = gtk_widget_has_screen(GTK_WIDGET(webView)) ? gtk_widget_get_screen(GTK_WIDGET(webView)) : gdk_screen_get_default();
- if (!screen)
- return false;
-
- GtkSettings* settings = gtk_settings_get_for_screen(screen);
- gboolean showMenu;
- g_object_get(G_OBJECT(settings), "gtk-show-unicode-menu", &showMenu, NULL);
- if (!showMenu)
- return false;
-
- GtkWidget* unicodeContextMenu = gtk_menu_new();
- unsigned i;
- for (i = 0; i < G_N_ELEMENTS(bidi_menu_entries); i++) {
- GtkWidget* menuitem = gtk_menu_item_new_with_mnemonic(_(bidi_menu_entries[i].label));
- g_object_set_data(G_OBJECT(menuitem), "gtk-unicode-menu-entry", (gpointer)&bidi_menu_entries[i]);
- g_signal_connect(menuitem, "activate", G_CALLBACK(insertControlCharacter), (gpointer)result.innerNonSharedNode()->document()->frame());
- gtk_widget_show(menuitem);
- gtk_menu_shell_append(GTK_MENU_SHELL(unicodeContextMenu), menuitem);
- // FIXME: Make the item sensitive as insertControlCharacter() is implemented
- gtk_widget_set_sensitive(menuitem, FALSE);
- }
-
- ContextMenu unicodeMenu(result);
- unicodeMenu.setPlatformDescription(GTK_MENU(unicodeContextMenu));
- unicodeMenuItem.setSubMenu(&unicodeMenu);
-
- return true;
-}
-#else
-
+
+#if !PLATFORM(GTK)
static void createAndAppendWritingDirectionSubMenu(const HitTestResult& result, ContextMenuItem& writingDirectionMenuItem)
{
ContextMenu writingDirectionMenu(result);
@@ -271,7 +176,7 @@ static void createAndAppendWritingDirectionSubMenu(const HitTestResult& result,
static bool selectionContainsPossibleWord(Frame* frame)
{
// Current algorithm: look for a character that's not just a separator.
- for (TextIterator it(frame->selectionController()->toRange().get()); !it.atEnd(); it.advance()) {
+ for (TextIterator it(frame->selection()->toRange().get()); !it.atEnd(); it.advance()) {
int length = it.length();
const UChar* characters = it.characters();
for (int i = 0; i < length; ++i)
@@ -401,8 +306,8 @@ void ContextMenu::populate()
}
}
} else { // Make an editing context menu
- SelectionController* selectionController = frame->selectionController();
- bool inPasswordField = selectionController->isInPasswordField();
+ SelectionController* selection = frame->selection();
+ bool inPasswordField = selection->isInPasswordField();
if (!inPasswordField) {
// Consider adding spelling-related or grammar-related context menu items (never both, since a single selected range
@@ -498,27 +403,13 @@ void ContextMenu::populate()
createAndAppendSpeechSubMenu(m_hitTestResult, SpeechMenuItem);
appendItem(SpeechMenuItem);
#endif
-#if PLATFORM(GTK)
- }
-
- ContextMenuItem InputMethodsMenuItem(ActionType, ContextMenuItemTagInputMethods, contextMenuItemTagInputMethods());
- bool showInputMethodsMenu = inPasswordField ? false : createAndAppendInputMethodsSubMenu(m_hitTestResult, InputMethodsMenuItem);
- ContextMenuItem UnicodeMenuItem(ActionType, ContextMenuItemTagUnicode, contextMenuItemTagUnicode());
- bool showUnicodeMenu = createAndAppendUnicodeSubMenu(m_hitTestResult, UnicodeMenuItem);
-
- if (showInputMethodsMenu || showUnicodeMenu)
- appendItem(*separatorItem());
- if (showInputMethodsMenu)
- appendItem(InputMethodsMenuItem);
- if (showUnicodeMenu)
- appendItem(UnicodeMenuItem);
-#else
+#if !PLATFORM(GTK)
ContextMenuItem WritingDirectionMenuItem(SubmenuType, ContextMenuItemTagWritingDirectionMenu,
contextMenuItemTagWritingDirectionMenu());
createAndAppendWritingDirectionSubMenu(m_hitTestResult, WritingDirectionMenuItem);
appendItem(WritingDirectionMenuItem);
- }
#endif
+ }
}
}
@@ -569,7 +460,7 @@ void ContextMenu::checkOrEnableIfNeeded(ContextMenuItem& item) const
ExceptionCode ec = 0;
RefPtr<CSSStyleDeclaration> style = frame->document()->createCSSStyleDeclaration();
String direction = item.action() == ContextMenuItemTagLeftToRight ? "ltr" : "rtl";
- style->setProperty(CSS_PROP_DIRECTION, direction, false, ec);
+ style->setProperty(CSSPropertyDirection, direction, false, ec);
shouldCheck = frame->editor()->selectionHasStyle(style.get()) != FalseTriState;
shouldEnable = true;
break;
@@ -582,7 +473,7 @@ void ContextMenu::checkOrEnableIfNeeded(ContextMenuItem& item) const
break;
case ContextMenuItemTagIgnoreSpelling:
case ContextMenuItemTagLearnSpelling:
- shouldEnable = frame->selectionController()->isRange();
+ shouldEnable = frame->selection()->isRange();
break;
case ContextMenuItemTagPaste:
shouldEnable = frame->editor()->canDHTMLPaste() || frame->editor()->canPaste();
@@ -600,13 +491,13 @@ void ContextMenu::checkOrEnableIfNeeded(ContextMenuItem& item) const
case ContextMenuItemTagUnderline: {
ExceptionCode ec = 0;
RefPtr<CSSStyleDeclaration> style = frame->document()->createCSSStyleDeclaration();
- style->setProperty(CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT, "underline", false, ec);
+ style->setProperty(CSSPropertyWebkitTextDecorationsInEffect, "underline", false, ec);
shouldCheck = frame->editor()->selectionHasStyle(style.get()) != FalseTriState;
shouldEnable = frame->editor()->canEditRichly();
break;
}
case ContextMenuItemTagLookUpInDictionary:
- shouldEnable = frame->selectionController()->isRange();
+ shouldEnable = frame->selection()->isRange();
break;
case ContextMenuItemTagCheckGrammarWithSpelling:
#ifndef BUILDING_ON_TIGER
@@ -618,7 +509,7 @@ void ContextMenu::checkOrEnableIfNeeded(ContextMenuItem& item) const
case ContextMenuItemTagItalic: {
ExceptionCode ec = 0;
RefPtr<CSSStyleDeclaration> style = frame->document()->createCSSStyleDeclaration();
- style->setProperty(CSS_PROP_FONT_STYLE, "italic", false, ec);
+ style->setProperty(CSSPropertyFontStyle, "italic", false, ec);
shouldCheck = frame->editor()->selectionHasStyle(style.get()) != FalseTriState;
shouldEnable = frame->editor()->canEditRichly();
break;
@@ -626,7 +517,7 @@ void ContextMenu::checkOrEnableIfNeeded(ContextMenuItem& item) const
case ContextMenuItemTagBold: {
ExceptionCode ec = 0;
RefPtr<CSSStyleDeclaration> style = frame->document()->createCSSStyleDeclaration();
- style->setProperty(CSS_PROP_FONT_WEIGHT, "bold", false, ec);
+ style->setProperty(CSSPropertyFontWeight, "bold", false, ec);
shouldCheck = frame->editor()->selectionHasStyle(style.get()) != FalseTriState;
shouldEnable = frame->editor()->canEditRichly();
break;