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 #include <cmath> | 5 #include <cmath> |
6 | 6 |
7 #import "chrome/browser/ui/cocoa/location_bar/bubble_decoration.h" | 7 #import "chrome/browser/ui/cocoa/location_bar/bubble_decoration.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 const CGFloat image_width = GetWidthForImageAndLabel(image_, nil); | 96 const CGFloat image_width = GetWidthForImageAndLabel(image_, nil); |
97 if (image_width <= width) | 97 if (image_width <= width) |
98 return image_width; | 98 return image_width; |
99 | 99 |
100 return kOmittedWidth; | 100 return kOmittedWidth; |
101 } | 101 } |
102 | 102 |
103 NSRect BubbleDecoration::GetBackgroundFrame(NSRect frame) { | 103 NSRect BubbleDecoration::GetBackgroundFrame(NSRect frame) { |
104 NSRect background_frame = NSInsetRect(frame, 0.0, kBackgroundFrameYInset); | 104 NSRect background_frame = NSInsetRect(frame, 0.0, kBackgroundFrameYInset); |
105 background_frame.origin.x += kBackgroundFrameLeftMargin; | 105 if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout()) { |
106 background_frame.size.width -= kDividerPadding; | 106 background_frame.origin.x += kDividerPadding; |
| 107 background_frame.size.width -= kDividerPadding + kBackgroundFrameLeftMargin; |
| 108 } else { |
| 109 background_frame.origin.x += kBackgroundFrameLeftMargin; |
| 110 background_frame.size.width -= kDividerPadding; |
| 111 } |
107 return background_frame; | 112 return background_frame; |
108 } | 113 } |
109 | 114 |
110 void BubbleDecoration::DrawInFrame(NSRect frame, NSView* control_view) { | 115 void BubbleDecoration::DrawInFrame(NSRect frame, NSView* control_view) { |
111 const NSRect decoration_frame = NSInsetRect(frame, 0.0, kImageFrameYInset); | 116 const NSRect decoration_frame = NSInsetRect(frame, 0.0, kImageFrameYInset); |
112 CGFloat text_left_offset = NSMinX(decoration_frame); | 117 CGFloat text_left_offset = NSMinX(decoration_frame); |
113 CGFloat text_right_offset = NSMaxX(decoration_frame); | 118 CGFloat text_right_offset = NSMaxX(decoration_frame); |
114 const BOOL is_rtl = cocoa_l10n_util::ShouldDoExperimentalRTLLayout(); | 119 const BOOL is_rtl = cocoa_l10n_util::ShouldDoExperimentalRTLLayout(); |
115 | 120 |
116 if (image_) { | 121 if (image_) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 [attributes_ setObject:text_color forKey:NSForegroundColorAttributeName]; | 202 [attributes_ setObject:text_color forKey:NSForegroundColorAttributeName]; |
198 } | 203 } |
199 | 204 |
200 void BubbleDecoration::SetFont(NSFont* font) { | 205 void BubbleDecoration::SetFont(NSFont* font) { |
201 [attributes_ setObject:font forKey:NSFontAttributeName]; | 206 [attributes_ setObject:font forKey:NSFontAttributeName]; |
202 } | 207 } |
203 | 208 |
204 void BubbleDecoration::SetRetinaBaselineOffset(CGFloat offset) { | 209 void BubbleDecoration::SetRetinaBaselineOffset(CGFloat offset) { |
205 retina_baseline_offset_ = offset; | 210 retina_baseline_offset_ = offset; |
206 } | 211 } |
OLD | NEW |