Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Unified Diff: content/browser/renderer_host/webmenurunner_mac.mm

Issue 2539543007: macOS: Fix <select> popup menu position in RTL. (Closed)
Patch Set: No respondoToSelector for NSPopUpButtonCell Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/webmenurunner_mac.mm
diff --git a/content/browser/renderer_host/webmenurunner_mac.mm b/content/browser/renderer_host/webmenurunner_mac.mm
index 0e189bedd6941e304e4797177054e3bbcad5fd58..e57cfae2c593e7ebae685e6083e63b13307539f8 100644
--- a/content/browser/renderer_host/webmenurunner_mac.mm
+++ b/content/browser/renderer_host/webmenurunner_mac.mm
@@ -120,10 +120,23 @@
// bad happens.
[cell selectItemWithTag:index];
- if (rightAligned_ &&
- [cell respondsToSelector:@selector(setUserInterfaceLayoutDirection:)]) {
+ if (rightAligned_) {
[cell setUserInterfaceLayoutDirection:
- NSUserInterfaceLayoutDirectionRightToLeft];
+ NSUserInterfaceLayoutDirectionRightToLeft];
+ // setUserInterfaceLayoutDirection for NSMenu is supported on macOS 10.11+.
+ SEL sel = @selector(setUserInterfaceLayoutDirection:);
+ if ([menu_ respondsToSelector:sel]) {
+ NSUserInterfaceLayoutDirection direction =
+ NSUserInterfaceLayoutDirectionRightToLeft;
+ NSMethodSignature* signature =
+ [NSMenu instanceMethodSignatureForSelector:sel];
+ NSInvocation* invocation =
+ [NSInvocation invocationWithMethodSignature:signature];
+ [invocation setTarget:menu_.get()];
+ [invocation setSelector:sel];
+ [invocation setArgument:&direction atIndex:2];
+ [invocation invoke];
+ }
}
// When popping up a menu near the Dock, Cocoa restricts the menu
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698