| Index: chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm
|
| diff --git a/chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm b/chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm
|
| index 40c69a481214cb95b75d8ce9df2af82402793775..1324e00fd318e3b1b35661ca103cd93d49259d0a 100644
|
| --- a/chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm
|
| +++ b/chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm
|
| @@ -15,6 +15,7 @@
|
| #include "chrome/browser/ui/browser_list.h"
|
| #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h"
|
| #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h"
|
| +#import "chrome/browser/ui/cocoa/l10n_util.h"
|
| #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
|
| #import "chrome/browser/ui/cocoa/themed_window.h"
|
| #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
|
| @@ -368,6 +369,7 @@ CGFloat ContentSettingDecoration::GetWidthForSpace(CGFloat width) {
|
| }
|
|
|
| void ContentSettingDecoration::DrawInFrame(NSRect frame, NSView* control_view) {
|
| + const BOOL is_rtl = cocoa_l10n_util::ShouldDoExperimentalRTLLayout();
|
| if ([animation_ animationState] != kNoAnimation) {
|
| NSRect background_rect = NSInsetRect(frame, 0.0, kBorderPadding);
|
| // This code is almost identical to code that appears in BubbleDecoration.
|
| @@ -383,25 +385,53 @@ void ContentSettingDecoration::DrawInFrame(NSRect frame, NSView* control_view) {
|
| NSImage* icon = GetImage();
|
| NSRect icon_rect = background_rect;
|
| if (icon) {
|
| - icon_rect.origin.x += kIconMarginPadding;
|
| + if (is_rtl) {
|
| + icon_rect.origin.x =
|
| + NSMaxX(background_rect) - kIconMarginPadding - [icon size].width;
|
| + } else {
|
| + icon_rect.origin.x += kIconMarginPadding;
|
| + }
|
| icon_rect.size.width = [icon size].width;
|
| ImageDecoration::DrawInFrame(icon_rect, control_view);
|
| }
|
|
|
| NSRect remainder = frame;
|
| - remainder.origin.x = NSMaxX(icon_rect) + kTextMarginPadding;
|
| - remainder.size.width =
|
| - NSMaxX(background_rect) - NSMinX(remainder) - kTextDividerPadding;
|
| - DrawAttributedString(animated_text_, remainder);
|
| + if (is_rtl) {
|
| + // drawInRect doesn't take line sweep into account when drawing with
|
| + // NSLineBreakByClipping
|
| + // This causes the animation to anchor to the left and look like it's
|
| + // growing the bounds, as opposed to revealing the text.
|
| + // rdar://29576934
|
| + // To compensate, draw the whole string with a negative offset and clip to
|
| + // the drawing area.
|
| + remainder.size.width = MeasureTextWidth();
|
| + remainder.origin.x =
|
| + NSMinX(icon_rect) - kTextMarginPadding - NSWidth(remainder);
|
| + NSRect clip_rect = background_rect;
|
| + clip_rect.origin.x += kTextDividerPadding;
|
| + NSBezierPath* clip_path = [NSBezierPath bezierPathWithRect:clip_rect];
|
| + [control_view lockFocus];
|
| + [clip_path addClip];
|
| + DrawAttributedString(animated_text_, remainder);
|
| + [control_view unlockFocus];
|
| + } else {
|
| + remainder.origin.x = NSMaxX(icon_rect) + kTextMarginPadding;
|
| + remainder.size.width =
|
| + NSMaxX(background_rect) - NSMinX(remainder) - kTextDividerPadding;
|
| + DrawAttributedString(animated_text_, remainder);
|
| + }
|
|
|
| // Draw the divider if available.
|
| if (state() == DecorationMouseState::NONE && !active()) {
|
| + const CGFloat divider_x_position =
|
| + is_rtl ? NSMinX(background_rect) + kDividerPadding
|
| + : NSMaxX(background_rect) - kDividerPadding;
|
| NSBezierPath* line = [NSBezierPath bezierPath];
|
| [line setLineWidth:1];
|
| - [line moveToPoint:NSMakePoint(NSMaxX(background_rect) - kDividerPadding,
|
| - NSMinY(background_rect))];
|
| - [line lineToPoint:NSMakePoint(NSMaxX(background_rect) - kDividerPadding,
|
| - NSMaxY(background_rect))];
|
| + [line
|
| + moveToPoint:NSMakePoint(divider_x_position, NSMinY(background_rect))];
|
| + [line
|
| + lineToPoint:NSMakePoint(divider_x_position, NSMaxY(background_rect))];
|
| [GetDividerColor(owner_->IsLocationBarDark()) set];
|
| [line stroke];
|
| }
|
|
|