* Qt and Gtk must know if a ContextMenuItem is checkable. Add a new ContextMenuItemTy...
authorzecke@webkit.org <zecke@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Jan 2008 19:14:58 +0000 (19:14 +0000)
committerzecke@webkit.org <zecke@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Jan 2008 19:14:58 +0000 (19:14 +0000)
  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: https://svn.webkit.org/repository/webkit/trunk@29230 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/page/ContextMenuController.cpp
WebCore/platform/ContextMenu.cpp
WebCore/platform/ContextMenuItem.h
WebCore/platform/gtk/ContextMenuItemGtk.cpp
WebKit/qt/Api/qwebpage.cpp
WebKit/qt/ChangeLog
WebKit/win/ChangeLog
WebKit/win/WebContextMenuClient.cpp

index a7b84d0b5137d82b381d78e9d673495a68f76ba6..0eaa7be3564876ed3ec33919680f6ad696149734 100644 (file)
@@ -1,3 +1,27 @@
+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.
index a9419e0aed042479c5d6c51bd7fa9e034f5e7666..1acbf5a961b8052c820d1cf37f30aec6bd348e5c 100644 (file)
@@ -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());
index d36a06554673bbf4cbb52cd7c08a9bd4341f7cb1..0dd6be4797b6d341b4e511964577d0f57e089b76 100644 (file)
@@ -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);
index 24694036abf7a2443a5f70f85be4b669b156e2b7..352c8c29b977fd3193c7d702d1aaf8de7c64e70b 100644 (file)
@@ -119,6 +119,7 @@ namespace WebCore {
 
     enum ContextMenuItemType {
         ActionType,
+        CheckableActionType,
         SeparatorType,
         SubmenuType
     };
index 9a01325dcba300dd58e456e6c0287ee323429a7e..5fd5786a4faa004ddb9a672133674044812debb1 100644 (file)
@@ -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;
 }
 
index 14f097039935743ab2fc7c6cb4cb6ada7f4ae612..57aeaf7ff6cf0253ca4c04bd00fff23a72011982 100644 (file)
@@ -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);
                 }
index 93ad5556968a6eb0b62ec56b3756b0804b697b4b..b2e662361ce1671b0685cc611885f48b2ed2676a 100644 (file)
@@ -1,3 +1,18 @@
+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
index 5afbb312b256bae4d0faa3bd175efca4190e87fd..31c13b1b02bcc105fbe75a5234d2f3935d212472 100644 (file)
@@ -1,3 +1,17 @@
+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.
index 6512b3802f255a6f659b70c330fc30894af9e458..ec1b0af3f3b8edde132832cb2b23200a1b1ac0d7 100644 (file)
@@ -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)))