Diff
Modified: trunk/Source/WebCore/ChangeLog (101793 => 101794)
--- trunk/Source/WebCore/ChangeLog 2011-12-02 15:17:50 UTC (rev 101793)
+++ trunk/Source/WebCore/ChangeLog 2011-12-02 15:24:04 UTC (rev 101794)
@@ -1,3 +1,33 @@
+2011-12-01 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Extract default call stack creation and check for front-end from console.
+ https://bugs.webkit.org/show_bug.cgi?id=73566
+
+ Reviewed by Yury Semikhatsky.
+
+ * bindings/js/ScriptCallStackFactory.cpp:
+ (WebCore::createScriptCallStack):
+ * bindings/js/ScriptCallStackFactory.h:
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateParametersCheck):
+ * bindings/scripts/CodeGeneratorV8.pm:
+ (GenerateFunctionCallback):
+ * bindings/scripts/test/JS/JSTestObj.cpp:
+ (WebCore::jsTestObjPrototypeFunctionCustomArgsAndException):
+ * bindings/scripts/test/V8/V8TestObj.cpp:
+ (WebCore::TestObjInternal::customArgsAndExceptionCallback):
+ * bindings/v8/ScriptCallStackFactory.cpp:
+ (WebCore::createScriptCallStack):
+ * bindings/v8/ScriptCallStackFactory.h:
+ * inspector/InspectorInstrumentation.cpp:
+ (WebCore::InspectorInstrumentation::hasFrontendForScriptContext):
+ * inspector/InspectorInstrumentation.h:
+ (WebCore::InspectorInstrumentation::hasFrontendForScriptContext):
+ * inspector/WorkerInspectorController.h:
+ (WebCore::WorkerInspectorController::hasFrontend):
+ * page/Console.cpp:
+ * page/Console.h:
+
2011-12-02 Gavin Peters <[email protected]>
Remove instrumentation tracking a fixed bug
Modified: trunk/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp (101793 => 101794)
--- trunk/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp 2011-12-02 15:17:50 UTC (rev 101793)
+++ trunk/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp 2011-12-02 15:24:04 UTC (rev 101794)
@@ -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 @@
namespace WebCore {
+class ScriptExecutionContext;
+
PassRefPtr<ScriptCallStack> createScriptCallStack(size_t, bool)
{
return 0;
@@ -83,6 +86,17 @@
return ScriptCallStack::create(frames);
}
+PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec)
+{
+ size_t maxStackSize = 1;
+ if (InspectorInstrumentation::hasFrontends()) {
+ ScriptExecutionContext* scriptExecutionContext = static_cast<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;
Modified: trunk/Source/WebCore/bindings/js/ScriptCallStackFactory.h (101793 => 101794)
--- trunk/Source/WebCore/bindings/js/ScriptCallStackFactory.h 2011-12-02 15:17:50 UTC (rev 101793)
+++ trunk/Source/WebCore/bindings/js/ScriptCallStackFactory.h 2011-12-02 15:24:04 UTC (rev 101794)
@@ -44,6 +44,7 @@
PassRefPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize, bool emptyStackIsAllowed);
PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState*, size_t maxStackSize);
+PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState*);
PassRefPtr<ScriptArguments> createScriptArguments(JSC::ExecState*, unsigned skipArgumentCount);
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (101793 => 101794)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2011-12-02 15:17:50 UTC (rev 101793)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2011-12-02 15:24:04 UTC (rev 101794)
@@ -2396,8 +2396,7 @@
if ($function->signature->extendedAttributes->{"CustomArgumentHandling"} and !$function->isStatic) {
push(@$outputArray, " RefPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, $numParameters));\n");
- push(@$outputArray, " size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;\n");
- push(@$outputArray, " RefPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize));\n");
+ push(@$outputArray, " RefPtr<ScriptCallStack> callStack(createScriptCallStack(exec));\n");
$implIncludes{"ScriptArguments.h"} = 1;
$implIncludes{"ScriptCallStack.h"} = 1;
$implIncludes{"ScriptCallStackFactory.h"} = 1;
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (101793 => 101794)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2011-12-02 15:17:50 UTC (rev 101793)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2011-12-02 15:24:04 UTC (rev 101794)
@@ -1389,8 +1389,7 @@
if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) {
push(@implContentDecls, <<END);
RefPtr<ScriptArguments> scriptArguments(createScriptArguments(args, $numParameters));
- size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;
- RefPtr<ScriptCallStack> callStack(createScriptCallStack(maxStackSize));
+ RefPtr<ScriptCallStack> callStack(createScriptCallStack());
if (!callStack)
return v8::Undefined();
END
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (101793 => 101794)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2011-12-02 15:17:50 UTC (rev 101793)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2011-12-02 15:24:04 UTC (rev 101794)
@@ -1287,8 +1287,7 @@
return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
ExceptionCode ec = 0;
RefPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, 1));
- size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;
- RefPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize));
+ RefPtr<ScriptCallStack> callStack(createScriptCallStack(exec));
log* intArg(tolog(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp (101793 => 101794)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp 2011-12-02 15:17:50 UTC (rev 101793)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp 2011-12-02 15:24:04 UTC (rev 101794)
@@ -858,8 +858,7 @@
ExceptionCode ec = 0;
{
RefPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 1));
- size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;
- RefPtr<ScriptCallStack> callStack(createScriptCallStack(maxStackSize));
+ RefPtr<ScriptCallStack> callStack(createScriptCallStack());
if (!callStack)
return v8::Undefined();
EXCEPTION_BLOCK(log*, intArg, V8log::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)) ? V8log::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined))) : 0);
Modified: trunk/Source/WebCore/bindings/v8/ScriptCallStackFactory.cpp (101793 => 101794)
--- trunk/Source/WebCore/bindings/v8/ScriptCallStackFactory.cpp 2011-12-02 15:17:50 UTC (rev 101793)
+++ trunk/Source/WebCore/bindings/v8/ScriptCallStackFactory.cpp 2011-12-02 15:24:04 UTC (rev 101794)
@@ -31,6 +31,7 @@
#include "config.h"
#include "ScriptCallStackFactory.h"
+#include "InspectorInstrumentation.h"
#include "InspectorValues.h"
#include "ScriptArguments.h"
#include "ScriptCallFrame.h"
@@ -38,11 +39,14 @@
#include "ScriptScope.h"
#include "ScriptValue.h"
#include "V8Binding.h"
+#include "V8Utilities.h"
#include <v8-debug.h>
namespace WebCore {
+class ScriptExecutionContext;
+
static ScriptCallFrame toScriptCallFrame(v8::Handle<v8::StackFrame> frame)
{
String sourceName;
@@ -101,6 +105,17 @@
return createScriptCallStack(stackTrace, maxStackSize, emptyStackIsAllowed);
}
+PassRefPtr<ScriptCallStack> createScriptCallStack()
+{
+ size_t maxStackSize = 1;
+ if (InspectorInstrumentation::hasFrontends()) {
+ ScriptExecutionContext* scriptExecutionContext = getScriptExecutionContext();
+ if (InspectorInstrumentation::hasFrontendForScriptContext(scriptExecutionContext))
+ maxStackSize = ScriptCallStack::maxCallStackSizeToCapture;
+ }
+ return createScriptCallStack(maxStackSize);
+}
+
PassRefPtr<ScriptArguments> createScriptArguments(const v8::Arguments& v8arguments, unsigned skipArgumentCount)
{
v8::HandleScope scope;
Modified: trunk/Source/WebCore/bindings/v8/ScriptCallStackFactory.h (101793 => 101794)
--- trunk/Source/WebCore/bindings/v8/ScriptCallStackFactory.h 2011-12-02 15:17:50 UTC (rev 101793)
+++ trunk/Source/WebCore/bindings/v8/ScriptCallStackFactory.h 2011-12-02 15:24:04 UTC (rev 101794)
@@ -48,6 +48,7 @@
PassRefPtr<ScriptCallStack> createScriptCallStack(v8::Handle<v8::StackTrace>, size_t maxStackSize);
PassRefPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize, bool emptyStackIsAllowed = false);
+PassRefPtr<ScriptCallStack> createScriptCallStack();
PassRefPtr<ScriptArguments> createScriptArguments(const v8::Arguments& v8arguments, unsigned skipArgumentCount);
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (101793 => 101794)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2011-12-02 15:17:50 UTC (rev 101793)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2011-12-02 15:24:04 UTC (rev 101794)
@@ -44,6 +44,8 @@
#include "InspectorDOMDebuggerAgent.h"
#include "InspectorCSSAgent.h"
#include "InspectorConsoleAgent.h"
+#include "InspectorController.h"
+#include "WorkerInspectorController.h"
#include "InspectorDatabaseAgent.h"
#include "InspectorDOMAgent.h"
#include "InspectorDOMStorageAgent.h"
@@ -875,6 +877,26 @@
return false;
}
+bool InspectorInstrumentation::hasFrontendForScriptContext(ScriptExecutionContext* scriptExecutionContext)
+{
+ if (!scriptExecutionContext)
+ return false;
+
+ if (scriptExecutionContext->isDocument()) {
+ Document* document = static_cast<Document*>(scriptExecutionContext);
+ Page* page = document->page();
+ return page && page->inspectorController()->hasFrontend();
+#if ENABLE(WORKERS)
+ } else {
+ WorkerContext* workerContext = static_cast<WorkerContext*>(scriptExecutionContext);
+ WorkerInspectorController* workerInspectorController = workerContext->workerInspectorController();
+ return workerInspectorController && workerInspectorController->hasFrontend();
+#endif
+ }
+
+ return false;
+}
+
void InspectorInstrumentation::pauseOnNativeEventIfNeeded(InstrumentingAgents* instrumentingAgents, const String& categoryType, const String& eventName, bool synchronous)
{
#if ENABLE(_javascript__DEBUGGER)
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (101793 => 101794)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2011-12-02 15:17:50 UTC (rev 101793)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2011-12-02 15:24:04 UTC (rev 101794)
@@ -205,9 +205,11 @@
static void frontendCreated() { s_frontendCounter += 1; }
static void frontendDeleted() { s_frontendCounter -= 1; }
static bool hasFrontends() { return s_frontendCounter; }
+ static bool hasFrontendForScriptContext(ScriptExecutionContext*);
static bool collectingHTMLParseErrors(Page*);
#else
static bool hasFrontends() { return false; }
+ static bool hasFrontendForScriptContext(ScriptExecutionContext*) { return false; }
static bool collectingHTMLParseErrors(Page*) { return false; }
#endif
Modified: trunk/Source/WebCore/inspector/WorkerInspectorController.h (101793 => 101794)
--- trunk/Source/WebCore/inspector/WorkerInspectorController.h 2011-12-02 15:17:50 UTC (rev 101793)
+++ trunk/Source/WebCore/inspector/WorkerInspectorController.h 2011-12-02 15:24:04 UTC (rev 101794)
@@ -64,6 +64,7 @@
WorkerInspectorController(WorkerContext*);
~WorkerInspectorController();
+ bool hasFrontend() const { return m_frontend; }
void connectFrontend();
void disconnectFrontend();
void restoreInspectorStateFromCookie(const String& inspectorCookie);
Modified: trunk/Source/WebCore/page/Console.cpp (101793 => 101794)
--- trunk/Source/WebCore/page/Console.cpp 2011-12-02 15:17:50 UTC (rev 101793)
+++ trunk/Source/WebCore/page/Console.cpp 2011-12-02 15:24:04 UTC (rev 101794)
@@ -343,19 +343,6 @@
InspectorInstrumentation::addMessageToConsole(page(), ConsoleAPIMessageSource, EndGroupMessageType, LogMessageLevel, String(), 0, String());
}
-bool Console::shouldCaptureFullStackTrace() const
-{
-#if ENABLE(INSPECTOR)
- Page* page = this->page();
- if (!page)
- return false;
-
- return page->inspectorController()->hasFrontend();
-#else
- return false;
-#endif
-}
-
void Console::warn(PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> callStack)
{
addMessage(LogMessageType, WarningMessageLevel, arguments, callStack);
Modified: trunk/Source/WebCore/page/Console.h (101793 => 101794)
--- trunk/Source/WebCore/page/Console.h 2011-12-02 15:17:50 UTC (rev 101793)
+++ trunk/Source/WebCore/page/Console.h 2011-12-02 15:24:04 UTC (rev 101794)
@@ -82,8 +82,6 @@
void groupCollapsed(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
void groupEnd();
- bool shouldCaptureFullStackTrace() const;
-
static bool shouldPrintExceptions();
static void setShouldPrintExceptions(bool);