summaryrefslogtreecommitdiffstats
path: root/webkit/glue
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 /webkit/glue
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
Diffstat (limited to 'webkit/glue')
-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
5 files changed, 52 insertions, 54 deletions
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_; }