Title: [134489] trunk/Source/WebCore
Revision
134489
Author
[email protected]
Date
2012-11-13 14:38:25 -0800 (Tue, 13 Nov 2012)

Log Message

[V8] instantiateV8Object should encapulate the tricky creationContext logic
https://bugs.webkit.org/show_bug.cgi?id=102117

Reviewed by Eric Seidel.

The logic around creationContext is tricky. Rather than putting the
logic in the code generator, we can centralize the logic in
instantiateV8Object.

This patch shouldn't have any behavior change.

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateToV8Converters):
* bindings/v8/V8DOMWrapper.cpp:
(V8WrapperInstantiationScope):
(WebCore::V8WrapperInstantiationScope::V8WrapperInstantiationScope):
(WebCore::V8WrapperInstantiationScope::~V8WrapperInstantiationScope):
(WebCore::V8WrapperInstantiationScope::context):
(WebCore):
(WebCore::V8DOMWrapper::instantiateV8Object):
* bindings/v8/V8DOMWrapper.h:
(V8DOMWrapper):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (134488 => 134489)


--- trunk/Source/WebCore/ChangeLog	2012-11-13 22:36:18 UTC (rev 134488)
+++ trunk/Source/WebCore/ChangeLog	2012-11-13 22:38:25 UTC (rev 134489)
@@ -1,3 +1,28 @@
+2012-11-13  Adam Barth  <[email protected]>
+
+        [V8] instantiateV8Object should encapulate the tricky creationContext logic
+        https://bugs.webkit.org/show_bug.cgi?id=102117
+
+        Reviewed by Eric Seidel.
+
+        The logic around creationContext is tricky. Rather than putting the
+        logic in the code generator, we can centralize the logic in
+        instantiateV8Object.
+
+        This patch shouldn't have any behavior change.
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateToV8Converters):
+        * bindings/v8/V8DOMWrapper.cpp:
+        (V8WrapperInstantiationScope):
+        (WebCore::V8WrapperInstantiationScope::V8WrapperInstantiationScope):
+        (WebCore::V8WrapperInstantiationScope::~V8WrapperInstantiationScope):
+        (WebCore::V8WrapperInstantiationScope::context):
+        (WebCore):
+        (WebCore::V8DOMWrapper::instantiateV8Object):
+        * bindings/v8/V8DOMWrapper.h:
+        (V8DOMWrapper):
+
 2012-11-13  Silvia Pfeiffer  <[email protected]>
 
         Clean up the inheritance tree under the MediaControls Class.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (134488 => 134489)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-11-13 22:36:18 UTC (rev 134488)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-11-13 22:38:25 UTC (rev 134489)
