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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/download/download_item_cell.mm » ('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/bookmarks/bookmark_bar_toolbar_view.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h"
6 6
7 #include "chrome/browser/ntp_background_util.h" 7 #include "chrome/browser/ntp_background_util.h"
8 #include "chrome/browser/themes/theme_service.h" 8 #include "chrome/browser/themes/theme_service.h"
9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h"
10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // The state of our morph; 1 is total bubble, 0 is the regular bar. We use it 49 // The state of our morph; 1 is total bubble, 0 is the regular bar. We use it
50 // to morph the bubble to a regular bar (shape and colour). 50 // to morph the bubble to a regular bar (shape and colour).
51 CGFloat morph = [controller_ detachedMorphProgress]; 51 CGFloat morph = [controller_ detachedMorphProgress];
52 52
53 NSRect bounds = [self bounds]; 53 NSRect bounds = [self bounds];
54 54
55 ui::ThemeProvider* themeProvider = [controller_ themeProvider]; 55 ui::ThemeProvider* themeProvider = [controller_ themeProvider];
56 if (!themeProvider) 56 if (!themeProvider)
57 return; 57 return;
58 58
59 gfx::ScopedNSGraphicsContextSaveGState scopedGState; 59 NSGraphicsContext* context = [NSGraphicsContext currentContext];
60 gfx::ScopedNSGraphicsContextSaveGState scopedGState(context);
60 61
61 // Draw the background. 62 // Draw the background.
62 { 63 {
63 // CanvasSkiaPaint draws to the NSGraphicsContext during its destructor, so 64 // CanvasSkiaPaint draws to the NSGraphicsContext during its destructor, so
64 // explicitly scope this. 65 // explicitly scope this.
65 // 66 //
66 // Paint the entire bookmark bar, even if the damage rect is much smaller 67 // Paint the entire bookmark bar, even if the damage rect is much smaller
67 // because PaintBackgroundDetachedMode() assumes that area's origin is 68 // because PaintBackgroundDetachedMode() assumes that area's origin is
68 // (0, 0) and that its size is the size of the bookmark bar. 69 // (0, 0) and that its size is the size of the bookmark bar.
69 // 70 //
(...skipping 25 matching lines...) Expand all
95 96
96 // Draw the rounded rectangle. 97 // Draw the rounded rectangle.
97 NSColor* toolbarColor = 98 NSColor* toolbarColor =
98 themeProvider->GetNSColor(ThemeService::COLOR_TOOLBAR, true); 99 themeProvider->GetNSColor(ThemeService::COLOR_TOOLBAR, true);
99 CGFloat alpha = morph * [toolbarColor alphaComponent]; 100 CGFloat alpha = morph * [toolbarColor alphaComponent];
100 [[toolbarColor colorWithAlphaComponent:alpha] set]; // Set with opacity. 101 [[toolbarColor colorWithAlphaComponent:alpha] set]; // Set with opacity.
101 [border fill]; 102 [border fill];
102 103
103 // Fade in/out the background. 104 // Fade in/out the background.
104 { 105 {
105 gfx::ScopedNSGraphicsContextSaveGState bgScopedState; 106 gfx::ScopedNSGraphicsContextSaveGState bgScopedState(context);
106 [border setClip]; 107 [border setClip];
107 NSGraphicsContext* context = [NSGraphicsContext currentContext];
108 CGContextRef cgContext = (CGContextRef)[context graphicsPort]; 108 CGContextRef cgContext = (CGContextRef)[context graphicsPort];
109 CGContextBeginTransparencyLayer(cgContext, NULL); 109 CGContextBeginTransparencyLayer(cgContext, NULL);
110 CGContextSetAlpha(cgContext, 1 - morph); 110 CGContextSetAlpha(cgContext, 1 - morph);
111 [context setPatternPhase:[[self window] themePatternPhase]]; 111 [context setPatternPhase:[[self window] themePatternPhase]];
112 [self drawBackgroundWithOpaque:YES]; 112 [self drawBackgroundWithOpaque:YES];
113 CGContextEndTransparencyLayer(cgContext); 113 CGContextEndTransparencyLayer(cgContext);
114 } 114 }
115 115
116 // Draw the border of the rounded rectangle. 116 // Draw the border of the rounded rectangle.
117 NSColor* borderColor = themeProvider->GetNSColor( 117 NSColor* borderColor = themeProvider->GetNSColor(
(...skipping 13 matching lines...) Expand all
131 NSMakePoint(morph * bookmarks::kNTPBookmarkBarPadding + morph * 0.5, 131 NSMakePoint(morph * bookmarks::kNTPBookmarkBarPadding + morph * 0.5,
132 morph * bookmarks::kNTPBookmarkBarPadding + morph * 0.5); 132 morph * bookmarks::kNTPBookmarkBarPadding + morph * 0.5);
133 CGFloat dividerWidth = 133 CGFloat dividerWidth =
134 NSWidth(bounds) - 2 * morph * bookmarks::kNTPBookmarkBarPadding - 2 * 0.5; 134 NSWidth(bounds) - 2 * morph * bookmarks::kNTPBookmarkBarPadding - 2 * 0.5;
135 [divider moveToPoint:dividerStart]; 135 [divider moveToPoint:dividerStart];
136 [divider relativeLineToPoint:NSMakePoint(dividerWidth, 0)]; 136 [divider relativeLineToPoint:NSMakePoint(dividerWidth, 0)];
137 [divider stroke]; 137 [divider stroke];
138 } 138 }
139 139
140 @end // @implementation BookmarkBarToolbarView 140 @end // @implementation BookmarkBarToolbarView
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/download/download_item_cell.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698