Title: [128361] trunk/Source/WebCore
Revision
128361
Author
[email protected]
Date
2012-09-12 14:36:48 -0700 (Wed, 12 Sep 2012)

Log Message

[V8] V8DOMWrapper::constructorForType is unnecessary now that we can get V8PerContextData from the v8::Context
https://bugs.webkit.org/show_bug.cgi?id=96556

Patch by Adam Barth <[email protected]> on 2012-09-12
Reviewed by Eric Seidel.

These functions no longer serve a purpose now that we can get the
V8PerContextData directly from the context. Previously we had to find
the Frame in order to find the per-context data.

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateConstructorGetter):
* bindings/v8/V8DOMWindowShell.cpp:
(WebCore::V8DOMWindowShell::installDOMWindow):
* bindings/v8/V8DOMWrapper.cpp:
(WebCore::V8DOMWrapper::instantiateV8Object):
* bindings/v8/V8DOMWrapper.h:
(V8DOMWrapper):
* bindings/v8/V8PerContextData.cpp:
(WebCore::V8PerContextData::from):
* bindings/v8/V8PerContextData.h:
(V8PerContextData):
    - Changed this function to accept an arbitrary context rather than
      requiring the caller to use the current context.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (128360 => 128361)


--- trunk/Source/WebCore/ChangeLog	2012-09-12 21:33:54 UTC (rev 128360)
+++ trunk/Source/WebCore/ChangeLog	2012-09-12 21:36:48 UTC (rev 128361)
@@ -1,3 +1,29 @@
+2012-09-12  Adam Barth  <[email protected]>
+
+        [V8] V8DOMWrapper::constructorForType is unnecessary now that we can get V8PerContextData from the v8::Context
+        https://bugs.webkit.org/show_bug.cgi?id=96556
+
+        Reviewed by Eric Seidel.
+
+        These functions no longer serve a purpose now that we can get the
+        V8PerContextData directly from the context. Previously we had to find
+        the Frame in order to find the per-context data.
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateConstructorGetter):
+        * bindings/v8/V8DOMWindowShell.cpp:
+        (WebCore::V8DOMWindowShell::installDOMWindow):
+        * bindings/v8/V8DOMWrapper.cpp:
+        (WebCore::V8DOMWrapper::instantiateV8Object):
+        * bindings/v8/V8DOMWrapper.h:
+        (V8DOMWrapper):
+        * bindings/v8/V8PerContextData.cpp:
+        (WebCore::V8PerContextData::from):
+        * bindings/v8/V8PerContextData.h:
+        (V8PerContextData):
+            - Changed this function to accept an arbitrary context rather than
+              requiring the caller to use the current context.
+
 2012-09-12  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r128318 and r128332.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (128360 => 128361)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-09-12 21:33:54 UTC (rev 128360)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-09-12 21:36:48 UTC (rev 128361)
@@ -804,25 +804,10 @@
     INC_STATS(\"DOM.$implClassName.constructors._get\");
     v8::Handle<v8::Value> data = ""
     ASSERT(data->IsExternal() || data->IsNumber());
-    WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data);
-END
-
-    if ($implClassName eq "DOMWindow") {
-        push(@implContentDecls, <<END);
-    // Get the proxy corresponding to the DOMWindow if possible to
-    // make sure that the constructor function is constructed in the
-    // context of the DOMWindow and not in the context of the caller.
-    return V8DOMWrapper::constructorForType(type, V8DOMWindow::toNative(info.Holder()));
-END
-    } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) {
-        push(@implContentDecls, <<END);
-    return V8DOMWrapper::constructorForType(type, V8WorkerContext::toNative(info.Holder()));
-END
-    } else {
-        push(@implContentDecls, "    return v8Undefined();");
-    }
-
-    push(@implContentDecls, <<END);
+    V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext());
+    if (!perContextData)
+        return v8Undefined();
+    return perContextData->constructorForType(WrapperTypeInfo::unwrap(data));
 }
 
 END

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


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-09-12 21:33:54 UTC (rev 128360)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-09-12 21:36:48 UTC (rev 128361)
@@ -1039,8 +1039,11 @@
     INC_STATS("DOM.TestObj.constructors._get");
     v8::Handle<v8::Value> data = ""
     ASSERT(data->IsExternal() || data->IsNumber());
