fix: add Chromium patch to fix RTL window buttons (#22016)

Classes that inherit from `NSThemeFrame` seem to show window buttons in the
incorrect position when the primary MacOS language is set to an RTL
(right-to-left) language like Arabic or Hebrew. The fix in this commit mirrors
that of `tabbed_browser_window.mm`
(https://chromium-review.googlesource.com/c/chromium/src/+/562603/10/chrome/browser/ui/cocoa/tabbed_browser_window.mm#88).

This change should be upstreamed, and then this patch can be removed.
This commit is contained in:
Sesh Sadasivam 2020-02-06 13:14:18 -08:00 committed by GitHub
parent f4fd939409
commit c8273e375c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View file

@ -81,3 +81,4 @@ feat_allow_disabling_blink_scheduler_throttling_per_renderview.patch
accessible_pane_view.patch
fixme_grit_conflicts.patch
fix_use_the_new_mediaplaypause_key_listener_for_internal_chrome.patch
fix_use_native_window_button_positions_when_macos_locale_is_rtl.patch

View file

@ -0,0 +1,31 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Sesh Sadasivam <sesh@fb.com>
Date: Fri, 31 Jan 2020 19:02:27 -0800
Subject: fix: use native window button positions when MacOS locale is RTL
Classes that inherit from `NSThemeFrame` seem to show window buttons in the
incorrect position when the primary MacOS language is set to an RTL
(right-to-left) language like Arabic or Hebrew. The fix in this commit mirrors
that of `tabbed_browser_window.mm`
(https://chromium-review.googlesource.com/c/chromium/src/+/562603/10/chrome/browser/ui/cocoa/tabbed_browser_window.mm#88).
This change should be upstreamed, and then this patch can be removed.
diff --git a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
index 9905e1c8914f852e250480797f43d17bf9d7f794..0016cc129805726d6518036fb181a2a9715af8c5 100644
--- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
+++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
@@ -69,6 +69,13 @@ - (void)mouseDown:(NSEvent*)event {
- (BOOL)usesCustomDrawing {
return NO;
}
+// AppKit's implementation only returns YES if [self class] == [NSThemeFrame
+// class]. See:
+// https://chromium-review.googlesource.com/c/chromium/src/+/562603/10/chrome/browser/ui/cocoa/tabbed_browser_window.mm#88
+- (BOOL)_shouldFlipTrafficLightsForRTL API_AVAILABLE(macosx(10.13)) {
+ return self.window.windowTitlebarLayoutDirection ==
+ NSUserInterfaceLayoutDirectionRightToLeft;
+}
@end
@implementation NativeWidgetMacNSWindowBorderlessFrame