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

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/autocomplete_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) 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 "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #include "base/mac/mac_logging.h" 9 #include "base/mac/mac_logging.h"
10 #include "chrome/browser/search/search.h"
10 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" 11 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h"
11 #import "chrome/browser/ui/cocoa/location_bar/button_decoration.h" 12 #import "chrome/browser/ui/cocoa/location_bar/button_decoration.h"
12 #import "chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h" 13 #import "chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h"
13 #import "chrome/browser/ui/cocoa/nsview_additions.h" 14 #import "chrome/browser/ui/cocoa/nsview_additions.h"
14 #import "chrome/common/extensions/feature_switch.h" 15 #import "chrome/common/extensions/feature_switch.h"
15 #import "third_party/mozilla/NSPasteboard+Utils.h" 16 #import "third_party/mozilla/NSPasteboard+Utils.h"
16 #import "ui/base/cocoa/tracking_area.h" 17 #import "ui/base/cocoa/tracking_area.h"
17 18
18 using extensions::FeatureSwitch; 19 using extensions::FeatureSwitch;
19 20
20 namespace { 21 namespace {
21 22
22 const CGFloat kBaselineAdjust = 3.0;
23
24 // Matches the clipping radius of |GradientButtonCell|. 23 // Matches the clipping radius of |GradientButtonCell|.
25 const CGFloat kCornerRadius = 3.0; 24 const CGFloat kCornerRadius = 3.0;
26 25
27 // How far to inset the left-hand decorations from the field's bounds. 26 // How far to inset the left-hand decorations from the field's bounds.
28 const CGFloat kLeftDecorationXOffset = 5.0; 27 const CGFloat kLeftDecorationXOffset = 5.0;
29 28
30 NSString* const kButtonDecorationKey = @"ButtonDecoration"; 29 NSString* const kButtonDecorationKey = @"ButtonDecoration";
31 30
32 // How far to inset the right-hand decorations from the field's bounds. 31 // How far to inset the right-hand decorations from the field's bounds.
33 // TODO(shess): Why is this different from |kLeftDecorationXOffset|? 32 // TODO(shess): Why is this different from |kLeftDecorationXOffset|?
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 208 }
210 209
211 } // namespace 210 } // namespace
212 211
213 @interface AutocompleteTextFieldCell () 212 @interface AutocompleteTextFieldCell ()
214 - (CGFloat)textWidth; 213 - (CGFloat)textWidth;
215 @end 214 @end
216 215
217 @implementation AutocompleteTextFieldCell 216 @implementation AutocompleteTextFieldCell
218 217
219 - (CGFloat)baselineAdjust { 218 - (CGFloat)topTextFrameOffset {
220 return kBaselineAdjust; 219 if (chrome::IsInstantExtendedAPIEnabled())
220 return 2.0;
221 return 3.0;
222 }
223
224 - (CGFloat)bottomTextFrameOffset {
225 return 3.0;
221 } 226 }
222 227
223 - (CGFloat)cornerRadius { 228 - (CGFloat)cornerRadius {
224 return kCornerRadius; 229 return kCornerRadius;
225 } 230 }
226 231
227 - (CGFloat)edgeWidth { 232 - (CGFloat)edgeWidth {
228 // The omnibox vertical edge width is 1 pixel both in low DPI and high DPI. 233 // The omnibox vertical edge width is 1 pixel both in low DPI and high DPI.
229 return [[self controlView] cr_lineWidth]; 234 return [[self controlView] cr_lineWidth];
230 } 235 }
231 236
232 - (BOOL)shouldDrawBezel { 237 - (BOOL)shouldDrawBezel {
233 return YES; 238 return YES;
234 } 239 }
235 240
241 - (CGFloat)lineHeight {
242 if (chrome::IsInstantExtendedAPIEnabled())
243 return 19;
244 return 16;
Scott Hess - ex-Googler 2013/05/23 20:08:02 Per offline discussion, this is kinda fine, except
sail 2013/05/23 20:45:44 Unfortunately I couldn't find anyway to derive the
245 }
246
236 - (void)clearDecorations { 247 - (void)clearDecorations {
237 leftDecorations_.clear(); 248 leftDecorations_.clear();
238 rightDecorations_.clear(); 249 rightDecorations_.clear();
239 } 250 }
240 251
241 - (void)addLeftDecoration:(LocationBarDecoration*)decoration { 252 - (void)addLeftDecoration:(LocationBarDecoration*)decoration {
242 leftDecorations_.push_back(decoration); 253 leftDecorations_.push_back(decoration);
243 } 254 }
244 255
245 - (void)addRightDecoration:(LocationBarDecoration*)decoration { 256 - (void)addRightDecoration:(LocationBarDecoration*)decoration {
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 791
781 - (BOOL)showsFirstResponder { 792 - (BOOL)showsFirstResponder {
782 return [super showsFirstResponder] && !hideFocusState_; 793 return [super showsFirstResponder] && !hideFocusState_;
783 } 794 }
784 795
785 - (CGFloat)textWidth { 796 - (CGFloat)textWidth {
786 return [[self attributedStringValue] size].width; 797 return [[self attributedStringValue] size].width;
787 } 798 }
788 799
789 @end 800 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698