Commit f8303fb7 authored by Richard Knoll's avatar Richard Knoll Committed by Commit Bot

Fix notification inline reply ripple in RTL layout

This will set the bounds rect of the ink drop container so the animation
is within the inline reply text input. Also fixes the starting point of
the animation to be relative to the container instead of the reply
button.

Before / After screenshots: https://imgur.com/CC787wK

Bug: 1090324
Change-Id: I7dd9918bcd13c28b7def8725fc2f3fe3ca7adc45
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2395655
Commit-Queue: Richard Knoll <knollr@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804779}
parent 601f3163
...@@ -182,6 +182,25 @@ std::unique_ptr<views::View> CreateItemView(const NotificationItem& item) { ...@@ -182,6 +182,25 @@ std::unique_ptr<views::View> CreateItemView(const NotificationItem& item) {
return view; return view;
} }
std::unique_ptr<ui::Event> ConvertToBoundedLocatedEvent(const ui::Event& event,
views::View* target) {
// In case the animation is triggered from keyboard operation.
if (!event.IsLocatedEvent())
return nullptr;
// Convert the point of |event| from the coordinate system of its target to
// that of the passed in |target| and create a new LocatedEvent.
std::unique_ptr<ui::Event> cloned_event = ui::Event::Clone(event);
ui::LocatedEvent* located_event = cloned_event->AsLocatedEvent();
event.target()->ConvertEventToTarget(target, located_event);
// Use default animation if location is out of bounds.
if (!target->HitTestPoint(located_event->location()))
return nullptr;
return cloned_event;
}
} // anonymous namespace } // anonymous namespace
// CompactTitleMessageView ///////////////////////////////////////////////////// // CompactTitleMessageView /////////////////////////////////////////////////////
...@@ -360,12 +379,10 @@ NotificationInputContainerMD::NotificationInputContainerMD( ...@@ -360,12 +379,10 @@ NotificationInputContainerMD::NotificationInputContainerMD(
NotificationInputContainerMD::~NotificationInputContainerMD() = default; NotificationInputContainerMD::~NotificationInputContainerMD() = default;
void NotificationInputContainerMD::AnimateBackground(const ui::Event& event) { void NotificationInputContainerMD::AnimateBackground(const ui::Event& event) {
// Try to get a located event. This can be NULL if triggered via keyboard. std::unique_ptr<ui::Event> located_event =
const ui::LocatedEvent* located_event = ui::LocatedEvent::FromIfValid(&event); ConvertToBoundedLocatedEvent(event, this);
// Use default animation if location is out of bounds. AnimateInkDrop(views::InkDropState::ACTION_PENDING,
if (located_event && !View::HitTestPoint(located_event->location())) ui::LocatedEvent::FromIfValid(located_event.get()));
located_event = nullptr;
AnimateInkDrop(views::InkDropState::ACTION_PENDING, located_event);
} }
void NotificationInputContainerMD::AddLayerBeneathView(ui::Layer* layer) { void NotificationInputContainerMD::AddLayerBeneathView(ui::Layer* layer) {
...@@ -410,6 +427,12 @@ void NotificationInputContainerMD::OnThemeChanged() { ...@@ -410,6 +427,12 @@ void NotificationInputContainerMD::OnThemeChanged() {
SetButtonImage(); SetButtonImage();
} }
void NotificationInputContainerMD::Layout() {
views::InkDropHostView::Layout();
// The animation is needed to run inside of the border.
ink_drop_container_->SetBoundsRect(GetLocalBounds());
}
bool NotificationInputContainerMD::HandleKeyEvent(views::Textfield* sender, bool NotificationInputContainerMD::HandleKeyEvent(views::Textfield* sender,
const ui::KeyEvent& event) { const ui::KeyEvent& event) {
if (event.type() == ui::ET_KEY_PRESSED && if (event.type() == ui::ET_KEY_PRESSED &&
...@@ -1411,30 +1434,10 @@ void NotificationViewMD::Activate() { ...@@ -1411,30 +1434,10 @@ void NotificationViewMD::Activate() {
void NotificationViewMD::AddBackgroundAnimation(const ui::Event& event) { void NotificationViewMD::AddBackgroundAnimation(const ui::Event& event) {
SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER);
// In case the animation is triggered from keyboard operation. std::unique_ptr<ui::Event> located_event =
if (!event.IsLocatedEvent()) { ConvertToBoundedLocatedEvent(event, this);
AnimateInkDrop(views::InkDropState::ACTION_PENDING, nullptr); AnimateInkDrop(views::InkDropState::ACTION_PENDING,
return; ui::LocatedEvent::FromIfValid(located_event.get()));
}
// 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.AsLocatedEvent()->location();
gfx::Point converted_location(location);
View::ConvertPointToTarget(target, this, &converted_location);
// Use default animation if location is out of bounds.
if (!View::HitTestPoint(converted_location)) {
AnimateInkDrop(views::InkDropState::ACTION_PENDING, nullptr);
return;
}
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);
AnimateInkDrop(views::InkDropState::ACTION_PENDING, cloned_located_event);
} }
void NotificationViewMD::RemoveBackgroundAnimation() { void NotificationViewMD::RemoveBackgroundAnimation() {
......
...@@ -126,6 +126,7 @@ class NotificationInputContainerMD : public views::InkDropHostView, ...@@ -126,6 +126,7 @@ class NotificationInputContainerMD : public views::InkDropHostView,
std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
SkColor GetInkDropBaseColor() const override; SkColor GetInkDropBaseColor() const override;
void OnThemeChanged() override; void OnThemeChanged() override;
void Layout() override;
// Overridden from views::TextfieldController: // Overridden from views::TextfieldController:
bool HandleKeyEvent(views::Textfield* sender, bool HandleKeyEvent(views::Textfield* sender,
......
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