2010-10-21 Yury Semikhatsky <yurys@chromium.org>
authoryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Oct 2010 10:49:58 +0000 (10:49 +0000)
committeryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Oct 2010 10:49:58 +0000 (10:49 +0000)
        Reviewed by Pavel Feldman.

        Web Inspector: decouple ScriptArguments from ScriptCallStack
        https://bugs.webkit.org/show_bug.cgi?id=48058

        ScriptCallFrame and ScriptCallStack are now the same for both JSC and V8.
        The factory functions that allow to create ScriptCallStack from VM-specific
        objects are defined in ScriptCallStackFactory.cpp.

        ScriptArguments class is used for passing arguments from JS code to the native
        part.

        No new tests. This refactoring is covered with existing Console tests.

        * WebCore.gypi:
        * WebCore.xcodeproj/project.pbxproj:
        * bindings/js/ScriptCallFrame.cpp: Removed.
        * bindings/js/ScriptCallFrame.h: Removed.
        * bindings/js/ScriptCallStack.cpp: Removed.
        * bindings/js/ScriptCallStack.h: Removed.
        * bindings/js/ScriptCallStackFactory.cpp: Added.
        (WebCore::createScriptCallStack):
        (WebCore::createScriptArguments):
        (WebCore::ScriptCallStack::stackTrace):
        * bindings/js/ScriptCallStackFactory.h: Added.
        * bindings/js/ScriptState.h:
        (WebCore::ScriptStateProtectedPtr::get):
        * bindings/scripts/CodeGeneratorJS.pm:
        * bindings/scripts/CodeGeneratorV8.pm:
        * bindings/v8/ScriptCallFrame.cpp: Removed.
        * bindings/v8/ScriptCallFrame.h: Removed.
        * bindings/v8/ScriptCallStack.cpp: Removed.
        * bindings/v8/ScriptCallStack.h: Removed.
        * bindings/v8/ScriptCallStackFactory.cpp: Added.
        (WebCore::toScriptCallFrame):
        (WebCore::toScriptCallFramesVector):
        (WebCore::createScriptCallStack):
        (WebCore::createScriptArguments):
        (WebCore::ScriptCallStack::stackTrace):
        * bindings/v8/ScriptCallStackFactory.h: Added.
        * bindings/v8/ScriptController.cpp:
        (WebCore::ScriptController::setCaptureCallStackForUncaughtExceptions):
        * bindings/v8/ScriptState.h:
        (WebCore::ScriptStateProtectedPtr::get):
        * bindings/v8/V8ConsoleMessage.cpp:
        (WebCore::V8ConsoleMessage::handler):
        (WebCore::V8ConsoleMessage::dispatchNow):
        * bindings/v8/V8ConsoleMessage.h:
        * bindings/v8/custom/V8ConsoleCustom.cpp:
        (WebCore::V8Console::traceCallback):
        (WebCore::V8Console::assertCallback):
        * inspector/ConsoleMessage.cpp:
        (WebCore::ConsoleMessage::ConsoleMessage):
        (WebCore::ConsoleMessage::addToFrontend):
        (WebCore::ConsoleMessage::updateRepeatCountInConsole):
        (WebCore::ConsoleMessage::isEqual):
        * inspector/ConsoleMessage.h:
        * inspector/InspectorController.cpp:
        (WebCore::InspectorController::addMessageToConsole):
        (WebCore::InspectorController::startGroup):
        * inspector/InspectorController.h:
        * inspector/ScriptArguments.cpp: Added.
        (WebCore::ScriptArguments::ScriptArguments):
        (WebCore::ScriptArguments::~ScriptArguments):
        (WebCore::ScriptArguments::argumentAt):
        (WebCore::ScriptArguments::globalState):
        (WebCore::ScriptArguments::getFirstArgumentAsString):
        (WebCore::ScriptArguments::isEqual):
        * inspector/ScriptArguments.h: Added.
        (WebCore::ScriptArguments::argumentCount):
        * inspector/ScriptCallFrame.cpp: Added.
        (WebCore::ScriptCallFrame::ScriptCallFrame):
        (WebCore::ScriptCallFrame::~ScriptCallFrame):
        (WebCore::ScriptCallFrame::isEqual):
        (WebCore::ScriptCallFrame::buildInspectorObject):
        * inspector/ScriptCallFrame.h: Added.
        (WebCore::ScriptCallFrame::functionName):
        (WebCore::ScriptCallFrame::sourceURL):
        (WebCore::ScriptCallFrame::lineNumber):
        * inspector/ScriptCallStack.cpp: Added.
        (WebCore::ScriptCallStack::ScriptCallStack):
        (WebCore::ScriptCallStack::~ScriptCallStack):
        (WebCore::ScriptCallStack::at):
        (WebCore::ScriptCallStack::size):
        (WebCore::ScriptCallStack::isEqual):
        (WebCore::ScriptCallStack::buildInspectorObject):
        * inspector/ScriptCallStack.h: Added.
        * page/Console.cpp:
        (WebCore::Console::addMessage):
        (WebCore::Console::debug):
        (WebCore::Console::error):
        (WebCore::Console::info):
        (WebCore::Console::log):
        (WebCore::Console::dir):
        (WebCore::Console::dirxml):
        (WebCore::Console::trace):
        (WebCore::Console::assertCondition):
        (WebCore::Console::count):
        (WebCore::Console::markTimeline):
        (WebCore::Console::profile):
        (WebCore::Console::profileEnd):
        (WebCore::Console::timeEnd):
        (WebCore::Console::group):
        (WebCore::Console::groupCollapsed):
        (WebCore::Console::shouldCaptureFullStackTrace):
        (WebCore::Console::warn):
        * page/Console.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@70298 268f45cc-cd09-0410-ab3c-d52691b4dbfc

41 files changed:
WebCore/Android.jscbindings.mk
WebCore/Android.v8bindings.mk
WebCore/CMakeLists.txt
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.gypi
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/js/JSBindingsAllInOne.cpp
WebCore/bindings/js/JSConsoleCustom.cpp
WebCore/bindings/js/ScriptCallStackFactory.cpp [moved from WebCore/bindings/js/ScriptCallStack.cpp with 52% similarity]
WebCore/bindings/js/ScriptCallStackFactory.h [moved from WebCore/bindings/js/ScriptCallFrame.cpp with 64% similarity]
WebCore/bindings/js/ScriptState.h
WebCore/bindings/scripts/CodeGeneratorJS.pm
WebCore/bindings/scripts/CodeGeneratorV8.pm
WebCore/bindings/scripts/test/JS/JSTestObj.cpp
WebCore/bindings/scripts/test/V8/V8TestObj.cpp
WebCore/bindings/v8/ScriptCallFrame.h [deleted file]
WebCore/bindings/v8/ScriptCallStack.h [deleted file]
WebCore/bindings/v8/ScriptCallStackFactory.cpp [moved from WebCore/bindings/v8/ScriptCallStack.cpp with 53% similarity]
WebCore/bindings/v8/ScriptCallStackFactory.h [new file with mode: 0644]
WebCore/bindings/v8/ScriptController.cpp
WebCore/bindings/v8/ScriptState.h
WebCore/bindings/v8/V8ConsoleMessage.cpp
WebCore/bindings/v8/V8ConsoleMessage.h
WebCore/bindings/v8/custom/V8ConsoleCustom.cpp [changed mode: 0644->0755]
WebCore/dom/NodeFilter.h
WebCore/inspector/ConsoleMessage.cpp
WebCore/inspector/ConsoleMessage.h
WebCore/inspector/InspectorController.cpp
WebCore/inspector/InspectorController.h
WebCore/inspector/ScriptArguments.cpp [new file with mode: 0644]
WebCore/inspector/ScriptArguments.h [new file with mode: 0644]
WebCore/inspector/ScriptCallFrame.cpp [moved from WebCore/bindings/v8/ScriptCallFrame.cpp with 71% similarity]
WebCore/inspector/ScriptCallFrame.h [moved from WebCore/bindings/js/ScriptCallFrame.h with 80% similarity]
WebCore/inspector/ScriptCallStack.cpp [new file with mode: 0644]
WebCore/inspector/ScriptCallStack.h [moved from WebCore/bindings/js/ScriptCallStack.h with 66% similarity]
WebCore/page/Console.cpp
WebCore/page/Console.h
WebCore/page/Console.idl

index 3288059..eea3537 100644 (file)
@@ -166,8 +166,7 @@ LOCAL_SRC_FILES += \
        bindings/js/ScheduledAction.cpp \
        bindings/js/ScriptArray.cpp \
        bindings/js/ScriptCachedFrameData.cpp \
-       bindings/js/ScriptCallFrame.cpp \
-       bindings/js/ScriptCallStack.cpp \
+       bindings/js/ScriptCallStackFactory.cpp \
        bindings/js/ScriptController.cpp \
        bindings/js/ScriptEventListener.cpp \
        bindings/js/ScriptFunctionCall.cpp \
index fdee6fb..692b453 100644 (file)
@@ -49,8 +49,7 @@ LOCAL_SRC_FILES += \
        bindings/v8/ScheduledAction.cpp \
        bindings/v8/ScopedDOMDataStore.cpp \
        bindings/v8/ScriptArray.cpp \
-       bindings/v8/ScriptCallFrame.cpp \
-       bindings/v8/ScriptCallStack.cpp \
+       bindings/v8/ScriptCallStackFactory.cpp \
        bindings/v8/ScriptController.cpp \
        bindings/v8/ScriptEventListener.cpp \
        bindings/v8/ScriptFunctionCall.cpp \
