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