| 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" |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |