Changeset 70300 in webkit
- Timestamp:
- Oct 22, 2010 4:40:11 AM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 deleted
- 29 edited
- 1 copied
- 7 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/Android.jscbindings.mk
r70298 r70300 167 167 bindings/js/ScriptArray.cpp \ 168 168 bindings/js/ScriptCachedFrameData.cpp \ 169 bindings/js/ScriptCallStackFactory.cpp \ 169 bindings/js/ScriptCallFrame.cpp \ 170 bindings/js/ScriptCallStack.cpp \ 170 171 bindings/js/ScriptController.cpp \ 171 172 bindings/js/ScriptEventListener.cpp \ -
trunk/WebCore/Android.v8bindings.mk
r70298 r70300 50 50 bindings/v8/ScopedDOMDataStore.cpp \ 51 51 bindings/v8/ScriptArray.cpp \ 52 bindings/v8/ScriptCallStackFactory.cpp \ 52 bindings/v8/ScriptCallFrame.cpp \ 53 bindings/v8/ScriptCallStack.cpp \ 53 54 bindings/v8/ScriptController.cpp \ 54 55 bindings/v8/ScriptEventListener.cpp \ -
trunk/WebCore/CMakeLists.txt
r70298 r70300 687 687 bindings/js/ScheduledAction.cpp 688 688 bindings/js/ScriptCachedFrameData.cpp 689 bindings/js/ScriptCallStackFactory.cpp 689 bindings/js/ScriptCallFrame.cpp 690 bindings/js/ScriptCallStack.cpp 690 691 bindings/js/ScriptController.cpp 691 692 bindings/js/ScriptDebugServer.cpp … … 1123 1124 inspector/InspectorStorageAgent.cpp 1124 1125 inspector/InspectorTimelineAgent.cpp 1125 inspector/ScriptArguments.cpp1126 1126 inspector/ScriptBreakpoint.cpp 1127 inspector/ScriptCallFrame.cpp1128 inspector/ScriptCallStack.cpp1129 1127 inspector/TimelineRecordFactory.cpp 1130 1128 -
trunk/WebCore/ChangeLog
r70298 r70300 1 2010-10-21 Yury Semikhatsky <yurys@chromium.org> 2 3 Unreviewed, rolling out r70298.WebKit win compilation failure. 4 http://trac.webkit.org/changeset/70298 5 https://bugs.webkit.org/show_bug.cgi?id=48122 6 1 7 2010-10-21 Yury Semikhatsky <yurys@chromium.org> 2 8 -
trunk/WebCore/GNUmakefile.am
r70298 r70300 817 817 WebCore/bindings/js/ScriptCachedFrameData.cpp \ 818 818 WebCore/bindings/js/ScriptCachedFrameData.h \ 819 WebCore/bindings/js/ScriptCallStackFactory.cpp \ 820 WebCore/bindings/js/ScriptCallStackFactory.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 \ 821 823 WebCore/bindings/js/ScriptController.cpp \ 822 824 WebCore/bindings/js/ScriptController.h \ … … 1851 1853 WebCore/inspector/InspectorValues.h \ 1852 1854 WebCore/inspector/InspectorWorkerResource.h \ 1853 WebCore/inspector/ScriptArguments.cpp \1854 WebCore/inspector/ScriptArguments.h \1855 1855 WebCore/inspector/ScriptBreakpoint.cpp \ 1856 1856 WebCore/inspector/ScriptBreakpoint.h \ 1857 WebCore/inspector/ScriptCallFrame.cpp \1858 WebCore/inspector/ScriptCallFrame.h \1859 WebCore/inspector/ScriptCallStack.cpp \1860 WebCore/inspector/ScriptCallStack.h \1861 1857 WebCore/inspector/ScriptDebugListener.h \ 1862 1858 WebCore/inspector/ScriptGCEventListener.h \ -
trunk/WebCore/WebCore.gypi
r70298 r70300 700 700 'bindings/js/ScriptCachedFrameData.cpp', 701 701 'bindings/js/ScriptCachedFrameData.h', 702 'bindings/js/ScriptCallFrame.cpp', 703 'bindings/js/ScriptCallFrame.h', 704 'bindings/js/ScriptCallStack.cpp', 705 'bindings/js/ScriptCallStack.h', 702 706 'bindings/js/ScriptController.cpp', 703 707 'bindings/js/ScriptController.h', … … 866 870 'bindings/v8/ScopedDOMDataStore.h', 867 871 'bindings/v8/ScriptCachedFrameData.h', 868 'bindings/v8/ScriptCallStackFactory.cpp', 869 'bindings/v8/ScriptCallStackFactory.h', 872 'bindings/v8/ScriptCallFrame.cpp', 873 'bindings/v8/ScriptCallFrame.h', 874 'bindings/v8/ScriptCallStack.cpp', 875 'bindings/v8/ScriptCallStack.h', 870 876 'bindings/v8/ScriptController.cpp', 871 877 'bindings/v8/ScriptController.h', … … 1949 1955 'inspector/ScriptBreakpoint.cpp', 1950 1956 'inspector/ScriptBreakpoint.h', 1951 'inspector/ScriptArguments.cpp',1952 'inspector/ScriptArguments.h',1953 'inspector/ScriptCallFrame.cpp',1954 'inspector/ScriptCallFrame.h',1955 'inspector/ScriptCallStack.cpp',1956 'inspector/ScriptCallStack.h',1957 1957 'inspector/ScriptDebugListener.h', 1958 1958 'inspector/ScriptGCEventListener.h', -
trunk/WebCore/WebCore.pro
r70298 r70300 352 352 # bindings/v8/ScriptArray.cpp \ 353 353 bindings/v8/ScriptCachedFrameData.cpp \ 354 bindings/v8/ScriptCallStackFactory.cpp \ 354 bindings/v8/ScriptCallFrame.cpp \ 355 bindings/v8/ScriptCallStack.cpp \ 355 356 bindings/ScriptControllerBase.cpp \ 356 357 bindings/v8/ScriptController.cpp \ … … 574 575 bindings/js/JSWorkerContextErrorHandler.cpp \ 575 576 bindings/js/ScriptCachedFrameData.cpp \ 576 bindings/js/ScriptCallStackFactory.cpp \ 577 bindings/js/ScriptCallFrame.cpp \ 578 bindings/js/ScriptCallStack.cpp \ 577 579 bindings/js/ScriptController.cpp \ 578 580 bindings/js/ScriptDebugServer.cpp \ … … 1011 1013 inspector/InspectorTimelineAgent.cpp \ 1012 1014 inspector/InspectorValues.cpp \ 1013 inspector/ScriptArguments.cpp \1014 1015 inspector/ScriptBreakpoint.cpp \ 1015 inspector/ScriptCallFrame.cpp \1016 inspector/ScriptCallStack.cpp \1017 1016 inspector/TimelineRecordFactory.cpp \ 1018 1017 loader/archive/ArchiveFactory.cpp \ … … 1390 1389 # bindings/v8/ScriptArray.h \ 1391 1390 bindings/v8/ScriptCachedFrameData.h \ 1391 bindings/v8/ScriptCallFrame.h \ 1392 bindings/v8/ScriptCallStack.h \ 1392 1393 bindings/v8/ScriptController.h \ 1393 1394 bindings/v8/ScriptEventListener.h \ … … 1472 1473 bindings/js/ScheduledAction.h \ 1473 1474 bindings/js/ScriptCachedFrameData.h \ 1475 bindings/js/ScriptCallFrame.h \ 1476 bindings/js/ScriptCallStack.h \ 1474 1477 bindings/js/ScriptController.h \ 1475 1478 bindings/js/ScriptEventListener.h \ -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r70298 r70300 60399 60399 </File> 60400 60400 <File 60401 RelativePath="..\bindings\js\ScriptCall StackFactory.cpp"60401 RelativePath="..\bindings\js\ScriptCallFrame.cpp" 60402 60402 > 60403 60403 <FileConfiguration … … 60451 60451 </File> 60452 60452 <File 60453 RelativePath="..\bindings\js\ScriptCallStackFactory.h" 60453 RelativePath="..\bindings\js\ScriptCallFrame.h" 60454 > 60455 </File> 60456 <File 60457 RelativePath="..\bindings\js\ScriptCallStack.cpp" 60458 > 60459 <FileConfiguration 60460 Name="Debug|Win32" 60461 ExcludedFromBuild="true" 60462 > 60463 <Tool 60464 Name="VCCLCompilerTool" 60465 /> 60466 </FileConfiguration> 60467 <FileConfiguration 60468 Name="Release|Win32" 60469 ExcludedFromBuild="true" 60470 > 60471 <Tool 60472 Name="VCCLCompilerTool" 60473 /> 60474 </FileConfiguration> 60475 <FileConfiguration 60476 Name="Debug_Internal|Win32" 60477 ExcludedFromBuild="true" 60478 > 60479 <Tool 60480 Name="VCCLCompilerTool" 60481 /> 60482 </FileConfiguration> 60483 <FileConfiguration 60484 Name="Debug_Cairo|Win32" 60485 ExcludedFromBuild="true" 60486 > 60487 <Tool 60488 Name="VCCLCompilerTool" 60489 /> 60490 </FileConfiguration> 60491 <FileConfiguration 60492 Name="Release_Cairo|Win32" 60493 ExcludedFromBuild="true" 60494 > 60495 <Tool 60496 Name="VCCLCompilerTool" 60497 /> 60498 </FileConfiguration> 60499 <FileConfiguration 60500 Name="Debug_All|Win32" 60501 ExcludedFromBuild="true" 60502 > 60503 <Tool 60504 Name="VCCLCompilerTool" 60505 /> 60506 </FileConfiguration> 60507 </File> 60508 <File 60509 RelativePath="..\bindings\js\ScriptCallStack.h" 60454 60510 > 60455 60511 </File> … … 63344 63400 </File> 63345 63401 <File 63346 RelativePath="..\inspector\ScriptArguments.cpp"63347 >63348 </File>63349 <File63350 RelativePath="..\inspector\ScriptArguments.h"63351 >63352 </File>63353 <File63354 63402 RelativePath="..\inspector\ScriptBreakpoint.cpp" 63355 63403 > … … 63357 63405 <File 63358 63406 RelativePath="..\inspector\ScriptBreakpoint.h" 63359 >63360 </File>63361 <File63362 RelativePath="..\inspector\ScriptCallFrame.cpp"63363 >63364 </File>63365 <File63366 RelativePath="..\inspector\ScriptCallFrame.h"63367 >63368 </File>63369 <File63370 RelativePath="..\inspector\ScriptCallStack.cpp"63371 >63372 </File>63373 <File63374 RelativePath="..\inspector\ScriptCallStack.h"63375 63407 > 63376 63408 </File> -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r70298 r70300 5461 5461 F3644B001119805900E0D537 /* InjectedScript.h in Headers */ = {isa = PBXBuildFile; fileRef = F3644AFE1119805900E0D537 /* InjectedScript.h */; }; 5462 5462 F375CC071150D300008DDB81 /* InspectorWorkerResource.h in Headers */ = {isa = PBXBuildFile; fileRef = F375CC061150D300008DDB81 /* InspectorWorkerResource.h */; }; 5463 F392249C126F11AE00A926D9 /* ScriptCallStackFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F392249A126F11AE00A926D9 /* ScriptCallStackFactory.cpp */; };5464 F392249D126F11AE00A926D9 /* ScriptCallStackFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = F392249B126F11AE00A926D9 /* ScriptCallStackFactory.h */; };5465 F39BE95B12673BF400E0A674 /* ScriptArguments.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F39BE95912673BF400E0A674 /* ScriptArguments.cpp */; };5466 F39BE95C12673BF400E0A674 /* ScriptArguments.h in Headers */ = {isa = PBXBuildFile; fileRef = F39BE95A12673BF400E0A674 /* ScriptArguments.h */; };5467 5463 F3D461481161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */; }; 5468 5464 F3D461491161D53200CA0D09 /* JSWorkerContextErrorHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */; }; … … 11493 11489 F3644AFE1119805900E0D537 /* InjectedScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedScript.h; sourceTree = "<group>"; }; 11494 11490 F375CC061150D300008DDB81 /* InspectorWorkerResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorWorkerResource.h; sourceTree = "<group>"; }; 11495 F392249A126F11AE00A926D9 /* ScriptCallStackFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptCallStackFactory.cpp; sourceTree = "<group>"; };11496 F392249B126F11AE00A926D9 /* ScriptCallStackFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptCallStackFactory.h; sourceTree = "<group>"; };11497 F39BE95912673BF400E0A674 /* ScriptArguments.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptArguments.cpp; sourceTree = "<group>"; };11498 F39BE95A12673BF400E0A674 /* ScriptArguments.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptArguments.h; sourceTree = "<group>"; };11499 11491 F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerContextErrorHandler.cpp; sourceTree = "<group>"; }; 11500 11492 F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWorkerContextErrorHandler.h; sourceTree = "<group>"; }; … … 12269 12261 1C81BA050E97348300266E07 /* JavaScriptCallFrame.idl */, 12270 12262 BCC64F5F0DCFB84E0081EF3B /* localizedStrings.js */, 12271 F39BE95912673BF400E0A674 /* ScriptArguments.cpp */,12272 F39BE95A12673BF400E0A674 /* ScriptArguments.h */,12273 12263 200B190811C277D900DCCD3A /* ScriptBreakpoint.cpp */, 12274 12264 7AFD4A8A1131C2760035B883 /* ScriptBreakpoint.h */, 12275 416E75CA0EDF90C700360E1D /* ScriptCallFrame.cpp */,12276 416E75C90EDF90C700360E1D /* ScriptCallFrame.h */,12277 416E75BD0EDF8FD700360E1D /* ScriptCallStack.cpp */,12278 416E75BC0EDF8FD700360E1D /* ScriptCallStack.h */,12279 12265 7AFD4FF3113277B60035B883 /* ScriptDebugListener.h */, 12280 12266 9FA37EEF1172FD4100C4CD55 /* ScriptProfile.idl */, … … 16793 16779 41F1D21E0EF35C2A00DA8753 /* ScriptCachedFrameData.cpp */, 16794 16780 41F1D21D0EF35C2A00DA8753 /* ScriptCachedFrameData.h */, 16795 F392249A126F11AE00A926D9 /* ScriptCallStackFactory.cpp */, 16796 F392249B126F11AE00A926D9 /* ScriptCallStackFactory.h */, 16781 416E75CA0EDF90C700360E1D /* ScriptCallFrame.cpp */, 16782 416E75C90EDF90C700360E1D /* ScriptCallFrame.h */, 16783 416E75BD0EDF8FD700360E1D /* ScriptCallStack.cpp */, 16784 416E75BC0EDF8FD700360E1D /* ScriptCallStack.h */, 16797 16785 93B70D5309EB0C7C009D8468 /* ScriptController.cpp */, 16798 16786 93B70D5409EB0C7C009D8468 /* ScriptController.h */, … … 20571 20559 5162C7F511F77EFB00612EFE /* SchemeRegistry.h in Headers */, 20572 20560 BCEC01BE0C274DAC009F4EC9 /* Screen.h in Headers */, 20573 F39BE95C12673BF400E0A674 /* ScriptArguments.h in Headers */,20574 20561 A84D82C111D3474800972990 /* ScriptableDocumentParser.h in Headers */, 20575 20562 7AFD4A8B1131C2760035B883 /* ScriptBreakpoint.h in Headers */, … … 21147 21134 081CDFBA126ECFDB00D215CA /* DeprecatedSVGAnimatedTemplate.h in Headers */, 21148 21135 081CDFBF126ECFE800D215CA /* SVGAnimatedPropertySynchronizer.h in Headers */, 21149 F392249D126F11AE00A926D9 /* ScriptCallStackFactory.h in Headers */,21150 21136 088A0E04126EF1DB00978F7A /* SVGAnimatedListPropertyTearOff.h in Headers */, 21151 21137 088A0E05126EF1DB00978F7A /* SVGAnimatedProperty.h in Headers */, … … 23203 23189 BCEC01BD0C274DAC009F4EC9 /* Screen.cpp in Sources */, 23204 23190 A84D82C211D3474800972990 /* ScriptableDocumentParser.cpp in Sources */, 23205 F39BE95B12673BF400E0A674 /* ScriptArguments.cpp in Sources */,23206 23191 200B190911C277D900DCCD3A /* ScriptBreakpoint.cpp in Sources */, 23207 23192 41F1D2200EF35C2A00DA8753 /* ScriptCachedFrameData.cpp in Sources */, … … 23712 23697 E18772F1126E2629003DD586 /* Language.cpp in Sources */, 23713 23698 7A1F2B52126C61B20006A7E6 /* InspectorClient.cpp in Sources */, 23714 F392249C126F11AE00A926D9 /* ScriptCallStackFactory.cpp in Sources */,23715 23699 ); 23716 23700 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/bindings/js/JSBindingsAllInOne.cpp
r70298 r70300 142 142 #include "ScheduledAction.cpp" 143 143 #include "ScriptCachedFrameData.cpp" 144 #include "ScriptCallStackFactory.cpp" 144 #include "ScriptCallFrame.cpp" 145 #include "ScriptCallStack.cpp" 145 146 #include "ScriptController.cpp" 146 147 #include "ScriptControllerWin.cpp" -
trunk/WebCore/bindings/js/JSConsoleCustom.cpp
r70298 r70300 30 30 #include "Console.h" 31 31 #include "JSScriptProfile.h" 32 #include "ScriptCallStack.h"33 #include "ScriptCallStackFactory.h"34 32 #include "ScriptProfile.h" 35 33 #include <runtime/JSArray.h> 36 #include <wtf/OwnPtr.h>37 34 38 35 using namespace JSC; … … 56 53 } 57 54 58 JSValue JSConsole::profile(ExecState* exec)59 {60 OwnPtr<ScriptCallStack> callStack(createScriptCallStack(exec, 1));61 const String& title = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0));62 if (exec->hadException())63 return jsUndefined();64 65 impl()->profile(title, exec, callStack.release());66 return jsUndefined();67 }68 69 JSValue JSConsole::profileEnd(ExecState* exec)70 {71 OwnPtr<ScriptCallStack> callStack(createScriptCallStack(exec, 1));72 const String& title = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0));73 if (exec->hadException())74 return jsUndefined();75 76 impl()->profileEnd(title, exec, callStack.release());77 return jsUndefined();78 }79 80 55 #endif 81 56 -
trunk/WebCore/bindings/js/ScriptCallFrame.cpp
r70299 r70300 1 1 /* 2 * Copyright (c) 20 10Google Inc. All rights reserved.2 * Copyright (c) 2008, Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 */ 30 30 31 #i fndef ScriptCallStackFactory_h32 # define ScriptCallStackFactory_h31 #include "config.h" 32 #include "ScriptCallFrame.h" 33 33 34 #include <wtf/PassOwnPtr.h> 34 #include <runtime/ArgList.h> 35 #include <runtime/UString.h> 35 36 36 namespace JSC { 37 class ExecState; 38 } 37 using namespace JSC; 39 38 40 39 namespace WebCore { 41 40 42 class ScriptArguments; 43 class ScriptCallStack; 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 } 44 52 45 PassOwnPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState*, size_t maxStackSize); 46 PassOwnPtr<ScriptArguments> createScriptArguments(JSC::ExecState*, unsigned skipArgumentCount); 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 } 47 62 48 63 } // namespace WebCore 49 50 #endif // ScriptCallStackFactory_h -
trunk/WebCore/bindings/js/ScriptCallFrame.h
r70299 r70300 1 1 /* 2 * Copyright (c) 20 10Google Inc. All rights reserved.2 * Copyright (c) 2008, Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 34 34 #include "PlatformString.h" 35 #include <wtf/PassRefPtr.h> 35 #include "ScriptValue.h" 36 #include <wtf/Vector.h> 37 38 namespace JSC { 39 class ExecState; 40 class UString; 41 } 36 42 37 43 namespace WebCore { 38 44 39 class InspectorObject;40 41 45 class ScriptCallFrame { 42 46 public: 43 ScriptCallFrame(const String& functionName, const String& urlString, unsigned lineNumber);47 ScriptCallFrame(const JSC::UString& functionName, const JSC::UString& urlString, int lineNumber, JSC::ExecState*, unsigned skipArgumentCount); 44 48 ~ScriptCallFrame(); 45 49 … … 48 52 unsigned lineNumber() const { return m_lineNumber; } 49 53 50 bool isEqual(const ScriptCallFrame&) const; 51 PassRefPtr<InspectorObject> buildInspectorObject() const; 54 // argument retrieval methods 55 const ScriptValue& argumentAt(unsigned) const; 56 unsigned argumentCount() const { return m_arguments.size(); } 52 57 53 58 private: … … 55 60 String m_sourceURL; 56 61 unsigned m_lineNumber; 62 63 Vector<ScriptValue> m_arguments; 57 64 }; 58 65 -
trunk/WebCore/bindings/js/ScriptCallStack.cpp
r70299 r70300 1 1 /* 2 * Copyright (c) 20 10Google Inc. All rights reserved.2 * Copyright (c) 2008, Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 30 30 31 31 #include "config.h" 32 #include "ScriptCallStack Factory.h"32 #include "ScriptCallStack.h" 33 33 34 #include "JSDOMBinding.h"35 #include "ScriptArguments.h"36 #include "ScriptCallFrame.h"37 #include "ScriptCallStack.h"38 #include "ScriptValue.h"39 34 #include <interpreter/CallFrame.h> 40 35 #include <interpreter/Interpreter.h> 41 #include <runtime/ArgList.h>42 36 #include <runtime/JSFunction.h> 43 #include <runtime/JSGlobalData.h>44 37 #include <runtime/JSValue.h> 45 38 #include <runtime/UString.h> 39 #include <runtime/JSGlobalData.h> 46 40 47 41 using namespace JSC; … … 49 43 namespace WebCore { 50 44 51 PassOwnPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t maxStackSize) 45 ScriptCallStack::ScriptCallStack(ExecState* exec, unsigned skipArgumentCount) 46 : m_initialized(false) 47 , m_exec(exec) 48 , m_caller(0) 52 49 { 53 Vector<ScriptCallFrame> frames; 54 CallFrame* callFrame = exec; 50 int signedLineNumber; 51 intptr_t sourceID; 52 UString urlString; 53 JSValue function; 54 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)); 66 } 67 } 68 69 ScriptCallStack::~ScriptCallStack() 70 { 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(); 55 100 while (true) { 56 101 ASSERT(callFrame); 57 int signedLineNumber; 58 intptr_t sourceID; 59 UString urlString; 60 JSValue function; 61 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 } 102 m_exec->interpreter()->retrieveLastCaller(callFrame, signedLineNumber, sourceID, urlString, function); 103 if (!function) 104 break; 105 JSFunction* jsFunction = asFunction(function); 72 106 unsigned lineNumber = signedLineNumber >= 0 ? signedLineNumber : 0; 73 frames.append(ScriptCallFrame(ustringToString(functionName), ustringToString(urlString), lineNumber)); 74 if (!function || frames.size() == maxStackSize) 75 break; 107 m_frames.append(ScriptCallFrame(jsFunction->name(m_exec), urlString, lineNumber, m_exec, 0)); 76 108 callFrame = callFrame->callerFrame(); 77 109 } 78 return new ScriptCallStack(frames); 79 } 80 81 PassOwnPtr<ScriptArguments> createScriptArguments(JSC::ExecState* exec, unsigned skipArgumentCount) 82 { 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); 110 m_initialized = true; 88 111 } 89 112 -
trunk/WebCore/bindings/js/ScriptCallStack.h
r70299 r70300 1 1 /* 2 * Copyright (c) 2008, 2010Google Inc. All rights reserved.2 * Copyright (c) 2008, Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 34 34 #include "ScriptCallFrame.h" 35 #include "ScriptState.h" 35 36 #include <wtf/Noncopyable.h> 36 #include <wtf/Vector.h> 37 #include <wtf/RefPtr.h> 38 39 namespace JSC { 40 class ExecState; 41 class JSValue; 42 } 37 43 38 44 namespace WebCore { 39 45 40 class InspectorArray;46 class InspectorArray; 41 47 42 class ScriptCallStack : public Noncopyable { 43 public: 44 static const size_t maxCallStackSizeToCapture = 200; 48 class ScriptCallStack : public Noncopyable { 49 public: 50 ScriptCallStack(JSC::ExecState*, unsigned skipArgumentCount = 0); 51 ~ScriptCallStack(); 45 52 46 ScriptCallStack(Vector<ScriptCallFrame>&); 47 ~ScriptCallStack(); 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>&); 48 59 49 const ScriptCallFrame &at(size_t);50 size_t size();51 static bool stackTrace(int, const RefPtr<InspectorArray>&);60 private: 61 void initialize(); 62 bool m_initialized; 52 63 53 bool isEqual(ScriptCallStack*) const; 54 PassRefPtr<InspectorArray> buildInspectorObject() const; 55 56 private: 57 Vector<ScriptCallFrame> m_frames; 58 }; 64 JSC::ExecState* m_exec; 65 Vector<ScriptCallFrame> m_frames; 66 JSC::JSFunction* m_caller; 67 }; 59 68 60 69 } // namespace WebCore -
trunk/WebCore/bindings/js/ScriptState.h
r70298 r70300 33 33 #define ScriptState_h 34 34 35 #include <interpreter/CallFrame.h> 36 #include <runtime/JSGlobalObject.h> 35 #include "JSDOMBinding.h" 37 36 #include <runtime/Protect.h> 38 37 #include <wtf/Noncopyable.h> … … 54 53 ScriptStateProtectedPtr() { } 55 54 ScriptStateProtectedPtr(ScriptState* scriptState) : m_globalObject(scriptState->lexicalGlobalObject()) { } 56 ScriptState* get() const55 ScriptState* get() 57 56 { 58 57 if (m_globalObject) -
trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm
r70298 r70300 1967 1967 1968 1968 if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { 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; 1969 push(@implContent, " ScriptCallStack callStack(exec, $numParameters);\n"); 1973 1970 $implIncludes{"ScriptCallStack.h"} = 1; 1974 $implIncludes{"ScriptCallStackFactory.h"} = 1;1975 1971 } 1976 1972 … … 2362 2358 if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { 2363 2359 $functionString .= ", " if $paramIndex; 2364 $paramIndex += 2;2365 $functionString .= " scriptArguments.release(), callStack.release()";2360 ++$paramIndex; 2361 $functionString .= "&callStack"; 2366 2362 } 2367 2363 -
trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm
r70298 r70300 1305 1305 if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { 1306 1306 push(@implContentDecls, <<END); 1307 OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, $numParameters)); 1308 size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1; 1309 OwnPtr<ScriptCallStack> callStack(createScriptCallStack(maxStackSize)); 1307 OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, $numParameters)); 1310 1308 if (!callStack) 1311 1309 return v8::Undefined(); 1312 1310 END 1313 $implIncludes{"ScriptArguments.h"} = 1;1314 1311 $implIncludes{"ScriptCallStack.h"} = 1; 1315 $implIncludes{"ScriptCallStackFactory.h"} = 1;1316 1312 } 1317 1313 if ($function->signature->extendedAttributes->{"SVGCheckSecurityDocument"}) { … … 2724 2720 if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { 2725 2721 $functionString .= ", " if $index; 2726 $functionString .= " scriptArguments.release(), callStack.release()";2727 $index += 2;2722 $functionString .= "callStack.get()"; 2723 $index++; 2728 2724 } 2729 2725 -
trunk/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r70298 r70300 32 32 #include "JSlog.h" 33 33 #include "KURL.h" 34 #include "ScriptArguments.h"35 34 #include "ScriptCallStack.h" 36 #include "ScriptCallStackFactory.h"37 35 #include "SerializedScriptValue.h" 38 36 #include "TestObj.h" … … 997 995 TestObj* imp = static_cast<TestObj*>(castedThis->impl()); 998 996 ExceptionCode ec = 0; 999 OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, 1)); 1000 size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1; 1001 OwnPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize)); 997 ScriptCallStack callStack(exec, 1); 1002 998 log* intArg = tolog(exec->argument(0)); 1003 999 if (exec->hadException()) 1004 1000 return JSValue::encode(jsUndefined()); 1005 1001 1006 imp->customArgsAndException(intArg, scriptArguments.release(), callStack.release(), ec);1002 imp->customArgsAndException(intArg, &callStack, ec); 1007 1003 setDOMException(exec, ec); 1008 1004 return JSValue::encode(jsUndefined()); -
trunk/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
r70298 r70300 27 27 #include "IDBKey.h" 28 28 #include "RuntimeEnabledFeatures.h" 29 #include "ScriptArguments.h"30 29 #include "ScriptCallStack.h" 31 #include "ScriptCallStackFactory.h"32 30 #include "SerializedScriptValue.h" 33 31 #include "V8Binding.h" … … 708 706 ExceptionCode ec = 0; 709 707 { 710 OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 1)); 711 size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1; 712 OwnPtr<ScriptCallStack> callStack(createScriptCallStack(maxStackSize)); 708 OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, 1)); 713 709 if (!callStack) 714 710 return v8::Undefined(); 715 711 EXCEPTION_BLOCK(log*, intArg, V8log::HasInstance(args[0]) ? V8log::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0); 716 imp->customArgsAndException(intArg, scriptArguments.release(), callStack.release(), ec);712 imp->customArgsAndException(intArg, callStack.get(), ec); 717 713 if (UNLIKELY(ec)) 718 714 goto fail; -
trunk/WebCore/bindings/v8/ScriptCallFrame.cpp
r70299 r70300 1 1 /* 2 * Copyright ( c) 2010Google Inc. All rights reserved.3 * 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions are 6 6 * met: 7 * 7 * 8 8 * * Redistributions of source code must retain the above copyright 9 9 * notice, this list of conditions and the following disclaimer. … … 32 32 #include "ScriptCallFrame.h" 33 33 34 #include "InspectorValues.h" 35 #include <wtf/RefPtr.h> 34 #include <v8.h> 35 36 #include "PlatformString.h" 37 #include "V8Binding.h" 38 #include "V8Proxy.h" 39 #include "ScriptValue.h" 36 40 37 41 namespace WebCore { 38 42 39 ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, unsigned lineNumber) 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) 40 53 : m_functionName(functionName) 41 54 , m_sourceURL(urlString) … … 48 61 } 49 62 50 bool ScriptCallFrame::isEqual(const ScriptCallFrame& o) const63 const ScriptValue& ScriptCallFrame::argumentAt(unsigned index) const 51 64 { 52 return m_functionName == o.m_functionName 53 && m_sourceURL == o.m_sourceURL 54 && m_lineNumber == o.m_lineNumber; 55 } 56 57 PassRefPtr<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; 65 ASSERT(m_arguments.size() > index); 66 return m_arguments[index]; 64 67 } 65 68 -
trunk/WebCore/bindings/v8/ScriptCallFrame.h
r70299 r70300 1 1 /* 2 * Copyright ( c) 2010Google Inc. All rights reserved.3 * 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions are 6 6 * met: 7 * 7 * 8 8 * * Redistributions of source code must retain the above copyright 9 9 * notice, this list of conditions and the following disclaimer. … … 29 29 */ 30 30 31 #ifndef Script Arguments_h32 #define Script Arguments_h31 #ifndef ScriptCallFrame_h 32 #define ScriptCallFrame_h 33 33 34 #include " PlatformString.h"35 #include "ScriptState.h" 34 #include "KURL.h" 35 36 36 #include <wtf/Vector.h> 37 37 38 namespace v8 { 39 class Arguments; 40 } 41 38 42 namespace WebCore { 43 class ScriptValue; 39 44 40 class ScriptValue; 45 // FIXME: Implement retrieving line number and source URL and storing here 46 // for all call frames, not just the first one. 47 // See <https://bugs.webkit.org/show_bug.cgi?id=22556> and 48 // <https://bugs.webkit.org/show_bug.cgi?id=21180> 49 class ScriptCallFrame { 50 public: 51 ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber, const v8::Arguments&, unsigned skipArgumentCount); 52 ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber); 53 ~ScriptCallFrame(); 41 54 42 class ScriptArguments { 43 public: 44 ScriptArguments(ScriptState*, Vector<ScriptValue>& arguments); 45 ~ScriptArguments(); 55 const String& functionName() const { return m_functionName; } 56 const String& sourceURL() const { return m_sourceURL; } 57 unsigned lineNumber() const { return m_lineNumber; } 46 58 47 const ScriptValue& argumentAt(size_t) const; 48 size_t argumentCount() const { return m_arguments.size(); } 59 // argument retrieval methods 60 const ScriptValue& argumentAt(unsigned) const; 61 unsigned argumentCount() const { return m_arguments.size(); } 49 62 50 ScriptState* globalState() const; 63 private: 64 String m_functionName; 65 String m_sourceURL; 66 unsigned m_lineNumber; 51 67 52 bool getFirstArgumentAsString(WTF::String& result, bool checkForNullOrUndefined = false); 53 bool isEqual(ScriptArguments*) const; 54 55 private: 56 ScriptStateProtectedPtr m_scriptState; 57 Vector<ScriptValue> m_arguments; 58 }; 68 Vector<ScriptValue> m_arguments; 69 }; 59 70 60 71 } // namespace WebCore 61 72 62 #endif // Script Arguments_h73 #endif // ScriptCallFrame_h -
trunk/WebCore/bindings/v8/ScriptCallStack.cpp
r70299 r70300 1 1 /* 2 * Copyright ( c) 2010Google Inc. All rights reserved.3 * 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions are 6 6 * met: 7 * 7 * 8 8 * * Redistributions of source code must retain the above copyright 9 9 * notice, this list of conditions and the following disclaimer. … … 30 30 31 31 #include "config.h" 32 #include "ScriptCallStack Factory.h"32 #include "ScriptCallStack.h" 33 33 34 34 #include "InspectorValues.h" 35 #include "ScriptArguments.h" 36 #include "ScriptCallFrame.h" 37 #include "ScriptCallStack.h" 35 #include "ScriptController.h" 36 #include "ScriptDebugServer.h" 38 37 #include "ScriptScope.h" 39 #include "ScriptValue.h"40 38 #include "V8Binding.h" 41 39 … … 44 42 namespace WebCore { 45 43 46 static ScriptCallFrame toScriptCallFrame(v8::Handle<v8::StackFrame> frame) 44 static void getFrameLocation(v8::Handle<v8::StackFrame> frame, String* sourceName, int* sourceLineNumber, String* functionName) 45 { 46 ASSERT(!frame.IsEmpty()); 47 v8::Local<v8::String> sourceNameValue(frame->GetScriptNameOrSourceURL()); 48 v8::Local<v8::String> functionNameValue(frame->GetFunctionName()); 49 *sourceName = sourceNameValue.IsEmpty() ? "" : toWebCoreString(sourceNameValue); 50 *functionName = functionNameValue.IsEmpty() ? "" : toWebCoreString(functionNameValue); 51 *sourceLineNumber = frame->GetLineNumber(); 52 } 53 54 static void getTopFrameLocation(v8::Handle<v8::StackTrace> stackTrace, String* sourceName, int* sourceLineNumber, String* functionName) 55 { 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) 47 69 { 48 70 String sourceName; 49 v8::Local<v8::String> sourceNameValue(frame->GetScriptNameOrSourceURL()); 50 if (!sourceNameValue.IsEmpty()) 51 sourceName = toWebCoreString(sourceNameValue); 52 71 int sourceLineNumber; 53 72 String functionName; 54 v8::Local<v8::String> functionNameValue(frame->GetFunctionName()); 55 if (!functionNameValue.IsEmpty()) 56 functionName = toWebCoreString(functionNameValue); 57 58 int sourceLineNumber = frame->GetLineNumber(); 59 return ScriptCallFrame(functionName, sourceName, sourceLineNumber); 73 getFrameLocation(frame, &sourceName, &sourceLineNumber, &functionName); 74 return new ScriptCallFrame(functionName, sourceName, sourceLineNumber); 60 75 } 61 76 62 static void toScriptCallFramesVector(v8::Local<v8::Context> context, v8::Handle<v8::StackTrace> stackTrace, Vector< ScriptCallFrame>& scriptCallFrames, size_t maxStackSize)77 static void toScriptCallFramesVector(v8::Local<v8::Context> context, v8::Handle<v8::StackTrace> stackTrace, Vector<OwnPtr<ScriptCallFrame> >& scriptCallFrames) 63 78 { 64 // TODO(yurys): remove this???65 79 v8::Context::Scope contextScope(context); 66 80 int frameCount = stackTrace->GetFrameCount(); 67 if (frameCount > static_cast<int>(maxStackSize))68 frameCount = maxStackSize;69 81 for (int i = 0; i < frameCount; i++) { 70 82 v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i); 71 83 scriptCallFrames.append(toScriptCallFrame(stackFrame)); 72 84 } 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 }79 85 } 80 86 81 PassOwnPtr<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); 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); 85 93 86 Vector<ScriptCallFrame> scriptCallFrames;87 toScriptCallFramesVector(context, stackTrace, scriptCallFrames, maxStackSize);88 return new ScriptCallStack(scriptCallFrames);89 }90 94 91 PassOwnPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize)95 PassOwnPtr<ScriptCallStack> ScriptCallStack::create(const v8::Arguments& arguments, unsigned skipArgumentCount, int framCountLimit) 92 96 { 93 97 v8::HandleScope scope; 94 98 v8::Local<v8::Context> context = v8::Context::GetCurrent(); 95 // TODO(yurys): remove?96 99 v8::Context::Scope contextScope(context); 97 v8::Handle<v8::StackTrace> stackTrace(v8::StackTrace::CurrentStackTrace(maxStackSize, stackTraceOptions)); 98 return createScriptCallStack(context, stackTrace, maxStackSize); 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); 99 115 } 100 116 101 PassOwnPtr<Script Arguments> createScriptArguments(const v8::Arguments& v8arguments, unsigned skipArgumentCount)117 PassOwnPtr<ScriptCallStack> ScriptCallStack::create(ScriptState* state, v8::Handle<v8::StackTrace> stackTrace) 102 118 { 103 119 v8::HandleScope scope; 104 v8::Local<v8::Context> context = v8::Context::GetCurrent();105 ScriptState* state = ScriptState::forContext(context);120 Vector<OwnPtr<ScriptCallFrame> > scriptCallFrames; 121 toScriptCallFramesVector(state->context(), stackTrace, scriptCallFrames); 106 122 107 Vector<ScriptValue> arguments; 108 for (int i = skipArgumentCount; i < v8arguments.Length(); ++i) 109 arguments.append(ScriptValue(v8arguments[i])); 123 String sourceName; 124 int sourceLineNumber; 125 String functionName; 126 getTopFrameLocation(stackTrace, &sourceName, &sourceLineNumber, &functionName); 110 127 111 return new Script Arguments(state, arguments);128 return new ScriptCallStack(state, new ScriptCallFrame(functionName, sourceName, sourceLineNumber), scriptCallFrames); 112 129 } 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 113 156 114 157 bool ScriptCallStack::stackTrace(int frameLimit, const RefPtr<InspectorArray>& stackTrace) -
trunk/WebCore/bindings/v8/ScriptCallStack.h
r70299 r70300 1 1 /* 2 * Copyright ( c) 2008, 2010Google Inc. All rights reserved.3 * 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions are 6 6 * met: 7 * 7 * 8 8 * * Redistributions of source code must retain the above copyright 9 9 * notice, this list of conditions and the following disclaimer. … … 33 33 34 34 #include "ScriptCallFrame.h" 35 #include "ScriptState.h" 36 #include "ScriptValue.h" 35 37 #include <wtf/Noncopyable.h> 36 #include <wtf/Vector.h> 38 #include <wtf/RefPtr.h> 39 40 namespace v8 { 41 class Arguments; 42 } 37 43 38 44 namespace WebCore { … … 42 48 class ScriptCallStack : public Noncopyable { 43 49 public: 44 static const size_t maxCallStackSizeToCapture = 200; 50 static const int maxCallStackSizeToCapture; 51 static const v8::StackTrace::StackTraceOptions stackTraceOptions; 45 52 46 ScriptCallStack(Vector<ScriptCallFrame>&); 53 static PassOwnPtr<ScriptCallStack> create(const v8::Arguments&, unsigned skipArgumentCount = 0, int framCountLimit = 1); 54 static PassOwnPtr<ScriptCallStack> create(ScriptState*, v8::Handle<v8::StackTrace>); 47 55 ~ScriptCallStack(); 48 56 49 const ScriptCallFrame &at(size_t); 50 size_t size(); 51 static bool stackTrace(int, const RefPtr<InspectorArray>&); 57 // Returns false if there is no running JavaScript or if fetching the stack failed. 58 // Sets stackTrace to be an array of stack frame objects. 59 // A stack frame object looks like: 60 // { 61 // scriptName: <file name for the associated script resource> 62 // functionName: <name of the JavaScript function> 63 // lineNumber: <1 based line number> 64 // column: <1 based column offset on the line> 65 // } 66 static bool stackTrace(int frameLimit, const RefPtr<InspectorArray>& stackTrace); 52 67 53 bool isEqual(ScriptCallStack*) const; 54 PassRefPtr<InspectorArray> buildInspectorObject() const; 68 const ScriptCallFrame& at(unsigned); 69 unsigned size(); 70 71 ScriptState* state() const { return m_scriptState; } 72 ScriptState* globalState() const { return m_scriptState; } 55 73 56 74 private: 57 Vector<ScriptCallFrame> m_frames; 75 ScriptCallStack(ScriptState* scriptState, PassOwnPtr<ScriptCallFrame> topFrame, Vector<OwnPtr<ScriptCallFrame> >& scriptCallFrames); 76 ScriptCallStack(ScriptState* scriptState, v8::Handle<v8::StackTrace> stackTrace); 77 78 OwnPtr<ScriptCallFrame> m_topFrame; 79 ScriptState* m_scriptState; 80 Vector<OwnPtr<ScriptCallFrame> > m_scriptCallFrames; 58 81 }; 59 82 -
trunk/WebCore/bindings/v8/ScriptController.cpp
r70298 r70300 36 36 #include "Document.h" 37 37 #include "ScriptCallStack.h" 38 #include "ScriptCallStackFactory.h"39 38 #include "ScriptableDocumentParser.h" 40 39 #include "DOMWindow.h" … … 470 469 void ScriptController::setCaptureCallStackForUncaughtExceptions(bool value) 471 470 { 472 v8::V8::SetCaptureStackTraceForUncaughtExceptions(value, ScriptCallStack::maxCallStackSizeToCapture, stackTraceOptions);471 v8::V8::SetCaptureStackTraceForUncaughtExceptions(value, ScriptCallStack::maxCallStackSizeToCapture, ScriptCallStack::stackTraceOptions); 473 472 } 474 473 #endif -
trunk/WebCore/bindings/v8/ScriptState.h
r70298 r70300 96 96 } 97 97 } 98 ScriptState* get() const{ return m_scriptState; }98 ScriptState* get() { return m_scriptState; } 99 99 private: 100 100 ScriptState* m_scriptState; -
trunk/WebCore/bindings/v8/V8ConsoleMessage.cpp
r70298 r70300 38 38 #include "Page.h" 39 39 #include "ScriptCallStack.h" 40 #include "ScriptCallStackFactory.h"41 40 #include "V8Binding.h" 42 41 #include "V8Proxy.h" … … 119 118 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) { 120 119 v8::Local<v8::Context> context = v8::Context::GetEntered(); 121 callStack = createScriptCallStack(context, stackTrace, ScriptCallStack::maxCallStackSizeToCapture); 120 ScriptState* scriptState = ScriptState::forContext(context); 121 callStack = ScriptCallStack::create(scriptState, stackTrace); 122 122 } 123 123 … … 126 126 String resourceNameString = useURL ? frame->document()->url() : toWebCoreString(resourceName); 127 127 V8ConsoleMessage consoleMessage(errorMessage, resourceNameString, message->GetLineNumber()); 128 consoleMessage.dispatchNow(page, callStack. release());128 consoleMessage.dispatchNow(page, callStack.get()); 129 129 } 130 130 131 void V8ConsoleMessage::dispatchNow(Page* page, PassOwnPtr<ScriptCallStack>callStack)131 void V8ConsoleMessage::dispatchNow(Page* page, ScriptCallStack* callStack) 132 132 { 133 133 ASSERT(page); -
trunk/WebCore/bindings/v8/V8ConsoleMessage.h
r70298 r70300 34 34 #include "PlatformString.h" 35 35 #include <v8.h> 36 #include <wtf/PassOwnPtr.h>37 36 #include <wtf/Vector.h> 38 37 … … 83 82 const unsigned m_lineNumber; 84 83 85 void dispatchNow(Page*, PassOwnPtr<ScriptCallStack>);84 void dispatchNow(Page*, ScriptCallStack*); 86 85 87 86 // All delayed messages are stored in this vector. If the vector -
trunk/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
- Property svn:executable deleted
r70298 r70300 34 34 35 35 #include "Console.h" 36 #include "ScriptArguments.h"37 36 #include "ScriptCallStack.h" 38 #include "ScriptCallStackFactory.h"39 37 #include "ScriptProfile.h" 40 38 #include "V8Binding.h" 41 #include "V8BindingMacros.h"42 39 #include "V8Proxy.h" 43 40 #include "V8ScriptProfile.h" … … 66 63 INC_STATS("DOM.Console.traceCallback"); 67 64 Console* imp = V8Console::toNative(args.Holder()); 68 OwnPtr<ScriptCallStack> callStack(createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture)); 69 OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 0)); 70 imp->trace(scriptArguments.release(), callStack.release()); 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()); 71 70 return v8::Handle<v8::Value>(); 72 71 } … … 76 75 INC_STATS("DOM.Console.assertCallback"); 77 76 Console* imp = V8Console::toNative(args.Holder()); 78 OwnPtr<ScriptCallStack> callStack( createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture));77 OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, 1, ScriptCallStack::maxCallStackSizeToCapture)); 79 78 bool condition = args[0]->BooleanValue(); 80 OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 1)); 81 imp->assertCondition(condition, scriptArguments.release(), callStack.release()); 82 return v8::Handle<v8::Value>(); 83 } 84 85 v8::Handle<v8::Value> V8Console::profileCallback(const v8::Arguments& args) 86 { 87 INC_STATS("DOM.Console.profile"); 88 Console* imp = V8Console::toNative(args.Holder()); 89 OwnPtr<ScriptCallStack> callStack(createScriptCallStack(1)); 90 if (!callStack) 91 return v8::Undefined(); 92 STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<WithUndefinedOrNullCheck>, title, args[0]); 93 imp->profile(title, ScriptState::current(), callStack.release()); 94 return v8::Handle<v8::Value>(); 95 } 96 97 v8::Handle<v8::Value> V8Console::profileEndCallback(const v8::Arguments& args) 98 { 99 INC_STATS("DOM.Console.profileEnd"); 100 Console* imp = V8Console::toNative(args.Holder()); 101 OwnPtr<ScriptCallStack> callStack(createScriptCallStack(1)); 102 if (!callStack) 103 return v8::Undefined(); 104 STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<WithUndefinedOrNullCheck>, title, args[0]); 105 imp->profileEnd(title, ScriptState::current(), callStack.release()); 79 imp->assertCondition(condition, callStack.get()); 106 80 return v8::Handle<v8::Value>(); 107 81 } -
trunk/WebCore/dom/NodeFilter.h
r70298 r70300 26 26 #define NodeFilter_h 27 27 28 #include "DOMWrapperWorld.h"29 28 #include "NodeFilterCondition.h" 30 29 #include <wtf/RefPtr.h> -
trunk/WebCore/inspector/ConsoleMessage.cpp
r70298 r70300 34 34 #include "InjectedScript.h" 35 35 #include "InjectedScriptHost.h" 36 #include "InspectorFrontend.h"37 36 #include "InspectorValues.h" 38 #include "ScriptArguments.h"39 37 #include "ScriptCallStack.h" 40 38 #include "ScriptValue.h" 41 #include <wtf/PassOwnPtr.h> 39 40 #if ENABLE(INSPECTOR) 41 #include "InspectorFrontend.h" 42 #endif 42 43 43 44 namespace 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 44 75 45 76 ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, unsigned li, const String& u, unsigned g) … … 55 86 } 56 87 57 ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack, unsigned g)88 ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, ScriptCallStack* callStack, unsigned g, bool storeTrace) 58 89 : m_source(s) 59 90 , m_type(t) 60 91 , m_level(l) 61 92 , m_message(m) 62 , m_arguments(arguments) 63 , m_callStack(callStack) 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) 64 98 , m_groupLevel(g) 65 99 , m_repeatCount(1) 66 100 { 67 const ScriptCallFrame& lastCaller = m_callStack->at(0);101 const ScriptCallFrame& lastCaller = callStack->at(0); 68 102 m_line = lastCaller.lineNumber(); 69 103 m_url = lastCaller.sourceURL(); 70 104 105 if (storeTrace) { 106 for (unsigned i = 0; i < callStack->size(); ++i) 107 m_frames[i] = ConsoleMessage::CallFrame(callStack->at(i)); 108 } 71 109 72 bool storeTrace = (t == TraceMessageType || t == UncaughtExceptionMessageType || t == AssertMessageType); 73 if (!storeTrace) 74 m_callStack.clear(); 110 #if ENABLE(INSPECTOR) 111 for (unsigned i = 0; i < lastCaller.argumentCount(); ++i) 112 m_arguments[i] = lastCaller.argumentAt(i); 113 #endif 75 114 } 76 115 116 #if ENABLE(INSPECTOR) 77 117 void ConsoleMessage::addToFrontend(InspectorFrontend* frontend, InjectedScriptHost* injectedScriptHost) 78 118 { … … 86 126 jsonObj->setNumber("repeatCount", static_cast<int>(m_repeatCount)); 87 127 jsonObj->setString("message", m_message); 88 if ( m_arguments && m_arguments->argumentCount()) {89 InjectedScript injectedScript = injectedScriptHost->injectedScriptFor(m_ arguments->globalState());128 if (!m_arguments.isEmpty()) { 129 InjectedScript injectedScript = injectedScriptHost->injectedScriptFor(m_scriptState.get()); 90 130 if (!injectedScript.hasNoValue()) { 91 131 RefPtr<InspectorArray> jsonArgs = InspectorArray::create(); 92 for (unsigned i = 0; i < m_arguments ->argumentCount(); ++i) {93 RefPtr<InspectorValue> inspectorValue = injectedScript.wrapForConsole(m_arguments ->argumentAt(i));132 for (unsigned i = 0; i < m_arguments.size(); ++i) { 133 RefPtr<InspectorValue> inspectorValue = injectedScript.wrapForConsole(m_arguments[i]); 94 134 if (!inspectorValue) { 95 135 ASSERT_NOT_REACHED(); … … 101 141 } 102 142 } 103 if (m_callStack) 104 jsonObj->setArray("stackTrace", m_callStack->buildInspectorObject()); 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 } 105 149 frontend->addConsoleMessage(jsonObj); 106 150 } … … 110 154 frontend->updateConsoleMessageRepeatCount(m_repeatCount); 111 155 } 156 #endif // ENABLE(INSPECTOR) 112 157 113 158 bool ConsoleMessage::isEqual(ConsoleMessage* msg) const 114 159 { 115 if (m_arguments) { 116 if (!m_arguments->isEqual(msg->m_arguments.get())) 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])) 117 170 return false; 118 } else if (msg->m_arguments) 171 } 172 #endif // ENABLE(INSPECTOR) 173 174 size_t frameCount = msg->m_frames.size(); 175 if (frameCount != m_frames.size()) 119 176 return false; 120 177 121 if (m_callStack) {122 if (!m_ callStack->isEqual(msg->m_callStack.get()))178 for (size_t i = 0; i < frameCount; ++i) { 179 if (!m_frames[i].isEqual(msg->m_frames[i])) 123 180 return false; 124 } else if (msg->m_callStack) 125 return false; 181 } 126 182 127 183 return msg->m_source == m_source -
trunk/WebCore/inspector/ConsoleMessage.h
r70298 r70300 2 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 4 * Copyright (C) 2009 , 2010Google Inc. All rights reserved.4 * Copyright (C) 2009 Google Inc. All rights reserved. 5 5 * 6 6 * Redistribution and use in source and binary forms, with or without … … 33 33 34 34 #include "Console.h" 35 #include "KURL.h" 35 36 #include "ScriptState.h" 36 37 37 #include <wtf/Forward.h>38 38 #include <wtf/Vector.h> 39 39 … … 42 42 class InspectorFrontend; 43 43 class InspectorObject; 44 class ScriptArguments;45 44 class ScriptCallFrame; 46 45 class ScriptCallStack; … … 50 49 public: 51 50 ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, unsigned li, const String& u, unsigned g); 52 ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>, unsigned g);51 ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, ScriptCallStack*, unsigned g, bool storeTrace = false); 53 52 53 #if ENABLE(INSPECTOR) 54 54 void addToFrontend(InspectorFrontend*, InjectedScriptHost*); 55 55 void updateRepeatCountInConsole(InspectorFrontend* frontend); 56 #endif 56 57 void incrementCount() { ++m_repeatCount; } 57 58 bool isEqual(ConsoleMessage* msg) const; … … 61 62 62 63 private: 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 63 79 MessageSource m_source; 64 80 MessageType m_type; 65 81 MessageLevel m_level; 66 82 String m_message; 67 OwnPtr<ScriptArguments> m_arguments; 68 OwnPtr<ScriptCallStack> m_callStack; 83 #if ENABLE(INSPECTOR) 84 Vector<ScriptValue> m_arguments; 85 ScriptStateProtectedPtr m_scriptState; 86 #endif 87 Vector<CallFrame> m_frames; 69 88 unsigned m_line; 70 89 String m_url; -
trunk/WebCore/inspector/InspectorController.cpp
r70298 r70300 83 83 #include "ResourceRequest.h" 84 84 #include "ResourceResponse.h" 85 #include "ScriptArguments.h"86 85 #include "ScriptCallStack.h" 87 86 #include "ScriptFunctionCall.h" … … 341 340 } 342 341 343 void 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)); 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)); 349 349 } 350 350 … … 392 392 } 393 393 394 void InspectorController::startGroup( PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>callStack, bool collapsed)394 void InspectorController::startGroup(MessageSource source, ScriptCallStack* callStack, bool collapsed) 395 395 { 396 396 ++m_groupLevel; 397 397 398 addConsoleMessage(new ConsoleMessage( JSMessageSource, collapsed ? StartGroupCollapsedMessageType : StartGroupMessageType, LogMessageLevel, "", arguments, callStack, m_groupLevel));398 addConsoleMessage(new ConsoleMessage(source, collapsed ? StartGroupCollapsedMessageType : StartGroupMessageType, LogMessageLevel, String(), callStack, m_groupLevel)); 399 399 } 400 400 -
trunk/WebCore/inspector/InspectorController.h
r70298 r70300 82 82 class ResourceResponse; 83 83 class ResourceError; 84 class ScriptArguments;85 84 class ScriptCallStack; 86 85 class ScriptProfile; … … 147 146 148 147 void setConsoleMessagesEnabled(bool enabled, bool* newState); 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& );148 void addMessageToConsole(MessageSource, MessageType, MessageLevel, ScriptCallStack*, const String& message); 149 void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID); 151 150 void clearConsoleMessages(); 152 151 const Vector<OwnPtr<ConsoleMessage> >& consoleMessages() const { return m_consoleMessages; } … … 234 233 bool stopTiming(const String& title, double& elapsed); 235 234 236 void startGroup( PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>callFrame, bool collapsed = false);235 void startGroup(MessageSource source, ScriptCallStack* callFrame, bool collapsed = false); 237 236 void endGroup(MessageSource source, unsigned lineNumber, const String& sourceURL); 238 237 -
trunk/WebCore/page/Console.cpp
r70298 r70300 42 42 #include "PlatformString.h" 43 43 44 #include "ScriptArguments.h"45 44 #include "ScriptCallStack.h" 46 45 #include "ScriptProfile.h" … … 79 78 } 80 79 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 81 93 static void printMessageSourceAndLevelPrefix(MessageSource source, MessageLevel level) 82 94 { … … 133 145 } 134 146 135 void 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 140 void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, PassOwnPtr<ScriptCallStack> callStack) 147 void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, ScriptCallStack* callStack) 141 148 { 142 149 Page* page = this->page(); … … 149 156 #if ENABLE(INSPECTOR) 150 157 if (callStack) 151 page->inspectorController()->addMessageToConsole(source, type, level, message, 0, callStack);158 page->inspectorController()->addMessageToConsole(source, type, level, callStack, message); 152 159 else 153 160 page->inspectorController()->addMessageToConsole(source, type, level, message, lineNumber, sourceURL); … … 163 170 } 164 171 165 void Console::addMessage(MessageType type, MessageLevel level, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>callStack, bool acceptNoArguments)166 { 167 Page* page = this->page(); 168 if (!page) 169 return; 170 171 const ScriptCallFrame& lastCaller = callStack->at(0); 172 173 if (!acceptNoArguments && ! arguments->argumentCount())172 void Console::addMessage(MessageType type, MessageLevel level, ScriptCallStack* callStack, bool acceptNoArguments) 173 { 174 Page* page = this->page(); 175 if (!page) 176 return; 177 178 const ScriptCallFrame& lastCaller = callStack->at(0); 179 180 if (!acceptNoArguments && !lastCaller.argumentCount()) 174 181 return; 175 182 176 183 String message; 177 if ( arguments->getFirstArgumentAsString(message))184 if (getFirstArgumentAsString(callStack->state(), lastCaller, message)) 178 185 page->chrome()->client()->addMessageToConsole(JSMessageSource, type, level, message, lastCaller.lineNumber(), lastCaller.sourceURL()); 179 186 180 187 #if ENABLE(INSPECTOR) 181 page->inspectorController()->addMessageToConsole(JSMessageSource, type, level, "", arguments, callStack);188 page->inspectorController()->addMessageToConsole(JSMessageSource, type, level, callStack, message); 182 189 #endif 183 190 … … 188 195 printMessageSourceAndLevelPrefix(JSMessageSource, level); 189 196 190 for (unsigned i = 0; i < arguments->argumentCount(); ++i) {197 for (unsigned i = 0; i < lastCaller.argumentCount(); ++i) { 191 198 String argAsString; 192 if ( arguments->argumentAt(i).getString(arguments->globalState(), argAsString))199 if (lastCaller.argumentAt(i).getString(callStack->state(), argAsString)) 193 200 printf(" %s", argAsString.utf8().data()); 194 201 } … … 196 203 } 197 204 198 void Console::debug( PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>callStack)205 void Console::debug(ScriptCallStack* callStack) 199 206 { 200 207 // In Firebug, console.debug has the same behavior as console.log. So we'll do the same. 201 log( arguments,callStack);202 } 203 204 void Console::error( PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>callStack)205 { 206 addMessage(LogMessageType, ErrorMessageLevel, arguments,callStack);207 } 208 209 void Console::info( PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>callStack)210 { 211 log( arguments,callStack);212 } 213 214 void Console::log( PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>callStack)215 { 216 addMessage(LogMessageType, LogMessageLevel, arguments,callStack);217 } 218 219 void Console::dir( PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>callStack)220 { 221 addMessage(ObjectMessageType, LogMessageLevel, arguments,callStack);222 } 223 224 void Console::dirxml( PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>callStack)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) 225 232 { 226 233 // The standard behavior of our console.log will print the DOM tree for nodes. 227 log( arguments,callStack);228 } 229 230 void Console::trace( PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>callStack)231 { 232 addMessage(TraceMessageType, LogMessageLevel, arguments,callStack, true);234 log(callStack); 235 } 236 237 void Console::trace(ScriptCallStack* callStack) 238 { 239 addMessage(TraceMessageType, LogMessageLevel, callStack, true); 233 240 234 241 if (!shouldPrintExceptions()) … … 242 249 } 243 250 244 void Console::assertCondition(bool condition, PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>callStack)251 void Console::assertCondition(bool condition, ScriptCallStack* callStack) 245 252 { 246 253 if (condition) 247 254 return; 248 255 249 addMessage(AssertMessageType, ErrorMessageLevel, arguments,callStack, true);250 } 251 252 void Console::count( PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>callStack)256 addMessage(AssertMessageType, ErrorMessageLevel, callStack, true); 257 } 258 259 void Console::count(ScriptCallStack* callStack) 253 260 { 254 261 #if ENABLE(INSPECTOR) … … 261 268 // the same bucket as no argument 262 269 String title; 263 arguments->getFirstArgumentAsString(title);270 getFirstArgumentAsString(callStack->state(), lastCaller, title); 264 271 265 272 page->inspectorController()->count(title, lastCaller.lineNumber(), lastCaller.sourceURL()); … … 269 276 } 270 277 271 void Console::markTimeline(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack>) 272 { 273 #if ENABLE(INSPECTOR) 274 Page* page = this->page(); 275 if (!page) 276 return; 277 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); 278 286 String message; 279 arguments->getFirstArgumentAsString(message);287 getFirstArgumentAsString(callStack->state(), lastCaller, message); 280 288 281 289 page->inspectorController()->markTimeline(message); 282 290 #else 283 UNUSED_PARAM( arguments);291 UNUSED_PARAM(callStack); 284 292 #endif 285 293 } … … 314 322 #if ENABLE(JAVASCRIPT_DEBUGGER) 315 323 316 void Console::profile(const String& title, Script State* state, PassOwnPtr<ScriptCallStack>callStack)324 void Console::profile(const String& title, ScriptCallStack* callStack) 317 325 { 318 326 Page* page = this->page(); … … 335 343 #endif 336 344 337 ScriptProfiler::start( state, resolvedTitle);345 ScriptProfiler::start(callStack->state(), resolvedTitle); 338 346 339 347 #if ENABLE(INSPECTOR) … … 343 351 } 344 352 345 void Console::profileEnd(const String& title, Script State* state, PassOwnPtr<ScriptCallStack>callStack)353 void Console::profileEnd(const String& title, ScriptCallStack* callStack) 346 354 { 347 355 Page* page = this->page(); … … 355 363 #endif 356 364 357 RefPtr<ScriptProfile> profile = ScriptProfiler::stop( state, title);365 RefPtr<ScriptProfile> profile = ScriptProfiler::stop(callStack->state(), title); 358 366 if (!profile) 359 367 return; … … 387 395 } 388 396 389 void Console::timeEnd(const String& title, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>callStack)397 void Console::timeEnd(const String& title, ScriptCallStack* callStack) 390 398 { 391 399 #if ENABLE(INSPECTOR) … … 413 421 } 414 422 415 void 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); 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 425 432 UNUSED_PARAM(callStack); 426 433 #endif 427 434 } 428 435 429 void 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); 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 439 445 UNUSED_PARAM(callStack); 440 446 #endif … … 452 458 } 453 459 454 bool 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 467 void Console::warn(PassOwnPtr<ScriptArguments> arguments, PassOwnPtr<ScriptCallStack> callStack) 468 { 469 addMessage(LogMessageType, WarningMessageLevel, arguments, callStack); 460 void Console::warn(ScriptCallStack* callStack) 461 { 462 addMessage(LogMessageType, WarningMessageLevel, callStack); 470 463 } 471 464 -
trunk/WebCore/page/Console.h
r70298 r70300 33 33 #include "PlatformString.h" 34 34 #include "ScriptProfile.h" 35 #include "ScriptState.h"36 35 37 36 #include <wtf/Forward.h> … … 40 39 41 40 namespace WebCore { 42 43 class ScriptArguments;44 41 45 42 #if ENABLE(JAVASCRIPT_DEBUGGER) … … 87 84 void disconnectFrame(); 88 85 89 void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL); 90 void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, PassOwnPtr<ScriptCallStack> callStack); 86 void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, ScriptCallStack* callStack = 0); 91 87 92 void debug( PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);93 void error( PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);94 void info( PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);95 void log( PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);96 void warn( PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);97 void dir( PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);98 void dirxml( PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);99 void trace( PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);100 void assertCondition(bool condition, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);101 void count( PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);102 void markTimeline( PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);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*); 103 99 #if ENABLE(WML) 104 100 String lastWMLErrorMessage() const; 105 101 #endif 106 102 #if ENABLE(JAVASCRIPT_DEBUGGER) 107 const ProfilesArray& profiles() const { return m_profiles; } 108 void profile(const String&, ScriptState*, PassOwnPtr<ScriptCallStack>); 109 void profileEnd(const String&, ScriptState*, PassOwnPtr<ScriptCallStack>); 103 void profile(const String&, ScriptCallStack*); 104 void profileEnd(const String&, ScriptCallStack*); 110 105 #endif 111 106 void time(const String&); 112 void timeEnd(const String&, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);113 void group( PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);114 void groupCollapsed( PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>);107 void timeEnd(const String&, ScriptCallStack*); 108 void group(ScriptCallStack*); 109 void groupCollapsed(ScriptCallStack*); 115 110 void groupEnd(); 116 117 bool shouldCaptureFullStackTrace() const;118 111 119 112 static bool shouldPrintExceptions(); 120 113 static void setShouldPrintExceptions(bool); 114 115 #if ENABLE(JAVASCRIPT_DEBUGGER) 116 const ProfilesArray& profiles() const { return m_profiles; } 117 #endif 121 118 122 119 MemoryInfo* memory() const; … … 124 121 private: 125 122 inline Page* page() const; 126 void addMessage(MessageType, MessageLevel, PassOwnPtr<ScriptArguments>, PassOwnPtr<ScriptCallStack>, bool acceptNoArguments = false);123 void addMessage(MessageType, MessageLevel, ScriptCallStack*, bool acceptNoArguments = false); 127 124 128 125 Console(Frame*); -
trunk/WebCore/page/Console.idl
r70298 r70300 31 31 interface [OmitConstructor] Console { 32 32 33 #if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER 34 readonly attribute [CustomGetter] Array profiles; 35 #endif 36 33 37 [CustomArgumentHandling] void debug(); 34 38 [CustomArgumentHandling] void error(); … … 48 52 49 53 #if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER 50 readonly attribute [CustomGetter] Array profiles; 51 [Custom] void profile(in DOMString title); 52 [Custom] void profileEnd(in DOMString title); 54 [CustomArgumentHandling] void profile(in [ConvertUndefinedOrNullToNullString] DOMString title); 55 [CustomArgumentHandling] void profileEnd(in [ConvertUndefinedOrNullToNullString] DOMString title); 53 56 #endif 54 57
Note: See TracChangeset
for help on using the changeset viewer.