diff options
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/print_web_view_helper.h | 5 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 10 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 3 | ||||
-rw-r--r-- | chrome/renderer/render_widget.cc | 33 | ||||
-rw-r--r-- | chrome/renderer/render_widget.h | 17 |
5 files changed, 42 insertions, 26 deletions
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); }; |