Title: [125998] trunk/Source/WebCore
Revision
125998
Author
[email protected]
Date
2012-08-19 22:18:56 -0700 (Sun, 19 Aug 2012)

Log Message

[V8] Move V8Proxy::callFunction() to ScriptController
https://bugs.webkit.org/show_bug.cgi?id=94437

Reviewed by Adam Barth.

To kill V8Proxy, this patch moves callFunction() from V8Proxy to ScriptController.

No tests. No change in behavior.

* bindings/v8/DOMTransaction.cpp:
(WebCore::DOMTransaction::callFunction):
* bindings/v8/NPV8Object.cpp:
(_NPN_Invoke):
(_NPN_InvokeDefault):
* bindings/v8/ScheduledAction.cpp:
(WebCore::ScheduledAction::execute):
* bindings/v8/ScheduledAction.h:
(WebCore):
(ScheduledAction):
* bindings/v8/ScriptController.cpp:
(WebCore::ScriptController::callFunction):
(WebCore):
(WebCore::ScriptController::callFunctionEvenIfScriptDisabled):
* bindings/v8/ScriptController.h:
(ScriptController):
* bindings/v8/V8EventListener.cpp:
(WebCore::V8EventListener::callListenerFunction):
* bindings/v8/V8LazyEventListener.cpp:
(WebCore::V8LazyEventListener::callListenerFunction):
* bindings/v8/V8Proxy.cpp:
* bindings/v8/V8Proxy.h:
(V8Proxy):
* bindings/v8/custom/V8HTMLDocumentCustom.cpp:
(WebCore::V8HTMLDocument::openCallback):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (125997 => 125998)


--- trunk/Source/WebCore/ChangeLog	2012-08-20 05:11:05 UTC (rev 125997)
+++ trunk/Source/WebCore/ChangeLog	2012-08-20 05:18:56 UTC (rev 125998)
@@ -1,3 +1,40 @@
+2012-08-19  Kentaro Hara  <[email protected]>
+
+        [V8] Move V8Proxy::callFunction() to ScriptController
+        https://bugs.webkit.org/show_bug.cgi?id=94437
+
+        Reviewed by Adam Barth.
+
+        To kill V8Proxy, this patch moves callFunction() from V8Proxy to ScriptController.
+
+        No tests. No change in behavior.
+
+        * bindings/v8/DOMTransaction.cpp:
+        (WebCore::DOMTransaction::callFunction):
+        * bindings/v8/NPV8Object.cpp:
+        (_NPN_Invoke):
+        (_NPN_InvokeDefault):
+        * bindings/v8/ScheduledAction.cpp:
+        (WebCore::ScheduledAction::execute):
+        * bindings/v8/ScheduledAction.h:
+        (WebCore):
+        (ScheduledAction):
+        * bindings/v8/ScriptController.cpp:
+        (WebCore::ScriptController::callFunction):
+        (WebCore):
+        (WebCore::ScriptController::callFunctionEvenIfScriptDisabled):
+        * bindings/v8/ScriptController.h:
+        (ScriptController):
+        * bindings/v8/V8EventListener.cpp:
+        (WebCore::V8EventListener::callListenerFunction):
+        * bindings/v8/V8LazyEventListener.cpp:
+        (WebCore::V8LazyEventListener::callListenerFunction):
+        * bindings/v8/V8Proxy.cpp:
+        * bindings/v8/V8Proxy.h:
+        (V8Proxy):
+        * bindings/v8/custom/V8HTMLDocumentCustom.cpp:
+        (WebCore::V8HTMLDocument::openCallback):
+
 2012-08-19  Yoshifumi Inoue  <[email protected]>
 
         [Forms] Set SpinButtonElement free from HTMLInputElement

Modified: trunk/Source/WebCore/bindings/v8/DOMTransaction.cpp (125997 => 125998)


--- trunk/Source/WebCore/bindings/v8/DOMTransaction.cpp	2012-08-20 05:11:05 UTC (rev 125997)
+++ trunk/Source/WebCore/bindings/v8/DOMTransaction.cpp	2012-08-20 05:18:56 UTC (rev 125998)
@@ -113,7 +113,7 @@
     if (receiver.IsEmpty())
         return;
     v8::Handle<v8::Value> parameters[0] = { };
-    frame->script()->proxy()->callFunction(function, receiver, 0, parameters);
+    frame->script()->callFunction(function, receiver, 0, parameters);
 }
 
 }

Modified: trunk/Source/WebCore/bindings/v8/NPV8Object.cpp (125997 => 125998)


--- trunk/Source/WebCore/bindings/v8/NPV8Object.cpp	2012-08-20 05:11:05 UTC (rev 125997)
+++ trunk/Source/WebCore/bindings/v8/NPV8Object.cpp	2012-08-20 05:18:56 UTC (rev 125998)
@@ -244,13 +244,13 @@
         return false;
     }
 
