| 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 77139739d6a4fe501c0b114991bcaeca395e1f4d..c8849207fa3897ae3a6ecc3b5f7776eb319f22c3 100644
|
| --- a/chrome/browser/ui/cocoa/l10n_util.mm
|
| +++ b/chrome/browser/ui/cocoa/l10n_util.mm
|
| @@ -5,6 +5,7 @@
|
| #import "chrome/browser/ui/cocoa/l10n_util.h"
|
|
|
| #include "base/i18n/rtl.h"
|
| +#include "base/mac/mac_util.h"
|
| #include "base/strings/string_util.h"
|
| #include "base/strings/sys_string_conversions.h"
|
| #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTweaker.h"
|
| @@ -91,4 +92,47 @@ bool ShouldDoExperimentalRTLLayout() {
|
| base::FeatureList::IsEnabled(kExperimentalMacRTL);
|
| }
|
|
|
| +#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
|
|
|