summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/renderer_host/render_widget_host.cc21
-rw-r--r--chrome/browser/renderer_host/render_widget_host.h3
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view.h1
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.h2
-rw-r--r--chrome/common/render_messages.h1
-rw-r--r--chrome/common/render_messages_internal.h8
-rw-r--r--chrome/renderer/print_web_view_helper.h5
-rw-r--r--chrome/renderer/render_view.cc10
-rw-r--r--chrome/renderer/render_view.h3
-rw-r--r--chrome/renderer/render_widget.cc33
-rw-r--r--chrome/renderer/render_widget.h17
-rw-r--r--webkit/api/public/WebPopupMenuInfo.h12
-rw-r--r--webkit/glue/chrome_client_impl.cc101
-rw-r--r--webkit/glue/chrome_client_impl.h9
-rw-r--r--webkit/glue/webmenuitem.h33
-rw-r--r--webkit/glue/webmenurunner_mac.h2
-rw-r--r--webkit/glue/webmenurunner_mac.mm2
-rw-r--r--webkit/glue/webview_delegate.h9
-rw-r--r--webkit/glue/webwidget_delegate.h31
-rw-r--r--webkit/glue/webwidget_impl.cc14
-rw-r--r--webkit/glue/webwidget_impl.h5
-rw-r--r--webkit/glue/webworker_impl.cc5
-rw-r--r--webkit/tools/test_shell/mac/test_webview_delegate.mm38
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.h32
-rw-r--r--webkit/tools/test_shell/test_webview_delegate_gtk.cc9
-rw-r--r--webkit/tools/test_shell/test_webview_delegate_win.cc9
-rw-r--r--webkit/webkit.gyp2
27 files changed, 215 insertions, 202 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc
index 6481881..cdadd9e 100644
--- a/chrome/browser/renderer_host/render_widget_host.cc
+++ b/chrome/browser/renderer_host/render_widget_host.cc
@@ -135,7 +135,7 @@ IPC_DEFINE_MESSAGE_MAP(RenderWidgetHost)
IPC_MESSAGE_HANDLER(ViewHostMsg_DestroyPluginContainer,
OnMsgDestroyPluginContainer)
#elif defined(OS_MACOSX)
- IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_ShowPopup, OnMsgShowPopup(msg))
+ IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup)
IPC_MESSAGE_HANDLER(ViewHostMsg_GetScreenInfo, OnMsgGetScreenInfo)
IPC_MESSAGE_HANDLER(ViewHostMsg_GetWindowRect, OnMsgGetWindowRect)
IPC_MESSAGE_HANDLER(ViewHostMsg_GetRootWindowRect, OnMsgGetRootWindowRect)
@@ -752,6 +752,7 @@ void RenderWidgetHost::OnMsgImeUpdateStatus(int control,
}
#if defined(OS_LINUX)
+
void RenderWidgetHost::OnMsgCreatePluginContainer(
gfx::PluginWindowHandle *container) {
*container = view_->CreatePluginContainer();
@@ -761,18 +762,15 @@ void RenderWidgetHost::OnMsgDestroyPluginContainer(
gfx::PluginWindowHandle container) {
view_->DestroyPluginContainer(container);
}
+
#elif defined(OS_MACOSX)
-void RenderWidgetHost::OnMsgShowPopup(const IPC::Message& message) {
- void* iter = NULL;
- ViewHostMsg_ShowPopup_Params validated_params;
- if (!IPC::ParamTraits<ViewHostMsg_ShowPopup_Params>::Read(&message, &iter,
- &validated_params))
- return;
- view_->ShowPopupWithItems(validated_params.bounds,
- validated_params.item_height,
- validated_params.selected_item,
- validated_params.popup_items);
+void RenderWidgetHost::OnMsgShowPopup(
+ const ViewHostMsg_ShowPopup_Params& params) {
+ view_->ShowPopupWithItems(params.bounds,
+ params.item_height,
+ params.selected_item,
+ params.popup_items);
}
void RenderWidgetHost::OnMsgGetScreenInfo(gfx::NativeViewId view,
@@ -794,6 +792,7 @@ void RenderWidgetHost::OnMsgGetRootWindowRect(gfx::NativeViewId window_id,
*results = view_->GetRootWindowRect();
}
}
+
#endif
void RenderWidgetHost::PaintBackingStoreRect(TransportDIB* bitmap,
diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h
index d2d2826..e133670 100644
--- a/chrome/browser/renderer_host/render_widget_host.h
+++ b/chrome/browser/renderer_host/render_widget_host.h
@@ -38,6 +38,7 @@ class TransportDIB;
class WebCursor;
struct ViewHostMsg_PaintRect_Params;
struct ViewHostMsg_ScrollRect_Params;
+struct ViewHostMsg_ShowPopup_Params;
// This class manages the browser side of a browser<->renderer HWND connection.
// The HWND lives in the browser process, and windows events are sent over
@@ -396,7 +397,7 @@ class RenderWidgetHost : public IPC::Channel::Listener {
void OnMsgCreatePluginContainer(gfx::PluginWindowHandle *container);
void OnMsgDestroyPluginContainer(gfx::PluginWindowHandle container);
#elif defined(OS_MACOSX)
- void OnMsgShowPopup(const IPC::Message& message);
+ void OnMsgShowPopup(const ViewHostMsg_ShowPopup_Params& params);
void OnMsgGetScreenInfo(gfx::NativeViewId view,
WebKit::WebScreenInfo* results);
void OnMsgGetWindowRect(gfx::NativeViewId window_id, gfx::Rect* results);
diff --git a/chrome/browser/renderer_host/render_widget_host_view.h b/chrome/browser/renderer_host/render_widget_host_view.h
index fd72167..0837bc7 100644
--- a/chrome/browser/renderer_host/render_widget_host_view.h
+++ b/chrome/browser/renderer_host/render_widget_host_view.h
@@ -23,6 +23,7 @@ class BackingStore;
class RenderProcessHost;
class RenderWidgetHost;
class WebCursor;
+struct WebMenuItem;
// RenderWidgetHostView is an interface implemented by an object that acts as
// the "View" portion of a RenderWidgetHost. The RenderWidgetHost and its
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.h b/chrome/browser/renderer_host/render_widget_host_view_mac.h
index 270f00f..6c705db 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.h
@@ -13,8 +13,8 @@
#include "base/time.h"
#include "chrome/browser/cocoa/base_view.h"
#include "chrome/browser/renderer_host/render_widget_host_view.h"
-
#include "webkit/glue/webcursor.h"
+#include "webkit/glue/webmenuitem.h"
class RenderWidgetHostViewMac;
class RWHVMEditCommandHelper;
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 829a8ed..c887d40 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -34,6 +34,7 @@
#include "webkit/glue/webaccessibility.h"
#include "webkit/glue/webappcachecontext.h"
#include "webkit/glue/webdropdata.h"
+#include "webkit/glue/webmenuitem.h"
#include "webkit/glue/webplugin.h"
#include "webkit/glue/webplugininfo.h"
#include "webkit/glue/webpreferences.h"
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 31670ba..d3046d0 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -655,6 +655,10 @@ IPC_BEGIN_MESSAGES(ViewHost)
int /* route_id */,
gfx::Rect /* initial_pos */)
+ // Message to show a popup menu using native cocoa controls (Mac only).
+ IPC_MESSAGE_ROUTED1(ViewHostMsg_ShowPopup,
+ ViewHostMsg_ShowPopup_Params)
+
// This message is sent after ViewHostMsg_ShowView to cause the RenderView
// to run in a modal fashion until it is closed.
IPC_SYNC_MESSAGE_ROUTED0_0(ViewHostMsg_RunModal)
@@ -1431,10 +1435,6 @@ IPC_BEGIN_MESSAGES(ViewHost)
IPC_MESSAGE_CONTROL1(ViewHostMsg_ExtensionCloseChannel,
int /* port_id */)
- // Message to show a popup menu using native cocoa controls (Mac only).
- IPC_MESSAGE_ROUTED1(ViewHostMsg_ShowPopup,
- ViewHostMsg_ShowPopup_Params)
-
// Sent as a result of a focus change in the renderer (if accessibility is
// enabled), to notify the browser side that its accessibility focus needs to
// change as well. Takes the id of the accessibility object that now has
diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h
index 07a57c3..11e16fd 100644
--- a/chrome/renderer/print_web_view_helper.h
+++ b/chrome/renderer/print_web_view_helper.h
@@ -72,11 +72,6 @@ class PrintWebViewHelper : public WebViewDelegate {
virtual void DidScrollRect(WebWidget* webwidget, int dx, int dy,
const WebKit::WebRect& clip_rect) {}
virtual void Show(WebWidget* webwidget, WindowOpenDisposition disposition) {}
- virtual void ShowAsPopupWithItems(WebWidget* webwidget,
- const WebKit::WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<WebMenuItem>& items) {}
virtual void CloseWidgetSoon(WebWidget* webwidget) {}
virtual void Focus(WebWidget* webwidget) {}
virtual void Blur(WebWidget* webwidget) {}
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index d9df8e4..5f82399 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -107,6 +107,7 @@ using WebKit::WebDragData;
using WebKit::WebForm;
using WebKit::WebHistoryItem;
using WebKit::WebNavigationType;
+using WebKit::WebPopupMenuInfo;
using WebKit::WebRect;
using WebKit::WebScriptSource;
using WebKit::WebSize;
@@ -1759,6 +1760,15 @@ WebWidget* RenderView::CreatePopupWidget(WebView* webview,
return widget->webwidget();
}
+WebWidget* RenderView::CreatePopupWidgetWithInfo(WebView* webview,
+ const WebPopupMenuInfo& info) {
+ RenderWidget* widget = RenderWidget::Create(routing_id_,
+ render_thread_,
+ true);
+ widget->ConfigureAsExternalPopupMenu(info);
+ return widget->webwidget();
+}
+
WebPluginDelegate* RenderView::CreatePluginDelegate(
WebView* webview,
const GURL& url,
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 24621a4..bf6b6e3 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -233,6 +233,9 @@ class RenderView : public RenderWidget,
bool user_gesture,
const GURL& creator_url);
virtual WebWidget* CreatePopupWidget(WebView* webview, bool activatable);
+ virtual WebWidget* CreatePopupWidgetWithInfo(
+ WebView* webview,
+ const WebKit::WebPopupMenuInfo& info);
virtual WebPluginDelegate* CreatePluginDelegate(
WebView* webview,
const GURL& url,
diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc
index cf2e1da..7ff612f 100644
--- a/chrome/renderer/render_widget.cc
+++ b/chrome/renderer/render_widget.cc
@@ -16,6 +16,7 @@
#include "skia/ext/platform_canvas.h"
#include "third_party/skia/include/core/SkShader.h"
#include "webkit/api/public/WebCursorInfo.h"
+#include "webkit/api/public/WebPopupMenuInfo.h"
#include "webkit/api/public/WebRect.h"
#include "webkit/api/public/WebScreenInfo.h"
#include "webkit/api/public/WebSize.h"
@@ -30,6 +31,7 @@
using WebKit::WebCursorInfo;
using WebKit::WebInputEvent;
+using WebKit::WebPopupMenuInfo;
using WebKit::WebRect;
using WebKit::WebScreenInfo;
using WebKit::WebSize;
@@ -86,6 +88,14 @@ RenderWidget* RenderWidget::Create(int32 opener_id,
return widget;
}
+void RenderWidget::ConfigureAsExternalPopupMenu(const WebPopupMenuInfo& info) {
+ popup_params_.reset(new ViewHostMsg_ShowPopup_Params);
+ popup_params_->item_height = info.itemHeight;
+ popup_params_->selected_item = info.selectedIndex;
+ for (size_t i = 0; i < info.items.size(); ++i)
+ popup_params_->popup_items.push_back(WebMenuItem(info.items[i]));
+}
+
void RenderWidget::Init(int32 opener_id) {
DCHECK(!webwidget_);
@@ -589,26 +599,17 @@ void RenderWidget::Show(WebWidget* webwidget,
// NOTE: initial_pos_ may still have its default values at this point, but
// that's okay. It'll be ignored if as_popup is false, or the browser
// process will impose a default position otherwise.
- render_thread_->Send(new ViewHostMsg_ShowWidget(
- opener_id_, routing_id_, initial_pos_));
+ if (popup_params_.get()) {
+ popup_params_->bounds = initial_pos_;
+ Send(new ViewHostMsg_ShowPopup(routing_id_, *popup_params_));
+ popup_params_.reset();
+ } else {
+ Send(new ViewHostMsg_ShowWidget(opener_id_, routing_id_, initial_pos_));
+ }
SetPendingWindowRect(initial_pos_);
}
}
-void RenderWidget::ShowAsPopupWithItems(WebWidget* webwidget,
- const WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<WebMenuItem>& items) {
- ViewHostMsg_ShowPopup_Params params;
- params.bounds = bounds;
- params.item_height = item_height;
- params.selected_item = selected_index;
- params.popup_items = items;
-
- Send(new ViewHostMsg_ShowPopup(routing_id_, params));
-}
-
void RenderWidget::Focus(WebWidget* webwidget) {
// Prevent the widget from stealing the focus if it does not have focus
// already. We do this by explicitely setting the focus to false again.
diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h
index 3be99d8..f1fa069 100644
--- a/chrome/renderer/render_widget.h
+++ b/chrome/renderer/render_widget.h
@@ -23,8 +23,13 @@
#include "webkit/glue/webcursor.h"
class RenderThreadBase;
+struct ViewHostMsg_ShowPopup_Params;
struct WebPluginGeometry;
+namespace WebKit {
+struct WebPopupMenuInfo;
+}
+
// RenderWidget provides a communication bridge between a WebWidget and
// a RenderWidgetHost, the latter of which lives in a different process.
class RenderWidget : public IPC::Channel::Listener,
@@ -39,6 +44,10 @@ class RenderWidget : public IPC::Channel::Listener,
RenderThreadBase* render_thread,
bool activatable);
+ // Called after Create to configure a RenderWidget to be rendered by the host
+ // as a popup menu with the given data.
+ void ConfigureAsExternalPopupMenu(const WebKit::WebPopupMenuInfo& info);
+
// The routing ID assigned by the RenderProcess. Will be MSG_ROUTING_NONE if
// not yet assigned a view ID, in which case, the process MUST NOT send
// messages with this ID to the parent.
@@ -63,11 +72,6 @@ class RenderWidget : public IPC::Channel::Listener,
virtual void DidScrollRect(WebWidget* webwidget, int dx, int dy,
const WebKit::WebRect& clip_rect);
virtual void Show(WebWidget* webwidget, WindowOpenDisposition disposition);
- virtual void ShowAsPopupWithItems(WebWidget* webwidget,
- const WebKit::WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<WebMenuItem>& items);
virtual void CloseWidgetSoon(WebWidget* webwidget);
virtual void Focus(WebWidget* webwidget);
virtual void Blur(WebWidget* webwidget);
@@ -207,6 +211,7 @@ class RenderWidget : public IPC::Channel::Listener,
// We store the current cursor object so we can avoid spamming SetCursor
// messages.
WebCursor current_cursor_;
+
// The size of the RenderWidget.
gfx::Size size_;
@@ -289,6 +294,8 @@ class RenderWidget : public IPC::Channel::Listener,
int pending_window_rect_count_;
WebKit::WebRect pending_window_rect_;
+ scoped_ptr<ViewHostMsg_ShowPopup_Params> popup_params_;
+
DISALLOW_COPY_AND_ASSIGN(RenderWidget);
};
diff --git a/webkit/api/public/WebPopupMenuInfo.h b/webkit/api/public/WebPopupMenuInfo.h
index 5ce741b..b976dd0 100644
--- a/webkit/api/public/WebPopupMenuInfo.h
+++ b/webkit/api/public/WebPopupMenuInfo.h
@@ -1,10 +1,10 @@
/*
* 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
@@ -14,7 +14,7 @@
* * 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
@@ -31,10 +31,9 @@
#ifndef WebPopupMenuInfo_h
#define WebPopupMenuInfo_h
-#error "This header file is still a work in progress; do not include!"
-
#include "WebCommon.h"
#include "WebRect.h"
+#include "WebString.h"
#include "WebVector.h"
namespace WebKit {
@@ -52,10 +51,11 @@ namespace WebKit {
bool enabled;
};
- WebRect bounds;
int itemHeight;
int selectedIndex;
WebVector<Item> items;
};
} // namespace WebKit
+
+#endif
diff --git a/webkit/glue/chrome_client_impl.cc b/webkit/glue/chrome_client_impl.cc
index d868767..4c233f2 100644
--- a/webkit/glue/chrome_client_impl.cc
+++ b/webkit/glue/chrome_client_impl.cc
@@ -39,6 +39,7 @@ MSVC_POP_WARNING();
#include "webkit/api/public/WebCursorInfo.h"
#include "webkit/api/public/WebInputEvent.h"
#include "webkit/api/public/WebKit.h"
+#include "webkit/api/public/WebPopupMenuInfo.h"
#include "webkit/api/public/WebRect.h"
#include "webkit/api/public/WebURLRequest.h"
#include "webkit/api/src/WrappedResourceRequest.h"
@@ -49,11 +50,16 @@ MSVC_POP_WARNING();
#include "webkit/glue/webview_impl.h"
#include "webkit/glue/webwidget_impl.h"
+using WebCore::PopupContainer;
+using WebCore::PopupItem;
+
using WebKit::WebCursorInfo;
using WebKit::WebInputEvent;
using WebKit::WebMouseEvent;
+using WebKit::WebPopupMenuInfo;
using WebKit::WebRect;
using WebKit::WebURLRequest;
+using WebKit::WebVector;
using WebKit::WrappedResourceRequest;
// Callback class that's given to the WebViewDelegate during a file choose
@@ -544,65 +550,25 @@ void ChromeClientImpl::runOpenPanel(WebCore::Frame* frame,
delegate->RunFileChooser(multiple_files, string16(), suggestion, chooser);
}
-void ChromeClientImpl::popupOpened(WebCore::PopupContainer* popup_container,
+void ChromeClientImpl::popupOpened(PopupContainer* popup_container,
const WebCore::IntRect& bounds,
bool activatable,
- bool handle_external) {
- if (handle_external) {
- // We're going to handle the popup with native controls by the external
- // embedder.
- popupOpenedInternal(popup_container, bounds, activatable);
- return;
- }
-
- WebViewDelegate* delegate = webview_->delegate();
- if (delegate) {
- WebWidgetImpl* webwidget =
- static_cast<WebWidgetImpl*>(delegate->CreatePopupWidget(webview_,
- activatable));
- webwidget->Init(popup_container, webkit_glue::IntRectToWebRect(bounds));
- }
-}
-
-void ChromeClientImpl::popupOpenedInternal(
- WebCore::PopupContainer* popup_container,
- const WebCore::IntRect& bounds,
- bool activatable) {
+ bool handle_externally) {
WebViewDelegate* delegate = webview_->delegate();
if (!delegate)
return;
- WebWidgetImpl* webwidget =
- static_cast<WebWidgetImpl*>(delegate->CreatePopupWidget(webview_,
- activatable));
- // Convert WebKit types for Chromium.
- std::vector<WebMenuItem> popup_items;
- const WTF::Vector<WebCore::PopupItem*>& items = popup_container->popupData();
- for (int i = 0; i < static_cast<int>(items.size()); ++i) {
- WebMenuItem menu_item;
- menu_item.label = webkit_glue::StringToString16(items[i]->label);
- menu_item.enabled = items[i]->enabled;
- switch (items[i]->type) {
- case WebCore::PopupItem::TypeOption:
- menu_item.type = WebMenuItem::OPTION;
- break;
- case WebCore::PopupItem::TypeGroup:
- menu_item.type = WebMenuItem::GROUP;
- break;
- case WebCore::PopupItem::TypeSeparator:
- menu_item.type = WebMenuItem::SEPARATOR;
- break;
- default:
- NOTIMPLEMENTED();
- }
- popup_items.push_back(menu_item);
+ WebWidget* webwidget;
+ if (handle_externally) {
+ WebPopupMenuInfo popup_info;
+ GetPopupMenuInfo(popup_container, &popup_info);
+ webwidget = delegate->CreatePopupWidgetWithInfo(webview_, popup_info);
+ } else {
+ webwidget = delegate->CreatePopupWidget(webview_, activatable);
}
- webwidget->InitWithItems(popup_container,
- webkit_glue::IntRectToWebRect(bounds),
- popup_container->menuItemHeight(),
- popup_container->selectedIndex(),
- popup_items);
+ static_cast<WebWidgetImpl*>(webwidget)->Init(
+ popup_container, webkit_glue::IntRectToWebRect(bounds));
}
void ChromeClientImpl::SetCursor(const WebCursorInfo& cursor) {
@@ -629,3 +595,36 @@ void ChromeClientImpl::formStateDidChange(const WebCore::Node*) {
if (delegate)
delegate->OnNavStateChanged(webview_);
}
+
+void ChromeClientImpl::GetPopupMenuInfo(PopupContainer* popup_container,
+ WebPopupMenuInfo* info) {
+ const Vector<PopupItem*>& input_items = popup_container->popupData();
+
+ WebVector<WebPopupMenuInfo::Item> output_items(input_items.size());
+
+ for (size_t i = 0; i < input_items.size(); ++i) {
+ const PopupItem& input_item = *input_items[i];
+ WebPopupMenuInfo::Item& output_item = output_items[i];
+
+ output_item.label = webkit_glue::StringToWebString(input_item.label);
+ output_item.enabled = input_item.enabled;
+
+ switch (input_item.type) {
+ case PopupItem::TypeOption:
+ output_item.type = WebPopupMenuInfo::Item::Option;
+ break;
+ case PopupItem::TypeGroup:
+ output_item.type = WebPopupMenuInfo::Item::Group;
+ break;
+ case PopupItem::TypeSeparator:
+ output_item.type = WebPopupMenuInfo::Item::Separator;
+ break;
+ default:
+ NOTREACHED();
+ }
+ }
+
+ info->itemHeight = popup_container->menuItemHeight();
+ info->selectedIndex = popup_container->selectedIndex();
+ info->items.swap(output_items);
+}
diff --git a/webkit/glue/chrome_client_impl.h b/webkit/glue/chrome_client_impl.h
index cebffc2..2a91659 100644
--- a/webkit/glue/chrome_client_impl.h
+++ b/webkit/glue/chrome_client_impl.h
@@ -22,6 +22,7 @@ struct WindowFeatures;
namespace WebKit {
struct WebCursorInfo;
+struct WebPopupMenuInfo;
}
// Handles window-level notifications from WebCore on behalf of a WebView.
@@ -131,10 +132,7 @@ class ChromeClientImpl : public WebCore::ChromeClientChromium {
virtual void popupOpened(WebCore::PopupContainer* popup_container,
const WebCore::IntRect& bounds,
bool activatable,
- bool handle_external);
- void popupOpenedInternal(WebCore::PopupContainer* popup_container,
- const WebCore::IntRect& bounds,
- bool activatable);
+ bool handle_externally);
void SetCursor(const WebKit::WebCursorInfo& cursor);
void SetCursorForPlugin(const WebKit::WebCursorInfo& cursor);
@@ -144,6 +142,9 @@ class ChromeClientImpl : public WebCore::ChromeClientChromium {
virtual PassOwnPtr<WebCore::HTMLParserQuirks> createHTMLParserQuirks() { return 0; }
private:
+ void GetPopupMenuInfo(WebCore::PopupContainer* popup_container,
+ WebKit::WebPopupMenuInfo* info);
+
WebViewImpl* webview_; // weak pointer
bool toolbars_visible_;
bool statusbar_visible_;
diff --git a/webkit/glue/webmenuitem.h b/webkit/glue/webmenuitem.h
new file mode 100644
index 0000000..584e071
--- /dev/null
+++ b/webkit/glue/webmenuitem.h
@@ -0,0 +1,33 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBMENUITEM_H_
+#define WEBMENUITEM_H_
+
+#include "base/string16.h"
+#include "webkit/api/public/WebPopupMenuInfo.h"
+
+// Container for information about entries in an HTML select popup menu.
+struct WebMenuItem {
+ enum Type {
+ OPTION = WebKit::WebPopupMenuInfo::Item::Option,
+ GROUP = WebKit::WebPopupMenuInfo::Item::Group,
+ SEPARATOR = WebKit::WebPopupMenuInfo::Item::Separator
+ };
+
+ string16 label;
+ Type type;
+ bool enabled;
+
+ WebMenuItem() : type(OPTION), enabled(false) {
+ }
+
+ WebMenuItem(const WebKit::WebPopupMenuInfo::Item& item)
+ : label(item.label),
+ type(static_cast<Type>(item.type)),
+ enabled(item.enabled) {
+ }
+};
+
+#endif // WEBMENUITEM_H_
diff --git a/webkit/glue/webmenurunner_mac.h b/webkit/glue/webmenurunner_mac.h
index 8d822a4..b83abeb 100644
--- a/webkit/glue/webmenurunner_mac.h
+++ b/webkit/glue/webmenurunner_mac.h
@@ -10,7 +10,7 @@
#include <vector>
#include "base/scoped_nsobject.h"
-#include "webkit/glue/webwidget_delegate.h"
+#include "webkit/glue/webmenuitem.h"
// WebMenuRunner ---------------------------------------------------------------
diff --git a/webkit/glue/webmenurunner_mac.mm b/webkit/glue/webmenurunner_mac.mm
index 8997f05..99c52bd 100644
--- a/webkit/glue/webmenurunner_mac.mm
+++ b/webkit/glue/webmenurunner_mac.mm
@@ -25,7 +25,7 @@
menu_.reset([[NSMenu alloc] initWithTitle:@""]);
[menu_ setAutoenablesItems:NO];
index_ = -1;
- for (int i = 0; i < static_cast<int>(items.size()); ++i)
+ for (size_t i = 0; i < items.size(); ++i)
[self addItem:items[i]];
}
return self;
diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h
index 6106d1d..eafd383 100644
--- a/webkit/glue/webview_delegate.h
+++ b/webkit/glue/webview_delegate.h
@@ -52,6 +52,7 @@ class WebMediaPlayerClient;
class WebURLRequest;
class WebURLResponse;
struct WebPoint;
+struct WebPopupMenuInfo;
struct WebRect;
struct WebURLError;
}
@@ -119,6 +120,14 @@ class WebViewDelegate : virtual public WebWidgetDelegate {
return NULL;
}
+ // Like CreatePopupWidget, except the actual widget is rendered by the
+ // embedder using the supplied info.
+ virtual WebWidget* CreatePopupWidgetWithInfo(
+ WebView* webview,
+ const WebKit::WebPopupMenuInfo& info) {
+ return NULL;
+ }
+
// This method is called to create a WebPluginDelegate implementation when a
// new plugin is instanced. See webkit_glue::CreateWebPluginDelegateHelper
// for a default WebPluginDelegate implementation.
diff --git a/webkit/glue/webwidget_delegate.h b/webkit/glue/webwidget_delegate.h
index 17704b0d..a891cb1 100644
--- a/webkit/glue/webwidget_delegate.h
+++ b/webkit/glue/webwidget_delegate.h
@@ -19,22 +19,6 @@ struct WebScreenInfo;
class WebWidget;
struct WebPluginGeometry;
-struct WebMenuItem {
- // Container for information about entries in an HTML select popup menu.
- // Types must be kept in sync with PopupListBox::ListItemType in
- // WebCore/platform/chromium/PopupMenuChromium.h. This won't change often
- // (if ever).
- enum Type {
- OPTION = 0,
- GROUP,
- SEPARATOR
- };
-
- string16 label;
- Type type;
- bool enabled;
-};
-
class WebWidgetDelegate {
public:
// Called when a region of the WebWidget needs to be re-painted.
@@ -54,21 +38,6 @@ class WebWidgetDelegate {
virtual void Show(WebWidget* webwidget,
WindowOpenDisposition disposition) = 0;
- // Used for displaying HTML popup menus on Mac OS X (other platforms will use
- // Show() above). |bounds| represents the positioning on the screen (in WebKit
- // coordinates, origin at the top left corner) of the button that will display
- // the menu. It will be used, along with |item_height| (which refers to the
- // size of each entry in the menu), to position the menu on the screen.
- // |selected_index| indicates the menu item that should be drawn as selected
- // when the menu initially is displayed. |items| contains information about
- // each of the entries in the popup menu, such as the type (separator, option,
- // group), the text representation and the item's enabled status.
- virtual void ShowAsPopupWithItems(WebWidget* webwidget,
- const WebKit::WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<WebMenuItem>& items) = 0;
-
// This method is called to instruct the window containing the WebWidget to
// close. Note: This method should just be the trigger that causes the
// WebWidget to eventually close. It should not actually be destroyed until
diff --git a/webkit/glue/webwidget_impl.cc b/webkit/glue/webwidget_impl.cc
index cb3a0c9..618a9bf 100644
--- a/webkit/glue/webwidget_impl.cc
+++ b/webkit/glue/webwidget_impl.cc
@@ -70,20 +70,6 @@ void WebWidgetImpl::Init(WebCore::FramelessScrollView* widget,
}
}
-void WebWidgetImpl::InitWithItems(WebCore::FramelessScrollView* widget,
- const WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<WebMenuItem>& items) {
- widget_ = widget;
- widget_->setClient(this);
-
- if (delegate_) {
- delegate_->ShowAsPopupWithItems(this, bounds, item_height,
- selected_index, items);
- }
-}
-
void WebWidgetImpl::MouseMove(const WebMouseEvent& event) {
// don't send mouse move messages if the mouse hasn't moved.
if (event.x != last_mouse_position_.x ||
diff --git a/webkit/glue/webwidget_impl.h b/webkit/glue/webwidget_impl.h
index a0078db..a1a1b18 100644
--- a/webkit/glue/webwidget_impl.h
+++ b/webkit/glue/webwidget_impl.h
@@ -59,11 +59,6 @@ class WebWidgetImpl : public WebWidget,
// WebWidgetImpl
void Init(WebCore::FramelessScrollView* widget,
const WebKit::WebRect& bounds);
- void InitWithItems(WebCore::FramelessScrollView* widget,
- const WebKit::WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<WebMenuItem>& items);
const WebKit::WebSize& size() const { return size_; }
diff --git a/webkit/glue/webworker_impl.cc b/webkit/glue/webworker_impl.cc
index 4016e85..c706524 100644
--- a/webkit/glue/webworker_impl.cc
+++ b/webkit/glue/webworker_impl.cc
@@ -69,11 +69,6 @@ class WorkerWebViewDelegate : public WebViewDelegate {
virtual void SetWindowRect(WebWidget *webwidget,
const WebKit::WebRect &rect) { }
virtual void Show(WebWidget *webwidget, WindowOpenDisposition disposition) { }
- virtual void ShowAsPopupWithItems(WebWidget *webwidget,
- const WebKit::WebRect &bounds,
- int item_height,
- int selected_index,
- const std::vector<WebMenuItem> &items) { }
// Tell the loader to load the data into the 'shadow page' synchronously,
// so we can grab the resulting Document right after load.
virtual void DidCreateDataSource(WebFrame* frame, WebKit::WebDataSource* ds) {
diff --git a/webkit/tools/test_shell/mac/test_webview_delegate.mm b/webkit/tools/test_shell/mac/test_webview_delegate.mm
index 93a3032..9939c68 100644
--- a/webkit/tools/test_shell/mac/test_webview_delegate.mm
+++ b/webkit/tools/test_shell/mac/test_webview_delegate.mm
@@ -8,7 +8,6 @@
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
#include "webkit/api/public/WebCursorInfo.h"
-#include "webkit/api/public/WebRect.h"
#include "webkit/glue/webcursor.h"
#include "webkit/glue/webview.h"
#include "webkit/glue/plugins/plugin_list.h"
@@ -17,6 +16,7 @@
#include "webkit/tools/test_shell/test_shell.h"
using WebKit::WebCursorInfo;
+using WebKit::WebPopupMenuInfo;
using WebKit::WebRect;
// WebViewDelegate -----------------------------------------------------------
@@ -24,6 +24,14 @@ using WebKit::WebRect;
TestWebViewDelegate::~TestWebViewDelegate() {
}
+WebWidget* TestWebViewDelegate::CreatePopupWidgetWithInfo(
+ WebView* webview,
+ const WebPopupMenuInfo& info) {
+ WebWidget* webwidget = shell_->CreatePopupWidget(webview);
+ popup_menu_info_.reset(new WebPopupMenuInfo(info));
+ return webwidget;
+}
+
WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate(
WebView* webview,
const GURL& url,
@@ -62,17 +70,24 @@ void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) {
// WebWidgetDelegate ---------------------------------------------------------
-void TestWebViewDelegate::Show(WebWidget* webview,
+void TestWebViewDelegate::Show(WebWidget* webwidget,
WindowOpenDisposition disposition) {
-}
+ if (!popup_menu_info_.get())
+ return;
+ if (webwidget != shell_->popup())
+ return;
+ // Display a HTML select menu.
+
+ std::vector<WebMenuItem> items;
+ for (size_t i = 0; i < popup_menu_info_->items.size(); ++i)
+ items.push_back(popup_menu_info_->items[i]);
+
+ int item_height = popup_menu_info_->itemHeight;
+ int selected_index = popup_menu_info_->selectedIndex;
+ popup_menu_info_.reset(); // No longer needed.
+
+ const WebRect& bounds = popup_bounds_;
-// Display a HTML select menu.
-void TestWebViewDelegate::ShowAsPopupWithItems(
- WebWidget* webview,
- const WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<WebMenuItem>& items) {
// Set up the menu position.
NSView* web_view = shell_->webViewWnd();
NSRect view_rect = [web_view bounds];
@@ -146,8 +161,7 @@ void TestWebViewDelegate::SetWindowRect(WebWidget* webwidget,
if (webwidget == shell_->webView()) {
// ignored
} else if (webwidget == shell_->popup()) {
- // MoveWindow(shell_->popupWnd(),
- // rect.x(), rect.y(), rect.width(), rect.height(), FALSE);
+ popup_bounds_ = rect; // The initial position of the popup.
}
}
diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h
index 1ce235e..208c8e6a 100644
--- a/webkit/tools/test_shell/test_webview_delegate.h
+++ b/webkit/tools/test_shell/test_webview_delegate.h
@@ -23,6 +23,10 @@
#include "base/basictypes.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
+#if defined(OS_MACOSX)
+#include "webkit/api/public/WebRect.h"
+#include "webkit/api/public/WebPopupMenuInfo.h"
+#endif
#include "webkit/glue/webcursor.h"
#include "webkit/glue/webview_delegate.h"
#include "webkit/glue/webwidget_delegate.h"
@@ -82,12 +86,17 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>,
bool user_gesture,
const GURL& creator_url);
virtual WebWidget* CreatePopupWidget(WebView* webview, bool activatable);
+#if defined(OS_MACOSX)
+ virtual WebWidget* CreatePopupWidgetWithInfo(
+ WebView* webview,
+ const WebKit::WebPopupMenuInfo& info);
+#endif
virtual WebPluginDelegate* CreatePluginDelegate(
- WebView* webview,
- const GURL& url,
- const std::string& mime_type,
- const std::string& clsid,
- std::string* actual_mime_type);
+ WebView* webview,
+ const GURL& url,
+ const std::string& mime_type,
+ const std::string& clsid,
+ std::string* actual_mime_type);
#if defined(OS_LINUX)
virtual gfx::PluginWindowHandle CreatePluginContainer();
virtual void WillDestroyPluginWindow(gfx::PluginWindowHandle handle);
@@ -227,11 +236,6 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>,
virtual void DidScrollRect(WebWidget* webwidget, int dx, int dy,
const WebKit::WebRect& clip_rect);
virtual void Show(WebWidget* webview, WindowOpenDisposition disposition);
- virtual void ShowAsPopupWithItems(WebWidget* webwidget,
- const WebKit::WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<WebMenuItem>& items);
virtual void CloseWidgetSoon(WebWidget* webwidget);
virtual void Focus(WebWidget* webwidget);
virtual void Blur(WebWidget* webwidget);
@@ -347,7 +351,10 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>,
// true if we want to enable selection of trailing whitespaces
bool select_trailing_whitespace_enabled_;
+ CapturedContextMenuEvents captured_context_menu_events_;
+
WebCursor current_cursor_;
+
#if defined(OS_WIN)
// Classes needed by drag and drop.
scoped_refptr<TestDragDelegate> drag_delegate_;
@@ -361,7 +368,10 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>,
GdkCursorType cursor_type_;
#endif
- CapturedContextMenuEvents captured_context_menu_events_;
+#if defined(OS_MACOSX)
+ scoped_ptr<WebKit::WebPopupMenuInfo> popup_menu_info_;
+ WebKit::WebRect popup_bounds_;
+#endif
DISALLOW_COPY_AND_ASSIGN(TestWebViewDelegate);
};
diff --git a/webkit/tools/test_shell/test_webview_delegate_gtk.cc b/webkit/tools/test_shell/test_webview_delegate_gtk.cc
index 46ecc9d..1257145 100644
--- a/webkit/tools/test_shell/test_webview_delegate_gtk.cc
+++ b/webkit/tools/test_shell/test_webview_delegate_gtk.cc
@@ -128,15 +128,6 @@ void TestWebViewDelegate::Show(WebWidget* webwidget,
gtk_widget_show_all(window);
}
-void TestWebViewDelegate::ShowAsPopupWithItems(
- WebWidget* webwidget,
- const WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<WebMenuItem>& items) {
- NOTREACHED();
-}
-
void TestWebViewDelegate::CloseWidgetSoon(WebWidget* webwidget) {
if (webwidget == shell_->webView()) {
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction(
diff --git a/webkit/tools/test_shell/test_webview_delegate_win.cc b/webkit/tools/test_shell/test_webview_delegate_win.cc
index dc16544..f33c95f 100644
--- a/webkit/tools/test_shell/test_webview_delegate_win.cc
+++ b/webkit/tools/test_shell/test_webview_delegate_win.cc
@@ -81,15 +81,6 @@ void TestWebViewDelegate::Show(WebWidget* webwidget, WindowOpenDisposition) {
}
}
-void TestWebViewDelegate::ShowAsPopupWithItems(
- WebWidget* webwidget,
- const WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<WebMenuItem>& items) {
- NOTREACHED();
-}
-
void TestWebViewDelegate::CloseWidgetSoon(WebWidget* webwidget) {
if (webwidget == shell_->webView()) {
PostMessage(shell_->mainWnd(), WM_CLOSE, 0, 0);
diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp
index 308fb5f..4c79563 100644
--- a/webkit/webkit.gyp
+++ b/webkit/webkit.gyp
@@ -4243,6 +4243,7 @@
'api/public/WebNonCopyable.h',
'api/public/WebPluginListBuilder.h',
'api/public/WebPoint.h',
+ 'api/public/WebPopupMenuInfo.h',
'api/public/WebRect.h',
'api/public/WebScreenInfo.h',
'api/public/WebScriptSource.h',
@@ -4616,6 +4617,7 @@
'glue/webkitclient_impl.h',
'glue/webmediaplayer_impl.h',
'glue/webmediaplayer_impl.cc',
+ 'glue/webmenuitem.h',
'glue/webmenurunner_mac.h',
'glue/webmenurunner_mac.mm',
'glue/webplugin.h',