index 42e344a..8f5d621 100644 (file)
@@ -686,8 +686,7 @@ SET(WebCore_SOURCES
     bindings/js/JSXSLTProcessorCustom.cpp
     bindings/js/ScheduledAction.cpp
     bindings/js/ScriptCachedFrameData.cpp
-    bindings/js/ScriptCallFrame.cpp
-    bindings/js/ScriptCallStack.cpp
+    bindings/js/ScriptCallStackFactory.cpp
     bindings/js/ScriptController.cpp
     bindings/js/ScriptDebugServer.cpp
     bindings/js/ScriptEventListener.cpp
@@ -1123,7 +1122,10 @@ SET(WebCore_SOURCES
     inspector/InspectorState.cpp
     inspector/InspectorStorageAgent.cpp
     inspector/InspectorTimelineAgent.cpp
+    inspector/ScriptArguments.cpp
     inspector/ScriptBreakpoint.cpp
+    inspector/ScriptCallFrame.cpp
+    inspector/ScriptCallStack.cpp
     inspector/TimelineRecordFactory.cpp
 
     loader/Cache.cpp
index 90d1903..680f2bc 100644 (file)
@@ -1,3 +1,113 @@
+2010-10-21  Yury Semikhatsky  <yurys@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: decouple ScriptArguments from ScriptCallStack
+        https://bugs.webkit.org/show_bug.cgi?id=48058
+
+        ScriptCallFrame and ScriptCallStack are now the same for both JSC and V8.
+        The factory functions that allow to create ScriptCallStack from VM-specific
+        objects are defined in ScriptCallStackFactory.cpp.
+
+        ScriptArguments class is used for passing arguments from JS code to the native
+        part.
+
+        No new tests. This refactoring is covered with existing Console tests.
+
+        * WebCore.gypi:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/ScriptCallFrame.cpp: Removed.
+        * bindings/js/ScriptCallFrame.h: Removed.
+        * bindings/js/ScriptCallStack.cpp: Removed.
+        * bindings/js/ScriptCallStack.h: Removed.
+        * bindings/js/ScriptCallStackFactory.cpp: Added.
+        (WebCore::createScriptCallStack):
+        (WebCore::createScriptArguments):
+        (WebCore::ScriptCallStack::stackTrace):
+        * bindings/js/ScriptCallStackFactory.h: Added.
+        * bindings/js/ScriptState.h:
+        (WebCore::ScriptStateProtectedPtr::get):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        * bindings/scripts/CodeGeneratorV8.pm:
+        * bindings/v8/ScriptCallFrame.cpp: Removed.
+        * bindings/v8/ScriptCallFrame.h: Removed.
+        * bindings/v8/ScriptCallStack.cpp: Removed.
+        * bindings/v8/ScriptCallStack.h: Removed.
+        * bindings/v8/ScriptCallStackFactory.cpp: Added.
+        (WebCore::toScriptCallFrame):
+        (WebCore::toScriptCallFramesVector):
+        (WebCore::createScriptCallStack):
+        (WebCore::createScriptArguments):
+        (WebCore::ScriptCallStack::stackTrace):
+        * bindings/v8/ScriptCallStackFactory.h: Added.
+        * bindings/v8/ScriptController.cpp:
+        (WebCore::ScriptController::setCaptureCallStackForUncaughtExceptions):
+        * bindings/v8/ScriptState.h:
+        (WebCore::ScriptStateProtectedPtr::get):
+        * bindings/v8/V8ConsoleMessage.cpp:
+        (WebCore::V8ConsoleMessage::handler):
+        (WebCore::V8ConsoleMessage::dispatchNow):
+        * bindings/v8/V8ConsoleMessage.h:
+        * bindings/v8/custom/V8ConsoleCustom.cpp:
+        (WebCore::V8Console::traceCallback):
+        (WebCore::V8Console::assertCallback):
+        * inspector/ConsoleMessage.cpp:
+        (WebCore::ConsoleMessage::ConsoleMessage):
+        (WebCore::ConsoleMessage::addToFrontend):
+        (WebCore::ConsoleMessage::updateRepeatCountInConsole):
+        (WebCore::ConsoleMessage::isEqual):
+        * inspector/ConsoleMessage.h:
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::addMessageToConsole):
+        (WebCore::InspectorController::startGroup):
+        * inspector/InspectorController.h:
+        * inspector/ScriptArguments.cpp: Added.
+        (WebCore::ScriptArguments::ScriptArguments):
+        (WebCore::ScriptArguments::~ScriptArguments):
+        (WebCore::ScriptArguments::argumentAt):
+        (WebCore::ScriptArguments::globalState):
+        (WebCore::ScriptArguments::getFirstArgumentAsString):
+        (WebCore::ScriptArguments::isEqual):
+        * inspector/ScriptArguments.h: Added.
+        (WebCore::ScriptArguments::argumentCount):
+        * inspector/ScriptCallFrame.cpp: Added.
+        (WebCore::ScriptCallFrame::ScriptCallFrame):
+        (WebCore::ScriptCallFrame::~ScriptCallFrame):
+        (WebCore::ScriptCallFrame::isEqual):
+        (WebCore::ScriptCallFrame::buildInspectorObject):
+        * inspector/ScriptCallFrame.h: Added.
+        (WebCore::ScriptCallFrame::functionName):
+        (WebCore::ScriptCallFrame::sourceURL):
+        (WebCore::ScriptCallFrame::lineNumber):
+        * inspector/ScriptCallStack.cpp: Added.
+        (WebCore::ScriptCallStack::ScriptCallStack):
+        (WebCore::ScriptCallStack::~ScriptCallStack):
+        (WebCore::ScriptCallStack::at):
+        (WebCore::ScriptCallStack::size):
+        (WebCore::ScriptCallStack::isEqual):
+        (WebCore::ScriptCallStack::buildInspectorObject):
+        * inspector/ScriptCallStack.h: Added.
+        * page/Console.cpp:
+        (WebCore::Console::addMessage):
+        (WebCore::Console::debug):
+        (WebCore::Console::error):
+        (WebCore::Console::info):
+        (WebCore::Console::log):
+        (WebCore::Console::dir):
+        (WebCore::Console::dirxml):
+        (WebCore::Console::trace):
+        (WebCore::Console::assertCondition):
+        (WebCore::Console::count):
+        (WebCore::Console::markTimeline):
+        (WebCore::Console::profile):
+        (WebCore::Console::profileEnd):
+        (WebCore::Console::timeEnd):
+        (WebCore::Console::group):
+        (WebCore::Console::groupCollapsed):
+        (WebCore::Console::shouldCaptureFullStackTrace):
+        (WebCore::Console::warn):
+        * page/Console.h:
+
 2010-10-22  Benjamin Poulain  <benjamin.poulain@nokia.com>
 
         Reviewed by Simon Hausmann.
index 26b692d..6460ee9 100644 (file)
@@ -816,10 +816,8 @@ webcore_sources += \
        WebCore/bindings/js/ScheduledAction.h \
        WebCore/bindings/js/ScriptCachedFrameData.cpp \
        WebCore/bindings/js/ScriptCachedFrameData.h \
-       WebCore/bindings/js/ScriptCallFrame.cpp \
-       WebCore/bindings/js/ScriptCallFrame.h \
-       WebCore/bindings/js/ScriptCallStack.cpp \
-       WebCore/bindings/js/ScriptCallStack.h \
+       WebCore/bindings/js/ScriptCallStackFactory.cpp \
+       WebCore/bindings/js/ScriptCallStackFactory.h \
        WebCore/bindings/js/ScriptController.cpp \
        WebCore/bindings/js/ScriptController.h \
        WebCore/bindings/js/ScriptDebugServer.cpp \
@@ -1852,8 +1850,14 @@ webcore_sources += \
        WebCore/inspector/InspectorValues.cpp \
        WebCore/inspector/InspectorValues.h \
        WebCore/inspector/InspectorWorkerResource.h \
+       WebCore/inspector/ScriptArguments.cpp \
+       WebCore/inspector/ScriptArguments.h \
        WebCore/inspector/ScriptBreakpoint.cpp \
        WebCore/inspector/ScriptBreakpoint.h \
+       WebCore/inspector/ScriptCallFrame.cpp \
+       WebCore/inspector/ScriptCallFrame.h \
+       WebCore/inspector/ScriptCallStack.cpp \
+       WebCore/inspector/ScriptCallStack.h \
        WebCore/inspector/ScriptDebugListener.h \
        WebCore/inspector/ScriptGCEventListener.h \
        WebCore/inspector/TimelineRecordFactory.cpp \
index 4a417f3..33ffde8 100644 (file)
             'bindings/js/ScheduledAction.h',
             'bindings/js/ScriptCachedFrameData.cpp',
             'bindings/js/ScriptCachedFrameData.h',
-            'bindings/js/ScriptCallFrame.cpp',
-            'bindings/js/ScriptCallFrame.h',
-            'bindings/js/ScriptCallStack.cpp',
-            'bindings/js/ScriptCallStack.h',
             'bindings/js/ScriptController.cpp',
             'bindings/js/ScriptController.h',
             'bindings/js/ScriptControllerGtk.cpp',
             'bindings/v8/ScopedDOMDataStore.cpp',
             'bindings/v8/ScopedDOMDataStore.h',
             'bindings/v8/ScriptCachedFrameData.h',
-            'bindings/v8/ScriptCallFrame.cpp',
-            'bindings/v8/ScriptCallFrame.h',
-            'bindings/v8/ScriptCallStack.cpp',
-            'bindings/v8/ScriptCallStack.h',
+            'bindings/v8/ScriptCallStackFactory.cpp',
+            'bindings/v8/ScriptCallStackFactory.h',
             'bindings/v8/ScriptController.cpp',
             'bindings/v8/ScriptController.h',
             'bindings/v8/ScriptDebugServer.cpp',
             'inspector/InspectorWorkerResource.h',
             'inspector/ScriptBreakpoint.cpp',
             'inspector/ScriptBreakpoint.h',
+            'inspector/ScriptArguments.cpp',
+            'inspector/ScriptArguments.h',
+            'inspector/ScriptCallFrame.cpp',
+            'inspector/ScriptCallFrame.h',
+            'inspector/ScriptCallStack.cpp',
+            'inspector/ScriptCallStack.h',
             'inspector/ScriptDebugListener.h',
             'inspector/ScriptGCEventListener.h',
             'inspector/TimelineRecordFactory.cpp',
index b6ac4ae..f0d7f4d 100644 (file)
@@ -351,8 +351,7 @@ v8 {
         bindings/v8/ScopedDOMDataStore.cpp \
 #        bindings/v8/ScriptArray.cpp \
         bindings/v8/ScriptCachedFrameData.cpp \
-        bindings/v8/ScriptCallFrame.cpp \
-        bindings/v8/ScriptCallStack.cpp \
+        bindings/v8/ScriptCallStackFactory.cpp \
         bindings/ScriptControllerBase.cpp \
         bindings/v8/ScriptController.cpp \
         bindings/v8/ScriptEventListener.cpp \
@@ -574,8 +573,7 @@ v8 {
         bindings/js/JSPopStateEventCustom.cpp \
         bindings/js/JSWorkerContextErrorHandler.cpp \
         bindings/js/ScriptCachedFrameData.cpp \
-        bindings/js/ScriptCallFrame.cpp \
-        bindings/js/ScriptCallStack.cpp \
+        bindings/js/ScriptCallStackFactory.cpp \
         bindings/js/ScriptController.cpp \
         bindings/js/ScriptDebugServer.cpp \
         bindings/js/ScriptEventListener.cpp \
@@ -1012,7 +1010,10 @@ SOURCES += \
     inspector/InspectorStyleSheet.cpp \
     inspector/InspectorTimelineAgent.cpp \
     inspector/InspectorValues.cpp \
+    inspector/ScriptArguments.cpp \
     inspector/ScriptBreakpoint.cpp \
+    inspector/ScriptCallFrame.cpp \
+    inspector/ScriptCallStack.cpp \
     inspector/TimelineRecordFactory.cpp \
     loader/archive/ArchiveFactory.cpp \
     loader/archive/ArchiveResource.cpp \
@@ -1388,8 +1389,6 @@ v8 {
         bindings/v8/ScopedDOMDataStore.h \
 #        bindings/v8/ScriptArray.h \
         bindings/v8/ScriptCachedFrameData.h \
-        bindings/v8/ScriptCallFrame.h \
-        bindings/v8/ScriptCallStack.h \
         bindings/v8/ScriptController.h \
         bindings/v8/ScriptEventListener.h \
         bindings/v8/ScriptFunctionCall.h \
@@ -1472,8 +1471,6 @@ v8 {
         bindings/js/JavaScriptCallFrame.h \
         bindings/js/ScheduledAction.h \
         bindings/js/ScriptCachedFrameData.h \
-        bindings/js/ScriptCallFrame.h \
-        bindings/js/ScriptCallStack.h \
         bindings/js/ScriptController.h \
         bindings/js/ScriptEventListener.h \
         bindings/js/ScriptFunctionCall.h \
index 0d9c224..a4dfff6 100644 (file)
                                        >\r
                                </File>\r
                                <File\r
-                                       RelativePath="..\bindings\js\ScriptCallFrame.cpp"\r
+                                       RelativePath="..\bindings\js\ScriptCallStackFactory.cpp"\r
                                        >\r
                                        <FileConfiguration\r
                                                Name="Debug|Win32"\r
                                        </FileConfiguration>\r
                                </File>\r
                                <File\r
-                                       RelativePath="..\bindings\js\ScriptCallFrame.h"\r
-                                       >\r
-                               </File>\r
-                               <File\r
-                                       RelativePath="..\bindings\js\ScriptCallStack.cpp"\r
-                                       >\r
-                                       <FileConfiguration\r
-                                               Name="Debug|Win32"\r
-                                               ExcludedFromBuild="true"\r
-                                               >\r
-                                               <Tool\r
-                                                       Name="VCCLCompilerTool"\r
-                                               />\r
-                                       </FileConfiguration>\r
-                                       <FileConfiguration\r
-                                               Name="Release|Win32"\r
-                                               ExcludedFromBuild="true"\r
-                                               >\r
-                                               <Tool\r
-                                                       Name="VCCLCompilerTool"\r
-                                               />\r
-                                       </FileConfiguration>\r
-                                       <FileConfiguration\r
-                                               Name="Debug_Internal|Win32"\r
-                                               ExcludedFromBuild="true"\r
-                                               >\r
-                                               <Tool\r
-                                                       Name="VCCLCompilerTool"\r
-                                               />\r
-                                       </FileConfiguration>\r
-                                       <FileConfiguration\r
-                                               Name="Debug_Cairo|Win32"\r
-                                               ExcludedFromBuild="true"\r
-                                               >\r
-                                               <Tool\r
-                                                       Name="VCCLCompilerTool"\r
-                                               />\r
-                                       </FileConfiguration>\r
-                                       <FileConfiguration\r
-                                               Name="Release_Cairo|Win32"\r
-                                               ExcludedFromBuild="true"\r
-                                               >\r
-                                               <Tool\r
-                                                       Name="VCCLCompilerTool"\r
-                                               />\r
-                                       </FileConfiguration>\r
-                                       <FileConfiguration\r
-                                               Name="Debug_All|Win32"\r
-                                               ExcludedFromBuild="true"\r
-                                               >\r
-                                               <Tool\r
-                                                       Name="VCCLCompilerTool"\r
-                                               />\r
-                                       </FileConfiguration>\r
-                               </File>\r
-                               <File\r
-                                       RelativePath="..\bindings\js\ScriptCallStack.h"\r
+                                       RelativePath="..\bindings\js\ScriptCallStackFactory.h"\r
                                        >\r
                                </File>\r
                                <File\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\inspector\ScriptArguments.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\inspector\ScriptArguments.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\inspector\ScriptBreakpoint.cpp"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\inspector\ScriptCallFrame.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\inspector\ScriptCallFrame.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\inspector\ScriptCallStack.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\inspector\ScriptCallStack.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\inspector\ScriptDebugListener.h"\r
                                >\r
                        </File>\r
index 098f916..f5f7354 100644 (file)
                F3644AFF1119805900E0D537 /* InjectedScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3644AFD1119805900E0D537 /* InjectedScript.cpp */; };
                F3644B001119805900E0D537 /* InjectedScript.h in Headers */ = {isa = PBXBuildFile; fileRef = F3644AFE1119805900E0D537 /* InjectedScript.h */; };
                F375CC071150D300008DDB81 /* InspectorWorkerResource.h in Headers */ = {isa = PBXBuildFile; fileRef = F375CC061150D300008DDB81 /* InspectorWorkerResource.h */; };
+               F392249C126F11AE00A926D9 /* ScriptCallStackFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F392249A126F11AE00A926D9 /* ScriptCallStackFactory.cpp */; };
+               F392249D126F11AE00A926D9 /* ScriptCallStackFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = F392249B126F11AE00A926D9 /* ScriptCallStackFactory.h */; };
+               F39BE95B12673BF400E0A674 /* ScriptArguments.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F39BE95912673BF400E0A674 /* ScriptArguments.cpp */; };
+               F39BE95C12673BF400E0A674 /* ScriptArguments.h in Headers */ = {isa = PBXBuildFile; fileRef = F39BE95A12673BF400E0A674 /* ScriptArguments.h */; };
                F3D461481161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */; };
                F3D461491161D53200CA0D09 /* JSWorkerContextErrorHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */; };
                F4EAF4AE10C742B1009100D3 /* OpenTypeSanitizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4EAF4AC10C742B1009100D3 /* OpenTypeSanitizer.cpp */; };
                F3644AFD1119805900E0D537 /* InjectedScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedScript.cpp; sourceTree = "<group>"; };
                F3644AFE1119805900E0D537 /* InjectedScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedScript.h; sourceTree = "<group>"; };
                F375CC061150D300008DDB81 /* InspectorWorkerResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorWorkerResource.h; sourceTree = "<group>"; };
+               F392249A126F11AE00A926D9 /* ScriptCallStackFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptCallStackFactory.cpp; sourceTree = "<group>"; };
+               F392249B126F11AE00A926D9 /* ScriptCallStackFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptCallStackFactory.h; sourceTree = "<group>"; };
+               F39BE95912673BF400E0A674 /* ScriptArguments.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptArguments.cpp; sourceTree = "<group>"; };
+               F39BE95A12673BF400E0A674 /* ScriptArguments.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptArguments.h; sourceTree = "<group>"; };
                F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerContextErrorHandler.cpp; sourceTree = "<group>"; };
                F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWorkerContextErrorHandler.h; sourceTree = "<group>"; };
                F4EAF4AC10C742B1009100D3 /* OpenTypeSanitizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OpenTypeSanitizer.cpp; path = opentype/OpenTypeSanitizer.cpp; sourceTree = "<group>"; };
                                F375CC061150D300008DDB81 /* InspectorWorkerResource.h */,
                                1C81BA050E97348300266E07 /* JavaScriptCallFrame.idl */,
                                BCC64F5F0DCFB84E0081EF3B /* localizedStrings.js */,