-    V8Proxy* proxy = toV8Proxy(npObject);
-    ASSERT(proxy);
+    Frame* frame = v8NpObject->rootObject->frame();
+    ASSERT(frame);
 
     // Call the function object.
     v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(functionObject);
     OwnArrayPtr<v8::Handle<v8::Value> > argv = createValueListFromVariantArgs(arguments, argumentCount, npObject);
-    v8::Local<v8::Value> resultObject = proxy->callFunction(function, v8NpObject->v8Object, argumentCount, argv.get());
+    v8::Local<v8::Value> resultObject = frame->script()->callFunction(function, v8NpObject->v8Object, argumentCount, argv.get());
 
     // If we had an error, return false.  The spec is a little unclear here, but says "Returns true if the method was
     // successfully invoked".  If we get an error return value, was that successfully invoked?
@@ -295,11 +295,11 @@
     v8::Local<v8::Value> resultObject;
     v8::Handle<v8::Function> function(v8::Function::Cast(*functionObject));
     if (!function->IsNull()) {
-        V8Proxy* proxy = toV8Proxy(npObject);
-        ASSERT(proxy);
+        Frame* frame = v8NpObject->rootObject->frame();
+        ASSERT(frame);
 
         OwnArrayPtr<v8::Handle<v8::Value> > argv = createValueListFromVariantArgs(arguments, argumentCount, npObject);
-        resultObject = proxy->callFunction(function, functionObject, argumentCount, argv.get());
+        resultObject = frame->script()->callFunction(function, functionObject, argumentCount, argv.get());
     }
     // If we had an error, return false.  The spec is a little unclear here, but says "Returns true if the method was
     // successfully invoked".  If we get an error return value, was that successfully invoked?

Modified: trunk/Source/WebCore/bindings/v8/ScheduledAction.cpp (125997 => 125998)


--- trunk/Source/WebCore/bindings/v8/ScheduledAction.cpp	2012-08-20 05:11:05 UTC (rev 125997)
+++ trunk/Source/WebCore/bindings/v8/ScheduledAction.cpp	2012-08-20 05:18:56 UTC (rev 125998)
@@ -40,6 +40,7 @@
 #include "TraceEvent.h"
 #endif
 
+#include "ScriptController.h"
 #include "V8Binding.h"
 #include "V8Proxy.h"
 #include "V8RecursionScope.h"
@@ -102,7 +103,7 @@
             return;
         if (!frame->script()->canExecuteScripts(AboutToExecuteScript))
             return;
-        execute(frame->script()->proxy());
+        execute(frame->script());
     }
 #if ENABLE(WORKERS)
     else {
@@ -112,9 +113,9 @@
 #endif
 }
 
-void ScheduledAction::execute(V8Proxy* proxy)
+void ScheduledAction::execute(ScriptController* script)
 {
-    ASSERT(proxy);
+    ASSERT(script->proxy());
 
     v8::HandleScope handleScope;
     v8::Handle<v8::Context> v8Context = v8::Local<v8::Context>::New(m_context.get());
@@ -129,9 +130,9 @@
 
     // FIXME: Need to implement timeouts for preempting a long-running script.
     if (!m_function.IsEmpty() && m_function->IsFunction())
-        proxy->callFunction(v8::Persistent<v8::Function>::Cast(m_function), v8Context->Global(), m_argc, m_argv);
+        script->callFunction(v8::Persistent<v8::Function>::Cast(m_function), v8Context->Global(), m_argc, m_argv);
     else
-        proxy->evaluate(m_code, 0);
+        script->proxy()->evaluate(m_code, 0);
 
     // The 'proxy' may be invalid at this point since JS could have released the owning Frame.
 }

Modified: trunk/Source/WebCore/bindings/v8/ScheduledAction.h (125997 => 125998)


--- trunk/Source/WebCore/bindings/v8/ScheduledAction.h	2012-08-20 05:11:05 UTC (rev 125997)
+++ trunk/Source/WebCore/bindings/v8/ScheduledAction.h	2012-08-20 05:18:56 UTC (rev 125998)
@@ -40,8 +40,8 @@
 
 namespace WebCore {
 
+    class ScriptController;
     class ScriptExecutionContext;
-    class V8Proxy;
     class WorkerContext;
 
     class ScheduledAction {
@@ -59,7 +59,7 @@
         virtual void execute(ScriptExecutionContext*);
 
     private:
-        void execute(V8Proxy*);
+        void execute(ScriptController*);
 #if ENABLE(WORKERS)
         void execute(WorkerContext*);
 #endif

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.cpp (125997 => 125998)


--- trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-08-20 05:11:05 UTC (rev 125997)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-08-20 05:18:56 UTC (rev 125998)
@@ -159,10 +159,17 @@
     return UserGestureIndicator::processingUserGesture();
 }
 
+v8::Local<v8::Value> ScriptController::callFunction(v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[])
+{
+    // Keep Frame (and therefore ScriptController and V8Proxy) alive.
+    RefPtr<Frame> protect(m_frame);
+    return V8Proxy::instrumentedCallFunction(m_frame, function, receiver, argc, args);
+}
+
 ScriptValue ScriptController::callFunctionEvenIfScriptDisabled(v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> argv[])
 {
     // FIXME: This should probably perform the same isPaused check that happens in ScriptController::executeScript.
-    return ScriptValue(m_proxy->callFunction(function, receiver, argc, argv));
+    return ScriptValue(callFunction(function, receiver, argc, argv));
 }
 
 void ScriptController::evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>& sources, Vector<ScriptValue>* results)

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.h (125997 => 125998)


