| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/controls/menu/menu_controller.h" | 5 #include "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 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 showing_submenu_ = true; | 1335 showing_submenu_ = true; |
| 1336 if (show) | 1336 if (show) |
| 1337 item->GetSubmenu()->ShowAt(owner_, bounds, do_capture); | 1337 item->GetSubmenu()->ShowAt(owner_, bounds, do_capture); |
| 1338 else | 1338 else |
| 1339 item->GetSubmenu()->Reposition(bounds); | 1339 item->GetSubmenu()->Reposition(bounds); |
| 1340 showing_submenu_ = false; | 1340 showing_submenu_ = false; |
| 1341 } | 1341 } |
| 1342 | 1342 |
| 1343 void MenuController::MenuChildrenChanged(MenuItemView* item) { | 1343 void MenuController::MenuChildrenChanged(MenuItemView* item) { |
| 1344 DCHECK(item); | 1344 DCHECK(item); |
| 1345 DCHECK(item->GetSubmenu()->IsShowing()); | |
| 1346 | 1345 |
| 1347 // Currently this only supports adjusting the bounds of the last menu. | 1346 // If the current item or pending item is a descendant of the item |
| 1348 DCHECK(item == state_.item->GetParentMenuItem()); | 1347 // that changed, move the selection back to the changed item. |
| 1348 const MenuItemView* ancestor = state_.item; |
| 1349 while (ancestor && ancestor != item) |
| 1350 ancestor = ancestor->GetParentMenuItem(); |
| 1351 ancestor = ancestor ? ancestor : pending_state_.item; |
| 1352 while (ancestor && ancestor != item) |
| 1353 ancestor = ancestor->GetParentMenuItem(); |
| 1349 | 1354 |
| 1350 // Make sure the submenu isn't showing for the current item (the position may | 1355 if (ancestor) { |
| 1351 // have changed or the menu removed). This also moves the selection back to | 1356 SetSelection(item, SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY); |
| 1352 // the parent, which handles the case where the selected item was removed. | 1357 if (item->HasSubmenu()) |
| 1353 SetSelection(state_.item->GetParentMenuItem(), | 1358 OpenMenuImpl(item, false); |
| 1354 SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY); | 1359 } |
| 1355 | |
| 1356 OpenMenuImpl(item, false); | |
| 1357 } | 1360 } |
| 1358 | 1361 |
| 1359 void MenuController::BuildPathsAndCalculateDiff( | 1362 void MenuController::BuildPathsAndCalculateDiff( |
| 1360 MenuItemView* old_item, | 1363 MenuItemView* old_item, |
| 1361 MenuItemView* new_item, | 1364 MenuItemView* new_item, |
| 1362 std::vector<MenuItemView*>* old_path, | 1365 std::vector<MenuItemView*>* old_path, |
| 1363 std::vector<MenuItemView*>* new_path, | 1366 std::vector<MenuItemView*>* new_path, |
| 1364 size_t* first_diff_at) { | 1367 size_t* first_diff_at) { |
| 1365 DCHECK(old_path && new_path && first_diff_at); | 1368 DCHECK(old_path && new_path && first_diff_at); |
| 1366 BuildMenuItemPath(old_item, old_path); | 1369 BuildMenuItemPath(old_item, old_path); |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1857 return; | 1860 return; |
| 1858 | 1861 |
| 1859 // Reset the active_mouse_view_ before sending mouse capture lost. That way if | 1862 // Reset the active_mouse_view_ before sending mouse capture lost. That way if |
| 1860 // it calls back to us, we aren't in a weird state. | 1863 // it calls back to us, we aren't in a weird state. |
| 1861 View* active_view = active_mouse_view_; | 1864 View* active_view = active_mouse_view_; |
| 1862 active_mouse_view_ = NULL; | 1865 active_mouse_view_ = NULL; |
| 1863 active_view->OnMouseCaptureLost(); | 1866 active_view->OnMouseCaptureLost(); |
| 1864 } | 1867 } |
| 1865 | 1868 |
| 1866 } // namespace views | 1869 } // namespace views |
| OLD | NEW |