Chromium Code Reviews| 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 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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()); | 1345 DCHECK(item->GetSubmenu()->IsShowing()); |
| 1346 | 1346 |
| 1347 // Currently this only supports adjusting the bounds of the last menu. | 1347 // If the current item is a descendant of the item that changed, |
| 1348 DCHECK(item == state_.item->GetParentMenuItem()); | 1348 // move the selection back to the changed item. |
| 1349 | 1349 const MenuItemView* ancestor = state_.item; |
|
sky
2011/05/11 14:26:10
You should update if either state_.item or pending
rhashimoto
2011/05/11 19:41:07
Done.
| |
| 1350 // Make sure the submenu isn't showing for the current item (the position may | 1350 while (ancestor && ancestor != item) |
| 1351 // have changed or the menu removed). This also moves the selection back to | 1351 ancestor = ancestor->GetParentMenuItem(); |
| 1352 // the parent, which handles the case where the selected item was removed. | 1352 if (ancestor) { |
| 1353 SetSelection(state_.item->GetParentMenuItem(), | 1353 SetSelection(item, SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY); |
| 1354 SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY); | 1354 OpenMenuImpl(item, false); |
|
sky
2011/05/11 14:26:10
You should only invoke OpenMenuItem if item has a
rhashimoto
2011/05/11 19:41:07
Done, though I think we only get here if the item
| |
| 1355 | 1355 } |
| 1356 OpenMenuImpl(item, false); | |
| 1357 } | 1356 } |
| 1358 | 1357 |
| 1359 void MenuController::BuildPathsAndCalculateDiff( | 1358 void MenuController::BuildPathsAndCalculateDiff( |
| 1360 MenuItemView* old_item, | 1359 MenuItemView* old_item, |
| 1361 MenuItemView* new_item, | 1360 MenuItemView* new_item, |
| 1362 std::vector<MenuItemView*>* old_path, | 1361 std::vector<MenuItemView*>* old_path, |
| 1363 std::vector<MenuItemView*>* new_path, | 1362 std::vector<MenuItemView*>* new_path, |
| 1364 size_t* first_diff_at) { | 1363 size_t* first_diff_at) { |
| 1365 DCHECK(old_path && new_path && first_diff_at); | 1364 DCHECK(old_path && new_path && first_diff_at); |
| 1366 BuildMenuItemPath(old_item, old_path); | 1365 BuildMenuItemPath(old_item, old_path); |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1857 return; | 1856 return; |
| 1858 | 1857 |
| 1859 // Reset the active_mouse_view_ before sending mouse capture lost. That way if | 1858 // 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. | 1859 // it calls back to us, we aren't in a weird state. |
| 1861 View* active_view = active_mouse_view_; | 1860 View* active_view = active_mouse_view_; |
| 1862 active_mouse_view_ = NULL; | 1861 active_mouse_view_ = NULL; |
| 1863 active_view->OnMouseCaptureLost(); | 1862 active_view->OnMouseCaptureLost(); |
| 1864 } | 1863 } |
| 1865 | 1864 |
| 1866 } // namespace views | 1865 } // namespace views |
| OLD | NEW |