Chromium Code Reviews| 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/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 1886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1897 } | 1897 } |
| 1898 | 1898 |
| 1899 void MenuController::IncrementSelection(int delta) { | 1899 void MenuController::IncrementSelection(int delta) { |
| 1900 MenuItemView* item = pending_state_.item; | 1900 MenuItemView* item = pending_state_.item; |
| 1901 DCHECK(item); | 1901 DCHECK(item); |
| 1902 if (pending_state_.submenu_open && item->HasSubmenu() && | 1902 if (pending_state_.submenu_open && item->HasSubmenu() && |
| 1903 item->GetSubmenu()->IsShowing()) { | 1903 item->GetSubmenu()->IsShowing()) { |
| 1904 // A menu is selected and open, but none of its children are selected, | 1904 // A menu is selected and open, but none of its children are selected, |
| 1905 // select the first menu item that is visible and enabled. | 1905 // select the first menu item that is visible and enabled. |
| 1906 if (item->GetSubmenu()->GetMenuItemCount()) { | 1906 if (item->GetSubmenu()->GetMenuItemCount()) { |
| 1907 MenuItemView* to_select = FindFirstSelectableMenuItem(item); | 1907 MenuItemView* to_select = FindFirstSelectableMenuItem(item); |
|
sadrul
2015/07/14 04:17:41
Hm. Perhaps we could add delta to FindFirstSelecta
varkha
2015/07/14 16:22:54
Done.
| |
| 1908 if (to_select) | 1908 if (to_select) |
| 1909 SetSelection(to_select, SELECTION_DEFAULT); | 1909 SetSelection(to_select, SELECTION_DEFAULT); |
| 1910 return; | 1910 if (delta == 1 || !to_select) |
| 1911 return; | |
| 1912 // When decrementing fall through to select a previous item. | |
| 1913 item = to_select; | |
| 1911 } | 1914 } |
| 1912 } | 1915 } |
| 1913 | 1916 |
| 1914 if (item->has_children()) { | 1917 if (item->has_children()) { |
| 1915 CustomButton* button = GetFirstHotTrackedView(item); | 1918 CustomButton* button = GetFirstHotTrackedView(item); |
| 1916 if (button) { | 1919 if (button) { |
| 1917 button->SetHotTracked(false); | 1920 button->SetHotTracked(false); |
| 1918 View* to_make_hot = GetNextFocusableView(item, button, delta == 1); | 1921 View* to_make_hot = GetNextFocusableView(item, button, delta == 1); |
| 1919 CustomButton* button_hot = CustomButton::AsCustomButton(to_make_hot); | 1922 CustomButton* button_hot = CustomButton::AsCustomButton(to_make_hot); |
| 1920 if (button_hot) { | 1923 if (button_hot) { |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2357 } | 2360 } |
| 2358 } | 2361 } |
| 2359 | 2362 |
| 2360 gfx::Screen* MenuController::GetScreen() { | 2363 gfx::Screen* MenuController::GetScreen() { |
| 2361 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; | 2364 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; |
| 2362 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) | 2365 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) |
| 2363 : gfx::Screen::GetNativeScreen(); | 2366 : gfx::Screen::GetNativeScreen(); |
| 2364 } | 2367 } |
| 2365 | 2368 |
| 2366 } // namespace views | 2369 } // namespace views |
| OLD | NEW |