Commit 26872015 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Fix crash on notification settings by keyboard.

When notification inline settings is opened from the top right gear icon
using by keyboard, it crashed as animation requires the event to be
LocatedEvent but it's not.

TEST=manual
BUG=823646

Change-Id: Ia683de86e042f010ac4bb0ee645fff170547b9fa
Reviewed-on: https://chromium-review.googlesource.com/974922
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545738}
parent 5efc817a
......@@ -304,7 +304,7 @@ void MessageView::OnCloseButtonPressed() {
true /* by_user */);
}
void MessageView::OnSettingsButtonPressed(const ui::LocatedEvent& event) {
void MessageView::OnSettingsButtonPressed(const ui::Event& event) {
MessageCenter::Get()->ClickOnSettingsButton(notification_id_);
}
......
......@@ -77,7 +77,7 @@ class MESSAGE_CENTER_EXPORT MessageView : public views::InkDropHostView,
virtual void OnContainerAnimationEnded();
void OnCloseButtonPressed();
virtual void OnSettingsButtonPressed(const ui::LocatedEvent& event);
virtual void OnSettingsButtonPressed(const ui::Event& event);
// views::View
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
......
......@@ -155,7 +155,7 @@ void NotificationControlButtonsView::ButtonPressed(views::Button* sender,
if (close_button_ && sender == close_button_.get()) {
message_view_->OnCloseButtonPressed();
} else if (settings_button_ && sender == settings_button_.get()) {
message_view_->OnSettingsButtonPressed(*event.AsLocatedEvent());
message_view_->OnSettingsButtonPressed(event);
}
}
......
......@@ -700,7 +700,7 @@ void NotificationViewMD::OnMouseReleased(const ui::MouseEvent& event) {
ui::GetGestureProviderConfig(
ui::GestureProviderConfigType::CURRENT_PLATFORM)
.gesture_detector_config.longpress_timeout.InSecondsF()) {
ToggleInlineSettings(*event.AsLocatedEvent());
ToggleInlineSettings(event);
return;
}
......@@ -736,7 +736,7 @@ void NotificationViewMD::OnMouseEvent(ui::MouseEvent* event) {
void NotificationViewMD::OnGestureEvent(ui::GestureEvent* event) {
if (event->type() == ui::ET_GESTURE_LONG_TAP) {
ToggleInlineSettings(*event->AsLocatedEvent());
ToggleInlineSettings(*event);
return;
}
MessageView::OnGestureEvent(event);
......@@ -803,7 +803,7 @@ void NotificationViewMD::ButtonPressed(views::Button* sender,
if (sender == settings_done_button_) {
if (block_all_button_->checked())
MessageCenter::Get()->DisableNotification(id);
ToggleInlineSettings(*event.AsLocatedEvent());
ToggleInlineSettings(event);
return;
}
}
......@@ -1239,7 +1239,7 @@ void NotificationViewMD::UpdateViewForExpandedState(bool expanded) {
}
}
void NotificationViewMD::ToggleInlineSettings(const ui::LocatedEvent& event) {
void NotificationViewMD::ToggleInlineSettings(const ui::Event& event) {
DCHECK(settings_row_);
bool inline_settings_visible = !settings_row_->visible();
......@@ -1303,8 +1303,7 @@ void NotificationViewMD::SetManuallyExpandedOrCollapsed(bool value) {
manually_expanded_or_collapsed_ = value;
}
void NotificationViewMD::OnSettingsButtonPressed(
const ui::LocatedEvent& event) {
void NotificationViewMD::OnSettingsButtonPressed(const ui::Event& event) {
if (settings_row_)
ToggleInlineSettings(event);
else
......@@ -1316,21 +1315,26 @@ void NotificationViewMD::Activate() {
GetWidget()->Activate();
}
void NotificationViewMD::AddBackgroundAnimation(const ui::LocatedEvent& event) {
void NotificationViewMD::AddBackgroundAnimation(const ui::Event& event) {
SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER);
// In case the animation is triggered from keyboard operation.
if (!event.IsLocatedEvent()) {
AnimateInkDrop(views::InkDropState::ACTION_PENDING, nullptr);
return;
}
// Convert the point of |event| from the coordinate system of
// |control_buttons_view_| to that of NotificationViewMD, create a new
// LocatedEvent which has the new point.
views::View* target = static_cast<views::View*>(event.target());
const gfx::Point& location = event.location();
const gfx::Point& location = event.AsLocatedEvent()->location();
gfx::Point converted_location(location);
View::ConvertPointToTarget(target, this, &converted_location);
std::unique_ptr<ui::Event> cloned_event = ui::Event::Clone(event);
ui::LocatedEvent* cloned_located_event = cloned_event->AsLocatedEvent();
cloned_located_event->set_location(converted_location);
if (View::HitTestPoint(event.location())) {
if (View::HitTestPoint(event.AsLocatedEvent()->location())) {
AnimateInkDrop(views::InkDropState::ACTION_PENDING,
ui::LocatedEvent::FromIfValid(cloned_located_event));
}
......
......@@ -225,7 +225,7 @@ class MESSAGE_CENTER_EXPORT NotificationViewMD
void Activate();
void AddBackgroundAnimation(const ui::LocatedEvent& event);
void AddBackgroundAnimation(const ui::Event& event);
void RemoveBackgroundAnimation();
// Overridden from views::View:
......@@ -256,7 +256,7 @@ class MESSAGE_CENTER_EXPORT NotificationViewMD
bool IsManuallyExpandedOrCollapsed() const override;
void SetManuallyExpandedOrCollapsed(bool value) override;
void OnSettingsButtonPressed(const ui::LocatedEvent& event) override;
void OnSettingsButtonPressed(const ui::Event& event) override;
// views::InkDropObserver:
void InkDropAnimationStarted() override;
......@@ -302,7 +302,7 @@ class MESSAGE_CENTER_EXPORT NotificationViewMD
bool IsExpandable();
void ToggleExpanded();
void UpdateViewForExpandedState(bool expanded);
void ToggleInlineSettings(const ui::LocatedEvent& event);
void ToggleInlineSettings(const ui::Event& event);
views::InkDropContainerView* const ink_drop_container_;
......
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