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

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

Issue 2610033003: [Mac] Prevent omnibox text bg from drawing over decoration, focus ring.
Patch Set: Created 3 years, 11 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
« 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 alpha:1] set]; 357 alpha:1] set];
358 } else { 358 } else {
359 [[[NSColor keyboardFocusIndicatorColor] 359 [[[NSColor keyboardFocusIndicatorColor]
360 colorWithAlphaComponent:alphaComponent] set]; 360 colorWithAlphaComponent:alphaComponent] set];
361 } 361 }
362 [path stroke]; 362 [path stroke];
363 } 363 }
364 } 364 }
365 365
366 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { 366 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
367 ui::ScopedCGContextSmoothFonts fontSmoothing;
368 [super drawInteriorWithFrame:cellFrame inView:controlView];
369
370 // NOTE: This method must closely match the logic in |-textFrameForFrame:|.
367 std::vector<LocationBarDecoration*> decorations; 371 std::vector<LocationBarDecoration*> decorations;
368 std::vector<NSRect> decorationFrames; 372 std::vector<NSRect> decorationFrames;
369 NSRect workingFrame; 373 NSRect workingFrame;
370 374
371 CalculatePositionsInFrame(cellFrame, leftDecorations_, rightDecorations_, 375 CalculatePositionsInFrame(cellFrame, leftDecorations_, rightDecorations_,
372 &decorations, &decorationFrames, &workingFrame); 376 &decorations, &decorationFrames, &workingFrame);
373 377
374 // Draw the decorations. 378 // Draw the decorations. Do this after drawing the interior because the
379 // field editor's background rect overlaps the right edge of the security
380 // decoration's hover rounded rect.
375 for (size_t i = 0; i < decorations.size(); ++i) { 381 for (size_t i = 0; i < decorations.size(); ++i) {
376 if (decorations[i]) { 382 if (decorations[i]) {
377 decorations[i]->DrawWithBackgroundInFrame(decorationFrames[i], 383 decorations[i]->DrawWithBackgroundInFrame(decorationFrames[i],
378 controlView); 384 controlView);
379 } 385 }
380 } 386 }
381
382 // NOTE: This function must closely match the logic in
383 // |-textFrameForFrame:|.
384
385 // Superclass draws text portion WRT original |cellFrame|.
386 ui::ScopedCGContextSmoothFonts fontSmoothing;
387 [super drawInteriorWithFrame:cellFrame inView:controlView];
388 } 387 }
389 388
390 - (BOOL)canDropAtLocationInWindow:(NSPoint)location 389 - (BOOL)canDropAtLocationInWindow:(NSPoint)location
391 ofView:(AutocompleteTextField*)controlView { 390 ofView:(AutocompleteTextField*)controlView {
392 NSRect cellFrame = [controlView bounds]; 391 NSRect cellFrame = [controlView bounds];
393 const NSPoint locationInView = 392 const NSPoint locationInView =
394 [controlView convertPoint:location fromView:nil]; 393 [controlView convertPoint:location fromView:nil];
395 394
396 // If we have decorations, the drop can't occur at their horizontal padding. 395 // If we have decorations, the drop can't occur at their horizontal padding.
397 if (!leftDecorations_.empty() && locationInView.x < kLeftDecorationXOffset) 396 if (!leftDecorations_.empty() && locationInView.x < kLeftDecorationXOffset)
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 693
695 @end 694 @end
696 695
697 @implementation AutocompleteTextFieldCell (TestingAPI) 696 @implementation AutocompleteTextFieldCell (TestingAPI)
698 697
699 - (const std::vector<LocationBarDecoration*>&)mouseTrackingDecorations { 698 - (const std::vector<LocationBarDecoration*>&)mouseTrackingDecorations {
700 return mouseTrackingDecorations_; 699 return mouseTrackingDecorations_;
701 } 700 }
702 701
703 @end 702 @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