Skip to content

Commit

Permalink
Fix IPH menu button animation for non-unit scale factors
Browse files Browse the repository at this point in the history
This is a workaround for a layer mask invalidation bug.

Bug: 909755, 935808
Change-Id: Ib634ab20b731bafc658487ddcaf4de98167cbe6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1487142
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: Peter Boström <pbos@chromium.org>
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#637387}
  • Loading branch information
chbaker0 authored and Commit Bot committed Mar 4, 2019
1 parent 5be1786 commit 1454e52
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
20 changes: 16 additions & 4 deletions chrome/browser/ui/views/toolbar/browser_app_menu_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ constexpr float kFeaturePromoPulseInsetDip = 3.0f;
class PulsingInkDropMask : public gfx::AnimationDelegate,
public views::InkDropMask {
public:
PulsingInkDropMask(const gfx::Size& layer_size,
PulsingInkDropMask(views::View* layer_container,
const gfx::Size& layer_size,
float normal_corner_radius,
float max_inset)
: views::InkDropMask(layer_size),
layer_container_(layer_container),
normal_corner_radius_(normal_corner_radius),
max_inset_(max_inset),
throb_animation_(this) {
Expand Down Expand Up @@ -109,8 +111,18 @@ class PulsingInkDropMask : public gfx::AnimationDelegate,
void AnimationProgressed(const gfx::Animation* animation) override {
DCHECK_EQ(animation, &throb_animation_);
layer()->SchedulePaint(gfx::Rect(layer()->size()));

// This is a workaround for crbug.com/935808: for scale factors >1,
// invalidating the mask layer doesn't cause the whole layer to be repainted
// on screen. TODO(crbug.com/935808): remove this workaround once the bug is
// fixed.
layer_container_->SchedulePaint();
}

// The View that contains the InkDrop layer we're masking. This must outlive
// our instance.
views::View* const layer_container_;

// Normal corner radius of the ink drop without animation. This is also the
// corner radius at the largest instant of the animation.
const float normal_corner_radius_;
Expand Down Expand Up @@ -382,9 +394,9 @@ std::unique_ptr<views::InkDropMask> BrowserAppMenuButton::CreateInkDropMask()
#if BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
if (promo_feature_) {
const float corner_radius = height() / 2.0f;
return std::make_unique<PulsingInkDropMask>(ink_drop_container()->size(),
corner_radius,
kFeaturePromoPulseInsetDip);
return std::make_unique<PulsingInkDropMask>(
ink_drop_container(), ink_drop_container()->size(), corner_radius,
kFeaturePromoPulseInsetDip);
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion ui/views/controls/button/label_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class VIEWS_EXPORT LabelButton : public Button, public NativeThemeDelegate {
// A separate view is necessary to hold the ink drop layer so that it can
// be stacked below |image_| and on top of |label_|, without resorting to
// drawing |label_| on a layer (which can mess with subpixel anti-aliasing).
InkDropContainerView* ink_drop_container_;
InkDropContainerView* const ink_drop_container_;

// The cached font lists in the normal and default button style. The latter
// may be bold.
Expand Down

0 comments on commit 1454e52

Please sign in to comment.