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

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

Issue 2562863002: [Mac] Prevent omnibox text bg from drawing over decoration, focus ring. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 alpha:1] set]; 368 alpha:1] set];
369 } else { 369 } else {
370 [[[NSColor keyboardFocusIndicatorColor] 370 [[[NSColor keyboardFocusIndicatorColor]
371 colorWithAlphaComponent:alphaComponent] set]; 371 colorWithAlphaComponent:alphaComponent] set];
372 } 372 }
373 [path stroke]; 373 [path stroke];
374 } 374 }
375 } 375 }
376 376
377 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { 377 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
378 ui::ScopedCGContextSmoothFonts fontSmoothing;
379 [super drawInteriorWithFrame:cellFrame inView:controlView];
380
381 // NOTE: This method must closely match the logic in |-textFrameForFrame:|.
378 std::vector<LocationBarDecoration*> decorations; 382 std::vector<LocationBarDecoration*> decorations;
379 std::vector<NSRect> decorationFrames; 383 std::vector<NSRect> decorationFrames;
380 NSRect workingFrame; 384 NSRect workingFrame;
381 385
382 CalculatePositionsInFrame(cellFrame, leftDecorations_, rightDecorations_, 386 CalculatePositionsInFrame(cellFrame, leftDecorations_, rightDecorations_,
383 &decorations, &decorationFrames, &workingFrame); 387 &decorations, &decorationFrames, &workingFrame);
384 388
385 // Draw the decorations. 389 // Draw the decorations. Do this after drawing the interior because the
390 // field editor's background rect overlaps the right edge of the security
391 // decoration's hover rounded rect.
386 for (size_t i = 0; i < decorations.size(); ++i) { 392 for (size_t i = 0; i < decorations.size(); ++i) {
387 if (decorations[i]) { 393 if (decorations[i]) {
388 decorations[i]->DrawWithBackgroundInFrame(decorationFrames[i], 394 decorations[i]->DrawWithBackgroundInFrame(decorationFrames[i],
389 controlView); 395 controlView);
390 } 396 }
391 } 397 }
392
393 // NOTE: This function must closely match the logic in
394 // |-textFrameForFrame:|.
395
396 // Superclass draws text portion WRT original |cellFrame|.
397 ui::ScopedCGContextSmoothFonts fontSmoothing;
398 [super drawInteriorWithFrame:cellFrame inView:controlView];
399 } 398 }
400 399
401 - (BOOL)canDropAtLocationInWindow:(NSPoint)location 400 - (BOOL)canDropAtLocationInWindow:(NSPoint)location
402 ofView:(AutocompleteTextField*)controlView { 401 ofView:(AutocompleteTextField*)controlView {
403 NSRect cellFrame = [controlView bounds]; 402 NSRect cellFrame = [controlView bounds];
404 const NSPoint locationInView = 403 const NSPoint locationInView =
405 [controlView convertPoint:location fromView:nil]; 404 [controlView convertPoint:location fromView:nil];
406 405
407 // If we have decorations, the drop can't occur at their horizontal padding. 406 // If we have decorations, the drop can't occur at their horizontal padding.
408 if (!leftDecorations_.empty() && locationInView.x < kLeftDecorationXOffset) 407 if (!leftDecorations_.empty() && locationInView.x < kLeftDecorationXOffset)
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 704
706 @end 705 @end
707 706
708 @implementation AutocompleteTextFieldCell (TestingAPI) 707 @implementation AutocompleteTextFieldCell (TestingAPI)
709 708
710 - (const std::vector<LocationBarDecoration*>&)mouseTrackingDecorations { 709 - (const std::vector<LocationBarDecoration*>&)mouseTrackingDecorations {
711 return mouseTrackingDecorations_; 710 return mouseTrackingDecorations_;
712 } 711 }
713 712
714 @end 713 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698