[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

weinig at apple.com weinig at apple.com
Wed Dec 22 14:41:30 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 334a7a34479c04065cef80bb79b8311d95cd3a2e
Author: weinig at apple.com <weinig at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Oct 16 00:47:12 2010 +0000

    Popup widget support (<select>)
    <rdar://problem/8147746>
    https://bugs.webkit.org/show_bug.cgi?id=47740
    
    Reviewed by Anders Carlsson.
    
    Add initial support for popup menus. Only works on the mac at this time.
    
    * Shared/WebPopupItem.cpp: Added.
    (WebKit::WebPopupItem::WebPopupItem):
    (WebKit::WebPopupItem::encode):
    (WebKit::WebPopupItem::decode):
    * Shared/WebPopupItem.h: Added.
    Serializable representation of a menu item.
    
    * UIProcess/API/mac/PageClientImpl.h:
    * UIProcess/API/mac/PageClientImpl.mm:
    (WebKit::PageClientImpl::createPopupMenuProxy):
    Create a WebPopupMenuProxyMac.
    
    * UIProcess/API/qt/qwkpage.cpp:
    (WebView::createPopupMenuProxy):
    * UIProcess/API/qt/qwkpage_p.h:
    Create a WebPopupMenuProxyQt (which is just a stub right now).
    
    (WebKit::WebPopupMenuProxyWin::create):
    * UIProcess/win/WebView.cpp:
    (WebKit::WebView::createPopupMenuProxy):
    * UIProcess/win/WebView.h:
    Create a WebPopupMenuProxyWin (which is just a stub right now).
    
    * UIProcess/PageClient.h:
    Add new client function to get a platform specific WebPopupMenuProxy.
    
    * UIProcess/WebPageProxy.cpp:
    (WebKit::WebPageProxy::close):
    (WebKit::WebPageProxy::showPopupMenu):
    (WebKit::WebPageProxy::hidePopupMenu):
    (WebKit::WebPageProxy::processDidExit):
    * UIProcess/WebPageProxy.h:
    * UIProcess/WebPageProxy.messages.in:
    Pipe through calls to set up the menu.
    
    * UIProcess/mac/WebPopupMenuProxyMac.h: Added.
    (WebKit::WebPopupMenuProxyMac::create):
    * UIProcess/mac/WebPopupMenuProxyMac.mm: Added.
    (WebKit::WebPopupMenuProxyMac::WebPopupMenuProxyMac):
    (WebKit::WebPopupMenuProxyMac::~WebPopupMenuProxyMac):
    (WebKit::WebPopupMenuProxyMac::populate):
    (WebKit::WebPopupMenuProxyMac::showPopupMenu):
    (WebKit::WebPopupMenuProxyMac::hidePopupMenu):
    Add UI process side implementation. Currently this does not support
    custom fonts as the old implementation did.
    
    * UIProcess/qt/WebPopupMenuProxyQt.cpp: Added.
    (WebKit::WebPopupMenuProxyQt::WebPopupMenuProxyQt):
    (WebKit::WebPopupMenuProxyQt::~WebPopupMenuProxyQt):
    (WebKit::WebPopupMenuProxyQt::showPopupMenu):
    (WebKit::WebPopupMenuProxyQt::hidePopupMenu):
    * UIProcess/qt/WebPopupMenuProxyQt.h: Added.
    (WebKit::WebPopupMenuProxyQt::create):
    * UIProcess/win/WebPopupMenuProxyWin.cpp: Added.
    (WebKit::WebPopupMenuProxyWin::WebPopupMenuProxyWin):
    (WebKit::WebPopupMenuProxyWin::~WebPopupMenuProxyWin):
    (WebKit::WebPopupMenuProxyWin::showPopupMenu):
    (WebKit::WebPopupMenuProxyWin::hidePopupMenu):
    * UIProcess/win/WebPopupMenuProxyWin.h: Added.
    Add stubbed out implementations for Qt and windows.
    
    * WebProcess/WebCoreSupport/WebChromeClient.cpp:
    (WebKit::WebChromeClient::createPopupMenu):
    (WebKit::WebChromeClient::createSearchPopupMenu):
    Pass the page in the create function.
    
    * WebProcess/WebCoreSupport/WebPopupMenu.cpp:
    (WebKit::WebPopupMenu::create):
    (WebKit::WebPopupMenu::WebPopupMenu):
    (WebKit::WebPopupMenu::didChangeSelectedIndex):
    (WebKit::WebPopupMenu::populateItems):
    (WebKit::WebPopupMenu::show):
    (WebKit::WebPopupMenu::hide):
    * WebProcess/WebCoreSupport/WebPopupMenu.h:
    (WebKit::WebPopupMenu::disconnectFromPage):
    * WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp:
    (WebKit::WebSearchPopupMenu::create):
    (WebKit::WebSearchPopupMenu::WebSearchPopupMenu):
    (WebKit::WebSearchPopupMenu::popupMenu):
    * WebProcess/WebCoreSupport/WebSearchPopupMenu.h:
    * WebProcess/WebPage/WebPage.cpp:
    (WebKit::WebPage::close):
    (WebKit::WebPage::setActivePopupMenu):
    (WebKit::WebPage::didChangeSelectedIndexForActivePopupMenu):
    * WebProcess/WebPage/WebPage.h:
    * WebProcess/WebPage/WebPage.messages.in:
    Pipe through calls to set up the menu.
    
    * WebKit2.pro:
    * WebKit2.xcodeproj/project.pbxproj:
    * win/WebKit2.vcproj:
    Add new files.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69899 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 12d6776..1eb76cc 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,106 @@
+2010-10-15  Sam Weinig  <sam at webkit.org>
+
+        Reviewed by Anders Carlsson.
+
+        Popup widget support (<select>)
+        <rdar://problem/8147746>
+        https://bugs.webkit.org/show_bug.cgi?id=47740
+
+        Add initial support for popup menus. Only works on the mac at this time.
+
+        * Shared/WebPopupItem.cpp: Added.
+        (WebKit::WebPopupItem::WebPopupItem):
+        (WebKit::WebPopupItem::encode):
+        (WebKit::WebPopupItem::decode):
+        * Shared/WebPopupItem.h: Added.
+        Serializable representation of a menu item.
+
+        * UIProcess/API/mac/PageClientImpl.h:
+        * UIProcess/API/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::createPopupMenuProxy):
+        Create a WebPopupMenuProxyMac.
+
+        * UIProcess/API/qt/qwkpage.cpp:
+        (WebView::createPopupMenuProxy):
+        * UIProcess/API/qt/qwkpage_p.h:
+        Create a WebPopupMenuProxyQt (which is just a stub right now).
+
+        (WebKit::WebPopupMenuProxyWin::create):
+        * UIProcess/win/WebView.cpp:
+        (WebKit::WebView::createPopupMenuProxy):
+        * UIProcess/win/WebView.h:
+        Create a WebPopupMenuProxyWin (which is just a stub right now).
+
+        * UIProcess/PageClient.h:
+        Add new client function to get a platform specific WebPopupMenuProxy.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::close):
+        (WebKit::WebPageProxy::showPopupMenu):
+        (WebKit::WebPageProxy::hidePopupMenu):
+        (WebKit::WebPageProxy::processDidExit):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        Pipe through calls to set up the menu.
+
+        * UIProcess/mac/WebPopupMenuProxyMac.h: Added.
+        (WebKit::WebPopupMenuProxyMac::create):
+        * UIProcess/mac/WebPopupMenuProxyMac.mm: Added.
+        (WebKit::WebPopupMenuProxyMac::WebPopupMenuProxyMac):
+        (WebKit::WebPopupMenuProxyMac::~WebPopupMenuProxyMac):
+        (WebKit::WebPopupMenuProxyMac::populate):
+        (WebKit::WebPopupMenuProxyMac::showPopupMenu):
+        (WebKit::WebPopupMenuProxyMac::hidePopupMenu):
+        Add UI process side implementation. Currently this does not support
+        custom fonts as the old implementation did.
+
+        * UIProcess/qt/WebPopupMenuProxyQt.cpp: Added.
+        (WebKit::WebPopupMenuProxyQt::WebPopupMenuProxyQt):
+        (WebKit::WebPopupMenuProxyQt::~WebPopupMenuProxyQt):
+        (WebKit::WebPopupMenuProxyQt::showPopupMenu):
+        (WebKit::WebPopupMenuProxyQt::hidePopupMenu):
+        * UIProcess/qt/WebPopupMenuProxyQt.h: Added.
+        (WebKit::WebPopupMenuProxyQt::create):
+        * UIProcess/win/WebPopupMenuProxyWin.cpp: Added.
+        (WebKit::WebPopupMenuProxyWin::WebPopupMenuProxyWin):
+        (WebKit::WebPopupMenuProxyWin::~WebPopupMenuProxyWin):
+        (WebKit::WebPopupMenuProxyWin::showPopupMenu):
+        (WebKit::WebPopupMenuProxyWin::hidePopupMenu):
+        * UIProcess/win/WebPopupMenuProxyWin.h: Added.
+        Add stubbed out implementations for Qt and windows.
+
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::createPopupMenu):
+        (WebKit::WebChromeClient::createSearchPopupMenu):
+        Pass the page in the create function.
+
+        * WebProcess/WebCoreSupport/WebPopupMenu.cpp:
+        (WebKit::WebPopupMenu::create):
+        (WebKit::WebPopupMenu::WebPopupMenu):
+        (WebKit::WebPopupMenu::didChangeSelectedIndex):
+        (WebKit::WebPopupMenu::populateItems):
+        (WebKit::WebPopupMenu::show):
+        (WebKit::WebPopupMenu::hide):
+        * WebProcess/WebCoreSupport/WebPopupMenu.h:
+        (WebKit::WebPopupMenu::disconnectFromPage):
+        * WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp:
+        (WebKit::WebSearchPopupMenu::create):
+        (WebKit::WebSearchPopupMenu::WebSearchPopupMenu):
+        (WebKit::WebSearchPopupMenu::popupMenu):
+        * WebProcess/WebCoreSupport/WebSearchPopupMenu.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::close):
+        (WebKit::WebPage::setActivePopupMenu):
+        (WebKit::WebPage::didChangeSelectedIndexForActivePopupMenu):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        Pipe through calls to set up the menu.
+
+        * WebKit2.pro:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * win/WebKit2.vcproj:
+        Add new files.
+
 2010-10-15  Anders Carlsson  <andersca at apple.com>
 
         Fix build.
