From 7dadfb3f1deba44fbdbb7836269a28377e28d5d2 Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Sun, 17 Apr 2022 12:43:36 +0900 Subject: [PATCH] Fixed tab mute button of inactive tab is not clickabl fix https://github.com/brave/brave-browser/issues/22081 Fixed by calculating tab selectable region properly by GetWidthOfLargestSelectableRegionBrave() as we moved alert button to left side. --- .../chrome/browser/ui/views/tabs/tab.cc | 23 +++++++++++++++++++ .../chrome/browser/ui/views/tabs/tab.h | 7 ++++++ 2 files changed, 30 insertions(+) diff --git a/chromium_src/chrome/browser/ui/views/tabs/tab.cc b/chromium_src/chrome/browser/ui/views/tabs/tab.cc index 73383bc9ef85..00775ca38e73 100644 --- a/chromium_src/chrome/browser/ui/views/tabs/tab.cc +++ b/chromium_src/chrome/browser/ui/views/tabs/tab.cc @@ -3,6 +3,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "chrome/browser/ui/views/tabs/tab.h" + // Set alert indicator's pos to start of the title and // move title after the alert indicator. // Title right should respect close btn's space @@ -17,6 +19,27 @@ #define BRAVE_UI_VIEWS_TABS_TAB_UPDATE_ICON_VISIBILITY \ showing_close_button_ &= mouse_hovered(); +#define GetWidthOfLargestSelectableRegion \ + GetWidthOfLargestSelectableRegion_ChromiumImpl #include "src/chrome/browser/ui/views/tabs/tab.cc" #undef BRAVE_UI_VIEWS_TABS_TAB_UPDATE_ICON_VISIBILITY #undef BRAVE_UI_VIEWS_TABS_TAB_ALERT_INDICATOR_POSITION +#undef GetWidthOfLargestSelectableRegion + +// Re-defined because we moved alert button to left side in the tab whereas +// upstream put it on right side. Need to consider this change for calculating +// largest selectable region. +int Tab::GetWidthOfLargestSelectableRegion() const { + // Assume the entire region except the area that alert indicator/close buttons + // occupied is available for click-to-select. + // If neither are visible, the entire tab region is available. + int selectable_width = width(); + if (alert_indicator_button_->GetVisible()) { + selectable_width -= alert_indicator_button_->width(); + } + + if (close_button_->GetVisible()) + selectable_width -= close_button_->width(); + + return std::max(0, selectable_width); +} diff --git a/chromium_src/chrome/browser/ui/views/tabs/tab.h b/chromium_src/chrome/browser/ui/views/tabs/tab.h index f1c451ef2fd9..796294bbc320 100644 --- a/chromium_src/chrome/browser/ui/views/tabs/tab.h +++ b/chromium_src/chrome/browser/ui/views/tabs/tab.h @@ -5,9 +5,16 @@ #ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ #define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ + #define kMinimumContentsWidthForCloseButtons \ kMinimumContentsWidthForCloseButtons = 55; \ static constexpr int kMinimumContentsWidthForCloseButtons_UnUsed + +#define GetWidthOfLargestSelectableRegion \ + GetWidthOfLargestSelectableRegion() const; \ + int GetWidthOfLargestSelectableRegion_ChromiumImpl #include "src/chrome/browser/ui/views/tabs/tab.h" #undef kMinimumContentsWidthForCloseButtons +#undef GetWidthOfLargestSelectableRegion + #endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_