Commit 1aee922b authored by zecke@webkit.org's avatar zecke@webkit.org

* Qt and Gtk must know if a ContextMenuItem is checkable. Add a new...

* Qt and Gtk must know if a ContextMenuItem is checkable. Add a new ContextMenuItemType for checkable
  actions.
* Use this information in the Gtk platform to create a GtkCheckMenuItem when needed.
* Update the ContextMenuController to accept CheckableActionTypes as well.
* Change ContextMenu.cpp to use the CheckableActionType. The information if a item is checkable
  was extracted from ContextMenu::checkOrEnableIfNeeded.
* Update the Qt and Windows port.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@29230 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 425dfd5e
2008-01-07 Holger Freyther <zecke@selfish.org>
Reviewed by Alp Toker.
* Qt and Gtk must know if a ContextMenuItem is checkable. Add a new ContextMenuItemType for checkable
actions.
* Use this information in the Gtk platform to create a GtkCheckMenuItem when needed.
* Update the ContextMenuController to accept CheckableActionTypes as well.
* Change ContextMenu.cpp to use the CheckableActionType. The information if a item is checkable
was extracted from ContextMenu::checkOrEnableIfNeeded.
* Update the Qt and Windows port.
* page/ContextMenuController.cpp:
* platform/ContextMenu.cpp:
(WebCore::createAndAppendFontSubMenu):
(WebCore::createAndAppendSpellingAndGrammarSubMenu):
(WebCore::createAndAppendSpellingSubMenu):
(WebCore::createAndAppendWritingDirectionSubMenu):
* platform/ContextMenuItem.h:
* platform/gtk/ContextMenuItemGtk.cpp:
(WebCore::ContextMenuItem::ContextMenuItem):
(WebCore::ContextMenuItem::createNativeMenuItem):
2008-01-07 Luca Bruno <lethalman88@gmail.com>
Reviewed by Alp Toker.
......
......@@ -118,7 +118,7 @@ static void openNewWindow(const KURL& urlToLoad, Frame* frame)
void ContextMenuController::contextMenuItemSelected(ContextMenuItem* item)
{
ASSERT(item->type() == ActionType);
ASSERT(item->type() == ActionType || item->type() == CheckableActionType);
if (item->action() >= ContextMenuItemBaseApplicationTag) {
m_client->contextMenuItemSelected(item, m_contextMenu.get());
......
......@@ -70,9 +70,9 @@ static void createAndAppendFontSubMenu(const HitTestResult& result, ContextMenuI
#if PLATFORM(MAC)
ContextMenuItem showFonts(ActionType, ContextMenuItemTagShowFonts, contextMenuItemTagShowFonts());
#endif
ContextMenuItem bold(ActionType, ContextMenuItemTagBold, contextMenuItemTagBold());
ContextMenuItem italic(ActionType, ContextMenuItemTagItalic, contextMenuItemTagItalic());
ContextMenuItem underline(ActionType, ContextMenuItemTagUnderline, contextMenuItemTagUnderline());
ContextMenuItem bold(CheckableActionType, ContextMenuItemTagBold, contextMenuItemTagBold());
ContextMenuItem italic(CheckableActionType, ContextMenuItemTagItalic, contextMenuItemTagItalic());
ContextMenuItem underline(CheckableActionType, ContextMenuItemTagUnderline, contextMenuItemTagUnderline());
ContextMenuItem outline(ActionType, ContextMenuItemTagOutline, contextMenuItemTagOutline());
#if PLATFORM(MAC)
ContextMenuItem styles(ActionType, ContextMenuItemTagStyles, contextMenuItemTagStyles());
......@@ -104,9 +104,9 @@ static void createAndAppendSpellingAndGrammarSubMenu(const HitTestResult& result
contextMenuItemTagShowSpellingPanel(true));
ContextMenuItem checkSpelling(ActionType, ContextMenuItemTagCheckSpelling,
contextMenuItemTagCheckSpelling());
ContextMenuItem checkAsYouType(ActionType, ContextMenuItemTagCheckSpellingWhileTyping,
ContextMenuItem checkAsYouType(CheckableActionType, ContextMenuItemTagCheckSpellingWhileTyping,
contextMenuItemTagCheckSpellingWhileTyping());
ContextMenuItem grammarWithSpelling(ActionType, ContextMenuItemTagCheckGrammarWithSpelling,
ContextMenuItem grammarWithSpelling(CheckableActionType, ContextMenuItemTagCheckGrammarWithSpelling,
contextMenuItemTagCheckGrammarWithSpelling());
spellingAndGrammarMenu.appendItem(showSpellingPanel);
......@@ -126,7 +126,7 @@ static void createAndAppendSpellingSubMenu(const HitTestResult& result, ContextM
contextMenuItemTagShowSpellingPanel(true));
ContextMenuItem checkSpelling(ActionType, ContextMenuItemTagCheckSpelling,
contextMenuItemTagCheckSpelling());
ContextMenuItem checkAsYouType(ActionType, ContextMenuItemTagCheckSpellingWhileTyping,
ContextMenuItem checkAsYouType(CheckableActionType, ContextMenuItemTagCheckSpellingWhileTyping,
contextMenuItemTagCheckSpellingWhileTyping());
spellingMenu.appendItem(showSpellingPanel);
......@@ -158,8 +158,8 @@ static void createAndAppendWritingDirectionSubMenu(const HitTestResult& result,
ContextMenuItem defaultItem(ActionType, ContextMenuItemTagDefaultDirection,
contextMenuItemTagDefaultDirection());
ContextMenuItem ltr(ActionType, ContextMenuItemTagLeftToRight, contextMenuItemTagLeftToRight());
ContextMenuItem rtl(ActionType, ContextMenuItemTagRightToLeft, contextMenuItemTagRightToLeft());
ContextMenuItem ltr(CheckableActionType, ContextMenuItemTagLeftToRight, contextMenuItemTagLeftToRight());
ContextMenuItem rtl(CheckableActionType, ContextMenuItemTagRightToLeft, contextMenuItemTagRightToLeft());
writingDirectionMenu.appendItem(defaultItem);
writingDirectionMenu.appendItem(ltr);
......
......@@ -119,6 +119,7 @@ namespace WebCore {
enum ContextMenuItemType {
ActionType,
CheckableActionType,
SeparatorType,
SubmenuType
};
......
......@@ -106,7 +106,10 @@ ContextMenuItem::ContextMenuItem(GtkMenuItem* item)
m_platformDescription.type = SeparatorType;
else if (gtk_menu_item_get_submenu(item))
m_platformDescription.type = SubmenuType;
else
else if (GTK_IS_CHECK_MENU_ITEM(item)) {
m_platformDescription.type = CheckableActionType;
m_platformDescription.checked = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item));
} else
m_platformDescription.type = ActionType;
m_platformDescription.action = *static_cast<ContextMenuAction*>(g_object_get_data(G_OBJECT(item), WEBKIT_CONTEXT_MENU_ACTION));
......@@ -140,7 +143,7 @@ GtkMenuItem* ContextMenuItem::createNativeMenuItem(const PlatformMenuItemDescrip
if (menu.type == SeparatorType)
item = GTK_MENU_ITEM(gtk_separator_menu_item_new());
else {
if (menu.checked) {
if (menu.type == CheckableActionType) {
item = GTK_MENU_ITEM(gtk_check_menu_item_new_with_label(menu.title.utf8().data()));
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), menu.checked);
} else {
......@@ -227,7 +230,7 @@ void ContextMenuItem::setSubMenu(ContextMenu* menu)
void ContextMenuItem::setChecked(bool shouldCheck)
{
ASSERT(type() == ActionType);
ASSERT(type() == ActionType || type() == CheckableActionType);
m_platformDescription.checked = shouldCheck;
}
......
......@@ -212,6 +212,7 @@ QMenu *QWebPagePrivate::createContextMenu(const WebCore::ContextMenu *webcoreMen
for (int i = 0; i < items->count(); ++i) {
const ContextMenuItem &item = items->at(i);
switch (item.type()) {
case WebCore::CheckableActionType: /* fall through */
case WebCore::ActionType: {
QWebPage::WebAction action = webActionForContextMenuAction(item.action());
QAction *a = q->action(action);
......@@ -221,6 +222,7 @@ QMenu *QWebPagePrivate::createContextMenu(const WebCore::ContextMenu *webcoreMen
PlatformMenuItemDescription desc = it.releasePlatformDescription();
a->setEnabled(desc.enabled);
a->setChecked(desc.checked);
a->setCheckable(item.type() == WebCore::CheckableActionType);
menu->addAction(a);
}
......
2008-01-07 Holger Freyther <zecke@selfish.org>
Reviewed by Alp Toker.
* Qt and Gtk must know if a ContextMenuItem is checkable. Add a new ContextMenuItemType for checkable
actions.
* Use this information in the Gtk platform to create a GtkCheckMenuItem when needed.
* Update the ContextMenuController to accept CheckableActionTypes as well.
* Change ContextMenu.cpp to use the CheckableActionType. The information if a item is checkable
was extracted from ContextMenu::checkOrEnableIfNeeded.
* Update the Qt and Windows port.
* Api/qwebpage.cpp:
(QWebPagePrivate::createContextMenu):
2008-01-07 Simon Hausmann <hausmann@webkit.org>
Build fix for the Windows build. MSVC wants to see the full
......
2008-01-07 Holger Freyther <zecke@selfish.org>
Reviewed by Alp Toker.
* Qt and Gtk must know if a ContextMenuItem is checkable. Add a new ContextMenuItemType for checkable
actions.
* Use this information in the Gtk platform to create a GtkCheckMenuItem when needed.
* Update the ContextMenuController to accept CheckableActionTypes as well.
* Change ContextMenu.cpp to use the CheckableActionType. The information if a item is checkable
was extracted from ContextMenu::checkOrEnableIfNeeded.
* Update the Qt and Windows port.
* WebContextMenuClient.cpp:
2008-01-04 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Adam Roben.
......
......@@ -116,7 +116,7 @@ HMENU WebContextMenuClient::getCustomMenuFromDefaultItems(ContextMenu* menu)
void WebContextMenuClient::contextMenuItemSelected(ContextMenuItem* item, const ContextMenu* parentMenu)
{
ASSERT(item->type() == ActionType);
ASSERT(item->type() == ActionType || item->type() == CheckableActionType);
COMPtr<IWebUIDelegate> uiDelegate;
if (FAILED(m_webView->uiDelegate(&uiDelegate)))
......
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