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

Unified Diff: chrome/browser/ui/cocoa/l10n_util.mm

Issue 2511973002: Reverse bookmark buttons and menus in RTL (Closed)
Patch Set: Use line width instead of hardcoding cell inset 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 | « chrome/browser/ui/cocoa/l10n_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/l10n_util.mm
diff --git a/chrome/browser/ui/cocoa/l10n_util.mm b/chrome/browser/ui/cocoa/l10n_util.mm
index 73db01d423dc3cc07cc90f4444bb793e6e918b41..49f47c7fcb92cf88e0368d880306b98dd5478aa6 100644
--- a/chrome/browser/ui/cocoa/l10n_util.mm
+++ b/chrome/browser/ui/cocoa/l10n_util.mm
@@ -96,4 +96,47 @@ bool ShouldFlipWindowControlsInRTL() {
return ShouldDoExperimentalRTLLayout() && base::mac::IsAtLeastOS10_12();
}
+#if !defined(MAC_OS_X_VERSION_10_12) || \
+ MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
+NSCellImagePosition LeadingCellImagePosition() {
+ return ShouldDoExperimentalRTLLayout() ? NSImageRight : NSImageLeft;
+}
+NSCellImagePosition TrailingCellImagePosition() {
+ return ShouldDoExperimentalRTLLayout() ? NSImageLeft : NSImageRight;
+}
+#else
+NSCellImagePosition LeadingCellImagePosition() {
+ return NSImageLeading;
+}
+NSCellImagePosition TrailingCellImagePosition() {
+ return NSImageTrailing;
+}
+#endif // MAC_OS_X_VERSION_10_12
+
+// Adapted from Apple's RTL docs (goo.gl/cBaFnT)
+NSImage* FlippedImage(NSImage* image) {
+ NSImage* existingImage = image;
+ NSSize existingSize = [existingImage size];
+ NSSize newSize = NSMakeSize(existingSize.width, existingSize.height);
+ NSImage* flippedImage = [[[NSImage alloc] initWithSize:newSize] autorelease];
+
+ [flippedImage lockFocus];
+ [[NSGraphicsContext currentContext]
+ setImageInterpolation:NSImageInterpolationHigh];
+
+ NSAffineTransform* transform = [NSAffineTransform transform];
+ [transform translateXBy:existingSize.width yBy:0];
+ [transform scaleXBy:-1 yBy:1];
+ [transform concat];
+
+ [existingImage drawAtPoint:NSZeroPoint
+ fromRect:NSMakeRect(0, 0, newSize.width, newSize.height)
+ operation:NSCompositeSourceOver
+ fraction:1.0];
+
+ [flippedImage unlockFocus];
+
+ return flippedImage;
+}
+
} // namespace cocoa_l10n_util
« no previous file with comments | « chrome/browser/ui/cocoa/l10n_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698