| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/os_exchange_data.h" | 8 #include "app/os_exchange_data.h" |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/keyboard_codes.h" | 10 #include "base/keyboard_codes.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 showing_ = true; | 239 showing_ = true; |
| 240 } | 240 } |
| 241 | 241 |
| 242 // Reset current state. | 242 // Reset current state. |
| 243 pending_state_ = State(); | 243 pending_state_ = State(); |
| 244 state_ = State(); | 244 state_ = State(); |
| 245 UpdateInitialLocation(bounds, position); | 245 UpdateInitialLocation(bounds, position); |
| 246 | 246 |
| 247 owner_ = parent; | 247 owner_ = parent; |
| 248 | 248 |
| 249 if (button) | |
| 250 button->NotifyAccessibilityEvent(AccessibilityTypes::EVENT_MENUPOPUPSTART); | |
| 251 | |
| 252 // Set the selection, which opens the initial menu. | 249 // Set the selection, which opens the initial menu. |
| 253 SetSelection(root, true, true); | 250 SetSelection(root, true, true); |
| 254 | 251 |
| 255 if (!blocking_run_) { | 252 if (!blocking_run_) { |
| 256 // Start the timer to hide the menu. This is needed as we get no | 253 // Start the timer to hide the menu. This is needed as we get no |
| 257 // notification when the drag has finished. | 254 // notification when the drag has finished. |
| 258 StartCancelAllTimer(); | 255 StartCancelAllTimer(); |
| 259 return NULL; | 256 return NULL; |
| 260 } else if (button) { | 257 } else if (button) { |
| 261 menu_button_ = button; | 258 menu_button_ = button; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 if (update_immediately) | 371 if (update_immediately) |
| 375 CommitPendingSelection(); | 372 CommitPendingSelection(); |
| 376 else | 373 else |
| 377 StartShowTimer(); | 374 StartShowTimer(); |
| 378 | 375 |
| 379 // Notify an accessibility focus event on all menu items except for the root. | 376 // Notify an accessibility focus event on all menu items except for the root. |
| 380 if (menu_item && | 377 if (menu_item && |
| 381 (MenuDepth(menu_item) != 1 || | 378 (MenuDepth(menu_item) != 1 || |
| 382 menu_item->GetType() != MenuItemView::SUBMENU)) | 379 menu_item->GetType() != MenuItemView::SUBMENU)) |
| 383 menu_item->NotifyAccessibilityEvent(AccessibilityTypes::EVENT_FOCUS); | 380 menu_item->NotifyAccessibilityEvent(AccessibilityTypes::EVENT_FOCUS); |
| 384 | |
| 385 if (menu_button_ && !menu_item && exit_type_ != EXIT_DESTROYED) { | |
| 386 menu_button_-> | |
| 387 NotifyAccessibilityEvent(AccessibilityTypes::EVENT_MENUPOPUPEND); | |
| 388 } | |
| 389 } | 381 } |
| 390 | 382 |
| 391 void MenuController::Cancel(ExitType type) { | 383 void MenuController::Cancel(ExitType type) { |
| 392 if (!showing_) { | 384 if (!showing_) { |
| 393 // This occurs if we're in the process of notifying the delegate for a drop | 385 // This occurs if we're in the process of notifying the delegate for a drop |
| 394 // and the delegate cancels us. | 386 // and the delegate cancels us. |
| 395 return; | 387 return; |
| 396 } | 388 } |
| 397 | 389 |
| 398 MenuItemView* selected = state_.item; | 390 MenuItemView* selected = state_.item; |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 default: | 798 default: |
| 807 break; | 799 break; |
| 808 } | 800 } |
| 809 TranslateMessage(&msg); | 801 TranslateMessage(&msg); |
| 810 DispatchMessage(&msg); | 802 DispatchMessage(&msg); |
| 811 return exit_type_ == EXIT_NONE; | 803 return exit_type_ == EXIT_NONE; |
| 812 } | 804 } |
| 813 | 805 |
| 814 #else | 806 #else |
| 815 bool MenuController::Dispatch(GdkEvent* event) { | 807 bool MenuController::Dispatch(GdkEvent* event) { |
| 816 | |
| 817 if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) { | 808 if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) { |
| 818 gtk_main_do_event(event); | 809 gtk_main_do_event(event); |
| 819 return false; | 810 return false; |
| 820 } | 811 } |
| 821 | 812 |
| 822 switch (event->type) { | 813 switch (event->type) { |
| 823 case GDK_KEY_PRESS: { | 814 case GDK_KEY_PRESS: { |
| 824 base::KeyboardCode win_keycode = | 815 base::KeyboardCode win_keycode = |
| 825 base::WindowsKeyCodeForGdkKeyCode(event->key.keyval); | 816 base::WindowsKeyCodeForGdkKeyCode(event->key.keyval); |
| 826 | 817 |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 std::list<bool> pending_open_direction; | 1195 std::list<bool> pending_open_direction; |
| 1205 state_.open_leading.swap(pending_open_direction); | 1196 state_.open_leading.swap(pending_open_direction); |
| 1206 state_ = pending_state_; | 1197 state_ = pending_state_; |
| 1207 state_.open_leading.swap(pending_open_direction); | 1198 state_.open_leading.swap(pending_open_direction); |
| 1208 | 1199 |
| 1209 int menu_depth = MenuDepth(state_.item); | 1200 int menu_depth = MenuDepth(state_.item); |
| 1210 if (menu_depth == 0) { | 1201 if (menu_depth == 0) { |
| 1211 state_.open_leading.clear(); | 1202 state_.open_leading.clear(); |
| 1212 } else { | 1203 } else { |
| 1213 int cached_size = static_cast<int>(state_.open_leading.size()); | 1204 int cached_size = static_cast<int>(state_.open_leading.size()); |
| 1214 DCHECK(menu_depth >= 0); | 1205 DCHECK_GE(menu_depth, 0); |
| 1215 while (cached_size-- >= menu_depth) | 1206 while (cached_size-- >= menu_depth) |
| 1216 state_.open_leading.pop_back(); | 1207 state_.open_leading.pop_back(); |
| 1217 } | 1208 } |
| 1218 | 1209 |
| 1219 if (!state_.item) { | 1210 if (!state_.item) { |
| 1220 // Nothing to select. | 1211 // Nothing to select. |
| 1221 StopScrolling(); | 1212 StopScrolling(); |
| 1222 return; | 1213 return; |
| 1223 } | 1214 } |
| 1224 | 1215 |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1771 | 1762 |
| 1772 MouseEvent release_event(Event::ET_MOUSE_RELEASED, -1, -1, 0); | 1763 MouseEvent release_event(Event::ET_MOUSE_RELEASED, -1, -1, 0); |
| 1773 // Reset the active_mouse_view_ before sending mouse released. That way if if | 1764 // Reset the active_mouse_view_ before sending mouse released. That way if if |
| 1774 // calls back to use we aren't in a weird state. | 1765 // calls back to use we aren't in a weird state. |
| 1775 View* active_view = active_mouse_view_; | 1766 View* active_view = active_mouse_view_; |
| 1776 active_mouse_view_ = NULL; | 1767 active_mouse_view_ = NULL; |
| 1777 active_view->OnMouseReleased(release_event, true); | 1768 active_view->OnMouseReleased(release_event, true); |
| 1778 } | 1769 } |
| 1779 | 1770 |
| 1780 } // namespace views | 1771 } // namespace views |
| OLD | NEW |