diff options
author | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-26 06:00:42 +0000 |
---|---|---|
committer | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-26 06:00:42 +0000 |
commit | 5fc549f0469b301169a17a28b725c8ea20d80673 (patch) | |
tree | fea512f022e5be806e587aea4a8905fcd73c2331 /views/controls | |
parent | 7de2cf6dea088d93b88e997605e229888fadfceb (diff) | |
download | chromium_src-5fc549f0469b301169a17a28b725c8ea20d80673.zip chromium_src-5fc549f0469b301169a17a28b725c8ea20d80673.tar.gz chromium_src-5fc549f0469b301169a17a28b725c8ea20d80673.tar.bz2 |
Use widget to specify the parent of views menu.
BUG=none
TEST=none. no functional change and all tests should pass.
Review URL: http://codereview.chromium.org/7489035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94046 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r-- | views/controls/button/button_dropdown.cc | 4 | ||||
-rw-r--r-- | views/controls/menu/menu_controller.cc | 7 | ||||
-rw-r--r-- | views/controls/menu/menu_controller.h | 4 | ||||
-rw-r--r-- | views/controls/menu/menu_host.cc | 8 | ||||
-rw-r--r-- | views/controls/menu/menu_host.h | 6 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view.cc | 4 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view.h | 4 | ||||
-rw-r--r-- | views/controls/menu/menu_runner.cc | 6 | ||||
-rw-r--r-- | views/controls/menu/menu_runner.h | 3 | ||||
-rw-r--r-- | views/controls/menu/submenu_view.cc | 2 | ||||
-rw-r--r-- | views/controls/menu/submenu_view.h | 2 | ||||
-rw-r--r-- | views/controls/textfield/native_textfield_views.cc | 2 |
12 files changed, 23 insertions, 29 deletions
diff --git a/views/controls/button/button_dropdown.cc b/views/controls/button/button_dropdown.cc index 01f13ca..16c0313 100644 --- a/views/controls/button/button_dropdown.cc +++ b/views/controls/button/button_dropdown.cc @@ -158,14 +158,14 @@ void ButtonDropDown::ShowDropDownMenu(gfx::NativeView window) { MenuItemView menu(&menu_delegate); menu_delegate.BuildMenu(&menu); - menu.RunMenuAt(GetWidget()->GetNativeWindow(), NULL, + menu.RunMenuAt(GetWidget(), NULL, gfx::Rect(menu_position, gfx::Size(0, 0)), views::MenuItemView::TOPLEFT, true); } else { MenuDelegate menu_delegate; MenuItemView menu(&menu_delegate); - menu.RunMenuAt(GetWidget()->GetNativeWindow(), NULL, + menu.RunMenuAt(GetWidget(), NULL, gfx::Rect(menu_position, gfx::Size(0, 0)), views::MenuItemView::TOPLEFT, true); diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc index 3fae8bc..64b2193 100644 --- a/views/controls/menu/menu_controller.cc +++ b/views/controls/menu/menu_controller.cc @@ -257,7 +257,7 @@ MenuController* MenuController::GetActiveInstance() { return active_instance_; } -MenuItemView* MenuController::Run(gfx::NativeWindow parent, +MenuItemView* MenuController::Run(Widget* parent, MenuButton* button, MenuItemView* root, const gfx::Rect& bounds, @@ -277,7 +277,7 @@ MenuItemView* MenuController::Run(gfx::NativeWindow parent, menu_stack_.push_back(state_); // The context menu should be owned by the same parent. - DCHECK(owner_ == parent); + DCHECK_EQ(owner_, parent); } else { showing_ = true; } @@ -1066,7 +1066,8 @@ bool MenuController::ShowSiblingMenu(SubmenuView* source, gfx::NativeWindow window_under_mouse = gfx::Screen::GetWindowAtCursorScreenPoint(); - if (window_under_mouse != owner_) + // TODO(oshima): Replace with views only API. + if (window_under_mouse != owner_->GetNativeWindow()) return false; // The user moved the mouse outside the menu and over the owning window. See diff --git a/views/controls/menu/menu_controller.h b/views/controls/menu/menu_controller.h index 7721a6e..83beb17 100644 --- a/views/controls/menu/menu_controller.h +++ b/views/controls/menu/menu_controller.h @@ -64,7 +64,7 @@ class MenuController : public MessageLoopForUI::Dispatcher { // Runs the menu at the specified location. If the menu was configured to // block, the selected item is returned. If the menu does not block this // returns NULL immediately. - MenuItemView* Run(gfx::NativeWindow parent, + MenuItemView* Run(Widget* parent, MenuButton* button, MenuItemView* root, const gfx::Rect& bounds, @@ -455,7 +455,7 @@ class MenuController : public MessageLoopForUI::Dispatcher { MenuDelegate::DropPosition drop_position_; // Owner of child windows. - gfx::NativeWindow owner_; + Widget* owner_; // Indicates a possible drag operation. bool possible_drag_; diff --git a/views/controls/menu/menu_host.cc b/views/controls/menu/menu_host.cc index f43800d..cd6a8ae 100644 --- a/views/controls/menu/menu_host.cc +++ b/views/controls/menu/menu_host.cc @@ -26,17 +26,13 @@ MenuHost::MenuHost(SubmenuView* submenu) MenuHost::~MenuHost() { } -void MenuHost::InitMenuHost(gfx::NativeWindow parent, +void MenuHost::InitMenuHost(Widget* parent, const gfx::Rect& bounds, View* contents_view, bool do_capture) { Widget::InitParams params(Widget::InitParams::TYPE_MENU); params.has_dropshadow = true; -#if defined(OS_WIN) - params.parent = parent; -#elif defined(TOOLKIT_USES_GTK) - params.parent = GTK_WIDGET(parent); -#endif + params.parent_widget = parent; params.bounds = bounds; Init(params); SetContentsView(contents_view); diff --git a/views/controls/menu/menu_host.h b/views/controls/menu/menu_host.h index 3edffb2..7fd76a6 100644 --- a/views/controls/menu/menu_host.h +++ b/views/controls/menu/menu_host.h @@ -7,7 +7,6 @@ #pragma once #include "base/compiler_specific.h" -#include "ui/gfx/native_widget_types.h" #include "ui/gfx/rect.h" #include "views/controls/menu/native_menu_host_delegate.h" #include "views/widget/widget.h" @@ -33,7 +32,7 @@ class MenuHost : public Widget { virtual ~MenuHost(); // Initializes and shows the MenuHost. - void InitMenuHost(gfx::NativeWindow parent, + void InitMenuHost(Widget* parent, const gfx::Rect& bounds, View* contents_view, bool do_capture); @@ -57,9 +56,6 @@ class MenuHost : public Widget { // Releases a mouse grab installed by |ShowMenuHost|. void ReleaseMenuHostCapture(); - // Returns the native window of the MenuHost. - gfx::NativeWindow GetMenuHostWindow(); - private: // Overridden from Widget: virtual internal::RootView* CreateRootView() OVERRIDE; diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc index e8f0026..eff0e39 100644 --- a/views/controls/menu/menu_item_view.cc +++ b/views/controls/menu/menu_item_view.cc @@ -171,7 +171,7 @@ string16 MenuItemView::GetAccessibleNameForMenuItem( return accessible_name; } -void MenuItemView::RunMenuAt(gfx::NativeWindow parent, +void MenuItemView::RunMenuAt(Widget* parent, MenuButton* button, const gfx::Rect& bounds, AnchorPosition anchor, @@ -231,7 +231,7 @@ void MenuItemView::RunMenuAt(gfx::NativeWindow parent, delegate_->ExecuteCommand(result->GetCommand(), mouse_event_flags); } -void MenuItemView::RunMenuForDropAt(gfx::NativeWindow parent, +void MenuItemView::RunMenuForDropAt(Widget* parent, const gfx::Rect& bounds, AnchorPosition anchor) { PrepareForRun(false, false); diff --git a/views/controls/menu/menu_item_view.h b/views/controls/menu/menu_item_view.h index ba2a365..1403729e 100644 --- a/views/controls/menu/menu_item_view.h +++ b/views/controls/menu/menu_item_view.h @@ -135,12 +135,12 @@ class MenuItemView : public View { // whether the items have mnemonics. Mnemonics are identified by way of the // character following the '&'. The anchor position is specified for non-RTL // languages; the opposite value will be used for RTL. - void RunMenuAt(gfx::NativeWindow parent, + void RunMenuAt(Widget* parent, MenuButton* button, const gfx::Rect& bounds, AnchorPosition anchor, bool has_mnemonics); - void RunMenuForDropAt(gfx::NativeWindow parent, + void RunMenuForDropAt(Widget* parent, const gfx::Rect& bounds, AnchorPosition anchor); diff --git a/views/controls/menu/menu_runner.cc b/views/controls/menu/menu_runner.cc index 78cb005..f210cc3 100644 --- a/views/controls/menu/menu_runner.cc +++ b/views/controls/menu/menu_runner.cc @@ -18,7 +18,7 @@ class MenuRunner::Holder { void Release(); // Runs the menu. - void RunMenuAt(gfx::NativeWindow parent, + void RunMenuAt(Widget* parent, MenuButton* button, const gfx::Rect& bounds, MenuItemView::AnchorPosition anchor, @@ -57,7 +57,7 @@ void MenuRunner::Holder::Release() { } } -void MenuRunner::Holder::RunMenuAt(gfx::NativeWindow parent, +void MenuRunner::Holder::RunMenuAt(Widget* parent, MenuButton* button, const gfx::Rect& bounds, MenuItemView::AnchorPosition anchor, @@ -81,7 +81,7 @@ MenuRunner::~MenuRunner() { holder_->Release(); } -void MenuRunner::RunMenuAt(gfx::NativeWindow parent, +void MenuRunner::RunMenuAt(Widget* parent, MenuButton* button, const gfx::Rect& bounds, MenuItemView::AnchorPosition anchor, diff --git a/views/controls/menu/menu_runner.h b/views/controls/menu/menu_runner.h index 4892b1e..3dfece5 100644 --- a/views/controls/menu/menu_runner.h +++ b/views/controls/menu/menu_runner.h @@ -13,6 +13,7 @@ namespace views { class MenuButton; +class Widget; // MenuRunner handles the lifetime of the root MenuItemView. MenuItemView runs a // nested message loop, which means care must be taken when the MenuItemView @@ -30,7 +31,7 @@ class MenuRunner { ~MenuRunner(); // Runs the menu. - void RunMenuAt(gfx::NativeWindow parent, + void RunMenuAt(Widget* parent, MenuButton* button, const gfx::Rect& bounds, MenuItemView::AnchorPosition anchor, diff --git a/views/controls/menu/submenu_view.cc b/views/controls/menu/submenu_view.cc index 987cf15..5664a8d 100644 --- a/views/controls/menu/submenu_view.cc +++ b/views/controls/menu/submenu_view.cc @@ -231,7 +231,7 @@ bool SubmenuView::IsShowing() { return host_ && host_->IsMenuHostVisible(); } -void SubmenuView::ShowAt(gfx::NativeWindow parent, +void SubmenuView::ShowAt(Widget* parent, const gfx::Rect& bounds, bool do_capture) { if (host_) { diff --git a/views/controls/menu/submenu_view.h b/views/controls/menu/submenu_view.h index 0caeffc..1ec627b 100644 --- a/views/controls/menu/submenu_view.h +++ b/views/controls/menu/submenu_view.h @@ -78,7 +78,7 @@ class SubmenuView : public View { // Shows the menu at the specified location. Coordinates are in screen // coordinates. max_width gives the max width the view should be. - void ShowAt(gfx::NativeWindow parent, + void ShowAt(Widget* parent, const gfx::Rect& bounds, bool do_capture); diff --git a/views/controls/textfield/native_textfield_views.cc b/views/controls/textfield/native_textfield_views.cc index b3f005d..c8ec99f 100644 --- a/views/controls/textfield/native_textfield_views.cc +++ b/views/controls/textfield/native_textfield_views.cc @@ -265,7 +265,7 @@ void NativeTextfieldViews::ShowContextMenuForView(View* source, const gfx::Point& p, bool is_mouse_gesture) { UpdateContextMenu(); - context_menu_menu_->RunMenuAt(GetWidget()->GetNativeWindow(), + context_menu_menu_->RunMenuAt(GetWidget(), NULL, gfx::Rect(p, gfx::Size()), views::MenuItemView::TOPLEFT, |