--- trunk/Source/WebCore/bindings/v8/ScriptController.h	2012-08-20 05:11:05 UTC (rev 125997)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.h	2012-08-20 05:18:56 UTC (rev 125998)
@@ -71,6 +71,10 @@
 
     ScriptValue executeScript(const ScriptSourceCode&);
     ScriptValue executeScript(const String& script, bool forceUserGesture = false);
+
+    // Call the function with the given receiver and arguments.
+    v8::Local<v8::Value> callFunction(v8::Handle<v8::Function>, v8::Handle<v8::Object>, int argc, v8::Handle<v8::Value> argv[]);
+
     ScriptValue callFunctionEvenIfScriptDisabled(v8::Handle<v8::Function>, v8::Handle<v8::Object>, int argc, v8::Handle<v8::Value> argv[]);
 
     // Returns true if argument is a _javascript_ URL.

Modified: trunk/Source/WebCore/bindings/v8/V8EventListener.cpp (125997 => 125998)


--- trunk/Source/WebCore/bindings/v8/V8EventListener.cpp	2012-08-20 05:11:05 UTC (rev 125997)
+++ trunk/Source/WebCore/bindings/v8/V8EventListener.cpp	2012-08-20 05:18:56 UTC (rev 125998)
@@ -93,7 +93,7 @@
     if (!frame->script()->canExecuteScripts(AboutToExecuteScript))
         return v8::Local<v8::Value>();
 
-    return frame->script()->proxy()->callFunction(handlerFunction, receiver, 1, parameters);
+    return frame->script()->callFunction(handlerFunction, receiver, 1, parameters);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp (125997 => 125998)


--- trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp	2012-08-20 05:11:05 UTC (rev 125997)
+++ trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp	2012-08-20 05:18:56 UTC (rev 125998)
@@ -100,7 +100,7 @@
     if (!frame->script()->canExecuteScripts(AboutToExecuteScript))
         return v8::Local<v8::Value>();
 
-    return frame->script()->proxy()->callFunction(handlerFunction, receiver, 1, parameters);
+    return frame->script()->callFunction(handlerFunction, receiver, 1, parameters);
 }
 
 static v8::Handle<v8::Value> V8LazyEventListenerToString(const v8::Arguments& args)

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.cpp (125997 => 125998)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-08-20 05:11:05 UTC (rev 125997)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-08-20 05:18:56 UTC (rev 125998)
@@ -268,13 +268,6 @@
     return result;
 }
 
-v8::Local<v8::Value> V8Proxy::callFunction(v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[])
-{
-    // Keep Frame (and therefore ScriptController and V8Proxy) alive.
-    RefPtr<Frame> protect(frame());
-    return V8Proxy::instrumentedCallFunction(frame(), function, receiver, argc, args);
-}
-
 static inline void resourceInfo(const v8::Handle<v8::Function> function, String& resourceName, int& lineNumber)
 {
     v8::ScriptOrigin origin = function->GetScriptOrigin();

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.h (125997 => 125998)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-08-20 05:11:05 UTC (rev 125997)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-08-20 05:18:56 UTC (rev 125998)
@@ -103,9 +103,6 @@
         // Run an already compiled script.
         v8::Local<v8::Value> runScript(v8::Handle<v8::Script>);
 
-        // Call the function with the given receiver and arguments.
-        v8::Local<v8::Value> callFunction(v8::Handle<v8::Function>, v8::Handle<v8::Object>, int argc, v8::Handle<v8::Value> argv[]);
-
         // call the function with the given receiver and arguments and report times to DevTools.
         static v8::Local<v8::Value> instrumentedCallFunction(Frame*, v8::Handle<v8::Function>, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[]);
 

Modified: trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp (125997 => 125998)


--- trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp	2012-08-20 05:11:05 UTC (rev 125997)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp	2012-08-20 05:18:56 UTC (rev 125998)
@@ -157,7 +157,7 @@
             for (int i = 0; i < args.Length(); i++)
                 params[i] = args[i];
 
-            return frame->script()->proxy()->callFunction(v8::Local<v8::Function>::Cast(function), global, args.Length(), params.get());
+            return frame->script()->callFunction(v8::Local<v8::Function>::Cast(function), global, args.Length(), params.get());
         }
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to