Skip to content

Commit

Permalink
Fixed tab mute button of inactive tab is not clickabl
Browse files Browse the repository at this point in the history
fix brave/brave-browser#22081

Fixed by calculating tab selectable region properly by
GetWidthOfLargestSelectableRegionBrave() as we moved alert button
to left side.
  • Loading branch information
simonhong committed Apr 19, 2022
1 parent fc39311 commit 7dadfb3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
23 changes: 23 additions & 0 deletions chromium_src/chrome/browser/ui/views/tabs/tab.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
7 changes: 7 additions & 0 deletions chromium_src/chrome/browser/ui/views/tabs/tab.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_

0 comments on commit 7dadfb3

Please sign in to comment.