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

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm

Issue 1802643002: Adjust locationbar text vertical position under Material Design. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code cleanup. Created 4 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/location_bar/autocomplete_text_field.h" 5 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "base/mac/mac_util.h" 8 #import "base/mac/mac_util.h"
9 #import "base/mac/sdk_forward_declarations.h" 9 #import "base/mac/sdk_forward_declarations.h"
10 #include "chrome/browser/themes/theme_service.h" 10 #include "chrome/browser/themes/theme_service.h"
11 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 11 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
12 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" 12 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h"
13 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" 13 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h"
14 #import "chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h" 14 #import "chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h"
15 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 15 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
16 #import "chrome/browser/ui/cocoa/url_drop_target.h" 16 #import "chrome/browser/ui/cocoa/url_drop_target.h"
17 #import "chrome/browser/ui/cocoa/view_id_util.h" 17 #import "chrome/browser/ui/cocoa/view_id_util.h"
18 #import "ui/base/cocoa/nsview_additions.h"
18 #include "ui/base/material_design/material_design_controller.h" 19 #include "ui/base/material_design/material_design_controller.h"
19 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 20 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
20 21
21 namespace { 22 namespace {
22 const CGFloat kAnimationDuration = 0.2; 23 const CGFloat kAnimationDuration = 0.2;
23 } 24 }
24 25
25 @implementation AutocompleteTextField 26 @implementation AutocompleteTextField
26 27
27 @synthesize observer = observer_; 28 @synthesize observer = observer_;
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 355
355 - (void)viewWillMoveToWindow:(NSWindow*)newWindow { 356 - (void)viewWillMoveToWindow:(NSWindow*)newWindow {
356 if ([self window]) { 357 if ([self window]) {
357 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; 358 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
358 [nc removeObserver:self 359 [nc removeObserver:self
359 name:NSWindowDidResignKeyNotification 360 name:NSWindowDidResignKeyNotification
360 object:[self window]]; 361 object:[self window]];
361 [nc removeObserver:self 362 [nc removeObserver:self
362 name:NSWindowDidResizeNotification 363 name:NSWindowDidResizeNotification
363 object:[self window]]; 364 object:[self window]];
365 [nc removeObserver:self
366 name:NSWindowDidChangeScreenNotification
367 object:[self window]];
364 } 368 }
365 } 369 }
366 370
371 - (void)windowDidChangeScreen {
372 // Inform the AutocompleteTextFieldCell's of the coordinate system line
373 // width needed to draw a single-pixel line. This value changes as we move
374 // between Retina and non-Retina displays.
375 [[self cell] setSinglePixelLineWidth:[self cr_lineWidth]];
376 [self setNeedsDisplay];
377 }
378
367 - (void)viewDidMoveToWindow { 379 - (void)viewDidMoveToWindow {
368 if (![self window]) { 380 if (![self window]) {
369 return; 381 return;
370 } 382 }
371 383
372 // Invert the textfield's colors when Material Design and Incognito and not 384 // Invert the textfield's colors when Material Design and Incognito and not
373 // a custom theme. 385 // a custom theme.
374 if (ui::MaterialDesignController::IsModeMaterial() && 386 if (ui::MaterialDesignController::IsModeMaterial() &&
375 [[self window] inIncognitoModeWithSystemTheme]) { 387 [[self window] inIncognitoModeWithSystemTheme]) {
376 [self setTextColor:[NSColor whiteColor]]; 388 [self setTextColor:[NSColor whiteColor]];
377 [self setBackgroundColor: 389 [self setBackgroundColor:
378 [NSColor colorWithCalibratedWhite:115 / 255. alpha:1]]; 390 [NSColor colorWithCalibratedWhite:115 / 255. alpha:1]];
379 } 391 }
380 392
381 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; 393 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
382 [nc addObserver:self 394 [nc addObserver:self
383 selector:@selector(windowDidResignKey:) 395 selector:@selector(windowDidResignKey:)
384 name:NSWindowDidResignKeyNotification 396 name:NSWindowDidResignKeyNotification
385 object:[self window]]; 397 object:[self window]];
386 [nc addObserver:self 398 [nc addObserver:self
387 selector:@selector(windowDidResize:) 399 selector:@selector(windowDidResize:)
388 name:NSWindowDidResizeNotification 400 name:NSWindowDidResizeNotification
389 object:[self window]]; 401 object:[self window]];
402 [nc addObserver:self
403 selector:@selector(windowDidChangeScreen)
404 name:NSWindowDidChangeScreenNotification
405 object:[self window]];
406
407 // Make sure the cell has the current line width.
408 [[self cell] setSinglePixelLineWidth:[self cr_lineWidth]];
409
390 // Only register for drops if not in a popup window. Lazily create the 410 // Only register for drops if not in a popup window. Lazily create the
391 // drop handler when the type of window is known. 411 // drop handler when the type of window is known.
392 BrowserWindowController* windowController = 412 BrowserWindowController* windowController =
393 [BrowserWindowController browserWindowControllerForView:self]; 413 [BrowserWindowController browserWindowControllerForView:self];
394 if ([windowController isTabbedWindow]) 414 if ([windowController isTabbedWindow])
395 dropHandler_.reset([[URLDropTargetHandler alloc] initWithView:self]); 415 dropHandler_.reset([[URLDropTargetHandler alloc] initWithView:self]);
396 } 416 }
397 417
398 // NSTextField becomes first responder by installing a "field editor" 418 // NSTextField becomes first responder by installing a "field editor"
399 // subview. Clicks outside the field editor (such as a decoration) 419 // subview. Clicks outside the field editor (such as a decoration)
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 NSMinY(frame), 553 NSMinY(frame),
534 suggestWidth, 554 suggestWidth,
535 NSHeight(frame)); 555 NSHeight(frame));
536 556
537 gfx::ScopedNSGraphicsContextSaveGState saveGState; 557 gfx::ScopedNSGraphicsContextSaveGState saveGState;
538 NSRectClip(suggestRect); 558 NSRectClip(suggestRect);
539 [cell drawInteriorWithFrame:frame inView:controlView]; 559 [cell drawInteriorWithFrame:frame inView:controlView];
540 } 560 }
541 561
542 } // namespace autocomplete_text_field 562 } // namespace autocomplete_text_field
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698