OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 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 20 matching lines...) Expand all Loading... |
31 | 31 |
32 #include "core/dom/Document.h" | 32 #include "core/dom/Document.h" |
33 #include "core/dom/ScriptableDocumentParser.h" | 33 #include "core/dom/ScriptableDocumentParser.h" |
34 #include "core/inspector/ConsoleAPITypes.h" | 34 #include "core/inspector/ConsoleAPITypes.h" |
35 #include "core/inspector/InspectorConsoleInstrumentation.h" | 35 #include "core/inspector/InspectorConsoleInstrumentation.h" |
36 #include "core/inspector/ScriptCallStack.h" | 36 #include "core/inspector/ScriptCallStack.h" |
37 #include "core/page/Chrome.h" | 37 #include "core/page/Chrome.h" |
38 #include "core/page/ChromeClient.h" | 38 #include "core/page/ChromeClient.h" |
39 #include "core/page/ConsoleTypes.h" | 39 #include "core/page/ConsoleTypes.h" |
40 #include "core/page/Page.h" | 40 #include "core/page/Page.h" |
| 41 #include "wtf/text/StringBuilder.h" |
41 #include "wtf/text/WTFString.h" | 42 #include "wtf/text/WTFString.h" |
42 | 43 |
43 namespace WebCore { | 44 namespace WebCore { |
44 | 45 |
45 namespace { | 46 namespace { |
46 | 47 |
47 int muteCount = 0; | 48 int muteCount = 0; |
48 | 49 |
49 } | 50 } |
50 | 51 |
(...skipping 24 matching lines...) Expand all Loading... |
75 return; | 76 return; |
76 | 77 |
77 if (callStack) | 78 if (callStack) |
78 InspectorInstrumentation::addMessageToConsole(page, source, LogMessageTy
pe, level, message, callStack, requestIdentifier); | 79 InspectorInstrumentation::addMessageToConsole(page, source, LogMessageTy
pe, level, message, callStack, requestIdentifier); |
79 else | 80 else |
80 InspectorInstrumentation::addMessageToConsole(page, source, LogMessageTy
pe, level, message, url, lineNumber, columnNumber, state, requestIdentifier); | 81 InspectorInstrumentation::addMessageToConsole(page, source, LogMessageTy
pe, level, message, url, lineNumber, columnNumber, state, requestIdentifier); |
81 | 82 |
82 if (source == CSSMessageSource) | 83 if (source == CSSMessageSource) |
83 return; | 84 return; |
84 | 85 |
85 page->chrome().client().addMessageToConsole(source, level, message, lineNumb
er, url); | 86 String stackTrace; |
| 87 if (page->chrome().client().shouldReportDetailedMessageForSource(url) && cal
lStack) |
| 88 stackTrace = formatStackTraceString(message, callStack); |
| 89 |
| 90 page->chrome().client().addMessageToConsole(source, level, message, lineNumb
er, url, stackTrace); |
86 } | 91 } |
87 | 92 |
88 // static | 93 String PageConsole::formatStackTraceString(const String& originalMessage, PassRe
fPtr<ScriptCallStack> callStack) |
| 94 { |
| 95 StringBuilder stackTrace; |
| 96 for (size_t i = 0; i < callStack->size(); ++i) { |
| 97 const ScriptCallFrame& frame = callStack->at(i); |
| 98 stackTrace.append("\n at " + (frame.functionName().length() ? frame.f
unctionName() : "(anonymous function)")); |
| 99 stackTrace.append(" ("); |
| 100 stackTrace.append(frame.sourceURL()); |
| 101 stackTrace.append(':'); |
| 102 stackTrace.append(String::number(frame.lineNumber())); |
| 103 stackTrace.append(':'); |
| 104 stackTrace.append(String::number(frame.columnNumber())); |
| 105 stackTrace.append(')'); |
| 106 } |
| 107 |
| 108 return stackTrace.toString(); |
| 109 } |
| 110 |
89 void PageConsole::mute() | 111 void PageConsole::mute() |
90 { | 112 { |
91 muteCount++; | 113 muteCount++; |
92 } | 114 } |
93 | 115 |
94 // static | |
95 void PageConsole::unmute() | 116 void PageConsole::unmute() |
96 { | 117 { |
97 ASSERT(muteCount > 0); | 118 ASSERT(muteCount > 0); |
98 muteCount--; | 119 muteCount--; |
99 } | 120 } |
100 | 121 |
101 } // namespace WebCore | 122 } // namespace WebCore |
OLD | NEW |