| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 FrameConsole::FrameConsole(LocalFrame& frame) | 49 FrameConsole::FrameConsole(LocalFrame& frame) |
| 50 : m_frame(frame) | 50 : m_frame(frame) |
| 51 { | 51 { |
| 52 } | 52 } |
| 53 | 53 |
| 54 void FrameConsole::addMessage(MessageSource source, MessageLevel level, const St
ring& message) | 54 void FrameConsole::addMessage(MessageSource source, MessageLevel level, const St
ring& message) |
| 55 { | 55 { |
| 56 addMessage(source, level, message, String(), 0, 0, nullptr, 0, 0); | 56 addMessage(source, level, message, String(), 0, 0, nullptr, 0, 0); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void FrameConsole::addMessage(MessageSource source, MessageLevel level, const St
ring& message, PassRefPtr<ScriptCallStack> callStack) | 59 void FrameConsole::addMessage(MessageSource source, MessageLevel level, const St
ring& message, PassRefPtrWillBeRawPtr<ScriptCallStack> callStack) |
| 60 { | 60 { |
| 61 addMessage(source, level, message, String(), 0, 0, callStack, 0); | 61 addMessage(source, level, message, String(), 0, 0, callStack, 0); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void FrameConsole::addMessage(MessageSource source, MessageLevel level, const St
ring& message, const String& url, unsigned lineNumber, unsigned columnNumber, Pa
ssRefPtr<ScriptCallStack> callStack, ScriptState* scriptState, unsigned long req
uestIdentifier) | 64 void FrameConsole::addMessage(MessageSource source, MessageLevel level, const St
ring& message, const String& url, unsigned lineNumber, unsigned columnNumber, Pa
ssRefPtrWillBeRawPtr<ScriptCallStack> callStack, ScriptState* scriptState, unsig
ned long requestIdentifier) |
| 65 { | 65 { |
| 66 if (muteCount) | 66 if (muteCount) |
| 67 return; | 67 return; |
| 68 | 68 |
| 69 // FIXME: This should not need to reach for the main-frame. | 69 // FIXME: This should not need to reach for the main-frame. |
| 70 // Inspector code should just take the current frame and know how to walk it
self. | 70 // Inspector code should just take the current frame and know how to walk it
self. |
| 71 ExecutionContext* context = m_frame.document(); | 71 ExecutionContext* context = m_frame.document(); |
| 72 if (!context) | 72 if (!context) |
| 73 return; | 73 return; |
| 74 | 74 |
| 75 String messageURL; | 75 String messageURL; |
| 76 if (callStack) { | 76 if (callStack) { |
| 77 messageURL = callStack->at(0).sourceURL(); | 77 messageURL = callStack->at(0).sourceURL(); |
| 78 InspectorInstrumentation::addMessageToConsole(context, source, LogMessag
eType, level, message, callStack, requestIdentifier); | 78 InspectorInstrumentation::addMessageToConsole(context, source, LogMessag
eType, level, message, callStack, requestIdentifier); |
| 79 } else { | 79 } else { |
| 80 messageURL = url; | 80 messageURL = url; |
| 81 InspectorInstrumentation::addMessageToConsole(context, source, LogMessag
eType, level, message, url, lineNumber, columnNumber, scriptState, requestIdenti
fier); | 81 InspectorInstrumentation::addMessageToConsole(context, source, LogMessag
eType, level, message, url, lineNumber, columnNumber, scriptState, requestIdenti
fier); |
| 82 } | 82 } |
| 83 | 83 |
| 84 if (source == CSSMessageSource) | 84 if (source == CSSMessageSource) |
| 85 return; | 85 return; |
| 86 | 86 |
| 87 String stackTrace; | 87 String stackTrace; |
| 88 if (callStack && m_frame.chromeClient().shouldReportDetailedMessageForSource
(messageURL)) | 88 if (callStack && m_frame.chromeClient().shouldReportDetailedMessageForSource
(messageURL)) |
| 89 stackTrace = FrameConsole::formatStackTraceString(message, callStack); | 89 stackTrace = FrameConsole::formatStackTraceString(message, callStack); |
| 90 | 90 |
| 91 m_frame.chromeClient().addMessageToConsole(&m_frame, source, level, message,
lineNumber, messageURL, stackTrace); | 91 m_frame.chromeClient().addMessageToConsole(&m_frame, source, level, message,
lineNumber, messageURL, stackTrace); |
| 92 } | 92 } |
| 93 | 93 |
| 94 String FrameConsole::formatStackTraceString(const String& originalMessage, PassR
efPtr<ScriptCallStack> callStack) | 94 String FrameConsole::formatStackTraceString(const String& originalMessage, PassR
efPtrWillBeRawPtr<ScriptCallStack> callStack) |
| 95 { | 95 { |
| 96 StringBuilder stackTrace; | 96 StringBuilder stackTrace; |
| 97 for (size_t i = 0; i < callStack->size(); ++i) { | 97 for (size_t i = 0; i < callStack->size(); ++i) { |
| 98 const ScriptCallFrame& frame = callStack->at(i); | 98 const ScriptCallFrame& frame = callStack->at(i); |
| 99 stackTrace.append("\n at " + (frame.functionName().length() ? frame.f
unctionName() : "(anonymous function)")); | 99 stackTrace.append("\n at " + (frame.functionName().length() ? frame.f
unctionName() : "(anonymous function)")); |
| 100 stackTrace.append(" ("); | 100 stackTrace.append(" ("); |
| 101 stackTrace.append(frame.sourceURL()); | 101 stackTrace.append(frame.sourceURL()); |
| 102 stackTrace.append(':'); | 102 stackTrace.append(':'); |
| 103 stackTrace.append(String::number(frame.lineNumber())); | 103 stackTrace.append(String::number(frame.lineNumber())); |
| 104 stackTrace.append(':'); | 104 stackTrace.append(':'); |
| 105 stackTrace.append(String::number(frame.columnNumber())); | 105 stackTrace.append(String::number(frame.columnNumber())); |
| 106 stackTrace.append(')'); | 106 stackTrace.append(')'); |
| 107 } | 107 } |
| 108 | 108 |
| 109 return stackTrace.toString(); | 109 return stackTrace.toString(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void FrameConsole::mute() | 112 void FrameConsole::mute() |
| 113 { | 113 { |
| 114 muteCount++; | 114 muteCount++; |
| 115 } | 115 } |
| 116 | 116 |
| 117 void FrameConsole::unmute() | 117 void FrameConsole::unmute() |
| 118 { | 118 { |
| 119 ASSERT(muteCount > 0); | 119 ASSERT(muteCount > 0); |
| 120 muteCount--; | 120 muteCount--; |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace WebCore | 123 } // namespace WebCore |
| OLD | NEW |