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

Side by Side Diff: chrome/browser/ui/cocoa/download/download_item_cell.mm

Issue 7541043: Revert 95611 - Always call the class methods to save/restore contexts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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) 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/download/download_item_cell.h" 5 #import "chrome/browser/ui/cocoa/download/download_item_cell.h"
6 6
7 #include "base/sys_string_conversions.h" 7 #include "base/sys_string_conversions.h"
8 #include "chrome/browser/download/download_item.h" 8 #include "chrome/browser/download/download_item.h"
9 #include "chrome/browser/download/download_item_model.h" 9 #include "chrome/browser/download/download_item_model.h"
10 #include "chrome/browser/download/download_manager.h" 10 #include "chrome/browser/download/download_manager.h"
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 if (![secondaryColor gtm_isDarkColor]) 399 if (![secondaryColor gtm_isDarkColor])
400 secondaryColor = [secondaryColor gtm_colorByAdjustingLuminance:-0.2]; 400 secondaryColor = [secondaryColor gtm_colorByAdjustingLuminance:-0.2];
401 401
402 NSDictionary* secondaryTextAttributes = 402 NSDictionary* secondaryTextAttributes =
403 [NSDictionary dictionaryWithObjectsAndKeys: 403 [NSDictionary dictionaryWithObjectsAndKeys:
404 secondaryColor, NSForegroundColorAttributeName, 404 secondaryColor, NSForegroundColorAttributeName,
405 [self secondaryFont], NSFontAttributeName, 405 [self secondaryFont], NSFontAttributeName,
406 nil]; 406 nil];
407 NSPoint secondaryPos = 407 NSPoint secondaryPos =
408 NSMakePoint(innerFrame.origin.x + kTextPosLeft, kSecondaryTextPosTop); 408 NSMakePoint(innerFrame.origin.x + kTextPosLeft, kSecondaryTextPosTop);
409
410 gfx::ScopedNSGraphicsContextSaveGState contextSave;
411 NSGraphicsContext* nsContext = [NSGraphicsContext currentContext]; 409 NSGraphicsContext* nsContext = [NSGraphicsContext currentContext];
412 CGContextRef cgContext = (CGContextRef)[nsContext graphicsPort]; 410 CGContextRef cgContext = (CGContextRef)[nsContext graphicsPort];
411 [nsContext saveGraphicsState];
413 [nsContext setCompositingOperation:NSCompositeSourceOver]; 412 [nsContext setCompositingOperation:NSCompositeSourceOver];
414 CGContextSetAlpha(cgContext, statusAlpha_); 413 CGContextSetAlpha(cgContext, statusAlpha_);
415 [secondaryText drawAtPoint:secondaryPos 414 [secondaryText drawAtPoint:secondaryPos
416 withAttributes:secondaryTextAttributes]; 415 withAttributes:secondaryTextAttributes];
416 [nsContext restoreGraphicsState];
417 } 417 }
418 418
419 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { 419 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
420 NSRect drawFrame = NSInsetRect(cellFrame, 1.5, 1.5); 420 NSRect drawFrame = NSInsetRect(cellFrame, 1.5, 1.5);
421 NSRect innerFrame = NSInsetRect(cellFrame, 2, 2); 421 NSRect innerFrame = NSInsetRect(cellFrame, 2, 2);
422 422
423 const float radius = 5; 423 const float radius = 5;
424 NSWindow* window = [controlView window]; 424 NSWindow* window = [controlView window];
425 BOOL active = [window isKeyWindow] || [window isMainWindow]; 425 BOOL active = [window isKeyWindow] || [window isMainWindow];
426 426
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 cy - kDropdownArrowHeight/3 + kDropdownAreaY); 572 cy - kDropdownArrowHeight/3 + kDropdownAreaY);
573 NSPoint p2 = NSMakePoint(cx + kDropdownArrowWidth/2, 573 NSPoint p2 = NSMakePoint(cx + kDropdownArrowWidth/2,
574 cy - kDropdownArrowHeight/3 + kDropdownAreaY); 574 cy - kDropdownArrowHeight/3 + kDropdownAreaY);
575 NSPoint p3 = NSMakePoint(cx, cy + kDropdownArrowHeight*2/3 + kDropdownAreaY); 575 NSPoint p3 = NSMakePoint(cx, cy + kDropdownArrowHeight*2/3 + kDropdownAreaY);
576 NSBezierPath *triangle = [NSBezierPath bezierPath]; 576 NSBezierPath *triangle = [NSBezierPath bezierPath];
577 [triangle moveToPoint:p1]; 577 [triangle moveToPoint:p1];
578 [triangle lineToPoint:p2]; 578 [triangle lineToPoint:p2];
579 [triangle lineToPoint:p3]; 579 [triangle lineToPoint:p3];
580 [triangle closePath]; 580 [triangle closePath];
581 581
582 gfx::ScopedNSGraphicsContextSaveGState scopedGState; 582 NSGraphicsContext* context = [NSGraphicsContext currentContext];
583 gfx::ScopedNSGraphicsContextSaveGState scopedGState(context);
583 584
584 scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); 585 scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]);
585 [shadow.get() setShadowColor:[NSColor whiteColor]]; 586 [shadow.get() setShadowColor:[NSColor whiteColor]];
586 [shadow.get() setShadowOffset:NSMakeSize(0, -1)]; 587 [shadow.get() setShadowOffset:NSMakeSize(0, -1)];
587 [shadow setShadowBlurRadius:0.0]; 588 [shadow setShadowBlurRadius:0.0];
588 [shadow set]; 589 [shadow set];
589 590
590 NSColor* fill = [self titleColorForPart:kDownloadItemMouseOverDropdownPart]; 591 NSColor* fill = [self titleColorForPart:kDownloadItemMouseOverDropdownPart];
591 [fill setFill]; 592 [fill setFill];
592 593
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 } 685 }
685 return self; 686 return self;
686 } 687 }
687 688
688 - (void)setCurrentProgress:(NSAnimationProgress)progress { 689 - (void)setCurrentProgress:(NSAnimationProgress)progress {
689 [super setCurrentProgress:progress]; 690 [super setCurrentProgress:progress];
690 [cell_ animation:self progressed:progress]; 691 [cell_ animation:self progressed:progress];
691 } 692 }
692 693
693 @end 694 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.mm ('k') | chrome/browser/ui/cocoa/find_bar/find_bar_view.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698