| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 // lay between cooridnate space lines). | 310 // lay between cooridnate space lines). |
| 311 CGFloat insetSize = 1 - singlePixelLineWidth_ / 2.; | 311 CGFloat insetSize = 1 - singlePixelLineWidth_ / 2.; |
| 312 if (isModeMaterial && showingFirstResponder && !inDarkMode) { | 312 if (isModeMaterial && showingFirstResponder && !inDarkMode) { |
| 313 insetSize++; | 313 insetSize++; |
| 314 } else if (!isModeMaterial) { | 314 } else if (!isModeMaterial) { |
| 315 insetSize = singlePixelLineWidth_ == 0.5 ? 1.5 : 2.0; | 315 insetSize = singlePixelLineWidth_ == 0.5 ? 1.5 : 2.0; |
| 316 } | 316 } |
| 317 | 317 |
| 318 // Compute the border's bezier path. | 318 // Compute the border's bezier path. |
| 319 NSRect pathRect = NSInsetRect(frame, insetSize, insetSize); | 319 NSRect pathRect = NSInsetRect(frame, insetSize, insetSize); |
| 320 // In dark mode, make room for a shadow beneath the bottom edge. | |
| 321 if (inDarkMode && isModeMaterial) { | |
| 322 pathRect.size.height -= singlePixelLineWidth_; | |
| 323 } | |
| 324 NSBezierPath* path = | 320 NSBezierPath* path = |
| 325 [NSBezierPath bezierPathWithRoundedRect:pathRect | 321 [NSBezierPath bezierPathWithRoundedRect:pathRect |
| 326 xRadius:kCornerRadius | 322 xRadius:kCornerRadius |
| 327 yRadius:kCornerRadius]; | 323 yRadius:kCornerRadius]; |
| 328 if (isModeMaterial) { | 324 if (isModeMaterial) { |
| 329 [path setLineWidth:showingFirstResponder ? singlePixelLineWidth_ * 2 | 325 [path setLineWidth:showingFirstResponder ? singlePixelLineWidth_ * 2 |
| 330 : singlePixelLineWidth_]; | 326 : singlePixelLineWidth_]; |
| 331 } | 327 } |
| 332 | 328 |
| 333 // Fill the background. | 329 // Fill the background. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 362 } | 358 } |
| 363 { | 359 { |
| 364 gfx::ScopedNSGraphicsContextSaveGState saveState; | 360 gfx::ScopedNSGraphicsContextSaveGState saveState; |
| 365 [[NSColor colorWithCalibratedWhite:71 / 255. alpha:1] set]; | 361 [[NSColor colorWithCalibratedWhite:71 / 255. alpha:1] set]; |
| 366 [NSBezierPath clipRect:NSMakeRect(NSMinX(frame), NSMinY(frame), | 362 [NSBezierPath clipRect:NSMakeRect(NSMinX(frame), NSMinY(frame), |
| 367 NSWidth(frame), 3)]; | 363 NSWidth(frame), 3)]; |
| 368 [path stroke]; | 364 [path stroke]; |
| 369 } | 365 } |
| 370 | 366 |
| 371 // Draw a highlight beneath the top edge, and a shadow beneath the bottom | 367 // Draw a highlight beneath the top edge, and a shadow beneath the bottom |
| 372 // edge. | 368 // edge when on a Retina screen. |
| 373 { | 369 { |
| 374 gfx::ScopedNSGraphicsContextSaveGState saveState; | 370 gfx::ScopedNSGraphicsContextSaveGState saveState; |
| 375 [NSBezierPath setDefaultLineWidth:singlePixelLineWidth_]; | 371 [NSBezierPath setDefaultLineWidth:singlePixelLineWidth_]; |
| 376 | 372 |
| 377 [[NSColor colorWithCalibratedWhite:120 / 255. alpha:1] set]; | 373 [[NSColor colorWithCalibratedWhite:120 / 255. alpha:1] set]; |
| 378 NSPoint origin = NSMakePoint(NSMinX(pathRect) + 3, | 374 NSPoint origin = NSMakePoint(NSMinX(pathRect) + 3, |
| 379 NSMinY(pathRect) + singlePixelLineWidth_); | 375 NSMinY(pathRect) + singlePixelLineWidth_); |
| 380 NSPoint destination = | 376 NSPoint destination = |
| 381 NSMakePoint(NSMaxX(pathRect) - 3, | 377 NSMakePoint(NSMaxX(pathRect) - 3, |
| 382 NSMinY(pathRect) + singlePixelLineWidth_); | 378 NSMinY(pathRect) + singlePixelLineWidth_); |
| 383 [NSBezierPath strokeLineFromPoint:origin | 379 [NSBezierPath strokeLineFromPoint:origin |
| 384 toPoint:destination]; | 380 toPoint:destination]; |
| 385 | 381 |
| 386 origin.y = destination.y = NSMaxY(pathRect) + singlePixelLineWidth_; | 382 if (singlePixelLineWidth_ < 1) { |
| 387 [[NSColor colorWithCalibratedWhite:69 / 255. alpha:1] set]; | 383 origin.y = destination.y = NSMaxY(pathRect) + singlePixelLineWidth_; |
| 388 [NSBezierPath strokeLineFromPoint:origin | 384 [[AutocompleteTextField shadowColor] set]; |
| 389 toPoint:destination]; | 385 [NSBezierPath strokeLineFromPoint:origin |
| 386 toPoint:destination]; |
| 387 } |
| 390 } | 388 } |
| 391 } | 389 } |
| 392 } else { | 390 } else { |
| 393 ui::DrawNinePartImage(frame, | 391 ui::DrawNinePartImage(frame, |
| 394 isPopupMode_ ? kPopupBorderImageIds | 392 isPopupMode_ ? kPopupBorderImageIds |
| 395 : kNormalBorderImageIds, | 393 : kNormalBorderImageIds, |
| 396 NSCompositeSourceOver, | 394 NSCompositeSourceOver, |
| 397 1.0, | 395 1.0, |
| 398 true); | 396 true); |
| 399 } | 397 } |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 | 765 |
| 768 - (void)handleFocusEvent:(NSEvent*)event | 766 - (void)handleFocusEvent:(NSEvent*)event |
| 769 ofView:(AutocompleteTextField*)controlView { | 767 ofView:(AutocompleteTextField*)controlView { |
| 770 if ([controlView observer]) { | 768 if ([controlView observer]) { |
| 771 const bool controlDown = ([event modifierFlags] & NSControlKeyMask) != 0; | 769 const bool controlDown = ([event modifierFlags] & NSControlKeyMask) != 0; |
| 772 [controlView observer]->OnSetFocus(controlDown); | 770 [controlView observer]->OnSetFocus(controlDown); |
| 773 } | 771 } |
| 774 } | 772 } |
| 775 | 773 |
| 776 @end | 774 @end |
| OLD | NEW |