Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: ui/views/controls/menu/menu_controller.cc

Issue 11751002: views: Cancel menu selection on tap-cancel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/menu/menu_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 part.menu, *event)) { 526 part.menu, *event)) {
527 Accept(part.menu, 0); 527 Accept(part.menu, 0);
528 } 528 }
529 event->StopPropagation(); 529 event->StopPropagation();
530 } else if (part.type == MenuPart::MENU_ITEM) { 530 } else if (part.type == MenuPart::MENU_ITEM) {
531 // User either tapped on empty space, or a menu that has children. 531 // User either tapped on empty space, or a menu that has children.
532 SetSelection(part.menu ? part.menu : state_.item, 532 SetSelection(part.menu ? part.menu : state_.item,
533 SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY); 533 SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
534 event->StopPropagation(); 534 event->StopPropagation();
535 } 535 }
536 } else if (event->type() == ui::ET_GESTURE_TAP_CANCEL &&
537 pending_state_.item &&
sky 2013/01/08 04:47:03 Why the check for pending_state_.item here?
sadrul 2013/01/08 08:10:26 Hm. You are right. It looks like it's not necessar
538 part.type == MenuPart::MENU_ITEM) {
539 // Move the selection to the parent menu so that the selection in the
540 // current menu is unset. Make sure the submenu remains open by sending the
541 // appropriate SetSelectionTypes flags.
542 SetSelection(part.menu->GetParentMenuItem(),
sky 2013/01/08 04:47:03 parn->menu can be NULL even if type == MENU_ITEM.
sadrul 2013/01/08 08:10:26 Ah, I see. I have added a check for non-null part.
543 SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
544 event->StopPropagation();
536 } 545 }
546
537 if (event->stopped_propagation()) 547 if (event->stopped_propagation())
538 return; 548 return;
539 549
540 if (!part.submenu) 550 if (!part.submenu)
541 return; 551 return;
542 part.submenu->OnGestureEvent(event); 552 part.submenu->OnGestureEvent(event);
543 } 553 }
544 554
545 bool MenuController::GetDropFormats( 555 bool MenuController::GetDropFormats(
546 SubmenuView* source, 556 SubmenuView* source,
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 current_path[i]->SetSelected(false); 746 current_path[i]->SetSelected(false);
737 } 747 }
738 748
739 // Notify the new path it is selected. 749 // Notify the new path it is selected.
740 for (size_t i = paths_differ_at; i < new_size; ++i) 750 for (size_t i = paths_differ_at; i < new_size; ++i)
741 new_path[i]->SetSelected(true); 751 new_path[i]->SetSelected(true);
742 752
743 if (menu_item && menu_item->GetDelegate()) 753 if (menu_item && menu_item->GetDelegate())
744 menu_item->GetDelegate()->SelectionChanged(menu_item); 754 menu_item->GetDelegate()->SelectionChanged(menu_item);
745 755
746 // TODO(sky): convert back to DCHECK when figure out 93471. 756 DCHECK(menu_item || (selection_types & SELECTION_EXIT) != 0);
sadrul 2013/01/02 20:08:36 The bug is now fixed.
747 CHECK(menu_item || (selection_types & SELECTION_EXIT) != 0);
748 757
749 pending_state_.item = menu_item; 758 pending_state_.item = menu_item;
750 pending_state_.submenu_open = (selection_types & SELECTION_OPEN_SUBMENU) != 0; 759 pending_state_.submenu_open = (selection_types & SELECTION_OPEN_SUBMENU) != 0;
751 760
752 // Stop timers. 761 // Stop timers.
753 StopCancelAllTimer(); 762 StopCancelAllTimer();
754 // Resets show timer only when pending menu item is changed. 763 // Resets show timer only when pending menu item is changed.
755 if (pending_item_changed) 764 if (pending_item_changed)
756 StopShowTimer(); 765 StopShowTimer();
757 766
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 1534
1526 void MenuController::BuildMenuItemPath(MenuItemView* item, 1535 void MenuController::BuildMenuItemPath(MenuItemView* item,
1527 std::vector<MenuItemView*>* path) { 1536 std::vector<MenuItemView*>* path) {
1528 if (!item) 1537 if (!item)
1529 return; 1538 return;
1530 BuildMenuItemPath(item->GetParentMenuItem(), path); 1539 BuildMenuItemPath(item->GetParentMenuItem(), path);
1531 path->push_back(item); 1540 path->push_back(item);
1532 } 1541 }
1533 1542
1534 void MenuController::StartShowTimer() { 1543 void MenuController::StartShowTimer() {
1535 show_timer_.Start(FROM_HERE, 1544 show_timer_.Start(FROM_HERE,
1536 TimeDelta::FromMilliseconds(menu_config_.show_delay), 1545 TimeDelta::FromMilliseconds(menu_config_.show_delay),
1537 this, &MenuController::CommitPendingSelection); 1546 this, &MenuController::CommitPendingSelection);
1538 } 1547 }
1539 1548
1540 void MenuController::StopShowTimer() { 1549 void MenuController::StopShowTimer() {
1541 show_timer_.Stop(); 1550 show_timer_.Stop();
1542 } 1551 }
1543 1552
1544 void MenuController::StartCancelAllTimer() { 1553 void MenuController::StartCancelAllTimer() {
1545 cancel_all_timer_.Start(FROM_HERE, 1554 cancel_all_timer_.Start(FROM_HERE,
1546 TimeDelta::FromMilliseconds(kCloseOnExitTime), 1555 TimeDelta::FromMilliseconds(kCloseOnExitTime),
1547 this, &MenuController::CancelAll); 1556 this, &MenuController::CancelAll);
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 (!pending_state_.item->HasSubmenu() || 2145 (!pending_state_.item->HasSubmenu() ||
2137 !pending_state_.item->GetSubmenu()->IsShowing())) { 2146 !pending_state_.item->GetSubmenu()->IsShowing())) {
2138 // On exit if the user hasn't selected an item with a submenu, move the 2147 // On exit if the user hasn't selected an item with a submenu, move the
2139 // selection back to the parent menu item. 2148 // selection back to the parent menu item.
2140 SetSelection(pending_state_.item->GetParentMenuItem(), 2149 SetSelection(pending_state_.item->GetParentMenuItem(),
2141 SELECTION_OPEN_SUBMENU); 2150 SELECTION_OPEN_SUBMENU);
2142 } 2151 }
2143 } 2152 }
2144 2153
2145 } // namespace views 2154 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698