Title: [125475] trunk/Source/WebCore
Revision
125475
Author
[email protected]
Date
2012-08-13 17:36:04 -0700 (Mon, 13 Aug 2012)

Log Message

[V8] Remove evaluateInIsolatedWorld() from V8Proxy
https://bugs.webkit.org/show_bug.cgi?id=93679

Reviewed by Adam Barth.

To remove V8Proxy, this patch moves V8Proxy::evaluateInIsolatedWorld()
to ScriptController.

No tests. No change in behavior.

* bindings/v8/ScriptController.cpp:
(WebCore::ScriptController::evaluateInIsolatedWorld):
* bindings/v8/V8Proxy.cpp:
(WebCore::V8Proxy::precompileScript):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (125474 => 125475)


--- trunk/Source/WebCore/ChangeLog	2012-08-14 00:33:47 UTC (rev 125474)
+++ trunk/Source/WebCore/ChangeLog	2012-08-14 00:36:04 UTC (rev 125475)
@@ -1,3 +1,20 @@
+2012-08-09  Kentaro Hara  <[email protected]>
+
+        [V8] Remove evaluateInIsolatedWorld() from V8Proxy
+        https://bugs.webkit.org/show_bug.cgi?id=93679
+
+        Reviewed by Adam Barth.
+
+        To remove V8Proxy, this patch moves V8Proxy::evaluateInIsolatedWorld()
+        to ScriptController.
+
+        No tests. No change in behavior.
+
+        * bindings/v8/ScriptController.cpp:
+        (WebCore::ScriptController::evaluateInIsolatedWorld):
+        * bindings/v8/V8Proxy.cpp:
+        (WebCore::V8Proxy::precompileScript):
+
 2012-08-13  Bear Travis  <[email protected]>
 
         [CSS Exclusions] Remove unused CSSWrapShapes header includes

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.cpp (125474 => 125475)


--- trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-08-14 00:33:47 UTC (rev 125474)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-08-14 00:36:04 UTC (rev 125475)
@@ -172,7 +172,58 @@
 void ScriptController::evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup, Vector<ScriptValue>* results)
 {
     v8::HandleScope handleScope;
-    v8::Local<v8::Array> v8Results = m_proxy->evaluateInIsolatedWorld(worldID, sources, extensionGroup);
+
+    // FIXME: This will need to get reorganized once we have a windowShell for the isolated world.
+    if (!windowShell()->initContextIfNeeded())
+        return;
+
+    v8::Local<v8::Array> v8Results;
+    {
+        v8::HandleScope evaluateHandleScope;
+        V8IsolatedContext* isolatedContext = 0;
+        if (worldID > 0) {
+            IsolatedWorldMap::iterator iter = m_proxy->isolatedWorlds().find(worldID);
+            if (iter != m_proxy->isolatedWorlds().end())
+                isolatedContext = iter->second;
+            else {
+                isolatedContext = new V8IsolatedContext(proxy(), extensionGroup, worldID);
+                if (isolatedContext->context().IsEmpty()) {
+                    delete isolatedContext;
+                    return;
+                }
+
+                // FIXME: We should change this to using window shells to match JSC.
+                m_proxy->isolatedWorlds().set(worldID, isolatedContext);
+            }
+
+            IsolatedWorldSecurityOriginMap::iterator securityOriginIter = m_proxy->isolatedWorldSecurityOrigins().find(worldID);
+            if (securityOriginIter != m_proxy->isolatedWorldSecurityOrigins().end())
+                isolatedContext->setSecurityOrigin(securityOriginIter->second);
+        } else {
+            isolatedContext = new V8IsolatedContext(proxy(), extensionGroup, worldID);
+            if (isolatedContext->context().IsEmpty()) {
+                delete isolatedContext;
+                return;
+            }
+        }
+
+        v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolatedContext->context());
+        v8::Context::Scope contextScope(context);
+        v8::Local<v8::Array> resultArray = v8::Array::New(sources.size());
+
+        for (size_t i = 0; i < sources.size(); ++i) {
+            v8::Local<v8::Value> evaluationResult = m_proxy->evaluate(sources[i], 0);
+            if (evaluationResult.IsEmpty())
+                evaluationResult = v8::Local<v8::Value>::New(v8::Undefined());
+            resultArray->Set(i, evaluationResult);
+        }
+
+        if (!worldID)
+            isolatedContext->destroy();
+
+        v8Results = evaluateHandleScope.Close(resultArray);
+    }
+
     if (results && !v8Results.IsEmpty()) {
         for (size_t i = 0; i < v8Results->Length(); ++i)
             results->append(ScriptValue(v8Results->Get(i)));

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.h (125474 => 125475)


--- trunk/Source/WebCore/bindings/v8/ScriptController.h	2012-08-14 00:33:47 UTC (rev 125474)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.h	2012-08-14 00:36:04 UTC (rev 125475)
@@ -82,6 +82,10 @@
     // as a string.
     ScriptValue evaluate(const ScriptSourceCode&);
 
+    // Evaluate _javascript_ in a new isolated world. The script gets its own
+    // global scope, its own prototypes for intrinsic _javascript_ objects (String,
+    // Array, and so-on), and its own wrappers for all DOM nodes and DOM
+    // constructors.
     void evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>& sources, Vector<ScriptValue>* results);
 
     // Executes _javascript_ in an isolated world. The script gets its own global scope,

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.cpp (125474 => 125475)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-08-14 00:33:47 UTC (rev 125474)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-08-14 00:36:04 UTC (rev 125475)
@@ -166,58 +166,6 @@
     return true;
 }
 
