Title: [120229] trunk/Source/WebCore
Revision
120229
Author
[email protected]
Date
2012-06-13 11:45:43 -0700 (Wed, 13 Jun 2012)

Log Message

Removing an extra HandleScope in V8Proxy::evaluateInIsolatedWorld
https://bugs.webkit.org/show_bug.cgi?id=88451

Patch by Eriq Augustine <[email protected]> on 2012-06-13
Reviewed by Adam Barth.

Any values retuned by the evaluation will get destroyed with the extra
HandleScope.

I was unable to cause a test failure, however this feature is tested by:
platform/chromium/http/tests/misc/execute-and-return-value.html

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (120228 => 120229)


--- trunk/Source/WebCore/ChangeLog	2012-06-13 18:21:58 UTC (rev 120228)
+++ trunk/Source/WebCore/ChangeLog	2012-06-13 18:45:43 UTC (rev 120229)
@@ -1,3 +1,19 @@
+2012-06-13  Eriq Augustine  <[email protected]>
+
+        Removing an extra HandleScope in V8Proxy::evaluateInIsolatedWorld
+        https://bugs.webkit.org/show_bug.cgi?id=88451
+
+        Reviewed by Adam Barth.
+
+        Any values retuned by the evaluation will get destroyed with the extra
+        HandleScope.
+
+        I was unable to cause a test failure, however this feature is tested by:
+        platform/chromium/http/tests/misc/execute-and-return-value.html
+
+        * bindings/v8/V8Proxy.cpp:
+        (WebCore::V8Proxy::evaluateInIsolatedWorld):
+
 2012-06-13  Zan Dobersek  <[email protected]>
 
         [Gtk] Enable link prefetch support in the developer builds

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.cpp (120228 => 120229)


--- trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-06-13 18:21:58 UTC (rev 120228)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-06-13 18:45:43 UTC (rev 120229)
@@ -177,14 +177,11 @@
 void ScriptController::evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup, Vector<ScriptValue>* results)
 {
     v8::HandleScope handleScope;
-    if (results) {
-        Vector<v8::Local<v8::Value> > v8Results;
-        m_proxy->evaluateInIsolatedWorld(worldID, sources, extensionGroup, &v8Results);
-        Vector<v8::Local<v8::Value> >::iterator itr;
-        for (itr = v8Results.begin(); itr != v8Results.end(); ++itr)
-            results->append(ScriptValue(*itr));
-    } else
-        m_proxy->evaluateInIsolatedWorld(worldID, sources, extensionGroup, 0);
+    v8::Local<v8::Array> v8Results = m_proxy->evaluateInIsolatedWorld(worldID, sources, extensionGroup);
+    if (results && !v8Results.IsEmpty()) {
+        for (size_t i = 0; i < v8Results->Length(); ++i)
+            results->append(ScriptValue(v8Results->Get(i)));
+    }
 }
 
 void ScriptController::setIsolatedWorldSecurityOrigin(int worldID, PassRefPtr<SecurityOrigin> securityOrigin)

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.cpp (120228 => 120229)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-06-13 18:21:58 UTC (rev 120228)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-06-13 18:45:43 UTC (rev 120229)
@@ -218,11 +218,11 @@
     return true;
 }
 
-void V8Proxy::evaluateInIsolatedWorld(int worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup, WTF::Vector<v8::Local<v8::Value> >* results)
+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;
+        return v8::Local<v8::Array>();
 
     v8::HandleScope handleScope;
     V8IsolatedContext* isolatedContext = 0;
@@ -235,7 +235,7 @@
             isolatedContext = new V8IsolatedContext(this, extensionGroup, worldID);
             if (isolatedContext->context().IsEmpty()) {
                 delete isolatedContext;
-                return;
+                return v8::Local<v8::Array>();
             }
 
             // FIXME: We should change this to using window shells to match JSC.
@@ -249,23 +249,25 @@
         isolatedContext = new V8IsolatedContext(this, extensionGroup, worldID);
         if (isolatedContext->context().IsEmpty()) {
             delete isolatedContext;
-            return;
+            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());
 
-    if (results) {
-        for (size_t i = 0; i < sources.size(); ++i)
-            results->append(evaluate(sources[i], 0));
-    } else {
-        for (size_t i = 0; i < sources.size(); ++i)
-            evaluate(sources[i], 0);
+    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);
 }
 
 void V8Proxy::setIsolatedWorldSecurityOrigin(int worldID, PassRefPtr<SecurityOrigin> prpSecurityOriginIn)

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.h (120228 => 120229)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-06-13 18:21:58 UTC (rev 120228)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-06-13 18:45:43 UTC (rev 120229)
@@ -148,7 +148,7 @@
         // 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(int worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup, WTF::Vector<v8::Local<v8::Value> >* result);
+        v8::Local<v8::Array> evaluateInIsolatedWorld(int worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup);
 
         void setIsolatedWorldSecurityOrigin(int worldID, PassRefPtr<SecurityOrigin>);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to