Commit 5bb16cdd authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Revert "Add HighlightPathGenerator to TabCloseButton"

This reverts commit b25e7445.

Reason for revert: The ink drop path here was not the same as the highlight path; in particular, the ink drop path is manually mirrored, while the highlight path is auto-mirrored.  Reverting since this results in the wrong appearance in RTL.

Original change's description:
> Add HighlightPathGenerator to TabCloseButton
> 
> Replaces OnBoundsChanged override which resulted in a lot of path
> generation (per-tab + frame) while opening new tabs or resizing the
> window.
> 
> Also removes a ::GetInkDropMask() override which just generated the same
> path.
> 
> Bug: chromium:1007546
> Change-Id: I0131f9a589c1525e2c0eacd61c9fcd9f6ac05948
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1861016
> Auto-Submit: Peter Boström <pbos@chromium.org>
> Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
> Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#705972}

TBR=ellyjones@chromium.org,pbos@chromium.org

Change-Id: Ic7bd1312d452c828877669db89af45ac59160455
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:1007546
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1864393Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706348}
parent c7933fba
...@@ -24,9 +24,9 @@ ...@@ -24,9 +24,9 @@
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
#include "ui/views/animation/ink_drop.h" #include "ui/views/animation/ink_drop.h"
#include "ui/views/animation/ink_drop_mask.h" #include "ui/views/animation/ink_drop_mask.h"
#include "ui/views/controls/highlight_path_generator.h"
#include "ui/views/layout/layout_provider.h" #include "ui/views/layout/layout_provider.h"
#include "ui/views/rect_based_targeting_utils.h" #include "ui/views/rect_based_targeting_utils.h"
#include "ui/views/view_class_properties.h"
#if defined(USE_AURA) #if defined(USE_AURA)
#include "ui/aura/env.h" #include "ui/aura/env.h"
...@@ -35,25 +35,6 @@ ...@@ -35,25 +35,6 @@
namespace { namespace {
constexpr int kGlyphWidth = 16; constexpr int kGlyphWidth = 16;
constexpr int kTouchGlyphWidth = 24; constexpr int kTouchGlyphWidth = 24;
class TabCloseButtonHighlightPathGenerator
: public views::HighlightPathGenerator {
public:
TabCloseButtonHighlightPathGenerator() = default;
// views::HighlightPathGenerator:
SkPath GetHighlightPath(const views::View* view) override {
const gfx::Rect bounds = view->GetContentsBounds();
const gfx::Point center = bounds.CenterPoint();
const int radius = views::LayoutProvider::Get()->GetCornerRadiusMetric(
views::EMPHASIS_MAXIMUM, bounds.size());
return SkPath().addCircle(center.x(), center.y(), radius);
}
private:
DISALLOW_COPY_AND_ASSIGN(TabCloseButtonHighlightPathGenerator);
};
} // namespace } // namespace
TabCloseButton::TabCloseButton(views::ButtonListener* listener, TabCloseButton::TabCloseButton(views::ButtonListener* listener,
...@@ -74,8 +55,6 @@ TabCloseButton::TabCloseButton(views::ButtonListener* listener, ...@@ -74,8 +55,6 @@ TabCloseButton::TabCloseButton(views::ButtonListener* listener,
GetInkDrop()->SetHoverHighlightFadeDuration(base::TimeDelta()); GetInkDrop()->SetHoverHighlightFadeDuration(base::TimeDelta());
SetInstallFocusRingOnFocus(true); SetInstallFocusRingOnFocus(true);
views::HighlightPathGenerator::Install(
this, std::make_unique<TabCloseButtonHighlightPathGenerator>());
} }
TabCloseButton::~TabCloseButton() {} TabCloseButton::~TabCloseButton() {}
...@@ -141,6 +120,25 @@ gfx::Size TabCloseButton::CalculatePreferredSize() const { ...@@ -141,6 +120,25 @@ gfx::Size TabCloseButton::CalculatePreferredSize() const {
return size; return size;
} }
void TabCloseButton::OnBoundsChanged(const gfx::Rect& previous_bounds) {
ImageButton::OnBoundsChanged(previous_bounds);
auto path = std::make_unique<SkPath>();
const gfx::Rect bounds = GetContentsBounds();
const gfx::Point center = bounds.CenterPoint();
const int radius = views::LayoutProvider::Get()->GetCornerRadiusMetric(
views::EMPHASIS_MAXIMUM, bounds.size());
path->addCircle(center.x(), center.y(), radius);
SetProperty(views::kHighlightPathKey, path.release());
}
std::unique_ptr<views::InkDropMask> TabCloseButton::CreateInkDropMask() const {
const gfx::Rect bounds = GetContentsBounds();
const int radius = views::LayoutProvider::Get()->GetCornerRadiusMetric(
views::EMPHASIS_MAXIMUM, bounds.size());
return std::make_unique<views::CircleInkDropMask>(
size(), GetMirroredRect(bounds).CenterPoint(), radius);
}
void TabCloseButton::PaintButtonContents(gfx::Canvas* canvas) { void TabCloseButton::PaintButtonContents(gfx::Canvas* canvas) {
cc::PaintFlags flags; cc::PaintFlags flags;
constexpr float kStrokeWidth = 1.5f; constexpr float kStrokeWidth = 1.5f;
......
...@@ -44,10 +44,12 @@ class TabCloseButton : public views::ImageButton, ...@@ -44,10 +44,12 @@ class TabCloseButton : public views::ImageButton,
void OnMouseReleased(const ui::MouseEvent& event) override; void OnMouseReleased(const ui::MouseEvent& event) override;
void OnMouseMoved(const ui::MouseEvent& event) override; void OnMouseMoved(const ui::MouseEvent& event) override;
void OnGestureEvent(ui::GestureEvent* event) override; void OnGestureEvent(ui::GestureEvent* event) override;
std::unique_ptr<views::InkDropMask> CreateInkDropMask() const override;
protected: protected:
// views::ImageButton: // views::ImageButton:
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
void PaintButtonContents(gfx::Canvas* canvas) override; void PaintButtonContents(gfx::Canvas* canvas) override;
private: private:
......
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