@@ -3498,7 +3498,6 @@
 {
     ASSERT(impl.get());
     ASSERT($getCachedWrapper.IsEmpty());
-    v8::Handle<v8::Object> wrapper;
 END
     if ($baseType ne $interfaceName) {
         push(@implContent, <<END);
@@ -3523,20 +3522,7 @@
 
     push(@implContent, <<END);
 
-    v8::Handle<v8::Context> context;
-    if (!creationContext.IsEmpty() && creationContext->CreationContext() != v8::Context::GetCurrent()) {
-        // For performance, we enter the context only if the currently running context
-        // is different from the context that we are about to enter.
-        context = v8::Local<v8::Context>::New(creationContext->CreationContext());
-        ASSERT(!context.IsEmpty());
-        context->Enter();
-    }
-
-    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
-
-    if (!context.IsEmpty())
-        context->Exit();
-
+    v8::Handle<v8::Object> wrapper = V8DOMWrapper::instantiateV8Object(creationContext, &info, impl.get());
     if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp (134488 => 134489)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp	2012-11-13 22:36:18 UTC (rev 134488)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp	2012-11-13 22:38:25 UTC (rev 134489)
@@ -149,23 +149,9 @@
 {
     ASSERT(impl.get());
     ASSERT(DOMDataStore::current(isolate)->get(impl.get()).IsEmpty());
-    v8::Handle<v8::Object> wrapper;
     ASSERT(static_cast<void*>(static_cast<ArrayBufferView*>(impl.get())) == static_cast<void*>(impl.get()));
 
-    v8::Handle<v8::Context> context;
-    if (!creationContext.IsEmpty() && creationContext->CreationContext() != v8::Context::GetCurrent()) {
-        // For performance, we enter the context only if the currently running context
-        // is different from the context that we are about to enter.
-        context = v8::Local<v8::Context>::New(creationContext->CreationContext());
-        ASSERT(!context.IsEmpty());
-        context->Enter();
-    }
-
-    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
-
-    if (!context.IsEmpty())
-        context->Exit();
-
+    v8::Handle<v8::Object> wrapper = V8DOMWrapper::instantiateV8Object(creationContext, &info, impl.get());
     if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp (134488 => 134489)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp	2012-11-13 22:36:18 UTC (rev 134488)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp	2012-11-13 22:38:25 UTC (rev 134489)
@@ -179,22 +179,8 @@
 {
     ASSERT(impl.get());
     ASSERT(DOMDataStore::current(isolate)->get(impl.get()).IsEmpty());
-    v8::Handle<v8::Object> wrapper;
 
-    v8::Handle<v8::Context> context;
-    if (!creationContext.IsEmpty() && creationContext->CreationContext() != v8::Context::GetCurrent()) {
-        // For performance, we enter the context only if the currently running context
-        // is different from the context that we are about to enter.
-        context = v8::Local<v8::Context>::New(creationContext->CreationContext());
-        ASSERT(!context.IsEmpty());
-        context->Enter();
-    }
-
-    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
-
-    if (!context.IsEmpty())
-        context->Exit();
-
+    v8::Handle<v8::Object> wrapper = V8DOMWrapper::instantiateV8Object(creationContext, &info, impl.get());
     if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp (134488 => 134489)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp	2012-11-13 22:36:18 UTC (rev 134488)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp	2012-11-13 22:38:25 UTC (rev 134489)
@@ -113,22 +113,8 @@
 {
     ASSERT(impl.get());
     ASSERT(DOMDataStore::current(isolate)->get(impl.get()).IsEmpty());
-    v8::Handle<v8::Object> wrapper;
 
-    v8::Handle<v8::Context> context;
-    if (!creationContext.IsEmpty() && creationContext->CreationContext() != v8::Context::GetCurrent()) {
-        // For performance, we enter the context only if the currently running context
-        // is different from the context that we are about to enter.
-        context = v8::Local<v8::Context>::New(creationContext->CreationContext());
-        ASSERT(!context.IsEmpty());
-        context->Enter();
-    }
-
-    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
-
-    if (!context.IsEmpty())
-        context->Exit();
-
+    v8::Handle<v8::Object> wrapper = V8DOMWrapper::instantiateV8Object(creationContext, &info, impl.get());
     if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp (134488 => 134489)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp	2012-11-13 22:36:18 UTC (rev 134488)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp	2012-11-13 22:38:25 UTC (rev 134489)
@@ -150,22 +150,8 @@
 {
     ASSERT(impl.get());
     ASSERT(DOMDataStore::current(isolate)->get(impl.get()).IsEmpty());
-    v8::Handle<v8::Object> wrapper;
 
-    v8::Handle<v8::Context> context;
-    if (!creationContext.IsEmpty() && creationContext->CreationContext() != v8::Context::GetCurrent()) {
-        // For performance, we enter the context only if the currently running context
-        // is different from the context that we are about to enter.
-        context = v8::Local<v8::Context>::New(creationContext->CreationContext());
-        ASSERT(!context.IsEmpty());
-        context->Enter();
-    }
-
-    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
-
-    if (!context.IsEmpty())
-        context->Exit();
-
+    v8::Handle<v8::Object> wrapper = V8DOMWrapper::instantiateV8Object(creationContext, &info, impl.get());
     if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp (134488 => 134489)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp	2012-11-13 22:36:18 UTC (rev 134488)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp	2012-11-13 22:38:25 UTC (rev 134489)
@@ -174,22 +174,8 @@
 {
     ASSERT(impl.get());
     ASSERT(DOMDataStore::current(isolate)->get(impl.get()).IsEmpty());
-    v8::Handle<v8::Object> wrapper;
 
-    v8::Handle<v8::Context> context;
-    if (!creationContext.IsEmpty() && creationContext->CreationContext() != v8::Context::GetCurrent()) {
-        // For performance, we enter the context only if the currently running context
-        // is different from the context that we are about to enter.
-        context = v8::Local<v8::Context>::New(creationContext->CreationContext());
-        ASSERT(!context.IsEmpty());
-        context->Enter();
-    }
-
-    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
-
-    if (!context.IsEmpty())
-        context->Exit();
-
+    v8::Handle<v8::Object> wrapper = V8DOMWrapper::instantiateV8Object(creationContext, &info, impl.get());
     if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestException.cpp (134488 => 134489)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestException.cpp	2012-11-13 22:36:18 UTC (rev 134488)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestException.cpp	2012-11-13 22:38:25 UTC (rev 134489)
@@ -104,22 +104,8 @@
 {
     ASSERT(impl.get());
     ASSERT(DOMDataStore::current(isolate)->get(impl.get()).IsEmpty());
-    v8::Handle<v8::Object> wrapper;
 
-    v8::Handle<v8::Context> context;
-    if (!creationContext.IsEmpty() && creationContext->CreationContext() != v8::Context::GetCurrent()) {
-        // For performance, we enter the context only if the currently running context
-        // is different from the context that we are about to enter.
-        context = v8::Local<v8::Context>::New(creationContext->CreationContext());
-        ASSERT(!context.IsEmpty());
-        context->Enter();
-    }
-
-    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
-
-    if (!context.IsEmpty())
-        context->Exit();
-
+    v8::Handle<v8::Object> wrapper = V8DOMWrapper::instantiateV8Object(creationContext, &info, impl.get());
     if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp (134488 => 134489)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp	2012-11-13 22:36:18 UTC (rev 134488)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp	2012-11-13 22:38:25 UTC (rev 134489)
@@ -343,22 +343,8 @@
 {
     ASSERT(impl.get());
     ASSERT(DOMDataStore::current(isolate)->get(impl.get()).IsEmpty());
-    v8::Handle<v8::Object> wrapper;
 
-    v8::Handle<v8::Context> context;
-    if (!creationContext.IsEmpty() && creationContext->CreationContext() != v8::Context::GetCurrent()) {
-        // For performance, we enter the context only if the currently running context
-        // is different from the context that we are about to enter.
-        context = v8::Local<v8::Context>::New(creationContext->CreationContext());
-        ASSERT(!context.IsEmpty());
-        context->Enter();
-    }
-
-    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
-
-    if (!context.IsEmpty())
-        context->Exit();
-
+    v8::Handle<v8::Object> wrapper = V8DOMWrapper::instantiateV8Object(creationContext, &info, impl.get());
     if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp (134488 => 134489)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp	2012-11-13 22:36:18 UTC (rev 134488)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp	2012-11-13 22:38:25 UTC (rev 134489)
@@ -113,22 +113,8 @@
 {
     ASSERT(impl.get());
     ASSERT(DOMDataStore::current(isolate)->get(impl.get()).IsEmpty());
-    v8::Handle<v8::Object> wrapper;
 
-    v8::Handle<v8::Context> context;
-    if (!creationContext.IsEmpty() && creationContext->CreationContext() != v8::Context::GetCurrent()) {
-        // For performance, we enter the context only if the currently running context
-        // is different from the context that we are about to enter.
-        context = v8::Local<v8::Context>::New(creationContext->CreationContext());
-        ASSERT(!context.IsEmpty());
-        context->Enter();
-    }
-
-    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
-
-    if (!context.IsEmpty())
-        context->Exit();
-
+    v8::Handle<v8::Object> wrapper = V8DOMWrapper::instantiateV8Object(creationContext, &info, impl.get());
     if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp (134488 => 134489)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp	2012-11-13 22:36:18 UTC (rev 134488)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp	2012-11-13 22:38:25 UTC (rev 134489)
@@ -153,22 +153,8 @@
 {
     ASSERT(impl.get());
     ASSERT(DOMDataStore::current(isolate)->get(impl.get()).IsEmpty());
-    v8::Handle<v8::Object> wrapper;
 
-    v8::Handle<v8::Context> context;
-    if (!creationContext.IsEmpty() && creationContext->CreationContext() != v8::Context::GetCurrent()) {
-        // For performance, we enter the context only if the currently running context
-        // is different from the context that we are about to enter.
-        context = v8::Local<v8::Context>::New(creationContext->CreationContext());
-        ASSERT(!context.IsEmpty());
-        context->Enter();
-    }
-
-    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
-
-    if (!context.IsEmpty())
-        context->Exit();
-
+    v8::Handle<v8::Object> wrapper = V8DOMWrapper::instantiateV8Object(creationContext, &info, impl.get());
     if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp (134488 => 134489)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp	2012-11-13 22:36:18 UTC (rev 134488)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp	2012-11-13 22:38:25 UTC (rev 134489)
@@ -112,23 +112,9 @@
 {
     ASSERT(impl.get());
     ASSERT(V8DOMWrapper::getCachedWrapper(impl.get()).IsEmpty());
-    v8::Handle<v8::Object> wrapper;
     ASSERT(static_cast<void*>(static_cast<Node*>(impl.get())) == static_cast<void*>(impl.get()));
 
-    v8::Handle<v8::Context> context;
-    if (!creationContext.IsEmpty() && creationContext->CreationContext() != v8::Context::GetCurrent()) {
-        // For performance, we enter the context only if the currently running context
-        // is different from the context that we are about to enter.
-        context = v8::Local<v8::Context>::New(creationContext->CreationContext());
-        ASSERT(!context.IsEmpty());
-        context->Enter();
-    }
-
-    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
-
-    if (!context.IsEmpty())
-        context->Exit();
-
+    v8::Handle<v8::Object> wrapper = V8DOMWrapper::instantiateV8Object(creationContext, &info, impl.get());
     if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp (134488 => 134489)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-11-13 22:36:18 UTC (rev 134488)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-11-13 22:38:25 UTC (rev 134489)
@@ -2356,22 +2356,8 @@
 {
     ASSERT(impl.get());
     ASSERT(DOMDataStore::current(isolate)->get(impl.get()).IsEmpty());
-    v8::Handle<v8::Object> wrapper;
 
-    v8::Handle<v8::Context> context;
-    if (!creationContext.IsEmpty() && creationContext->CreationContext() != v8::Context::GetCurrent()) {
-        // For performance, we enter the context only if the currently running context
-        // is different from the context that we are about to enter.
-        context = v8::Local<v8::Context>::New(creationContext->CreationContext());
-        ASSERT(!context.IsEmpty());
-        context->Enter();
-    }
-
-    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
-
-    if (!context.IsEmpty())
-        context->Exit();
-
+    v8::Handle<v8::Object> wrapper = V8DOMWrapper::instantiateV8Object(creationContext, &info, impl.get());
     if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestOverloadedConstructors.cpp (134488 => 134489)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestOverloadedConstructors.cpp	2012-11-13 22:36:18 UTC (rev 134488)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestOverloadedConstructors.cpp	2012-11-13 22:38:25 UTC (rev 134489)
@@ -177,22 +177,8 @@
 {
     ASSERT(impl.get());
     ASSERT(DOMDataStore::current(isolate)->get(impl.get()).IsEmpty());
-    v8::Handle<v8::Object> wrapper;
 
-    v8::Handle<v8::Context> context;
-    if (!creationContext.IsEmpty() && creationContext->CreationContext() != v8::Context::GetCurrent()) {
-        // For performance, we enter the context only if the currently running context
-        // is different from the context that we are about to enter.
-        context = v8::Local<v8::Context>::New(creationContext->CreationContext());
-        ASSERT(!context.IsEmpty());
-        context->Enter();
-    }
-
-    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
-
-    if (!context.IsEmpty())
-        context->Exit();
-
+    v8::Handle<v8::Object> wrapper = V8DOMWrapper::instantiateV8Object(creationContext, &info, impl.get());
     if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp (134488 => 134489)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp	2012-11-13 22:36:18 UTC (rev 134488)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp	2012-11-13 22:38:25 UTC (rev 134489)
@@ -296,22 +296,8 @@
 {
     ASSERT(impl.get());
     ASSERT(DOMDataStore::current(isolate)->get(impl.get()).IsEmpty());
-    v8::Handle<v8::Object> wrapper;
 
-    v8::Handle<v8::Context> context;
-    if (!creationContext.IsEmpty() && creationContext->CreationContext() != v8::Context::GetCurrent()) {
-        // For performance, we enter the context only if the currently running context
-        // is different from the context that we are about to enter.
-        context = v8::Local<v8::Context>::New(creationContext->CreationContext());
-        ASSERT(!context.IsEmpty());
-        context->Enter();
-    }
-
-    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
-
-    if (!context.IsEmpty())
-        context->Exit();
-
+    v8::Handle<v8::Object> wrapper = V8DOMWrapper::instantiateV8Object(creationContext, &info, impl.get());
     if (UNLIKELY(wrapper.IsEmpty()))
         return wrapper;
 

Modified: trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp (134488 => 134489)


--- trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp	2012-11-13 22:36:18 UTC (rev 134488)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp	2012-11-13 22:38:25 UTC (rev 134489)
@@ -68,6 +68,38 @@
 
 namespace WebCore {
 
+class V8WrapperInstantiationScope {
+public:
+    explicit V8WrapperInstantiationScope(v8::Handle<v8::Object> creationContext)
+        : m_didEnterContext(false)
+        , m_context(v8::Context::GetCurrent())
+    {
+        if (creationContext.IsEmpty())
+            return;
+        v8::Handle<v8::Context> contextForWrapper = creationContext->CreationContext();
+        // For performance, we enter the context only if the currently running context
+        // is different from the context that we are about to enter.
+        if (contextForWrapper == m_context)
+            return;
+        m_context = v8::Local<v8::Context>::New(contextForWrapper);
+        m_didEnterContext = true;
+        m_context->Enter();
+    }
+
+    ~V8WrapperInstantiationScope()
+    {
+        if (!m_didEnterContext)
+            return;
+        m_context->Exit();
+    }
+
+    v8::Handle<v8::Context> context() const { return m_context; }
+
+private:
+    bool m_didEnterContext;
+    v8::Handle<v8::Context> m_context;
+};
+
 void V8DOMWrapper::setNamedHiddenReference(v8::Handle<v8::Object> parent, const char* name, v8::Handle<v8::Value> child)
 {
     ASSERT(name);
@@ -93,9 +125,11 @@
     return NodeFilter::create(V8NodeFilterCondition::create(filter));
 }
 
-v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(WrapperTypeInfo* type, void* impl)
+v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(v8::Handle<v8::Object> creationContext, WrapperTypeInfo* type, void* impl)
 {
-    V8PerContextData* perContextData = V8PerContextData::from(v8::Context::GetCurrent());
+    V8WrapperInstantiationScope scope(creationContext);
+
+    V8PerContextData* perContextData = V8PerContextData::from(scope.context());
     v8::Local<v8::Object> instance = perContextData ? perContextData->createWrapperFromCache(type) : V8ObjectConstructor::newInstance(type->getTemplate()->GetFunction());
 
     // Avoid setting the DOM wrapper for failed allocations.

Modified: trunk/Source/WebCore/bindings/v8/V8DOMWrapper.h (134488 => 134489)


--- trunk/Source/WebCore/bindings/v8/V8DOMWrapper.h	2012-11-13 22:36:18 UTC (rev 134488)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWrapper.h	2012-11-13 22:38:25 UTC (rev 134489)
@@ -110,7 +110,7 @@
 
         static void setNamedHiddenReference(v8::Handle<v8::Object> parent, const char* name, v8::Handle<v8::Value> child);
 
-        static v8::Local<v8::Object> instantiateV8Object(WrapperTypeInfo*, void*);
+        static v8::Local<v8::Object> instantiateV8Object(v8::Handle<v8::Object> creationContext, WrapperTypeInfo*, void*);
 
         static v8::Handle<v8::Object> getCachedWrapper(Node* node)
         {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to