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/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 UpdateActiveMouseView(source, event, mouse_menu); | 468 UpdateActiveMouseView(source, event, mouse_menu); |
469 } | 469 } |
470 | 470 |
471 void MenuController::OnMouseReleased(SubmenuView* source, | 471 void MenuController::OnMouseReleased(SubmenuView* source, |
472 const MouseEvent& event) { | 472 const MouseEvent& event) { |
473 if (!blocking_run_) | 473 if (!blocking_run_) |
474 return; | 474 return; |
475 | 475 |
476 // We must ignore the first release event when it occured within the original | 476 // We must ignore the first release event when it occured within the original |
477 // bounds. | 477 // bounds. |
478 if (drop_first_release_event_ && event.flags() == ui::EF_LEFT_MOUSE_BUTTON) { | 478 if (drop_first_release_event_ && (event.flags() & ui::EF_LEFT_MOUSE_BUTTON)) { |
479 drop_first_release_event_ = false; | 479 drop_first_release_event_ = false; |
480 gfx::Point loc(event.location()); | 480 gfx::Point loc(event.location()); |
481 View::ConvertPointToScreen(source->GetScrollViewContainer(), &loc); | 481 View::ConvertPointToScreen(source->GetScrollViewContainer(), &loc); |
482 DCHECK(!state_.initial_bounds.IsEmpty()); | 482 DCHECK(!state_.initial_bounds.IsEmpty()); |
483 if (state_.initial_bounds.Contains(loc)) | 483 if (state_.initial_bounds.Contains(loc)) |
484 return; | 484 return; |
485 } | 485 } |
486 drop_first_release_event_ = false; | 486 drop_first_release_event_ = false; |
487 | 487 |
488 DCHECK(state_.item); | 488 DCHECK(state_.item); |
489 possible_drag_ = false; | 489 possible_drag_ = false; |
490 DCHECK(blocking_run_); | 490 DCHECK(blocking_run_); |
491 MenuPart part = GetMenuPart(source, event.location()); | 491 MenuPart part = GetMenuPart(source, event.location()); |
492 if (event.IsRightMouseButton() && (part.type == MenuPart::MENU_ITEM && | 492 if (event.IsRightMouseButton() && (part.type == MenuPart::MENU_ITEM && |
493 part.menu)) { | 493 part.menu)) { |
494 if (ShowContextMenu(part.menu, source, event)) | 494 if (ShowContextMenu(part.menu, source, event)) |
495 return; | 495 return; |
496 } | 496 } |
497 | 497 |
498 // We can use Ctrl+click or the middle mouse button to recursively open urls | 498 // We can use Ctrl+click or the middle mouse button to recursively open urls |
499 // for selected folder menu items. If it's only a left click, show the | 499 // for selected folder menu items. If it's only a left click, show the |
500 // contents of the folder. | 500 // contents of the folder. |
501 if (!part.is_scroll() && part.menu && | 501 if (!part.is_scroll() && part.menu && |
502 !(part.menu->HasSubmenu() && | 502 !(part.menu->HasSubmenu() && |
503 (event.flags() == ui::EF_LEFT_MOUSE_BUTTON))) { | 503 (event.flags() & ui::EF_LEFT_MOUSE_BUTTON))) { |
504 if (active_mouse_view_) { | 504 if (active_mouse_view_) { |
505 SendMouseReleaseToActiveView(source, event); | 505 SendMouseReleaseToActiveView(source, event); |
506 return; | 506 return; |
507 } | 507 } |
508 if (part.menu->GetDelegate()->IsTriggerableEvent(part.menu, event)) { | 508 if (part.menu->GetDelegate()->IsTriggerableEvent(part.menu, event)) { |
509 Accept(part.menu, event.flags()); | 509 Accept(part.menu, event.flags()); |
510 return; | 510 return; |
511 } | 511 } |
512 } else if (part.type == MenuPart::MENU_ITEM) { | 512 } else if (part.type == MenuPart::MENU_ITEM) { |
513 // User either clicked on empty space, or a menu that has children. | 513 // User either clicked on empty space, or a menu that has children. |
(...skipping 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2140 | 2140 |
2141 #if defined(USE_AURA) | 2141 #if defined(USE_AURA) |
2142 void MenuController::OnWindowActivated(aura::Window* active, | 2142 void MenuController::OnWindowActivated(aura::Window* active, |
2143 aura::Window* old_active) { | 2143 aura::Window* old_active) { |
2144 if (!drag_in_progress_) | 2144 if (!drag_in_progress_) |
2145 Cancel(EXIT_ALL); | 2145 Cancel(EXIT_ALL); |
2146 } | 2146 } |
2147 #endif | 2147 #endif |
2148 | 2148 |
2149 } // namespace views | 2149 } // namespace views |
OLD | NEW |