diff --git a/WebKit2/Shared/WebPopupItem.cpp b/WebKit2/Shared/WebPopupItem.cpp
new file mode 100644
index 0000000..f691cd8
--- /dev/null
+++ b/WebKit2/Shared/WebPopupItem.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+#include "WebPopupItem.h"
+
+#include "ArgumentCoders.h"
+#include "Arguments.h"
+
+namespace WebKit {
+
+WebPopupItem::WebPopupItem()
+    : m_type(Item)
+    , m_isEnabled(true)
+{
+}
+
+WebPopupItem::WebPopupItem(Type type)
+    : m_type(type)
+    , m_isEnabled(true)
+{
+}
+
+WebPopupItem::WebPopupItem(Type type, const String& text, const String& toolTip, const String& accessibilityText, bool isEnabled)
+    : m_type(type)
+    , m_text(text)
+    , m_toolTip(toolTip)
+    , m_accessibilityText(accessibilityText)
+    , m_isEnabled(isEnabled)
+{
+}
+
+void WebPopupItem::encode(CoreIPC::ArgumentEncoder* encoder) const
+{
+    encoder->encode(CoreIPC::In(static_cast<uint32_t>(m_type), m_text, m_toolTip, m_accessibilityText, m_isEnabled));
+}
+
+bool WebPopupItem::decode(CoreIPC::ArgumentDecoder* decoder, WebPopupItem& item)
+{
+    uint32_t type;
+    String text;
+    String toolTip;
+    String accessibilityText;
+    bool isEnabled;
+    if (!decoder->decode(CoreIPC::Out(type, text, toolTip, accessibilityText, isEnabled)))
+        return false;
+
+    item = WebPopupItem(static_cast<Type>(type), text, toolTip, accessibilityText, isEnabled);
+    return true;
+}
+
+} // namespace WebKit
diff --git a/WebKit2/Shared/WebPopupItem.h b/WebKit2/Shared/WebPopupItem.h
new file mode 100644
index 0000000..9448bc0
--- /dev/null
+++ b/WebKit2/Shared/WebPopupItem.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 WebPopupItem_h
+#define WebPopupItem_h
+
+#include <wtf/text/WTFString.h>
+
+namespace CoreIPC {
+    class ArgumentDecoder;
+    class ArgumentEncoder;
+}
+
+namespace WebKit {
+
+struct WebPopupItem {
+    enum Type {
+        Seperator,
+        Item
+    };
+
+    WebPopupItem();
+    WebPopupItem(Type);
+    WebPopupItem(Type, const String& text, const String& toolTip, const String& accessibilityText, bool isEnabled);
+
+    void encode(CoreIPC::ArgumentEncoder*) const;
+    static bool decode(CoreIPC::ArgumentDecoder*, WebPopupItem&);
+
+    Type m_type;
+    String m_text;
+    String m_toolTip;
+    String m_accessibilityText;
+    bool m_isEnabled;
+};
+
+} // namespace WebKit
+
+#endif // WebPopupItem_h
diff --git a/WebKit2/UIProcess/API/mac/PageClientImpl.h b/WebKit2/UIProcess/API/mac/PageClientImpl.h
index 6d37d25..52f3b4b 100644
--- a/WebKit2/UIProcess/API/mac/PageClientImpl.h
+++ b/WebKit2/UIProcess/API/mac/PageClientImpl.h
@@ -55,20 +55,22 @@ private:
     virtual void setCursor(const WebCore::Cursor&);
     virtual void setViewportArguments(const WebCore::ViewportArguments&);
 
-    void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
-    void clearAllEditCommands();
-    void setEditCommandState(const String& commandName, bool isEnabled, int state);
+    virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
+    virtual void clearAllEditCommands();
+    virtual void setEditCommandState(const String& commandName, bool isEnabled, int state);
 
-    WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
-    WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
+    virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
+    virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
 
     virtual void didNotHandleKeyEvent(const NativeWebKeyboardEvent&);
 
+    virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy();
+
     void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut);
 
 #if USE(ACCELERATED_COMPOSITING)
-    void pageDidEnterAcceleratedCompositing();
-    void pageDidLeaveAcceleratedCompositing();
+    virtual void pageDidEnterAcceleratedCompositing();
+    virtual void pageDidLeaveAcceleratedCompositing();
 #endif
 
     WKView* m_wkView;
