diff --git a/browser/ui/views/brave_tooltips/brave_tooltip_popup.cc b/browser/ui/views/brave_tooltips/brave_tooltip_popup.cc index ddd4b061940..369f3d883d8 100644 --- a/browser/ui/views/brave_tooltips/brave_tooltip_popup.cc +++ b/browser/ui/views/brave_tooltips/brave_tooltip_popup.cc @@ -18,8 +18,6 @@ #include "ui/base/metadata/metadata_impl_macros.h" #include "ui/compositor/layer.h" #include "ui/display/screen.h" -#include "ui/gfx/animation/linear_animation.h" -#include "ui/gfx/animation/tween.h" #include "ui/gfx/canvas.h" #include "ui/gfx/color_palette.h" #include "ui/gfx/geometry/insets.h" @@ -63,8 +61,7 @@ constexpr int kCornerRadius = 7; namespace brave_tooltips { BraveTooltipPopup::BraveTooltipPopup(std::unique_ptr tooltip) - : tooltip_(std::move(tooltip)), - animation_(std::make_unique(this)) { + : tooltip_(std::move(tooltip)) { CreatePopup(); NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); @@ -73,8 +70,6 @@ BraveTooltipPopup::BraveTooltipPopup(std::unique_ptr tooltip) if (screen) { screen->AddObserver(this); } - - FadeIn(); } BraveTooltipPopup::~BraveTooltipPopup() { @@ -97,7 +92,7 @@ void BraveTooltipPopup::Close() { delegate->OnTooltipClose(tooltip_->id()); } - FadeOut(); + CloseWidget(); } void BraveTooltipPopup::CloseWidget() { @@ -112,7 +107,7 @@ void BraveTooltipPopup::OnOkButtonPressed() { delegate->OnTooltipOkButtonPressed(tooltip_->id()); } - FadeOut(); + Close(); } void BraveTooltipPopup::OnCancelButtonPressed() { @@ -127,7 +122,7 @@ void BraveTooltipPopup::OnCancelButtonPressed() { delegate->OnTooltipCancelButtonPressed(tooltip_->id()); } - FadeOut(); + Close(); } void BraveTooltipPopup::set_normalized_display_coordinates(double x, double y) { @@ -230,35 +225,6 @@ void BraveTooltipPopup::OnWidgetBoundsChanged(views::Widget* widget, widget_origin_ = new_bounds.origin(); } -void BraveTooltipPopup::AnimationEnded(const gfx::Animation* animation) { - UpdateAnimation(); - - switch (animation_state_) { - case AnimationState::kIdle: { - break; - } - - case AnimationState::kFadeIn: { - animation_state_ = AnimationState::kIdle; - break; - } - - case AnimationState::kFadeOut: { - animation_state_ = AnimationState::kIdle; - CloseWidget(); - break; - } - } -} - -void BraveTooltipPopup::AnimationProgressed(const gfx::Animation* animation) { - UpdateAnimation(); -} - -void BraveTooltipPopup::AnimationCanceled(const gfx::Animation* animation) { - UpdateAnimation(); -} - /////////////////////////////////////////////////////////////////////////////// void BraveTooltipPopup::CreatePopup() { @@ -369,7 +335,6 @@ void BraveTooltipPopup::CreateWidgetView() { widget->Init(std::move(params)); - widget->SetOpacity(0.0); widget->ShowInactive(); } @@ -386,45 +351,6 @@ void BraveTooltipPopup::CloseWidgetView() { GetWidget()->CloseNow(); } -void BraveTooltipPopup::FadeIn() { - animation_state_ = AnimationState::kFadeIn; - animation_->SetDuration(base::Milliseconds(fade_duration_)); - StartAnimation(); -} - -void BraveTooltipPopup::FadeOut() { - animation_state_ = AnimationState::kFadeOut; - animation_->SetDuration(base::Milliseconds(fade_duration_)); - StartAnimation(); -} - -void BraveTooltipPopup::StartAnimation() { - animation_->Start(); - - UpdateAnimation(); - - DCHECK(animation_->is_animating()); -} - -void BraveTooltipPopup::UpdateAnimation() { - DCHECK_NE(animation_state_, AnimationState::kIdle); - - if (!IsWidgetValid()) { - return; - } - - const double value = gfx::Tween::CalculateValue( - animation_state_ == AnimationState::kFadeOut ? gfx::Tween::EASE_IN - : gfx::Tween::EASE_OUT, - animation_->GetCurrentValue()); - - if (animation_state_ == AnimationState::kFadeIn) { - GetWidget()->SetOpacity(gfx::Tween::FloatValueBetween(value, 0.0f, 1.0f)); - } else if (animation_state_ == AnimationState::kFadeOut) { - GetWidget()->SetOpacity(gfx::Tween::FloatValueBetween(value, 1.0f, 0.0f)); - } -} - bool BraveTooltipPopup::IsWidgetValid() const { return GetWidget() && !GetWidget()->IsClosed(); } diff --git a/browser/ui/views/brave_tooltips/brave_tooltip_popup.h b/browser/ui/views/brave_tooltips/brave_tooltip_popup.h index e10a9807adb..586f4190a62 100644 --- a/browser/ui/views/brave_tooltips/brave_tooltip_popup.h +++ b/browser/ui/views/brave_tooltips/brave_tooltip_popup.h @@ -16,7 +16,6 @@ #include "brave/browser/ui/views/brave_tooltips/brave_tooltip_view.h" #include "ui/base/metadata/metadata_impl_macros.h" #include "ui/display/display_observer.h" -#include "ui/gfx/animation/animation_delegate.h" #include "ui/gfx/shadow_util.h" #include "ui/gfx/shadow_value.h" #include "ui/views/controls/button/button.h" @@ -24,7 +23,6 @@ #include "ui/views/widget/widget_observer.h" namespace gfx { -class LinearAnimation; class Point; class Rect; class Size; @@ -56,7 +54,6 @@ class BraveTooltipView; // constructor). Finally, the tooltip is closed. class BraveTooltipPopup : public views::WidgetDelegateView, public views::WidgetObserver, - public gfx::AnimationDelegate, public display::DisplayObserver { METADATA_HEADER(BraveTooltipPopup, views::WidgetDelegateView) public: @@ -113,11 +110,6 @@ class BraveTooltipPopup : public views::WidgetDelegateView, void OnWidgetBoundsChanged(views::Widget* widget, const gfx::Rect& new_bounds) override; - // AnimationDelegate: - void AnimationEnded(const gfx::Animation* animation) override; - void AnimationProgressed(const gfx::Animation* animation) override; - void AnimationCanceled(const gfx::Animation* animation) override; - private: void CreatePopup(); @@ -133,12 +125,6 @@ class BraveTooltipPopup : public views::WidgetDelegateView, bool IsWidgetValid() const; - void StartAnimation(); - void UpdateAnimation(); - - void FadeIn(); - void FadeOut(); - std::unique_ptr tooltip_; raw_ptr tooltip_view_ = nullptr; @@ -151,17 +137,6 @@ class BraveTooltipPopup : public views::WidgetDelegateView, int display_work_area_inset_x_ = -13; int display_work_area_inset_y_ = 18; - int fade_duration_ = 200; - - enum class AnimationState { - kIdle, - kFadeIn, - kFadeOut, - }; - - const std::unique_ptr animation_; - AnimationState animation_state_ = AnimationState::kIdle; - base::ScopedObservation widget_observation_{this}; }; diff --git a/browser/ui/views/brave_tooltips/brave_tooltips_unittest.cc b/browser/ui/views/brave_tooltips/brave_tooltips_unittest.cc index 38d85baba9e..895e2ee0410 100644 --- a/browser/ui/views/brave_tooltips/brave_tooltips_unittest.cc +++ b/browser/ui/views/brave_tooltips/brave_tooltips_unittest.cc @@ -80,8 +80,6 @@ TEST_F(BraveTooltipsTest, OkButtonPressed) { ClickButton(tooltip_popup->ok_button_for_testing()); - tooltip_popup->Close(); - mock_tooltip_delegate_.WaitForWidgetDestroyedNotification(); tooltip_popup.release(); @@ -102,8 +100,6 @@ TEST_F(BraveTooltipsTest, CancelButtonPressed) { ClickButton(tooltip_popup->cancel_button_for_testing()); - tooltip_popup->Close(); - mock_tooltip_delegate_.WaitForWidgetDestroyedNotification(); tooltip_popup.release();