Chromium Code Reviews| Index: chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm |
| diff --git a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm |
| index 4b59a6a66a91374d3070697eb15adbd6afd3e568..bed1cbcebb9aae9317d3e2cb44ebd7357952e356 100644 |
| --- a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm |
| +++ b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm |
| @@ -742,11 +742,29 @@ new ManagePasswordsDecoration(command_updater, this)), |
| LocationBarDecoration* decoration) { |
| if (!decoration->IsVisible()) |
| return; |
| - NSRect r = |
| + NSRect apparent_frame = |
| [[field_ cell] frameForDecoration:decoration inFrame:[field_ frame]]; |
| - [decoration->GetAccessibilityView() setFrame:r]; |
| - [decoration->GetAccessibilityView() setNeedsDisplayInRect:r]; |
| - decoration->UpdateAccessibilityView(); |
| + |
| + // This is a bit subtle: |
| + // The decorations' accessibility views can become key to allow keyboard |
| + // access to the location bar decorations, but Cocoa's automatic key view loop |
| + // sorts by top-left coordinate. Since the omnibox's top-left coordinate is |
|
lgrey
2017/04/25 21:11:39
Do you know if the top-left thing holds in RTL?
I
Elly Fong-Jones
2017/04/26 16:50:01
It seems to proceed from the top right instead.
|
| + // before its leading decorations, the omnibox would sort before its own |
| + // leading decorations, which was logical but visually unintuitive. Therefore, |
| + // for leading decorations, this method moves their frame to be "just before" |
| + // the omnibox in automatic key view loop order, and gives them an apparent |
| + // frame (see DecorationAccessibilityView) so that they still paint their |
| + // focus rings at the right place. |
| + // |
| + // TODO(ellyjones): what happens in RTL layouts? |
| + NSRect real_frame = apparent_frame; |
| + int left_index = [[field_ cell] leadingDecorationIndex:decoration]; |
| + if (left_index != -1) |
| + real_frame.origin.x = [field_ frame].origin.x - left_index - 1; |
|
Mark Mentovai
2017/04/25 20:44:31
Can we have so many decorations that something’s x
Elly Fong-Jones
2017/04/26 16:50:01
Added a DCHECK.
|
| + |
| + decoration->UpdateAccessibilityView(apparent_frame); |
| + [decoration->GetAccessibilityView() setFrame:real_frame]; |
| + [decoration->GetAccessibilityView() setNeedsDisplayInRect:apparent_frame]; |
| } |
| std::vector<LocationBarDecoration*> LocationBarViewMac::GetDecorations() { |