diff --git a/WebKit2/UIProcess/API/mac/PageClientImpl.mm b/WebKit2/UIProcess/API/mac/PageClientImpl.mm
index c10a4b7..74d7dd1 100644
--- a/WebKit2/UIProcess/API/mac/PageClientImpl.mm
+++ b/WebKit2/UIProcess/API/mac/PageClientImpl.mm
@@ -30,10 +30,12 @@
 #import "WKStringCF.h"
 #import "WKViewInternal.h"
 #import "WebEditCommandProxy.h"
+#import "WebPopupMenuProxyMac.h"
 #import <WebCore/Cursor.h>
 #import <WebCore/FloatRect.h>
 #import <WebCore/FoundationExtras.h>
 #import <wtf/PassOwnPtr.h>
+#import <wtf/text/CString.h>
 #import <wtf/text/WTFString.h>
 
 using namespace WebCore;
@@ -226,6 +228,11 @@ void PageClientImpl::didNotHandleKeyEvent(const NativeWebKeyboardEvent&)
 {
 }
 
+PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy()
+{
+    return WebPopupMenuProxyMac::create(m_wkView);
+}
+
 void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator> findIndicator, bool fadeOut)
 {
     [m_wkView _setFindIndicator:findIndicator fadeOut:fadeOut];
diff --git a/WebKit2/UIProcess/API/qt/qwkpage.cpp b/WebKit2/UIProcess/API/qt/qwkpage.cpp
index dc68ea1..bb27e84 100644
--- a/WebKit2/UIProcess/API/qt/qwkpage.cpp
+++ b/WebKit2/UIProcess/API/qt/qwkpage.cpp
@@ -30,6 +30,7 @@
 #include "WebContext.h"
 #include "WebEventFactoryQt.h"
 #include "WebPlatformStrategies.h"
+#include "WebPopupMenuProxyQt.h"
 #include "WKStringQt.h"
 #include "WKURLQt.h"
 #include "ViewportArguments.h"
@@ -43,7 +44,6 @@
 #include <WebKit2/WKFrame.h>
 #include <WebKit2/WKRetainPtr.h>
 
-
 using namespace WebKit;
 using namespace WebCore;
 
@@ -113,6 +113,11 @@ void QWKPagePrivate::didNotHandleKeyEvent(const NativeWebKeyboardEvent&)
 {
 }
 
+PassRefPtr<WebPopupMenuProxy> WebView::createPopupMenuProxy()
+{
+    return WebPopupMenuProxyQt::create();
+}
+
 void QWKPagePrivate::setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut)
 {
 }
diff --git a/WebKit2/UIProcess/API/qt/qwkpage_p.h b/WebKit2/UIProcess/API/qt/qwkpage_p.h
index da5e5e4..8e7d58f 100644
--- a/WebKit2/UIProcess/API/qt/qwkpage_p.h
+++ b/WebKit2/UIProcess/API/qt/qwkpage_p.h
@@ -59,6 +59,7 @@ public:
     virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
     virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
     virtual void didNotHandleKeyEvent(const WebKit::NativeWebKeyboardEvent&);
+    virtual PassRefPtr<WebKit::WebPopupMenuProxy> createPopupMenuProxy();
 
     virtual void setFindIndicator(PassRefPtr<WebKit::FindIndicator>, bool fadeOut);
 
diff --git a/WebKit2/UIProcess/PageClient.h b/WebKit2/UIProcess/PageClient.h
index 5bf7cc7..c2da296 100644
--- a/WebKit2/UIProcess/PageClient.h
+++ b/WebKit2/UIProcess/PageClient.h
@@ -27,6 +27,7 @@
 #define PageClient_h
 
 #include "WebPageProxy.h"
