| 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 #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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 [self addSubview:subview | 53 [self addSubview:subview |
| 54 positioned:place | 54 positioned:place |
| 55 relativeTo:otherView]; | 55 relativeTo:otherView]; |
| 56 } | 56 } |
| 57 | 57 |
| 58 - (NSColor*)cr_keyboardFocusIndicatorColor { | 58 - (NSColor*)cr_keyboardFocusIndicatorColor { |
| 59 return [[NSColor keyboardFocusIndicatorColor] | 59 return [[NSColor keyboardFocusIndicatorColor] |
| 60 colorWithAlphaComponent:0.5 / [self cr_lineWidth]]; | 60 colorWithAlphaComponent:0.5 / [self cr_lineWidth]]; |
| 61 } | 61 } |
| 62 | 62 |
| 63 - (void)cr_recursivelyInvokeBlock:(void (^)(id view))block { |
| 64 block(self); |
| 65 for (NSView* subview in [self subviews]) |
| 66 [subview cr_recursivelyInvokeBlock:block]; |
| 67 } |
| 68 |
| 63 - (void)cr_recursivelySetNeedsDisplay:(BOOL)flag { | 69 - (void)cr_recursivelySetNeedsDisplay:(BOOL)flag { |
| 64 [self setNeedsDisplay:YES]; | 70 [self setNeedsDisplay:YES]; |
| 65 for (NSView* child in [self subviews]) | 71 for (NSView* child in [self subviews]) |
| 66 [child cr_recursivelySetNeedsDisplay:flag]; | 72 [child cr_recursivelySetNeedsDisplay:flag]; |
| 67 } | 73 } |
| 68 | 74 |
| 69 static NSView* g_ancestorBeingDrawnFrom = nil; | 75 static NSView* g_ancestorBeingDrawnFrom = nil; |
| 70 static NSView* g_childBeingDrawnTo = nil; | 76 static NSView* g_childBeingDrawnTo = nil; |
| 71 | 77 |
| 72 - (void)cr_drawUsingAncestor:(NSView*)ancestorView inRect:(NSRect)rect { | 78 - (void)cr_drawUsingAncestor:(NSView*)ancestorView inRect:(NSRect)rect { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 91 } | 97 } |
| 92 | 98 |
| 93 - (NSView*)cr_viewBeingDrawnTo { | 99 - (NSView*)cr_viewBeingDrawnTo { |
| 94 if (!g_ancestorBeingDrawnFrom) | 100 if (!g_ancestorBeingDrawnFrom) |
| 95 return self; | 101 return self; |
| 96 DCHECK(g_ancestorBeingDrawnFrom == self); | 102 DCHECK(g_ancestorBeingDrawnFrom == self); |
| 97 return g_childBeingDrawnTo; | 103 return g_childBeingDrawnTo; |
| 98 } | 104 } |
| 99 | 105 |
| 100 @end | 106 @end |
| OLD | NEW |