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

Unified Diff: chrome/browser/cocoa/autocomplete_text_field_cell.mm

Issue 222020: [Mac] Show the page info window after clicking the security icon in the URL bar (Closed)
Patch Set: Unit tests Created 11 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/cocoa/autocomplete_text_field_cell.mm
diff --git a/chrome/browser/cocoa/autocomplete_text_field_cell.mm b/chrome/browser/cocoa/autocomplete_text_field_cell.mm
index 585a1dd9d8f361fbbba1580493d6782acb14b6ed..10ae6f4b8cd2b213306f260d711128ae57316f31 100644
--- a/chrome/browser/cocoa/autocomplete_text_field_cell.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field_cell.mm
@@ -254,6 +254,25 @@ const NSInteger kHintIconHorizontalPad = 5;
return [super drawingRectForBounds:[self textFrameForFrame:theRect]];
}
+- (NSRect)hintImageFrameForFrame:(NSRect)cellFrame {
+ // We'll draw the entire image
+ const NSSize imageRect([hintIcon_ size]);
+
+ // Move the rect that we're drawing into to the far right
+ cellFrame.origin.x += cellFrame.size.width - imageRect.width;
+ // Add back the padding
+ cellFrame.origin.x -= kHintIconHorizontalPad;
+
+ // Center the image vertically in the frame
+ cellFrame.origin.y +=
+ floor((cellFrame.size.height - imageRect.height) / 2);
+
+ // Set the drawing size to the image size
+ cellFrame.size = imageRect;
+
+ return cellFrame;
+}
+
- (void)drawHintWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
DCHECK(hintString_);
@@ -296,25 +315,14 @@ const NSInteger kHintIconHorizontalPad = 5;
}
- (void)drawHintIconWithFrame:(NSRect)cellFrame
- inView:(NSView*)controlView {
+ inView:(NSView*)controlView {
// We'll draw the entire image
NSRect imageRect = NSZeroRect;
imageRect.size = [hintIcon_ size];
-
- // Move the rect that we're drawing into to the far right
- cellFrame.origin.x += cellFrame.size.width - imageRect.size.width;
- // Add back the padding
- cellFrame.origin.x -= kHintIconHorizontalPad;
-
- // Center the image vertically in the frame
- cellFrame.origin.y +=
- floor((cellFrame.size.height - imageRect.size.height) / 2);
-
- // Set the drawing size to the image size
- cellFrame.size = imageRect.size;
+ const NSRect hintFrame([self hintImageFrameForFrame:cellFrame]);
[hintIcon_ setFlipped:[controlView isFlipped]];
- [hintIcon_ drawInRect:cellFrame
+ [hintIcon_ drawInRect:hintFrame
fromRect:imageRect
operation:NSCompositeSourceOver
fraction:1.0];

Powered by Google App Engine
This is Rietveld 408576698