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

Side by Side Diff: chrome/browser/ui/cocoa/nsview_additions.mm

Issue 469003006: Remove --disable-core-animation flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@erikchen_patch
Patch Set: Created 6 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
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/command_line.h"
6 #include "base/mac/mac_util.h" 5 #include "base/mac/mac_util.h"
7 #include "base/mac/sdk_forward_declarations.h" 6 #include "base/mac/sdk_forward_declarations.h"
8 #import "chrome/browser/ui/cocoa/nsview_additions.h" 7 #import "chrome/browser/ui/cocoa/nsview_additions.h"
9 #include "chrome/common/chrome_switches.h" 8 #include "chrome/common/chrome_switches.h"
10 #include "ui/base/ui_base_switches.h"
11 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 9 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
12 10
13 #include "base/logging.h" 11 #include "base/logging.h"
14 12
15 @implementation NSView (ChromeAdditions) 13 @implementation NSView (ChromeAdditions)
16 14
17 - (CGFloat)cr_lineWidth { 15 - (CGFloat)cr_lineWidth {
18 // All shipping retina macs run at least 10.7. 16 // All shipping retina macs run at least 10.7.
19 if (![self respondsToSelector:@selector(convertSizeFromBacking:)]) 17 if (![self respondsToSelector:@selector(convertSizeFromBacking:)])
20 return 1; 18 return 1;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return [[NSColor keyboardFocusIndicatorColor] 61 return [[NSColor keyboardFocusIndicatorColor]
64 colorWithAlphaComponent:0.5 / [self cr_lineWidth]]; 62 colorWithAlphaComponent:0.5 / [self cr_lineWidth]];
65 } 63 }
66 64
67 - (void)cr_recursivelySetNeedsDisplay:(BOOL)flag { 65 - (void)cr_recursivelySetNeedsDisplay:(BOOL)flag {
68 [self setNeedsDisplay:YES]; 66 [self setNeedsDisplay:YES];
69 for (NSView* child in [self subviews]) 67 for (NSView* child in [self subviews])
70 [child cr_recursivelySetNeedsDisplay:flag]; 68 [child cr_recursivelySetNeedsDisplay:flag];
71 } 69 }
72 70
73 - (void)cr_setWantsLayer:(BOOL)wantsLayer {
74 if (CommandLine::ForCurrentProcess()->HasSwitch(
75 switches::kDisableCoreAnimation))
76 return;
77
78 // Dynamically removing layers on SnowLeopard will sometimes result in
79 // crashes. Once a view has a layer on SnowLeopard, it is stuck with it.
80 // http://crbug.com/348328
81 if (!wantsLayer && base::mac::IsOSSnowLeopard())
82 return;
Avi (use Gerrit) 2014/08/14 19:23:40 Do we ever call setWantsLayer:NO? I'm hoping we do
ccameron 2014/08/14 19:34:39 We didn't call cr_setWantsLayer:NO (the previous c
83
84 [self setWantsLayer:wantsLayer];
85 }
86
87 static NSView* g_ancestorBeingDrawnFrom = nil; 71 static NSView* g_ancestorBeingDrawnFrom = nil;
88 static NSView* g_childBeingDrawnTo = nil; 72 static NSView* g_childBeingDrawnTo = nil;
89 73
90 - (void)cr_drawUsingAncestor:(NSView*)ancestorView inRect:(NSRect)rect { 74 - (void)cr_drawUsingAncestor:(NSView*)ancestorView inRect:(NSRect)rect {
91 gfx::ScopedNSGraphicsContextSaveGState scopedGSState; 75 gfx::ScopedNSGraphicsContextSaveGState scopedGSState;
92 NSRect frame = [self convertRect:[self bounds] toView:ancestorView]; 76 NSRect frame = [self convertRect:[self bounds] toView:ancestorView];
93 NSAffineTransform* transform = [NSAffineTransform transform]; 77 NSAffineTransform* transform = [NSAffineTransform transform];
94 if ([self isFlipped] == [ancestorView isFlipped]) { 78 if ([self isFlipped] == [ancestorView isFlipped]) {
95 [transform translateXBy:-NSMinX(frame) yBy:-NSMinY(frame)]; 79 [transform translateXBy:-NSMinX(frame) yBy:-NSMinY(frame)];
96 } else { 80 } else {
(...skipping 12 matching lines...) Expand all
109 } 93 }
110 94
111 - (NSView*)cr_viewBeingDrawnTo { 95 - (NSView*)cr_viewBeingDrawnTo {
112 if (!g_ancestorBeingDrawnFrom) 96 if (!g_ancestorBeingDrawnFrom)
113 return self; 97 return self;
114 DCHECK(g_ancestorBeingDrawnFrom == self); 98 DCHECK(g_ancestorBeingDrawnFrom == self);
115 return g_childBeingDrawnTo; 99 return g_childBeingDrawnTo;
116 } 100 }
117 101
118 @end 102 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698