+                               F39BE95912673BF400E0A674 /* ScriptArguments.cpp */,
+                               F39BE95A12673BF400E0A674 /* ScriptArguments.h */,
                                200B190811C277D900DCCD3A /* ScriptBreakpoint.cpp */,
                                7AFD4A8A1131C2760035B883 /* ScriptBreakpoint.h */,
+                               416E75CA0EDF90C700360E1D /* ScriptCallFrame.cpp */,
+                               416E75C90EDF90C700360E1D /* ScriptCallFrame.h */,
+                               416E75BD0EDF8FD700360E1D /* ScriptCallStack.cpp */,
+                               416E75BC0EDF8FD700360E1D /* ScriptCallStack.h */,
                                7AFD4FF3113277B60035B883 /* ScriptDebugListener.h */,
                                9FA37EEF1172FD4100C4CD55 /* ScriptProfile.idl */,
                                9FA37EF01172FD4100C4CD55 /* ScriptProfileNode.idl */,
                                BCA378BB0D15F64200B793D6 /* ScheduledAction.h */,
                                41F1D21E0EF35C2A00DA8753 /* ScriptCachedFrameData.cpp */,
                                41F1D21D0EF35C2A00DA8753 /* ScriptCachedFrameData.h */,
-                               416E75CA0EDF90C700360E1D /* ScriptCallFrame.cpp */,
-                               416E75C90EDF90C700360E1D /* ScriptCallFrame.h */,
-                               416E75BD0EDF8FD700360E1D /* ScriptCallStack.cpp */,
-                               416E75BC0EDF8FD700360E1D /* ScriptCallStack.h */,
+                               F392249A126F11AE00A926D9 /* ScriptCallStackFactory.cpp */,
+                               F392249B126F11AE00A926D9 /* ScriptCallStackFactory.h */,
                                93B70D5309EB0C7C009D8468 /* ScriptController.cpp */,
                                93B70D5409EB0C7C009D8468 /* ScriptController.h */,
                                A83E1C720E49042B00140B9C /* ScriptControllerMac.mm */,
                                1CEFC9B90D78DC8C007D2579 /* SchedulePair.h in Headers */,
                                5162C7F511F77EFB00612EFE /* SchemeRegistry.h in Headers */,
                                BCEC01BE0C274DAC009F4EC9 /* Screen.h in Headers */,
+                               F39BE95C12673BF400E0A674 /* ScriptArguments.h in Headers */,
                                A84D82C111D3474800972990 /* ScriptableDocumentParser.h in Headers */,
                                7AFD4A8B1131C2760035B883 /* ScriptBreakpoint.h in Headers */,
                                41F1D21F0EF35C2A00DA8753 /* ScriptCachedFrameData.h in Headers */,
                                081CDFB9126ECFDB00D215CA /* DeprecatedSVGAnimatedPropertyTraits.h in Headers */,
                                081CDFBA126ECFDB00D215CA /* DeprecatedSVGAnimatedTemplate.h in Headers */,
                                081CDFBF126ECFE800D215CA /* SVGAnimatedPropertySynchronizer.h in Headers */,
+                               F392249D126F11AE00A926D9 /* ScriptCallStackFactory.h in Headers */,
                                088A0E04126EF1DB00978F7A /* SVGAnimatedListPropertyTearOff.h in Headers */,
                                088A0E05126EF1DB00978F7A /* SVGAnimatedProperty.h in Headers */,
                                088A0E06126EF1DB00978F7A /* SVGAnimatedPropertyDescription.h in Headers */,
                                5162C7F411F77EFB00612EFE /* SchemeRegistry.cpp in Sources */,
                                BCEC01BD0C274DAC009F4EC9 /* Screen.cpp in Sources */,
                                A84D82C211D3474800972990 /* ScriptableDocumentParser.cpp in Sources */,
+                               F39BE95B12673BF400E0A674 /* ScriptArguments.cpp in Sources */,
                                200B190911C277D900DCCD3A /* ScriptBreakpoint.cpp in Sources */,
                                41F1D2200EF35C2A00DA8753 /* ScriptCachedFrameData.cpp in Sources */,
                                416E75CC0EDF90C700360E1D /* ScriptCallFrame.cpp in Sources */,
                                9728C3131268E4390041E89B /* MarkupAccumulator.cpp in Sources */,
                                E18772F1126E2629003DD586 /* Language.cpp in Sources */,
                                7A1F2B52126C61B20006A7E6 /* InspectorClient.cpp in Sources */,
+                               F392249C126F11AE00A926D9 /* ScriptCallStackFactory.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index cf08ca9..e2012ce 100644 (file)
 #include "MemoryInfo.cpp"
 #include "ScheduledAction.cpp"
 #include "ScriptCachedFrameData.cpp"
-#include "ScriptCallFrame.cpp"
-#include "ScriptCallStack.cpp"
+#include "ScriptCallStackFactory.cpp"
 #include "ScriptController.cpp"
 #include "ScriptControllerWin.cpp"
 #include "ScriptDebugServer.cpp"
index f0419c7..6df88f6 100644 (file)
 
 #include "Console.h"
 #include "JSScriptProfile.h"
+#include "ScriptCallStack.h"
+#include "ScriptCallStackFactory.h"
 #include "ScriptProfile.h"
 #include <runtime/JSArray.h>
+#include <wtf/OwnPtr.h>
 
 using namespace JSC;
 
@@ -52,6 +55,28 @@ JSValue JSConsole::profiles(ExecState* exec) const
     return constructArray(exec, list);
 }
 
+JSValue JSConsole::profile(ExecState* exec)
+{
+    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(exec, 1));
+    const String& title = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0));
+    if (exec->hadException())
+        return jsUndefined();
+
+    impl()->profile(title, exec, callStack.release());
+    return jsUndefined();
+}
+
+JSValue JSConsole::profileEnd(ExecState* exec)
+{
+    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(exec, 1));
+    const String& title = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0));
+    if (exec->hadException())
+        return jsUndefined();
+
+    impl()->profileEnd(title, exec, callStack.release());
+    return jsUndefined();
+}
+
 #endif
 
 } // namespace WebCore
similarity index 52%
rename from WebCore/bindings/js/ScriptCallStack.cpp
rename to WebCore/bindings/js/ScriptCallStackFactory.cpp
index de61b07..25fabdd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Google Inc. All rights reserved.
+ * Copyright (c) 2010 Google Inc. All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
  */
 
 #include "config.h"
-#include "ScriptCallStack.h"
+#include "ScriptCallStackFactory.h"
 
+#include "JSDOMBinding.h"
+#include "ScriptArguments.h"
+#include "ScriptCallFrame.h"
+#include "ScriptCallStack.h"
+#include "ScriptValue.h"
 #include <interpreter/CallFrame.h>
 #include <interpreter/Interpreter.h>
+#include <runtime/ArgList.h>
 #include <runtime/JSFunction.h>
+#include <runtime/JSGlobalData.h>
 #include <runtime/JSValue.h>
 #include <runtime/UString.h>
-#include <runtime/JSGlobalData.h>
 
 using namespace JSC;
 
 namespace WebCore {
 
-ScriptCallStack::ScriptCallStack(ExecState* exec, unsigned skipArgumentCount)
-    : m_initialized(false)
-    , m_exec(exec)
-    , m_caller(0)
-{
-    int signedLineNumber;
-    intptr_t sourceID;
-    UString urlString;
-    JSValue function;
-
-    exec->interpreter()->retrieveLastCaller(exec, signedLineNumber, sourceID, urlString, function);
-
-    unsigned lineNumber = signedLineNumber >= 0 ? signedLineNumber : 0;
-
-    if (function) {
-        m_caller = asFunction(function);
-        m_frames.append(ScriptCallFrame(m_caller->name(m_exec), urlString, lineNumber, m_exec, skipArgumentCount));
-    } else {
-        // Caller is unknown, but we should still add the frame, because
-        // something called us, and gave us arguments.
-        m_frames.append(ScriptCallFrame(UString(), urlString, lineNumber, m_exec, skipArgumentCount));
-    }
-}
-
-ScriptCallStack::~ScriptCallStack()
-{
-}
-
-const ScriptCallFrame &ScriptCallStack::at(unsigned index)
+PassOwnPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t maxStackSize)
 {
-    // First frame is pre-populated in constructor, so don't trigger
-    // initialization unless looking beyond the first frame.
-    if (index > 0)
-        initialize();
-    ASSERT(m_frames.size() > index);
-    return m_frames[index];
-}
-
-unsigned ScriptCallStack::size()
-{
-    initialize();
-    return m_frames.size();
-}
-
-void ScriptCallStack::initialize()
-{
-    if (!m_caller || m_initialized)
-        return;
-
-    int signedLineNumber;
-    intptr_t sourceID;
-    UString urlString;
-    JSValue function;
-    // callFrame must exist if m_caller is not null.
-    CallFrame* callFrame = m_exec->callerFrame();
+    Vector<ScriptCallFrame> frames;
+    CallFrame* callFrame = exec;
     while (true) {
         ASSERT(callFrame);
-        m_exec->interpreter()->retrieveLastCaller(callFrame, signedLineNumber, sourceID, urlString, function);
-        if (!function)
-            break;
-        JSFunction* jsFunction = asFunction(function);
+        int signedLineNumber;
+        intptr_t sourceID;
+        UString urlString;
+        JSValue function;
+
+        exec->interpreter()->retrieveLastCaller(callFrame, signedLineNumber, sourceID, urlString, function);
+        UString functionName;
+        if (function)
+            functionName = asFunction(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.
+            if (!frames.isEmpty())
+                break;
+        }
         unsigned lineNumber = signedLineNumber >= 0 ? signedLineNumber : 0;
-        m_frames.append(ScriptCallFrame(jsFunction->name(m_exec), urlString, lineNumber, m_exec, 0));
+        frames.append(ScriptCallFrame(ustringToString(functionName), ustringToString(urlString), lineNumber));
+        if (!function || frames.size() == maxStackSize)
+            break;
         callFrame = callFrame->callerFrame();
     }
-    m_initialized = true;
+    return new ScriptCallStack(frames);
+}
+
+PassOwnPtr<ScriptArguments> createScriptArguments(JSC::ExecState* exec, unsigned skipArgumentCount)
+{
+    Vector<ScriptValue> arguments;
+    size_t argumentCount = exec->argumentCount();
+    for (size_t i = skipArgumentCount; i < argumentCount; ++i)
+        arguments.append(ScriptValue(exec->argument(i)));
+    return new ScriptArguments(exec, arguments);
 }
 
 bool ScriptCallStack::stackTrace(int, const RefPtr<InspectorArray>&)
