Commit 18d20ce6 authored by lgrey's avatar lgrey Committed by Commit bot

[Mac] Fix Omnibox decoration accessibility views in RTL

BUG=715627

Review-Url: https://codereview.chromium.org/2848953002
Cr-Commit-Position: refs/heads/master@{#468115}
parent e752d174
...@@ -159,9 +159,10 @@ size_t CalculatePositionsInFrame( ...@@ -159,9 +159,10 @@ size_t CalculatePositionsInFrame(
// Flip all frames in RTL. // Flip all frames in RTL.
if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout()) { if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout()) {
for (NSRect& rect : *decoration_frames) for (NSRect& rect : *decoration_frames)
rect.origin.x = NSWidth(frame) - NSWidth(rect) - NSMinX(rect); rect.origin.x =
text_frame->origin.x = NSMinX(frame) + NSMaxX(frame) - NSWidth(rect) - NSMinX(rect);
NSWidth(frame) - NSWidth(*text_frame) - NSMinX(*text_frame); text_frame->origin.x = NSMinX(frame) + NSMaxX(frame) -
NSWidth(*text_frame) - NSMinX(*text_frame);
leading_count = decorations->size() - leading_count; leading_count = decorations->size() - leading_count;
} }
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h" #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h"
#import "chrome/browser/ui/cocoa/first_run_bubble_controller.h" #import "chrome/browser/ui/cocoa/first_run_bubble_controller.h"
#import "chrome/browser/ui/cocoa/info_bubble_view.h" #import "chrome/browser/ui/cocoa/info_bubble_view.h"
#import "chrome/browser/ui/cocoa/l10n_util.h"
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h"
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h"
#import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h" #import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h"
...@@ -742,6 +743,8 @@ void LocationBarViewMac::UpdateAccessibilityView( ...@@ -742,6 +743,8 @@ void LocationBarViewMac::UpdateAccessibilityView(
LocationBarDecoration* decoration) { LocationBarDecoration* decoration) {
if (!decoration->IsVisible()) if (!decoration->IsVisible())
return; return;
// This uses |frame| instead of |bounds| because the accessibility views are
// parented to the toolbar.
NSRect apparent_frame = NSRect apparent_frame =
[[field_ cell] frameForDecoration:decoration inFrame:[field_ frame]]; [[field_ cell] frameForDecoration:decoration inFrame:[field_ frame]];
...@@ -766,9 +769,13 @@ void LocationBarViewMac::UpdateAccessibilityView( ...@@ -766,9 +769,13 @@ void LocationBarViewMac::UpdateAccessibilityView(
// before the button preceding the omnibox in the key view order. This // before the button preceding the omnibox in the key view order. This
// threshold is just a guess. // threshold is just a guess.
DCHECK_LT(left_index, 10); DCHECK_LT(left_index, 10);
if (left_index != -1) if (left_index != -1) {
real_frame.origin.x = [field_ frame].origin.x - left_index - 1; CGFloat delta = left_index + 1;
real_frame.origin.x =
cocoa_l10n_util::ShouldDoExperimentalRTLLayout()
? NSMaxX([field_ frame]) + delta - NSWidth(real_frame)
: NSMinX([field_ frame]) - delta;
}
decoration->UpdateAccessibilityView(apparent_frame); decoration->UpdateAccessibilityView(apparent_frame);
[decoration->GetAccessibilityView() setFrame:real_frame]; [decoration->GetAccessibilityView() setFrame:real_frame];
[decoration->GetAccessibilityView() setNeedsDisplayInRect:apparent_frame]; [decoration->GetAccessibilityView() setNeedsDisplayInRect:apparent_frame];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment