summaryrefslogtreecommitdiffstats
path: root/views/controls/menu/submenu_view.cc
diff options
context:
space:
mode:
Diffstat (limited to 'views/controls/menu/submenu_view.cc')
-rw-r--r--views/controls/menu/submenu_view.cc49
1 files changed, 29 insertions, 20 deletions
diff --git a/views/controls/menu/submenu_view.cc b/views/controls/menu/submenu_view.cc
index 117496d..a0d3f12 100644
--- a/views/controls/menu/submenu_view.cc
+++ b/views/controls/menu/submenu_view.cc
@@ -13,11 +13,19 @@
#include "views/widget/root_view.h"
#include "views/widget/widget.h"
+namespace {
+
// Height of the drop indicator. This should be an even number.
-static const int kDropIndicatorHeight = 2;
+const int kDropIndicatorHeight = 2;
// Color of the drop indicator.
-static const SkColor kDropIndicatorColor = SK_ColorBLACK;
+const SkColor kDropIndicatorColor = SK_ColorBLACK;
+
+// TODO(msw): Resolve crasher crbug.com/78792.
+const int kMagicInitialized = 0x346292;
+const int kMagicDestroyed = 0x9932CD;
+
+} // namespace
namespace views {
@@ -33,18 +41,23 @@ SubmenuView::SubmenuView(MenuItemView* parent)
drop_item_(NULL),
drop_position_(MenuDelegate::DROP_NONE),
scroll_view_container_(NULL),
- max_accelerator_width_(0) {
+ max_accelerator_width_(0),
+ magic_token_(kMagicInitialized) {
DCHECK(parent);
// We'll delete ourselves, otherwise the ScrollView would delete us on close.
set_parent_owned(false);
}
SubmenuView::~SubmenuView() {
+ CHECK_EQ(magic_token_, kMagicInitialized);
+
// The menu may not have been closed yet (it will be hidden, but not
// necessarily closed).
Close();
delete scroll_view_container_;
+
+ magic_token_ = kMagicDestroyed;
}
int SubmenuView::GetMenuItemCount() {
@@ -229,25 +242,15 @@ void SubmenuView::ShowAt(gfx::NativeWindow parent,
bool do_capture) {
if (host_) {
host_->ShowMenuHost(do_capture);
-
- GetScrollViewContainer()->GetWidget()->NotifyAccessibilityEvent(
- GetScrollViewContainer(),
- ui::AccessibilityTypes::EVENT_MENUSTART,
- true);
- GetWidget()->NotifyAccessibilityEvent(
- this,
- ui::AccessibilityTypes::EVENT_MENUPOPUPSTART,
- true);
- return;
+ } else {
+ host_ = new MenuHost(this);
+ // Force construction of the scroll view container.
+ GetScrollViewContainer();
+ // Make sure the first row is visible.
+ ScrollRectToVisible(gfx::Rect(gfx::Point(), gfx::Size(1, 1)));
+ host_->InitMenuHost(parent, bounds, scroll_view_container_, do_capture);
}
- host_ = new MenuHost(this);
- // Force construction of the scroll view container.
- GetScrollViewContainer();
- // Make sure the first row is visible.
- ScrollRectToVisible(gfx::Rect(gfx::Point(), gfx::Size(1, 1)));
- host_->InitMenuHost(parent, bounds, scroll_view_container_, do_capture);
-
GetScrollViewContainer()->GetWidget()->NotifyAccessibilityEvent(
GetScrollViewContainer(),
ui::AccessibilityTypes::EVENT_MENUSTART,
@@ -293,6 +296,11 @@ bool SubmenuView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) {
return views::FocusManager::IsTabTraversalKeyEvent(e);
}
+MenuItemView* SubmenuView::GetMenuItem() const {
+ CHECK_EQ(magic_token_, kMagicInitialized);
+ return parent_menu_item_;
+}
+
void SubmenuView::SetDropMenuItem(MenuItemView* item,
MenuDelegate::DropPosition position) {
if (drop_item_ == item && drop_position_ == position)
@@ -313,6 +321,7 @@ bool SubmenuView::GetShowSelection(MenuItemView* item) {
}
MenuScrollViewContainer* SubmenuView::GetScrollViewContainer() {
+ CHECK_EQ(magic_token_, kMagicInitialized);
if (!scroll_view_container_) {
scroll_view_container_ = new MenuScrollViewContainer(this);
// Otherwise MenuHost would delete us.