| 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/submenu_view.h" | 5 #include "ui/views/controls/menu/submenu_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "ui/base/accessibility/accessible_view_state.h" | 10 #include "ui/base/accessibility/accessible_view_state.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 drop_item_(NULL), | 37 drop_item_(NULL), |
| 38 drop_position_(MenuDelegate::DROP_NONE), | 38 drop_position_(MenuDelegate::DROP_NONE), |
| 39 scroll_view_container_(NULL), | 39 scroll_view_container_(NULL), |
| 40 max_accelerator_width_(0), | 40 max_accelerator_width_(0), |
| 41 minimum_preferred_width_(0), | 41 minimum_preferred_width_(0), |
| 42 resize_open_menu_(false), | 42 resize_open_menu_(false), |
| 43 ALLOW_THIS_IN_INITIALIZER_LIST( | 43 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 44 scroll_animator_(new ScrollAnimator(this))) { | 44 scroll_animator_(new ScrollAnimator(this))) { |
| 45 DCHECK(parent); | 45 DCHECK(parent); |
| 46 // We'll delete ourselves, otherwise the ScrollView would delete us on close. | 46 // We'll delete ourselves, otherwise the ScrollView would delete us on close. |
| 47 set_parent_owned(false); | 47 set_owned_by_client(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 SubmenuView::~SubmenuView() { | 50 SubmenuView::~SubmenuView() { |
| 51 // The menu may not have been closed yet (it will be hidden, but not | 51 // The menu may not have been closed yet (it will be hidden, but not |
| 52 // necessarily closed). | 52 // necessarily closed). |
| 53 Close(); | 53 Close(); |
| 54 | 54 |
| 55 delete scroll_view_container_; | 55 delete scroll_view_container_; |
| 56 } | 56 } |
| 57 | 57 |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 // Something is being dropped on one of this menus items. Show the | 347 // Something is being dropped on one of this menus items. Show the |
| 348 // selection if the drop is on the passed in item and the drop position is | 348 // selection if the drop is on the passed in item and the drop position is |
| 349 // ON. | 349 // ON. |
| 350 return (drop_item_ == item && drop_position_ == MenuDelegate::DROP_ON); | 350 return (drop_item_ == item && drop_position_ == MenuDelegate::DROP_ON); |
| 351 } | 351 } |
| 352 | 352 |
| 353 MenuScrollViewContainer* SubmenuView::GetScrollViewContainer() { | 353 MenuScrollViewContainer* SubmenuView::GetScrollViewContainer() { |
| 354 if (!scroll_view_container_) { | 354 if (!scroll_view_container_) { |
| 355 scroll_view_container_ = new MenuScrollViewContainer(this); | 355 scroll_view_container_ = new MenuScrollViewContainer(this); |
| 356 // Otherwise MenuHost would delete us. | 356 // Otherwise MenuHost would delete us. |
| 357 scroll_view_container_->set_parent_owned(false); | 357 scroll_view_container_->set_owned_by_client(); |
| 358 } | 358 } |
| 359 return scroll_view_container_; | 359 return scroll_view_container_; |
| 360 } | 360 } |
| 361 | 361 |
| 362 void SubmenuView::MenuHostDestroyed() { | 362 void SubmenuView::MenuHostDestroyed() { |
| 363 host_ = NULL; | 363 host_ = NULL; |
| 364 GetMenuItem()->GetMenuController()->Cancel(MenuController::EXIT_DESTROYED); | 364 GetMenuItem()->GetMenuController()->Cancel(MenuController::EXIT_DESTROYED); |
| 365 } | 365 } |
| 366 | 366 |
| 367 std::string SubmenuView::GetClassName() const { | 367 std::string SubmenuView::GetClassName() const { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 int y = vis_bounds.y() - static_cast<int>(dy); | 424 int y = vis_bounds.y() - static_cast<int>(dy); |
| 425 // clamp y to [0, full_height - vis_height) | 425 // clamp y to [0, full_height - vis_height) |
| 426 y = std::max(y, 0); | 426 y = std::max(y, 0); |
| 427 y = std::min(y, full_bounds.height() - vis_bounds.height() - 1); | 427 y = std::min(y, full_bounds.height() - vis_bounds.height() - 1); |
| 428 gfx::Rect new_vis_bounds(x, y, vis_bounds.width(), vis_bounds.height()); | 428 gfx::Rect new_vis_bounds(x, y, vis_bounds.width(), vis_bounds.height()); |
| 429 if (new_vis_bounds != vis_bounds) | 429 if (new_vis_bounds != vis_bounds) |
| 430 ScrollRectToVisible(new_vis_bounds); | 430 ScrollRectToVisible(new_vis_bounds); |
| 431 } | 431 } |
| 432 | 432 |
| 433 } // namespace views | 433 } // namespace views |
| OLD | NEW |