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

Side by Side Diff: ui/base/cocoa/nsview_additions.mm

Issue 1125363005: Fix darkly-drawn Show All button in Downloads Shelf. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change API to accommodate Show All button background drawing. Created 5 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 | « ui/base/cocoa/nsview_additions.h ('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 #include "base/mac/sdk_forward_declarations.h" 5 #include "base/mac/sdk_forward_declarations.h"
6 #import "ui/base/cocoa/nsview_additions.h" 6 #import "ui/base/cocoa/nsview_additions.h"
7 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 7 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 - (void)cr_recursivelySetNeedsDisplay:(BOOL)flag { 69 - (void)cr_recursivelySetNeedsDisplay:(BOOL)flag {
70 [self setNeedsDisplay:YES]; 70 [self setNeedsDisplay:YES];
71 for (NSView* child in [self subviews]) 71 for (NSView* child in [self subviews])
72 [child cr_recursivelySetNeedsDisplay:flag]; 72 [child cr_recursivelySetNeedsDisplay:flag];
73 } 73 }
74 74
75 static NSView* g_ancestorBeingDrawnFrom = nil; 75 static NSView* g_ancestorBeingDrawnFrom = nil;
76 static NSView* g_childBeingDrawnTo = nil; 76 static NSView* g_childBeingDrawnTo = nil;
77 77
78 - (void)cr_drawUsingAncestor:(NSView*)ancestorView inRect:(NSRect)dirtyRect { 78 - (void)cr_drawUsingAncestor:(NSView*)ancestorView inRect:(NSRect)dirtyRect
79 clippedToAncestorBounds:(BOOL)clipToAncestorBounds {
79 gfx::ScopedNSGraphicsContextSaveGState scopedGSState; 80 gfx::ScopedNSGraphicsContextSaveGState scopedGSState;
80 NSRect frame = [self convertRect:[self bounds] toView:ancestorView]; 81 NSRect frame = [self convertRect:[self bounds] toView:ancestorView];
81 NSAffineTransform* transform = [NSAffineTransform transform]; 82 NSAffineTransform* transform = [NSAffineTransform transform];
82 if ([self isFlipped] == [ancestorView isFlipped]) { 83 if ([self isFlipped] == [ancestorView isFlipped]) {
83 [transform translateXBy:-NSMinX(frame) yBy:-NSMinY(frame)]; 84 [transform translateXBy:-NSMinX(frame) yBy:-NSMinY(frame)];
84 } else { 85 } else {
85 [transform translateXBy:-NSMinX(frame) yBy:NSMaxY(frame)]; 86 [transform translateXBy:-NSMinX(frame) yBy:NSMaxY(frame)];
86 [transform scaleXBy:1.0 yBy:-1.0]; 87 [transform scaleXBy:1.0 yBy:-1.0];
87 } 88 }
88 [transform concat]; 89 [transform concat];
89 90
90 // This can be made robust to recursive calls, but is as of yet unneeded. 91 // This can be made robust to recursive calls, but is as of yet unneeded.
91 DCHECK(!g_ancestorBeingDrawnFrom && !g_childBeingDrawnTo); 92 DCHECK(!g_ancestorBeingDrawnFrom && !g_childBeingDrawnTo);
92 g_ancestorBeingDrawnFrom = ancestorView; 93 g_ancestorBeingDrawnFrom = ancestorView;
93 g_childBeingDrawnTo = self; 94 g_childBeingDrawnTo = self;
94 [ancestorView drawRect:NSIntersectionRect( 95 NSRect drawRect = [self convertRect:dirtyRect toView:ancestorView];
95 [ancestorView bounds], 96 if (clipToAncestorBounds) {
96 [self convertRect:dirtyRect toView:ancestorView])]; 97 drawRect = NSIntersectionRect([ancestorView bounds], drawRect);
98 }
99 [ancestorView drawRect:drawRect];
97 g_childBeingDrawnTo = nil; 100 g_childBeingDrawnTo = nil;
98 g_ancestorBeingDrawnFrom = nil; 101 g_ancestorBeingDrawnFrom = nil;
99 } 102 }
100 103
104 - (void)cr_drawUsingAncestor:(NSView*)ancestorView inRect:(NSRect)dirtyRect {
105 [self cr_drawUsingAncestor:ancestorView
106 inRect:dirtyRect
107 clippedToAncestorBounds:YES];
108 }
109
101 - (NSView*)cr_viewBeingDrawnTo { 110 - (NSView*)cr_viewBeingDrawnTo {
102 if (!g_ancestorBeingDrawnFrom) 111 if (!g_ancestorBeingDrawnFrom)
103 return self; 112 return self;
104 DCHECK(g_ancestorBeingDrawnFrom == self); 113 DCHECK(g_ancestorBeingDrawnFrom == self);
105 return g_childBeingDrawnTo; 114 return g_childBeingDrawnTo;
106 } 115 }
107 116
108 @end 117 @end
OLDNEW
« no previous file with comments | « ui/base/cocoa/nsview_additions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698