OLD | NEW |
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/view_id_util.h" | 5 #import "chrome/browser/ui/cocoa/view_id_util.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <utility> | 10 #include <utility> |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } // namespace view_id_util | 79 } // namespace view_id_util |
80 | 80 |
81 @implementation NSView (ViewID) | 81 @implementation NSView (ViewID) |
82 | 82 |
83 - (ViewID)viewID { | 83 - (ViewID)viewID { |
84 ViewIDMap* map = g_view_id_map.Pointer(); | 84 ViewIDMap* map = g_view_id_map.Pointer(); |
85 ViewIDMap::const_iterator iter = map->find(self); | 85 ViewIDMap::const_iterator iter = map->find(self); |
86 return iter != map->end() ? iter->second : VIEW_ID_NONE; | 86 return iter != map->end() ? iter->second : VIEW_ID_NONE; |
87 } | 87 } |
88 | 88 |
| 89 - (NSView*)ancestorWithViewID:(ViewID)viewID { |
| 90 NSView* ancestor = self; |
| 91 while (ancestor && [ancestor viewID] != viewID) |
| 92 ancestor = [ancestor superview]; |
| 93 return ancestor; |
| 94 } |
| 95 |
89 @end | 96 @end |
OLD | NEW |