similarity index 64%
rename from WebCore/bindings/js/ScriptCallFrame.cpp
rename to WebCore/bindings/js/ScriptCallStackFactory.h
index 2f74b96..744d88d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Google Inc. All rights reserved.
+ * Copyright (c) 2010 Google Inc. All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "config.h"
-#include "ScriptCallFrame.h"
+#ifndef ScriptCallStackFactory_h
+#define ScriptCallStackFactory_h
 
-#include <runtime/ArgList.h>
-#include <runtime/UString.h>
+#include <wtf/PassOwnPtr.h>
 
-using namespace JSC;
+namespace JSC {
+class ExecState;
+}
 
 namespace WebCore {
 
-ScriptCallFrame::ScriptCallFrame(const UString& functionName, const UString& urlString, int lineNumber, ExecState* exec, unsigned skipArgumentCount)
-    : m_functionName(ustringToString(functionName))
-    , m_sourceURL(ustringToString(urlString))
-    , m_lineNumber(lineNumber)
-{
-    if (!exec)
-        return;
-    size_t argumentCount = exec->argumentCount();
-    for (size_t i = skipArgumentCount; i < argumentCount; ++i)
-        m_arguments.append(ScriptValue(exec->argument(i)));
-}
-
-ScriptCallFrame::~ScriptCallFrame()
-{
-}
+class ScriptArguments;
+class ScriptCallStack;
 
-const ScriptValue &ScriptCallFrame::argumentAt(unsigned index) const
-{
-    ASSERT(m_arguments.size() > index);
-    return m_arguments[index];
-}
+PassOwnPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState*, size_t maxStackSize);
+PassOwnPtr<ScriptArguments> createScriptArguments(JSC::ExecState*, unsigned skipArgumentCount);
 
 } // namespace WebCore
+
+#endif // ScriptCallStackFactory_h
index 6bef4f7..b716849 100644 (file)
@@ -32,7 +32,8 @@
 #ifndef ScriptState_h
 #define ScriptState_h
 
-#include "JSDOMBinding.h"
+#include <interpreter/CallFrame.h>
+#include <runtime/JSGlobalObject.h>
 #include <runtime/Protect.h>
 #include <wtf/Noncopyable.h>
 
@@ -52,7 +53,7 @@ class ScriptStateProtectedPtr : public Noncopyable {
 public:
     ScriptStateProtectedPtr() { }
     ScriptStateProtectedPtr(ScriptState* scriptState) : m_globalObject(scriptState->lexicalGlobalObject()) { }
-    ScriptState* get()
+    ScriptState* get() const
     {
         if (m_globalObject)
             return m_globalObject->globalExec();
index 0b56f13..23db957 100644 (file)
@@ -1966,8 +1966,12 @@ sub GenerateImplementation
                     my $hasOptionalArguments = 0;
 
                     if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) {
-                        push(@implContent, "    ScriptCallStack callStack(exec, $numParameters);\n");
+                        push(@implContent, "    OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, $numParameters));\n");
+                        push(@implContent, "    size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;\n");
+                        push(@implContent, "    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize));\n");
+                        $implIncludes{"ScriptArguments.h"} = 1;
                         $implIncludes{"ScriptCallStack.h"} = 1;
+                        $implIncludes{"ScriptCallStackFactory.h"} = 1;
                     }
 
                     my $callWith = $function->signature->extendedAttributes->{"CallWith"};
@@ -2357,8 +2361,8 @@ sub GenerateImplementationFunctionCall()
 
     if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) {
         $functionString .= ", " if $paramIndex;
-        ++$paramIndex;
-        $functionString .= "&callStack";
+        $paramIndex += 2;
+        $functionString .= "scriptArguments.release(), callStack.release()";
     }
 
     if (@{$function->raisesExceptions}) {
index 751e350..0c79e64 100644 (file)
@@ -1304,11 +1304,15 @@ END
 
     if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) {
         push(@implContentDecls, <<END);
-    OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, $numParameters));
+    OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, $numParameters));
+    size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;
+    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(maxStackSize));
     if (!callStack)
         return v8::Undefined();
 END
+        $implIncludes{"ScriptArguments.h"} = 1;
         $implIncludes{"ScriptCallStack.h"} = 1;
+        $implIncludes{"ScriptCallStackFactory.h"} = 1;
     }
     if ($function->signature->extendedAttributes->{"SVGCheckSecurityDocument"}) {
         push(@implContentDecls, <<END);
@@ -2719,8 +2723,8 @@ sub GenerateFunctionCallString()
 
     if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) {
         $functionString .= ", " if $index;
-        $functionString .= "callStack.get()";
-        $index++;
+        $functionString .= "scriptArguments.release(), callStack.release()";
+        $index += 2;
     }
 
     if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) {
index 5236267..7e06068 100644 (file)
@@ -31,7 +31,9 @@
 #include "JSTestObj.h"
 #include "JSlog.h"
 #include "KURL.h"
+#include "ScriptArguments.h"
 #include "ScriptCallStack.h"
+#include "ScriptCallStackFactory.h"
 #include "SerializedScriptValue.h"
 #include "TestObj.h"
 #include <runtime/Error.h>
@@ -994,12 +996,14 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomArgsAndException(Ex
     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
     ExceptionCode ec = 0;
-    ScriptCallStack callStack(exec, 1);
+    OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, 1));
+    size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;
+    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize));
     log* intArg = tolog(exec->argument(0));
     if (exec->hadException())
         return JSValue::encode(jsUndefined());
 
-    imp->customArgsAndException(intArg, &callStack, ec);
+    imp->customArgsAndException(intArg, scriptArguments.release(), callStack.release(), ec);
     setDOMException(exec, ec);
     return JSValue::encode(jsUndefined());
 }
index 44f0d3e..3441b73 100644 (file)
@@ -26,7 +26,9 @@
 #include "IDBBindingUtilities.h"
 #include "IDBKey.h"
 #include "RuntimeEnabledFeatures.h"
+#include "ScriptArguments.h"
 #include "ScriptCallStack.h"
+#include "ScriptCallStackFactory.h"
 #include "SerializedScriptValue.h"
 #include "V8Binding.h"
 #include "V8BindingMacros.h"
@@ -705,11 +707,13 @@ static v8::Handle<v8::Value> customArgsAndExceptionCallback(const v8::Arguments&
     TestObj* imp = V8TestObj::toNative(args.Holder());
     ExceptionCode ec = 0;
     {
-    OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, 1));
+    OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 1));
+    size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;
+    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(maxStackSize));
     if (!callStack)
         return v8::Undefined();
     EXCEPTION_BLOCK(log*, intArg, V8log::HasInstance(args[0]) ? V8log::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
-    imp->customArgsAndException(intArg, callStack.get(), ec);
+    imp->customArgsAndException(intArg, scriptArguments.release(), callStack.release(), ec);
     if (UNLIKELY(ec))
         goto fail;
     return v8::Handle<v8::Value>();
diff --git a/WebCore/bindings/v8/ScriptCallFrame.h b/WebCore/bindings/v8/ScriptCallFrame.h
deleted file mode 100644 (file)
index ff77d4a..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScriptCallFrame_h
-#define ScriptCallFrame_h
-
-#include "KURL.h"
-
-#include <wtf/Vector.h>
-
-namespace v8 {
-    class Arguments;
-}
-
-namespace WebCore {
-    class ScriptValue;
-
-    // FIXME: Implement retrieving line number and source URL and storing here
-    // for all call frames, not just the first one.
-    // See <https://bugs.webkit.org/show_bug.cgi?id=22556> and
-    // <https://bugs.webkit.org/show_bug.cgi?id=21180>
-    class ScriptCallFrame  {
-    public:
-        ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber, const v8::Arguments&, unsigned skipArgumentCount);
-        ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber);
-        ~ScriptCallFrame();
-
-        const String& functionName() const { return m_functionName; }
-        const String& sourceURL() const { return m_sourceURL; }
-        unsigned lineNumber() const { return m_lineNumber; }
-
-        // argument retrieval methods
-        const ScriptValue& argumentAt(unsigned) const;
-        unsigned argumentCount() const { return m_arguments.size(); }
-
-    private:
-        String m_functionName;
-        String m_sourceURL;
-        unsigned m_lineNumber;
-
-        Vector<ScriptValue> m_arguments;
-    };
-
-} // namespace WebCore
-
-#endif // ScriptCallFrame_h
diff --git a/WebCore/bindings/v8/ScriptCallStack.h b/WebCore/bindings/v8/ScriptCallStack.h
deleted file mode 100644 (file)
index 98e5195..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScriptCallStack_h
-#define ScriptCallStack_h
-
-#include "ScriptCallFrame.h"
-#include "ScriptState.h"
-#include "ScriptValue.h"
-#include <wtf/Noncopyable.h>
-#include <wtf/RefPtr.h>
-
-namespace v8 {
-    class Arguments;
-}
-
-namespace WebCore {
-
-class InspectorArray;
-
-class ScriptCallStack : public Noncopyable {
-public:
-    static const int maxCallStackSizeToCapture;
-    static const v8::StackTrace::StackTraceOptions stackTraceOptions;
-
-    static PassOwnPtr<ScriptCallStack> create(const v8::Arguments&, unsigned skipArgumentCount = 0, int framCountLimit = 1);
-    static PassOwnPtr<ScriptCallStack> create(ScriptState*, v8::Handle<v8::StackTrace>);
-    ~ScriptCallStack();
-
-    // Returns false if there is no running JavaScript or if fetching the stack failed.
-    // Sets stackTrace to be an array of stack frame objects.
-    // A stack frame object looks like:
-    // {
-    //   scriptName: <file name for the associated script resource>
-    //   functionName: <name of the JavaScript function>
-    //   lineNumber: <1 based line number>
-    //   column: <1 based column offset on the line>
-    // }
-    static bool stackTrace(int frameLimit, const RefPtr<InspectorArray>& stackTrace);
-
-    const ScriptCallFrame& at(unsigned);
-    unsigned size();
-
-    ScriptState* state() const { return m_scriptState; }
-    ScriptState* globalState() const { return m_scriptState; }
-
-private:
-    ScriptCallStack(ScriptState* scriptState, PassOwnPtr<ScriptCallFrame> topFrame, Vector<OwnPtr<ScriptCallFrame> >& scriptCallFrames);
-    ScriptCallStack(ScriptState* scriptState, v8::Handle<v8::StackTrace> stackTrace);
-
-    OwnPtr<ScriptCallFrame> m_topFrame;
-    ScriptState* m_scriptState;
-    Vector<OwnPtr<ScriptCallFrame> > m_scriptCallFrames;
-};
-
-} // namespace WebCore
-
-#endif // ScriptCallStack_h
similarity index 53%
rename from WebCore/bindings/v8/ScriptCallStack.cpp
rename to WebCore/bindings/v8/ScriptCallStackFactory.cpp
index 3e29c7a..62fbeef 100644 (file)
@@ -1,10 +1,10 @@
 /*
- * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
- *
+ * Copyright (c) 2010 Google Inc. All rights reserved.
+ * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
  * met:
- *
+ * 
  *     * Redistributions of source code must retain the above copyright
  * notice, this list of conditions and the following disclaimer.
  *     * Redistributions in binary form must reproduce the above
  */
 
 #include "config.h"
-#include "ScriptCallStack.h"
+#include "ScriptCallStackFactory.h"
 
 #include "InspectorValues.h"
-#include "ScriptController.h"
-#include "ScriptDebugServer.h"
+#include "ScriptArguments.h"
+#include "ScriptCallFrame.h"
+#include "ScriptCallStack.h"
 #include "ScriptScope.h"
