| OLD | NEW |
| 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 Loading... |
| 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 } | |
| 321 NSBezierPath* path = | 317 NSBezierPath* path = |
| 322 [NSBezierPath bezierPathWithRoundedRect:pathRect | 318 [NSBezierPath bezierPathWithRoundedRect:pathRect |
| 323 xRadius:kCornerRadius | 319 xRadius:kCornerRadius |
| 324 yRadius:kCornerRadius]; | 320 yRadius:kCornerRadius]; |
| 325 if (isModeMaterial) { | 321 if (isModeMaterial) { |
| 326 [path setLineWidth:showingFirstResponder ? singlePixelLineWidth_ * 2 | 322 [path setLineWidth:showingFirstResponder ? singlePixelLineWidth_ * 2 |
| 327 : singlePixelLineWidth_]; | 323 : singlePixelLineWidth_]; |
| 328 } | 324 } |
| 329 | 325 |
| 330 // Fill the background. | 326 // Fill the background. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 359 } | 355 } |
| 360 { | 356 { |
| 361 gfx::ScopedNSGraphicsContextSaveGState saveState; | 357 gfx::ScopedNSGraphicsContextSaveGState saveState; |
| 362 [[NSColor colorWithCalibratedWhite:71 / 255. alpha:1] set]; | 358 [[NSColor colorWithCalibratedWhite:71 / 255. alpha:1] set]; |
| 363 [NSBezierPath clipRect:NSMakeRect(NSMinX(frame), NSMinY(frame), | 359 [NSBezierPath clipRect:NSMakeRect(NSMinX(frame), NSMinY(frame), |
| 364 NSWidth(frame), 3)]; | 360 NSWidth(frame), 3)]; |
| 365 [path stroke]; | 361 [path stroke]; |
| 366 } | 362 } |
| 367 | 363 |
| 368 // Draw a highlight beneath the top edge, and a shadow beneath the bottom | 364 // Draw a highlight beneath the top edge, and a shadow beneath the bottom |
| 369 // edge. | 365 // edge when on a Retina screen. |
| 370 { | 366 { |
| 371 gfx::ScopedNSGraphicsContextSaveGState saveState; | 367 gfx::ScopedNSGraphicsContextSaveGState saveState; |
| 372 [NSBezierPath setDefaultLineWidth:singlePixelLineWidth_]; | 368 [NSBezierPath setDefaultLineWidth:singlePixelLineWidth_]; |
| 373 | 369 |
| 374 [[NSColor colorWithCalibratedWhite:120 / 255. alpha:1] set]; | 370 [[NSColor colorWithCalibratedWhite:120 / 255. alpha:1] set]; |
| 375 NSPoint origin = NSMakePoint(NSMinX(pathRect) + 3, | 371 NSPoint origin = NSMakePoint(NSMinX(pathRect) + 3, |
| 376 NSMinY(pathRect) + singlePixelLineWidth_); | 372 NSMinY(pathRect) + singlePixelLineWidth_); |
| 377 NSPoint destination = | 373 NSPoint destination = |
| 378 NSMakePoint(NSMaxX(pathRect) - 3, | 374 NSMakePoint(NSMaxX(pathRect) - 3, |
| 379 NSMinY(pathRect) + singlePixelLineWidth_); | 375 NSMinY(pathRect) + singlePixelLineWidth_); |
| 380 [NSBezierPath strokeLineFromPoint:origin | 376 [NSBezierPath strokeLineFromPoint:origin |
| 381 toPoint:destination]; | 377 toPoint:destination]; |
| 382 | 378 |
| 383 origin.y = destination.y = NSMaxY(pathRect) + singlePixelLineWidth_; | 379 if (singlePixelLineWidth_ < 1) { |
| 384 [[NSColor colorWithCalibratedWhite:69 / 255. alpha:1] set]; | 380 origin.y = destination.y = NSMaxY(pathRect) + singlePixelLineWidth_; |
| 385 [NSBezierPath strokeLineFromPoint:origin | 381 [[AutocompleteTextField shadowColor] set]; |
| 386 toPoint:destination]; | 382 [NSBezierPath strokeLineFromPoint:origin |
| 383 toPoint:destination]; |
| 384 } |
| 387 } | 385 } |
| 388 } | 386 } |
| 389 } else { | 387 } else { |
| 390 ui::DrawNinePartImage(frame, | 388 ui::DrawNinePartImage(frame, |
| 391 isPopupMode_ ? kPopupBorderImageIds | 389 isPopupMode_ ? kPopupBorderImageIds |
| 392 : kNormalBorderImageIds, | 390 : kNormalBorderImageIds, |
| 393 NSCompositeSourceOver, | 391 NSCompositeSourceOver, |
| 394 1.0, | 392 1.0, |
| 395 true); | 393 true); |
| 396 } | 394 } |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 | 762 |
| 765 - (void)handleFocusEvent:(NSEvent*)event | 763 - (void)handleFocusEvent:(NSEvent*)event |
| 766 ofView:(AutocompleteTextField*)controlView { | 764 ofView:(AutocompleteTextField*)controlView { |
| 767 if ([controlView observer]) { | 765 if ([controlView observer]) { |
| 768 const bool controlDown = ([event modifierFlags] & NSControlKeyMask) != 0; | 766 const bool controlDown = ([event modifierFlags] & NSControlKeyMask) != 0; |
| 769 [controlView observer]->OnSetFocus(controlDown); | 767 [controlView observer]->OnSetFocus(controlDown); |
| 770 } | 768 } |
| 771 } | 769 } |
| 772 | 770 |
| 773 @end | 771 @end |
| OLD | NEW |