OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "core/inspector/InspectorConsoleInstrumentation.h" | 35 #include "core/inspector/InspectorConsoleInstrumentation.h" |
36 #include "core/inspector/ScriptArguments.h" | 36 #include "core/inspector/ScriptArguments.h" |
37 #include "core/inspector/ScriptCallStack.h" | 37 #include "core/inspector/ScriptCallStack.h" |
38 #include "core/inspector/ScriptProfile.h" | 38 #include "core/inspector/ScriptProfile.h" |
39 #include "core/page/Chrome.h" | 39 #include "core/page/Chrome.h" |
40 #include "core/page/ChromeClient.h" | 40 #include "core/page/ChromeClient.h" |
41 #include "core/page/ConsoleTypes.h" | 41 #include "core/page/ConsoleTypes.h" |
42 #include "core/page/Frame.h" | 42 #include "core/page/Frame.h" |
43 #include "core/page/MemoryInfo.h" | 43 #include "core/page/MemoryInfo.h" |
44 #include "core/page/Page.h" | 44 #include "core/page/Page.h" |
| 45 #include "core/page/PageConsole.h" |
45 #include "wtf/text/CString.h" | 46 #include "wtf/text/CString.h" |
46 #include "wtf/text/WTFString.h" | 47 #include "wtf/text/WTFString.h" |
47 | 48 |
48 #include "core/platform/chromium/TraceEvent.h" | 49 #include "core/platform/chromium/TraceEvent.h" |
49 | 50 |
50 namespace WebCore { | 51 namespace WebCore { |
51 | 52 |
52 Console::Console(Frame* frame) | 53 Console::Console(Frame* frame) |
53 : DOMWindowProperty(frame) | 54 : DOMWindowProperty(frame) |
54 { | 55 { |
55 ScriptWrappable::init(this); | 56 ScriptWrappable::init(this); |
56 } | 57 } |
57 | 58 |
58 Console::~Console() | 59 Console::~Console() |
59 { | 60 { |
60 } | 61 } |
61 | 62 |
62 static void internalAddMessage(Page* page, MessageType type, MessageLevel level,
ScriptState* state, PassRefPtr<ScriptArguments> prpArguments, bool acceptNoArgu
ments = false, bool printTrace = false) | 63 static void internalAddMessage(Page* page, MessageType type, MessageLevel level,
ScriptState* state, PassRefPtr<ScriptArguments> prpArguments, bool acceptNoArgu
ments = false, bool printTrace = false) |
63 { | 64 { |
64 RefPtr<ScriptArguments> arguments = prpArguments; | 65 RefPtr<ScriptArguments> arguments = prpArguments; |
65 | 66 |
66 if (!page) | 67 if (!page) |
67 return; | 68 return; |
68 | 69 |
69 if (!acceptNoArguments && !arguments->argumentCount()) | 70 if (!acceptNoArguments && !arguments->argumentCount()) |
70 return; | 71 return; |
71 | 72 |
72 size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture :
1; | |
73 RefPtr<ScriptCallStack> callStack(createScriptCallStack(state, stackSize)); | |
74 const ScriptCallFrame& lastCaller = callStack->at(0); | |
75 | |
76 String message; | 73 String message; |
77 bool gotMessage = arguments->getFirstArgumentAsString(message); | 74 bool gotMessage = arguments->getFirstArgumentAsString(message); |
78 InspectorInstrumentation::addMessageToConsole(page, ConsoleAPIMessageSource,
type, level, message, state, arguments); | 75 InspectorInstrumentation::addMessageToConsole(page, ConsoleAPIMessageSource,
type, level, message, state, arguments); |
79 | 76 |
80 if (gotMessage) | 77 String stackTrace; |
81 page->chrome().client().addMessageToConsole(ConsoleAPIMessageSource, typ
e, level, message, lastCaller.lineNumber(), lastCaller.sourceURL()); | 78 if (gotMessage) { |
| 79 RefPtr<ScriptCallStack> callStack(createScriptCallStack(state, 1)); |
| 80 if (page->chrome().client().shouldReportDetailedMessageForSource(callSta
ck->at(0).sourceURL())) { |
| 81 callStack = createScriptCallStack(ScriptCallStack::maxCallStackSizeT
oCapture); |
| 82 stackTrace = PageConsole::formatStackTraceString(message, callStack)
; |
| 83 } |
| 84 page->chrome().client().addMessageToConsole(ConsoleAPIMessageSource, lev
el, message, callStack->at(0).lineNumber(), callStack->at(0).sourceURL(), stackT
race); |
| 85 } |
82 } | 86 } |
83 | 87 |
84 void Console::debug(ScriptState* state, PassRefPtr<ScriptArguments> arguments) | 88 void Console::debug(ScriptState* state, PassRefPtr<ScriptArguments> arguments) |
85 { | 89 { |
86 internalAddMessage(page(), LogMessageType, DebugMessageLevel, state, argumen
ts); | 90 internalAddMessage(page(), LogMessageType, DebugMessageLevel, state, argumen
ts); |
87 } | 91 } |
88 | 92 |
89 void Console::error(ScriptState* state, PassRefPtr<ScriptArguments> arguments) | 93 void Console::error(ScriptState* state, PassRefPtr<ScriptArguments> arguments) |
90 { | 94 { |
91 internalAddMessage(page(), LogMessageType, ErrorMessageLevel, state, argumen
ts); | 95 internalAddMessage(page(), LogMessageType, ErrorMessageLevel, state, argumen
ts); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 } | 234 } |
231 | 235 |
232 Page* Console::page() const | 236 Page* Console::page() const |
233 { | 237 { |
234 if (!m_frame) | 238 if (!m_frame) |
235 return 0; | 239 return 0; |
236 return m_frame->page(); | 240 return m_frame->page(); |
237 } | 241 } |
238 | 242 |
239 } // namespace WebCore | 243 } // namespace WebCore |
OLD | NEW |