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

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

Issue 1928783003: Revert of [Mac][Material Design] Rework how location bar shadow is drawn. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm ('k') | no next file » | 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) 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 // lay between cooridnate space lines). 307 // lay between cooridnate space lines).
308 CGFloat insetSize = 1 - singlePixelLineWidth_ / 2.; 308 CGFloat insetSize = 1 - singlePixelLineWidth_ / 2.;
309 if (isModeMaterial && showingFirstResponder && !inDarkMode) { 309 if (isModeMaterial && showingFirstResponder && !inDarkMode) {
310 insetSize++; 310 insetSize++;
311 } else if (!isModeMaterial) { 311 } else if (!isModeMaterial) {
312 insetSize = singlePixelLineWidth_ == 0.5 ? 1.5 : 2.0; 312 insetSize = singlePixelLineWidth_ == 0.5 ? 1.5 : 2.0;
313 } 313 }
314 314
315 // Compute the border's bezier path. 315 // Compute the border's bezier path.
316 NSRect pathRect = NSInsetRect(frame, insetSize, insetSize); 316 NSRect pathRect = NSInsetRect(frame, insetSize, insetSize);
317 // In dark mode, make room for a shadow beneath the bottom edge.
318 if (inDarkMode && isModeMaterial) {
319 pathRect.size.height -= singlePixelLineWidth_;
320 }
317 NSBezierPath* path = 321 NSBezierPath* path =
318 [NSBezierPath bezierPathWithRoundedRect:pathRect 322 [NSBezierPath bezierPathWithRoundedRect:pathRect
319 xRadius:kCornerRadius 323 xRadius:kCornerRadius
320 yRadius:kCornerRadius]; 324 yRadius:kCornerRadius];
321 if (isModeMaterial) { 325 if (isModeMaterial) {
322 [path setLineWidth:showingFirstResponder ? singlePixelLineWidth_ * 2 326 [path setLineWidth:showingFirstResponder ? singlePixelLineWidth_ * 2
323 : singlePixelLineWidth_]; 327 : singlePixelLineWidth_];
324 } 328 }
325 329
326 // Fill the background. 330 // Fill the background.
(...skipping 28 matching lines...) Expand all
355 } 359 }
356 { 360 {
357 gfx::ScopedNSGraphicsContextSaveGState saveState; 361 gfx::ScopedNSGraphicsContextSaveGState saveState;
358 [[NSColor colorWithCalibratedWhite:71 / 255. alpha:1] set]; 362 [[NSColor colorWithCalibratedWhite:71 / 255. alpha:1] set];
359 [NSBezierPath clipRect:NSMakeRect(NSMinX(frame), NSMinY(frame), 363 [NSBezierPath clipRect:NSMakeRect(NSMinX(frame), NSMinY(frame),
360 NSWidth(frame), 3)]; 364 NSWidth(frame), 3)];
361 [path stroke]; 365 [path stroke];
362 } 366 }
363 367
364 // Draw a highlight beneath the top edge, and a shadow beneath the bottom 368 // Draw a highlight beneath the top edge, and a shadow beneath the bottom
365 // edge when on a Retina screen. 369 // edge.
366 { 370 {
367 gfx::ScopedNSGraphicsContextSaveGState saveState; 371 gfx::ScopedNSGraphicsContextSaveGState saveState;
368 [NSBezierPath setDefaultLineWidth:singlePixelLineWidth_]; 372 [NSBezierPath setDefaultLineWidth:singlePixelLineWidth_];
369 373
370 [[NSColor colorWithCalibratedWhite:120 / 255. alpha:1] set]; 374 [[NSColor colorWithCalibratedWhite:120 / 255. alpha:1] set];
371 NSPoint origin = NSMakePoint(NSMinX(pathRect) + 3, 375 NSPoint origin = NSMakePoint(NSMinX(pathRect) + 3,
372 NSMinY(pathRect) + singlePixelLineWidth_); 376 NSMinY(pathRect) + singlePixelLineWidth_);
373 NSPoint destination = 377 NSPoint destination =
374 NSMakePoint(NSMaxX(pathRect) - 3, 378 NSMakePoint(NSMaxX(pathRect) - 3,
375 NSMinY(pathRect) + singlePixelLineWidth_); 379 NSMinY(pathRect) + singlePixelLineWidth_);
376 [NSBezierPath strokeLineFromPoint:origin 380 [NSBezierPath strokeLineFromPoint:origin
377 toPoint:destination]; 381 toPoint:destination];
378 382
379 if (singlePixelLineWidth_ < 1) { 383 origin.y = destination.y = NSMaxY(pathRect) + singlePixelLineWidth_;
380 origin.y = destination.y = NSMaxY(pathRect) + singlePixelLineWidth_; 384 [[NSColor colorWithCalibratedWhite:69 / 255. alpha:1] set];
381 [[AutocompleteTextField shadowColor] set]; 385 [NSBezierPath strokeLineFromPoint:origin
382 [NSBezierPath strokeLineFromPoint:origin 386 toPoint:destination];
383 toPoint:destination];
384 }
385 } 387 }
386 } 388 }
387 } else { 389 } else {
388 ui::DrawNinePartImage(frame, 390 ui::DrawNinePartImage(frame,
389 isPopupMode_ ? kPopupBorderImageIds 391 isPopupMode_ ? kPopupBorderImageIds
390 : kNormalBorderImageIds, 392 : kNormalBorderImageIds,
391 NSCompositeSourceOver, 393 NSCompositeSourceOver,
392 1.0, 394 1.0,
393 true); 395 true);
394 } 396 }
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 764
763 - (void)handleFocusEvent:(NSEvent*)event 765 - (void)handleFocusEvent:(NSEvent*)event
764 ofView:(AutocompleteTextField*)controlView { 766 ofView:(AutocompleteTextField*)controlView {
765 if ([controlView observer]) { 767 if ([controlView observer]) {
766 const bool controlDown = ([event modifierFlags] & NSControlKeyMask) != 0; 768 const bool controlDown = ([event modifierFlags] & NSControlKeyMask) != 0;
767 [controlView observer]->OnSetFocus(controlDown); 769 [controlView observer]->OnSetFocus(controlDown);
768 } 770 }
769 } 771 }
770 772
771 @end 773 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698