| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "bindings/core/v8/ScriptWrappable.h" | 5 #include "bindings/core/v8/ScriptWrappable.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/DOMDataStore.h" | 7 #include "bindings/core/v8/DOMDataStore.h" |
| 8 #include "bindings/core/v8/V8DOMWrapper.h" | 8 #include "bindings/core/v8/V8DOMWrapper.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 struct SameSizeAsScriptWrappable { | 12 struct SameSizeAsScriptWrappable { |
| 13 virtual ~SameSizeAsScriptWrappable() { } | 13 virtual ~SameSizeAsScriptWrappable() { } |
| 14 v8::Persistent<v8::Object> m_wrapper; | 14 v8::Persistent<v8::Object> m_wrapper; |
| 15 }; | 15 }; |
| 16 | 16 |
| 17 static_assert(sizeof(ScriptWrappable) <= sizeof(SameSizeAsScriptWrappable), "Scr
iptWrappable should stay small"); | 17 static_assert(sizeof(ScriptWrappable) <= sizeof(SameSizeAsScriptWrappable), "Scr
iptWrappable should stay small"); |
| 18 | 18 |
| 19 v8::Local<v8::Object> ScriptWrappable::wrap(v8::Isolate* isolate, v8::Local<v8::
Object> creationContext) | 19 v8::Local<v8::Object> ScriptWrappable::wrap(v8::Isolate* isolate, v8::Local<v8::
Object> creationContext) |
| 20 { | 20 { |
| 21 const WrapperTypeInfo* wrapperTypeInfo = this->wrapperTypeInfo(); | 21 const WrapperTypeInfo* wrapperTypeInfo = this->wrapperTypeInfo(); |
| 22 | 22 |
| 23 ASSERT(!DOMDataStore::containsWrapper(this, isolate)); | 23 ASSERT(!DOMDataStore::containsWrapper(this, isolate)); |
| 24 | 24 |
| 25 v8::Local<v8::Object> wrapper = V8DOMWrapper::createWrapper(isolate, creatio
nContext, wrapperTypeInfo, this); | 25 v8::Local<v8::Object> wrapper = V8DOMWrapper::createWrapper(isolate, creatio
nContext, wrapperTypeInfo); |
| 26 if (UNLIKELY(wrapper.IsEmpty())) | 26 if (UNLIKELY(wrapper.IsEmpty())) |
| 27 return wrapper; | 27 return wrapper; |
| 28 | 28 |
| 29 wrapperTypeInfo->installConditionallyEnabledProperties(wrapper, isolate); | 29 wrapperTypeInfo->installConditionallyEnabledProperties(wrapper, isolate); |
| 30 return associateWithWrapper(isolate, wrapperTypeInfo, wrapper); | 30 return associateWithWrapper(isolate, wrapperTypeInfo, wrapper); |
| 31 } | 31 } |
| 32 | 32 |
| 33 v8::Local<v8::Object> ScriptWrappable::associateWithWrapper(v8::Isolate* isolate
, const WrapperTypeInfo* wrapperTypeInfo, v8::Local<v8::Object> wrapper) | 33 v8::Local<v8::Object> ScriptWrappable::associateWithWrapper(v8::Isolate* isolate
, const WrapperTypeInfo* wrapperTypeInfo, v8::Local<v8::Object> wrapper) |
| 34 { | 34 { |
| 35 return V8DOMWrapper::associateObjectWithWrapper(isolate, this, wrapperTypeIn
fo, wrapper); | 35 return V8DOMWrapper::associateObjectWithWrapper(isolate, this, wrapperTypeIn
fo, wrapper); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void ScriptWrappable::markWrapper(v8::Isolate* isolate) const | 38 void ScriptWrappable::markWrapper(v8::Isolate* isolate) const |
| 39 { | 39 { |
| 40 if (containsWrapper()) | 40 if (containsWrapper()) |
| 41 ScriptWrappableVisitor::markWrapper(m_wrapper, isolate); | 41 ScriptWrappableVisitor::markWrapper(m_wrapper, isolate); |
| 42 } | 42 } |
| 43 | 43 |
| 44 } // namespace blink | 44 } // namespace blink |
| OLD | NEW |