| OLD | NEW |
| 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 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 class CORE_EXPORT TraceWrapperBase { | 44 class CORE_EXPORT TraceWrapperBase { |
| 45 WTF_MAKE_NONCOPYABLE(TraceWrapperBase); | 45 WTF_MAKE_NONCOPYABLE(TraceWrapperBase); |
| 46 | 46 |
| 47 public: | 47 public: |
| 48 TraceWrapperBase() = default; | 48 TraceWrapperBase() = default; |
| 49 virtual bool isScriptWrappable() const { return false; } | 49 virtual bool isScriptWrappable() const { return false; } |
| 50 | 50 |
| 51 void markAndDispatchTraceWrappers(const WrapperVisitor* visitor) const { | |
| 52 visitor->dispatchTraceWrappers(this); | |
| 53 } | |
| 54 | |
| 55 DECLARE_VIRTUAL_TRACE_WRAPPERS(){}; | 51 DECLARE_VIRTUAL_TRACE_WRAPPERS(){}; |
| 56 }; | 52 }; |
| 57 | 53 |
| 58 // ScriptWrappable provides a way to map from/to C++ DOM implementation to/from | 54 // ScriptWrappable provides a way to map from/to C++ DOM implementation to/from |
| 59 // JavaScript object (platform object). ToV8() converts a ScriptWrappable to | 55 // JavaScript object (platform object). ToV8() converts a ScriptWrappable to |
| 60 // a v8::Object and toScriptWrappable() converts a v8::Object back to | 56 // a v8::Object and toScriptWrappable() converts a v8::Object back to |
| 61 // a ScriptWrappable. v8::Object as platform object is called "wrapper object". | 57 // a ScriptWrappable. v8::Object as platform object is called "wrapper object". |
| 62 // The wrapepr object for the main world is stored in ScriptWrappable. Wrapper | 58 // The wrapepr object for the main world is stored in ScriptWrappable. Wrapper |
| 63 // objects for other worlds are stored in DOMWrapperMap. | 59 // objects for other worlds are stored in DOMWrapperMap. |
| 64 class CORE_EXPORT ScriptWrappable : public TraceWrapperBase { | 60 class CORE_EXPORT ScriptWrappable : public TraceWrapperBase { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 return containsWrapper(); | 154 return containsWrapper(); |
| 159 } | 155 } |
| 160 | 156 |
| 161 bool containsWrapper() const { return !m_mainWorldWrapper.IsEmpty(); } | 157 bool containsWrapper() const { return !m_mainWorldWrapper.IsEmpty(); } |
| 162 | 158 |
| 163 // Mark wrapper of this ScriptWrappable as alive in V8. Only marks | 159 // Mark wrapper of this ScriptWrappable as alive in V8. Only marks |
| 164 // wrapper in the main world. To mark wrappers in all worlds call | 160 // wrapper in the main world. To mark wrappers in all worlds call |
| 165 // ScriptWrappableVisitor::markWrapper(ScriptWrappable*, v8::Isolate*) | 161 // ScriptWrappableVisitor::markWrapper(ScriptWrappable*, v8::Isolate*) |
| 166 void markWrapper(const WrapperVisitor*) const; | 162 void markWrapper(const WrapperVisitor*) const; |
| 167 | 163 |
| 168 void markAndDispatchTraceWrappers(const WrapperVisitor* visitor) const { | |
| 169 visitor->markWrappersInAllWorlds(this); | |
| 170 visitor->dispatchTraceWrappers(this); | |
| 171 } | |
| 172 | |
| 173 private: | 164 private: |
| 174 // These classes are exceptionally allowed to use mainWorldWrapper(). | 165 // These classes are exceptionally allowed to use mainWorldWrapper(). |
| 175 friend class DOMDataStore; | 166 friend class DOMDataStore; |
| 176 friend class HeapSnaphotWrapperVisitor; | 167 friend class HeapSnaphotWrapperVisitor; |
| 177 friend class V8HiddenValue; | 168 friend class V8HiddenValue; |
| 178 friend class V8PrivateProperty; | 169 friend class V8PrivateProperty; |
| 179 | 170 |
| 180 v8::Local<v8::Object> mainWorldWrapper(v8::Isolate* isolate) const { | 171 v8::Local<v8::Object> mainWorldWrapper(v8::Isolate* isolate) const { |
| 181 return v8::Local<v8::Object>::New(isolate, m_mainWorldWrapper); | 172 return v8::Local<v8::Object>::New(isolate, m_mainWorldWrapper); |
| 182 } | 173 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 #define DECLARE_WRAPPERTYPEINFO() \ | 211 #define DECLARE_WRAPPERTYPEINFO() \ |
| 221 public: \ | 212 public: \ |
| 222 const WrapperTypeInfo* wrapperTypeInfo() const override; \ | 213 const WrapperTypeInfo* wrapperTypeInfo() const override; \ |
| 223 \ | 214 \ |
| 224 private: \ | 215 private: \ |
| 225 typedef void end_of_define_wrappertypeinfo_not_reached_t | 216 typedef void end_of_define_wrappertypeinfo_not_reached_t |
| 226 | 217 |
| 227 } // namespace blink | 218 } // namespace blink |
| 228 | 219 |
| 229 #endif // ScriptWrappable_h | 220 #endif // ScriptWrappable_h |
| OLD | NEW |