-    WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data);
-    return v8Undefined();}
+    V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext());
+    if (!perContextData)
+        return v8Undefined();
+    return perContextData->constructorForType(WrapperTypeInfo::unwrap(data));
+}
 
 static void TestObjReplaceableAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
 {

Modified: trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp (128360 => 128361)


--- trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp	2012-09-12 21:33:54 UTC (rev 128360)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp	2012-09-12 21:36:48 UTC (rev 128361)
@@ -435,7 +435,7 @@
 bool V8DOMWindowShell::installDOMWindow()
 {
     DOMWindow* window = m_frame->document()->domWindow();
-    v8::Local<v8::Object> windowWrapper = V8ObjectConstructor::newInstance(V8DOMWrapper::constructorForType(&V8DOMWindow::info, window));
+    v8::Local<v8::Object> windowWrapper = V8ObjectConstructor::newInstance(V8PerContextData::from(m_context.get())->constructorForType(&V8DOMWindow::info));
     if (windowWrapper.IsEmpty())
         return false;
 

Modified: trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp (128360 => 128361)


--- trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp	2012-09-12 21:33:54 UTC (rev 128360)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp	2012-09-12 21:36:48 UTC (rev 128361)
@@ -86,28 +86,7 @@
     return wrapperHandle;
 }
 
-v8::Local<v8::Function> V8DOMWrapper::constructorForType(WrapperTypeInfo* type, DOMWindow* window)
-{
-    Frame* frame = window->frame();
-    if (!frame)
-        return v8::Local<v8::Function>();
-
-    if (V8PerContextData* contextData = perContextDataForCurrentWorld(frame))
-        return contextData->constructorForType(type);
-
-    return v8::Local<v8::Function>();
-}
-
 #if ENABLE(WORKERS)
-v8::Local<v8::Function> V8DOMWrapper::constructorForType(WrapperTypeInfo* type, WorkerContext*)
-{
-    WorkerScriptController* controller = WorkerScriptController::controllerForContext();
-    WorkerContextExecutionProxy* proxy = controller ? controller->proxy() : 0;
-    return proxy ? proxy->perContextData()->constructorForType(type) : v8::Local<v8::Function>();
-}
-#endif
-
-#if ENABLE(WORKERS)
 V8PerContextData* V8DOMWrapper::perContextData(WorkerContext*)
 {
     WorkerScriptController* controller = WorkerScriptController::controllerForContext();
@@ -150,7 +129,7 @@
     if (document && document->frame())
         perContextData = perContextDataForCurrentWorld(document->frame());
     else
-        perContextData = V8PerContextData::current();
+        perContextData = V8PerContextData::from(v8::Context::GetCurrent());
 
     v8::Local<v8::Object> instance = perContextData ? perContextData->createWrapperFromCache(type) : V8ObjectConstructor::newInstance(type->getTemplate()->GetFunction());
 

Modified: trunk/Source/WebCore/bindings/v8/V8DOMWrapper.h (128360 => 128361)


--- trunk/Source/WebCore/bindings/v8/V8DOMWrapper.h	2012-09-12 21:33:54 UTC (rev 128360)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWrapper.h	2012-09-12 21:36:48 UTC (rev 128361)
@@ -93,11 +93,6 @@
         // Wrap JS node filter in C++.
         static PassRefPtr<NodeFilter> wrapNativeNodeFilter(v8::Handle<v8::Value>);
 
-        static v8::Local<v8::Function> constructorForType(WrapperTypeInfo*, DOMWindow*);
-#if ENABLE(WORKERS)
-        static v8::Local<v8::Function> constructorForType(WrapperTypeInfo*, WorkerContext*);
-#endif
-
         template<typename T>
         static v8::Persistent<v8::Object> setJSWrapperForDOMObject(PassRefPtr<T>, v8::Handle<v8::Object>, v8::Isolate* = 0);
         template<typename T>

Modified: trunk/Source/WebCore/bindings/v8/V8PerContextData.cpp (128360 => 128361)


--- trunk/Source/WebCore/bindings/v8/V8PerContextData.cpp	2012-09-12 21:33:54 UTC (rev 128360)
+++ trunk/Source/WebCore/bindings/v8/V8PerContextData.cpp	2012-09-12 21:36:48 UTC (rev 128361)
@@ -37,9 +37,9 @@
 
 namespace WebCore {
 
-V8PerContextData* V8PerContextData::current()
+V8PerContextData* V8PerContextData::from(v8::Handle<v8::Context> context)
 {
-    v8::Handle<v8::Value> wrappedPerContextData = toInnerGlobalObject(v8::Context::GetCurrent())->GetHiddenValue(V8HiddenPropertyName::perContextData());
+    v8::Handle<v8::Value> wrappedPerContextData = toInnerGlobalObject(context)->GetHiddenValue(V8HiddenPropertyName::perContextData());
     if (wrappedPerContextData.IsEmpty())
         return 0;
     return static_cast<V8PerContextData*>(v8::External::Unwrap(wrappedPerContextData));

Modified: trunk/Source/WebCore/bindings/v8/V8PerContextData.h (128360 => 128361)


--- trunk/Source/WebCore/bindings/v8/V8PerContextData.h	2012-09-12 21:33:54 UTC (rev 128360)
+++ trunk/Source/WebCore/bindings/v8/V8PerContextData.h	2012-09-12 21:36:48 UTC (rev 128361)
@@ -53,7 +53,7 @@
 
     bool init();
 
-    static V8PerContextData* current();
+    static V8PerContextData* from(v8::Handle<v8::Context>);
 
     // To create JS Wrapper objects, we create a cache of a 'boiler plate'
     // object, and then simply Clone that object each time we need a new one.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to