+#include "ScriptValue.h"
 #include "V8Binding.h"
 
 #include <v8-debug.h>
 
 namespace WebCore {
 
-static void getFrameLocation(v8::Handle<v8::StackFrame> frame, String* sourceName, int* sourceLineNumber, String* functionName)
+static ScriptCallFrame toScriptCallFrame(v8::Handle<v8::StackFrame> frame)
 {
-    ASSERT(!frame.IsEmpty());
+    String sourceName;
     v8::Local<v8::String> sourceNameValue(frame->GetScriptNameOrSourceURL());
-    v8::Local<v8::String> functionNameValue(frame->GetFunctionName());
-    *sourceName = sourceNameValue.IsEmpty() ? "" : toWebCoreString(sourceNameValue);
-    *functionName = functionNameValue.IsEmpty() ? "" : toWebCoreString(functionNameValue);
-    *sourceLineNumber = frame->GetLineNumber();
-}
-
-static void getTopFrameLocation(v8::Handle<v8::StackTrace> stackTrace, String* sourceName, int* sourceLineNumber, String* functionName)
-{
-    if (stackTrace->GetFrameCount() <= 0) {
-        // Successfully grabbed stack trace, but there are no frames. It may happen in case of a syntax error for example.
-        // Fallback to setting lineNumber to 0, and source and function name to "undefined".
-        *sourceName = "undefined";
-        *sourceLineNumber = 0;
-        *functionName = "undefined";
-    } else {
-        v8::Handle<v8::StackFrame> frame = stackTrace->GetFrame(0);
-        getFrameLocation(frame, sourceName, sourceLineNumber, functionName);
-    }
-}
+    if (!sourceNameValue.IsEmpty())
+        sourceName = toWebCoreString(sourceNameValue);
 
-static PassOwnPtr<ScriptCallFrame> toScriptCallFrame(v8::Handle<v8::StackFrame> frame)
-{
-    String sourceName;
-    int sourceLineNumber;
     String functionName;
-    getFrameLocation(frame, &sourceName, &sourceLineNumber, &functionName);
-    return new ScriptCallFrame(functionName, sourceName, sourceLineNumber);
+    v8::Local<v8::String> functionNameValue(frame->GetFunctionName());
+    if (!functionNameValue.IsEmpty())
+        functionName = toWebCoreString(functionNameValue);
+
+    int sourceLineNumber = frame->GetLineNumber();
+    return ScriptCallFrame(functionName, sourceName, sourceLineNumber);
 }
 
-static void toScriptCallFramesVector(v8::Local<v8::Context> context, v8::Handle<v8::StackTrace> stackTrace, Vector<OwnPtr<ScriptCallFrame> >& scriptCallFrames)
+static void toScriptCallFramesVector(v8::Local<v8::Context> context, v8::Handle<v8::StackTrace> stackTrace, Vector<ScriptCallFrame>& scriptCallFrames, size_t maxStackSize)
 {
+    // TODO(yurys): remove this???
     v8::Context::Scope contextScope(context);
     int frameCount = stackTrace->GetFrameCount();
+    if (frameCount > static_cast<int>(maxStackSize))
+        frameCount = maxStackSize;
     for (int i = 0; i < frameCount; i++) {
         v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i);
         scriptCallFrames.append(toScriptCallFrame(stackFrame));
     }
+    
+    if (!frameCount) {
+        // Successfully grabbed stack trace, but there are no frames. It may happen in case of a syntax error for example.
+        // Fallback to setting lineNumber to 0, and source and function name to "undefined".
+        scriptCallFrames.append(ScriptCallFrame("undefined", "undefined", 0));
+    }
 }
 
-const int ScriptCallStack::maxCallStackSizeToCapture = 200;
-const v8::StackTrace::StackTraceOptions ScriptCallStack::stackTraceOptions = static_cast<v8::StackTrace::StackTraceOptions>(
-     v8::StackTrace::kLineNumber
-    | v8::StackTrace::kColumnOffset
-    | v8::StackTrace::kScriptNameOrSourceURL
-    | v8::StackTrace::kFunctionName);
-
-
-PassOwnPtr<ScriptCallStack> ScriptCallStack::create(const v8::Arguments& arguments, unsigned skipArgumentCount, int framCountLimit)
+PassOwnPtr<ScriptCallStack> createScriptCallStack(v8::Local<v8::Context> context, v8::Handle<v8::StackTrace> stackTrace, size_t maxStackSize)
 {
     v8::HandleScope scope;
-    v8::Local<v8::Context> context = v8::Context::GetCurrent();
     v8::Context::Scope contextScope(context);
-    v8::Handle<v8::StackTrace> stackTrace(v8::StackTrace::CurrentStackTrace(framCountLimit, ScriptCallStack::stackTraceOptions));
-
-    if (stackTrace.IsEmpty())
-        return 0;
-
-    String sourceName;
-    int sourceLineNumber;
-    String functionName;
-    getTopFrameLocation(stackTrace, &sourceName, &sourceLineNumber, &functionName);
-
-    Vector<OwnPtr<ScriptCallFrame> > scriptCallFrames;
-    if (framCountLimit > 1)
-        toScriptCallFramesVector(context, stackTrace, scriptCallFrames);
 
-    return new ScriptCallStack(ScriptState::forContext(context), new ScriptCallFrame(functionName, sourceName, sourceLineNumber, arguments, skipArgumentCount), scriptCallFrames);
+    Vector<ScriptCallFrame> scriptCallFrames;
+    toScriptCallFramesVector(context, stackTrace, scriptCallFrames, maxStackSize);
+    return new ScriptCallStack(scriptCallFrames);
 }
 
-PassOwnPtr<ScriptCallStack> ScriptCallStack::create(ScriptState* state, v8::Handle<v8::StackTrace> stackTrace)
+PassOwnPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize)
 {
     v8::HandleScope scope;
-    Vector<OwnPtr<ScriptCallFrame> > scriptCallFrames;
-    toScriptCallFramesVector(state->context(), stackTrace, scriptCallFrames);
-
-    String sourceName;
-    int sourceLineNumber;
-    String functionName;
-    getTopFrameLocation(stackTrace, &sourceName, &sourceLineNumber, &functionName);
-
-    return new ScriptCallStack(state, new ScriptCallFrame(functionName, sourceName, sourceLineNumber), scriptCallFrames);
-}
-
-ScriptCallStack::ScriptCallStack(ScriptState* scriptState, PassOwnPtr<ScriptCallFrame> topFrame, Vector<OwnPtr<ScriptCallFrame> >& scriptCallFrames)
-    : m_topFrame(topFrame)
-    , m_scriptState(scriptState)
-{
-    m_scriptCallFrames.swap(scriptCallFrames);
+    v8::Local<v8::Context> context = v8::Context::GetCurrent();
+    // TODO(yurys): remove?
+    v8::Context::Scope contextScope(context);
+    v8::Handle<v8::StackTrace> stackTrace(v8::StackTrace::CurrentStackTrace(maxStackSize, stackTraceOptions));
+    return createScriptCallStack(context, stackTrace, maxStackSize);
 }
 
-ScriptCallStack::~ScriptCallStack()
+PassOwnPtr<ScriptArguments> createScriptArguments(const v8::Arguments& v8arguments, unsigned skipArgumentCount)
 {
-}
+    v8::HandleScope scope;
+    v8::Local<v8::Context> context = v8::Context::GetCurrent();
+    ScriptState* state = ScriptState::forContext(context);
 
-const ScriptCallFrame& ScriptCallStack::at(unsigned index)
-{
-    if (!index && m_topFrame)
-        return *m_topFrame;
-    return *m_scriptCallFrames.at(index);
-}
+    Vector<ScriptValue> arguments;
+    for (int i = skipArgumentCount; i < v8arguments.Length(); ++i)
+        arguments.append(ScriptValue(v8arguments[i]));
 
-unsigned ScriptCallStack::size()
-{
-    if (m_scriptCallFrames.isEmpty())
-        return 1;
-    return m_scriptCallFrames.size();
+    return new ScriptArguments(state, arguments);
 }
 
-
 bool ScriptCallStack::stackTrace(int frameLimit, const RefPtr<InspectorArray>& stackTrace)
 {
 #if ENABLE(INSPECTOR)
diff --git a/WebCore/bindings/v8/ScriptCallStackFactory.h b/WebCore/bindings/v8/ScriptCallStackFactory.h
new file mode 100644 (file)
index 0000000..613af7b
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2010 Google Inc. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ScriptCallStackFactory_h
+#define ScriptCallStackFactory_h
+
+#include <v8.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+
+class ScriptState;
+
+const v8::StackTrace::StackTraceOptions stackTraceOptions = static_cast<v8::StackTrace::StackTraceOptions>(
+      v8::StackTrace::kLineNumber
+    | v8::StackTrace::kColumnOffset
+    | v8::StackTrace::kScriptNameOrSourceURL
+    | v8::StackTrace::kFunctionName);
+
+class ScriptArguments;
+class ScriptCallStack;
+
+PassOwnPtr<ScriptCallStack> createScriptCallStack(v8::Local<v8::Context>, v8::Handle<v8::StackTrace>, size_t maxStackSize);
+PassOwnPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize);
+PassOwnPtr<ScriptArguments> createScriptArguments(const v8::Arguments& v8arguments, unsigned skipArgumentCount);
+
+} // namespace WebCore
+
+#endif // ScriptCallStackFactory_h
index 4904a4e..fa37c38 100644 (file)
@@ -35,6 +35,7 @@
 #include "PlatformBridge.h"
 #include "Document.h"
 #include "ScriptCallStack.h"
+#include "ScriptCallStackFactory.h"
 #include "ScriptableDocumentParser.h"
 #include "DOMWindow.h"
 #include "Event.h"
@@ -468,7 +469,7 @@ void ScriptController::clearWindowShell(bool)
 #if ENABLE(INSPECTOR)
 void ScriptController::setCaptureCallStackForUncaughtExceptions(bool value)
 {
-    v8::V8::SetCaptureStackTraceForUncaughtExceptions(value, ScriptCallStack::maxCallStackSizeToCapture, ScriptCallStack::stackTraceOptions);
+    v8::V8::SetCaptureStackTraceForUncaughtExceptions(value, ScriptCallStack::maxCallStackSizeToCapture, stackTraceOptions);
 }
 #endif
 
index ce350da..11813b0 100644 (file)
@@ -95,7 +95,7 @@ public:
             m_context.Clear();
         }
     }
-    ScriptState* get() { return m_scriptState; }
+    ScriptState* get() const { return m_scriptState; }
 private:
     ScriptState* m_scriptState;
     v8::Persistent<v8::Context> m_context;
index 8b6bb17..40f9a7a 100644 (file)
@@ -37,6 +37,7 @@
 #include "OwnPtr.h"
 #include "Page.h"
 #include "ScriptCallStack.h"
+#include "ScriptCallStackFactory.h"
 #include "V8Binding.h"
 #include "V8Proxy.h"
 
@@ -117,18 +118,17 @@ void V8ConsoleMessage::handler(v8::Handle<v8::Message> message, v8::Handle<v8::V
     // Currently stack trace is only collected when inspector is open.
     if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) {
         v8::Local<v8::Context> context = v8::Context::GetEntered();
-        ScriptState* scriptState = ScriptState::forContext(context);
-        callStack = ScriptCallStack::create(scriptState, stackTrace);
+        callStack = createScriptCallStack(context, stackTrace, ScriptCallStack::maxCallStackSizeToCapture);
     }
 
     v8::Handle<v8::Value> resourceName = message->GetScriptResourceName();
     bool useURL = resourceName.IsEmpty() || !resourceName->IsString();
     String resourceNameString = useURL ? frame->document()->url() : toWebCoreString(resourceName);
     V8ConsoleMessage consoleMessage(errorMessage, resourceNameString, message->GetLineNumber());
-    consoleMessage.dispatchNow(page, callStack.get());
+    consoleMessage.dispatchNow(page, callStack.release());
 }
 
-void V8ConsoleMessage::dispatchNow(Page* page, ScriptCallStack* callStack)
+void V8ConsoleMessage::dispatchNow(Page* page, PassOwnPtr<ScriptCallStack> callStack)
 {
     ASSERT(page);
 
index 387b5ee..6b892dd 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "PlatformString.h"
 #include <v8.h>
+#include <wtf/PassOwnPtr.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
@@ -81,7 +82,7 @@ namespace WebCore {
         const String m_sourceID;
         const unsigned m_lineNumber;
 
-        void dispatchNow(Page*, ScriptCallStack*);
+        void dispatchNow(Page*, PassOwnPtr<ScriptCallStack>);
 
         // All delayed messages are stored in this vector. If the vector
         // is 0, there are no delayed messages.
old mode 100644 (file)
new mode 100755 (executable)
index fc83b61..b17b8e9
 #include "V8Console.h"
 
 #include "Console.h"
+#include "ScriptArguments.h"
 #include "ScriptCallStack.h"
+#include "ScriptCallStackFactory.h"
 #include "ScriptProfile.h"
 #include "V8Binding.h"
+#include "V8BindingMacros.h"
 #include "V8Proxy.h"
 #include "V8ScriptProfile.h"
 
@@ -62,11 +65,9 @@ v8::Handle<v8::Value> V8Console::traceCallback(const v8::Arguments& args)
 {
     INC_STATS("DOM.Console.traceCallback");
     Console* imp = V8Console::toNative(args.Holder());
-    v8::HandleScope handleScope;
-    ScriptState* scriptState = ScriptState::current();
-    v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(ScriptCallStack::maxCallStackSizeToCapture, ScriptCallStack::stackTraceOptions);
-    OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(scriptState, stackTrace));
-    imp->trace(callStack.get());
+    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture));
+    OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 0));
+    imp->trace(scriptArguments.release(), callStack.release());
     return v8::Handle<v8::Value>();
 }
 
