OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/autocomplete_text_field_cell.h" | 5 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
11 #include "base/mac/mac_logging.h" | 11 #include "base/mac/mac_logging.h" |
| 12 #include "base/stl_util.h" |
12 #include "chrome/browser/search/search.h" | 13 #include "chrome/browser/search/search.h" |
13 #include "chrome/browser/themes/theme_service.h" | 14 #include "chrome/browser/themes/theme_service.h" |
14 #include "chrome/browser/ui/cocoa/l10n_util.h" | 15 #include "chrome/browser/ui/cocoa/l10n_util.h" |
15 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" | 16 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" |
16 #import "chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h" | 17 #import "chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h" |
17 #import "chrome/browser/ui/cocoa/themed_window.h" | 18 #import "chrome/browser/ui/cocoa/themed_window.h" |
18 #import "extensions/common/feature_switch.h" | 19 #import "extensions/common/feature_switch.h" |
19 #import "third_party/mozilla/NSPasteboard+Utils.h" | 20 #import "third_party/mozilla/NSPasteboard+Utils.h" |
20 #import "ui/base/cocoa/appkit_utils.h" | 21 #import "ui/base/cocoa/appkit_utils.h" |
21 #import "ui/base/cocoa/tracking_area.h" | |
22 #import "ui/base/cocoa/nsview_additions.h" | 22 #import "ui/base/cocoa/nsview_additions.h" |
23 #include "ui/base/cocoa/scoped_cg_context_smooth_fonts.h" | 23 #include "ui/base/cocoa/scoped_cg_context_smooth_fonts.h" |
| 24 #import "ui/base/cocoa/tracking_area.h" |
24 #include "ui/base/material_design/material_design_controller.h" | 25 #include "ui/base/material_design/material_design_controller.h" |
25 | 26 |
26 using extensions::FeatureSwitch; | 27 using extensions::FeatureSwitch; |
27 | 28 |
28 namespace { | 29 namespace { |
29 | 30 |
30 // Matches the clipping radius of |GradientButtonCell|. | 31 // Matches the clipping radius of |GradientButtonCell|. |
31 const CGFloat kCornerRadius = 3.0; | 32 const CGFloat kCornerRadius = 3.0; |
32 | 33 |
33 // How far to inset the left- and right-hand decorations from the field's | 34 // How far to inset the left- and right-hand decorations from the field's |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 } | 265 } |
265 | 266 |
266 - (NSRect)backgroundFrameForDecoration:(LocationBarDecoration*)decoration | 267 - (NSRect)backgroundFrameForDecoration:(LocationBarDecoration*)decoration |
267 inFrame:(NSRect)cellFrame | 268 inFrame:(NSRect)cellFrame |
268 isLeftDecoration:(BOOL*)isLeftDecoration { | 269 isLeftDecoration:(BOOL*)isLeftDecoration { |
269 NSRect decorationFrame = | 270 NSRect decorationFrame = |
270 [self frameForDecoration:decoration inFrame:cellFrame]; | 271 [self frameForDecoration:decoration inFrame:cellFrame]; |
271 std::vector<LocationBarDecoration*>& left_decorations = | 272 std::vector<LocationBarDecoration*>& left_decorations = |
272 cocoa_l10n_util::ShouldDoExperimentalRTLLayout() ? trailingDecorations_ | 273 cocoa_l10n_util::ShouldDoExperimentalRTLLayout() ? trailingDecorations_ |
273 : leadingDecorations_; | 274 : leadingDecorations_; |
274 *isLeftDecoration = | 275 *isLeftDecoration = base::ContainsValue(left_decorations, decoration); |
275 std::find(left_decorations.begin(), left_decorations.end(), decoration) != | |
276 left_decorations.end(); | |
277 return decoration->GetBackgroundFrame(decorationFrame); | 276 return decoration->GetBackgroundFrame(decorationFrame); |
278 } | 277 } |
279 | 278 |
280 // Overriden to account for the decorations. | 279 // Overriden to account for the decorations. |
281 - (NSRect)textFrameForFrame:(NSRect)cellFrame { | 280 - (NSRect)textFrameForFrame:(NSRect)cellFrame { |
282 // Get the frame adjusted for decorations. | 281 // Get the frame adjusted for decorations. |
283 std::vector<LocationBarDecoration*> decorations; | 282 std::vector<LocationBarDecoration*> decorations; |
284 std::vector<NSRect> decorationFrames; | 283 std::vector<NSRect> decorationFrames; |
285 NSRect textFrame = [super textFrameForFrame:cellFrame]; | 284 NSRect textFrame = [super textFrameForFrame:cellFrame]; |
286 CalculatePositionsInFrame(textFrame, leadingDecorations_, | 285 CalculatePositionsInFrame(textFrame, leadingDecorations_, |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 | 752 |
754 @end | 753 @end |
755 | 754 |
756 @implementation AutocompleteTextFieldCell (TestingAPI) | 755 @implementation AutocompleteTextFieldCell (TestingAPI) |
757 | 756 |
758 - (const std::vector<LocationBarDecoration*>&)mouseTrackingDecorations { | 757 - (const std::vector<LocationBarDecoration*>&)mouseTrackingDecorations { |
759 return mouseTrackingDecorations_; | 758 return mouseTrackingDecorations_; |
760 } | 759 } |
761 | 760 |
762 @end | 761 @end |
OLD | NEW |