summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpaulg@google.com <paulg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-10 03:03:09 +0000
committerpaulg@google.com <paulg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-10 03:03:09 +0000
commit3f64e5af06d2506e1e9886fc834775f2169f21be (patch)
tree6a23effda23684362a666dc02efa3a337fd40f3c
parent1f73c7ff048b6735e5cf2c36d77ac0cd175d5fb8 (diff)
downloadchromium_src-3f64e5af06d2506e1e9886fc834775f2169f21be.zip
chromium_src-3f64e5af06d2506e1e9886fc834775f2169f21be.tar.gz
chromium_src-3f64e5af06d2506e1e9886fc834775f2169f21be.tar.bz2
Chrome side of the WebKit popup changes.
Implements HTML select popups on Mac OS X as native Cocoa controls. BUG=5095 (http://crbug.com/5095) Review URL: http://codereview.chromium.org/67018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13495 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/renderer/render_widget.cc10
-rw-r--r--chrome/renderer/render_widget.h12
-rw-r--r--webkit/glue/chrome_client_impl.cc53
-rw-r--r--webkit/glue/chrome_client_impl.h14
-rw-r--r--webkit/glue/webwidget_delegate.h31
-rw-r--r--webkit/glue/webwidget_impl.cc6
-rw-r--r--webkit/glue/webwidget_impl.h2
-rwxr-xr-xwebkit/tools/test_shell/mac/test_webview_delegate.mm18
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.h10
-rwxr-xr-xwebkit/tools/test_shell/test_webview_delegate_gtk.cc13
-rwxr-xr-xwebkit/tools/test_shell/test_webview_delegate_win.cc13
11 files changed, 92 insertions, 90 deletions
diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc
index ba82739..7f698cf 100644
--- a/chrome/renderer/render_widget.cc
+++ b/chrome/renderer/render_widget.cc
@@ -564,11 +564,11 @@ void RenderWidget::Show(WebWidget* webwidget,
}
}
-void RenderWidget::ShowWithItems(WebWidget* webwidget,
- const WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<MenuItem>& items) {
+void RenderWidget::ShowAsPopupWithItems(WebWidget* webwidget,
+ const WebRect& bounds,
+ int item_height,
+ int selected_index,
+ const std::vector<WebMenuItem>& items) {
// TODO(paulg): Implement this for Mac HTML select menus in Chromium, bug
// number: http://crbug.com/8389
}
diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h
index 32c2405..9dbfcbb 100644
--- a/chrome/renderer/render_widget.h
+++ b/chrome/renderer/render_widget.h
@@ -69,16 +69,16 @@ class RenderWidget : public IPC::Channel::Listener,
const WebKit::WebRect& rect);
virtual void DidScrollRect(WebWidget* webwidget, int dx, int dy,
const WebKit::WebRect& clip_rect);
- virtual void SetCursor(WebWidget* webwidget, const WebCursor& cursor);
virtual void Show(WebWidget* webwidget, WindowOpenDisposition disposition);
- virtual void ShowWithItems(WebWidget* webwidget,
- const WebKit::WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<MenuItem>& items);
+ 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);
+ virtual void SetCursor(WebWidget* webwidget, const WebCursor& cursor);
virtual void GetWindowRect(WebWidget* webwidget, WebKit::WebRect* rect);
virtual void SetWindowRect(WebWidget* webwidget,
const WebKit::WebRect& rect);
diff --git a/webkit/glue/chrome_client_impl.cc b/webkit/glue/chrome_client_impl.cc
index aebc29b..f3addc5 100644
--- a/webkit/glue/chrome_client_impl.cc
+++ b/webkit/glue/chrome_client_impl.cc
@@ -506,29 +506,30 @@ void ChromeClientImpl::runOpenPanel(WebCore::Frame* frame,
std::wstring(), chooser);
}
-void ChromeClientImpl::popupOpened(WebCore::FramelessScrollView* popup_view,
+void ChromeClientImpl::popupOpened(WebCore::PopupContainer* popup_container,
const WebCore::IntRect& bounds,
- bool activatable) {
+ 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_view, webkit_glue::IntRectToWebRect(bounds));
+ webwidget->Init(popup_container, webkit_glue::IntRectToWebRect(bounds));
}
}
-void ChromeClientImpl::popupOpenedWithItems(
- WebCore::FramelessScrollView* popup_view,
+void ChromeClientImpl::popupOpenedInternal(
+ WebCore::PopupContainer* popup_container,
const WebCore::IntRect& bounds,
- bool activatable,
- int item_height,
- int selected_index,
- const WTF::Vector<WebCore::PopupListData*>& items) {
- /*
- Uncomment this section once the changes to
- WebKit/WebCore/platform/chromium/PopupMenuChromium* have landed in our tree.
-
+ bool activatable) {
WebViewDelegate* delegate = webview_->delegate();
if (!delegate)
return;
@@ -537,20 +538,21 @@ void ChromeClientImpl::popupOpenedWithItems(
static_cast<WebWidgetImpl*>(delegate->CreatePopupWidget(webview_,
activatable));
// Convert WebKit types for Chromium.
- std::vector<MenuItem> popup_items;
- for (int i = 0; i < items.size(); ++i) {
- MenuItem menu_item;
+ 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::PopupListData::TypeOption:
- menu_item.type = MenuItem::OPTION;
+ case WebCore::PopupItem::TypeOption:
+ menu_item.type = WebMenuItem::OPTION;
break;
- case WebCore::PopupListData::TypeGroup:
- menu_item.type = MenuItem::GROUP;
+ case WebCore::PopupItem::TypeGroup:
+ menu_item.type = WebMenuItem::GROUP;
break;
- case WebCore::PopupListData::TypeSeparator:
- menu_item.type = MenuItem::SEPARATOR;
+ case WebCore::PopupItem::TypeSeparator:
+ menu_item.type = WebMenuItem::SEPARATOR;
break;
default:
NOTIMPLEMENTED();
@@ -558,12 +560,11 @@ void ChromeClientImpl::popupOpenedWithItems(
popup_items.push_back(menu_item);
}
- webwidget->InitWithItems(popup_view,
+ webwidget->InitWithItems(popup_container,
webkit_glue::IntRectToWebRect(bounds),
- item_height,
- selected_index,
+ popup_container->menuItemHeight(),
+ popup_container->selectedIndex(),
popup_items);
- */
}
void ChromeClientImpl::SetCursor(const WebCursor& cursor) {
diff --git a/webkit/glue/chrome_client_impl.h b/webkit/glue/chrome_client_impl.h
index ad427f4..a29a2da 100644
--- a/webkit/glue/chrome_client_impl.h
+++ b/webkit/glue/chrome_client_impl.h
@@ -15,7 +15,7 @@ class WebCursor;
class WebViewImpl;
namespace WebCore {
-struct PopupListData;
+class PopupContainer;
class SecurityOrigin;
struct WindowFeatures;
}
@@ -117,15 +117,13 @@ class ChromeClientImpl : public WebCore::ChromeClientChromium {
virtual void runOpenPanel(WebCore::Frame*,
PassRefPtr<WebCore::FileChooser>);
- virtual void popupOpened(WebCore::FramelessScrollView* popup_view,
+ virtual void popupOpened(WebCore::PopupContainer* popup_container,
const WebCore::IntRect& bounds,
- bool activatable);
- void popupOpenedWithItems(WebCore::FramelessScrollView* popupView,
+ bool activatable,
+ bool handle_external);
+ void popupOpenedInternal(WebCore::PopupContainer* popup_container,
const WebCore::IntRect& bounds,
- bool activatable,
- int item_height,
- int selected_index,
- const WTF::Vector<WebCore::PopupListData*>& items);
+ bool activatable);
void SetCursor(const WebCursor& cursor);
void SetCursorForPlugin(const WebCursor& cursor);
diff --git a/webkit/glue/webwidget_delegate.h b/webkit/glue/webwidget_delegate.h
index e6d95b0..5b8fbbd0 100644
--- a/webkit/glue/webwidget_delegate.h
+++ b/webkit/glue/webwidget_delegate.h
@@ -21,7 +21,7 @@ class WebWidget;
class WebCursor;
struct WebPluginGeometry;
-struct MenuItem {
+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
@@ -57,21 +57,20 @@ class WebWidgetDelegate {
// window should be displayed, but generally only means something for WebViews.
virtual void Show(WebWidget* webwidget, WindowOpenDisposition disposition) = 0;
- // Used for displaying HTML select elements as 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 ShowWithItems(WebWidget* webwidget,
- const WebKit::WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<MenuItem>& items) = 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
diff --git a/webkit/glue/webwidget_impl.cc b/webkit/glue/webwidget_impl.cc
index 79408fb..f8442d6 100644
--- a/webkit/glue/webwidget_impl.cc
+++ b/webkit/glue/webwidget_impl.cc
@@ -73,13 +73,13 @@ void WebWidgetImpl::InitWithItems(WebCore::FramelessScrollView* widget,
const WebRect& bounds,
int item_height,
int selected_index,
- const std::vector<MenuItem>& items) {
+ const std::vector<WebMenuItem>& items) {
widget_ = widget;
widget_->setClient(this);
if (delegate_) {
- delegate_->SetWindowRect(this, bounds);
- delegate_->ShowWithItems(this, bounds, item_height, selected_index, items);
+ delegate_->ShowAsPopupWithItems(this, bounds, item_height,
+ selected_index, items);
}
}
diff --git a/webkit/glue/webwidget_impl.h b/webkit/glue/webwidget_impl.h
index 548952b..5b01475 100644
--- a/webkit/glue/webwidget_impl.h
+++ b/webkit/glue/webwidget_impl.h
@@ -65,7 +65,7 @@ class WebWidgetImpl : public WebWidget,
const WebKit::WebRect& bounds,
int item_height,
int selected_index,
- const std::vector<MenuItem>& items);
+ const std::vector<WebMenuItem>& items);
const WebKit::WebSize& size() const { return size_; }
diff --git a/webkit/tools/test_shell/mac/test_webview_delegate.mm b/webkit/tools/test_shell/mac/test_webview_delegate.mm
index 9ae7a80..8df8d40 100755
--- a/webkit/tools/test_shell/mac/test_webview_delegate.mm
+++ b/webkit/tools/test_shell/mac/test_webview_delegate.mm
@@ -27,15 +27,17 @@ using WebKit::WebRect;
NSMenu* menu_; // Non-owning
BOOL menuItemWasChosen_;
}
-- (id)initWithItems:(const std::vector<MenuItem>&)items forMenu:(NSMenu*)menu;
-- (void)addItem:(const MenuItem&)item;
+- (id)initWithItems:(const std::vector<WebMenuItem>&)items
+ forMenu:(NSMenu*)menu;
+- (void)addItem:(const WebMenuItem&)item;
- (BOOL)menuItemWasChosen;
- (void)menuItemSelected:(id)sender;
@end
@implementation MenuDelegate
-- (id)initWithItems:(const std::vector<MenuItem>&)items forMenu:(NSMenu*)menu {
+- (id)initWithItems:(const std::vector<WebMenuItem>&)items
+ forMenu:(NSMenu*)menu {
if ((self = [super init])) {
menu_ = menu;
menuItemWasChosen_ = NO;
@@ -45,8 +47,8 @@ using WebKit::WebRect;
return self;
}
-- (void)addItem:(const MenuItem&)item {
- if (item.type == MenuItem::SEPARATOR) {
+- (void)addItem:(const WebMenuItem&)item {
+ if (item.type == WebMenuItem::SEPARATOR) {
[menu_ addItem:[NSMenuItem separatorItem]];
return;
}
@@ -55,7 +57,7 @@ using WebKit::WebRect;
NSMenuItem* menu_item = [menu_ addItemWithTitle:title
action:@selector(menuItemSelected:)
keyEquivalent:@""];
- [menu_item setEnabled:(item.enabled && item.type != MenuItem::GROUP)];
+ [menu_item setEnabled:(item.enabled && item.type != WebMenuItem::GROUP)];
[menu_item setTarget:self];
}
@@ -122,12 +124,12 @@ void TestWebViewDelegate::Show(WebWidget* webview,
}
// Display a HTML select menu.
-void TestWebViewDelegate::ShowWithItems(
+void TestWebViewDelegate::ShowAsPopupWithItems(
WebWidget* webview,
const WebRect& bounds,
int item_height,
int selected_index,
- const std::vector<MenuItem>& items) {
+ const std::vector<WebMenuItem>& items) {
// Populate the menu.
NSMenu* menu = [[[NSMenu alloc] initWithTitle:@""] autorelease];
[menu setAutoenablesItems:NO];
diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h
index e1692fe..03d7387 100644
--- a/webkit/tools/test_shell/test_webview_delegate.h
+++ b/webkit/tools/test_shell/test_webview_delegate.h
@@ -217,11 +217,11 @@ 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 ShowWithItems(WebWidget* webwidget,
- const WebKit::WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<MenuItem>& items);
+ 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/webkit/tools/test_shell/test_webview_delegate_gtk.cc b/webkit/tools/test_shell/test_webview_delegate_gtk.cc
index ef92a3b..b389c6f 100755
--- a/webkit/tools/test_shell/test_webview_delegate_gtk.cc
+++ b/webkit/tools/test_shell/test_webview_delegate_gtk.cc
@@ -115,12 +115,13 @@ void TestWebViewDelegate::Show(WebWidget* webwidget,
gtk_widget_show_all(window);
}
-void TestWebViewDelegate::ShowWithItems(WebWidget* webwidget,
- const WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<MenuItem>& items) {
- NOTIMPLEMENTED();
+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) {
diff --git a/webkit/tools/test_shell/test_webview_delegate_win.cc b/webkit/tools/test_shell/test_webview_delegate_win.cc
index 125c1b2..16d84e9 100755
--- a/webkit/tools/test_shell/test_webview_delegate_win.cc
+++ b/webkit/tools/test_shell/test_webview_delegate_win.cc
@@ -81,12 +81,13 @@ void TestWebViewDelegate::Show(WebWidget* webwidget, WindowOpenDisposition) {
}
}
-void TestWebViewDelegate::ShowWithItems(WebWidget* webwidget,
- const WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<MenuItem>& items) {
- NOTIMPLEMENTED();
+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) {