OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef GFX_NATIVE_WIDGET_TYPES_H_ | 5 #ifndef GFX_NATIVE_WIDGET_TYPES_H_ |
6 #define GFX_NATIVE_WIDGET_TYPES_H_ | 6 #define GFX_NATIVE_WIDGET_TYPES_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 | 82 |
83 // Note: for test_shell we're packing a pointer into the NativeViewId. So, if | 83 // Note: for test_shell we're packing a pointer into the NativeViewId. So, if |
84 // you make it a type which is smaller than a pointer, you have to fix | 84 // you make it a type which is smaller than a pointer, you have to fix |
85 // test_shell. | 85 // test_shell. |
86 // | 86 // |
87 // See comment at the top of the file for usage. | 87 // See comment at the top of the file for usage. |
88 typedef intptr_t NativeViewId; | 88 typedef intptr_t NativeViewId; |
89 | 89 |
90 #if defined(OS_WIN) | 90 #if defined(OS_WIN) |
91 // Convert a NativeViewId to a NativeView. | 91 // Convert a NativeViewId to a NativeView. |
92 // This is only used on Windows, where we pass an HWND into the renderer and | 92 // |
93 // let the renderer operate on it. On other platforms, the renderer doesn't | 93 // On Windows, we pass an HWND into the renderer. As stated above, the renderer |
94 // have access to native platform widgets. | 94 // should not be performing operations on the view. |
95 static inline NativeView NativeViewFromId(NativeViewId id) { | 95 static inline NativeView NativeViewFromId(NativeViewId id) { |
96 return reinterpret_cast<NativeView>(id); | 96 return reinterpret_cast<NativeView>(id); |
97 } | 97 } |
98 #define NativeViewFromIdInBrowser(x) NativeViewFromId(x) | |
99 #elif defined(OS_MACOSX) | |
100 // On the Mac, a NativeView is a pointer to an object, and is useless outside | |
101 // the process in which it was created. This is a little reminder that | |
102 // NativeViewFromId should only be used inside the appropriate platform ifdef | |
103 // outside of the browser. (NativeViewFromIdInBrowser can be used everywhere in | |
104 // the browser.) If your cross-platform design involves a call to | |
105 // NativeViewFromId from outside the browser it will never work on the Mac and | |
106 // is fundamentally broken. | |
107 #define NativeViewFromId \ | |
108 NATIVE_VIEW_FROM_ID_NOT_AVAILABLE_OUTSIDE_BROWSER_ON_MAC | |
stuartmorgan
2010/05/12 18:54:43
Is this line really necessary? Not having a defini
| |
109 // Please do not call this from outside the browser. It won't work; the name | |
110 // should give you a subtle hint. | |
111 static inline NativeView NativeViewFromIdInBrowser(NativeViewId id) { | |
112 return reinterpret_cast<NativeView>(id); | |
113 } | |
98 #endif | 114 #endif |
99 | 115 |
100 // Convert a NativeView to a NativeViewId. See the comments at the top of | 116 // Convert a NativeView to a NativeViewId. See the comments at the top of |
101 // this file. | 117 // this file. |
102 #if defined(OS_WIN) || defined(OS_MACOSX) | 118 #if defined(OS_WIN) || defined(OS_MACOSX) |
103 static inline NativeViewId IdFromNativeView(NativeView view) { | 119 static inline NativeViewId IdFromNativeView(NativeView view) { |
104 return reinterpret_cast<NativeViewId>(view); | 120 return reinterpret_cast<NativeViewId>(view); |
105 } | 121 } |
106 #elif defined(USE_X11) | 122 #elif defined(USE_X11) |
107 // Not inlined because it involves pulling too many headers. | 123 // Not inlined because it involves pulling too many headers. |
(...skipping 21 matching lines...) Expand all Loading... | |
129 // GPU plugin becomes a full-on GPU process, this typedef can be | 145 // GPU plugin becomes a full-on GPU process, this typedef can be |
130 // returned to a bool. For now we use a type large enough to hold a | 146 // returned to a bool. For now we use a type large enough to hold a |
131 // pointer on 64-bit architectures in case we need this capability. | 147 // pointer on 64-bit architectures in case we need this capability. |
132 typedef uint64 PluginWindowHandle; | 148 typedef uint64 PluginWindowHandle; |
133 const PluginWindowHandle kNullPluginWindow = 0; | 149 const PluginWindowHandle kNullPluginWindow = 0; |
134 #endif | 150 #endif |
135 | 151 |
136 } // namespace gfx | 152 } // namespace gfx |
137 | 153 |
138 #endif // GFX_NATIVE_WIDGET_TYPES_H_ | 154 #endif // GFX_NATIVE_WIDGET_TYPES_H_ |
OLD | NEW |