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

Side by Side Diff: chrome/browser/ui/cocoa/styled_text_field_cell.mm

Issue 15553008: Instant Extended: Reduce clipping in omnibox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/styled_text_field_cell.h" 5 #import "chrome/browser/ui/cocoa/styled_text_field_cell.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/themes/theme_properties.h" 8 #include "chrome/browser/themes/theme_properties.h"
9 #include "chrome/browser/themes/theme_service.h" 9 #include "chrome/browser/themes/theme_service.h"
10 #import "chrome/browser/ui/cocoa/nsview_additions.h" 10 #import "chrome/browser/ui/cocoa/nsview_additions.h"
11 #import "chrome/browser/ui/cocoa/themed_window.h" 11 #import "chrome/browser/ui/cocoa/themed_window.h"
12 #include "grit/theme_resources.h" 12 #include "grit/theme_resources.h"
13 #include "ui/base/resource/resource_bundle.h" 13 #include "ui/base/resource/resource_bundle.h"
14 #include "ui/gfx/font.h" 14 #include "ui/gfx/font.h"
15 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 15 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
16 16
17 @interface StyledTextFieldCell ()
18 - (NSRect)textFrameForFrameInternal:(NSRect)cellFrame;
19 @end
20
17 @implementation StyledTextFieldCell 21 @implementation StyledTextFieldCell
18 22
19 - (CGFloat)baselineAdjust { 23 - (CGFloat)topTextFrameOffset {
20 return 0.0; 24 return 0.0;
21 } 25 }
22 26
27 - (CGFloat)bottomTextFrameOffset {
28 return 0.0;
29 }
30
23 - (CGFloat)cornerRadius { 31 - (CGFloat)cornerRadius {
24 return 0.0; 32 return 0.0;
25 } 33 }
26 34
27 - (rect_path_utils::RoundedCornerFlags)roundedCornerFlags { 35 - (rect_path_utils::RoundedCornerFlags)roundedCornerFlags {
28 return rect_path_utils::RoundedCornerAll; 36 return rect_path_utils::RoundedCornerAll;
29 } 37 }
30 38
31 - (BOOL)shouldDrawBezel { 39 - (BOOL)shouldDrawBezel {
32 return NO; 40 return NO;
33 } 41 }
34 42
35 // Returns the same value as textCursorFrameForFrame, but does not call it 43 // Returns the same value as textCursorFrameForFrame, but does not call it
36 // directly to avoid potential infinite loops. 44 // directly to avoid potential infinite loops.
37 - (NSRect)textFrameForFrame:(NSRect)cellFrame { 45 - (NSRect)textFrameForFrame:(NSRect)cellFrame {
38 return NSInsetRect(cellFrame, 0, [self baselineAdjust]); 46 return [self textFrameForFrameInternal:cellFrame];
39 } 47 }
40 48
41 // Returns the same value as textFrameForFrame, but does not call it directly to 49 // Returns the same value as textFrameForFrame, but does not call it directly to
42 // avoid potential infinite loops. 50 // avoid potential infinite loops.
43 - (NSRect)textCursorFrameForFrame:(NSRect)cellFrame { 51 - (NSRect)textCursorFrameForFrame:(NSRect)cellFrame {
44 return NSInsetRect(cellFrame, 0, [self baselineAdjust]); 52 return [self textFrameForFrameInternal:cellFrame];
45 } 53 }
46 54
47 // Override to show the I-beam cursor only in the area given by 55 // Override to show the I-beam cursor only in the area given by
48 // |textCursorFrameForFrame:|. 56 // |textCursorFrameForFrame:|.
49 - (void)resetCursorRect:(NSRect)cellFrame inView:(NSView *)controlView { 57 - (void)resetCursorRect:(NSRect)cellFrame inView:(NSView *)controlView {
50 [super resetCursorRect:[self textCursorFrameForFrame:cellFrame] 58 [super resetCursorRect:[self textCursorFrameForFrame:cellFrame]
51 inView:controlView]; 59 inView:controlView];
52 } 60 }
53 61
54 // For NSTextFieldCell this is the area within the borders. For our 62 // For NSTextFieldCell this is the area within the borders. For our
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 158
151 // Draw the focus ring if needed. 159 // Draw the focus ring if needed.
152 if ([self showsFirstResponder]) { 160 if ([self showsFirstResponder]) {
153 NSColor* color = [[NSColor keyboardFocusIndicatorColor] 161 NSColor* color = [[NSColor keyboardFocusIndicatorColor]
154 colorWithAlphaComponent:0.5 / lineWidth]; 162 colorWithAlphaComponent:0.5 / lineWidth];
155 rect_path_utils::FrameRectWithInset(roundedCornerFlags, frame, 0.0, 0.0, 163 rect_path_utils::FrameRectWithInset(roundedCornerFlags, frame, 0.0, 0.0,
156 radius, lineWidth * 2, color); 164 radius, lineWidth * 2, color);
157 } 165 }
158 } 166 }
159 167
168 - (NSRect)textFrameForFrameInternal:(NSRect)cellFrame {
169 CGFloat topOffset = [self topTextFrameOffset];
170 NSRect textFrame = cellFrame;
171 textFrame.origin.y += topOffset;
172 textFrame.size.height -= topOffset + [self bottomTextFrameOffset];
173 return return textFrame;
Scott Hess - ex-Googler 2013/05/22 23:39:39 typo typo
sail 2013/05/23 19:46:32 Done.
174 }
175
160 @end 176 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698