[Release] Webkit-EFL Ver. 2.0_beta_118996_0.6.24
[framework/web/webkit-efl.git] / Source / WebCore / bindings / js / ScriptCallStackFactory.cpp
old mode 100755 (executable)
new mode 100644 (file)
index a266449..ccf673f
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "ScriptCallStackFactory.h"
 
+#include "InspectorInstrumentation.h"
 #include "JSDOMBinding.h"
 #include "ScriptArguments.h"
 #include "ScriptCallFrame.h"
@@ -48,6 +49,8 @@ using namespace JSC;
 
 namespace WebCore {
 
+class ScriptExecutionContext;
+
 PassRefPtr<ScriptCallStack> createScriptCallStack(size_t, bool)
 {
     return 0;
@@ -67,7 +70,7 @@ PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t m
         exec->interpreter()->retrieveLastCaller(callFrame, signedLineNumber, sourceID, urlString, function);
         UString functionName;
         if (function)
-            functionName = asFunction(function)->name(exec);
+            functionName = jsCast<JSFunction*>(function)->name(exec);
         else {
             // Caller is unknown, but if frames is empty we should still add the frame, because
             // something called us, and gave us arguments.
@@ -83,6 +86,17 @@ PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t m
     return ScriptCallStack::create(frames);
 }
 
+PassRefPtr<ScriptCallStack> createScriptCallStackForInspector(JSC::ExecState* exec)
+{
+    size_t maxStackSize = 1;
+    if (InspectorInstrumentation::hasFrontends()) {
+        ScriptExecutionContext* scriptExecutionContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();
+        if (InspectorInstrumentation::hasFrontendForScriptContext(scriptExecutionContext))
+            maxStackSize = ScriptCallStack::maxCallStackSizeToCapture;
+    }
+    return createScriptCallStack(exec, maxStackSize);
+}
+
 PassRefPtr<ScriptArguments> createScriptArguments(JSC::ExecState* exec, unsigned skipArgumentCount)
 {
     Vector<ScriptValue> arguments;