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

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

Issue 2972593002: Mac: Fix up location bar decoration bubble anchoring. (Closed)
Patch Set: Created 3 years, 5 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 (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"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 return decorationFrames[index]; 267 return decorationFrames[index];
268 } 268 }
269 269
270 // Decorations which are not visible should have been filtered out 270 // Decorations which are not visible should have been filtered out
271 // at the top, but return |NSZeroRect| rather than a 0-width rect 271 // at the top, but return |NSZeroRect| rather than a 0-width rect
272 // for consistency. 272 // for consistency.
273 NOTREACHED(); 273 NOTREACHED();
274 return NSZeroRect; 274 return NSZeroRect;
275 } 275 }
276 276
277 - (NSRect)backgroundFrameForDecoration:(LocationBarDecoration*)decoration 277 - (BOOL)isLeftDecoration:(LocationBarDecoration*)decoration {
278 inFrame:(NSRect)cellFrame
279 isLeftDecoration:(BOOL*)isLeftDecoration {
280 NSRect decorationFrame =
281 [self frameForDecoration:decoration inFrame:cellFrame];
282 std::vector<LocationBarDecoration*>& left_decorations = 278 std::vector<LocationBarDecoration*>& left_decorations =
283 cocoa_l10n_util::ShouldDoExperimentalRTLLayout() ? trailingDecorations_ 279 cocoa_l10n_util::ShouldDoExperimentalRTLLayout() ? trailingDecorations_
284 : leadingDecorations_; 280 : leadingDecorations_;
285 *isLeftDecoration = base::ContainsValue(left_decorations, decoration); 281 return base::ContainsValue(left_decorations, decoration);
286 return decoration->GetBackgroundFrame(decorationFrame);
287 } 282 }
288 283
289 // Overriden to account for the decorations. 284 // Overriden to account for the decorations.
290 - (NSRect)textFrameForFrame:(NSRect)cellFrame { 285 - (NSRect)textFrameForFrame:(NSRect)cellFrame {
291 // Get the frame adjusted for decorations. 286 // Get the frame adjusted for decorations.
292 std::vector<LocationBarDecoration*> decorations; 287 std::vector<LocationBarDecoration*> decorations;
293 std::vector<NSRect> decorationFrames; 288 std::vector<NSRect> decorationFrames;
294 NSRect textFrame = [super textFrameForFrame:cellFrame]; 289 NSRect textFrame = [super textFrameForFrame:cellFrame];
295 CalculatePositionsInFrame(textFrame, leadingDecorations_, 290 CalculatePositionsInFrame(textFrame, leadingDecorations_,
296 trailingDecorations_, &decorations, 291 trailingDecorations_, &decorations,
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 757
763 @end 758 @end
764 759
765 @implementation AutocompleteTextFieldCell (TestingAPI) 760 @implementation AutocompleteTextFieldCell (TestingAPI)
766 761
767 - (const std::vector<LocationBarDecoration*>&)mouseTrackingDecorations { 762 - (const std::vector<LocationBarDecoration*>&)mouseTrackingDecorations {
768 return mouseTrackingDecorations_; 763 return mouseTrackingDecorations_;
769 } 764 }
770 765
771 @end 766 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698