+#include "WebPopupMenuProxy.h"
 #include <wtf/Forward.h>
 
 namespace WebCore {
@@ -39,6 +40,7 @@ namespace WebKit {
 class FindIndicator;
 class NativeWebKeyboardEvent;
 class WebEditCommandProxy;
+class WebPopupMenuProxy;
 
 class PageClient {
 public:
@@ -62,6 +64,8 @@ public:
 
     virtual void didNotHandleKeyEvent(const NativeWebKeyboardEvent&) = 0;
 
+    virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy() = 0;
+
     virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut) = 0;
 
 #if USE(ACCELERATED_COMPOSITING)
diff --git a/WebKit2/UIProcess/WebPageProxy.cpp b/WebKit2/UIProcess/WebPageProxy.cpp
index 3088145..1b5b861 100644
--- a/WebKit2/UIProcess/WebPageProxy.cpp
+++ b/WebKit2/UIProcess/WebPageProxy.cpp
@@ -46,6 +46,8 @@
 #include "WebPageCreationParameters.h"
 #include "WebPageMessages.h"
 #include "WebPageNamespace.h"
+#include "WebPopupItem.h"
+#include "WebPopupMenuProxy.h"
 #include "WebPreferences.h"
 #include "WebProcessManager.h"
 #include "WebProcessMessages.h"
@@ -210,6 +212,8 @@ void WebPageProxy::close()
     for (size_t i = 0, size = editCommandVector.size(); i < size; ++i)
         editCommandVector[i]->invalidate();
 
+    m_activePopupMenu = 0;
+
     m_estimatedProgress = 0.0;
     
     m_loaderClient.initialize(0);
@@ -968,6 +972,29 @@ void WebPageProxy::setFindIndicator(const FloatRect& selectionRect, const Vector
     m_pageClient->setFindIndicator(findIndicator.release(), fadeOut);
 }
 
+void WebPageProxy::showPopupMenu(const IntRect& rect, const Vector<WebPopupItem>& items, int32_t selectedIndex)
+{
+    if (m_activePopupMenu)
+        m_activePopupMenu->hidePopupMenu();
+    else
+        m_activePopupMenu = m_pageClient->createPopupMenuProxy();
+
+    int32_t newSelectedIndex = 0;
+    m_activePopupMenu->showPopupMenu(rect, items, selectedIndex, newSelectedIndex);
+
+    process()->send(Messages::WebPage::DidChangeSelectedIndexForActivePopupMenu(newSelectedIndex), m_pageID);
+    m_activePopupMenu = 0;
+}
+
+void WebPageProxy::hidePopupMenu()
+{
+    if (!m_activePopupMenu)
+        return;
+
+    m_activePopupMenu->hidePopupMenu();
+    m_activePopupMenu = 0;
+}
+
 void WebPageProxy::registerEditCommand(PassRefPtr<WebEditCommandProxy> commandProxy, UndoOrRedo undoOrRedo)
 {
     m_pageClient->registerEditCommand(commandProxy, undoOrRedo);
@@ -1139,6 +1166,8 @@ void WebPageProxy::processDidExit()
         editCommandVector[i]->invalidate();
     m_pageClient->clearAllEditCommands();
 
+    m_activePopupMenu = 0;
+
     m_estimatedProgress = 0.0;
 
     m_pageClient->processDidExit();
diff --git a/WebKit2/UIProcess/WebPageProxy.h b/WebKit2/UIProcess/WebPageProxy.h
index 43528e2..dc413c1 100644
--- a/WebKit2/UIProcess/WebPageProxy.h
+++ b/WebKit2/UIProcess/WebPageProxy.h
@@ -79,6 +79,8 @@ class WebEditCommandProxy;
 class WebKeyboardEvent;
 class WebMouseEvent;
 class WebPageNamespace;
+class WebPopupItem;
+class WebPopupMenuProxy;
 class WebProcessProxy;
 class WebURLRequest;
 class WebWheelEvent;
@@ -286,6 +288,10 @@ private:
     void didCountStringMatches(const String&, uint32_t numMatches);
     void setFindIndicator(const WebCore::FloatRect& selectionRect, const Vector<WebCore::FloatRect>& textRects, const SharedMemory::Handle& contentImageHandle, bool fadeOut);
 
+    // Popup Menu.
+    void showPopupMenu(const WebCore::IntRect& rect, const Vector<WebPopupItem>& items, int32_t selectedIndex);
+    void hidePopupMenu();
+
     void takeFocus(bool direction);
     void setToolTip(const String&);
     void setCursor(const WebCore::Cursor&);
@@ -321,6 +327,8 @@ private:
 
     HashSet<WebEditCommandProxy*> m_editCommandSet;
 
+    RefPtr<WebPopupMenuProxy> m_activePopupMenu;
+
     double m_estimatedProgress;
 
     // Whether the web page is contained in a top-level window.
diff --git a/WebKit2/UIProcess/WebPageProxy.messages.in b/WebKit2/UIProcess/WebPageProxy.messages.in
index 13b09c5..bed1e5e 100644
--- a/WebKit2/UIProcess/WebPageProxy.messages.in
+++ b/WebKit2/UIProcess/WebPageProxy.messages.in
@@ -95,6 +95,10 @@ messages -> WebPageProxy {
     DidCountStringMatches(WTF::String string, uint32_t numMatches)
     SetFindIndicator(WebCore::FloatRect selectionRect, Vector<WebCore::FloatRect> textRects, WebKit::SharedMemory::Handle contentImageHandle, bool fadeOut)
 
+    # PopupMenu.
+    ShowPopupMenu(WebCore::IntRect rect, Vector<WebKit::WebPopupItem> items, int32_t selectedIndex)
+    HidePopupMenu()
+
 #if USE(ACCELERATED_COMPOSITING)
     # Accelerated compsiting messages.
     DidChangeAcceleratedCompositing(bool compositing) -> (WebKit::DrawingAreaBase::DrawingAreaInfo newDrawingArea)
diff --git a/WebKit2/UIProcess/WebPopupMenuProxy.h b/WebKit2/UIProcess/WebPopupMenuProxy.h
new file mode 100644
index 0000000..da4ab1f
--- /dev/null
+++ b/WebKit2/UIProcess/WebPopupMenuProxy.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 WebPopupMenuProxy_h
+#define WebPopupMenuProxy_h
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+    class IntRect;
+}
+
+namespace WebKit {
+
+class WebPopupItem;
+
+class WebPopupMenuProxy : public RefCounted<WebPopupMenuProxy> {
+public:    
+    virtual ~WebPopupMenuProxy()
+    {
+    }
+
+    virtual void showPopupMenu(const WebCore::IntRect& rect, const Vector<WebPopupItem>& items, int32_t selectedIndex, int32_t& newSelectedIndex) = 0;
+    virtual void hidePopupMenu() = 0;
+
+protected:
+    WebPopupMenuProxy()
+    {
+    }
+};
+
+} // namespace WebKit
+
+#endif // WebPopupMenuProxy_h
diff --git a/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.h b/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.h
new file mode 100644
index 0000000..5723b82
--- /dev/null
+++ b/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 WebPopupMenuProxyMac_h
+#define WebPopupMenuProxyMac_h
+
+#include "WebPopupMenuProxy.h"
+#include <wtf/RetainPtr.h>
+
+#ifdef __OBJC__
+ at class NSPopUpButtonCell;
+ at class WKView;
+#else
+class NSPopUpButtonCell;
+class WKView;
+#endif
+
+namespace WebKit {
+
+class WebPageProxy;
+
+class WebPopupMenuProxyMac : public WebPopupMenuProxy {
+public:
+    static PassRefPtr<WebPopupMenuProxyMac> create(WKView* webView)
+    {
+        return adoptRef(new WebPopupMenuProxyMac(webView));
+    }
+    ~WebPopupMenuProxyMac();
+
+    virtual void showPopupMenu(const WebCore::IntRect&, const Vector<WebPopupItem>&, int32_t selectedIndex, int32_t& newSelectedIndex);
+    virtual void hidePopupMenu();
+
+private:
+    WebPopupMenuProxyMac(WKView*);
+
+    void populate(const Vector<WebPopupItem>&);
+
+    RetainPtr<NSPopUpButtonCell> m_popup;
+    WKView* m_webView;
+};
+
+} // namespace WebKit
+
+#endif // WebPopupMenuProxyMac_h
diff --git a/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm b/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm
new file mode 100644
index 0000000..eb3790f
--- /dev/null
+++ b/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+#include "WebPopupMenuProxyMac.h"
+
+#include "PageClientImpl.h"
+#include "WKView.h"
+#include "WebPopupItem.h"
+#include <WebKitSystemInterface.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebPopupMenuProxyMac::WebPopupMenuProxyMac(WKView* webView)
+    : m_webView(webView)
+{
+}
+
+WebPopupMenuProxyMac::~WebPopupMenuProxyMac()
+{
+    if (m_popup)
+        [m_popup.get() setControlView:nil];
+}
+
+void WebPopupMenuProxyMac::populate(const Vector<WebPopupItem>& items)
+{
+    if (m_popup)
+        [m_popup.get() removeAllItems];
+    else {
+        m_popup.adoptNS([[NSPopUpButtonCell alloc] initTextCell:@"" pullsDown:NO]);
+        [m_popup.get() setUsesItemFromMenu:NO];
+        [m_popup.get() setAutoenablesItems:NO];
+    }
+
+    int size = items.size();
+
+    for (int i = 0; i < size; i++) {
+        if (items[i].m_type == WebPopupItem::Seperator)
+            [[m_popup.get() menu] addItem:[NSMenuItem separatorItem]];
+        else {
+            [m_popup.get() addItemWithTitle:nsStringFromWebCoreString(items[i].m_text)];
+            NSMenuItem* menuItem = [m_popup.get() lastItem];
+            [menuItem setEnabled:items[i].m_isEnabled];
+            [menuItem setToolTip:nsStringFromWebCoreString(items[i].m_toolTip)];
+        }
+    }
+}
+
+void WebPopupMenuProxyMac::showPopupMenu(const IntRect& rect, const Vector<WebPopupItem>& items, int32_t selectedIndex, int32_t& newSelectedIndex)
+{
+    populate(items);
+
+    [m_popup.get() attachPopUpWithFrame:rect inView:m_webView];
+    [m_popup.get() selectItemAtIndex:selectedIndex];
+
+    NSMenu* menu = [m_popup.get() menu];
+
+    // These values were borrowed from AppKit to match their placement of the menu.
+    const int popOverHorizontalAdjust = -10;
+    NSRect titleFrame = [m_popup.get()  titleRectForBounds:rect];
+    if (titleFrame.size.width <= 0 || titleFrame.size.height <= 0)
+        titleFrame = rect;
+    float vertOffset = roundf((NSMaxY(rect) - NSMaxY(titleFrame)) + NSHeight(titleFrame));
+    NSPoint location = NSMakePoint(NSMinX(rect) + popOverHorizontalAdjust, NSMaxY(rect) - vertOffset);
+
+    RetainPtr<NSView> dummyView(AdoptNS, [[NSView alloc] initWithFrame:rect]);
+    [m_webView addSubview:dummyView.get()];
+    location = [dummyView.get() convertPoint:location fromView:m_webView];
+
+    WKPopupMenu(menu, location, roundf(NSWidth(rect)), dummyView.get(), selectedIndex, [NSFont menuFontOfSize:0]);
+
+    [m_popup.get() dismissPopUp];
+    [dummyView.get() removeFromSuperview];
+
+    newSelectedIndex = [m_popup.get() indexOfSelectedItem];
+}
+
+void WebPopupMenuProxyMac::hidePopupMenu()
+{
+    [m_popup.get() dismissPopUp];
+}
+
+
+} // namespace WebKit
diff --git a/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp b/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp
new file mode 100644
index 0000000..a4e963d
--- /dev/null
+++ b/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+#include "WebPopupMenuProxyQt.h"
+
+#include "WebPopupItem.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebPopupMenuProxyQt::WebPopupMenuProxyQt()
+{
+}
+
+WebPopupMenuProxyQt::~WebPopupMenuProxyQt()
+{
+}
+
+void WebPopupMenuProxyQt::showPopupMenu(const IntRect& rect, const Vector<WebPopupItem>& items, int32_t selectedIndex, int32_t& newSelectedIndex)
+{
+}
+
+void WebPopupMenuProxyQt::hidePopupMenu()
+{
+}
+
+} // namespace WebKit
diff --git a/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.h b/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.h
new file mode 100644
index 0000000..2d004bd
--- /dev/null
+++ b/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 WebPopupMenuProxyQt_h
+#define WebPopupMenuProxyQt_h
+
+#include "WebPopupMenuProxy.h"
+
+namespace WebKit {
+
+class WebPopupMenuProxyQt : public WebPopupMenuProxy {
+public:
+    static PassRefPtr<WebPopupMenuProxyQt> create()
+    {
+        return adoptRef(new WebPopupMenuProxyQt());
+    }
+    ~WebPopupMenuProxyQt();
+
+    virtual void showPopupMenu(const WebCore::IntRect&, const Vector<WebPopupItem>&, int32_t selectedIndex, int32_t& newSelectedIndex);
+    virtual void hidePopupMenu();
+
+private:
+    WebPopupMenuProxyQt();
+};
+
+} // namespace WebKit
+
+#endif // WebPopupMenuProxyQt_h
diff --git a/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp b/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp
new file mode 100644
index 0000000..7524b40
--- /dev/null
+++ b/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+#include "WebPopupMenuProxyWin.h"
+
+#include "WebPopupItem.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebPopupMenuProxyWin::WebPopupMenuProxyWin()
+{
+}
+
+WebPopupMenuProxyWin::~WebPopupMenuProxyWin()
+{
+}
+
+void WebPopupMenuProxyWin::showPopupMenu(const IntRect& rect, const Vector<WebPopupItem>& items, int32_t selectedIndex, int32_t& newSelectedIndex)
+{
+}
+
+void WebPopupMenuProxyWin::hidePopupMenu()
+{
+}
+
+} // namespace WebKit
diff --git a/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h b/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h
new file mode 100644
index 0000000..3106aa6
--- /dev/null
+++ b/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 WebPopupMenuProxyWin_h
+#define WebPopupMenuProxyWin_h
+
+#include "WebPopupMenuProxy.h"
+
+namespace WebKit {
+
+class WebPopupMenuProxyWin : public WebPopupMenuProxy {
+public:
+    static PassRefPtr<WebPopupMenuProxyWin> create()
+    {
+        return adoptRef(new WebPopupMenuProxyWin());
+    }
+    ~WebPopupMenuProxyWin();
+
+    virtual void showPopupMenu(const WebCore::IntRect&, const Vector<WebPopupItem>&, int32_t selectedIndex, int32_t& newSelectedIndex);
+    virtual void hidePopupMenu();
+
+private:
+    WebPopupMenuProxyWin();
+};
+
+} // namespace WebKit
+
+#endif // WebPopupMenuProxyWin_h
diff --git a/WebKit2/UIProcess/win/WebView.cpp b/WebKit2/UIProcess/win/WebView.cpp
index 171cf35..52e8be8 100644
--- a/WebKit2/UIProcess/win/WebView.cpp
+++ b/WebKit2/UIProcess/win/WebView.cpp
@@ -33,6 +33,7 @@
 #include "WebEventFactory.h"
 #include "WebPageNamespace.h"
 #include "WebPageProxy.h"
