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