| 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 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1508 } | 1508 } |
| 1509 | 1509 |
| 1510 void MenuController::OpenMenuImpl(MenuItemView* item, bool show) { | 1510 void MenuController::OpenMenuImpl(MenuItemView* item, bool show) { |
| 1511 // TODO(oshima|sky): Don't show the menu if drag is in progress and | 1511 // TODO(oshima|sky): Don't show the menu if drag is in progress and |
| 1512 // this menu doesn't support drag drop. See crbug.com/110495. | 1512 // this menu doesn't support drag drop. See crbug.com/110495. |
| 1513 if (show) { | 1513 if (show) { |
| 1514 int old_count = item->GetSubmenu()->child_count(); | 1514 int old_count = item->GetSubmenu()->child_count(); |
| 1515 item->GetDelegate()->WillShowMenu(item); | 1515 item->GetDelegate()->WillShowMenu(item); |
| 1516 if (old_count != item->GetSubmenu()->child_count()) { | 1516 if (old_count != item->GetSubmenu()->child_count()) { |
| 1517 // If the number of children changed then we may need to add empty items. | 1517 // If the number of children changed then we may need to add empty items. |
| 1518 item->RemoveEmptyMenus(); |
| 1518 item->AddEmptyMenus(); | 1519 item->AddEmptyMenus(); |
| 1519 } | 1520 } |
| 1520 } | 1521 } |
| 1521 bool prefer_leading = | 1522 bool prefer_leading = |
| 1522 state_.open_leading.empty() ? true : state_.open_leading.back(); | 1523 state_.open_leading.empty() ? true : state_.open_leading.back(); |
| 1523 bool resulting_direction; | 1524 bool resulting_direction; |
| 1524 gfx::Rect bounds = MenuItemView::IsBubble(state_.anchor) ? | 1525 gfx::Rect bounds = MenuItemView::IsBubble(state_.anchor) ? |
| 1525 CalculateBubbleMenuBounds(item, prefer_leading, &resulting_direction) : | 1526 CalculateBubbleMenuBounds(item, prefer_leading, &resulting_direction) : |
| 1526 CalculateMenuBounds(item, prefer_leading, &resulting_direction); | 1527 CalculateMenuBounds(item, prefer_leading, &resulting_direction); |
| 1527 state_.open_leading.push_back(resulting_direction); | 1528 state_.open_leading.push_back(resulting_direction); |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2327 } | 2328 } |
| 2328 } | 2329 } |
| 2329 | 2330 |
| 2330 gfx::Screen* MenuController::GetScreen() { | 2331 gfx::Screen* MenuController::GetScreen() { |
| 2331 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; | 2332 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; |
| 2332 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) | 2333 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) |
| 2333 : gfx::Screen::GetNativeScreen(); | 2334 : gfx::Screen::GetNativeScreen(); |
| 2334 } | 2335 } |
| 2335 | 2336 |
| 2336 } // namespace views | 2337 } // namespace views |
| OLD | NEW |