+#include "WebPopupMenuProxyWin.h"
 #include <Commctrl.h>
 #include <WebCore/FloatRect.h>
 #include <WebCore/IntRect.h>
@@ -609,6 +610,11 @@ void WebView::didNotHandleKeyEvent(const NativeWebKeyboardEvent& event)
     ::DefWindowProcW(event.nativeEvent()->hwnd, event.nativeEvent()->message, event.nativeEvent()->wParam, event.nativeEvent()->lParam);
 }
 
+PassRefPtr<WebPopupMenuProxy> WebView::createPopupMenuProxy()
+{
+    return WebPopupMenuProxyWin::create();
+}
+
 void WebView::setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut)
 {
     // FIXME: Implement.
diff --git a/WebKit2/UIProcess/win/WebView.h b/WebKit2/UIProcess/win/WebView.h
index fb0813f..2165e53 100644
--- a/WebKit2/UIProcess/win/WebView.h
+++ b/WebKit2/UIProcess/win/WebView.h
@@ -102,6 +102,7 @@ private:
     virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
     virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
     virtual void didNotHandleKeyEvent(const NativeWebKeyboardEvent&);
+    virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy();
     virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut);
 
 #if USE(ACCELERATED_COMPOSITING)
diff --git a/WebKit2/WebKit2.pro b/WebKit2/WebKit2.pro
index e86a891..f5ade6b 100644
--- a/WebKit2/WebKit2.pro
+++ b/WebKit2/WebKit2.pro
@@ -214,6 +214,7 @@ HEADERS += \
     Shared/WebNavigationDataStore.h \
     Shared/WebNumber.h \
     Shared/WebPageCreationParameters.h \
+    Shared/WebPopupItem.h \
     Shared/WebProcessCreationParameters.h \
     Shared/WebPreferencesStore.h \
     Shared/WebURLRequest.h \
@@ -270,6 +271,7 @@ HEADERS += \
     UIProcess/WebProcessManager.h \
     UIProcess/WebProcessProxy.h \
     UIProcess/WebUIClient.h \
+    UIProcess/qt/WebPopupMenuProxyQt.h \
     WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h \
     WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.h \
     WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h \
@@ -357,6 +359,7 @@ SOURCES += \
     Shared/VisitedLinkTable.cpp \
     Shared/WebEventConversion.cpp \
     Shared/WebPageCreationParameters.cpp \
+    Shared/WebPopupItem.cpp \
     Shared/WebProcessCreationParameters.cpp \
     Shared/WebPreferencesStore.cpp \
     Shared/WebURLRequest.cpp \
@@ -461,6 +464,7 @@ SOURCES += \
     WebProcess/WebProcess.cpp \
     UIProcess/qt/ChunkedUpdateDrawingAreaProxyQt.cpp \
     UIProcess/qt/WebContextQt.cpp \
