[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

pfeldman at chromium.org pfeldman at chromium.org
Thu Apr 8 00:28:21 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 8107938bb8cb55426eb87c207b48fd931d8a06d6
Author: pfeldman at chromium.org <pfeldman at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Dec 8 22:43:45 2009 +0000

    2009-12-08  Pavel Feldman  <pfeldman at chromium.org>
    
            Reviewed by Darin Fisher.
    
            Chromium: support custom WebCore context menu items in Chromium port.
    
            https://bugs.webkit.org/show_bug.cgi?id=32277
    
    WebCore:
            * platform/ContextMenu.h:
            * platform/ContextMenuItem.h:
            (WebCore::PlatformMenuItemDescription::PlatformMenuItemDescription):
            * platform/chromium/ContextMenuChromium.cpp:
            (WebCore::ContextMenu::ContextMenu):
            (WebCore::ContextMenu::itemCount):
            (WebCore::ContextMenu::insertItem):
            (WebCore::ContextMenu::appendItem):
            (WebCore::ContextMenu::itemWithAction):
            (WebCore::ContextMenu::itemAtIndex):
            (WebCore::ContextMenu::platformDescription):
            * platform/chromium/ContextMenuItemChromium.cpp:
            (WebCore::ContextMenuItem::ContextMenuItem):
            (WebCore::ContextMenuItem::releasePlatformDescription):
            (WebCore::ContextMenuItem::type):
            (WebCore::ContextMenuItem::action):
            (WebCore::ContextMenuItem::title):
            (WebCore::ContextMenuItem::checked):
            (WebCore::ContextMenuItem::enabled):
            (WebCore::ContextMenuItem::setType):
            (WebCore::ContextMenuItem::setAction):
            (WebCore::ContextMenuItem::setTitle):
            (WebCore::ContextMenuItem::setChecked):
            (WebCore::ContextMenuItem::setEnabled):
    
    WebKit/chromium:
            * public/WebContextMenuData.h:
            * public/WebPopupMenuInfo.h:
            (WebKit::WebPopupMenuInfo::Item::):
            * public/WebView.h:
            * src/ContextMenuClientImpl.cpp:
            (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems):
            * src/WebViewImpl.cpp:
            (WebKit::WebViewImpl::executeCustomContextMenuAction):
            * src/WebViewImpl.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51874 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index f193742..b5ff23e 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,36 @@
+2009-12-08  Pavel Feldman  <pfeldman at chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        Chromium: support custom WebCore context menu items in Chromium port.
+
+        https://bugs.webkit.org/show_bug.cgi?id=32277
+
+        * platform/ContextMenu.h:
+        * platform/ContextMenuItem.h:
+        (WebCore::PlatformMenuItemDescription::PlatformMenuItemDescription):
+        * platform/chromium/ContextMenuChromium.cpp:
+        (WebCore::ContextMenu::ContextMenu):
+        (WebCore::ContextMenu::itemCount):
+        (WebCore::ContextMenu::insertItem):
+        (WebCore::ContextMenu::appendItem):
+        (WebCore::ContextMenu::itemWithAction):
+        (WebCore::ContextMenu::itemAtIndex):
+        (WebCore::ContextMenu::platformDescription):
+        * platform/chromium/ContextMenuItemChromium.cpp:
+        (WebCore::ContextMenuItem::ContextMenuItem):
+        (WebCore::ContextMenuItem::releasePlatformDescription):
+        (WebCore::ContextMenuItem::type):
+        (WebCore::ContextMenuItem::action):
+        (WebCore::ContextMenuItem::title):
+        (WebCore::ContextMenuItem::checked):
+        (WebCore::ContextMenuItem::enabled):
+        (WebCore::ContextMenuItem::setType):
+        (WebCore::ContextMenuItem::setAction):
+        (WebCore::ContextMenuItem::setTitle):
+        (WebCore::ContextMenuItem::setChecked):
+        (WebCore::ContextMenuItem::setEnabled):
+
 2009-12-08  Adam Langley  <agl at google.com>
 
         Reviewed by Dimitri Glazkov.
diff --git a/WebCore/platform/ContextMenu.h b/WebCore/platform/ContextMenu.h
index dc484b2..77843dc 100644
--- a/WebCore/platform/ContextMenu.h
+++ b/WebCore/platform/ContextMenu.h
@@ -78,6 +78,8 @@ namespace WebCore {
         RetainPtr<NSMutableArray> m_platformDescription;
 #elif PLATFORM(QT)
         QList<ContextMenuItem> m_items;
+#elif PLATFORM(CHROMIUM)
+        Vector<ContextMenuItem> m_items;
 #else
         PlatformMenuDescription m_platformDescription;
 #endif
diff --git a/WebCore/platform/ContextMenuItem.h b/WebCore/platform/ContextMenuItem.h
index d428547..88ff0ad 100644
--- a/WebCore/platform/ContextMenuItem.h
+++ b/WebCore/platform/ContextMenuItem.h
@@ -209,6 +209,19 @@ namespace WebCore {
     };
 #elif PLATFORM(HAIKU)
     typedef BMenuItem* PlatformMenuItemDescription;
+#elif PLATFORM(CHROMIUM)
+    struct PlatformMenuItemDescription {
+        PlatformMenuItemDescription()
+            : type(ActionType)
+            , action(ContextMenuItemTagNoAction)
+            , checked(false)
+            , enabled(true) { }
+        ContextMenuItemType type;
+        ContextMenuAction action;
+        String title;
+        bool checked;
+        bool enabled;
+    };
 #else
     typedef void* PlatformMenuItemDescription;
 #endif
@@ -238,7 +251,8 @@ namespace WebCore {
         void setSubMenu(ContextMenu*);
 
         void setChecked(bool = true);
-        
+        bool checked() const;
+
         void setEnabled(bool = true);
         bool enabled() const;
 
diff --git a/WebCore/platform/chromium/ContextMenuChromium.cpp b/WebCore/platform/chromium/ContextMenuChromium.cpp
index 0614e3e..93c0ec4 100644
--- a/WebCore/platform/chromium/ContextMenuChromium.cpp
+++ b/WebCore/platform/chromium/ContextMenuChromium.cpp
@@ -38,13 +38,11 @@ namespace WebCore {
 
 ContextMenu::ContextMenu(const HitTestResult& result)
     : m_hitTestResult(result)
-    , m_platformDescription(0)
 {
 }
 
 ContextMenu::ContextMenu(const HitTestResult& result, const PlatformMenuDescription menu)
     : m_hitTestResult(result)
-    , m_platformDescription(0)
 {
 }
 
@@ -54,25 +52,31 @@ ContextMenu::~ContextMenu()
 
 unsigned ContextMenu::itemCount() const
 {
-    return 0;
+    return m_items.size();
 }
 
 void ContextMenu::insertItem(unsigned position, ContextMenuItem& item)
 {
+    m_items.insert(position, item);
 }
 
 void ContextMenu::appendItem(ContextMenuItem& item)
 {
+    m_items.append(item);
 }
 
 ContextMenuItem* ContextMenu::itemWithAction(unsigned action)
 {
+    for (size_t i = 0; i < m_items.size(); ++i) {
+        if (m_items[i].action() == static_cast<ContextMenuAction>(action))
+            return &m_items[i];
+    }
     return 0;
 }
 
 ContextMenuItem* ContextMenu::itemAtIndex(unsigned index, const PlatformMenuDescription platformDescription)
 {
-    return 0;
+    return &m_items[index];
 }
 
 void ContextMenu::setPlatformDescription(PlatformMenuDescription menu)
@@ -81,7 +85,7 @@ void ContextMenu::setPlatformDescription(PlatformMenuDescription menu)
 
 PlatformMenuDescription ContextMenu::platformDescription() const
 {
-    return m_platformDescription;
+    return 0;
 }
 
 PlatformMenuDescription ContextMenu::releasePlatformDescription()
diff --git a/WebCore/platform/chromium/ContextMenuItemChromium.cpp b/WebCore/platform/chromium/ContextMenuItemChromium.cpp
index f34ea23..6a0d657 100644
--- a/WebCore/platform/chromium/ContextMenuItemChromium.cpp
+++ b/WebCore/platform/chromium/ContextMenuItemChromium.cpp
@@ -46,6 +46,9 @@ ContextMenuItem::ContextMenuItem(ContextMenu* subMenu)
 
 ContextMenuItem::ContextMenuItem(ContextMenuItemType type, ContextMenuAction action, const String& title, ContextMenu* subMenu)
 {
+    m_platformDescription.type = type;
+    m_platformDescription.action = action;
+    m_platformDescription.title = title;
 }
 
 ContextMenuItem::~ContextMenuItem()
@@ -54,22 +57,32 @@ ContextMenuItem::~ContextMenuItem()
 
 PlatformMenuItemDescription ContextMenuItem::releasePlatformDescription()
 {
-    return PlatformMenuItemDescription();
+    return m_platformDescription;
 }
 
 ContextMenuItemType ContextMenuItem::type() const
 {
-    return ContextMenuItemType();
+    return m_platformDescription.type;
 }
 
 ContextMenuAction ContextMenuItem::action() const
 { 
-    return ContextMenuAction();
+    return m_platformDescription.action;
 }
 
 String ContextMenuItem::title() const 
 {
-    return String();
+    return m_platformDescription.title;
+}
+
+bool ContextMenuItem::checked() const
+{
+    return m_platformDescription.checked;
+}
+
+bool ContextMenuItem::enabled() const
+{
+    return m_platformDescription.enabled;
 }
 
 PlatformMenuDescription ContextMenuItem::platformSubMenu() const
@@ -79,14 +92,17 @@ PlatformMenuDescription ContextMenuItem::platformSubMenu() const
 
 void ContextMenuItem::setType(ContextMenuItemType type)
 {
+    m_platformDescription.type = type;
 }
 
 void ContextMenuItem::setAction(ContextMenuAction action)
 {
+    m_platformDescription.action = action;
 }
 
 void ContextMenuItem::setTitle(const String& title)
 {
+    m_platformDescription.title = title;
 }
 
 void ContextMenuItem::setSubMenu(ContextMenu* subMenu)
@@ -95,15 +111,12 @@ void ContextMenuItem::setSubMenu(ContextMenu* subMenu)
 
 void ContextMenuItem::setChecked(bool checked)
 {
+    m_platformDescription.checked = checked;
 }
 
 void ContextMenuItem::setEnabled(bool enabled)
 {
-}
-
-bool ContextMenuItem::enabled() const
-{
-    return false;
+    m_platformDescription.enabled = enabled;
 }
 
 } // namespace WebCore
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 41c9b85..af02ddd 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,21 @@
+2009-12-08  Pavel Feldman  <pfeldman at chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        Chromium: support custom WebCore context menu items in Chromium port.
+
+        https://bugs.webkit.org/show_bug.cgi?id=32277
+
+        * public/WebContextMenuData.h:
+        * public/WebPopupMenuInfo.h:
+        (WebKit::WebPopupMenuInfo::Item::):
+        * public/WebView.h:
+        * src/ContextMenuClientImpl.cpp:
+        (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::executeCustomContextMenuAction):
+        * src/WebViewImpl.h:
+
 2009-12-08  Albert J. Wong  <ajwong at chromium.org>
 
         Not reviewed: Chromium build fix.
diff --git a/WebKit/chromium/WebKit.gyp b/WebKit/chromium/WebKit.gyp
index 7c0d913..f044279 100644
--- a/WebKit/chromium/WebKit.gyp
+++ b/WebKit/chromium/WebKit.gyp
@@ -131,6 +131,7 @@
                 'public/WebMediaPlayer.h',
                 'public/WebMediaPlayerAction.h',
                 'public/WebMediaPlayerClient.h',
+                'public/WebMenuItemInfo.h',
                 'public/WebMessagePortChannel.h',
                 'public/WebMessagePortChannelClient.h',
                 'public/WebMimeRegistry.h',
diff --git a/WebKit/chromium/public/WebContextMenuData.h b/WebKit/chromium/public/WebContextMenuData.h
index 11f23ba..b4acb1c 100644
--- a/WebKit/chromium/public/WebContextMenuData.h
+++ b/WebKit/chromium/public/WebContextMenuData.h
@@ -31,9 +31,11 @@
 #ifndef WebContextMenuData_h
 #define WebContextMenuData_h
 
+#include "WebMenuItemInfo.h"
 #include "WebPoint.h"
 #include "WebString.h"
 #include "WebURL.h"
+#include "WebVector.h"
 
 namespace WebKit {
 
@@ -111,6 +113,9 @@ struct WebContextMenuData {
 
     // Security information for the context.
     WebCString securityInfo;
+
+    // Custom context menu items provided by the WebCore internals.
+    WebVector<WebMenuItemInfo> customItems;
 };
 
 } // namespace WebKit
diff --git a/WebKit/chromium/public/WebMenuItemInfo.h b/WebKit/chromium/public/WebMenuItemInfo.h
new file mode 100644
index 0000000..d513e66
--- /dev/null
+++ b/WebKit/chromium/public/WebMenuItemInfo.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebMenuItemInfo_h
+#define WebMenuItemInfo_h
+
+#include "WebCommon.h"
+#include "WebString.h"
+#include "WebVector.h"
+
+namespace WebKit {
+
+struct WebMenuItemInfo {
+    enum Type {
+        Option,
+        CheckableOption,
+        Group,
+        Separator,
+    };
+    WebString label;
+    Type type;
+    unsigned action;
+    bool enabled;
+    bool checked;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/public/WebPopupMenuInfo.h b/WebKit/chromium/public/WebPopupMenuInfo.h
index 107cfa9..876842d 100644
--- a/WebKit/chromium/public/WebPopupMenuInfo.h
+++ b/WebKit/chromium/public/WebPopupMenuInfo.h
@@ -31,29 +31,18 @@
 #ifndef WebPopupMenuInfo_h
 #define WebPopupMenuInfo_h
 
-#include "WebCommon.h"
-#include "WebRect.h"
-#include "WebString.h"
+#include "WebMenuItemInfo.h"
 #include "WebVector.h"
 
 namespace WebKit {
 
 // Describes the contents of a popup menu.
 struct WebPopupMenuInfo {
-    struct Item {
-        enum Type {
-            Option,
-            Group,
-            Separator,
-        };
-        WebString label;
-        Type type;
-        bool enabled;
-    };
-
+    // FIXME: migrate clients to WebMenuItemInfo and remove this temporary Item typedef.
+    typedef WebMenuItemInfo Item;
     int itemHeight;
     int selectedIndex;
-    WebVector<Item> items;
+    WebVector<WebMenuItemInfo> items;
 };
 
 } // namespace WebKit
diff --git a/WebKit/chromium/public/WebView.h b/WebKit/chromium/public/WebView.h
index d239ef1..5e1f15d 100644
--- a/WebKit/chromium/public/WebView.h
+++ b/WebKit/chromium/public/WebView.h
@@ -235,6 +235,11 @@ public:
     virtual void hideAutofillPopup() = 0;
 
 
+    // Context menu --------------------------------------------------------
+
+    virtual void performCustomContextMenuAction(unsigned action) = 0;
+
+
     // Visited link state --------------------------------------------------
 
     // Tells all WebView instances to update the visited link state for the
@@ -245,6 +250,7 @@ public:
     // their links.
     WEBKIT_API static void resetVisitedLinkState();
 
+
     // Scrollbar colors ----------------------------------------------------
     virtual void setScrollbarColors(unsigned inactiveColor,
                                     unsigned activeColor,
diff --git a/WebKit/chromium/src/ContextMenuClientImpl.cpp b/WebKit/chromium/src/ContextMenuClientImpl.cpp
index f32c72f..f23919e 100644
--- a/WebKit/chromium/src/ContextMenuClientImpl.cpp
+++ b/WebKit/chromium/src/ContextMenuClientImpl.cpp
@@ -50,10 +50,12 @@
 #include "WebContextMenuData.h"
 #include "WebDataSourceImpl.h"
 #include "WebFrameImpl.h"
+#include "WebMenuItemInfo.h"
 #include "WebPoint.h"
 #include "WebString.h"
 #include "WebURL.h"
 #include "WebURLResponse.h"
+#include "WebVector.h"
 #include "WebViewClient.h"
 #include "WebViewImpl.h"
 
@@ -228,6 +230,9 @@ PlatformMenuDescription ContextMenuClientImpl::getCustomMenuFromDefaultItems(
     // We can always select all...
     data.editFlags |= WebContextMenuData::CanSelectAll;
 
+    // Filter out custom menu elements and add them into the data.
+    populateCustomMenuItems(defaultMenu, &data);
+
     WebFrame* selected_web_frame = WebFrameImpl::fromFrame(selectedFrame);
     if (m_webView->client())
         m_webView->client()->showContextMenu(selected_web_frame, data);
@@ -235,4 +240,40 @@ PlatformMenuDescription ContextMenuClientImpl::getCustomMenuFromDefaultItems(
     return 0;
 }
 
+void ContextMenuClientImpl::populateCustomMenuItems(WebCore::ContextMenu* defaultMenu, WebContextMenuData* data)
+{
+    Vector<WebMenuItemInfo> customItems;
+    for (size_t i = 0; i < defaultMenu->itemCount(); ++i) {
+        ContextMenuItem* inputItem = defaultMenu->itemAtIndex(i, defaultMenu->platformDescription());
+        if (inputItem->action() < ContextMenuItemBaseCustomTag || inputItem->action() >=  ContextMenuItemBaseApplicationTag)
+            continue;
+
+        WebMenuItemInfo outputItem;
+        outputItem.label = inputItem->title();
+        outputItem.enabled = inputItem->enabled();
+        outputItem.checked = inputItem->checked();
+        outputItem.action = static_cast<unsigned>(inputItem->action() - ContextMenuItemBaseCustomTag);
+        switch (inputItem->type()) {
+        case ActionType:
+            outputItem.type = WebMenuItemInfo::Option;
+            break;
+        case CheckableActionType:
+            outputItem.type = WebMenuItemInfo::CheckableOption;
+            break;
+        case SeparatorType:
+            outputItem.type = WebMenuItemInfo::Separator;
+            break;
+        case SubmenuType:
+            outputItem.type = WebMenuItemInfo::Group;
+            break;
+        }
+        customItems.append(outputItem);
+    }
+
+    WebVector<WebMenuItemInfo> outputItems(customItems.size());
+    for (size_t i = 0; i < customItems.size(); ++i)
+        outputItems[i] = customItems[i];
+    data->customItems.swap(outputItems);
+}
+
 } // namespace WebKit
diff --git a/WebKit/chromium/src/ContextMenuClientImpl.h b/WebKit/chromium/src/ContextMenuClientImpl.h
index 8b5bab6..a499d8b 100644
--- a/WebKit/chromium/src/ContextMenuClientImpl.h
+++ b/WebKit/chromium/src/ContextMenuClientImpl.h
@@ -35,6 +35,7 @@
 
 namespace WebKit {
 
+class WebContextMenuData;
 class WebViewImpl;
 
 class ContextMenuClientImpl : public  WebCore::ContextMenuClient {
@@ -53,6 +54,7 @@ public:
     virtual void speak(const WebCore::String&) {}
     virtual void stopSpeaking() {}
 private:
+    void populateCustomMenuItems(WebCore::ContextMenu*, WebContextMenuData*);
     WebViewImpl* m_webView;
 };
 
diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp
index 1612b6a..8ec8c0b 100644
--- a/WebKit/chromium/src/WebViewImpl.cpp
+++ b/WebKit/chromium/src/WebViewImpl.cpp
@@ -33,6 +33,9 @@
 
 #include "AutocompletePopupMenuClient.h"
 #include "AXObjectCache.h"
+#include "ContextMenu.h"
+#include "ContextMenuController.h"
+#include "ContextMenuItem.h"
 #include "CSSStyleSelector.h"
 #include "CSSValueKeywords.h"
 #include "Cursor.h"
@@ -1586,6 +1589,19 @@ void WebViewImpl::hideAutofillPopup()
     hideAutoCompletePopup();
 }
 
+void WebViewImpl::performCustomContextMenuAction(unsigned action)
+{
+    if (!m_page)
+        return;
+    ContextMenu* menu = m_page->contextMenuController()->contextMenu();
+    if (!menu)
+        return;
+    ContextMenuItem* item = menu->itemWithAction(static_cast<ContextMenuAction>(ContextMenuItemBaseCustomTag + action));
+    if (item)
+        m_page->contextMenuController()->contextMenuItemSelected(item);
+    m_page->contextMenuController()->clearContextMenu();
+}
+
 // WebView --------------------------------------------------------------------
 
 bool WebViewImpl::setDropEffect(bool accept)
diff --git a/WebKit/chromium/src/WebViewImpl.h b/WebKit/chromium/src/WebViewImpl.h
index 3bec50d..dd5191e 100644
--- a/WebKit/chromium/src/WebViewImpl.h
+++ b/WebKit/chromium/src/WebViewImpl.h
@@ -157,6 +157,7 @@ public:
     virtual void setScrollbarColors(unsigned inactiveColor,
                                     unsigned activeColor,
                                     unsigned trackColor);
+    virtual void performCustomContextMenuAction(unsigned action);
 
     // WebViewImpl
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list