| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/controls/menu/menu_controller.h" | 5 #include "ui/views/controls/menu/menu_controller.h" |
| 6 | 6 |
| 7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 return true; | 928 return true; |
| 929 default: | 929 default: |
| 930 break; | 930 break; |
| 931 } | 931 } |
| 932 | 932 |
| 933 aura::Env::GetInstance()->GetDispatcher()->Dispatch(event); | 933 aura::Env::GetInstance()->GetDispatcher()->Dispatch(event); |
| 934 return exit_type_ == EXIT_NONE; | 934 return exit_type_ == EXIT_NONE; |
| 935 } | 935 } |
| 936 #endif | 936 #endif |
| 937 | 937 |
| 938 bool MenuController::ShouldExit() OVERRIDE { |
| 939 return exit_type_ != EXIT_NONE; |
| 940 } |
| 941 |
| 938 bool MenuController::OnKeyDown(ui::KeyboardCode key_code) { | 942 bool MenuController::OnKeyDown(ui::KeyboardCode key_code) { |
| 939 DCHECK(blocking_run_); | 943 DCHECK(blocking_run_); |
| 940 | 944 |
| 941 switch (key_code) { | 945 switch (key_code) { |
| 942 case ui::VKEY_UP: | 946 case ui::VKEY_UP: |
| 943 IncrementSelection(-1); | 947 IncrementSelection(-1); |
| 944 break; | 948 break; |
| 945 | 949 |
| 946 case ui::VKEY_DOWN: | 950 case ui::VKEY_DOWN: |
| 947 IncrementSelection(1); | 951 IncrementSelection(1); |
| (...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1965 | 1969 |
| 1966 // Reset the active_mouse_view_ before sending mouse capture lost. That way if | 1970 // Reset the active_mouse_view_ before sending mouse capture lost. That way if |
| 1967 // it calls back to us, we aren't in a weird state. | 1971 // it calls back to us, we aren't in a weird state. |
| 1968 View* active_view = active_mouse_view_; | 1972 View* active_view = active_mouse_view_; |
| 1969 active_mouse_view_ = NULL; | 1973 active_mouse_view_ = NULL; |
| 1970 active_view->OnMouseCaptureLost(); | 1974 active_view->OnMouseCaptureLost(); |
| 1971 } | 1975 } |
| 1972 | 1976 |
| 1973 void MenuController::SetExitType(ExitType type) { | 1977 void MenuController::SetExitType(ExitType type) { |
| 1974 exit_type_ = type; | 1978 exit_type_ = type; |
| 1975 #if defined(USE_AURA) | |
| 1976 // On aura, closing menu may not trigger next native event, which | |
| 1977 // is necessary to exit from nested loop (See Dispatch methods). | |
| 1978 // Send non-op event so that Dispatch method will always be called. | |
| 1979 // crbug.com/104684. | |
| 1980 if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) { | |
| 1981 owner_->GetNativeView()->GetRootWindow()->PostNativeEvent( | |
| 1982 ui::CreateNoopEvent()); | |
| 1983 } | |
| 1984 #endif | |
| 1985 } | 1979 } |
| 1986 | 1980 |
| 1987 void MenuController::HandleMouseLocation(SubmenuView* source, | 1981 void MenuController::HandleMouseLocation(SubmenuView* source, |
| 1988 const gfx::Point& mouse_location) { | 1982 const gfx::Point& mouse_location) { |
| 1989 if (showing_submenu_) | 1983 if (showing_submenu_) |
| 1990 return; | 1984 return; |
| 1991 | 1985 |
| 1992 MenuPart part = GetMenuPart(source, mouse_location); | 1986 MenuPart part = GetMenuPart(source, mouse_location); |
| 1993 | 1987 |
| 1994 UpdateScrolling(part); | 1988 UpdateScrolling(part); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2006 (!pending_state_.item->HasSubmenu() || | 2000 (!pending_state_.item->HasSubmenu() || |
| 2007 !pending_state_.item->GetSubmenu()->IsShowing())) { | 2001 !pending_state_.item->GetSubmenu()->IsShowing())) { |
| 2008 // On exit if the user hasn't selected an item with a submenu, move the | 2002 // On exit if the user hasn't selected an item with a submenu, move the |
| 2009 // selection back to the parent menu item. | 2003 // selection back to the parent menu item. |
| 2010 SetSelection(pending_state_.item->GetParentMenuItem(), | 2004 SetSelection(pending_state_.item->GetParentMenuItem(), |
| 2011 SELECTION_OPEN_SUBMENU); | 2005 SELECTION_OPEN_SUBMENU); |
| 2012 } | 2006 } |
| 2013 } | 2007 } |
| 2014 | 2008 |
| 2015 } // namespace views | 2009 } // namespace views |
| OLD | NEW |