Chromium Code Reviews| 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/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1436 | 1436 |
| 1437 View* source_view = source->GetScrollViewContainer(); | 1437 View* source_view = source->GetScrollViewContainer(); |
| 1438 if (mouse_location.x() >= 0 && | 1438 if (mouse_location.x() >= 0 && |
| 1439 mouse_location.x() < source_view->width() && | 1439 mouse_location.x() < source_view->width() && |
| 1440 mouse_location.y() >= 0 && | 1440 mouse_location.y() >= 0 && |
| 1441 mouse_location.y() < source_view->height()) { | 1441 mouse_location.y() < source_view->height()) { |
| 1442 // The mouse is over the menu, no need to continue. | 1442 // The mouse is over the menu, no need to continue. |
| 1443 return false; | 1443 return false; |
| 1444 } | 1444 } |
| 1445 | 1445 |
| 1446 gfx::NativeWindow window_under_mouse = | |
| 1447 display::Screen::GetScreen()->GetWindowUnderCursor(); | |
| 1448 // TODO(oshima): Replace with views only API. | 1446 // TODO(oshima): Replace with views only API. |
| 1449 if (!owner_ || window_under_mouse != owner_->GetNativeWindow()) | 1447 bool window_under_mouse = display::Screen::GetScreen()-> |
| 1448 IsWindowUnderCursor(owner_->GetNativeWindow()); | |
|
sky
2016/05/02 23:01:43
This crashes if owner_ is null.
| |
| 1449 if (!owner_ || !window_under_mouse) | |
| 1450 return false; | 1450 return false; |
| 1451 | 1451 |
| 1452 // The user moved the mouse outside the menu and over the owning window. See | 1452 // The user moved the mouse outside the menu and over the owning window. See |
| 1453 // if there is a sibling menu we should show. | 1453 // if there is a sibling menu we should show. |
| 1454 gfx::Point screen_point(mouse_location); | 1454 gfx::Point screen_point(mouse_location); |
| 1455 View::ConvertPointToScreen(source_view, &screen_point); | 1455 View::ConvertPointToScreen(source_view, &screen_point); |
| 1456 MenuAnchorPosition anchor; | 1456 MenuAnchorPosition anchor; |
| 1457 bool has_mnemonics; | 1457 bool has_mnemonics; |
| 1458 MenuButton* button = NULL; | 1458 MenuButton* button = NULL; |
| 1459 MenuItemView* alt_menu = source->GetMenuItem()->GetDelegate()-> | 1459 MenuItemView* alt_menu = source->GetMenuItem()->GetDelegate()-> |
| (...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2673 return; | 2673 return; |
| 2674 } | 2674 } |
| 2675 if (hot_button_) | 2675 if (hot_button_) |
| 2676 hot_button_->SetHotTracked(false); | 2676 hot_button_->SetHotTracked(false); |
| 2677 hot_button_ = hot_button; | 2677 hot_button_ = hot_button; |
| 2678 if (hot_button) | 2678 if (hot_button) |
| 2679 hot_button->SetHotTracked(true); | 2679 hot_button->SetHotTracked(true); |
| 2680 } | 2680 } |
| 2681 | 2681 |
| 2682 } // namespace views | 2682 } // namespace views |
| OLD | NEW |