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

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

Issue 2539543007: macOS: Fix <select> popup menu position in RTL. (Closed)
Patch Set: Created 4 years, 1 month 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..a5849161f9062d6e39765c90c92b11f1a50de44a 100644
--- a/content/browser/renderer_host/webmenurunner_mac.mm
+++ b/content/browser/renderer_host/webmenurunner_mac.mm
@@ -120,10 +120,25 @@
// bad happens.
[cell selectItemWithTag:index];
- if (rightAligned_ &&
- [cell respondsToSelector:@selector(setUserInterfaceLayoutDirection:)]) {
- [cell setUserInterfaceLayoutDirection:
- NSUserInterfaceLayoutDirectionRightToLeft];
+ if (rightAligned_) {
+ SEL sel = @selector(setUserInterfaceLayoutDirection:);
+ if ([cell respondsToSelector:sel]) {
Avi (use Gerrit) 2016/11/30 17:25:04 NSCell has supported this property since 10.6, so
tkent 2016/11/30 23:43:57 Done.
+ [cell setUserInterfaceLayoutDirection:
+ NSUserInterfaceLayoutDirectionRightToLeft];
+ }
+ // setUserInterfaceLayoutDirection for NSMenu is supported on macOS 10.11+.
+ 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