Changeset 70232 in webkit


Ignore:
Timestamp:
Oct 21, 2010 5:31:37 AM (13 years ago)
Author:
yurys@chromium.org
Message:

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:
Location:
trunk/WebCore
Files:
2 deleted
26 edited
4 copied
6 moved

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/Android.jscbindings.mk

    r70047 r70232  
    167167        bindings/js/ScriptArray.cpp \
    168168        bindings/js/ScriptCachedFrameData.cpp \
    169         bindings/js/ScriptCallFrame.cpp \
    170         bindings/js/ScriptCallStack.cpp \
     169        bindings/js/ScriptCallStackFactory.cpp \
    171170        bindings/js/ScriptController.cpp \
    172171        bindings/js/ScriptEventListener.cpp \
  • trunk/WebCore/Android.v8bindings.mk

    r69148 r70232  
    5050        bindings/v8/ScopedDOMDataStore.cpp \
    5151        bindings/v8/ScriptArray.cpp \
    52         bindings/v8/ScriptCallFrame.cpp \
    53         bindings/v8/ScriptCallStack.cpp \
     52        bindings/v8/ScriptCallStackFactory.cpp \
    5453        bindings/v8/ScriptController.cpp \
    5554        bindings/v8/ScriptEventListener.cpp \
  • trunk/WebCore/CMakeLists.txt

    r70140 r70232  
    687687    bindings/js/ScheduledAction.cpp
    688688    bindings/js/ScriptCachedFrameData.cpp
    689     bindings/js/ScriptCallFrame.cpp
    690     bindings/js/ScriptCallStack.cpp
     689    bindings/js/ScriptCallStackFactory.cpp
    691690    bindings/js/ScriptController.cpp
    692691    bindings/js/ScriptDebugServer.cpp
     
    11241123    inspector/InspectorStorageAgent.cpp
    11251124    inspector/InspectorTimelineAgent.cpp
     1125    inspector/ScriptArguments.cpp
    11261126    inspector/ScriptBreakpoint.cpp
     1127    inspector/ScriptCallFrame.cpp
     1128    inspector/ScriptCallStack.cpp
    11271129    inspector/TimelineRecordFactory.cpp
    11281130
  • trunk/WebCore/ChangeLog

    r70231 r70232  
     12010-10-21  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: decouple ScriptArguments from ScriptCallStack
     6        https://bugs.webkit.org/show_bug.cgi?id=48058
     7
     8        ScriptCallFrame and ScriptCallStack are now the same for both JSC and V8.
     9        The factory functions that allow to create ScriptCallStack from VM-specific
     10        objects are defined in ScriptCallStackFactory.cpp.
     11
     12        ScriptArguments class is used for passing arguments from JS code to the native
     13        part.
     14
     15        No new tests. This refactoring is covered with existing Console tests.
     16
     17        * WebCore.gypi:
     18        * WebCore.xcodeproj/project.pbxproj:
     19        * bindings/js/ScriptCallFrame.cpp: Removed.
     20        * bindings/js/ScriptCallFrame.h: Removed.
     21        * bindings/js/ScriptCallStack.cpp: Removed.
     22        * bindings/js/ScriptCallStack.h: Removed.
     23        * bindings/js/ScriptCallStackFactory.cpp: Added.
     24        (WebCore::createScriptCallStack):
     25        (WebCore::createScriptArguments):
     26        (WebCore::ScriptCallStack::stackTrace):
     27        * bindings/js/ScriptCallStackFactory.h: Added.
     28        * bindings/js/ScriptState.h:
     29        (WebCore::ScriptStateProtectedPtr::get):
     30        * bindings/scripts/CodeGeneratorJS.pm:
     31        * bindings/scripts/CodeGeneratorV8.pm:
     32        * bindings/v8/ScriptCallFrame.cpp: Removed.
     33        * bindings/v8/ScriptCallFrame.h: Removed.
     34        * bindings/v8/ScriptCallStack.cpp: Removed.
     35        * bindings/v8/ScriptCallStack.h: Removed.
     36        * bindings/v8/ScriptCallStackFactory.cpp: Added.
     37        (WebCore::toScriptCallFrame):
     38        (WebCore::toScriptCallFramesVector):
     39        (WebCore::createScriptCallStack):
     40        (WebCore::createScriptArguments):
     41        (WebCore::ScriptCallStack::stackTrace):
     42        * bindings/v8/ScriptCallStackFactory.h: Added.
     43        * bindings/v8/ScriptController.cpp:
     44        (WebCore::ScriptController::setCaptureCallStackForUncaughtExceptions):
     45        * bindings/v8/ScriptState.h:
     46        (WebCore::ScriptStateProtectedPtr::get):
     47        * bindings/v8/V8ConsoleMessage.cpp:
     48        (WebCore::V8ConsoleMessage::handler):
     49        (WebCore::V8ConsoleMessage::dispatchNow):
     50        * bindings/v8/V8ConsoleMessage.h:
     51        * bindings/v8/custom/V8ConsoleCustom.cpp:
     52        (WebCore::V8Console::traceCallback):
     53        (WebCore::V8Console::assertCallback):
     54        * inspector/ConsoleMessage.cpp:
     55        (WebCore::ConsoleMessage::ConsoleMessage):
     56        (WebCore::ConsoleMessage::addToFrontend):
     57        (WebCore::ConsoleMessage::updateRepeatCountInConsole):
     58        (WebCore::ConsoleMessage::isEqual):
     59        * inspector/ConsoleMessage.h:
     60        * inspector/InspectorController.cpp:
     61        (WebCore::InspectorController::addMessageToConsole):
     62        (WebCore::InspectorController::startGroup):
     63        * inspector/InspectorController.h:
     64        * inspector/ScriptArguments.cpp: Added.
     65        (WebCore::ScriptArguments::ScriptArguments):
     66        (WebCore::ScriptArguments::~ScriptArguments):
     67        (WebCore::ScriptArguments::argumentAt):
     68        (WebCore::ScriptArguments::globalState):
     69        (WebCore::ScriptArguments::getFirstArgumentAsString):
     70        (WebCore::ScriptArguments::isEqual):
     71        * inspector/ScriptArguments.h: Added.
     72        (WebCore::ScriptArguments::argumentCount):
     73        * inspector/ScriptCallFrame.cpp: Added.
     74        (WebCore::ScriptCallFrame::ScriptCallFrame):
     75        (WebCore::ScriptCallFrame::~ScriptCallFrame):
     76        (WebCore::ScriptCallFrame::isEqual):
     77        (WebCore::ScriptCallFrame::buildInspectorObject):
     78        * inspector/ScriptCallFrame.h: Added.
     79        (WebCore::ScriptCallFrame::functionName):
     80        (WebCore::ScriptCallFrame::sourceURL):
     81        (WebCore::ScriptCallFrame::lineNumber):
     82        * inspector/ScriptCallStack.cpp: Added.
     83        (WebCore::ScriptCallStack::ScriptCallStack):
     84        (WebCore::ScriptCallStack::~ScriptCallStack):
     85        (WebCore::ScriptCallStack::at):
     86        (WebCore::ScriptCallStack::size):
     87        (WebCore::ScriptCallStack::isEqual):
     88        (WebCore::ScriptCallStack::buildInspectorObject):
     89        * inspector/ScriptCallStack.h: Added.
     90        * page/Console.cpp:
     91        (WebCore::Console::addMessage):
     92        (WebCore::Console::debug):
     93        (WebCore::Console::error):
     94        (WebCore::Console::info):
     95        (WebCore::Console::log):
     96        (WebCore::Console::dir):
     97        (WebCore::Console::dirxml):
     98        (WebCore::Console::trace):
     99        (WebCore::Console::assertCondition):
     100        (WebCore::Console::count):
     101        (WebCore::Console::markTimeline):
     102        (WebCore::Console::profile):
     103        (WebCore::Console::profileEnd):
     104        (WebCore::Console::timeEnd):
     105        (WebCore::Console::group):
     106        (WebCore::Console::groupCollapsed):
     107        (WebCore::Console::shouldCaptureFullStackTrace):
     108        (WebCore::Console::warn):
     109        * page/Console.h:
     110
    11112010-10-21  Pavel Feldman  <pfeldman@chromium.org>
    2112
  • trunk/WebCore/GNUmakefile.am

    r70223 r70232  
    817817        WebCore/bindings/js/ScriptCachedFrameData.cpp \
    818818        WebCore/bindings/js/ScriptCachedFrameData.h \
    819         WebCore/bindings/js/ScriptCallFrame.cpp \
    820         WebCore/bindings/js/ScriptCallFrame.h \
    821         WebCore/bindings/js/ScriptCallStack.cpp \
    822         WebCore/bindings/js/ScriptCallStack.h \
     819        WebCore/bindings/js/ScriptCallStackFactory.cpp \
     820        WebCore/bindings/js/ScriptCallStackFactory.h \
    823821        WebCore/bindings/js/ScriptController.cpp \
    824822        WebCore/bindings/js/ScriptController.h \
     
    18521850        WebCore/inspector/InspectorValues.h \
    18531851        WebCore/inspector/InspectorWorkerResource.h \
     1852        WebCore/inspector/ScriptArguments.cpp \
     1853        WebCore/inspector/ScriptArguments.h \
    18541854        WebCore/inspector/ScriptBreakpoint.cpp \
    18551855        WebCore/inspector/ScriptBreakpoint.h \
     1856        WebCore/inspector/ScriptCallFrame.cpp \
     1857        WebCore/inspector/ScriptCallFrame.h \
     1858        WebCore/inspector/ScriptCallStack.cpp \
     1859        WebCore/inspector/ScriptCallStack.h \
    18561860        WebCore/inspector/ScriptDebugListener.h \
    18571861        WebCore/inspector/ScriptGCEventListener.h \
  • trunk/WebCore/WebCore.gypi

    r70223 r70232  
    700700            'bindings/js/ScriptCachedFrameData.cpp',
    701701            'bindings/js/ScriptCachedFrameData.h',
    702             'bindings/js/ScriptCallFrame.cpp',
    703             'bindings/js/ScriptCallFrame.h',
    704             'bindings/js/ScriptCallStack.cpp',
    705             'bindings/js/ScriptCallStack.h',
    706702            'bindings/js/ScriptController.cpp',
    707703            'bindings/js/ScriptController.h',
     
    870866            'bindings/v8/ScopedDOMDataStore.h',
    871867            'bindings/v8/ScriptCachedFrameData.h',
    872             'bindings/v8/ScriptCallFrame.cpp',
    873             'bindings/v8/ScriptCallFrame.h',
    874             'bindings/v8/ScriptCallStack.cpp',
    875             'bindings/v8/ScriptCallStack.h',
     868            'bindings/v8/ScriptCallStackFactory.cpp',
     869            'bindings/v8/ScriptCallStackFactory.h',
    876870            'bindings/v8/ScriptController.cpp',
    877871            'bindings/v8/ScriptController.h',
     
    19541948            'inspector/ScriptBreakpoint.cpp',
    19551949            'inspector/ScriptBreakpoint.h',
     1950            'inspector/ScriptArguments.cpp',
     1951            'inspector/ScriptArguments.h',
     1952            'inspector/ScriptCallFrame.cpp',
     1953            'inspector/ScriptCallFrame.h',
     1954            'inspector/ScriptCallStack.cpp',
     1955            'inspector/ScriptCallStack.h',
    19561956            'inspector/ScriptDebugListener.h',
    19571957            'inspector/ScriptGCEventListener.h',
  • trunk/WebCore/WebCore.pro

    r70223 r70232  
    352352#        bindings/v8/ScriptArray.cpp \
    353353        bindings/v8/ScriptCachedFrameData.cpp \
    354         bindings/v8/ScriptCallFrame.cpp \
    355         bindings/v8/ScriptCallStack.cpp \
     354        bindings/v8/ScriptCallStackFactory.cpp \
    356355        bindings/ScriptControllerBase.cpp \
    357356        bindings/v8/ScriptController.cpp \
     
    575574        bindings/js/JSWorkerContextErrorHandler.cpp \
    576575        bindings/js/ScriptCachedFrameData.cpp \
    577         bindings/js/ScriptCallFrame.cpp \
    578         bindings/js/ScriptCallStack.cpp \
     576        bindings/js/ScriptCallStackFactory.cpp \
    579577        bindings/js/ScriptController.cpp \
    580578        bindings/js/ScriptDebugServer.cpp \
     
    10131011    inspector/InspectorTimelineAgent.cpp \
    10141012    inspector/InspectorValues.cpp \
     1013    inspector/ScriptArguments.cpp \
    10151014    inspector/ScriptBreakpoint.cpp \
     1015    inspector/ScriptCallFrame.cpp \
     1016    inspector/ScriptCallStack.cpp \
    10161017    inspector/TimelineRecordFactory.cpp \
    10171018    loader/archive/ArchiveFactory.cpp \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r70223 r70232  
    6039560395                                </File>
    6039660396                                <File
    60397                                         RelativePath="..\bindings\js\ScriptCallFrame.cpp"
     60397                                        RelativePath="..\bindings\js\ScriptCallStackFactory.cpp"
    6039860398                                        >
    6039960399                                        <FileConfiguration
     
    6044760447                                </File>
    6044860448                                <File
    60449                                         RelativePath="..\bindings\js\ScriptCallFrame.h"
    60450                                         >
    60451                                 </File>
    60452                                 <File
    60453                                         RelativePath="..\bindings\js\ScriptCallStack.cpp"
    60454                                         >
    60455                                         <FileConfiguration
    60456                                                 Name="Debug|Win32"
    60457                                                 ExcludedFromBuild="true"
    60458                                                 >
    60459                                                 <Tool
    60460                                                         Name="VCCLCompilerTool"
    60461                                                 />
    60462                                         </FileConfiguration>
    60463                                         <FileConfiguration
    60464                                                 Name="Release|Win32"
    60465                                                 ExcludedFromBuild="true"
    60466                                                 >
    60467                                                 <Tool
    60468                                                         Name="VCCLCompilerTool"
    60469                                                 />
    60470                                         </FileConfiguration>
    60471                                         <FileConfiguration
    60472                                                 Name="Debug_Internal|Win32"
    60473                                                 ExcludedFromBuild="true"
    60474                                                 >
    60475                                                 <Tool
    60476                                                         Name="VCCLCompilerTool"
    60477                                                 />
    60478                                         </FileConfiguration>
    60479                                         <FileConfiguration
    60480                                                 Name="Debug_Cairo|Win32"
    60481                                                 ExcludedFromBuild="true"
    60482                                                 >
    60483                                                 <Tool
    60484                                                         Name="VCCLCompilerTool"
    60485                                                 />
    60486                                         </FileConfiguration>
    60487                                         <FileConfiguration
    60488                                                 Name="Release_Cairo|Win32"
    60489                                                 ExcludedFromBuild="true"
    60490                                                 >
    60491                                                 <Tool
    60492                                                         Name="VCCLCompilerTool"
    60493                                                 />
    60494                                         </FileConfiguration>
    60495                                         <FileConfiguration
    60496                                                 Name="Debug_All|Win32"
    60497                                                 ExcludedFromBuild="true"
    60498                                                 >
    60499                                                 <Tool
    60500                                                         Name="VCCLCompilerTool"
    60501                                                 />
    60502                                         </FileConfiguration>
    60503                                 </File>
    60504                                 <File
    60505                                         RelativePath="..\bindings\js\ScriptCallStack.h"
     60449                                        RelativePath="..\bindings\js\ScriptCallStackFactory.h"
    6050660450                                        >
    6050760451                                </File>
     
    6339663340                        </File>
    6339763341                        <File
     63342                                RelativePath="..\inspector\ScriptArguments.cpp"
     63343                                >
     63344                        </File>
     63345                        <File
     63346                                RelativePath="..\inspector\ScriptArguments.h"
     63347                                >
     63348                        </File>
     63349                        <File
    6339863350                                RelativePath="..\inspector\ScriptBreakpoint.cpp"
    6339963351                                >
     
    6340163353                        <File
    6340263354                                RelativePath="..\inspector\ScriptBreakpoint.h"
     63355                                >
     63356                        </File>
     63357                        <File
     63358                                RelativePath="..\inspector\ScriptCallFrame.cpp"
     63359                                >
     63360                        </File>
     63361                        <File
     63362                                RelativePath="..\inspector\ScriptCallFrame.h"
     63363                                >
     63364                        </File>
     63365                        <File
     63366                                RelativePath="..\inspector\ScriptCallStack.cpp"
     63367                                >
     63368                        </File>
     63369                        <File
     63370                                RelativePath="..\inspector\ScriptCallStack.h"
    6340363371                                >
    6340463372                        </File>
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r70229 r70232  
    54605460                F3644B001119805900E0D537 /* InjectedScript.h in Headers */ = {isa = PBXBuildFile; fileRef = F3644AFE1119805900E0D537 /* InjectedScript.h */; };
    54615461                F375CC071150D300008DDB81 /* InspectorWorkerResource.h in Headers */ = {isa = PBXBuildFile; fileRef = F375CC061150D300008DDB81 /* InspectorWorkerResource.h */; };
     5462                F392249C126F11AE00A926D9 /* ScriptCallStackFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F392249A126F11AE00A926D9 /* ScriptCallStackFactory.cpp */; };
     5463                F392249D126F11AE00A926D9 /* ScriptCallStackFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = F392249B126F11AE00A926D9 /* ScriptCallStackFactory.h */; };
     5464                F39BE95B12673BF400E0A674 /* ScriptArguments.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F39BE95912673BF400E0A674 /* ScriptArguments.cpp */; };
     5465                F39BE95C12673BF400E0A674 /* ScriptArguments.h in Headers */ = {isa = PBXBuildFile; fileRef = F39BE95A12673BF400E0A674 /* ScriptArguments.h */; };
    54625466                F3D461481161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */; };
    54635467                F3D461491161D53200CA0D09 /* JSWorkerContextErrorHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */; };
     
    1148611490                F3644AFE1119805900E0D537 /* InjectedScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedScript.h; sourceTree = "<group>"; };
    1148711491                F375CC061150D300008DDB81 /* InspectorWorkerResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorWorkerResource.h; sourceTree = "<group>"; };
     11492                F392249A126F11AE00A926D9 /* ScriptCallStackFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptCallStackFactory.cpp; sourceTree = "<group>"; };
     11493                F392249B126F11AE00A926D9 /* ScriptCallStackFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptCallStackFactory.h; sourceTree = "<group>"; };
     11494                F39BE95912673BF400E0A674 /* ScriptArguments.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptArguments.cpp; sourceTree = "<group>"; };
     11495                F39BE95A12673BF400E0A674 /* ScriptArguments.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptArguments.h; sourceTree = "<group>"; };
    1148811496                F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerContextErrorHandler.cpp; sourceTree = "<group>"; };
    1148911497                F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWorkerContextErrorHandler.h; sourceTree = "<group>"; };
     
    1225712265                                1C81BA050E97348300266E07 /* JavaScriptCallFrame.idl */,
    1225812266                                BCC64F5F0DCFB84E0081EF3B /* localizedStrings.js */,
     12267                                F39BE95912673BF400E0A674 /* ScriptArguments.cpp */,
     12268                                F39BE95A12673BF400E0A674 /* ScriptArguments.h */,
    1225912269                                200B190811C277D900DCCD3A /* ScriptBreakpoint.cpp */,
    1226012270                                7AFD4A8A1131C2760035B883 /* ScriptBreakpoint.h */,
     12271                                416E75CA0EDF90C700360E1D /* ScriptCallFrame.cpp */,
     12272                                416E75C90EDF90C700360E1D /* ScriptCallFrame.h */,
     12273                                416E75BD0EDF8FD700360E1D /* ScriptCallStack.cpp */,
     12274                                416E75BC0EDF8FD700360E1D /* ScriptCallStack.h */,
    1226112275                                7AFD4FF3113277B60035B883 /* ScriptDebugListener.h */,
    1226212276                                9FA37EEF1172FD4100C4CD55 /* ScriptProfile.idl */,
     
    1677416788                                41F1D21E0EF35C2A00DA8753 /* ScriptCachedFrameData.cpp */,
    1677516789                                41F1D21D0EF35C2A00DA8753 /* ScriptCachedFrameData.h */,
    16776                                 416E75CA0EDF90C700360E1D /* ScriptCallFrame.cpp */,
    16777                                 416E75C90EDF90C700360E1D /* ScriptCallFrame.h */,
    16778                                 416E75BD0EDF8FD700360E1D /* ScriptCallStack.cpp */,
    16779                                 416E75BC0EDF8FD700360E1D /* ScriptCallStack.h */,
     16790                                F392249A126F11AE00A926D9 /* ScriptCallStackFactory.cpp */,
     16791                                F392249B126F11AE00A926D9 /* ScriptCallStackFactory.h */,
    1678016792                                93B70D5309EB0C7C009D8468 /* ScriptController.cpp */,
    1678116793                                93B70D5409EB0C7C009D8468 /* ScriptController.h */,
     
    2055320565                                5162C7F511F77EFB00612EFE /* SchemeRegistry.h in Headers */,
    2055420566                                BCEC01BE0C274DAC009F4EC9 /* Screen.h in Headers */,
     20567                                F39BE95C12673BF400E0A674 /* ScriptArguments.h in Headers */,
    2055520568                                A84D82C111D3474800972990 /* ScriptableDocumentParser.h in Headers */,
    2055620569                                7AFD4A8B1131C2760035B883 /* ScriptBreakpoint.h in Headers */,
     
    2112721140                                081CDFBA126ECFDB00D215CA /* DeprecatedSVGAnimatedTemplate.h in Headers */,
    2112821141                                081CDFBF126ECFE800D215CA /* SVGAnimatedPropertySynchronizer.h in Headers */,
     21142                                F392249D126F11AE00A926D9 /* ScriptCallStackFactory.h in Headers */,
    2112921143                                088A0E04126EF1DB00978F7A /* SVGAnimatedListPropertyTearOff.h in Headers */,
    2113021144                                088A0E05126EF1DB00978F7A /* SVGAnimatedProperty.h in Headers */,
     
    2318023194                                BCEC01BD0C274DAC009F4EC9 /* Screen.cpp in Sources */,
    2318123195                                A84D82C211D3474800972990 /* ScriptableDocumentParser.cpp in Sources */,
     23196                                F39BE95B12673BF400E0A674 /* ScriptArguments.cpp in Sources */,
    2318223197                                200B190911C277D900DCCD3A /* ScriptBreakpoint.cpp in Sources */,
    2318323198                                41F1D2200EF35C2A00DA8753 /* ScriptCachedFrameData.cpp in Sources */,
     
    2368823703                                E18772F1126E2629003DD586 /* Language.cpp in Sources */,
    2368923704                                7A1F2B52126C61B20006A7E6 /* InspectorClient.cpp in Sources */,
     23705                                F392249C126F11AE00A926D9 /* ScriptCallStackFactory.cpp in Sources */,
    2369023706                        );
    2369123707                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/bindings/js/JSBindingsAllInOne.cpp

    r70047 r70232  
    142142#include "ScheduledAction.cpp"
    143143#include "ScriptCachedFrameData.cpp"
    144 #include "ScriptCallFrame.cpp"
    145 #include "ScriptCallStack.cpp"
     144#include "ScriptCallStackFactory.cpp"
    146145#include "ScriptController.cpp"
    147146#include "ScriptControllerWin.cpp"
  • trunk/WebCore/bindings/js/ScriptCallStackFactory.cpp

    r70231 r70232  
    11/*
    2  * Copyright (c) 2008, Google Inc. All rights reserved.
     2 * Copyright (c) 2010 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3030
    3131#include "config.h"
     32#include "ScriptCallStackFactory.h"
     33
     34#include "JSDOMBinding.h"
     35#include "ScriptArguments.h"
     36#include "ScriptCallFrame.h"
    3237#include "ScriptCallStack.h"
    33 
     38#include "ScriptValue.h"
    3439#include <interpreter/CallFrame.h>
    3540#include <interpreter/Interpreter.h>
     41#include <runtime/ArgList.h>
    3642#include <runtime/JSFunction.h>
     43#include <runtime/JSGlobalData.h>
    3744#include <runtime/JSValue.h>
    3845#include <runtime/UString.h>
    39 #include <runtime/JSGlobalData.h>
    4046
    4147using namespace JSC;
     
    4349namespace WebCore {
    4450
    45 ScriptCallStack::ScriptCallStack(ExecState* exec, unsigned skipArgumentCount)
    46     : m_initialized(false)
    47     , m_exec(exec)
    48     , m_caller(0)
     51PassOwnPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t maxStackSize)
    4952{
    50     int signedLineNumber;
    51     intptr_t sourceID;
    52     UString urlString;
    53     JSValue function;
     53    Vector<ScriptCallFrame> frames;
     54    CallFrame* callFrame = exec;
     55    while (true) {
     56        ASSERT(callFrame);
     57        int signedLineNumber;
     58        intptr_t sourceID;
     59        UString urlString;
     60        JSValue function;
    5461
    55     exec->interpreter()->retrieveLastCaller(exec, signedLineNumber, sourceID, urlString, function);
    56 
    57     unsigned lineNumber = signedLineNumber >= 0 ? signedLineNumber : 0;
    58 
    59     if (function) {
    60         m_caller = asFunction(function);
    61         m_frames.append(ScriptCallFrame(m_caller->name(m_exec), urlString, lineNumber, m_exec, skipArgumentCount));
    62     } else {
    63         // Caller is unknown, but we should still add the frame, because
    64         // something called us, and gave us arguments.
    65         m_frames.append(ScriptCallFrame(UString(), urlString, lineNumber, m_exec, skipArgumentCount));
     62        exec->interpreter()->retrieveLastCaller(callFrame, signedLineNumber, sourceID, urlString, function);
     63        UString functionName;
     64        if (function)
     65            functionName = asFunction(function)->name(exec);
     66        else {
     67            // Caller is unknown, but if frames is empty we should still add the frame, because
     68            // something called us, and gave us arguments.
     69            if (!frames.isEmpty())
     70                break;
     71        }
     72        unsigned lineNumber = signedLineNumber >= 0 ? signedLineNumber : 0;
     73        frames.append(ScriptCallFrame(ustringToString(functionName), ustringToString(urlString), lineNumber));
     74        if (!function || frames.size() == maxStackSize)
     75            break;
     76        callFrame = callFrame->callerFrame();
    6677    }
     78    return new ScriptCallStack(frames);
    6779}
    6880
    69 ScriptCallStack::~ScriptCallStack()
     81PassOwnPtr<ScriptArguments> createScriptArguments(JSC::ExecState* exec, unsigned skipArgumentCount)
    7082{
    71 }
    72 
    73 const ScriptCallFrame &ScriptCallStack::at(unsigned index)
    74 {
    75     // First frame is pre-populated in constructor, so don't trigger
    76     // initialization unless looking beyond the first frame.
    77     if (index > 0)
    78         initialize();
    79     ASSERT(m_frames.size() > index);
    80     return m_frames[index];
    81 }
    82 
    83 unsigned ScriptCallStack::size()
    84 {
    85     initialize();
    86     return m_frames.size();
    87 }
    88 
    89 void ScriptCallStack::initialize()
    90 {
    91     if (!m_caller || m_initialized)
    92         return;
    93 
    94     int signedLineNumber;
    95     intptr_t sourceID;
    96     UString urlString;
    97     JSValue function;
    98     // callFrame must exist if m_caller is not null.
    99     CallFrame* callFrame = m_exec->callerFrame();
    100     while (true) {
    101         ASSERT(callFrame);
    102         m_exec->interpreter()->retrieveLastCaller(callFrame, signedLineNumber, sourceID, urlString, function);
    103         if (!function)
    104             break;
    105         JSFunction* jsFunction = asFunction(function);
    106         unsigned lineNumber = signedLineNumber >= 0 ? signedLineNumber : 0;
    107         m_frames.append(ScriptCallFrame(jsFunction->name(m_exec), urlString, lineNumber, m_exec, 0));
    108         callFrame = callFrame->callerFrame();
    109     }
    110     m_initialized = true;
     83    Vector<ScriptValue> arguments;
     84    size_t argumentCount = exec->argumentCount();
     85    for (size_t i = skipArgumentCount; i < argumentCount; ++i)
     86        arguments.append(ScriptValue(exec->argument(i)));
     87    return new ScriptArguments(exec, arguments);
    11188}
    11289
  • trunk/WebCore/bindings/js/ScriptCallStackFactory.h

    r70231 r70232  
    11/*
    2  * Copyright (c) 2008, Google Inc. All rights reserved.
     2 * Copyright (c) 2010 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929 */
    3030
    31 #include "config.h"
    32 #include "ScriptCallFrame.h"
     31#ifndef ScriptCallStackFactory_h
     32#define ScriptCallStackFactory_h
    3333
    34 #include <runtime/ArgList.h>
    35 #include <runtime/UString.h>
     34#include <wtf/PassOwnPtr.h>
    3635
    37 using namespace JSC;
     36namespace JSC {
     37class ExecState;
     38}
    3839
    3940namespace WebCore {
    4041
    41 ScriptCallFrame::ScriptCallFrame(const UString& functionName, const UString& urlString, int lineNumber, ExecState* exec, unsigned skipArgumentCount)
    42     : m_functionName(ustringToString(functionName))
    43     , m_sourceURL(ustringToString(urlString))
    44     , m_lineNumber(lineNumber)
    45 {
    46     if (!exec)
    47         return;
    48     size_t argumentCount = exec->argumentCount();
    49     for (size_t i = skipArgumentCount; i < argumentCount; ++i)
    50         m_arguments.append(ScriptValue(exec->argument(i)));
    51 }
     42class ScriptArguments;
     43class ScriptCallStack;
    5244
    53 ScriptCallFrame::~ScriptCallFrame()
    54 {
    55 }
    56 
    57 const ScriptValue &ScriptCallFrame::argumentAt(unsigned index) const
    58 {
    59     ASSERT(m_arguments.size() > index);
    60     return m_arguments[index];
    61 }
     45PassOwnPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState*, size_t maxStackSize);
     46PassOwnPtr<ScriptArguments> createScriptArguments(JSC::ExecState*, unsigned skipArgumentCount);
    6247
    6348} // namespace WebCore
     49
     50#endif // ScriptCallStackFactory_h
  • trunk/WebCore/bindings/js/ScriptState.h

    r56708 r70232  
    5353    ScriptStateProtectedPtr() { }
    5454    ScriptStateProtectedPtr(ScriptState* scriptState) : m_globalObject(scriptState->lexicalGlobalObject()) { }
    55     ScriptState* get()
     55    ScriptState* get() const
    5656    {
    5757        if (m_globalObject)
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r70223 r70232  
    19671967
    19681968                    if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) {
    1969                         push(@implContent, "    ScriptCallStack callStack(exec, $numParameters);\n");
     1969                        push(@implContent, "    OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, $numParameters));\n");
     1970                        push(@implContent, "    size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;\n");
     1971                        push(@implContent, "    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize));\n");
     1972                        $implIncludes{"ScriptArguments.h"} = 1;
    19701973                        $implIncludes{"ScriptCallStack.h"} = 1;
     1974                        $implIncludes{"ScriptCallStackFactory.h"} = 1;
    19711975                    }
    19721976
     
    23582362    if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) {
    23592363        $functionString .= ", " if $paramIndex;
    2360         ++$paramIndex;
    2361         $functionString .= "&callStack";
     2364        $paramIndex += 2;
     2365        $functionString .= "scriptArguments.release(), callStack.release()";
    23622366    }
    23632367
  • trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r70223 r70232  
    13051305    if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) {
    13061306        push(@implContentDecls, <<END);
    1307     OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, $numParameters));
     1307    OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, $numParameters));
     1308    size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;
     1309    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(maxStackSize));
    13081310    if (!callStack)
    13091311        return v8::Undefined();
    13101312END
     1313        $implIncludes{"ScriptArguments.h"} = 1;
    13111314        $implIncludes{"ScriptCallStack.h"} = 1;
     1315        $implIncludes{"ScriptCallStackFactory.h"} = 1;
    13121316    }
    13131317    if ($function->signature->extendedAttributes->{"SVGCheckSecurityDocument"}) {
     
    27202724    if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) {
    27212725        $functionString .= ", " if $index;
    2722         $functionString .= "callStack.get()";
    2723         $index++;
     2726        $functionString .= "scriptArguments.release(), callStack.release()";
     2727        $index += 2;
    27242728    }
    27252729
  • trunk/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r67421 r70232  
    3232#include "JSlog.h"
    3333#include "KURL.h"
     34#include "ScriptArguments.h"
    3435#include "ScriptCallStack.h"
     36#include "ScriptCallStackFactory.h"
    3537#include "SerializedScriptValue.h"
    3638#include "TestObj.h"
     
    995997    TestObj* imp = static_cast<TestObj*>(castedThis->impl());
    996998    ExceptionCode ec = 0;
    997     ScriptCallStack callStack(exec, 1);
     999    OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, 1));
     1000    size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;
     1001    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize));
    9981002    log* intArg = tolog(exec->argument(0));
    9991003    if (exec->hadException())
    10001004        return JSValue::encode(jsUndefined());
    10011005
    1002     imp->customArgsAndException(intArg, &callStack, ec);
     1006    imp->customArgsAndException(intArg, scriptArguments.release(), callStack.release(), ec);
    10031007    setDOMException(exec, ec);
    10041008    return JSValue::encode(jsUndefined());
  • trunk/WebCore/bindings/scripts/test/V8/V8TestObj.cpp

    r67421 r70232  
    2727#include "IDBKey.h"
    2828#include "RuntimeEnabledFeatures.h"
     29#include "ScriptArguments.h"
    2930#include "ScriptCallStack.h"
     31#include "ScriptCallStackFactory.h"
    3032#include "SerializedScriptValue.h"
    3133#include "V8Binding.h"
     
    706708    ExceptionCode ec = 0;
    707709    {
    708     OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, 1));
     710    OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 1));
     711    size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;
     712    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(maxStackSize));
    709713    if (!callStack)
    710714        return v8::Undefined();
    711715    EXCEPTION_BLOCK(log*, intArg, V8log::HasInstance(args[0]) ? V8log::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
    712     imp->customArgsAndException(intArg, callStack.get(), ec);
     716    imp->customArgsAndException(intArg, scriptArguments.release(), callStack.release(), ec);
    713717    if (UNLIKELY(ec))
    714718        goto fail;
  • trunk/WebCore/bindings/v8/ScriptCallStackFactory.cpp

    r70231 r70232  
    11/*
    2  * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
    3  *
     2 * Copyright (c) 2010 Google Inc. All rights reserved.
     3 * 
    44 * Redistribution and use in source and binary forms, with or without
    55 * modification, are permitted provided that the following conditions are
    66 * met:
    7  *
     7 * 
    88 *     * Redistributions of source code must retain the above copyright
    99 * notice, this list of conditions and the following disclaimer.
     
    3030
    3131#include "config.h"
    32 #include "ScriptCallStack.h"
     32#include "ScriptCallStackFactory.h"
    3333
    3434#include "InspectorValues.h"
    35 #include "ScriptController.h"
    36 #include "ScriptDebugServer.h"
     35#include "ScriptArguments.h"
     36#include "ScriptCallFrame.h"
     37#include "ScriptCallStack.h"
    3738#include "ScriptScope.h"
     39#include "ScriptValue.h"
    3840#include "V8Binding.h"
    3941
     
    4244namespace WebCore {
    4345
    44 static void getFrameLocation(v8::Handle<v8::StackFrame> frame, String* sourceName, int* sourceLineNumber, String* functionName)
     46static ScriptCallFrame toScriptCallFrame(v8::Handle<v8::StackFrame> frame)
    4547{
    46     ASSERT(!frame.IsEmpty());
     48    String sourceName;
    4749    v8::Local<v8::String> sourceNameValue(frame->GetScriptNameOrSourceURL());
     50    if (!sourceNameValue.IsEmpty())
     51        sourceName = toWebCoreString(sourceNameValue);
     52
     53    String functionName;
    4854    v8::Local<v8::String> functionNameValue(frame->GetFunctionName());
    49     *sourceName = sourceNameValue.IsEmpty() ? "" : toWebCoreString(sourceNameValue);
    50     *functionName = functionNameValue.IsEmpty() ? "" : toWebCoreString(functionNameValue);
    51     *sourceLineNumber = frame->GetLineNumber();
     55    if (!functionNameValue.IsEmpty())
     56        functionName = toWebCoreString(functionNameValue);
     57
     58    int sourceLineNumber = frame->GetLineNumber();
     59    return ScriptCallFrame(functionName, sourceName, sourceLineNumber);
    5260}
    5361
    54 static void getTopFrameLocation(v8::Handle<v8::StackTrace> stackTrace, String* sourceName, int* sourceLineNumber, String* functionName)
     62static void toScriptCallFramesVector(v8::Local<v8::Context> context, v8::Handle<v8::StackTrace> stackTrace, Vector<ScriptCallFrame>& scriptCallFrames, size_t maxStackSize)
    5563{
    56     if (stackTrace->GetFrameCount() <= 0) {
    57         // Successfully grabbed stack trace, but there are no frames. It may happen in case of a syntax error for example.
    58         // Fallback to setting lineNumber to 0, and source and function name to "undefined".
    59         *sourceName = "undefined";
    60         *sourceLineNumber = 0;
    61         *functionName = "undefined";
    62     } else {
    63         v8::Handle<v8::StackFrame> frame = stackTrace->GetFrame(0);
    64         getFrameLocation(frame, sourceName, sourceLineNumber, functionName);
    65     }
    66 }
    67 
    68 static PassOwnPtr<ScriptCallFrame> toScriptCallFrame(v8::Handle<v8::StackFrame> frame)
    69 {
    70     String sourceName;
    71     int sourceLineNumber;
    72     String functionName;
    73     getFrameLocation(frame, &sourceName, &sourceLineNumber, &functionName);
    74     return new ScriptCallFrame(functionName, sourceName, sourceLineNumber);
    75 }
    76 
    77 static void toScriptCallFramesVector(v8::Local<v8::Context> context, v8::Handle<v8::StackTrace> stackTrace, Vector<OwnPtr<ScriptCallFrame> >& scriptCallFrames)
    78 {
     64    // TODO(yurys): remove this???
    7965    v8::Context::Scope contextScope(context);
    8066    int frameCount = stackTrace->GetFrameCount();
     67    if (frameCount > static_cast<int>(maxStackSize))
     68        frameCount = maxStackSize;
    8169    for (int i = 0; i < frameCount; i++) {
    8270        v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i);
    8371        scriptCallFrames.append(toScriptCallFrame(stackFrame));
    8472    }
     73   
     74    if (!frameCount) {
     75        // Successfully grabbed stack trace, but there are no frames. It may happen in case of a syntax error for example.
     76        // Fallback to setting lineNumber to 0, and source and function name to "undefined".
     77        scriptCallFrames.append(ScriptCallFrame("undefined", "undefined", 0));
     78    }
    8579}
    8680
    87 const int ScriptCallStack::maxCallStackSizeToCapture = 200;
    88 const v8::StackTrace::StackTraceOptions ScriptCallStack::stackTraceOptions = static_cast<v8::StackTrace::StackTraceOptions>(
    89      v8::StackTrace::kLineNumber
    90     | v8::StackTrace::kColumnOffset
    91     | v8::StackTrace::kScriptNameOrSourceURL
    92     | v8::StackTrace::kFunctionName);
     81PassOwnPtr<ScriptCallStack> createScriptCallStack(v8::Local<v8::Context> context, v8::Handle<v8::StackTrace> stackTrace, size_t maxStackSize)
     82{
     83    v8::HandleScope scope;
     84    v8::Context::Scope contextScope(context);
    9385
     86    Vector<ScriptCallFrame> scriptCallFrames;
     87    toScriptCallFramesVector(context, stackTrace, scriptCallFrames, maxStackSize);
     88    return new ScriptCallStack(scriptCallFrames);
     89}
    9490
    95 PassOwnPtr<ScriptCallStack> ScriptCallStack::create(const v8::Arguments& arguments, unsigned skipArgumentCount, int framCountLimit)
     91PassOwnPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize)
    9692{
    9793    v8::HandleScope scope;
    9894    v8::Local<v8::Context> context = v8::Context::GetCurrent();
     95    // TODO(yurys): remove?
    9996    v8::Context::Scope contextScope(context);
    100     v8::Handle<v8::StackTrace> stackTrace(v8::StackTrace::CurrentStackTrace(framCountLimit, ScriptCallStack::stackTraceOptions));
    101 
    102     if (stackTrace.IsEmpty())
    103         return 0;
    104 
    105     String sourceName;
    106     int sourceLineNumber;
    107     String functionName;
    108     getTopFrameLocation(stackTrace, &sourceName, &sourceLineNumber, &functionName);
    109 
    110     Vector<OwnPtr<ScriptCallFrame> > scriptCallFrames;
    111     if (framCountLimit > 1)
    112         toScriptCallFramesVector(context, stackTrace, scriptCallFrames);
    113 
    114     return new ScriptCallStack(ScriptState::forContext(context), new ScriptCallFrame(functionName, sourceName, sourceLineNumber, arguments, skipArgumentCount), scriptCallFrames);
     97    v8::Handle<v8::StackTrace> stackTrace(v8::StackTrace::CurrentStackTrace(maxStackSize, stackTraceOptions));
     98    return createScriptCallStack(context, stackTrace, maxStackSize);
    11599}
    116100
    117 PassOwnPtr<ScriptCallStack> ScriptCallStack::create(ScriptState* state, v8::Handle<v8::StackTrace> stackTrace)
     101PassOwnPtr<ScriptArguments> createScriptArguments(const v8::Arguments& v8arguments, unsigned skipArgumentCount)
    118102{
    119103    v8::HandleScope scope;
    120     Vector<OwnPtr<ScriptCallFrame> > scriptCallFrames;
    121     toScriptCallFramesVector(state->context(), stackTrace, scriptCallFrames);
     104    v8::Local<v8::Context> context = v8::Context::GetCurrent();
     105    ScriptState* state = ScriptState::forContext(context);
    122106
    123     String sourceName;
    124     int sourceLineNumber;
    125     String functionName;
    126     getTopFrameLocation(stackTrace, &sourceName, &sourceLineNumber, &functionName);
     107    Vector<ScriptValue> arguments;
     108    for (int i = skipArgumentCount; i < v8arguments.Length(); ++i)
     109        arguments.append(ScriptValue(v8arguments[i]));
    127110
    128     return new ScriptCallStack(state, new ScriptCallFrame(functionName, sourceName, sourceLineNumber), scriptCallFrames);
     111    return new ScriptArguments(state, arguments);
    129112}
    130 
    131 ScriptCallStack::ScriptCallStack(ScriptState* scriptState, PassOwnPtr<ScriptCallFrame> topFrame, Vector<OwnPtr<ScriptCallFrame> >& scriptCallFrames)
    132     : m_topFrame(topFrame)
    133     , m_scriptState(scriptState)
    134 {
    135     m_scriptCallFrames.swap(scriptCallFrames);
    136 }
    137 
    138 ScriptCallStack::~ScriptCallStack()
    139 {
    140 }
    141 
    142 const ScriptCallFrame& ScriptCallStack::at(unsigned index)
    143 {
    144     if (!index && m_topFrame)
    145         return *m_topFrame;
    146     return *m_scriptCallFrames.at(index);
    147 }
    148 
    149 unsigned ScriptCallStack::size()
    150 {
    151     if (m_scriptCallFrames.isEmpty())
    152         return 1;
    153     return m_scriptCallFrames.size();
    154 }
    155 
    156113
    157114bool ScriptCallStack::stackTrace(int frameLimit, const RefPtr<InspectorArray>& stackTrace)
  • trunk/WebCore/bindings/v8/ScriptCallStackFactory.h

    r70231 r70232  
    11/*
    2  * Copyright (c) 2008, Google Inc. All rights reserved.
     2 * Copyright (c) 2010 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929 */
    3030
    31 #include "config.h"
    32 #include "ScriptCallFrame.h"
     31#ifndef ScriptCallStackFactory_h
     32#define ScriptCallStackFactory_h
    3333
    34 #include <runtime/ArgList.h>
    35 #include <runtime/UString.h>
    36 
    37 using namespace JSC;
     34#include <v8.h>
     35#include <wtf/PassOwnPtr.h>
    3836
    3937namespace WebCore {
    4038
    41 ScriptCallFrame::ScriptCallFrame(const UString& functionName, const UString& urlString, int lineNumber, ExecState* exec, unsigned skipArgumentCount)
    42     : m_functionName(ustringToString(functionName))
    43     , m_sourceURL(ustringToString(urlString))
    44     , m_lineNumber(lineNumber)
    45 {
    46     if (!exec)
    47         return;
    48     size_t argumentCount = exec->argumentCount();
    49     for (size_t i = skipArgumentCount; i < argumentCount; ++i)
    50         m_arguments.append(ScriptValue(exec->argument(i)));
    51 }
     39class ScriptState;
    5240
    53 ScriptCallFrame::~ScriptCallFrame()
    54 {
    55 }
     41const v8::StackTrace::StackTraceOptions stackTraceOptions = static_cast<v8::StackTrace::StackTraceOptions>(
     42      v8::StackTrace::kLineNumber
     43    | v8::StackTrace::kColumnOffset
     44    | v8::StackTrace::kScriptNameOrSourceURL
     45    | v8::StackTrace::kFunctionName);
    5646
    57 const ScriptValue &ScriptCallFrame::argumentAt(unsigned index) const
    58 {
    59     ASSERT(m_arguments.size() > index);
    60     return m_arguments[index];
    61 }
     47class ScriptArguments;
     48class ScriptCallStack;
     49
     50PassOwnPtr<ScriptCallStack> createScriptCallStack(v8::Local<v8::Context>, v8::Handle<v8::StackTrace>, size_t maxStackSize);
     51PassOwnPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize);
     52PassOwnPtr<ScriptArguments> createScriptArguments(const v8::Arguments& v8arguments, unsigned skipArgumentCount);
    6253
    6354} // namespace WebCore
     55
     56#endif // ScriptCallStackFactory_h
  • trunk/WebCore/bindings/v8/ScriptController.cpp

    r70181 r70232  
    3636#include "Document.h"
    3737#include "ScriptCallStack.h"
     38#include "ScriptCallStackFactory.h"
    3839#include "ScriptableDocumentParser.h"
    3940#include "DOMWindow.h"
     
    469470void ScriptController::setCaptureCallStackForUncaughtExceptions(bool value)
    470471{
    471     v8::V8::SetCaptureStackTraceForUncaughtExceptions(value, ScriptCallStack::maxCallStackSizeToCapture, ScriptCallStack::stackTraceOptions);
     472    v8::V8::SetCaptureStackTraceForUncaughtExceptions(value, ScriptCallStack::maxCallStackSizeToCapture, stackTraceOptions);
    472473}
    473474#endif
  • trunk/WebCore/bindings/v8/ScriptState.h

    r56708 r70232  
    9696        }
    9797    }
    98     ScriptState* get() { return m_scriptState; }
     98    ScriptState* get() const { return m_scriptState; }
    9999private:
    100100    ScriptState* m_scriptState;
  • trunk/WebCore/bindings/v8/V8ConsoleMessage.cpp

    r63746 r70232  
    3838#include "Page.h"
    3939#include "ScriptCallStack.h"
     40#include "ScriptCallStackFactory.h"
    4041#include "V8Binding.h"
    4142#include "V8Proxy.h"
     
    118119    if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) {
    119120        v8::Local<v8::Context> context = v8::Context::GetEntered();
    120         ScriptState* scriptState = ScriptState::forContext(context);
    121         callStack = ScriptCallStack::create(scriptState, stackTrace);
     121        callStack = createScriptCallStack(context, stackTrace, ScriptCallStack::maxCallStackSizeToCapture);
    122122    }
    123123
     
    126126    String resourceNameString = useURL ? frame->document()->url() : toWebCoreString(resourceName);
    127127    V8ConsoleMessage consoleMessage(errorMessage, resourceNameString, message->GetLineNumber());
    128     consoleMessage.dispatchNow(page, callStack.get());
     128    consoleMessage.dispatchNow(page, callStack.release());
    129129}
    130130
    131 void V8ConsoleMessage::dispatchNow(Page* page, ScriptCallStack* callStack)
     131void V8ConsoleMessage::dispatchNow(Page* page, PassOwnPtr<ScriptCallStack> callStack)
    132132{
    133133    ASSERT(page);
  • trunk/WebCore/bindings/v8/V8ConsoleMessage.h

    r63662 r70232  
    3434#include "PlatformString.h"
    3535#include <v8.h>
     36#include <wtf/PassOwnPtr.h>
    3637#include <wtf/Vector.h>
    3738
     
    8283        const unsigned m_lineNumber;
    8384
    84         void dispatchNow(Page*, ScriptCallStack*);
     85        void dispatchNow(Page*, PassOwnPtr<ScriptCallStack>);
    8586
    8687        // All delayed messages are stored in this vector. If the vector
  • trunk/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp

    r69662 r70232  
    3434
    3535#include "Console.h"
     36#include "ScriptArguments.h"
    3637#include "ScriptCallStack.h"
     38#include "ScriptCallStackFactory.h"
    3739#include "ScriptProfile.h"
    3840#include "V8Binding.h"
     
    6365    INC_STATS("DOM.Console.traceCallback");
    6466    Console* imp = V8Console::toNative(args.Holder());
    65     v8::HandleScope handleScope;
    66     ScriptState* scriptState = ScriptState::current();
    67     v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(ScriptCallStack::maxCallStackSizeToCapture, ScriptCallStack::stackTraceOptions);
    68     OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(scriptState, stackTrace));
    69     imp->trace(callStack.get());
     67    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture));
     68    OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 0));
     69    imp->trace(scriptArguments.release(), callStack.release());
    7070    return v8::Handle<v8::Value>();
    7171}
     
    7575    INC_STATS("DOM.Console.assertCallback");
    7676    Console* imp = V8Console::toNative(args.Holder());
    77     OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, 1, ScriptCallStack::maxCallStackSizeToCapture));
     77    OwnPtr<ScriptCallStack> callStack(createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture));
    7878    bool condition = args[0]->BooleanValue();
    79     imp->assertCondition(condition, callStack.get());
     79    OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 1));
     80    imp->assertCondition(condition, scriptArguments.release(), callStack.release());
    8081    return v8::Handle<v8::Value>();
    8182}
  • trunk/WebCore/inspector/ConsoleMessage.cpp

    r69799 r70232  
    3434#include "InjectedScript.h"
    3535#include "InjectedScriptHost.h"
     36#include "InspectorFrontend.h"
    3637#include "InspectorValues.h"
     38#include "ScriptArguments.h"
    3739#include "ScriptCallStack.h"
    3840#include "ScriptValue.h"
    3941
    40 #if ENABLE(INSPECTOR)
    41 #include "InspectorFrontend.h"
    42 #endif
    43 
    4442namespace WebCore {
    45 
    46 ConsoleMessage::CallFrame::CallFrame(const ScriptCallFrame& frame)
    47     : m_functionName(frame.functionName())
    48     , m_sourceURL(frame.sourceURL())
    49     , m_lineNumber(frame.lineNumber())
    50 {
    51 }
    52 
    53 ConsoleMessage::CallFrame::CallFrame()
    54     : m_lineNumber(0)
    55 {
    56 }
    57 
    58 bool ConsoleMessage::CallFrame::isEqual(const ConsoleMessage::CallFrame& o) const
    59 {
    60     return m_functionName == o.m_functionName
    61         && m_sourceURL == o.m_sourceURL
    62         && m_lineNumber == o.m_lineNumber;
    63 }
    64 
    65 #if ENABLE(INSPECTOR)
    66 PassRefPtr<InspectorObject> ConsoleMessage::CallFrame::buildInspectorObject() const
    67 {
    68     RefPtr<InspectorObject> frame = InspectorObject::create();
    69     frame->setString("functionName", m_functionName);
    70     frame->setString("sourceURL", m_sourceURL);
    71     frame->setNumber("lineNumber", m_lineNumber);
    72     return frame;
    73 }
    74 #endif
    7543
    7644ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, unsigned li, const String& u, unsigned g)
     
    8654}
    8755
    88 ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, ScriptCallStack* callStack, unsigned g, bool storeTrace)
     56ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack, unsigned g)
    8957    : m_source(s)
    9058    , m_type(t)
    9159    , m_level(l)
    9260    , m_message(m)
    93 #if ENABLE(INSPECTOR)
    94     , m_arguments(callStack->at(0).argumentCount())
    95     , m_scriptState(callStack->globalState())
    96 #endif
    97     , m_frames(storeTrace ? callStack->size() : 0)
     61    , m_arguments(arguments)
     62    , m_callStack(callStack)
    9863    , m_groupLevel(g)
    9964    , m_repeatCount(1)
    10065{
    101     const ScriptCallFrame& lastCaller = callStack->at(0);
     66    const ScriptCallFrame& lastCaller = m_callStack->at(0);
    10267    m_line = lastCaller.lineNumber();
    10368    m_url = lastCaller.sourceURL();
    10469
    105     if (storeTrace) {
    106         for (unsigned i = 0; i < callStack->size(); ++i)
    107             m_frames[i] = ConsoleMessage::CallFrame(callStack->at(i));
    108     }
    10970
    110 #if ENABLE(INSPECTOR)
    111     for (unsigned i = 0; i < lastCaller.argumentCount(); ++i)
    112         m_arguments[i] = lastCaller.argumentAt(i);
    113 #endif
     71    bool storeTrace = (t == TraceMessageType || t == UncaughtExceptionMessageType || t == AssertMessageType);
     72    if (!storeTrace)
     73        m_callStack.clear();
    11474}
    11575
    116 #if ENABLE(INSPECTOR)
    11776void ConsoleMessage::addToFrontend(InspectorFrontend* frontend, InjectedScriptHost* injectedScriptHost)
    11877{
     
    12685    jsonObj->setNumber("repeatCount", static_cast<int>(m_repeatCount));
    12786    jsonObj->setString("message", m_message);
    128     if (!m_arguments.isEmpty()) {
    129         InjectedScript injectedScript = injectedScriptHost->injectedScriptFor(m_scriptState.get());
     87    if (m_arguments && m_arguments->argumentCount()) {
     88        InjectedScript injectedScript = injectedScriptHost->injectedScriptFor(m_arguments->globalState());
    13089        if (!injectedScript.hasNoValue()) {
    13190            RefPtr<InspectorArray> jsonArgs = InspectorArray::create();
    132             for (unsigned i = 0; i < m_arguments.size(); ++i) {
    133                 RefPtr<InspectorValue> inspectorValue = injectedScript.wrapForConsole(m_arguments[i]);
     91            for (unsigned i = 0; i < m_arguments->argumentCount(); ++i) {
     92                RefPtr<InspectorValue> inspectorValue = injectedScript.wrapForConsole(m_arguments->argumentAt(i));
    13493                if (!inspectorValue) {
    13594                    ASSERT_NOT_REACHED();
     
    141100        }
    142101    }
    143     if (!m_frames.isEmpty()) {
    144         RefPtr<InspectorArray> frames = InspectorArray::create();
    145         for (unsigned i = 0; i < m_frames.size(); i++)
    146             frames->pushObject(m_frames.at(i).buildInspectorObject());
    147         jsonObj->setArray("stackTrace", frames);
    148     }
     102    if (m_callStack)
     103        jsonObj->setArray("stackTrace", m_callStack->buildInspectorObject());
    149104    frontend->addConsoleMessage(jsonObj);
    150105}
     
    154109    frontend->updateConsoleMessageRepeatCount(m_repeatCount);
    155110}
    156 #endif // ENABLE(INSPECTOR)
    157111
    158112bool ConsoleMessage::isEqual(ConsoleMessage* msg) const
    159113{
    160 #if ENABLE(INSPECTOR)
    161     if (msg->m_arguments.size() != m_arguments.size())
    162         return false;
    163     if (!msg->m_scriptState.get() && msg->m_arguments.size()) {
    164         ASSERT_NOT_REACHED();
    165         return false;
    166     }
    167 
    168     for (size_t i = 0; i < m_arguments.size(); ++i) {
    169         if (!m_arguments[i].isEqual(msg->m_scriptState.get(), msg->m_arguments[i]))
     114    if (m_arguments) {
     115        if (!m_arguments->isEqual(msg->m_arguments.get()))
    170116            return false;
    171     }
    172 #endif // ENABLE(INSPECTOR)
    173 
    174     size_t frameCount = msg->m_frames.size();
    175     if (frameCount != m_frames.size())
     117    } else if (msg->m_arguments)
    176118        return false;
    177119
    178     for (size_t i = 0; i < frameCount; ++i) {
    179         if (!m_frames[i].isEqual(msg->m_frames[i]))
     120    if (m_callStack) {
     121        if (!m_callStack->isEqual(msg->m_callStack.get()))
    180122            return false;
    181     }
     123    } else if (msg->m_callStack)
     124        return false;
    182125
    183126    return msg->m_source == m_source
  • trunk/WebCore/inspector/ConsoleMessage.h

    r69799 r70232  
    22 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
    4  * Copyright (C) 2009 Google Inc. All rights reserved.
     4 * Copyright (C) 2009, 2010 Google Inc. All rights reserved.
    55 *
    66 * Redistribution and use in source and binary forms, with or without
     
    3333
    3434#include "Console.h"
    35 #include "KURL.h"
    3635#include "ScriptState.h"
    3736
     
    4241class InspectorFrontend;
    4342class InspectorObject;
     43class ScriptArguments;
    4444class ScriptCallFrame;
    4545class ScriptCallStack;
     
    4949public:
    5050    ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, unsigned li, const String& u, unsigned g);
    51     ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, ScriptCallStack*, unsigned g, bool storeTrace = false);
     51    ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>, unsigned g);
    5252
    53 #if ENABLE(INSPECTOR)
    5453    void addToFrontend(InspectorFrontend*, InjectedScriptHost*);
    5554    void updateRepeatCountInConsole(InspectorFrontend* frontend);
    56 #endif
    5755    void incrementCount() { ++m_repeatCount; }
    5856    bool isEqual(ConsoleMessage* msg) const;
     
    6260
    6361private:
    64     class CallFrame {
    65     public:
    66         explicit CallFrame(const ScriptCallFrame& frame);
    67         CallFrame();
    68         bool isEqual(const CallFrame& o) const;
    69 #if ENABLE(INSPECTOR)
    70         PassRefPtr<InspectorObject> buildInspectorObject() const;
    71 #endif
    72 
    73     private:
    74         String m_functionName;
    75         String m_sourceURL;
    76         unsigned m_lineNumber;
    77     };
    78 
    7962    MessageSource m_source;
    8063    MessageType m_type;
    8164    MessageLevel m_level;
    8265    String m_message;
    83 #if ENABLE(INSPECTOR)
    84     Vector<ScriptValue> m_arguments;
    85     ScriptStateProtectedPtr m_scriptState;
    86 #endif
    87     Vector<CallFrame> m_frames;
     66    OwnPtr<ScriptArguments> m_arguments;
     67    OwnPtr<ScriptCallStack> m_callStack;
    8868    unsigned m_line;
    8969    String m_url;
  • trunk/WebCore/inspector/InspectorController.cpp

    r70143 r70232  
    8383#include "ResourceRequest.h"
    8484#include "ResourceResponse.h"
     85#include "ScriptArguments.h"
    8586#include "ScriptCallStack.h"
    8687#include "ScriptFunctionCall.h"
     
    340341}
    341342
    342 void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, ScriptCallStack* callStack, const String& message)
    343 {
    344     if (!enabled())
    345         return;
    346 
    347     bool storeStackTrace = type == TraceMessageType || type == UncaughtExceptionMessageType || type == AssertMessageType;
    348     addConsoleMessage(new ConsoleMessage(source, type, level, message, callStack, m_groupLevel, storeStackTrace));
     343void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, const String& message, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
     344{
     345    if (!enabled())
     346        return;
     347
     348    addConsoleMessage(new ConsoleMessage(source, type, level, message, arguments, callStack, m_groupLevel));
    349349}
    350350
     
    392392}
    393393
    394 void InspectorController::startGroup(MessageSource source, ScriptCallStack* callStack, bool collapsed)
     394void InspectorController::startGroup(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack, bool collapsed)
    395395{
    396396    ++m_groupLevel;
    397397
    398     addConsoleMessage(new ConsoleMessage(source, collapsed ? StartGroupCollapsedMessageType : StartGroupMessageType, LogMessageLevel, String(), callStack, m_groupLevel));
     398    addConsoleMessage(new ConsoleMessage(JSMessageSource, collapsed ? StartGroupCollapsedMessageType : StartGroupMessageType, LogMessageLevel, "", arguments, callStack, m_groupLevel));
    399399}
    400400
  • trunk/WebCore/inspector/InspectorController.h

    r69948 r70232  
    8282class ResourceResponse;
    8383class ResourceError;
     84class ScriptArguments;
    8485class ScriptCallStack;
    8586class ScriptProfile;
     
    146147
    147148    void setConsoleMessagesEnabled(bool enabled, bool* newState);
    148     void addMessageToConsole(MessageSource, MessageType, MessageLevel, ScriptCallStack*, const String& message);
    149     void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID);
     149    void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>);
     150    void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String&);
    150151    void clearConsoleMessages();
    151152    const Vector<OwnPtr<ConsoleMessage> >& consoleMessages() const { return m_consoleMessages; }
     
    233234    bool stopTiming(const String& title, double& elapsed);
    234235
    235     void startGroup(MessageSource source, ScriptCallStack* callFrame, bool collapsed = false);
     236    void startGroup(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack> callFrame, bool collapsed = false);
    236237    void endGroup(MessageSource source, unsigned lineNumber, const String& sourceURL);
    237238
  • trunk/WebCore/inspector/ScriptArguments.cpp

    r70231 r70232  
    11/*
    2  * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
    3  *
     2 * Copyright (c) 2010 Google Inc. All rights reserved.
     3 * 
    44 * Redistribution and use in source and binary forms, with or without
    55 * modification, are permitted provided that the following conditions are
    66 * met:
    7  *
     7 * 
    88 *     * Redistributions of source code must retain the above copyright
    99 * notice, this list of conditions and the following disclaimer.
     
    3030
    3131#include "config.h"
    32 #include "ScriptCallFrame.h"
     32#include "ScriptArguments.h"
    3333
    34 #include <v8.h>
    35 
    36 #include "PlatformString.h"
    37 #include "V8Binding.h"
    38 #include "V8Proxy.h"
    3934#include "ScriptValue.h"
    4035
    4136namespace WebCore {
    4237
    43 ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber, const v8::Arguments& arguments, unsigned skipArgumentCount)
    44     : m_functionName(functionName)
    45     , m_sourceURL(urlString)
    46     , m_lineNumber(lineNumber)
     38ScriptArguments::ScriptArguments(ScriptState* scriptState, Vector<ScriptValue>& arguments)
     39    : m_scriptState(scriptState)
    4740{
    48     for (int i = skipArgumentCount; i < arguments.Length(); ++i)
    49         m_arguments.append(ScriptValue(arguments[i]));
     41    m_arguments.swap(arguments);
    5042}
    5143
    52 ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber)
    53     : m_functionName(functionName)
    54     , m_sourceURL(urlString)
    55     , m_lineNumber(lineNumber)
     44ScriptArguments::~ScriptArguments()
    5645{
    5746}
    5847
    59 ScriptCallFrame::~ScriptCallFrame()
    60 {
    61 }
    62 
    63 const ScriptValue& ScriptCallFrame::argumentAt(unsigned index) const
     48const ScriptValue &ScriptArguments::argumentAt(size_t index) const
    6449{
    6550    ASSERT(m_arguments.size() > index);
     
    6752}
    6853
     54ScriptState* ScriptArguments::globalState() const
     55{
     56    return m_scriptState.get();
     57}
     58
     59bool ScriptArguments::getFirstArgumentAsString(String& result, bool checkForNullOrUndefined)
     60{
     61    if (!argumentCount())
     62        return false;
     63
     64    const ScriptValue& value = argumentAt(0);
     65    if (checkForNullOrUndefined && (value.isNull() || value.isUndefined()))
     66        return false;
     67
     68    if (!globalState()) {
     69        ASSERT_NOT_REACHED();
     70        return false;
     71    }
     72
     73    result = value.toString(globalState());
     74    return true;
     75}
     76
     77bool ScriptArguments::isEqual(ScriptArguments* other) const
     78{
     79    if (!other)
     80        return false;
     81
     82    if (m_arguments.size() != other->m_arguments.size())
     83        return false;
     84    if (!globalState() && m_arguments.size())
     85        return false;
     86
     87    for (size_t i = 0; i < m_arguments.size(); ++i) {
     88        if (!m_arguments[i].isEqual(other->globalState(), other->m_arguments[i]))
     89            return false;
     90    }
     91    return true;
     92}
     93
    6994} // namespace WebCore
  • trunk/WebCore/inspector/ScriptArguments.h

    r70231 r70232  
    11/*
    2  * Copyright (c) 2008, Google Inc. All rights reserved.
     2 * Copyright (c) 2010 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929 */
    3030
    31 #ifndef ScriptCallFrame_h
    32 #define ScriptCallFrame_h
     31#ifndef ScriptArguments_h
     32#define ScriptArguments_h
    3333
    3434#include "PlatformString.h"
    35 #include "ScriptValue.h"
     35#include "ScriptState.h"
    3636#include <wtf/Vector.h>
    37 
    38 namespace JSC {
    39 class ExecState;
    40 class UString;
    41 }
    4237
    4338namespace WebCore {
    4439
    45 class ScriptCallFrame  {
     40class ScriptValue;
     41
     42class ScriptArguments {
    4643public:
    47     ScriptCallFrame(const JSC::UString& functionName, const JSC::UString& urlString, int lineNumber, JSC::ExecState*, unsigned skipArgumentCount);
    48     ~ScriptCallFrame();
     44    ScriptArguments(ScriptState*, Vector<ScriptValue>& arguments);
     45    ~ScriptArguments();
    4946
    50     const String& functionName() const { return m_functionName; }
    51     const String& sourceURL() const { return m_sourceURL; }
    52     unsigned lineNumber() const { return m_lineNumber; }
     47    const ScriptValue& argumentAt(size_t) const;
     48    size_t argumentCount() const { return m_arguments.size(); }
    5349
    54     // argument retrieval methods
    55     const ScriptValue& argumentAt(unsigned) const;
    56     unsigned argumentCount() const { return m_arguments.size(); }
     50    ScriptState* globalState() const;
     51
     52    bool getFirstArgumentAsString(WTF::String& result, bool checkForNullOrUndefined = false);
     53    bool isEqual(ScriptArguments*) const;
    5754
    5855private:
    59     String m_functionName;
    60     String m_sourceURL;
    61     unsigned m_lineNumber;
    62 
     56    ScriptStateProtectedPtr m_scriptState;
    6357    Vector<ScriptValue> m_arguments;
    6458};
     
    6660} // namespace WebCore
    6761
    68 #endif // ScriptCallFrame_h
     62#endif // ScriptArguments_h
  • trunk/WebCore/inspector/ScriptCallFrame.cpp

    r70231 r70232  
    11/*
    2  * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
    3  *
     2 * Copyright (c) 2010 Google Inc. All rights reserved.
     3 * 
    44 * Redistribution and use in source and binary forms, with or without
    55 * modification, are permitted provided that the following conditions are
    66 * met:
    7  *
     7 * 
    88 *     * Redistributions of source code must retain the above copyright
    99 * notice, this list of conditions and the following disclaimer.
     
    3232#include "ScriptCallFrame.h"
    3333
    34 #include <v8.h>
    35 
    36 #include "PlatformString.h"
    37 #include "V8Binding.h"
    38 #include "V8Proxy.h"
    39 #include "ScriptValue.h"
     34#include "InspectorValues.h"
     35#include <wtf/RefPtr.h>
    4036
    4137namespace WebCore {
    4238
    43 ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber, const v8::Arguments& arguments, unsigned skipArgumentCount)
    44     : m_functionName(functionName)
    45     , m_sourceURL(urlString)
    46     , m_lineNumber(lineNumber)
    47 {
    48     for (int i = skipArgumentCount; i < arguments.Length(); ++i)
    49         m_arguments.append(ScriptValue(arguments[i]));
    50 }
    51 
    52 ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber)
     39ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, unsigned lineNumber)
    5340    : m_functionName(functionName)
    5441    , m_sourceURL(urlString)
     
    6148}
    6249
    63 const ScriptValue& ScriptCallFrame::argumentAt(unsigned index) const
     50bool ScriptCallFrame::isEqual(const ScriptCallFrame& o) const
    6451{
    65     ASSERT(m_arguments.size() > index);
    66     return m_arguments[index];
     52    return m_functionName == o.m_functionName
     53        && m_sourceURL == o.m_sourceURL
     54        && m_lineNumber == o.m_lineNumber;
     55}
     56
     57PassRefPtr<InspectorObject> ScriptCallFrame::buildInspectorObject() const
     58{
     59    RefPtr<InspectorObject> frame = InspectorObject::create();
     60    frame->setString("functionName", m_functionName);
     61    frame->setString("sourceURL", m_sourceURL);
     62    frame->setNumber("lineNumber", m_lineNumber);
     63    return frame;
    6764}
    6865
  • trunk/WebCore/inspector/ScriptCallFrame.h

    r70231 r70232  
    11/*
    2  * Copyright (c) 2008, Google Inc. All rights reserved.
     2 * Copyright (c) 2010 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3333
    3434#include "PlatformString.h"
    35 #include "ScriptValue.h"
    36 #include <wtf/Vector.h>
    37 
    38 namespace JSC {
    39 class ExecState;
    40 class UString;
    41 }
     35#include <wtf/PassRefPtr.h>
    4236
    4337namespace WebCore {
    4438
     39class InspectorObject;
     40
    4541class ScriptCallFrame  {
    4642public:
    47     ScriptCallFrame(const JSC::UString& functionName, const JSC::UString& urlString, int lineNumber, JSC::ExecState*, unsigned skipArgumentCount);
     43    ScriptCallFrame(const String& functionName, const String& urlString, unsigned lineNumber);
    4844    ~ScriptCallFrame();
    4945
     
    5248    unsigned lineNumber() const { return m_lineNumber; }
    5349
    54     // argument retrieval methods
    55     const ScriptValue& argumentAt(unsigned) const;
    56     unsigned argumentCount() const { return m_arguments.size(); }
     50    bool isEqual(const ScriptCallFrame&) const;
     51    PassRefPtr<InspectorObject> buildInspectorObject() const;
    5752
    5853private:
     
    6055    String m_sourceURL;
    6156    unsigned m_lineNumber;
    62 
    63     Vector<ScriptValue> m_arguments;
    6457};
    6558
  • trunk/WebCore/inspector/ScriptCallStack.cpp

    r70231 r70232  
    3030
    3131#include "config.h"
    32 #include "ScriptCallFrame.h"
     32#include "ScriptCallStack.h"
    3333
    34 #include <runtime/ArgList.h>
    35 #include <runtime/UString.h>
    36 
    37 using namespace JSC;
     34#include "InspectorValues.h"
    3835
    3936namespace WebCore {
    4037
    41 ScriptCallFrame::ScriptCallFrame(const UString& functionName, const UString& urlString, int lineNumber, ExecState* exec, unsigned skipArgumentCount)
    42     : m_functionName(ustringToString(functionName))
    43     , m_sourceURL(ustringToString(urlString))
    44     , m_lineNumber(lineNumber)
     38ScriptCallStack::ScriptCallStack(Vector<ScriptCallFrame>& frames)
    4539{
    46     if (!exec)
    47         return;
    48     size_t argumentCount = exec->argumentCount();
    49     for (size_t i = skipArgumentCount; i < argumentCount; ++i)
    50         m_arguments.append(ScriptValue(exec->argument(i)));
     40    m_frames.swap(frames);
    5141}
    5242
    53 ScriptCallFrame::~ScriptCallFrame()
     43ScriptCallStack::~ScriptCallStack()
    5444{
    5545}
    5646
    57 const ScriptValue &ScriptCallFrame::argumentAt(unsigned index) const
     47const ScriptCallFrame &ScriptCallStack::at(size_t index)
    5848{
    59     ASSERT(m_arguments.size() > index);
    60     return m_arguments[index];
     49    ASSERT(m_frames.size() > index);
     50    return m_frames[index];
     51}
     52
     53size_t ScriptCallStack::size()
     54{
     55    return m_frames.size();
     56}
     57
     58bool ScriptCallStack::isEqual(ScriptCallStack* o) const
     59{
     60    if (!o)
     61        return false;
     62
     63    size_t frameCount = o->m_frames.size();
     64    if (frameCount != m_frames.size())
     65        return false;
     66
     67    for (size_t i = 0; i < frameCount; ++i) {
     68        if (!m_frames[i].isEqual(o->m_frames[i]))
     69            return false;
     70    }
     71
     72    return true;
     73}
     74
     75PassRefPtr<InspectorArray> ScriptCallStack::buildInspectorObject() const
     76{
     77    RefPtr<InspectorArray> frames = InspectorArray::create();
     78    for (size_t i = 0; i < m_frames.size(); i++)
     79        frames->pushObject(m_frames.at(i).buildInspectorObject());
     80    return frames;
    6181}
    6282
  • trunk/WebCore/inspector/ScriptCallStack.h

    r70231 r70232  
    11/*
    2  * Copyright (c) 2008, Google Inc. All rights reserved.
     2 * Copyright (c) 2008, 2010 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3333
    3434#include "ScriptCallFrame.h"
    35 #include "ScriptState.h"
    3635#include <wtf/Noncopyable.h>
    37 #include <wtf/RefPtr.h>
    38 
    39 namespace JSC {
    40     class ExecState;
    41     class JSValue;
    42 }
     36#include <wtf/Vector.h>
    4337
    4438namespace WebCore {
    4539
    46     class InspectorArray;
     40class InspectorArray;
    4741
    48     class ScriptCallStack : public Noncopyable {
    49     public:
    50         ScriptCallStack(JSC::ExecState*, unsigned skipArgumentCount = 0);
    51         ~ScriptCallStack();
     42class ScriptCallStack : public Noncopyable {
     43public:
     44    static const size_t maxCallStackSizeToCapture = 200;
    5245
    53         ScriptState* state() const { return m_exec; }
    54         ScriptState* globalState() const { return m_exec->lexicalGlobalObject()->globalExec(); }
    55         // frame retrieval methods
    56         const ScriptCallFrame &at(unsigned);
    57         unsigned size();
    58         static bool stackTrace(int, const RefPtr<InspectorArray>&);
     46    ScriptCallStack(Vector<ScriptCallFrame>&);
     47    ~ScriptCallStack();
    5948
    60     private:
    61         void initialize();
    62         bool m_initialized;
     49    const ScriptCallFrame &at(size_t);
     50    size_t size();
     51    static bool stackTrace(int, const RefPtr<InspectorArray>&);
    6352
    64         JSC::ExecState* m_exec;
    65         Vector<ScriptCallFrame> m_frames;
    66         JSC::JSFunction* m_caller;
    67     };
     53    bool isEqual(ScriptCallStack*) const;
     54    PassRefPtr<InspectorArray> buildInspectorObject() const;
     55
     56private:
     57    Vector<ScriptCallFrame> m_frames;
     58};
    6859
    6960} // namespace WebCore
  • trunk/WebCore/page/Console.cpp

    r69662 r70232  
    4242#include "PlatformString.h"
    4343
     44#include "ScriptArguments.h"
    4445#include "ScriptCallStack.h"
    4546#include "ScriptProfile.h"
     
    7879}
    7980
    80 static bool getFirstArgumentAsString(ScriptState* scriptState, const ScriptCallFrame& callFrame, String& result, bool checkForNullOrUndefined = false)
    81 {
    82     if (!callFrame.argumentCount())
    83         return false;
    84 
    85     const ScriptValue& value = callFrame.argumentAt(0);
    86     if (checkForNullOrUndefined && (value.isNull() || value.isUndefined()))
    87         return false;
    88 
    89     result = value.toString(scriptState);
    90     return true;
    91 }
    92 
    9381static void printMessageSourceAndLevelPrefix(MessageSource source, MessageLevel level)
    9482{
     
    145133}
    146134
    147 void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, ScriptCallStack* callStack)
     135void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL)
     136{
     137    addMessage(source, type, level, message, lineNumber, sourceURL, 0);
     138}
     139
     140void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, PassOwnPtr<ScriptCallStack> callStack)
    148141{
    149142    Page* page = this->page();
     
    156149#if ENABLE(INSPECTOR)
    157150    if (callStack)
    158         page->inspectorController()->addMessageToConsole(source, type, level, callStack, message);
     151        page->inspectorController()->addMessageToConsole(source, type, level, message, 0, callStack);
    159152    else
    160153        page->inspectorController()->addMessageToConsole(source, type, level, message, lineNumber, sourceURL);
     
    170163}
    171164
    172 void Console::addMessage(MessageType type, MessageLevel level, ScriptCallStack* callStack, bool acceptNoArguments)
     165void Console::addMessage(MessageType type, MessageLevel level, PassOwnPtr<ScriptArguments> arguments,  PassOwnPtr<ScriptCallStack> callStack, bool acceptNoArguments)
    173166{
    174167    Page* page = this->page();
     
    178171    const ScriptCallFrame& lastCaller = callStack->at(0);
    179172
    180     if (!acceptNoArguments && !lastCaller.argumentCount())
     173    if (!acceptNoArguments && !arguments->argumentCount())
    181174        return;
    182175
    183176    String message;
    184     if (getFirstArgumentAsString(callStack->state(), lastCaller, message))
     177    if (arguments->getFirstArgumentAsString(message))
    185178        page->chrome()->client()->addMessageToConsole(JSMessageSource, type, level, message, lastCaller.lineNumber(), lastCaller.sourceURL());
    186179
    187180#if ENABLE(INSPECTOR)
    188     page->inspectorController()->addMessageToConsole(JSMessageSource, type, level, callStack, message);
     181    page->inspectorController()->addMessageToConsole(JSMessageSource, type, level, "", arguments, callStack);
    189182#endif
    190183
     
    195188    printMessageSourceAndLevelPrefix(JSMessageSource, level);
    196189
    197     for (unsigned i = 0; i < lastCaller.argumentCount(); ++i) {
     190    for (unsigned i = 0; i < arguments->argumentCount(); ++i) {
    198191        String argAsString;
    199         if (lastCaller.argumentAt(i).getString(callStack->state(), argAsString))
     192        if (arguments->argumentAt(i).getString(arguments->globalState(), argAsString))
    200193            printf(" %s", argAsString.utf8().data());
    201194    }
     
    203196}
    204197
    205 void Console::debug(ScriptCallStack* callStack)
     198void Console::debug(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
    206199{
    207200    // In Firebug, console.debug has the same behavior as console.log. So we'll do the same.
    208     log(callStack);
    209 }
    210 
    211 void Console::error(ScriptCallStack* callStack)
    212 {
    213     addMessage(LogMessageType, ErrorMessageLevel, callStack);
    214 }
    215 
    216 void Console::info(ScriptCallStack* callStack)
    217 {
    218     log(callStack);
    219 }
    220 
    221 void Console::log(ScriptCallStack* callStack)
    222 {
    223     addMessage(LogMessageType, LogMessageLevel, callStack);
    224 }
    225 
    226 void Console::dir(ScriptCallStack* callStack)
    227 {
    228     addMessage(ObjectMessageType, LogMessageLevel, callStack);
    229 }
    230 
    231 void Console::dirxml(ScriptCallStack* callStack)
     201    log(arguments, callStack);
     202}
     203
     204void Console::error(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
     205{
     206    addMessage(LogMessageType, ErrorMessageLevel, arguments, callStack);
     207}
     208
     209void Console::info(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
     210{
     211    log(arguments, callStack);
     212}
     213
     214void Console::log(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
     215{
     216    addMessage(LogMessageType, LogMessageLevel, arguments, callStack);
     217}
     218
     219void Console::dir(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
     220{
     221    addMessage(ObjectMessageType, LogMessageLevel, arguments, callStack);
     222}
     223
     224void Console::dirxml(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
    232225{
    233226    // The standard behavior of our console.log will print the DOM tree for nodes.
    234     log(callStack);
    235 }
    236 
    237 void Console::trace(ScriptCallStack* callStack)
    238 {
    239     addMessage(TraceMessageType, LogMessageLevel, callStack, true);
     227    log(arguments, callStack);
     228}
     229
     230void Console::trace(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
     231{
     232    addMessage(TraceMessageType, LogMessageLevel, arguments, callStack, true);
    240233
    241234    if (!shouldPrintExceptions())
     
    249242}
    250243
    251 void Console::assertCondition(bool condition, ScriptCallStack* callStack)
     244void Console::assertCondition(bool condition, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
    252245{
    253246    if (condition)
    254247        return;
    255248
    256     addMessage(AssertMessageType, ErrorMessageLevel, callStack, true);
    257 }
    258 
    259 void Console::count(ScriptCallStack* callStack)
     249    addMessage(AssertMessageType, ErrorMessageLevel, arguments, callStack, true);
     250}
     251
     252void Console::count(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
    260253{
    261254#if ENABLE(INSPECTOR)
     
    268261    // the same bucket as no argument
    269262    String title;
    270     getFirstArgumentAsString(callStack->state(), lastCaller, title);
     263    arguments->getFirstArgumentAsString(title);
    271264
    272265    page->inspectorController()->count(title, lastCaller.lineNumber(), lastCaller.sourceURL());
     
    276269}
    277270
    278 void Console::markTimeline(ScriptCallStack* callStack)
    279 {
    280 #if ENABLE(INSPECTOR)
    281     Page* page = this->page();
    282     if (!page)
    283         return;
    284 
    285     const ScriptCallFrame& lastCaller = callStack->at(0);
     271void Console::markTimeline(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>)
     272{
     273#if ENABLE(INSPECTOR)
     274    Page* page = this->page();
     275    if (!page)
     276        return;
     277
    286278    String message;
    287     getFirstArgumentAsString(callStack->state(), lastCaller, message);
     279    arguments->getFirstArgumentAsString(message);
    288280
    289281    page->inspectorController()->markTimeline(message);
    290282#else
    291     UNUSED_PARAM(callStack);
     283    UNUSED_PARAM(arguments);
    292284#endif
    293285}
     
    322314#if ENABLE(JAVASCRIPT_DEBUGGER)
    323315
    324 void Console::profile(const String& title, ScriptCallStack* callStack)
     316void Console::profile(const String& title, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
    325317{
    326318    Page* page = this->page();
     
    343335#endif
    344336
    345     ScriptProfiler::start(callStack->state(), resolvedTitle);
     337    ScriptProfiler::start(arguments->globalState(), resolvedTitle);
    346338
    347339#if ENABLE(INSPECTOR)
     
    351343}
    352344
    353 void Console::profileEnd(const String& title, ScriptCallStack* callStack)
     345void Console::profileEnd(const String& title, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
    354346{
    355347    Page* page = this->page();
     
    363355#endif
    364356
    365     RefPtr<ScriptProfile> profile = ScriptProfiler::stop(callStack->state(), title);
     357    RefPtr<ScriptProfile> profile = ScriptProfiler::stop(arguments->globalState(), title);
    366358    if (!profile)
    367359        return;
     
    395387}
    396388
    397 void Console::timeEnd(const String& title, ScriptCallStack* callStack)
     389void Console::timeEnd(const String& title, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack> callStack)
    398390{
    399391#if ENABLE(INSPECTOR)
     
    421413}
    422414
    423 void Console::group(ScriptCallStack* callStack)
    424 {
    425 #if ENABLE(INSPECTOR)
    426     Page* page = this->page();
    427     if (!page)
    428         return;
    429 
    430     page->inspectorController()->startGroup(JSMessageSource, callStack);
    431 #else
     415void Console::group(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
     416{
     417#if ENABLE(INSPECTOR)
     418    Page* page = this->page();
     419    if (!page)
     420        return;
     421
     422    page->inspectorController()->startGroup(arguments, callStack);
     423#else
     424    UNUSED_PARAM(arguments);
    432425    UNUSED_PARAM(callStack);
    433426#endif
    434427}
    435428
    436 void Console::groupCollapsed(ScriptCallStack* callStack)
    437 {
    438 #if ENABLE(INSPECTOR)
    439     Page* page = this->page();
    440     if (!page)
    441         return;
    442 
    443     page->inspectorController()->startGroup(JSMessageSource, callStack, true);
    444 #else
     429void Console::groupCollapsed(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
     430{
     431#if ENABLE(INSPECTOR)
     432    Page* page = this->page();
     433    if (!page)
     434        return;
     435
     436    page->inspectorController()->startGroup(arguments, callStack, true);
     437#else
     438    UNUSED_PARAM(arguments);
    445439    UNUSED_PARAM(callStack);
    446440#endif
     
    458452}
    459453
    460 void Console::warn(ScriptCallStack* callStack)
    461 {
    462     addMessage(LogMessageType, WarningMessageLevel, callStack);
     454bool Console::shouldCaptureFullStackTrace() const
     455{
     456#if ENABLE(INSPECTOR)
     457    Page* page = this->page();
     458    if (!page)
     459        return false;
     460
     461    return page->inspectorController()->hasFrontend();
     462#else
     463    return false;
     464#endif
     465}
     466
     467void Console::warn(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack)
     468{
     469    addMessage(LogMessageType, WarningMessageLevel, arguments, callStack);
    463470}
    464471
  • trunk/WebCore/page/Console.h

    r65021 r70232  
    3939
    4040namespace WebCore {
     41
     42class ScriptArguments;
    4143
    4244#if ENABLE(JAVASCRIPT_DEBUGGER)
     
    8486    void disconnectFrame();
    8587
    86     void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, ScriptCallStack* callStack = 0);
     88    void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL);
     89    void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, PassOwnPtr<ScriptCallStack> callStack);
    8790
    88     void debug(ScriptCallStack*);
    89     void error(ScriptCallStack*);
    90     void info(ScriptCallStack*);
    91     void log(ScriptCallStack*);
    92     void warn(ScriptCallStack*);
    93     void dir(ScriptCallStack*);
    94     void dirxml(ScriptCallStack*);
    95     void trace(ScriptCallStack*);
    96     void assertCondition(bool condition, ScriptCallStack*);
    97     void count(ScriptCallStack*);
    98     void markTimeline(ScriptCallStack*);
     91    void debug(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
     92    void error(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
     93    void info(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
     94    void log(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
     95    void warn(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
     96    void dir(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
     97    void dirxml(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
     98    void trace(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
     99    void assertCondition(bool condition, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
     100    void count(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
     101    void markTimeline(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
    99102#if ENABLE(WML)
    100103    String lastWMLErrorMessage() const;
    101104#endif
    102105#if ENABLE(JAVASCRIPT_DEBUGGER)
    103     void profile(const String&, ScriptCallStack*);
    104     void profileEnd(const String&, ScriptCallStack*);
     106    void profile(const String&, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
     107    void profileEnd(const String&, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
    105108#endif
    106109    void time(const String&);
    107     void timeEnd(const String&, ScriptCallStack*);
    108     void group(ScriptCallStack*);
    109     void groupCollapsed(ScriptCallStack*);
     110    void timeEnd(const String&, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
     111    void group(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
     112    void groupCollapsed(PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);
    110113    void groupEnd();
     114
     115    bool shouldCaptureFullStackTrace() const;
    111116
    112117    static bool shouldPrintExceptions();
     
    121126private:
    122127    inline Page* page() const;
    123     void addMessage(MessageType, MessageLevel, ScriptCallStack*, bool acceptNoArguments = false);
     128    void addMessage(MessageType, MessageLevel, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>, bool acceptNoArguments = false);
    124129
    125130    Console(Frame*);
Note: See TracChangeset for help on using the changeset viewer.