@@ -74,9 +75,34 @@ v8::Handle<v8::Value> V8Console::assertCallback(const v8::Arguments& args)
 {
     INC_STATS("DOM.Console.assertCallback");
     Console* imp = V8Console::toNative(args.Holder());
-    OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, 1, ScriptCallStack::maxCallStackSizeToCapture));
+    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture));
     bool condition = args[0]->BooleanValue();
-    imp->assertCondition(condition, callStack.get());
+    OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 1));
+    imp->assertCondition(condition, scriptArguments.release(), callStack.release());
+    return v8::Handle<v8::Value>();
+}
+
+v8::Handle<v8::Value> V8Console::profileCallback(const v8::Arguments& args)
+{
+    INC_STATS("DOM.Console.profile");
+    Console* imp = V8Console::toNative(args.Holder());
+    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(1));
+    if (!callStack)
+        return v8::Undefined();
+    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<WithUndefinedOrNullCheck>, title, args[0]);
+    imp->profile(title, ScriptState::current(), callStack.release());
+    return v8::Handle<v8::Value>();
+}
+
+v8::Handle<v8::Value> V8Console::profileEndCallback(const v8::Arguments& args)
+{
+    INC_STATS("DOM.Console.profileEnd");
+    Console* imp = V8Console::toNative(args.Holder());
+    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(1));
+    if (!callStack)
+        return v8::Undefined();
+    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<WithUndefinedOrNullCheck>, title, args[0]);
+    imp->profileEnd(title, ScriptState::current(), callStack.release());
     return v8::Handle<v8::Value>();
 }
 
index d2022bc..5ce2866 100644 (file)
@@ -25,6 +25,7 @@
 #ifndef NodeFilter_h
 #define NodeFilter_h
 
+#include "DOMWrapperWorld.h"
 #include "NodeFilterCondition.h"
 #include <wtf/RefPtr.h>
 
index 67930cd..03283bf 100644 (file)
 
 #include "InjectedScript.h"
 #include "InjectedScriptHost.h"
+#include "InspectorFrontend.h"
 #include "InspectorValues.h"
+#include "ScriptArguments.h"
 #include "ScriptCallStack.h"
 #include "ScriptValue.h"
-
-#if ENABLE(INSPECTOR)
-#include "InspectorFrontend.h"
-#endif
+#include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
 
-ConsoleMessage::CallFrame::CallFrame(const ScriptCallFrame& frame)
-    : m_functionName(frame.functionName())
-    , m_sourceURL(frame.sourceURL())
-    , m_lineNumber(frame.lineNumber())
-{
-}
-
-ConsoleMessage::CallFrame::CallFrame()
-    : m_lineNumber(0)
-{
-}
-
-bool ConsoleMessage::CallFrame::isEqual(const ConsoleMessage::CallFrame& o) const
-{
-    return m_functionName == o.m_functionName
-        && m_sourceURL == o.m_sourceURL
-        && m_lineNumber == o.m_lineNumber;
-}
-
-#if ENABLE(INSPECTOR)
-PassRefPtr<InspectorObject> ConsoleMessage::CallFrame::buildInspectorObject() const
-{
-    RefPtr<InspectorObject> frame = InspectorObject::create();
-    frame->setString("functionName", m_functionName);
-    frame->setString("sourceURL", m_sourceURL);
-    frame->setNumber("lineNumber", m_lineNumber);
-    return frame;
-}
-#endif
-
 ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, unsigned li, const String& u, unsigned g)
     : m_source(s)
     , m_type(t)
@@ -85,35 +54,26 @@ ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, c
 {
 }
 
-ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, ScriptCallStack* callStack, unsigned g, bool storeTrace)
+ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack, unsigned g)
     : m_source(s)
     , m_type(t)
     , m_level(l)
     , m_message(m)
-#if ENABLE(INSPECTOR)
-    , m_arguments(callStack->at(0).argumentCount())
-    , m_scriptState(callStack->globalState())
-#endif
-    , m_frames(storeTrace ? callStack->size() : 0)
+    , m_arguments(arguments)
+    , m_callStack(callStack)
     , m_groupLevel(g)
     , m_repeatCount(1)
 {
-    const ScriptCallFrame& lastCaller = callStack->at(0);
+    const ScriptCallFrame& lastCaller = m_callStack->at(0);
     m_line = lastCaller.lineNumber();
     m_url = lastCaller.sourceURL();
 
-    if (storeTrace) {
-        for (unsigned i = 0; i < callStack->size(); ++i)
-            m_frames[i] = ConsoleMessage::CallFrame(callStack->at(i));
-    }
 
-#if ENABLE(INSPECTOR)
-    for (unsigned i = 0; i < lastCaller.argumentCount(); ++i)
-        m_arguments[i] = lastCaller.argumentAt(i);
-#endif
+    bool storeTrace = (t == TraceMessageType || t == UncaughtExceptionMessageType || t == AssertMessageType);
+    if (!storeTrace)
+        m_callStack.clear();
 }
 
-#if ENABLE(INSPECTOR)
 void ConsoleMessage::addToFrontend(InspectorFrontend* frontend, InjectedScriptHost* injectedScriptHost)
 {
     RefPtr<InspectorObject> jsonObj = InspectorObject::create();
@@ -125,12 +85,12 @@ void ConsoleMessage::addToFrontend(InspectorFrontend* frontend, InjectedScriptHo
     jsonObj->setNumber("groupLevel", static_cast<int>(m_groupLevel));
     jsonObj->setNumber("repeatCount", static_cast<int>(m_repeatCount));
     jsonObj->setString("message", m_message);
-    if (!m_arguments.isEmpty()) {
-        InjectedScript injectedScript = injectedScriptHost->injectedScriptFor(m_scriptState.get());
+    if (m_arguments && m_arguments->argumentCount()) {
+        InjectedScript injectedScript = injectedScriptHost->injectedScriptFor(m_arguments->globalState());
         if (!injectedScript.hasNoValue()) {
             RefPtr<InspectorArray> jsonArgs = InspectorArray::create();
-            for (unsigned i = 0; i < m_arguments.size(); ++i) {
-                RefPtr<InspectorValue> inspectorValue = injectedScript.wrapForConsole(m_arguments[i]);
+            for (unsigned i = 0; i < m_arguments->argumentCount(); ++i) {
+                RefPtr<InspectorValue> inspectorValue = injectedScript.wrapForConsole(m_arguments->argumentAt(i));
                 if (!inspectorValue) {
                     ASSERT_NOT_REACHED();
                     return;
@@ -140,12 +100,8 @@ void ConsoleMessage::addToFrontend(InspectorFrontend* frontend, InjectedScriptHo
             jsonObj->setArray("parameters", jsonArgs);
         }
     }
-    if (!m_frames.isEmpty()) {
-        RefPtr<InspectorArray> frames = InspectorArray::create();
-        for (unsigned i = 0; i < m_frames.size(); i++)
-            frames->pushObject(m_frames.at(i).buildInspectorObject());
-        jsonObj->setArray("stackTrace", frames);
-    }
+    if (m_callStack)
+        jsonObj->setArray("stackTrace", m_callStack->buildInspectorObject());
     frontend->addConsoleMessage(jsonObj);
 }
 
@@ -153,32 +109,20 @@ void ConsoleMessage::updateRepeatCountInConsole(InspectorFrontend* frontend)
 {
     frontend->updateConsoleMessageRepeatCount(m_repeatCount);
 }
-#endif // ENABLE(INSPECTOR)
 
 bool ConsoleMessage::isEqual(ConsoleMessage* msg) const
 {
-#if ENABLE(INSPECTOR)
-    if (msg->m_arguments.size() != m_arguments.size())
-        return false;
-    if (!msg->m_scriptState.get() && msg->m_arguments.size()) {
-        ASSERT_NOT_REACHED();
-        return false;
-    }
-
-    for (size_t i = 0; i < m_arguments.size(); ++i) {
-        if (!m_arguments[i].isEqual(msg->m_scriptState.get(), msg->m_arguments[i]))
+    if (m_arguments) {
+        if (!m_arguments->isEqual(msg->m_arguments.get()))
             return false;
-    }
-#endif // ENABLE(INSPECTOR)
-
-    size_t frameCount = msg->m_frames.size();
-    if (frameCount != m_frames.size())
+    } else if (msg->m_arguments)
         return false;
 
-    for (size_t i = 0; i < frameCount; ++i) {
-        if (!m_frames[i].isEqual(msg->m_frames[i]))
+    if (m_callStack) {
+        if (!m_callStack->isEqual(msg->m_callStack.get()))
             return false;
-    }
+    } else if (msg->m_callStack)
+        return false;
 
     return msg->m_source == m_source
         && msg->m_type == m_type
index 6c3f2c7..4e88bec 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
- * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2009, 2010 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #define ConsoleMessage_h
 
 #include "Console.h"
-#include "KURL.h"
 #include "ScriptState.h"
 
+#include <wtf/Forward.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
 class InjectedScriptHost;
 class InspectorFrontend;
 class InspectorObject;
+class ScriptArguments;
 class ScriptCallFrame;
 class ScriptCallStack;
 class ScriptValue;
@@ -48,12 +49,10 @@ class ScriptValue;
 class ConsoleMessage : public Noncopyable {
 public:
     ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, unsigned li, const String& u, unsigned g);
-    ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, ScriptCallStack*, unsigned g, bool storeTrace = false);
+    ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>, unsigned g);
 
-#if ENABLE(INSPECTOR)
     void addToFrontend(InspectorFrontend*, InjectedScriptHost*);
     void updateRepeatCountInConsole(InspectorFrontend* frontend);
-#endif
     void incrementCount() { ++m_repeatCount; }
     bool isEqual(ConsoleMessage* msg) const;
 
@@ -61,30 +60,12 @@ public:
     const String& message() const { return m_message; }
 
 private:
-    class CallFrame {
-    public:
-        explicit CallFrame(const ScriptCallFrame& frame);
-        CallFrame();
-        bool isEqual(const CallFrame& o) const;
-#if ENABLE(INSPECTOR)
-        PassRefPtr<InspectorObject> buildInspectorObject() const;
-#endif
-
-    private:
-        String m_functionName;
-        String m_sourceURL;
-        unsigned m_lineNumber;
-    };
-
     MessageSource m_source;
     MessageType m_type;
     MessageLevel m_level;
     String m_message;
-#if ENABLE(INSPECTOR)
-    Vector<ScriptValue> m_arguments;
-    ScriptStateProtectedPtr m_scriptState;
-#endif
-    Vector<CallFrame> m_frames;
+    OwnPtr<ScriptArguments> m_arguments;
+    OwnPtr<ScriptCallStack> m_callStack;
     unsigned m_line;
     String m_url;
     unsigned m_groupLevel;
index 00a1166..a0934cd 100644 (file)
@@ -82,6 +82,7 @@
 #include "RenderInline.h"
 #include "ResourceRequest.h"
 #include "ResourceResponse.h"
+#include "ScriptArguments.h"
 #include "ScriptCallStack.h"
 #include "ScriptFunctionCall.h"
 #include "ScriptObject.h"
@@ -339,13 +340,12 @@ void InspectorController::setConsoleMessagesEnabled(bool enabled)
         m_consoleMessages[i]->addToFrontend(m_frontend.get(), m_injectedScriptHost.get());
 }
 
-void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, ScriptCallStack* callStack, const String& message)
+void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, const String& message, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
     if (!enabled())
         return;
 
-    bool storeStackTrace = type == TraceMessageType || type == UncaughtExceptionMessageType || type == AssertMessageType;
-    addConsoleMessage(new ConsoleMessage(source, type, level, message, callStack, m_groupLevel, storeStackTrace));
+    addConsoleMessage(new ConsoleMessage(source, type, level, message, arguments, callStack, m_groupLevel));
 }
 
 void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceID)
@@ -391,11 +391,11 @@ void InspectorController::clearConsoleMessages()
         m_frontend->consoleMessagesCleared();
 }
 
-void InspectorController::startGroup(MessageSource source, ScriptCallStack* callStack, bool collapsed)
+void InspectorController::startGroup(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack, bool collapsed)
 {
     ++m_groupLevel;
 
-    addConsoleMessage(new ConsoleMessage(source, collapsed ? StartGroupCollapsedMessageType : StartGroupMessageType, LogMessageLevel, String(), callStack, m_groupLevel));
+    addConsoleMessage(new ConsoleMessage(JSMessageSource, collapsed ? StartGroupCollapsedMessageType : StartGroupMessageType, LogMessageLevel, "", arguments, callStack, m_groupLevel));
 }
 
 void InspectorController::endGroup(MessageSource source, unsigned lineNumber, const String& sourceURL)
index 6d4d9e0..68aa147 100644 (file)
@@ -81,6 +81,7 @@ class Page;
 class ResourceRequest;
 class ResourceResponse;
 class ResourceError;
