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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 if (!page) | 66 if (!page) |
67 return; | 67 return; |
68 | 68 |
69 if (!acceptNoArguments && !arguments->argumentCount()) | 69 if (!acceptNoArguments && !arguments->argumentCount()) |
70 return; | 70 return; |
71 | 71 |
72 size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture :
1; | 72 size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture :
1; |
73 RefPtr<ScriptCallStack> callStack(createScriptCallStack(state, stackSize)); | 73 RefPtr<ScriptCallStack> callStack(createScriptCallStack(state, stackSize)); |
74 const ScriptCallFrame& lastCaller = callStack->at(0); | 74 const ScriptCallFrame& lastCaller = callStack->at(0); |
75 | 75 |
| 76 String executionContextURL = state->scriptExecutionContext()->url().string()
; |
| 77 bool reportDetailedMessage = page->chrome().client()->shouldReportDetailedMe
ssageForContext(state->context()) || page->chrome().client()->shouldReportDetail
edMessageForURL(executionContextURL); |
| 78 |
76 String message; | 79 String message; |
77 bool gotMessage = arguments->getFirstArgumentAsString(message); | 80 bool gotMessage = arguments->getFirstArgumentAsString(message); |
78 InspectorInstrumentation::addMessageToConsole(page, ConsoleAPIMessageSource,
type, level, message, state, arguments); | 81 |
| 82 OwnPtr<ConsoleMessage> consoleMessage = adoptPtr(new ConsoleMessage(reportDe
tailedMessage, ConsoleAPIMessageSource, type, level, message, executionContextUR
L, prpArguments, state, 0)); |
79 | 83 |
80 if (gotMessage) | 84 if (gotMessage) |
81 page->chrome().client()->addMessageToConsole(ConsoleAPIMessageSource, ty
pe, level, message, lastCaller.lineNumber(), lastCaller.sourceURL()); | 85 page->chrome().client()->addMessageToConsole(ConsoleAPIMessageSource, le
vel, message, lastCaller.lineNumber(), lastCaller.sourceURL(), consoleMessage->g
enerateJSONWithoutArguments()->toJSONString()); |
| 86 |
| 87 InspectorInstrumentation::addMessageToConsole(page, consoleMessage.release()
); |
82 } | 88 } |
83 | 89 |
84 void Console::debug(ScriptState* state, PassRefPtr<ScriptArguments> arguments) | 90 void Console::debug(ScriptState* state, PassRefPtr<ScriptArguments> arguments) |
85 { | 91 { |
86 internalAddMessage(page(), LogMessageType, DebugMessageLevel, state, argumen
ts); | 92 internalAddMessage(page(), LogMessageType, DebugMessageLevel, state, argumen
ts); |
87 } | 93 } |
88 | 94 |
89 void Console::error(ScriptState* state, PassRefPtr<ScriptArguments> arguments) | 95 void Console::error(ScriptState* state, PassRefPtr<ScriptArguments> arguments) |
90 { | 96 { |
91 internalAddMessage(page(), LogMessageType, ErrorMessageLevel, state, argumen
ts); | 97 internalAddMessage(page(), LogMessageType, ErrorMessageLevel, state, argumen
ts); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 InspectorInstrumentation::stopConsoleTiming(m_frame, title, callStack.releas
e()); | 208 InspectorInstrumentation::stopConsoleTiming(m_frame, title, callStack.releas
e()); |
203 } | 209 } |
204 | 210 |
205 void Console::timeStamp(PassRefPtr<ScriptArguments> arguments) | 211 void Console::timeStamp(PassRefPtr<ScriptArguments> arguments) |
206 { | 212 { |
207 InspectorInstrumentation::consoleTimeStamp(m_frame, arguments); | 213 InspectorInstrumentation::consoleTimeStamp(m_frame, arguments); |
208 } | 214 } |
209 | 215 |
210 void Console::group(ScriptState* state, PassRefPtr<ScriptArguments> arguments) | 216 void Console::group(ScriptState* state, PassRefPtr<ScriptArguments> arguments) |
211 { | 217 { |
212 InspectorInstrumentation::addMessageToConsole(page(), ConsoleAPIMessageSourc
e, StartGroupMessageType, LogMessageLevel, String(), state, arguments); | 218 InspectorInstrumentation::addMessageToConsole(page(), adoptPtr(new ConsoleMe
ssage(false, ConsoleAPIMessageSource, StartGroupMessageType, LogMessageLevel, St
ring(), String(), arguments, state, 0))); |
213 } | 219 } |
214 | 220 |
215 void Console::groupCollapsed(ScriptState* state, PassRefPtr<ScriptArguments> arg
uments) | 221 void Console::groupCollapsed(ScriptState* state, PassRefPtr<ScriptArguments> arg
uments) |
216 { | 222 { |
217 InspectorInstrumentation::addMessageToConsole(page(), ConsoleAPIMessageSourc
e, StartGroupCollapsedMessageType, LogMessageLevel, String(), state, arguments); | 223 InspectorInstrumentation::addMessageToConsole(page(), adoptPtr(new ConsoleMe
ssage(false, ConsoleAPIMessageSource, StartGroupCollapsedMessageType, LogMessage
Level, String(), String(), arguments, state, 0))); |
218 } | 224 } |
219 | 225 |
220 void Console::groupEnd() | 226 void Console::groupEnd() |
221 { | 227 { |
222 InspectorInstrumentation::addMessageToConsole(page(), ConsoleAPIMessageSourc
e, EndGroupMessageType, LogMessageLevel, String(), String(), 0, 0); | 228 InspectorInstrumentation::addMessageToConsole(page(), adoptPtr(new ConsoleMe
ssage(false, ConsoleAPIMessageSource, EndGroupMessageType, LogMessageLevel, Stri
ng(), String(), String(), 0, 0, 0, 0)), true); |
223 } | 229 } |
224 | 230 |
225 PassRefPtr<MemoryInfo> Console::memory() const | 231 PassRefPtr<MemoryInfo> Console::memory() const |
226 { | 232 { |
227 // FIXME: Because we create a new object here each time, | 233 // FIXME: Because we create a new object here each time, |
228 // console.memory !== console.memory, which seems wrong. | 234 // console.memory !== console.memory, which seems wrong. |
229 return MemoryInfo::create(m_frame); | 235 return MemoryInfo::create(m_frame); |
230 } | 236 } |
231 | 237 |
232 Page* Console::page() const | 238 Page* Console::page() const |
233 { | 239 { |
234 if (!m_frame) | 240 if (!m_frame) |
235 return 0; | 241 return 0; |
236 return m_frame->page(); | 242 return m_frame->page(); |
237 } | 243 } |
238 | 244 |
239 } // namespace WebCore | 245 } // namespace WebCore |
OLD | NEW |