| 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/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1571 this, &MenuController::CommitPendingSelection); | 1571 this, &MenuController::CommitPendingSelection); |
| 1572 } | 1572 } |
| 1573 | 1573 |
| 1574 void MenuController::StopShowTimer() { | 1574 void MenuController::StopShowTimer() { |
| 1575 show_timer_.Stop(); | 1575 show_timer_.Stop(); |
| 1576 } | 1576 } |
| 1577 | 1577 |
| 1578 void MenuController::StartCancelAllTimer() { | 1578 void MenuController::StartCancelAllTimer() { |
| 1579 cancel_all_timer_.Start(FROM_HERE, | 1579 cancel_all_timer_.Start(FROM_HERE, |
| 1580 TimeDelta::FromMilliseconds(kCloseOnExitTime), | 1580 TimeDelta::FromMilliseconds(kCloseOnExitTime), |
| 1581 this, &MenuController::CancelAll); | 1581 this, &MenuController::CancelAllForDrag); |
| 1582 } | 1582 } |
| 1583 | 1583 |
| 1584 void MenuController::StopCancelAllTimer() { | 1584 void MenuController::StopCancelAllTimer() { |
| 1585 cancel_all_timer_.Stop(); | 1585 cancel_all_timer_.Stop(); |
| 1586 } | 1586 } |
| 1587 | 1587 |
| 1588 void MenuController::CancelAllForDrag() { |
| 1589 // It's possible that a child View will be in the middle of a drag-and-drop |
| 1590 // operation that we didn't get events for (since we only get updated for |
| 1591 // MenuItemViews). If so, just restart the cancel timer. |
| 1592 if (state_.item && |
| 1593 state_.item->GetDelegate() && |
| 1594 state_.item->GetDelegate()->InNestedDrag()) |
| 1595 StartCancelAllTimer(); |
| 1596 else |
| 1597 CancelAll(); |
| 1598 } |
| 1599 |
| 1588 gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item, | 1600 gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item, |
| 1589 bool prefer_leading, | 1601 bool prefer_leading, |
| 1590 bool* is_leading) { | 1602 bool* is_leading) { |
| 1591 DCHECK(item); | 1603 DCHECK(item); |
| 1592 | 1604 |
| 1593 SubmenuView* submenu = item->GetSubmenu(); | 1605 SubmenuView* submenu = item->GetSubmenu(); |
| 1594 DCHECK(submenu); | 1606 DCHECK(submenu); |
| 1595 | 1607 |
| 1596 gfx::Size pref = submenu->GetScrollViewContainer()->GetPreferredSize(); | 1608 gfx::Size pref = submenu->GetScrollViewContainer()->GetPreferredSize(); |
| 1597 | 1609 |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2299 } | 2311 } |
| 2300 } | 2312 } |
| 2301 | 2313 |
| 2302 gfx::Screen* MenuController::GetScreen() { | 2314 gfx::Screen* MenuController::GetScreen() { |
| 2303 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; | 2315 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; |
| 2304 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) | 2316 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) |
| 2305 : gfx::Screen::GetNativeScreen(); | 2317 : gfx::Screen::GetNativeScreen(); |
| 2306 } | 2318 } |
| 2307 | 2319 |
| 2308 } // namespace views | 2320 } // namespace views |
| OLD | NEW |