Commit f683121b authored by Tim Song's avatar Tim Song Committed by Commit Bot

Fix focus ink drop rendering issue for toggle buttons.

A recent refactor changed the default ink drop logic, which caused a regression
in ToggleButton:
https://chromium-review.googlesource.com/c/chromium/src/+/1367186

All InkDropViewHosts now get a InkDropMask (default is a rounded rect). This change breaks
the ToggleView as it effectively gets clipped to the view bounds.

BUG=921485

Change-Id: I2fb1d5f1bb4981945fc93160fc75de9e533e1794
Reviewed-on: https://chromium-review.googlesource.com/c/1487079
Commit-Queue: Tim Song <tengs@chromium.org>
Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635759}
parent 6d0e3050
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "ui/gfx/shadow_value.h" #include "ui/gfx/shadow_value.h"
#include "ui/gfx/skia_paint_util.h" #include "ui/gfx/skia_paint_util.h"
#include "ui/views/animation/ink_drop_impl.h" #include "ui/views/animation/ink_drop_impl.h"
#include "ui/views/animation/ink_drop_mask.h"
#include "ui/views/animation/ink_drop_ripple.h" #include "ui/views/animation/ink_drop_ripple.h"
#include "ui/views/border.h" #include "ui/views/border.h"
#include "ui/views/painter.h" #include "ui/views/painter.h"
...@@ -99,6 +100,10 @@ class ToggleButton::ThumbView : public InkDropHostView { ...@@ -99,6 +100,10 @@ class ToggleButton::ThumbView : public InkDropHostView {
thumb_flags); thumb_flags);
} }
std::unique_ptr<InkDropMask> CreateInkDropMask() const override {
return nullptr;
}
// Color ratio between 0 and 1 that controls the thumb color. // Color ratio between 0 and 1 that controls the thumb color.
float color_ratio_; float color_ratio_;
...@@ -259,9 +264,15 @@ void ToggleButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { ...@@ -259,9 +264,15 @@ void ToggleButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) {
std::unique_ptr<InkDrop> ToggleButton::CreateInkDrop() { std::unique_ptr<InkDrop> ToggleButton::CreateInkDrop() {
std::unique_ptr<InkDropImpl> ink_drop = Button::CreateDefaultInkDropImpl(); std::unique_ptr<InkDropImpl> ink_drop = Button::CreateDefaultInkDropImpl();
ink_drop->SetShowHighlightOnHover(false); ink_drop->SetShowHighlightOnHover(false);
ink_drop->SetAutoHighlightMode(
InkDropImpl::AutoHighlightMode::HIDE_ON_RIPPLE);
return std::move(ink_drop); return std::move(ink_drop);
} }
std::unique_ptr<InkDropMask> ToggleButton::CreateInkDropMask() const {
return nullptr;
}
std::unique_ptr<InkDropRipple> ToggleButton::CreateInkDropRipple() const { std::unique_ptr<InkDropRipple> ToggleButton::CreateInkDropRipple() const {
gfx::Rect rect = thumb_view_->GetLocalBounds(); gfx::Rect rect = thumb_view_->GetLocalBounds();
rect.Inset(-ThumbView::GetShadowOutsets()); rect.Inset(-ThumbView::GetShadowOutsets());
......
...@@ -60,6 +60,7 @@ class VIEWS_EXPORT ToggleButton : public Button { ...@@ -60,6 +60,7 @@ class VIEWS_EXPORT ToggleButton : public Button {
void AddInkDropLayer(ui::Layer* ink_drop_layer) override; void AddInkDropLayer(ui::Layer* ink_drop_layer) override;
void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override;
std::unique_ptr<InkDrop> CreateInkDrop() override; std::unique_ptr<InkDrop> CreateInkDrop() override;
std::unique_ptr<InkDropMask> CreateInkDropMask() const override;
std::unique_ptr<InkDropRipple> CreateInkDropRipple() const override; std::unique_ptr<InkDropRipple> CreateInkDropRipple() const override;
SkColor GetInkDropBaseColor() const override; SkColor GetInkDropBaseColor() const override;
......
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