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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/view_id_util.h
diff --git a/chrome/browser/cocoa/view_id_util.h b/chrome/browser/cocoa/view_id_util.h
new file mode 100644
index 0000000000000000000000000000000000000000..72bb11969041fb15ea97828f11478b3fd09aac53
--- /dev/null
+++ b/chrome/browser/cocoa/view_id_util.h
@@ -0,0 +1,37 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_COCOA_VIEW_ID_UTIL_H_
+#define CHROME_BROWSER_COCOA_VIEW_ID_UTIL_H_
+
+#include "gfx/native_widget_types.h"
+#include "chrome/browser/view_ids.h"
+
+namespace view_id_util {
+
+// We use NSView's tag property to support ViewID, so we don't need special code
+// for binding a ViewID to a NSView. The subclasses of NSView shall override tag
+// method to return their ViewIDs.
+// However the tag property is also used elsewhere, such as the window buttons
+// provided by the Cocoa system (the three stoplights on the top left corner),
+// whose tags will be set to 0, 1, 2 by the Cocoa system.
+// In order to avoid conflict, we use negative tag value for ViewID.
+// No existing chromium code uses negative tag value, so it's safe for us to use
+// it.
+// See http://dev.chromium.org/developers/design-documents/viewid-support-on-mac
+// for details.
+
+// A convenient function to convert a ViewID value to negative tag value. Using
+// this function to make sure that we only need to change this fuction when we
+// have to change the mapping algorithm to avoid conflict in the future.
+inline int ViewIDToTag(ViewID viewID) {
+ return -viewID - 1;
+}
+
+// A convenient function to lookup a view by a ViewID in a given window.
+NSView* GetView(NSWindow* window, ViewID viewID);
+
+} // namespace view_id_util
+
+#endif // CHROME_BROWSER_COCOA_VIEW_ID_UTIL_H_
« 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