-v8::Local<v8::Array> V8Proxy::evaluateInIsolatedWorld(int worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup)
-{
-    // FIXME: This will need to get reorganized once we have a windowShell for the isolated world.
-    if (!windowShell()->initContextIfNeeded())
-        return v8::Local<v8::Array>();
-
-    v8::HandleScope handleScope;
-    V8IsolatedContext* isolatedContext = 0;
-
-    if (worldID > 0) {
-        IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(worldID);
-        if (iter != m_isolatedWorlds.end()) {
-            isolatedContext = iter->second;
-        } else {
-            isolatedContext = new V8IsolatedContext(this, extensionGroup, worldID);
-            if (isolatedContext->context().IsEmpty()) {
-                delete isolatedContext;
-                return v8::Local<v8::Array>();
-            }
-
-            // FIXME: We should change this to using window shells to match JSC.
-            m_isolatedWorlds.set(worldID, isolatedContext);
-        }
-
-        IsolatedWorldSecurityOriginMap::iterator securityOriginIter = m_isolatedWorldSecurityOrigins.find(worldID);
-        if (securityOriginIter != m_isolatedWorldSecurityOrigins.end())
-            isolatedContext->setSecurityOrigin(securityOriginIter->second);
-    } else {
-        isolatedContext = new V8IsolatedContext(this, extensionGroup, worldID);
-        if (isolatedContext->context().IsEmpty()) {
-            delete isolatedContext;
-            return v8::Local<v8::Array>();
-        }
-    }
-
-    v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolatedContext->context());
-    v8::Context::Scope context_scope(context);
-    v8::Local<v8::Array> results = v8::Array::New(sources.size());
-
-    for (size_t i = 0; i < sources.size(); ++i) {
-        v8::Local<v8::Value> evaluationResult = evaluate(sources[i], 0);
-        if (evaluationResult.IsEmpty())
-            evaluationResult = v8::Local<v8::Value>::New(v8::Undefined());
-        results->Set(i, evaluationResult);
-    }
-
-    if (worldID == 0)
-        isolatedContext->destroy();
-
-    return handleScope.Close(results);
-}
-
 PassOwnPtr<v8::ScriptData> V8Proxy::precompileScript(v8::Handle<v8::String> code, CachedScript* cachedScript)
 {
     // A pseudo-randomly chosen ID used to store and retrieve V8 ScriptData from

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.h (125474 => 125475)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-08-14 00:33:47 UTC (rev 125474)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-08-14 00:36:04 UTC (rev 125475)
@@ -104,12 +104,6 @@
 
         void finishedWithEvent(Event*) { }
 
-        // Evaluate _javascript_ in a new isolated world. The script gets its own
-        // global scope, its own prototypes for intrinsic _javascript_ objects (String,
-        // Array, and so-on), and its own wrappers for all DOM nodes and DOM
-        // constructors.
-        v8::Local<v8::Array> evaluateInIsolatedWorld(int worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup);
-
         // Evaluate a script file in the current execution environment.
         // The caller must hold an execution context.
         // If cannot evalute the script, it returns an error.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to