Commit fee73e22 authored by Charlene Yan's avatar Charlene Yan Committed by Commit Bot

Renamed MenuButtonEventHandler to MenuButtonController since it contains more...

Renamed MenuButtonEventHandler to MenuButtonController since it contains more than just EventHandling logic.

Bug: 901183
Change-Id: Ibb983144b9f5713d69298ca5dff13dc3de9d7c65
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1539917Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Commit-Queue: Charlene Yan <cyan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644615}
parent c20ae7ee
...@@ -300,7 +300,7 @@ void ToolbarActionView::OnPopupShown(bool by_user) { ...@@ -300,7 +300,7 @@ void ToolbarActionView::OnPopupShown(bool by_user) {
// or delegate_->GetOverflowReferenceView(), which returns a MenuButton. // or delegate_->GetOverflowReferenceView(), which returns a MenuButton.
views::MenuButton* reference_view = views::MenuButton* reference_view =
static_cast<views::MenuButton*>(GetReferenceViewForPopup()); static_cast<views::MenuButton*>(GetReferenceViewForPopup());
pressed_lock_ = reference_view->menu_button_event_handler()->TakeLock(); pressed_lock_ = reference_view->menu_button_controller()->TakeLock();
} }
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "chrome/browser/ui/views/toolbar/toolbar_action_view_delegate_views.h" #include "chrome/browser/ui/views/toolbar/toolbar_action_view_delegate_views.h"
#include "ui/views/context_menu_controller.h" #include "ui/views/context_menu_controller.h"
#include "ui/views/controls/button/menu_button.h" #include "ui/views/controls/button/menu_button.h"
#include "ui/views/controls/button/menu_button_event_handler.h" #include "ui/views/controls/button/menu_button_controller.h"
#include "ui/views/controls/button/menu_button_listener.h" #include "ui/views/controls/button/menu_button_listener.h"
#include "ui/views/controls/menu/menu_model_adapter.h" #include "ui/views/controls/menu/menu_model_adapter.h"
#include "ui/views/drag_controller.h" #include "ui/views/drag_controller.h"
...@@ -133,7 +133,7 @@ class ToolbarActionView : public views::MenuButton, ...@@ -133,7 +133,7 @@ class ToolbarActionView : public views::MenuButton,
void OnMenuClosed(); void OnMenuClosed();
// A lock to keep the MenuButton pressed when a menu or popup is visible. // A lock to keep the MenuButton pressed when a menu or popup is visible.
std::unique_ptr<views::MenuButtonEventHandler::PressedLock> pressed_lock_; std::unique_ptr<views::MenuButtonController::PressedLock> pressed_lock_;
// The controller for this toolbar action view. // The controller for this toolbar action view.
ToolbarActionViewController* view_controller_; ToolbarActionViewController* view_controller_;
......
...@@ -111,7 +111,7 @@ jumbo_component("views") { ...@@ -111,7 +111,7 @@ jumbo_component("views") {
"controls/button/label_button_border.h", "controls/button/label_button_border.h",
"controls/button/md_text_button.h", "controls/button/md_text_button.h",
"controls/button/menu_button.h", "controls/button/menu_button.h",
"controls/button/menu_button_event_handler.h", "controls/button/menu_button_controller.h",
"controls/button/menu_button_listener.h", "controls/button/menu_button_listener.h",
"controls/button/radio_button.h", "controls/button/radio_button.h",
"controls/button/toggle_button.h", "controls/button/toggle_button.h",
...@@ -322,7 +322,7 @@ jumbo_component("views") { ...@@ -322,7 +322,7 @@ jumbo_component("views") {
"controls/button/label_button_border.cc", "controls/button/label_button_border.cc",
"controls/button/md_text_button.cc", "controls/button/md_text_button.cc",
"controls/button/menu_button.cc", "controls/button/menu_button.cc",
"controls/button/menu_button_event_handler.cc", "controls/button/menu_button_controller.cc",
"controls/button/radio_button.cc", "controls/button/radio_button.cc",
"controls/button/toggle_button.cc", "controls/button/toggle_button.cc",
"controls/combobox/combobox.cc", "controls/combobox/combobox.cc",
......
...@@ -21,18 +21,18 @@ MenuButton::MenuButton(const base::string16& text, ...@@ -21,18 +21,18 @@ MenuButton::MenuButton(const base::string16& text,
MenuButtonListener* menu_button_listener, MenuButtonListener* menu_button_listener,
int button_context) int button_context)
: LabelButton(nullptr, text, button_context), : LabelButton(nullptr, text, button_context),
menu_button_event_handler_(this, menu_button_listener) { menu_button_controller_(this, menu_button_listener) {
SetHorizontalAlignment(gfx::ALIGN_LEFT); SetHorizontalAlignment(gfx::ALIGN_LEFT);
} }
MenuButton::~MenuButton() = default; MenuButton::~MenuButton() = default;
bool MenuButton::Activate(const ui::Event* event) { bool MenuButton::Activate(const ui::Event* event) {
return menu_button_event_handler_.Activate(event); return menu_button_controller_.Activate(event);
} }
bool MenuButton::IsTriggerableEventType(const ui::Event& event) { bool MenuButton::IsTriggerableEventType(const ui::Event& event) {
return menu_button_event_handler_.IsTriggerableEventType(event); return menu_button_controller_.IsTriggerableEventType(event);
} }
const char* MenuButton::GetClassName() const { const char* MenuButton::GetClassName() const {
...@@ -40,23 +40,23 @@ const char* MenuButton::GetClassName() const { ...@@ -40,23 +40,23 @@ const char* MenuButton::GetClassName() const {
} }
bool MenuButton::OnMousePressed(const ui::MouseEvent& event) { bool MenuButton::OnMousePressed(const ui::MouseEvent& event) {
return menu_button_event_handler_.OnMousePressed(event); return menu_button_controller_.OnMousePressed(event);
} }
void MenuButton::OnMouseReleased(const ui::MouseEvent& event) { void MenuButton::OnMouseReleased(const ui::MouseEvent& event) {
menu_button_event_handler_.OnMouseReleased(event); menu_button_controller_.OnMouseReleased(event);
} }
bool MenuButton::OnKeyPressed(const ui::KeyEvent& event) { bool MenuButton::OnKeyPressed(const ui::KeyEvent& event) {
return menu_button_event_handler_.OnKeyPressed(event); return menu_button_controller_.OnKeyPressed(event);
} }
bool MenuButton::OnKeyReleased(const ui::KeyEvent& event) { bool MenuButton::OnKeyReleased(const ui::KeyEvent& event) {
return menu_button_event_handler_.OnKeyReleased(event); return menu_button_controller_.OnKeyReleased(event);
} }
void MenuButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { void MenuButton::GetAccessibleNodeData(ui::AXNodeData* node_data) {
menu_button_event_handler_.GetAccessibleNodeData(node_data); menu_button_controller_.GetAccessibleNodeData(node_data);
} }
void MenuButton::OnMouseEntered(const ui::MouseEvent& event) {} void MenuButton::OnMouseEntered(const ui::MouseEvent& event) {}
...@@ -69,19 +69,19 @@ void MenuButton::LabelButtonStateChanged(ButtonState old_state) { ...@@ -69,19 +69,19 @@ void MenuButton::LabelButtonStateChanged(ButtonState old_state) {
} }
bool MenuButton::IsTriggerableEvent(const ui::Event& event) { bool MenuButton::IsTriggerableEvent(const ui::Event& event) {
return menu_button_event_handler_.IsTriggerableEvent(event); return menu_button_controller_.IsTriggerableEvent(event);
} }
bool MenuButton::ShouldEnterPushedState(const ui::Event& event) { bool MenuButton::ShouldEnterPushedState(const ui::Event& event) {
return menu_button_event_handler_.ShouldEnterPushedState(event); return menu_button_controller_.ShouldEnterPushedState(event);
} }
void MenuButton::StateChanged(ButtonState old_state) { void MenuButton::StateChanged(ButtonState old_state) {
menu_button_event_handler_.StateChanged(old_state); menu_button_controller_.StateChanged(old_state);
} }
void MenuButton::NotifyClick(const ui::Event& event) { void MenuButton::NotifyClick(const ui::Event& event) {
menu_button_event_handler_.NotifyClick(event); menu_button_controller_.NotifyClick(event);
} }
} // namespace views } // namespace views
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "ui/views/controls/button/label_button.h" #include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/button/menu_button_event_handler.h" #include "ui/views/controls/button/menu_button_controller.h"
namespace views { namespace views {
...@@ -37,7 +37,7 @@ class VIEWS_EXPORT MenuButton : public LabelButton { ...@@ -37,7 +37,7 @@ class VIEWS_EXPORT MenuButton : public LabelButton {
bool Activate(const ui::Event* event); bool Activate(const ui::Event* event);
// TODO(cyan): Move into MenuButtonEventHandler. // TODO(cyan): Move into MenuButtonController.
virtual bool IsTriggerableEventType(const ui::Event& event); virtual bool IsTriggerableEventType(const ui::Event& event);
// View: // View:
...@@ -50,14 +50,14 @@ class VIEWS_EXPORT MenuButton : public LabelButton { ...@@ -50,14 +50,14 @@ class VIEWS_EXPORT MenuButton : public LabelButton {
void OnGestureEvent(ui::GestureEvent* event) override; void OnGestureEvent(ui::GestureEvent* event) override;
// Disallow overriding of these methods. // Disallow overriding of these methods.
// No-op implementations as these are handled in MenuButtonEventHandler (and // No-op implementations as these are handled in MenuButtonController (and
// should not be handled here as well). To override these you need to subclass // should not be handled here as well). To override these you need to subclass
// MenuButtonEventHandler and replace this event handler of the button. // MenuButtonController and replace this event handler of the button.
void OnMouseEntered(const ui::MouseEvent& event) final; void OnMouseEntered(const ui::MouseEvent& event) final;
void OnMouseExited(const ui::MouseEvent& event) final; void OnMouseExited(const ui::MouseEvent& event) final;
void OnMouseMoved(const ui::MouseEvent& event) final; void OnMouseMoved(const ui::MouseEvent& event) final;
// Protected methods needed for MenuButtonEventHandler. // Protected methods needed for MenuButtonController.
// TODO(cyan): Move these to a delegate interface. // TODO(cyan): Move these to a delegate interface.
using InkDropHostView::GetInkDrop; using InkDropHostView::GetInkDrop;
using View::InDrag; using View::InDrag;
...@@ -68,8 +68,8 @@ class VIEWS_EXPORT MenuButton : public LabelButton { ...@@ -68,8 +68,8 @@ class VIEWS_EXPORT MenuButton : public LabelButton {
// Button: // Button:
bool IsTriggerableEvent(const ui::Event& event) override; bool IsTriggerableEvent(const ui::Event& event) override;
MenuButtonEventHandler* menu_button_event_handler() { MenuButtonController* menu_button_controller() {
return &menu_button_event_handler_; return &menu_button_controller_;
} }
protected: protected:
...@@ -81,9 +81,9 @@ class VIEWS_EXPORT MenuButton : public LabelButton { ...@@ -81,9 +81,9 @@ class VIEWS_EXPORT MenuButton : public LabelButton {
private: private:
// All events get sent to this handler to be processed. // All events get sent to this handler to be processed.
// TODO(cyan): This will be generalized into a ButtonEventHandler and moved // TODO(cyan): This will be generalized into a ButtonController and moved
// into the Button class. // into the Button class.
MenuButtonEventHandler menu_button_event_handler_; MenuButtonController menu_button_controller_;
DISALLOW_COPY_AND_ASSIGN(MenuButton); DISALLOW_COPY_AND_ASSIGN(MenuButton);
}; };
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_EVENT_HANDLER_H_ #ifndef UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_CONTROLLER_H_
#define UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_EVENT_HANDLER_H_ #define UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_CONTROLLER_H_
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
...@@ -21,31 +21,31 @@ class MenuButtonListener; ...@@ -21,31 +21,31 @@ class MenuButtonListener;
// An EventHandler that contains the event behavior of a MenuButton. // An EventHandler that contains the event behavior of a MenuButton.
// TODO (cyan): This will eventually be available to any Button derivative class // TODO (cyan): This will eventually be available to any Button derivative class
// that wants MenuButton behavior. // that wants MenuButton behavior.
class VIEWS_EXPORT MenuButtonEventHandler : public ui::EventHandler { class VIEWS_EXPORT MenuButtonController : public ui::EventHandler {
public: public:
// A scoped lock for keeping the MenuButton in STATE_PRESSED e.g., while a // A scoped lock for keeping the MenuButton in STATE_PRESSED e.g., while a
// menu is running. These are cumulative. // menu is running. These are cumulative.
class VIEWS_EXPORT PressedLock { class VIEWS_EXPORT PressedLock {
public: public:
explicit PressedLock(MenuButtonEventHandler* menu_button_event_handler); explicit PressedLock(MenuButtonController* menu_button_controller);
// |event| is the event that caused the button to be pressed. May be null. // |event| is the event that caused the button to be pressed. May be null.
PressedLock(MenuButtonEventHandler* menu_button_event_handler, PressedLock(MenuButtonController* menu_button_controller,
bool is_sibling_menu_show, bool is_sibling_menu_show,
const ui::LocatedEvent* event); const ui::LocatedEvent* event);
~PressedLock(); ~PressedLock();
private: private:
base::WeakPtr<MenuButtonEventHandler> menu_button_event_handler_; base::WeakPtr<MenuButtonController> menu_button_controller_;
DISALLOW_COPY_AND_ASSIGN(PressedLock); DISALLOW_COPY_AND_ASSIGN(PressedLock);
}; };
// TODO (cyan): MenuButtonEventHandler should take in a Button. // TODO (cyan): MenuButtonController should take in a Button.
MenuButtonEventHandler(MenuButton* menu_button_parent, MenuButtonController(MenuButton* menu_button_parent,
MenuButtonListener* menu_button_listener); MenuButtonListener* menu_button_listener);
~MenuButtonEventHandler() override; ~MenuButtonController() override;
// TODO (cyan): Methods in this block should override EventHandler methods. // TODO (cyan): Methods in this block should override EventHandler methods.
// These are currently called by the corresponding method from view::Views. // These are currently called by the corresponding method from view::Views.
...@@ -127,11 +127,11 @@ class VIEWS_EXPORT MenuButtonEventHandler : public ui::EventHandler { ...@@ -127,11 +127,11 @@ class VIEWS_EXPORT MenuButtonEventHandler : public ui::EventHandler {
// we programmatically show a menu on a disabled button. // we programmatically show a menu on a disabled button.
bool should_disable_after_press_ = false; bool should_disable_after_press_ = false;
base::WeakPtrFactory<MenuButtonEventHandler> weak_factory_{this}; base::WeakPtrFactory<MenuButtonController> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(MenuButtonEventHandler); DISALLOW_COPY_AND_ASSIGN(MenuButtonController);
}; };
} // namespace views } // namespace views
#endif // UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_EVENT_HANDLER_H_ #endif // UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_CONTROLLER_H_
\ No newline at end of file \ No newline at end of file
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "ui/events/test/event_generator.h" #include "ui/events/test/event_generator.h"
#include "ui/views/animation/test/ink_drop_host_view_test_api.h" #include "ui/views/animation/test/ink_drop_host_view_test_api.h"
#include "ui/views/animation/test/test_ink_drop.h" #include "ui/views/animation/test/test_ink_drop.h"
#include "ui/views/controls/button/menu_button_event_handler.h" #include "ui/views/controls/button/menu_button_controller.h"
#include "ui/views/controls/button/menu_button_listener.h" #include "ui/views/controls/button/menu_button_listener.h"
#include "ui/views/drag_controller.h" #include "ui/views/drag_controller.h"
#include "ui/views/test/views_test_base.h" #include "ui/views/test/views_test_base.h"
...@@ -189,7 +189,7 @@ class PressStateMenuButtonListener : public MenuButtonListener { ...@@ -189,7 +189,7 @@ class PressStateMenuButtonListener : public MenuButtonListener {
void OnMenuButtonClicked(MenuButton* source, void OnMenuButtonClicked(MenuButton* source,
const gfx::Point& point, const gfx::Point& point,
const ui::Event* event) override { const ui::Event* event) override {
pressed_lock_ = menu_button_->menu_button_event_handler()->TakeLock(); pressed_lock_ = menu_button_->menu_button_controller()->TakeLock();
if (release_lock_) if (release_lock_)
pressed_lock_.reset(); pressed_lock_.reset();
} }
...@@ -199,7 +199,7 @@ class PressStateMenuButtonListener : public MenuButtonListener { ...@@ -199,7 +199,7 @@ class PressStateMenuButtonListener : public MenuButtonListener {
private: private:
MenuButton* menu_button_; MenuButton* menu_button_;
std::unique_ptr<MenuButtonEventHandler::PressedLock> pressed_lock_; std::unique_ptr<MenuButtonController::PressedLock> pressed_lock_;
// The |pressed_lock_| will be released when true. // The |pressed_lock_| will be released when true.
bool release_lock_; bool release_lock_;
...@@ -366,8 +366,8 @@ TEST_F(MenuButtonTest, InkDropCenterSetFromClickWithPressedLock) { ...@@ -366,8 +366,8 @@ TEST_F(MenuButtonTest, InkDropCenterSetFromClickWithPressedLock) {
gfx::Point click_point(11, 7); gfx::Point click_point(11, 7);
ui::MouseEvent click_event(ui::EventType::ET_MOUSE_PRESSED, click_point, ui::MouseEvent click_event(ui::EventType::ET_MOUSE_PRESSED, click_point,
click_point, base::TimeTicks(), 0, 0); click_point, base::TimeTicks(), 0, 0);
MenuButtonEventHandler::PressedLock pressed_lock( MenuButtonController::PressedLock pressed_lock(
button()->menu_button_event_handler(), false, &click_event); button()->menu_button_controller(), false, &click_event);
EXPECT_EQ(Button::STATE_PRESSED, button()->state()); EXPECT_EQ(Button::STATE_PRESSED, button()->state());
EXPECT_EQ( EXPECT_EQ(
...@@ -384,9 +384,9 @@ TEST_F(MenuButtonTest, ButtonStateForMenuButtonsWithPressedLocks) { ...@@ -384,9 +384,9 @@ TEST_F(MenuButtonTest, ButtonStateForMenuButtonsWithPressedLocks) {
EXPECT_EQ(Button::STATE_HOVERED, button()->state()); EXPECT_EQ(Button::STATE_HOVERED, button()->state());
// Introduce a PressedLock, which should make the button pressed. // Introduce a PressedLock, which should make the button pressed.
std::unique_ptr<MenuButtonEventHandler::PressedLock> pressed_lock1( std::unique_ptr<MenuButtonController::PressedLock> pressed_lock1(
new MenuButtonEventHandler::PressedLock( new MenuButtonController::PressedLock(
button()->menu_button_event_handler())); button()->menu_button_controller()));
EXPECT_EQ(Button::STATE_PRESSED, button()->state()); EXPECT_EQ(Button::STATE_PRESSED, button()->state());
// Even if we move the mouse outside of the button, it should remain pressed. // Even if we move the mouse outside of the button, it should remain pressed.
...@@ -394,9 +394,9 @@ TEST_F(MenuButtonTest, ButtonStateForMenuButtonsWithPressedLocks) { ...@@ -394,9 +394,9 @@ TEST_F(MenuButtonTest, ButtonStateForMenuButtonsWithPressedLocks) {
EXPECT_EQ(Button::STATE_PRESSED, button()->state()); EXPECT_EQ(Button::STATE_PRESSED, button()->state());
// Creating a new lock should obviously keep the button pressed. // Creating a new lock should obviously keep the button pressed.
std::unique_ptr<MenuButtonEventHandler::PressedLock> pressed_lock2( std::unique_ptr<MenuButtonController::PressedLock> pressed_lock2(
new MenuButtonEventHandler::PressedLock( new MenuButtonController::PressedLock(
button()->menu_button_event_handler())); button()->menu_button_controller()));
EXPECT_EQ(Button::STATE_PRESSED, button()->state()); EXPECT_EQ(Button::STATE_PRESSED, button()->state());
// The button should remain pressed while any locks are active. // The button should remain pressed while any locks are active.
...@@ -413,7 +413,7 @@ TEST_F(MenuButtonTest, ButtonStateForMenuButtonsWithPressedLocks) { ...@@ -413,7 +413,7 @@ TEST_F(MenuButtonTest, ButtonStateForMenuButtonsWithPressedLocks) {
// Test that the button returns to the appropriate state after the press; if // Test that the button returns to the appropriate state after the press; if
// the mouse ends over the button, the button should be hovered. // the mouse ends over the button, the button should be hovered.
pressed_lock1 = button()->menu_button_event_handler()->TakeLock(); pressed_lock1 = button()->menu_button_controller()->TakeLock();
EXPECT_EQ(Button::STATE_PRESSED, button()->state()); EXPECT_EQ(Button::STATE_PRESSED, button()->state());
pressed_lock1.reset(); pressed_lock1.reset();
EXPECT_EQ(Button::STATE_HOVERED, button()->state()); EXPECT_EQ(Button::STATE_HOVERED, button()->state());
...@@ -421,7 +421,7 @@ TEST_F(MenuButtonTest, ButtonStateForMenuButtonsWithPressedLocks) { ...@@ -421,7 +421,7 @@ TEST_F(MenuButtonTest, ButtonStateForMenuButtonsWithPressedLocks) {
// If the button is disabled before the pressed lock, it should be disabled // If the button is disabled before the pressed lock, it should be disabled
// after the pressed lock. // after the pressed lock.
button()->SetState(Button::STATE_DISABLED); button()->SetState(Button::STATE_DISABLED);
pressed_lock1 = button()->menu_button_event_handler()->TakeLock(); pressed_lock1 = button()->menu_button_controller()->TakeLock();
EXPECT_EQ(Button::STATE_PRESSED, button()->state()); EXPECT_EQ(Button::STATE_PRESSED, button()->state());
pressed_lock1.reset(); pressed_lock1.reset();
EXPECT_EQ(Button::STATE_DISABLED, button()->state()); EXPECT_EQ(Button::STATE_DISABLED, button()->state());
...@@ -430,7 +430,7 @@ TEST_F(MenuButtonTest, ButtonStateForMenuButtonsWithPressedLocks) { ...@@ -430,7 +430,7 @@ TEST_F(MenuButtonTest, ButtonStateForMenuButtonsWithPressedLocks) {
// Edge case: the button is disabled, a pressed lock is added, and then the // Edge case: the button is disabled, a pressed lock is added, and then the
// button is re-enabled. It should be enabled after the lock is removed. // button is re-enabled. It should be enabled after the lock is removed.
pressed_lock1 = button()->menu_button_event_handler()->TakeLock(); pressed_lock1 = button()->menu_button_controller()->TakeLock();
EXPECT_EQ(Button::STATE_PRESSED, button()->state()); EXPECT_EQ(Button::STATE_PRESSED, button()->state());
button()->SetState(Button::STATE_NORMAL); button()->SetState(Button::STATE_NORMAL);
pressed_lock1.reset(); pressed_lock1.reset();
...@@ -508,15 +508,15 @@ TEST_F(MenuButtonTest, ...@@ -508,15 +508,15 @@ TEST_F(MenuButtonTest,
TEST_F(MenuButtonTest, InkDropStateForMenuButtonsWithPressedLocks) { TEST_F(MenuButtonTest, InkDropStateForMenuButtonsWithPressedLocks) {
CreateMenuButtonWithNoListener(); CreateMenuButtonWithNoListener();
std::unique_ptr<MenuButtonEventHandler::PressedLock> pressed_lock1( std::unique_ptr<MenuButtonController::PressedLock> pressed_lock1(
new MenuButtonEventHandler::PressedLock( new MenuButtonController::PressedLock(
button()->menu_button_event_handler())); button()->menu_button_controller()));
EXPECT_EQ(InkDropState::ACTIVATED, ink_drop()->GetTargetInkDropState()); EXPECT_EQ(InkDropState::ACTIVATED, ink_drop()->GetTargetInkDropState());
std::unique_ptr<MenuButtonEventHandler::PressedLock> pressed_lock2( std::unique_ptr<MenuButtonController::PressedLock> pressed_lock2(
new MenuButtonEventHandler::PressedLock( new MenuButtonController::PressedLock(
button()->menu_button_event_handler())); button()->menu_button_controller()));
EXPECT_EQ(InkDropState::ACTIVATED, ink_drop()->GetTargetInkDropState()); EXPECT_EQ(InkDropState::ACTIVATED, ink_drop()->GetTargetInkDropState());
...@@ -532,16 +532,16 @@ TEST_F(MenuButtonTest, InkDropStateForMenuButtonsWithPressedLocks) { ...@@ -532,16 +532,16 @@ TEST_F(MenuButtonTest, InkDropStateForMenuButtonsWithPressedLocks) {
TEST_F(MenuButtonTest, OneInkDropAnimationForReentrantPressedLocks) { TEST_F(MenuButtonTest, OneInkDropAnimationForReentrantPressedLocks) {
CreateMenuButtonWithNoListener(); CreateMenuButtonWithNoListener();
std::unique_ptr<MenuButtonEventHandler::PressedLock> pressed_lock1( std::unique_ptr<MenuButtonController::PressedLock> pressed_lock1(
new MenuButtonEventHandler::PressedLock( new MenuButtonController::PressedLock(
button()->menu_button_event_handler())); button()->menu_button_controller()));
EXPECT_EQ(InkDropState::ACTIVATED, ink_drop()->GetTargetInkDropState()); EXPECT_EQ(InkDropState::ACTIVATED, ink_drop()->GetTargetInkDropState());
ink_drop()->AnimateToState(InkDropState::ACTION_PENDING); ink_drop()->AnimateToState(InkDropState::ACTION_PENDING);
std::unique_ptr<MenuButtonEventHandler::PressedLock> pressed_lock2( std::unique_ptr<MenuButtonController::PressedLock> pressed_lock2(
new MenuButtonEventHandler::PressedLock( new MenuButtonController::PressedLock(
button()->menu_button_event_handler())); button()->menu_button_controller()));
EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop()->GetTargetInkDropState()); EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop()->GetTargetInkDropState());
} }
...@@ -552,8 +552,7 @@ TEST_F(MenuButtonTest, ...@@ -552,8 +552,7 @@ TEST_F(MenuButtonTest,
InkDropStateForMenuButtonWithPressedLockBeforeActivation) { InkDropStateForMenuButtonWithPressedLockBeforeActivation) {
TestMenuButtonListener menu_button_listener; TestMenuButtonListener menu_button_listener;
CreateMenuButtonWithMenuButtonListener(&menu_button_listener); CreateMenuButtonWithMenuButtonListener(&menu_button_listener);
MenuButtonEventHandler::PressedLock lock( MenuButtonController::PressedLock lock(button()->menu_button_controller());
button()->menu_button_event_handler());
button()->Activate(nullptr); button()->Activate(nullptr);
......
...@@ -487,7 +487,7 @@ void MenuController::Run(Widget* parent, ...@@ -487,7 +487,7 @@ void MenuController::Run(Widget* parent,
SetSelection(root, SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY); SetSelection(root, SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
if (button) { if (button) {
pressed_lock_ = button->menu_button_event_handler()->TakeLock( pressed_lock_ = button->menu_button_controller()->TakeLock(
false, ui::LocatedEvent::FromIfValid(event)); false, ui::LocatedEvent::FromIfValid(event));
} }
...@@ -1683,7 +1683,7 @@ bool MenuController::ShowSiblingMenu(SubmenuView* source, ...@@ -1683,7 +1683,7 @@ bool MenuController::ShowSiblingMenu(SubmenuView* source,
// There is a sibling menu, update the button state, hide the current menu // There is a sibling menu, update the button state, hide the current menu
// and show the new one. // and show the new one.
pressed_lock_ = button->menu_button_event_handler()->TakeLock(true, nullptr); pressed_lock_ = button->menu_button_controller()->TakeLock(true, nullptr);
// Need to reset capture when we show the menu again, otherwise we aren't // Need to reset capture when we show the menu again, otherwise we aren't
// going to get any events. // going to get any events.
...@@ -2915,7 +2915,7 @@ MenuItemView* MenuController::ExitTopMostMenu() { ...@@ -2915,7 +2915,7 @@ MenuItemView* MenuController::ExitTopMostMenu() {
} }
#endif #endif
std::unique_ptr<MenuButtonEventHandler::PressedLock> nested_pressed_lock; std::unique_ptr<MenuButtonController::PressedLock> nested_pressed_lock;
bool nested_menu = !menu_stack_.empty(); bool nested_menu = !menu_stack_.empty();
if (nested_menu) { if (nested_menu) {
DCHECK(!menu_stack_.empty()); DCHECK(!menu_stack_.empty());
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "ui/events/platform/platform_event_dispatcher.h" #include "ui/events/platform/platform_event_dispatcher.h"
#include "ui/gfx/animation/throb_animation.h" #include "ui/gfx/animation/throb_animation.h"
#include "ui/views/controls/button/menu_button.h" #include "ui/views/controls/button/menu_button.h"
#include "ui/views/controls/button/menu_button_event_handler.h" #include "ui/views/controls/button/menu_button_controller.h"
#include "ui/views/controls/menu/menu_config.h" #include "ui/views/controls/menu/menu_config.h"
#include "ui/views/controls/menu/menu_delegate.h" #include "ui/views/controls/menu/menu_delegate.h"
#include "ui/views/widget/widget_observer.h" #include "ui/views/widget/widget_observer.h"
...@@ -656,7 +656,7 @@ class VIEWS_EXPORT MenuController ...@@ -656,7 +656,7 @@ class VIEWS_EXPORT MenuController
// Run, the current state (state_) is pushed onto menu_stack_. This allows // Run, the current state (state_) is pushed onto menu_stack_. This allows
// MenuController to restore the state when the nested run returns. // MenuController to restore the state when the nested run returns.
using NestedState = using NestedState =
std::pair<State, std::unique_ptr<MenuButtonEventHandler::PressedLock>>; std::pair<State, std::unique_ptr<MenuButtonController::PressedLock>>;
std::list<NestedState> menu_stack_; std::list<NestedState> menu_stack_;
// When Run is invoked during an active Run, it may be called from a separate // When Run is invoked during an active Run, it may be called from a separate
...@@ -710,7 +710,7 @@ class VIEWS_EXPORT MenuController ...@@ -710,7 +710,7 @@ class VIEWS_EXPORT MenuController
std::unique_ptr<MenuScrollTask> scroll_task_; std::unique_ptr<MenuScrollTask> scroll_task_;
// The lock to keep the menu button pressed while a menu is visible. // The lock to keep the menu button pressed while a menu is visible.
std::unique_ptr<MenuButtonEventHandler::PressedLock> pressed_lock_; std::unique_ptr<MenuButtonController::PressedLock> pressed_lock_;
// ViewTracker used to store the View mouse drag events are forwarded to. See // ViewTracker used to store the View mouse drag events are forwarded to. See
// UpdateActiveMouseView() for details. // UpdateActiveMouseView() for details.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment