Commit d53b5a93 authored by Thomas Lukaszewicz's avatar Thomas Lukaszewicz Committed by Commit Bot

Fixed stuck inkdrop effect on download shelf item.

Fixed the issue with a stuck inkdrop on drag of a download item
due to incorrect handling of the button's OnMouseDragged() and
OnMouseCaptureLost() handlers. Prior to this change
DownloadItemView attempted to intervene in the button's inkdrop
display logic.

Removed inheritance from InkDropHost for DownloadItemView as it is
unnecessary due to the use of a transparent button overlay for the
button effects.

Bug: 1026384
Change-Id: I2436fab35f5334ca0bd947189c831f932ba1f0ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1955657
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#723036}
parent cb8d3ee2
...@@ -182,13 +182,17 @@ class TransparentButton : public views::Button { ...@@ -182,13 +182,17 @@ class TransparentButton : public views::Button {
const char* GetClassName() const override { return "TransparentButton"; } const char* GetClassName() const override { return "TransparentButton"; }
// Forward dragging events, since this class doesn't have enough context to // Forward dragging and capture loss events, since this class doesn't have
// handle them. // enough context to handle them. Let the button class manage visual
// transitions.
bool OnMouseDragged(const ui::MouseEvent& event) override { bool OnMouseDragged(const ui::MouseEvent& event) override {
Button::OnMouseDragged(event);
return parent()->OnMouseDragged(event); return parent()->OnMouseDragged(event);
} }
void OnMouseCaptureLost() override {
void OnMouseCaptureLost() override { parent()->OnMouseCaptureLost(); } parent()->OnMouseCaptureLost();
Button::OnMouseCaptureLost();
}
}; };
} // namespace } // namespace
...@@ -214,7 +218,6 @@ DownloadItemView::DownloadItemView(DownloadUIModel::DownloadUIModelPtr download, ...@@ -214,7 +218,6 @@ DownloadItemView::DownloadItemView(DownloadUIModel::DownloadUIModelPtr download,
deep_scanning_label_(nullptr), deep_scanning_label_(nullptr),
open_now_button_(nullptr) { open_now_button_(nullptr) {
views::InstallRectHighlightPathGenerator(this); views::InstallRectHighlightPathGenerator(this);
SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER);
model_->AddObserver(this); model_->AddObserver(this);
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
...@@ -464,7 +467,7 @@ void DownloadItemView::OnDownloadOpened() { ...@@ -464,7 +467,7 @@ void DownloadItemView::OnDownloadOpened() {
// In dangerous mode we have to layout our buttons. // In dangerous mode we have to layout our buttons.
void DownloadItemView::Layout() { void DownloadItemView::Layout() {
InkDropHostView::Layout(); View::Layout();
UpdateColorsFromTheme(); UpdateColorsFromTheme();
...@@ -581,7 +584,6 @@ bool DownloadItemView::OnMouseDragged(const ui::MouseEvent& event) { ...@@ -581,7 +584,6 @@ bool DownloadItemView::OnMouseDragged(const ui::MouseEvent& event) {
if (!starting_drag_) { if (!starting_drag_) {
starting_drag_ = true; starting_drag_ = true;
drag_start_point_ = event.location(); drag_start_point_ = event.location();
AnimateInkDrop(views::InkDropState::HIDDEN, &event);
} }
if (dragging_) { if (dragging_) {
if (model_->GetState() == DownloadItem::COMPLETE) { if (model_->GetState() == DownloadItem::COMPLETE) {
...@@ -639,10 +641,6 @@ void DownloadItemView::OnThemeChanged() { ...@@ -639,10 +641,6 @@ void DownloadItemView::OnThemeChanged() {
UpdateDropdownButton(); UpdateDropdownButton();
} }
void DownloadItemView::OnInkDropCreated() {
ConfigureInkDrop();
}
void DownloadItemView::ShowContextMenuForViewImpl( void DownloadItemView::ShowContextMenuForViewImpl(
View* source, View* source,
const gfx::Point& point, const gfx::Point& point,
...@@ -921,8 +919,6 @@ void DownloadItemView::ShowContextMenuImpl(const gfx::Rect& rect, ...@@ -921,8 +919,6 @@ void DownloadItemView::ShowContextMenuImpl(const gfx::Rect& rect,
static_cast<views::internal::RootView*>(GetWidget()->GetRootView()) static_cast<views::internal::RootView*>(GetWidget()->GetRootView())
->SetMouseHandler(nullptr); ->SetMouseHandler(nullptr);
AnimateInkDrop(views::InkDropState::HIDDEN, nullptr);
if (!context_menu_.get()) if (!context_menu_.get())
context_menu_ = std::make_unique<DownloadShelfContextMenuView>(this); context_menu_ = std::make_unique<DownloadShelfContextMenuView>(this);
context_menu_->Run(GetWidget()->GetTopLevelWidget(), rect, source_type, context_menu_->Run(GetWidget()->GetTopLevelWidget(), rect, source_type,
...@@ -948,18 +944,8 @@ void DownloadItemView::SetDropdownState(State new_state) { ...@@ -948,18 +944,8 @@ void DownloadItemView::SetDropdownState(State new_state) {
SchedulePaint(); SchedulePaint();
} }
void DownloadItemView::ConfigureInkDrop() {
if (HasInkDrop())
GetInkDrop()->SetShowHighlightOnHover(!IsShowingWarningDialog());
}
SkColor DownloadItemView::GetInkDropBaseColor() const {
return color_utils::DeriveDefaultIconColor(GetTextColor());
}
void DownloadItemView::SetMode(Mode mode) { void DownloadItemView::SetMode(Mode mode) {
mode_ = mode; mode_ = mode;
ConfigureInkDrop();
} }
void DownloadItemView::TransitionToWarningDialog() { void DownloadItemView::TransitionToWarningDialog() {
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include "content/public/browser/download_manager.h" #include "content/public/browser/download_manager.h"
#include "ui/gfx/font_list.h" #include "ui/gfx/font_list.h"
#include "ui/views/animation/animation_delegate_views.h" #include "ui/views/animation/animation_delegate_views.h"
#include "ui/views/animation/ink_drop_host_view.h"
#include "ui/views/context_menu_controller.h" #include "ui/views/context_menu_controller.h"
#include "ui/views/controls/button/button.h" #include "ui/views/controls/button/button.h"
...@@ -60,7 +59,7 @@ class StyledLabel; ...@@ -60,7 +59,7 @@ class StyledLabel;
// Represents a single download item on the download shelf. Encompasses an icon, // Represents a single download item on the download shelf. Encompasses an icon,
// text, malicious download warnings, etc. // text, malicious download warnings, etc.
class DownloadItemView : public views::InkDropHostView, class DownloadItemView : public views::View,
public views::ButtonListener, public views::ButtonListener,
public views::ContextMenuController, public views::ContextMenuController,
public DownloadUIModel::Observer, public DownloadUIModel::Observer,
...@@ -103,10 +102,6 @@ class DownloadItemView : public views::InkDropHostView, ...@@ -103,10 +102,6 @@ class DownloadItemView : public views::InkDropHostView,
base::string16 GetTooltipText(const gfx::Point& p) const override; base::string16 GetTooltipText(const gfx::Point& p) const override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override; void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
// view::InkDropHostView:
void OnInkDropCreated() override;
SkColor GetInkDropBaseColor() const override;
// views::ContextMenuController. // views::ContextMenuController.
void ShowContextMenuForViewImpl(View* source, void ShowContextMenuForViewImpl(View* source,
const gfx::Point& point, const gfx::Point& point,
...@@ -201,9 +196,6 @@ class DownloadItemView : public views::InkDropHostView, ...@@ -201,9 +196,6 @@ class DownloadItemView : public views::InkDropHostView,
// Sets the state and triggers a repaint. // Sets the state and triggers a repaint.
void SetDropdownState(State new_state); void SetDropdownState(State new_state);
// Configures the InkDrop. e.g. disables highlight when in dangerous mode.
void ConfigureInkDrop();
void SetMode(Mode mode); void SetMode(Mode mode);
// Whether we are in the dangerous mode. // Whether we are in the dangerous mode.
......
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