+class ScriptArguments;
 class ScriptCallStack;
 class ScriptProfile;
 class SharedBuffer;
@@ -145,8 +146,8 @@ public:
     void disconnectFrontend();
 
     void setConsoleMessagesEnabled(bool enabled, bool* newState);
-    void addMessageToConsole(MessageSource, MessageType, MessageLevel, ScriptCallStack*, const String& message);
-    void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID);
+    void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>);
+    void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String&);
     void clearConsoleMessages();
     const Vector<OwnPtr<ConsoleMessage> >& consoleMessages() const { return m_consoleMessages; }
 
@@ -232,7 +233,7 @@ public:
     void startTiming(const String& title);
     bool stopTiming(const String& title, double& elapsed);
 
-    void startGroup(MessageSource source, ScriptCallStack* callFrame, bool collapsed = false);
+    void startGroup(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack> callFrame, bool collapsed = false);
     void endGroup(MessageSource source, unsigned lineNumber, const String& sourceURL);
 
     void markTimeline(const String& message);
diff --git a/WebCore/inspector/ScriptArguments.cpp b/WebCore/inspector/ScriptArguments.cpp
new file mode 100644 (file)
index 0000000..e30e135
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2010 Google Inc. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ScriptArguments.h"
+
+#include "ScriptValue.h"
+
+namespace WebCore {
+
+ScriptArguments::ScriptArguments(ScriptState* scriptState, Vector<ScriptValue>& arguments)
+    : m_scriptState(scriptState)
+{
+    m_arguments.swap(arguments);
+}
+
+ScriptArguments::~ScriptArguments()
+{
+}
+
+const ScriptValue &ScriptArguments::argumentAt(size_t index) const
+{
+    ASSERT(m_arguments.size() > index);
+    return m_arguments[index];
+}
+
+ScriptState* ScriptArguments::globalState() const
+{
+    return m_scriptState.get();
+}
+
+bool ScriptArguments::getFirstArgumentAsString(String& result, bool checkForNullOrUndefined)
+{
+    if (!argumentCount())
+        return false;
+
+    const ScriptValue& value = argumentAt(0);
+    if (checkForNullOrUndefined && (value.isNull() || value.isUndefined()))
+        return false;
+
+    if (!globalState()) {
+        ASSERT_NOT_REACHED();
+        return false;
+    }
+
+    result = value.toString(globalState());
+    return true;
+}
+
+bool ScriptArguments::isEqual(ScriptArguments* other) const
+{
+    if (!other)
+        return false;
+
+    if (m_arguments.size() != other->m_arguments.size())
+        return false;
+    if (!globalState() && m_arguments.size())
+        return false;
+
+    for (size_t i = 0; i < m_arguments.size(); ++i) {
+        if (!m_arguments[i].isEqual(other->globalState(), other->m_arguments[i]))
+            return false;
+    }
+    return true;
+}
+
+} // namespace WebCore
diff --git a/WebCore/inspector/ScriptArguments.h b/WebCore/inspector/ScriptArguments.h
new file mode 100644 (file)
index 0000000..fdf05ab
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2010 Google Inc. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ScriptArguments_h
+#define ScriptArguments_h
+
+#include "PlatformString.h"
+#include "ScriptState.h"
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class ScriptValue;
+
+class ScriptArguments {
+public:
+    ScriptArguments(ScriptState*, Vector<ScriptValue>& arguments);
+    ~ScriptArguments();
+
+    const ScriptValue& argumentAt(size_t) const;
+    size_t argumentCount() const { return m_arguments.size(); }
+
+    ScriptState* globalState() const;
+
+    bool getFirstArgumentAsString(WTF::String& result, bool checkForNullOrUndefined = false);
+    bool isEqual(ScriptArguments*) const;
+
+private:
+    ScriptStateProtectedPtr m_scriptState;
+    Vector<ScriptValue> m_arguments;
+};
+
+} // namespace WebCore
+
+#endif // ScriptArguments_h
similarity index 71%
rename from WebCore/bindings/v8/ScriptCallFrame.cpp
rename to WebCore/inspector/ScriptCallFrame.cpp
index f0c7343..5455d25 100644 (file)
@@ -1,10 +1,10 @@
 /*
- * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
- *
+ * Copyright (c) 2010 Google Inc. All rights reserved.
+ * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
  * met:
- *
+ * 
  *     * Redistributions of source code must retain the above copyright
  * notice, this list of conditions and the following disclaimer.
  *     * Redistributions in binary form must reproduce the above
 #include "config.h"
 #include "ScriptCallFrame.h"
 
-#include <v8.h>
-
-#include "PlatformString.h"
-#include "V8Binding.h"
-#include "V8Proxy.h"
-#include "ScriptValue.h"
+#include "InspectorValues.h"
+#include <wtf/RefPtr.h>
 
 namespace WebCore {
 
-ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber, const v8::Arguments& arguments, unsigned skipArgumentCount)
+ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, unsigned lineNumber)
     : m_functionName(functionName)
     , m_sourceURL(urlString)
     , m_lineNumber(lineNumber)
 {
-    for (int i = skipArgumentCount; i < arguments.Length(); ++i)
-        m_arguments.append(ScriptValue(arguments[i]));
 }
 
-ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber)
-    : m_functionName(functionName)
-    , m_sourceURL(urlString)
-    , m_lineNumber(lineNumber)
+ScriptCallFrame::~ScriptCallFrame()
 {
 }
 
-ScriptCallFrame::~ScriptCallFrame()
+bool ScriptCallFrame::isEqual(const ScriptCallFrame& o) const
 {
+    return m_functionName == o.m_functionName
+        && m_sourceURL == o.m_sourceURL
+        && m_lineNumber == o.m_lineNumber;
 }
 
-const ScriptValue& ScriptCallFrame::argumentAt(unsigned index) const
+PassRefPtr<InspectorObject> ScriptCallFrame::buildInspectorObject() const
 {
-    ASSERT(m_arguments.size() > index);
-    return m_arguments[index];
+    RefPtr<InspectorObject> frame = InspectorObject::create();
+    frame->setString("functionName", m_functionName);
+    frame->setString("sourceURL", m_sourceURL);
+    frame->setNumber("lineNumber", m_lineNumber);
+    return frame;
 }
 
 } // namespace WebCore
similarity index 80%
rename from WebCore/bindings/js/ScriptCallFrame.h
rename to WebCore/inspector/ScriptCallFrame.h
index 31aec7e..60d77e1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Google Inc. All rights reserved.
+ * Copyright (c) 2010 Google Inc. All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
 #define ScriptCallFrame_h
 
 #include "PlatformString.h"
-#include "ScriptValue.h"
-#include <wtf/Vector.h>
-
-namespace JSC {
-class ExecState;
-class UString;
-}
+#include <wtf/PassRefPtr.h>
 
 namespace WebCore {
 
+class InspectorObject;
+
 class ScriptCallFrame  {
 public:
-    ScriptCallFrame(const JSC::UString& functionName, const JSC::UString& urlString, int lineNumber, JSC::ExecState*, unsigned skipArgumentCount);
+    ScriptCallFrame(const String& functionName, const String& urlString, unsigned lineNumber);
     ~ScriptCallFrame();
 
     const String& functionName() const { return m_functionName; }
     const String& sourceURL() const { return m_sourceURL; }
     unsigned lineNumber() const { return m_lineNumber; }
 
-    // argument retrieval methods
-    const ScriptValue& argumentAt(unsigned) const;
-    unsigned argumentCount() const { return m_arguments.size(); }
+    bool isEqual(const ScriptCallFrame&) const;
+    PassRefPtr<InspectorObject> buildInspectorObject() const;
 
 private:
     String m_functionName;
     String m_sourceURL;
     unsigned m_lineNumber;
-
-    Vector<ScriptValue> m_arguments;
 };
 
 } // namespace WebCore
diff --git a/WebCore/inspector/ScriptCallStack.cpp b/WebCore/inspector/ScriptCallStack.cpp
new file mode 100644 (file)
index 0000000..8d010bb
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2008, Google Inc. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ScriptCallStack.h"
+
+#include "InspectorValues.h"
+
+namespace WebCore {
+
+ScriptCallStack::ScriptCallStack(Vector<ScriptCallFrame>& frames)
+{
+    m_frames.swap(frames);
+}
+
+ScriptCallStack::~ScriptCallStack()
+{
+}
+
+const ScriptCallFrame &ScriptCallStack::at(size_t index)
+{
+    ASSERT(m_frames.size() > index);
+    return m_frames[index];
+}
+
+size_t ScriptCallStack::size()
+{
+    return m_frames.size();
+}
+
+bool ScriptCallStack::isEqual(ScriptCallStack* o) const
+{
+    if (!o)
+        return false;
+
+    size_t frameCount = o->m_frames.size();
+    if (frameCount != m_frames.size())
+        return false;
+
+    for (size_t i = 0; i < frameCount; ++i) {
+        if (!m_frames[i].isEqual(o->m_frames[i]))
+            return false;
+    }
+
+    return true;
+}
+
+PassRefPtr<InspectorArray> ScriptCallStack::buildInspectorObject() const
+{
+    RefPtr<InspectorArray> frames = InspectorArray::create();
+    for (size_t i = 0; i < m_frames.size(); i++)
+        frames->pushObject(m_frames.at(i).buildInspectorObject());
+    return frames;
+}
+
+} // namespace WebCore
similarity index 66%
rename from WebCore/bindings/js/ScriptCallStack.h
rename to WebCore/inspector/ScriptCallStack.h
index 17d1c46..54c6bba 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Google Inc. All rights reserved.
+ * Copyright (c) 2008, 2010 Google Inc. All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
 #define ScriptCallStack_h
 
 #include "ScriptCallFrame.h"
-#include "ScriptState.h"
 #include <wtf/Noncopyable.h>
-#include <wtf/RefPtr.h>
-
-namespace JSC {
-    class ExecState;
-    class JSValue;
-}
+#include <wtf/Vector.h>
 
 namespace WebCore {
 
-    class InspectorArray;
+class InspectorArray;
+
+class ScriptCallStack : public Noncopyable {
+public:
+    static const size_t maxCallStackSizeToCapture = 200;
 
-    class ScriptCallStack : public Noncopyable {
-    public:
-        ScriptCallStack(JSC::ExecState*, unsigned skipArgumentCount = 0);
-        ~ScriptCallStack();
+    ScriptCallStack(Vector<ScriptCallFrame>&);
+    ~ScriptCallStack();
 
-        ScriptState* state() const { return m_exec; }
-        ScriptState* globalState() const { return m_exec->lexicalGlobalObject()->globalExec(); }
-        // frame retrieval methods
-        const ScriptCallFrame &at(unsigned);
-        unsigned size();
-        static bool stackTrace(int, const RefPtr<InspectorArray>&);
+    const ScriptCallFrame &at(size_t);
+    size_t size();
+    static bool stackTrace(int, const RefPtr<InspectorArray>&);
 
-    private:
-        void initialize();
-        bool m_initialized;
+    bool isEqual(ScriptCallStack*) const;
+    PassRefPtr<InspectorArray> buildInspectorObject() const;
 
-        JSC::ExecState* m_exec;
-        Vector<ScriptCallFrame> m_frames;
-        JSC::JSFunction* m_caller;
-    };
+private:
+    Vector<ScriptCallFrame> m_frames;
+};
 
 } // namespace WebCore
 
index 2d4cc98..6fbf253 100644 (file)
@@ -41,6 +41,7 @@
 #include "PageGroup.h"
 #include "PlatformString.h"
 
+#include "ScriptArguments.h"
 #include "ScriptCallStack.h"
 #include "ScriptProfile.h"
 #include "ScriptProfiler.h"
@@ -77,19 +78,6 @@ static void printSourceURLAndLine(const String& sourceURL, unsigned lineNumber)
     }
 }
 
-static bool getFirstArgumentAsString(ScriptState* scriptState, const ScriptCallFrame& callFrame, String& result, bool checkForNullOrUndefined = false)
-{
-    if (!callFrame.argumentCount())
-        return false;
-
-    const ScriptValue& value = callFrame.argumentAt(0);
-    if (checkForNullOrUndefined && (value.isNull() || value.isUndefined()))
-        return false;
-
-    result = value.toString(scriptState);
-    return true;
-}
-
 static void printMessageSourceAndLevelPrefix(MessageSource source, MessageLevel level)
 {
     const char* sourceString;
@@ -144,7 +132,12 @@ static void printMessageSourceAndLevelPrefix(MessageSource source, MessageLevel
     printf("%s %s:", sourceString, levelString);
 }
 
-void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, ScriptCallStack* callStack)
+void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL)
+{
+    addMessage(source, type, level, message, lineNumber, sourceURL, 0);
+}
+
+void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, PassOwnPtr<ScriptCallStack> callStack)
 {
     Page* page = this->page();
     if (!page)
@@ -155,7 +148,7 @@ void Console::addMessage(MessageSource source, MessageType type, MessageLevel le
 
 #if ENABLE(INSPECTOR)
     if (callStack)
-        page->inspectorController()->addMessageToConsole(source, type, level, callStack, message);
+        page->inspectorController()->addMessageToConsole(source, type, level, message, 0, callStack);
     else
         page->inspectorController()->addMessageToConsole(source, type, level, message, lineNumber, sourceURL);
 #endif
@@ -169,7 +162,7 @@ void Console::addMessage(MessageSource source, MessageType type, MessageLevel le
     printf(" %s\n", message.utf8().data());
 }
 
-void Console::addMessage(MessageType type, MessageLevel level, ScriptCallStack* callStack, bool acceptNoArguments)
+void Console::addMessage(MessageType type, MessageLevel level, PassOwnPtr<ScriptArguments> arguments,  PassOwnPtr<ScriptCallStack> callStack, bool acceptNoArguments)
 {
     Page* page = this->page();
     if (!page)
@@ -177,15 +170,15 @@ void Console::addMessage(MessageType type, MessageLevel level, ScriptCallStack*
 
     const ScriptCallFrame& lastCaller = callStack->at(0);
 
-    if (!acceptNoArguments && !lastCaller.argumentCount())
+    if (!acceptNoArguments && !arguments->argumentCount())
         return;
 
     String message;
-    if (getFirstArgumentAsString(callStack->state(), lastCaller, message))
+    if (arguments->getFirstArgumentAsString(message))
         page->chrome()->client()->addMessageToConsole(JSMessageSource, type, level, message, lastCaller.lineNumber(), lastCaller.sourceURL());
 
 #if ENABLE(INSPECTOR)
-    page->inspectorController()->addMessageToConsole(JSMessageSource, type, level, callStack, message);
+    page->inspectorController()->addMessageToConsole(JSMessageSource, type, level, "", arguments, callStack);
 #endif
 
     if (!Console::shouldPrintExceptions())
@@ -194,49 +187,49 @@ void Console::addMessage(MessageType type, MessageLevel level, ScriptCallStack*
     printSourceURLAndLine(lastCaller.sourceURL(), 0);
     printMessageSourceAndLevelPrefix(JSMessageSource, level);
 
-    for (unsigned i = 0; i < lastCaller.argumentCount(); ++i) {
+    for (unsigned i = 0; i < arguments->argumentCount(); ++i) {
         String argAsString;
-        if (lastCaller.argumentAt(i).getString(callStack->state(), argAsString))
+        if (arguments->argumentAt(i).getString(arguments->globalState(), argAsString))
             printf(" %s", argAsString.utf8().data());
     }
     printf("\n");
 }
 
-void Console::debug(ScriptCallStack* callStack)
+void Console::debug(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
     // In Firebug, console.debug has the same behavior as console.log. So we'll do the same.
-    log(callStack);
+    log(arguments, callStack);
 }
 
-void Console::error(ScriptCallStack* callStack)
+void Console::error(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
-    addMessage(LogMessageType, ErrorMessageLevel, callStack);
+    addMessage(LogMessageType, ErrorMessageLevel, arguments, callStack);
 }
 
-void Console::info(ScriptCallStack* callStack)
+void Console::info(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
-    log(callStack);
+    log(arguments, callStack);
 }
 
-void Console::log(ScriptCallStack* callStack)
+void Console::log(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
-    addMessage(LogMessageType, LogMessageLevel, callStack);
+    addMessage(LogMessageType, LogMessageLevel, arguments, callStack);
 }
 
-void Console::dir(ScriptCallStack* callStack)
+void Console::dir(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
-    addMessage(ObjectMessageType, LogMessageLevel, callStack);
+    addMessage(ObjectMessageType, LogMessageLevel, arguments, callStack);
 }
 
-void Console::dirxml(ScriptCallStack* callStack)
+void Console::dirxml(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
     // The standard behavior of our console.log will print the DOM tree for nodes.
-    log(callStack);
+    log(arguments, callStack);
 }
 
-void Console::trace(ScriptCallStack* callStack)
+void Console::trace(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
-    addMessage(TraceMessageType, LogMessageLevel, callStack, true);
+    addMessage(TraceMessageType, LogMessageLevel, arguments, callStack, true);
 
     if (!shouldPrintExceptions())
         return;
@@ -248,15 +241,15 @@ void Console::trace(ScriptCallStack* callStack)
     }
 }
 
-void Console::assertCondition(bool condition, ScriptCallStack* callStack)
+void Console::assertCondition(bool condition, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
     if (condition)
         return;
 
-    addMessage(AssertMessageType, ErrorMessageLevel, callStack, true);
+    addMessage(AssertMessageType, ErrorMessageLevel, arguments, callStack, true);
 }
 
-void Console::count(ScriptCallStack* callStack)
+void Console::count(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
 #if ENABLE(INSPECTOR)
     Page* page = this->page();
@@ -267,7 +260,7 @@ void Console::count(ScriptCallStack* callStack)
     // Follow Firebug's behavior of counting with null and undefined title in
     // the same bucket as no argument
     String title;
-    getFirstArgumentAsString(callStack->state(), lastCaller, title);
+    arguments->getFirstArgumentAsString(title);
 
     page->inspectorController()->count(title, lastCaller.lineNumber(), lastCaller.sourceURL());
 #else
@@ -275,20 +268,19 @@ void Console::count(ScriptCallStack* callStack)
 #endif
 }
 
-void Console::markTimeline(ScriptCallStack* callStack)
+void Console::markTimeline(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>)
 {
 #if ENABLE(INSPECTOR)
     Page* page = this->page();
     if (!page)
         return;
 
-    const ScriptCallFrame& lastCaller = callStack->at(0);
     String message;
-    getFirstArgumentAsString(callStack->state(), lastCaller, message);
+    arguments->getFirstArgumentAsString(message);
 
     page->inspectorController()->markTimeline(message);
 #else
-    UNUSED_PARAM(callStack);
+    UNUSED_PARAM(arguments);
 #endif
 }
 
@@ -321,7 +313,7 @@ String Console::lastWMLErrorMessage() const
 
 #if ENABLE(JAVASCRIPT_DEBUGGER)
 
-void Console::profile(const String& title, ScriptCallStack* callStack)
+void Console::profile(const String& title, ScriptState* state, PassOwnPtr<ScriptCallStack> callStack)
 {
     Page* page = this->page();
     if (!page)
@@ -342,7 +334,7 @@ void Console::profile(const String& title, ScriptCallStack* callStack)
         resolvedTitle = "";
 #endif
 
-    ScriptProfiler::start(callStack->state(), resolvedTitle);
+    ScriptProfiler::start(state, resolvedTitle);
 
 #if ENABLE(INSPECTOR)
     const ScriptCallFrame& lastCaller = callStack->at(0);
@@ -350,7 +342,7 @@ void Console::profile(const String& title, ScriptCallStack* callStack)
 #endif
 }
 
-void Console::profileEnd(const String& title, ScriptCallStack* callStack)
+void Console::profileEnd(const String& title, ScriptState* state, PassOwnPtr<ScriptCallStack> callStack)
 {
     Page* page = this->page();
     if (!page)
@@ -362,7 +354,7 @@ void Console::profileEnd(const String& title, ScriptCallStack* callStack)
         return;
 #endif
 
-    RefPtr<ScriptProfile> profile = ScriptProfiler::stop(callStack->state(), title);
+    RefPtr<ScriptProfile> profile = ScriptProfiler::stop(state, title);
     if (!profile)
         return;
 
@@ -394,7 +386,7 @@ void Console::time(const String& title)
 #endif
 }
 
-void Console::timeEnd(const String& title, ScriptCallStack* callStack)
+void Console::timeEnd(const String& title, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack> callStack)
 {
 #if ENABLE(INSPECTOR)
     Page* page = this->page();
@@ -420,28 +412,30 @@ void Console::timeEnd(const String& title, ScriptCallStack* callStack)
 #endif
 }
 
-void Console::group(ScriptCallStack* callStack)
+void Console::group(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
 #if ENABLE(INSPECTOR)
     Page* page = this->page();
     if (!page)
         return;
 
-    page->inspectorController()->startGroup(JSMessageSource, callStack);
+    page->inspectorController()->startGroup(arguments, callStack);
 #else
+    UNUSED_PARAM(arguments);
     UNUSED_PARAM(callStack);
 #endif
 }
 
-void Console::groupCollapsed(ScriptCallStack* callStack)
+void Console::groupCollapsed(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
 #if ENABLE(INSPECTOR)
     Page* page = this->page();
     if (!page)
         return;
 
-    page->inspectorController()->startGroup(JSMessageSource, callStack, true);
+    page->inspectorController()->startGroup(arguments, callStack, true);
 #else
+    UNUSED_PARAM(arguments);
     UNUSED_PARAM(callStack);
 #endif
 }
@@ -457,9 +451,22 @@ void Console::groupEnd()
 #endif
 }
 
-void Console::warn(ScriptCallStack* callStack)
+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(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
 {
-    addMessage(LogMessageType, WarningMessageLevel, callStack);
+    addMessage(LogMessageType, WarningMessageLevel, arguments, callStack);
 }
 
 MemoryInfo* Console::memory() const
index ab62525..92fee59 100644 (file)
@@ -32,6 +32,7 @@
 #include "MemoryInfo.h"
 #include "PlatformString.h"
 #include "ScriptProfile.h"
+#include "ScriptState.h"
 
 #include <wtf/Forward.h>
 #include <wtf/PassRefPtr.h>
@@ -39,6 +40,8 @@
 
 namespace WebCore {
 
+class ScriptArguments;
+
 #if ENABLE(JAVASCRIPT_DEBUGGER)
 typedef Vector<RefPtr<ScriptProfile> > ProfilesArray;
 #endif
@@ -83,44 +86,44 @@ public:
     Frame* frame() const;
     void disconnectFrame();
 
-    void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, ScriptCallStack* callStack = 0);
-
-    void debug(ScriptCallStack*);
-    void error(ScriptCallStack*);
-    void info(ScriptCallStack*);
-    void log(ScriptCallStack*);
-    void warn(ScriptCallStack*);
-    void dir(ScriptCallStack*);
-    void dirxml(ScriptCallStack*);
-    void trace(ScriptCallStack*);
-    void assertCondition(bool condition, ScriptCallStack*);
-    void count(ScriptCallStack*);
-    void markTimeline(ScriptCallStack*);
+    void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL);
+    void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, PassOwnPtr<ScriptCallStack> callStack);
+
+    void debug(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void error(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void info(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void log(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void warn(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void dir(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void dirxml(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void trace(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void assertCondition(bool condition, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void count(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void markTimeline(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
 #if ENABLE(WML)
     String lastWMLErrorMessage() const;
 #endif
 #if ENABLE(JAVASCRIPT_DEBUGGER)
-    void profile(const String&, ScriptCallStack*);
-    void profileEnd(const String&, ScriptCallStack*);
+    const ProfilesArray& profiles() const { return m_profiles; }
+    void profile(const String&, ScriptState*, PassOwnPtr<ScriptCallStack>);
+    void profileEnd(const String&, ScriptState*, PassOwnPtr<ScriptCallStack>);
 #endif
     void time(const String&);
-    void timeEnd(const String&, ScriptCallStack*);
-    void group(ScriptCallStack*);
-    void groupCollapsed(ScriptCallStack*);
+    void timeEnd(const String&, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void group(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
+    void groupCollapsed(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
     void groupEnd();
 
+    bool shouldCaptureFullStackTrace() const;
+
     static bool shouldPrintExceptions();
     static void setShouldPrintExceptions(bool);
 
-#if ENABLE(JAVASCRIPT_DEBUGGER)
-    const ProfilesArray& profiles() const { return m_profiles; }
-#endif
-
     MemoryInfo* memory() const;
 
 private:
     inline Page* page() const;
-    void addMessage(MessageType, MessageLevel, ScriptCallStack*, bool acceptNoArguments = false);
+    void addMessage(MessageType, MessageLevel, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>, bool acceptNoArguments = false);
 
     Console(Frame*);
 
index 52528f1..9f03911 100644 (file)
@@ -30,10 +30,6 @@ module window {
 
     interface [OmitConstructor] Console {
 
-#if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER
-        readonly attribute [CustomGetter] Array profiles;
-#endif
-    
         [CustomArgumentHandling] void debug();
         [CustomArgumentHandling] void error();
         [CustomArgumentHandling] void info();
@@ -51,8 +47,9 @@ module window {
 #endif
 
 #if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER
-        [CustomArgumentHandling] void profile(in [ConvertUndefinedOrNullToNullString] DOMString title);
-        [CustomArgumentHandling] void profileEnd(in [ConvertUndefinedOrNullToNullString] DOMString title);
+        readonly attribute [CustomGetter] Array profiles;
+        [Custom] void profile(in DOMString title);
+        [Custom] void profileEnd(in DOMString title);
 #endif
 
         void time(in [ConvertUndefinedOrNullToNullString] DOMString title);