+    UIProcess/qt/WebPopupMenuProxyQt.cpp \
     WebProcess/qt/WebProcessMainQt.cpp \
     WebProcess/qt/WebProcessQt.cpp \
     $$WEBKIT2_GENERATED_SOURCES
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index 73cb1cc..b51fa36 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -295,7 +295,12 @@
 		BC4BEEAC120A0A5F00FBA0C7 /* InjectedBundleNodeHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC4BEEAA120A0A5F00FBA0C7 /* InjectedBundleNodeHandle.cpp */; };
 		BC4BEFE1120A1A4C00FBA0C7 /* WKBundleNodeHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = BC4BEFDF120A1A4C00FBA0C7 /* WKBundleNodeHandle.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		BC4BEFE2120A1A4C00FBA0C7 /* WKBundleNodeHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC4BEFE0120A1A4C00FBA0C7 /* WKBundleNodeHandle.cpp */; };
+		BC5744EF12638FB3006F0F12 /* WebPopupItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC5744ED12638FB3006F0F12 /* WebPopupItem.cpp */; };
+		BC5744F012638FB3006F0F12 /* WebPopupItem.h in Headers */ = {isa = PBXBuildFile; fileRef = BC5744EE12638FB3006F0F12 /* WebPopupItem.h */; };
 		BC57450C1263B155006F0F12 /* WKBundleNodeHandlePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = BC57450B1263B155006F0F12 /* WKBundleNodeHandlePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		BC574E631267D080006F0F12 /* WebPopupMenuProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = BC574E611267D080006F0F12 /* WebPopupMenuProxy.h */; };
+		BC5750971268F3C6006F0F12 /* WebPopupMenuProxyMac.h in Headers */ = {isa = PBXBuildFile; fileRef = BC5750951268F3C6006F0F12 /* WebPopupMenuProxyMac.h */; };
+		BC5750981268F3C6006F0F12 /* WebPopupMenuProxyMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC5750961268F3C6006F0F12 /* WebPopupMenuProxyMac.mm */; };
 		BC59534210FC04520098F82D /* WebLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = BC59534010FC04520098F82D /* WebLoaderClient.h */; };
 		BC597075116591D000551FCA /* ProcessModel.h in Headers */ = {isa = PBXBuildFile; fileRef = BC597074116591D000551FCA /* ProcessModel.h */; };
 		BC5F7BB41182376C0052C02C /* ChunkedUpdateDrawingArea.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC5F7BB21182376C0052C02C /* ChunkedUpdateDrawingArea.cpp */; };
@@ -772,7 +777,12 @@
 		BC4BEEAA120A0A5F00FBA0C7 /* InjectedBundleNodeHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleNodeHandle.cpp; sourceTree = "<group>"; };
 		BC4BEFDF120A1A4C00FBA0C7 /* WKBundleNodeHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleNodeHandle.h; sourceTree = "<group>"; };
 		BC4BEFE0120A1A4C00FBA0C7 /* WKBundleNodeHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleNodeHandle.cpp; sourceTree = "<group>"; };
+		BC5744ED12638FB3006F0F12 /* WebPopupItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPopupItem.cpp; sourceTree = "<group>"; };
+		BC5744EE12638FB3006F0F12 /* WebPopupItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPopupItem.h; sourceTree = "<group>"; };
 		BC57450B1263B155006F0F12 /* WKBundleNodeHandlePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleNodeHandlePrivate.h; sourceTree = "<group>"; };
+		BC574E611267D080006F0F12 /* WebPopupMenuProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPopupMenuProxy.h; sourceTree = "<group>"; };
+		BC5750951268F3C6006F0F12 /* WebPopupMenuProxyMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPopupMenuProxyMac.h; sourceTree = "<group>"; };
+		BC5750961268F3C6006F0F12 /* WebPopupMenuProxyMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPopupMenuProxyMac.mm; sourceTree = "<group>"; };
 		BC59534010FC04520098F82D /* WebLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebLoaderClient.h; sourceTree = "<group>"; };
 		BC597074116591D000551FCA /* ProcessModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProcessModel.h; sourceTree = "<group>"; };
 		BC5F7BB21182376C0052C02C /* ChunkedUpdateDrawingArea.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ChunkedUpdateDrawingArea.cpp; sourceTree = "<group>"; };
@@ -1190,6 +1200,8 @@
 				BC032DB110F4380F0058C15A /* WebEventConversion.h */,
 				BCF69F981176CED600471A52 /* WebNavigationDataStore.h */,
 				BC33DD671238464600360F3F /* WebNumber.h */,
+				BC5744ED12638FB3006F0F12 /* WebPopupItem.cpp */,
+				BC5744EE12638FB3006F0F12 /* WebPopupItem.h */,
 				C06C6093124C14430001682F /* WebPageCreationParameters.cpp */,
 				C06C6094124C14430001682F /* WebPageCreationParameters.h */,
 				BC306823125A6B9400E71278 /* WebProcessCreationParameters.cpp */,
@@ -1408,6 +1420,7 @@
 				BCBD38FA125BAB9A00D2C29F /* WebPageProxy.messages.in */,
 				BCB9F8AD1124E07700A137E0 /* WebPolicyClient.cpp */,
 				BCB9F8AE1124E07700A137E0 /* WebPolicyClient.h */,
+				BC574E611267D080006F0F12 /* WebPopupMenuProxy.h */,
 				BCD597FE112B57BE00EC8C23 /* WebPreferences.cpp */,
 				BCD597FD112B57BE00EC8C23 /* WebPreferences.h */,
 				BC111B0C112F5E4F00337BAB /* WebProcessManager.cpp */,
@@ -1714,6 +1727,8 @@
 				BC2651F511825EF800243E12 /* ChunkedUpdateDrawingAreaProxyMac.mm */,
 				0F5265BB11DD37860006D33C /* LayerBackedDrawingAreaProxyMac.mm */,
 				1A1C648611F415B700553C19 /* WebContextMac.mm */,
+				BC5750951268F3C6006F0F12 /* WebPopupMenuProxyMac.h */,
+				BC5750961268F3C6006F0F12 /* WebPopupMenuProxyMac.mm */,
 			);
 			path = mac;
 			sourceTree = "<group>";
@@ -2033,12 +2048,15 @@
 				1A3DD202125E5A1F004515E6 /* WebFindClient.h in Headers */,
 				1A3DD206125E5A2F004515E6 /* APIClient.h in Headers */,
 				BCC8B374125FB69000DE46A4 /* WKGeometry.h in Headers */,
+				BC5744F012638FB3006F0F12 /* WebPopupItem.h in Headers */,
 				BC57450C1263B155006F0F12 /* WKBundleNodeHandlePrivate.h in Headers */,
 				1AC41AC71263C88300054E94 /* BinarySemaphore.h in Headers */,
 				1A90C1EE1264FD50003E44D4 /* FindOptions.h in Headers */,
 				1A90C1F41264FD71003E44D4 /* FindController.h in Headers */,
 				1A90C23712650717003E44D4 /* PageOverlay.h in Headers */,
 				1A90C2A312650C60003E44D4 /* FindPageOverlay.h in Headers */,
+				BC574E631267D080006F0F12 /* WebPopupMenuProxy.h in Headers */,
+				BC5750971268F3C6006F0F12 /* WebPopupMenuProxyMac.h in Headers */,
 				1A910071126675C4001842F5 /* FindIndicator.h in Headers */,
 				1A91010A1268C8CA001842F5 /* FindIndicatorWindow.h in Headers */,
 			);
