| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 return decorationFrames[index]; | 235 return decorationFrames[index]; |
| 236 } | 236 } |
| 237 | 237 |
| 238 // Decorations which are not visible should have been filtered out | 238 // Decorations which are not visible should have been filtered out |
| 239 // at the top, but return |NSZeroRect| rather than a 0-width rect | 239 // at the top, but return |NSZeroRect| rather than a 0-width rect |
| 240 // for consistency. | 240 // for consistency. |
| 241 NOTREACHED(); | 241 NOTREACHED(); |
| 242 return NSZeroRect; | 242 return NSZeroRect; |
| 243 } | 243 } |
| 244 | 244 |
| 245 - (NSRect)backgroundFrameForDecoration:(LocationBarDecoration*)decoration |
| 246 inFrame:(NSRect)cellFrame |
| 247 isLeftDecoration:(BOOL*)isLeftDecoration { |
| 248 NSRect decorationFrame = |
| 249 [self frameForDecoration:decoration inFrame:cellFrame]; |
| 250 *isLeftDecoration = |
| 251 std::find(leftDecorations_.begin(), leftDecorations_.end(), decoration) != |
| 252 leftDecorations_.end(); |
| 253 return decoration->GetBackgroundFrame(decorationFrame); |
| 254 } |
| 255 |
| 245 // Overriden to account for the decorations. | 256 // Overriden to account for the decorations. |
| 246 - (NSRect)textFrameForFrame:(NSRect)cellFrame { | 257 - (NSRect)textFrameForFrame:(NSRect)cellFrame { |
| 247 // Get the frame adjusted for decorations. | 258 // Get the frame adjusted for decorations. |
| 248 std::vector<LocationBarDecoration*> decorations; | 259 std::vector<LocationBarDecoration*> decorations; |
| 249 std::vector<NSRect> decorationFrames; | 260 std::vector<NSRect> decorationFrames; |
| 250 NSRect textFrame = [super textFrameForFrame:cellFrame]; | 261 NSRect textFrame = [super textFrameForFrame:cellFrame]; |
| 251 CalculatePositionsInFrame(textFrame, leftDecorations_, rightDecorations_, | 262 CalculatePositionsInFrame(textFrame, leftDecorations_, rightDecorations_, |
| 252 &decorations, &decorationFrames, &textFrame); | 263 &decorations, &decorationFrames, &textFrame); |
| 253 | 264 |
| 254 // The text needs to be slightly higher than its default position to match the | 265 // The text needs to be slightly higher than its default position to match the |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 | 705 |
| 695 @end | 706 @end |
| 696 | 707 |
| 697 @implementation AutocompleteTextFieldCell (TestingAPI) | 708 @implementation AutocompleteTextFieldCell (TestingAPI) |
| 698 | 709 |
| 699 - (const std::vector<LocationBarDecoration*>&)mouseTrackingDecorations { | 710 - (const std::vector<LocationBarDecoration*>&)mouseTrackingDecorations { |
| 700 return mouseTrackingDecorations_; | 711 return mouseTrackingDecorations_; |
| 701 } | 712 } |
| 702 | 713 |
| 703 @end | 714 @end |
| OLD | NEW |