From cd49a125c0fd9cb8dc74f709642ac4e3fc32cd66 Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Tue, 11 Sep 2018 12:39:18 +0900 Subject: [PATCH] Fix newtab button isn't clickable With chromium's recent change, this button's border path rect is calculated by using corder radius with layout value of EMPHASIS_MAXIMUM. However, we changed that value to 4. Because of this, path rect is calculated much smaller than buttons size. So, most hittest was failed. --- browser/ui/views/tabs/brave_new_tab_button.cc | 13 +++++++++++++ browser/ui/views/tabs/brave_new_tab_button.h | 4 ++++ ...ome-browser-ui-views-tabs-new_tab_button.h.patch | 10 +++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/browser/ui/views/tabs/brave_new_tab_button.cc b/browser/ui/views/tabs/brave_new_tab_button.cc index 84394d272f00..6592140bc21f 100644 --- a/browser/ui/views/tabs/brave_new_tab_button.cc +++ b/browser/ui/views/tabs/brave_new_tab_button.cc @@ -44,3 +44,16 @@ void BraveNewTabButton::PaintPlusIcon(gfx::Canvas* canvas, int offset, int size) const int fixed_offset = (GetContentsBounds().width() / 2) - (size / 2); NewTabButton::PaintPlusIcon(canvas, fixed_offset, size); } + +SkPath BraveNewTabButton::GetNewerMaterialUiButtonPath(float button_y, + float scale, + bool extend_to_top, + bool for_fill) const { + SkPath path; + const gfx::Rect contents_bounds = GetContentsBounds(); + path.addRect(0, extend_to_top ? 0 : button_y, + contents_bounds.width() * scale, + button_y + contents_bounds.height() * scale); + path.close(); + return path; +} diff --git a/browser/ui/views/tabs/brave_new_tab_button.h b/browser/ui/views/tabs/brave_new_tab_button.h index f692ec9187e4..27a418b565c5 100644 --- a/browser/ui/views/tabs/brave_new_tab_button.h +++ b/browser/ui/views/tabs/brave_new_tab_button.h @@ -19,6 +19,10 @@ class BraveNewTabButton : public NewTabButton { private: gfx::Size CalculatePreferredSize() const override; void PaintPlusIcon(gfx::Canvas* canvas, int offset, int size) override; + SkPath GetNewerMaterialUiButtonPath(float button_y, + float scale, + bool extend_to_top, + bool for_fill) const override; DISALLOW_COPY_AND_ASSIGN(BraveNewTabButton); }; diff --git a/patches/chrome-browser-ui-views-tabs-new_tab_button.h.patch b/patches/chrome-browser-ui-views-tabs-new_tab_button.h.patch index e9f717219c6c..647b67dcb11a 100644 --- a/patches/chrome-browser-ui-views-tabs-new_tab_button.h.patch +++ b/patches/chrome-browser-ui-views-tabs-new_tab_button.h.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/ui/views/tabs/new_tab_button.h b/chrome/browser/ui/views/tabs/new_tab_button.h -index ee40211315f979cfc34a7373195b2179b72429d4..9b3715cfe72390310b277f1ed0361821558da189 100644 +index ee40211315f979cfc34a7373195b2179b72429d4..6b0e87c2a7ae38b47c4a452ff0d6bacb1cb2620f 100644 --- a/chrome/browser/ui/views/tabs/new_tab_button.h +++ b/chrome/browser/ui/views/tabs/new_tab_button.h @@ -25,6 +25,7 @@ class NewTabButton : public views::ImageButton, @@ -19,3 +19,11 @@ index ee40211315f979cfc34a7373195b2179b72429d4..9b3715cfe72390310b277f1ed0361821 SkColor GetButtonFillColor(bool opaque) const; SkColor GetIconColor() const; +@@ -120,6 +121,7 @@ class NewTabButton : public views::ImageButton, + // the path will be shrunk by 1px from all sides to allow room for the stroke + // to show up. If |extend_to_top| is true, the path is extended vertically to + // y = 0. ++ virtual + SkPath GetNewerMaterialUiButtonPath(float button_y, + float scale, + bool extend_to_top,