@@ -2342,11 +2360,13 @@
 				51A7F2F5125BF8D4008AEB1D /* Logging.cpp in Sources */,
 				BCBD3914125BB1A800D2C29F /* WebPageProxyMessageReceiver.cpp in Sources */,
 				1A3DD1FD125E59F3004515E6 /* WebFindClient.cpp in Sources */,
+				BC5744EF12638FB3006F0F12 /* WebPopupItem.cpp in Sources */,
 				1AC41AC81263C88300054E94 /* BinarySemaphore.cpp in Sources */,
 				1A90C1F51264FD71003E44D4 /* FindController.cpp in Sources */,
 				1A90C23812650717003E44D4 /* PageOverlay.cpp in Sources */,
 				1A90C2A412650C60003E44D4 /* FindPageOverlay.cpp in Sources */,
 				C01A260112662F2100C9ED55 /* BackingStoreCG.cpp in Sources */,
+				BC5750981268F3C6006F0F12 /* WebPopupMenuProxyMac.mm in Sources */,
 				1A910072126675C4001842F5 /* FindIndicator.cpp in Sources */,
 				1A91010B1268C8CA001842F5 /* FindIndicatorWindow.mm in Sources */,
 			);
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp b/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
index e4ff00c..8810959 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
+++ b/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
@@ -516,12 +516,12 @@ bool WebChromeClient::selectItemWritingDirectionIsNatural()
 
 PassRefPtr<WebCore::PopupMenu> WebChromeClient::createPopupMenu(WebCore::PopupMenuClient* client) const
 {
-    return WebPopupMenu::create(client);
+    return WebPopupMenu::create(m_page, client);
 }
 
 PassRefPtr<WebCore::SearchPopupMenu> WebChromeClient::createSearchPopupMenu(WebCore::PopupMenuClient* client) const
 {
-    return WebSearchPopupMenu::create(client);
+    return WebSearchPopupMenu::create(m_page, client);
 }
 
 PassOwnPtr<HTMLParserQuirks> WebChromeClient::createHTMLParserQuirks()
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.cpp b/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.cpp
index a2c22a2..8a5509a 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.cpp
+++ b/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.cpp
@@ -21,18 +21,25 @@
 
 #include "WebPopupMenu.h"
 
+#include "WebCoreArgumentCoders.h"
+#include "WebPage.h"
+#include "WebPageProxyMessages.h"
+#include "WebProcess.h"
 #include <WebCore/FrameView.h>
 #include <WebCore/PopupMenuClient.h>
 
