Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm

Issue 2091063002: Location bar: make decorations accessible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/location_bar/location_bar_view_mac.h" 5 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #import "base/mac/mac_util.h" 9 #import "base/mac/mac_util.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 if (ev_bubble_decoration_->IsVisible()) { 547 if (ev_bubble_decoration_->IsVisible()) {
548 return [field_ bubblePointForDecoration:ev_bubble_decoration_.get()]; 548 return [field_ bubblePointForDecoration:ev_bubble_decoration_.get()];
549 } else { 549 } else {
550 return [field_ bubblePointForDecoration:location_icon_decoration_.get()]; 550 return [field_ bubblePointForDecoration:location_icon_decoration_.get()];
551 } 551 }
552 } 552 }
553 553
554 void LocationBarViewMac::OnDecorationsChanged() { 554 void LocationBarViewMac::OnDecorationsChanged() {
555 // TODO(shess): The field-editor frame and cursor rects should not 555 // TODO(shess): The field-editor frame and cursor rects should not
556 // change, here. 556 // change, here.
557 std::vector<LocationBarDecoration*> decorations;
558 GetDecorations(&decorations);
559 for (const auto& decoration : decorations)
560 UpdateAccessibilityViewPosition(decoration);
557 [field_ updateMouseTracking]; 561 [field_ updateMouseTracking];
558 [field_ resetFieldEditorFrameIfNeeded]; 562 [field_ resetFieldEditorFrameIfNeeded];
559 [field_ setNeedsDisplay:YES]; 563 [field_ setNeedsDisplay:YES];
560 } 564 }
561 565
562 // TODO(shess): This function should over time grow to closely match 566 // TODO(shess): This function should over time grow to closely match
563 // the views Layout() function. 567 // the views Layout() function.
564 void LocationBarViewMac::Layout() { 568 void LocationBarViewMac::Layout() {
565 AutocompleteTextFieldCell* cell = [field_ cell]; 569 AutocompleteTextFieldCell* cell = [field_ cell];
566 570
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 bool LocationBarViewMac::UpdateZoomDecoration(bool default_zoom_changed) { 969 bool LocationBarViewMac::UpdateZoomDecoration(bool default_zoom_changed) {
966 WebContents* web_contents = GetWebContents(); 970 WebContents* web_contents = GetWebContents();
967 if (!web_contents) 971 if (!web_contents)
968 return false; 972 return false;
969 973
970 return zoom_decoration_->UpdateIfNecessary( 974 return zoom_decoration_->UpdateIfNecessary(
971 zoom::ZoomController::FromWebContents(web_contents), default_zoom_changed, 975 zoom::ZoomController::FromWebContents(web_contents), default_zoom_changed,
972 IsLocationBarDark()); 976 IsLocationBarDark());
973 } 977 }
974 978
979 void LocationBarViewMac::UpdateAccessibilityViewPosition(
980 LocationBarDecoration* decoration) {
981 if (!decoration->IsVisible())
982 return;
983 NSRect r =
984 [[field_ cell] frameForDecoration:decoration inFrame:[field_ frame]];
985 [decoration->GetAccessibilityView() setFrame:r];
986 [decoration->GetAccessibilityView() setNeedsDisplayInRect:r];
987 }
988
989 void LocationBarViewMac::GetDecorations(
990 std::vector<LocationBarDecoration*>* decorations) {
Mark Mentovai 2016/06/23 19:30:55 Clear the vector on entry to this function and the
Elly Fong-Jones 2016/06/23 20:25:58 Done.
991 // TODO(ellyjones): content setting decorations aren't included right now, nor
992 // are page actions and the keyword hint.
Mark Mentovai 2016/06/23 19:30:55 This seems like a lot to keep in sync with (someth
Elly Fong-Jones 2016/06/23 20:25:58 It doesn't seem so. Most places only need one of t
993 decorations->push_back(location_icon_decoration_.get());
994 decorations->push_back(selected_keyword_decoration_.get());
995 decorations->push_back(ev_bubble_decoration_.get());
996 decorations->push_back(save_credit_card_decoration_.get());
997 decorations->push_back(star_decoration_.get());
998 decorations->push_back(translate_decoration_.get());
999 decorations->push_back(zoom_decoration_.get());
1000 decorations->push_back(manage_passwords_decoration_.get());
1001 }
1002
975 void LocationBarViewMac::OnDefaultZoomLevelChanged() { 1003 void LocationBarViewMac::OnDefaultZoomLevelChanged() {
976 if (UpdateZoomDecoration(/*default_zoom_changed=*/true)) 1004 if (UpdateZoomDecoration(/*default_zoom_changed=*/true))
977 OnDecorationsChanged(); 1005 OnDecorationsChanged();
978 } 1006 }
1007
1008 void LocationBarViewMac::GetDecorationAccessibilityViews(
1009 std::vector<NSView*>* views) {
1010 std::vector<LocationBarDecoration*> decorations;
1011 GetDecorations(&decorations);
1012 for (const auto& decoration : decorations)
1013 views->push_back(decoration->GetAccessibilityView());
1014 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698