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

Side by Side Diff: chrome/browser/cocoa/view_id_util.h

Issue 2973004: [Mac]Implement ViewID support. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Turns out that, it's not a good solution. Created 10 years, 5 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 | « chrome/browser/cocoa/toolbar_view.mm ('k') | chrome/browser/cocoa/view_id_util.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_COCOA_VIEW_ID_UTIL_H_
6 #define CHROME_BROWSER_COCOA_VIEW_ID_UTIL_H_
7
8 #include "gfx/native_widget_types.h"
9 #include "chrome/browser/view_ids.h"
10
11 namespace view_id_util {
12
13 // We use NSView's tag property to support ViewID, so we don't need special code
14 // for binding a ViewID to a NSView. The subclasses of NSView shall override tag
15 // method to return their ViewIDs.
16 // However the tag property is also used elsewhere, such as the window buttons
17 // provided by the Cocoa system (the three stoplights on the top left corner),
18 // whose tags will be set to 0, 1, 2 by the Cocoa system.
19 // In order to avoid conflict, we use negative tag value for ViewID.
20 // No existing chromium code uses negative tag value, so it's safe for us to use
21 // it.
22 // See http://dev.chromium.org/developers/design-documents/viewid-support-on-mac
23 // for details.
24
25 // A convenient function to convert a ViewID value to negative tag value. Using
26 // this function to make sure that we only need to change this fuction when we
27 // have to change the mapping algorithm to avoid conflict in the future.
28 inline int ViewIDToTag(ViewID viewID) {
29 return -viewID - 1;
30 }
31
32 // A convenient function to lookup a view by a ViewID in a given window.
33 NSView* GetView(NSWindow* window, ViewID viewID);
34
35 } // namespace view_id_util
36
37 #endif // CHROME_BROWSER_COCOA_VIEW_ID_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/toolbar_view.mm ('k') | chrome/browser/cocoa/view_id_util.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698