summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-14 16:32:59 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-14 16:32:59 +0000
commit88efb7ec99239eeecaa17d21f8635be1bce29cca (patch)
treeb1a988fbca10748e584f78abb755036e63ff335f /chrome/renderer
parentc9d6a1df8ef5fd2c3f134dcb544663ce8bd21c7b (diff)
downloadchromium_src-88efb7ec99239eeecaa17d21f8635be1bce29cca.zip
chromium_src-88efb7ec99239eeecaa17d21f8635be1bce29cca.tar.gz
chromium_src-88efb7ec99239eeecaa17d21f8635be1bce29cca.tar.bz2
Replace ShowAsPopupWithItems to CreatePopupWidgetWithInfo. Also,
make use of WebPopupMenuInfo from the WebKit API. WebMenuItem remains in webkit/glue for convenience with IPC marshalling and related usage in Chrome. This work is precursor to switching over to using WebWidget from the WebKit API. BUG=16234 TEST=html select drop downs should still work on the mac. try switching languages on news.google.com. R=paul Review URL: http://codereview.chromium.org/155378 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20624 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-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
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);
};