| 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_
|
|
|