| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/l10n_util.h" | 5 #import "chrome/browser/ui/cocoa/l10n_util.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 110 } |
| 111 #else | 111 #else |
| 112 NSCellImagePosition LeadingCellImagePosition() { | 112 NSCellImagePosition LeadingCellImagePosition() { |
| 113 return NSImageLeading; | 113 return NSImageLeading; |
| 114 } | 114 } |
| 115 NSCellImagePosition TrailingCellImagePosition() { | 115 NSCellImagePosition TrailingCellImagePosition() { |
| 116 return NSImageTrailing; | 116 return NSImageTrailing; |
| 117 } | 117 } |
| 118 #endif // MAC_OS_X_VERSION_10_12 | 118 #endif // MAC_OS_X_VERSION_10_12 |
| 119 | 119 |
| 120 NSRectEdge LeadingEdge() { |
| 121 return ShouldDoExperimentalRTLLayout() ? NSMaxXEdge : NSMinXEdge; |
| 122 } |
| 123 |
| 124 NSRectEdge TrailingEdge() { |
| 125 return ShouldDoExperimentalRTLLayout() ? NSMinXEdge : NSMaxXEdge; |
| 126 } |
| 127 |
| 120 // Adapted from Apple's RTL docs (goo.gl/cBaFnT) | 128 // Adapted from Apple's RTL docs (goo.gl/cBaFnT) |
| 121 NSImage* FlippedImage(NSImage* image) { | 129 NSImage* FlippedImage(NSImage* image) { |
| 122 const NSSize size = [image size]; | 130 const NSSize size = [image size]; |
| 123 NSImage* flipped_image = [[[NSImage alloc] initWithSize:size] autorelease]; | 131 NSImage* flipped_image = [[[NSImage alloc] initWithSize:size] autorelease]; |
| 124 | 132 |
| 125 [flipped_image lockFocus]; | 133 [flipped_image lockFocus]; |
| 126 [[NSGraphicsContext currentContext] | 134 [[NSGraphicsContext currentContext] |
| 127 setImageInterpolation:NSImageInterpolationHigh]; | 135 setImageInterpolation:NSImageInterpolationHigh]; |
| 128 | 136 |
| 129 NSAffineTransform* transform = [NSAffineTransform transform]; | 137 NSAffineTransform* transform = [NSAffineTransform transform]; |
| 130 [transform translateXBy:size.width yBy:0]; | 138 [transform translateXBy:size.width yBy:0]; |
| 131 [transform scaleXBy:-1 yBy:1]; | 139 [transform scaleXBy:-1 yBy:1]; |
| 132 [transform concat]; | 140 [transform concat]; |
| 133 | 141 |
| 134 [image drawAtPoint:NSZeroPoint | 142 [image drawAtPoint:NSZeroPoint |
| 135 fromRect:NSMakeRect(0, 0, size.width, size.height) | 143 fromRect:NSMakeRect(0, 0, size.width, size.height) |
| 136 operation:NSCompositeSourceOver | 144 operation:NSCompositeSourceOver |
| 137 fraction:1.0]; | 145 fraction:1.0]; |
| 138 | 146 |
| 139 [flipped_image unlockFocus]; | 147 [flipped_image unlockFocus]; |
| 140 | 148 |
| 141 return flipped_image; | 149 return flipped_image; |
| 142 } | 150 } |
| 143 | 151 |
| 144 } // namespace cocoa_l10n_util | 152 } // namespace cocoa_l10n_util |
| OLD | NEW |