| OLD | NEW |
| 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 Loading... |
| 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 = GetDecorations(); |
| 558 for (const auto& decoration : decorations) |
| 559 UpdateAccessibilityViewPosition(decoration); |
| 557 [field_ updateMouseTracking]; | 560 [field_ updateMouseTracking]; |
| 558 [field_ resetFieldEditorFrameIfNeeded]; | 561 [field_ resetFieldEditorFrameIfNeeded]; |
| 559 [field_ setNeedsDisplay:YES]; | 562 [field_ setNeedsDisplay:YES]; |
| 560 } | 563 } |
| 561 | 564 |
| 562 // TODO(shess): This function should over time grow to closely match | 565 // TODO(shess): This function should over time grow to closely match |
| 563 // the views Layout() function. | 566 // the views Layout() function. |
| 564 void LocationBarViewMac::Layout() { | 567 void LocationBarViewMac::Layout() { |
| 565 AutocompleteTextFieldCell* cell = [field_ cell]; | 568 AutocompleteTextFieldCell* cell = [field_ cell]; |
| 566 | 569 |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 bool LocationBarViewMac::UpdateZoomDecoration(bool default_zoom_changed) { | 968 bool LocationBarViewMac::UpdateZoomDecoration(bool default_zoom_changed) { |
| 966 WebContents* web_contents = GetWebContents(); | 969 WebContents* web_contents = GetWebContents(); |
| 967 if (!web_contents) | 970 if (!web_contents) |
| 968 return false; | 971 return false; |
| 969 | 972 |
| 970 return zoom_decoration_->UpdateIfNecessary( | 973 return zoom_decoration_->UpdateIfNecessary( |
| 971 zoom::ZoomController::FromWebContents(web_contents), default_zoom_changed, | 974 zoom::ZoomController::FromWebContents(web_contents), default_zoom_changed, |
| 972 IsLocationBarDark()); | 975 IsLocationBarDark()); |
| 973 } | 976 } |
| 974 | 977 |
| 978 void LocationBarViewMac::UpdateAccessibilityViewPosition( |
| 979 LocationBarDecoration* decoration) { |
| 980 if (!decoration->IsVisible()) |
| 981 return; |
| 982 NSRect r = |
| 983 [[field_ cell] frameForDecoration:decoration inFrame:[field_ frame]]; |
| 984 [decoration->GetAccessibilityView() setFrame:r]; |
| 985 [decoration->GetAccessibilityView() setNeedsDisplayInRect:r]; |
| 986 } |
| 987 |
| 988 std::vector<LocationBarDecoration*> LocationBarViewMac::GetDecorations() { |
| 989 std::vector<LocationBarDecoration*> decorations; |
| 990 // TODO(ellyjones): content setting decorations aren't included right now, nor |
| 991 // are page actions and the keyword hint. |
| 992 decorations.push_back(location_icon_decoration_.get()); |
| 993 decorations.push_back(selected_keyword_decoration_.get()); |
| 994 decorations.push_back(ev_bubble_decoration_.get()); |
| 995 decorations.push_back(save_credit_card_decoration_.get()); |
| 996 decorations.push_back(star_decoration_.get()); |
| 997 decorations.push_back(translate_decoration_.get()); |
| 998 decorations.push_back(zoom_decoration_.get()); |
| 999 decorations.push_back(manage_passwords_decoration_.get()); |
| 1000 return decorations; |
| 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 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { |
| 1009 std::vector<LocationBarDecoration*> decorations = GetDecorations(); |
| 1010 std::vector<NSView*> views; |
| 1011 for (const auto& decoration : decorations) |
| 1012 views.push_back(decoration->GetAccessibilityView()); |
| 1013 return views; |
| 1014 } |
| OLD | NEW |