+using namespace WebCore;
+
 namespace WebKit {
 
-PassRefPtr<WebPopupMenu> WebPopupMenu::create(WebCore::PopupMenuClient* client)
+PassRefPtr<WebPopupMenu> WebPopupMenu::create(WebPage* page, PopupMenuClient* client)
 {
-    return adoptRef(new WebPopupMenu(client));
+    return adoptRef(new WebPopupMenu(page, client));
 }
 
-WebPopupMenu::WebPopupMenu(WebCore::PopupMenuClient* client)
+WebPopupMenu::WebPopupMenu(WebPage* page, PopupMenuClient* client)
     : m_popupClient(client)
+    , m_page(page)
 {
 }
 
@@ -40,19 +47,66 @@ WebPopupMenu::~WebPopupMenu()
 {
 }
 
-
 void WebPopupMenu::disconnectClient()
 {
     m_popupClient = 0;
 }
 
-void WebPopupMenu::show(const WebCore::IntRect& rect, WebCore::FrameView* view, int index)
+void WebPopupMenu::didChangeSelectedIndex(int newIndex)
+{
+    if (!m_popupClient)
+        return;
+
+    m_popupClient->popupDidHide();
+    if (newIndex >= 0)
+        m_popupClient->valueChanged(newIndex);
+}
+
+Vector<WebPopupItem> WebPopupMenu::populateItems()
+{
+    size_t size = m_popupClient->listSize();
+
+    Vector<WebPopupItem> items;
+    items.reserveInitialCapacity(size);
+    
+    for (size_t i = 0; i < size; ++i) {
+        if (m_popupClient->itemIsSeparator(i))
+            items.append(WebPopupItem(WebPopupItem::Seperator));
+        else {
+            // FIXME: Add support for styling the font.
+            // FIXME: Add support for styling the foreground and background colors.
+            // FIXME: Find a way to customize text color when an item is highlighted.
+            items.append(WebPopupItem(WebPopupItem::Item, m_popupClient->itemText(i), m_popupClient->itemToolTip(i), m_popupClient->itemAccessibilityText(i), m_popupClient->itemIsEnabled(i)));
+        }
+    }
+
+    return items;
+}
+
+void WebPopupMenu::show(const IntRect& rect, FrameView* view, int index)
 {
+    // FIXME: We should probably inform the client to also close the menu.
+    Vector<WebPopupItem> items = populateItems();
 
+    if (items.isEmpty() || !m_page) {
+        m_popupClient->popupDidHide();
+        return;
+    }
+
+    m_page->setActivePopupMenu(this);
+
+    // Move to page coordinates
+    IntRect pageCoordinates(view->contentsToWindow(rect.location()), rect.size());
+    WebProcess::shared().connection()->send(Messages::WebPageProxy::ShowPopupMenu(pageCoordinates, items, index), m_page->pageID());
 }
 
 void WebPopupMenu::hide()
 {
+    if (!m_page || !m_popupClient)
+        return;
+
+    WebProcess::shared().connection()->send(Messages::WebPageProxy::HidePopupMenu(), m_page->pageID());
+    m_page->setActivePopupMenu(0);
 }
 
 void WebPopupMenu::updateFromElement()
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.h b/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.h
index e7267be..c2d7480 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.h
+++ b/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.h
@@ -22,8 +22,11 @@
 #ifndef WebPopupMenu_h
 #define WebPopupMenu_h
 
+#include "WebPopupItem.h"
 #include <WebCore/PopupMenu.h>
 #include <wtf/Forward.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/Vector.h>
 
 namespace WebCore {
 class PopupMenuClient;
@@ -31,20 +34,29 @@ class PopupMenuClient;
 
 namespace WebKit {
 
+class WebPage;
+class WebPopupItem;
+
 class WebPopupMenu : public WebCore::PopupMenu {
 public:
-    static PassRefPtr<WebPopupMenu> create(WebCore::PopupMenuClient*);
+    static PassRefPtr<WebPopupMenu> create(WebPage*, WebCore::PopupMenuClient*);
     ~WebPopupMenu();
 
+    void disconnectFromPage() { m_page = 0; }
+    void didChangeSelectedIndex(int newIndex);
+
     virtual void show(const WebCore::IntRect&, WebCore::FrameView*, int index);
     virtual void hide();
     virtual void updateFromElement();
     virtual void disconnectClient();
 
 private:
-    WebPopupMenu(WebCore::PopupMenuClient*);
+    WebPopupMenu(WebPage*, WebCore::PopupMenuClient*);
+
+    Vector<WebPopupItem> populateItems();
 
     WebCore::PopupMenuClient* m_popupClient;
+    WebPage* m_page;
 };
 
 } // namespace WebKit
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp b/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp
index fe622fd..acec5f2 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp
+++ b/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp
@@ -22,19 +22,21 @@
 
 #include "WebSearchPopupMenu.h"
 
+using namespace WebCore;
+
 namespace WebKit {
 
-PassRefPtr<WebSearchPopupMenu> WebSearchPopupMenu::create(WebCore::PopupMenuClient* client)
+PassRefPtr<WebSearchPopupMenu> WebSearchPopupMenu::create(WebPage* page, PopupMenuClient* client)
 {
-    return adoptRef(new WebSearchPopupMenu(client));
+    return adoptRef(new WebSearchPopupMenu(page, client));
 }
 
-WebSearchPopupMenu::WebSearchPopupMenu(WebCore::PopupMenuClient* client)
-    : m_popup(WebPopupMenu::create(client))
+WebSearchPopupMenu::WebSearchPopupMenu(WebPage* page, PopupMenuClient* client)
+    : m_popup(WebPopupMenu::create(page, client))
 {
 }
 
-WebCore::PopupMenu* WebSearchPopupMenu::popupMenu()
+PopupMenu* WebSearchPopupMenu::popupMenu()
 {
     return m_popup.get();
 }
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.h b/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.h
index f6576ad..0221571 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.h
+++ b/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.h
@@ -28,7 +28,7 @@ namespace WebKit {
 
 class WebSearchPopupMenu : public WebCore::SearchPopupMenu {
 public:
-    static PassRefPtr<WebSearchPopupMenu> create(WebCore::PopupMenuClient*);
+    static PassRefPtr<WebSearchPopupMenu> create(WebPage*, WebCore::PopupMenuClient*);
 
     virtual WebCore::PopupMenu* popupMenu();
     virtual void saveRecentSearches(const WTF::AtomicString& name, const Vector<String>& searchItems);
@@ -36,7 +36,7 @@ public:
     virtual bool enabled();
 
 private:
-    WebSearchPopupMenu(WebCore::PopupMenuClient*);
+    WebSearchPopupMenu(WebPage*, WebCore::PopupMenuClient*);
 
     RefPtr<WebPopupMenu> m_popup;
 };
diff --git a/WebKit2/WebProcess/WebPage/WebPage.cpp b/WebKit2/WebProcess/WebPage/WebPage.cpp
index 9e52d48..505c71b 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.cpp
+++ b/WebKit2/WebProcess/WebPage/WebPage.cpp
@@ -48,9 +48,10 @@
 #include "WebInspectorClient.h"
 #include "WebPageCreationParameters.h"
 #include "WebPageProxyMessages.h"
-#include "WebProcessProxyMessageKinds.h"
+#include "WebPopupMenu.h"
 #include "WebPreferencesStore.h"
 #include "WebProcess.h"
+#include "WebProcessProxyMessageKinds.h"
 #include <WebCore/EventHandler.h>
 #include <WebCore/FocusController.h>
 #include <WebCore/Frame.h>
@@ -262,8 +263,12 @@ void WebPage::close()
     if (WebProcess::shared().injectedBundle())
         WebProcess::shared().injectedBundle()->willDestroyPage(this);
 
-    m_mainFrame->coreFrame()->loader()->detachFromParent();
+    if (m_activePopupMenu) {
+        m_activePopupMenu->disconnectFromPage();
+        m_activePopupMenu = 0;
+    }
 
+    m_mainFrame->coreFrame()->loader()->detachFromParent();
     m_page.clear();
 
     WebProcess::shared().removeWebPage(m_pageID);
@@ -777,6 +782,11 @@ void WebPage::didRemoveEditCommand(uint64_t commandID)
     removeWebEditCommand(commandID);
 }
 
+void WebPage::setActivePopupMenu(WebPopupMenu* menu)
+{
+    m_activePopupMenu = menu;
+}
+
 void WebPage::findString(const String& string, uint32_t findDirection, uint32_t findOptions, uint32_t maxNumMatches)
 {
     m_findController.findString(string, static_cast<FindDirection>(findDirection), static_cast<FindOptions>(findOptions), maxNumMatches);
@@ -794,7 +804,17 @@ void WebPage::countStringMatches(const String& string, bool caseInsensitive, uin
 
     WebProcess::shared().connection()->send(Messages::WebPageProxy::DidCountStringMatches(string, numMatches), m_pageID);
 }
-    
+
+void WebPage::didChangeSelectedIndexForActivePopupMenu(int32_t newIndex)
+{
+    if (!m_activePopupMenu)
+        return;
+
+    m_activePopupMenu->didChangeSelectedIndex(newIndex);
+    m_activePopupMenu = 0;
+}
+
+
 #if PLATFORM(MAC)
 void WebPage::addPluginView(PluginView* pluginView)
 {
diff --git a/WebKit2/WebProcess/WebPage/WebPage.h b/WebKit2/WebProcess/WebPage/WebPage.h
index 9be272a..607a17a 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.h
+++ b/WebKit2/WebProcess/WebPage/WebPage.h
@@ -70,6 +70,7 @@ class WebEvent;
 class WebFrame;
 class WebKeyboardEvent;
 class WebMouseEvent;
+class WebPopupMenu;
 class WebWheelEvent;
 #if ENABLE(TOUCH_EVENTS)
 class WebTouchEvent;
@@ -110,6 +111,8 @@ public:
     void removeWebEditCommand(uint64_t);
     bool isInRedo() const { return m_isInRedo; }
 
+    void setActivePopupMenu(WebPopupMenu*);
+
     // -- Called from WebProcess.
     void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
 
@@ -227,6 +230,8 @@ private:
     void hideFindUI();
     void countStringMatches(const String&, bool caseInsensitive, uint32_t maxNumMatches);
 
+    void didChangeSelectedIndexForActivePopupMenu(int32_t newIndex);
+
     OwnPtr<WebCore::Page> m_page;
     RefPtr<WebFrame> m_mainFrame;
 
@@ -263,6 +268,8 @@ private:
     FindController m_findController;
     OwnPtr<PageOverlay> m_pageOverlay;
 
+    RefPtr<WebPopupMenu> m_activePopupMenu;
+
     uint64_t m_pageID;
 };
 
diff --git a/WebKit2/WebProcess/WebPage/WebPage.messages.in b/WebKit2/WebProcess/WebPage/WebPage.messages.in
index 2148f4e..f144cff 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.messages.in
+++ b/WebKit2/WebProcess/WebPage/WebPage.messages.in
@@ -72,7 +72,10 @@ messages -> WebPage {
     FindString(WTF::String string, uint32_t findDirection, uint32_t findOptions, unsigned maxNumMatches)
     HideFindUI()
     CountStringMatches(WTF::String string, bool caseInsensitive, unsigned maxNumMatches)
-    
+
+    # Popup menu.
+    DidChangeSelectedIndexForActivePopupMenu(int32_t newIndex);
+
     SetWindowResizerSize(WebCore::IntSize intersectsView)
 
 #if PLATFORM(MAC)
diff --git a/WebKit2/win/WebKit2.vcproj b/WebKit2/win/WebKit2.vcproj
index d3a5d70..c303ebc 100755
--- a/WebKit2/win/WebKit2.vcproj
+++ b/WebKit2/win/WebKit2.vcproj
@@ -529,6 +529,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\Shared\WebPopupItem.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\Shared\WebPopupItem.h"
+				>
+			</File>
+			<File
 				RelativePath="..\Shared\WebPreferencesStore.cpp"
 				>
 			</File>
@@ -1920,6 +1928,14 @@
 					>
 				</File>
 				<File
+					RelativePath="..\UIProcess\win\WebPopupMenuProxyWin.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\UIProcess\win\WebPopupMenuProxyWin.h"
+					>
+				</File>
+				<File
 					RelativePath="..\UIProcess\win\WebView.cpp"
 					>
 				</File>

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list