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

Side by Side Diff: third_party/WebKit/Source/platform/bindings/WrapperTypeInfo.h

Issue 2843603002: Move ScriptWrappable and dependencies to platform/bindings (Closed)
Patch Set: Rebase and try again Created 3 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef WrapperTypeInfo_h 31 #ifndef WrapperTypeInfo_h
32 #define WrapperTypeInfo_h 32 #define WrapperTypeInfo_h
33 33
34 #include "bindings/core/v8/ActiveScriptWrappable.h"
35 #include "gin/public/wrapper_info.h" 34 #include "gin/public/wrapper_info.h"
35 #include "platform/bindings/ActiveScriptWrappable.h"
36 #include "platform/heap/Handle.h" 36 #include "platform/heap/Handle.h"
37 #include "platform/wtf/Allocator.h" 37 #include "platform/wtf/Allocator.h"
38 #include "platform/wtf/Assertions.h" 38 #include "platform/wtf/Assertions.h"
39 #include "v8/include/v8.h" 39 #include "v8/include/v8.h"
40 40
41 namespace blink { 41 namespace blink {
42 42
43 class DOMWrapperWorld; 43 class DOMWrapperWorld;
44 class ScriptWrappable; 44 class ScriptWrappable;
45 45
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 DCHECK(trace_wrappers_function); 149 DCHECK(trace_wrappers_function);
150 return trace_wrappers_function(visitor, script_wrappable); 150 return trace_wrappers_function(visitor, script_wrappable);
151 } 151 }
152 152
153 void PreparePrototypeAndInterfaceObject( 153 void PreparePrototypeAndInterfaceObject(
154 v8::Local<v8::Context> context, 154 v8::Local<v8::Context> context,
155 const DOMWrapperWorld& world, 155 const DOMWrapperWorld& world,
156 v8::Local<v8::Object> prototype_object, 156 v8::Local<v8::Object> prototype_object,
157 v8::Local<v8::Function> interface_object, 157 v8::Local<v8::Function> interface_object,
158 v8::Local<v8::FunctionTemplate> interface_template) const { 158 v8::Local<v8::FunctionTemplate> interface_template) const {
159 if (prepare_prototype_and_interface_object_function) 159 if (prepare_prototype_and_interface_object_function) {
160 prepare_prototype_and_interface_object_function( 160 prepare_prototype_and_interface_object_function(
161 context, world, prototype_object, interface_object, 161 context, world, prototype_object, interface_object,
162 interface_template); 162 interface_template);
163 }
163 } 164 }
164 165
165 bool IsActiveScriptWrappable() const { 166 bool IsActiveScriptWrappable() const {
166 return active_script_wrappable_inheritance == 167 return active_script_wrappable_inheritance ==
167 kInheritFromActiveScriptWrappable; 168 kInheritFromActiveScriptWrappable;
168 } 169 }
169 170
170 // This field must be the first member of the struct WrapperTypeInfo. 171 // This field must be the first member of the struct WrapperTypeInfo.
171 // See also static_assert() in .cpp file. 172 // See also static_assert() in .cpp file.
172 const gin::GinEmbedder gin_embedder; 173 const gin::GinEmbedder gin_embedder;
173 174
174 DomTemplateFunction dom_template_function; 175 DomTemplateFunction dom_template_function;
175 const TraceFunction trace_function; 176 const TraceFunction trace_function;
176 const TraceWrappersFunction trace_wrappers_function; 177 const TraceWrappersFunction trace_wrappers_function;
177 PreparePrototypeAndInterfaceObjectFunction 178 PreparePrototypeAndInterfaceObjectFunction
178 prepare_prototype_and_interface_object_function; 179 prepare_prototype_and_interface_object_function;
179 const char* const interface_name; 180 const char* const interface_name;
180 const WrapperTypeInfo* parent_class; 181 const WrapperTypeInfo* parent_class;
181 const unsigned wrapper_type_prototype : 1; // WrapperTypePrototype 182 const unsigned wrapper_type_prototype : 1; // WrapperTypePrototype
182 const unsigned wrapper_class_id : 2; // WrapperClassId 183 const unsigned wrapper_class_id : 2; // WrapperClassId
183 const unsigned // ActiveScriptWrappableInheritance 184 const unsigned // ActiveScriptWrappableInheritance
184 active_script_wrappable_inheritance : 1; 185 active_script_wrappable_inheritance : 1;
185 const unsigned lifetime : 1; // Lifetime 186 const unsigned lifetime : 1; // Lifetime
186 }; 187 };
187 188
188 template <typename T, int offset> 189 template <typename T, int offset>
189 inline T* GetInternalField(const v8::PersistentBase<v8::Object>& persistent) { 190 inline T* GetInternalField(const v8::PersistentBase<v8::Object>& persistent) {
190 DCHECK_LT(offset, v8::Object::InternalFieldCount(persistent)); 191 DCHECK_LT(offset, v8::Object::InternalFieldCount(persistent));
191 return reinterpret_cast<T*>( 192 return reinterpret_cast<T*>(
192 v8::Object::GetAlignedPointerFromInternalField(persistent, offset)); 193 v8::Object::GetAlignedPointerFromInternalField(persistent, offset));
193 } 194 }
194 195
195 template <typename T, int offset> 196 template <typename T, int offset>
(...skipping 19 matching lines...) Expand all
215 return GetInternalField<WrapperTypeInfo, kV8DOMWrapperTypeIndex>(wrapper); 216 return GetInternalField<WrapperTypeInfo, kV8DOMWrapperTypeIndex>(wrapper);
216 } 217 }
217 218
218 inline const WrapperTypeInfo* ToWrapperTypeInfo(v8::Local<v8::Object> wrapper) { 219 inline const WrapperTypeInfo* ToWrapperTypeInfo(v8::Local<v8::Object> wrapper) {
219 return GetInternalField<WrapperTypeInfo, kV8DOMWrapperTypeIndex>(wrapper); 220 return GetInternalField<WrapperTypeInfo, kV8DOMWrapperTypeIndex>(wrapper);
220 } 221 }
221 222
222 } // namespace blink 223 } // namespace blink
223 224
224 #endif // WrapperTypeInfo_h 225 #endif // WrapperTypeInfo_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698