Commit 320e6d06 authored by Dana Fried's avatar Dana Fried Committed by Commit Bot

Fix RTL tabstrip issue on MacOS 10.10 and 10.11

Caption buttons on most platforms stay on the leading edge of the
tabstrip in RTL mode, which effectively means they switch sides.

This is not true on Mac 10.10 and 10.11, however. Unfortunately, this
change is not reflected in the logic, which means the tabstrip still
renders in RTL on those platforms as if the caption buttons are on the
right (leading) side rather than the left (where they actually are).

This change makes the following functions behave correctly on MacOS
10.10 and 10.11:
 - BrowserNonClientFrameViewMac::CaptionButtonsOnLeadingEdge()
 - BrowserNonClientFrameViewMac::GetBoundsForTabStripRegion()

Bug: 891311
Change-Id: I3ad3d190cab805b3960a4920b48069f3d4e782c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1972930Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Dana Fried <dfried@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726090}
parent c44018b0
...@@ -114,7 +114,10 @@ void BrowserNonClientFrameViewMac::OnFullscreenStateChanged() { ...@@ -114,7 +114,10 @@ void BrowserNonClientFrameViewMac::OnFullscreenStateChanged() {
} }
bool BrowserNonClientFrameViewMac::CaptionButtonsOnLeadingEdge() const { bool BrowserNonClientFrameViewMac::CaptionButtonsOnLeadingEdge() const {
return true; // In OSX 10.10 and 10.11, caption buttons always get drawn on the left side
// of the browser frame instead of the leading edge. This causes a discrepancy
// in RTL mode.
return !base::i18n::IsRTL() || base::mac::IsAtLeastOS10_12();
} }
gfx::Rect BrowserNonClientFrameViewMac::GetBoundsForTabStripRegion( gfx::Rect BrowserNonClientFrameViewMac::GetBoundsForTabStripRegion(
...@@ -125,12 +128,20 @@ gfx::Rect BrowserNonClientFrameViewMac::GetBoundsForTabStripRegion( ...@@ -125,12 +128,20 @@ gfx::Rect BrowserNonClientFrameViewMac::GetBoundsForTabStripRegion(
// calling through private APIs. // calling through private APIs.
DCHECK(tabstrip); DCHECK(tabstrip);
constexpr int kTabstripLeftInset = 70; // Make room for caption buttons.
// Do not draw caption buttons on fullscreen.
const int x = frame()->IsFullscreen() ? 0 : kTabstripLeftInset;
const bool restored = !frame()->IsMaximized() && !frame()->IsFullscreen(); const bool restored = !frame()->IsMaximized() && !frame()->IsFullscreen();
return gfx::Rect(x, GetTopInset(restored), width() - x, gfx::Rect bounds(0, GetTopInset(restored), width(),
tabstrip->GetPreferredSize().height()); tabstrip->GetPreferredSize().height());
// Do not draw caption buttons on fullscreen.
if (!frame()->IsFullscreen()) {
constexpr int kCaptionWidth = 70;
if (CaptionButtonsOnLeadingEdge())
bounds.Inset(gfx::Insets(0, kCaptionWidth, 0, 0));
else
bounds.Inset(gfx::Insets(0, 0, 0, kCaptionWidth));
}
return bounds;
} }
int BrowserNonClientFrameViewMac::GetTopInset(bool restored) const { int BrowserNonClientFrameViewMac::GetTopInset(bool restored) const {
......
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