Web Inspector: split Console into two entities, a web-facing bound object and page console.

https://bugs.webkit.org/show_bug.cgi?id=111578

Patch by Sergey Ryazanov <serya@chromium.org> on 2013-03-19
Reviewed by Vsevolod Vlasov.

Otherwise, a lot of logging in WebCore needs to go through the DOMWindow which is unnecessary.

Source/WebCore:

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.exp.in:
* WebCore.gypi:
* WebCore.order:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSCustomXPathNSResolver.cpp:
(WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):
* bindings/v8/custom/V8CustomXPathNSResolver.cpp:
(WebCore::V8CustomXPathNSResolver::lookupNamespaceURI):
* dom/Document.cpp:
(WebCore::Document::addConsoleMessage):
(WebCore::Document::addMessage):
* inspector/PageDebuggerAgent.cpp:
(WebCore::PageDebuggerAgent::muteConsole):
(WebCore::PageDebuggerAgent::unmuteConsole):
* inspector/PageRuntimeAgent.cpp:
(WebCore::PageRuntimeAgent::muteConsole):
(WebCore::PageRuntimeAgent::unmuteConsole):
* page/Console.cpp:
(WebCore::internalAddMessage):
* page/Console.h:
(WebCore):
(Console):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::pageConsole):
(WebCore):
(WebCore::DOMWindow::dispatchMessageEventWithOriginCheck):
(WebCore::DOMWindow::printErrorMessage):
* page/DOMWindow.h:
(WebCore):
(DOMWindow):
* page/Page.cpp:
(WebCore::Page::Page):
* page/Page.h:
(WebCore):
(WebCore::Page::console):
(Page):
* page/PageConsole.cpp: Added.
(WebCore::PageConsole::PageConsole):
(WebCore):
(WebCore::PageConsole::~PageConsole):
(WebCore::PageConsole::printSourceURLAndLine):
(WebCore::PageConsole::printMessageSourceAndLevelPrefix):
(WebCore::PageConsole::addMessage):
(WebCore::PageConsole::mute):
(WebCore::PageConsole::unmute):
(WebCore::PageConsole::shouldPrintExceptions):
(WebCore::PageConsole::setShouldPrintExceptions):
* page/PageConsole.h: Copied from Source/WebCore/page/Console.h.
(WebCore):
(PageConsole):
(WebCore::PageConsole::create):
(WebCore::PageConsole::page):
* xml/XSLStyleSheetLibxslt.cpp:
(WebCore::XSLStyleSheet::parseString):
* xml/XSLTProcessorLibxslt.cpp:
(WebCore::XSLTProcessor::parseErrorFunc):
(WebCore::docLoaderFunc):

Source/WebKit/mac:

* Misc/WebCoreStatistics.mm:
(+[WebCoreStatistics shouldPrintExceptions]):
(+[WebCoreStatistics setShouldPrintExceptions:]):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@146208 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e3aba506
......@@ -1788,6 +1788,7 @@ set(WebCore_SOURCES
page/NavigatorBase.cpp
page/OriginAccessEntry.cpp
page/Page.cpp
page/PageConsole.cpp
page/PageGroup.cpp
page/PageGroupLoadDeferrer.cpp
page/PageSerializer.cpp
......
2013-03-19 Sergey Ryazanov <serya@chromium.org>
Web Inspector: split Console into two entities, a web-facing bound object and page console.
https://bugs.webkit.org/show_bug.cgi?id=111578
Reviewed by Vsevolod Vlasov.
Otherwise, a lot of logging in WebCore needs to go through the DOMWindow which is unnecessary.
* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.exp.in:
* WebCore.gypi:
* WebCore.order:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSCustomXPathNSResolver.cpp:
(WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):
* bindings/v8/custom/V8CustomXPathNSResolver.cpp:
(WebCore::V8CustomXPathNSResolver::lookupNamespaceURI):
* dom/Document.cpp:
(WebCore::Document::addConsoleMessage):
(WebCore::Document::addMessage):
* inspector/PageDebuggerAgent.cpp:
(WebCore::PageDebuggerAgent::muteConsole):
(WebCore::PageDebuggerAgent::unmuteConsole):
* inspector/PageRuntimeAgent.cpp:
(WebCore::PageRuntimeAgent::muteConsole):
(WebCore::PageRuntimeAgent::unmuteConsole):
* page/Console.cpp:
(WebCore::internalAddMessage):
* page/Console.h:
(WebCore):
(Console):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::pageConsole):
(WebCore):
(WebCore::DOMWindow::dispatchMessageEventWithOriginCheck):
(WebCore::DOMWindow::printErrorMessage):
* page/DOMWindow.h:
(WebCore):
(DOMWindow):
* page/Page.cpp:
(WebCore::Page::Page):
* page/Page.h:
(WebCore):
(WebCore::Page::console):
(Page):
* page/PageConsole.cpp: Added.
(WebCore::PageConsole::PageConsole):
(WebCore):
(WebCore::PageConsole::~PageConsole):
(WebCore::PageConsole::printSourceURLAndLine):
(WebCore::PageConsole::printMessageSourceAndLevelPrefix):
(WebCore::PageConsole::addMessage):
(WebCore::PageConsole::mute):
(WebCore::PageConsole::unmute):
(WebCore::PageConsole::shouldPrintExceptions):
(WebCore::PageConsole::setShouldPrintExceptions):
* page/PageConsole.h: Copied from Source/WebCore/page/Console.h.
(WebCore):
(PageConsole):
(WebCore::PageConsole::create):
(WebCore::PageConsole::page):
* xml/XSLStyleSheetLibxslt.cpp:
(WebCore::XSLStyleSheet::parseString):
* xml/XSLTProcessorLibxslt.cpp:
(WebCore::XSLTProcessor::parseErrorFunc):
(WebCore::docLoaderFunc):
2013-03-19 Ilya Tikhonovsky <loislo@chromium.org>
Web Inspector: move OverviewGrid and OverviewWindow into separate file.
......@@ -4235,6 +4235,8 @@ webcore_sources += \
Source/WebCore/page/OriginAccessEntry.h \
Source/WebCore/page/Page.cpp \
Source/WebCore/page/Page.h \
Source/WebCore/page/PageConsole.cpp \
Source/WebCore/page/PageConsole.h \
Source/WebCore/page/PageGroup.cpp \
Source/WebCore/page/PageGroup.h \
Source/WebCore/page/PageGroupLoadDeferrer.cpp \
......
......@@ -947,6 +947,7 @@ SOURCES += \
page/NavigatorBase.cpp \
page/OriginAccessEntry.cpp \
page/Page.cpp \
page/PageConsole.cpp \
page/PageGroup.cpp \
page/PageGroupLoadDeferrer.cpp \
page/PageVisibilityState.cpp \
......@@ -2144,6 +2145,7 @@ HEADERS += \
page/PageGroup.h \
page/PageGroupLoadDeferrer.h \
page/Page.h \
page/PageConsole.h \
page/PageVisibilityState.h \
page/PlugInClient.h \
page/PopupOpeningObserver.h \
......
......@@ -936,8 +936,6 @@ __ZN7WebCore6Widget8setFocusEb
__ZN7WebCore6Widget9setParentEPNS_10ScrollViewE
__ZN7WebCore6WidgetD2Ev
__ZN7WebCore6toNodeEN3JSC7JSValueE
__ZN7WebCore7Console21shouldPrintExceptionsEv
__ZN7WebCore7Console24setShouldPrintExceptionsEb
__ZN7WebCore7Element12setAttributeERKN3WTF12AtomicStringES4_Ri
__ZN7WebCore7Element12setAttributeERKNS_13QualifiedNameERKN3WTF12AtomicStringE
__ZN7WebCore7Element21boundsInRootViewSpaceEv
......@@ -1725,6 +1723,8 @@ __ZN7WebCore10handCursorEv
__ZN7WebCore11CachedImage5imageEv
__ZN7WebCore11globalPointERK8_NSPointP8NSWindow
__ZN7WebCore11toUserSpaceERK7_NSRectP8NSWindow
__ZN7WebCore11PageConsole21shouldPrintExceptionsEv
__ZN7WebCore11PageConsole24setShouldPrintExceptionsEb
__ZN7WebCore12EventHandler10mouseMovedEP7NSEvent
__ZN7WebCore12EventHandler10wheelEventEP7NSEvent
__ZN7WebCore12EventHandler12mouseDraggedEP7NSEvent
......
......@@ -2252,6 +2252,7 @@
'page/OriginAccessEntry.cpp',
'page/OriginAccessEntry.h',
'page/Page.cpp',
'page/PageConsole.cpp',
'page/PageGroup.cpp',
'page/PageGroupLoadDeferrer.cpp',
'page/PageGroupLoadDeferrer.h',
......
......@@ -15559,7 +15559,6 @@ __ZN3WTF29RefPtrHashMapRawKeyTranslatorIPN7WebCore14ResourceLoaderESt4pairINS_6R
__ZN3WTF6VectorINS_6RefPtrIN7WebCore15ArchiveResourceEEELm0EED1Ev
__ZN7WebCore5TimerINS_14DocumentLoaderEE5firedEv
__ZN7WebCore14DocumentLoader36substituteResourceDeliveryTimerFiredEPNS_5TimerIS0_EE
__ZN7WebCore7Console24setShouldPrintExceptionsEb
__ZN7WebCore16jsClipboardTypesEPN3JSC9ExecStateENS0_7JSValueERKNS0_10IdentifierE
__ZNK7WebCore11JSClipboard5typesEPN3JSC9ExecStateE
__ZNK7WebCore12ClipboardMac5typesEv
......@@ -15679,6 +15678,7 @@ __ZN7WebCore23RenderFileUploadControl19receiveDroppedFilesERKN3WTF6VectorINS1_6S
__ZN7WebCore23RenderFileUploadControl19allowsMultipleFilesEv
__ZN7WebCore11FileChooser10chooseFileERKN3WTF6StringE
__ZN7WebCore11FileChooser11chooseFilesERKN3WTF6VectorINS1_6StringELm0EEE
__ZN7WebCore11PageConsole24setShouldPrintExceptionsEb
__ZThn184_N7WebCore23RenderFileUploadControl18chooseIconForFilesEPNS_11FileChooserERKN3WTF6VectorINS3_6StringELm0EEE
__ZN7WebCore6Chrome18chooseIconForFilesERKN3WTF6VectorINS1_6StringELm0EEEPNS_11FileChooserE
__ZN7WebCore4Icon18createIconForFilesERKN3WTF6VectorINS1_6StringELm0EEE
......@@ -27590,6 +27590,14 @@
RelativePath="..\page\Page.cpp"
>
</File>
<File
RelativePath="..\page\PageConsole.cpp"
>
</File>
<File
RelativePath="..\page\PageConsole.h"
>
</File>
<File
RelativePath="..\page\PageGroup.cpp"
>
......@@ -3937,6 +3937,7 @@
<ClCompile Include="..\page\NavigatorBase.cpp" />
<ClCompile Include="..\page\OriginAccessEntry.cpp" />
<ClCompile Include="..\page\Page.cpp" />
<ClCompile Include="..\page\PageConsole.cpp" />
<ClCompile Include="..\page\PageGroup.cpp" />
<ClCompile Include="..\page\PageGroupLoadDeferrer.cpp" />
<ClCompile Include="..\page\PageSerializer.cpp" />
......@@ -6696,6 +6696,9 @@
<ClCompile Include="..\page\Page.cpp">
<Filter>page</Filter>
</ClCompile>
<ClCompile Include="..\page\PageConsole.cpp">
<Filter>page</Filter>
</ClCompile>
<ClCompile Include="..\page\PageGroup.cpp">
<Filter>page</Filter>
</ClCompile>
......
......@@ -6153,6 +6153,8 @@
D7613A501474F13F00DB8606 /* WebKitNamedFlow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D7613A4E1474F13F00DB8606 /* WebKitNamedFlow.cpp */; };
D7613AC414753E5600DB8606 /* JSWebKitNamedFlow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D7613AC214753E5600DB8606 /* JSWebKitNamedFlow.cpp */; };
D8B6152F1032495100C8554A /* Cookie.h in Headers */ = {isa = PBXBuildFile; fileRef = D8B6152E1032495100C8554A /* Cookie.h */; settings = {ATTRIBUTES = (Private, ); }; };
DAED203016F2442B0070EC0F /* PageConsole.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DAACB3D916F2416400666135 /* PageConsole.cpp */; };
DAED203116F244480070EC0F /* PageConsole.h in Headers */ = {isa = PBXBuildFile; fileRef = DAACB3DA16F2416400666135 /* PageConsole.h */; settings = {ATTRIBUTES = (Private, ); }; };
DB23C2CB0A508D29002489EB /* IndentOutdentCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DB23C2C90A508D29002489EB /* IndentOutdentCommand.cpp */; };
DB23C2CC0A508D29002489EB /* IndentOutdentCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = DB23C2CA0A508D29002489EB /* IndentOutdentCommand.h */; };
DD05FE0D0B8BA3C6009ACDFE /* WebCoreObjCExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = DD05FE0B0B8BA3C6009ACDFE /* WebCoreObjCExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -13862,6 +13864,8 @@
D7613AC214753E5600DB8606 /* JSWebKitNamedFlow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitNamedFlow.cpp; sourceTree = "<group>"; };
D7613AC314753E5600DB8606 /* JSWebKitNamedFlow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebKitNamedFlow.h; sourceTree = "<group>"; };
D8B6152E1032495100C8554A /* Cookie.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cookie.h; sourceTree = "<group>"; };
DAACB3D916F2416400666135 /* PageConsole.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageConsole.cpp; sourceTree = "<group>"; };
DAACB3DA16F2416400666135 /* PageConsole.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageConsole.h; sourceTree = "<group>"; };
DB23C2C90A508D29002489EB /* IndentOutdentCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IndentOutdentCommand.cpp; sourceTree = "<group>"; };
DB23C2CA0A508D29002489EB /* IndentOutdentCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IndentOutdentCommand.h; sourceTree = "<group>"; };
DD05FE0B0B8BA3C6009ACDFE /* WebCoreObjCExtras.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreObjCExtras.h; sourceTree = "<group>"; };
......@@ -16478,6 +16482,8 @@
975CA287130365F800E99AD9 /* Crypto.cpp */,
975CA288130365F800E99AD9 /* Crypto.h */,
975CA289130365F800E99AD9 /* Crypto.idl */,
DAACB3D916F2416400666135 /* PageConsole.cpp */,
DAACB3DA16F2416400666135 /* PageConsole.h */,
CCC2B51015F613060048CDD6 /* DeviceClient.h */,
CCC2B51115F613060048CDD6 /* DeviceController.cpp */,
CCC2B51215F613060048CDD6 /* DeviceController.h */,
......@@ -26764,6 +26770,7 @@
977E2E0F12F0FC9C00C13379 /* XSSAuditor.h in Headers */,
977E2E0F12F0FC9C00C13380 /* XSSAuditorDelegate.h in Headers */,
FD537353137B651800008DCE /* ZeroPole.h in Headers */,
DAED203116F244480070EC0F /* PageConsole.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -29971,6 +29978,7 @@
977E2E0E12F0FC9C00C13379 /* XSSAuditor.cpp in Sources */,
977E2E0E12F0FC9C00C13380 /* XSSAuditorDelegate.cpp in Sources */,
FD537352137B651800008DCE /* ZeroPole.cpp in Sources */,
DAED203016F2442B0070EC0F /* PageConsole.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -26,12 +26,13 @@
#include "config.h"
#include "JSCustomXPathNSResolver.h"
#include "Console.h"
#include "Document.h"
#include "ExceptionCode.h"
#include "Frame.h"
#include "JSDOMWindowCustom.h"
#include "JSMainThreadExecState.h"
#include "Page.h"
#include "PageConsole.h"
#include "SecurityOrigin.h"
#include <runtime/JSLock.h>
......@@ -78,7 +79,8 @@ String JSCustomXPathNSResolver::lookupNamespaceURI(const String& prefix)
callType = m_customResolver->methodTable()->getCallData(m_customResolver.get(), callData);
if (callType == CallTypeNone) {
// FIXME: Pass actual line number and source URL.
m_globalObject->impl()->console()->addMessage(JSMessageSource, ErrorMessageLevel, "XPathNSResolver does not have a lookupNamespaceURI method.");
if (PageConsole* console = m_globalObject->impl()->pageConsole())
console->addMessage(JSMessageSource, ErrorMessageLevel, "XPathNSResolver does not have a lookupNamespaceURI method.");
return String();
}
function = m_customResolver.get();
......
......@@ -30,8 +30,10 @@
#include "config.h"
#include "V8CustomXPathNSResolver.h"
#include "Console.h"
#include "DOMWindow.h"
#include "Frame.h"
#include "Page.h"
#include "PageConsole.h"
#include "ScriptCallStack.h"
#include "ScriptController.h"
#include "ScriptExecutionContext.h"
......@@ -69,7 +71,9 @@ String V8CustomXPathNSResolver::lookupNamespaceURI(const String& prefix)
}
if (lookupNamespaceURIFunc.IsEmpty() && !m_resolver->IsFunction()) {
activeDOMWindow(BindingState::instance())->console()->addMessage(JSMessageSource, ErrorMessageLevel, "XPathNSResolver does not have a lookupNamespaceURI method.");
Frame* frame = activeDOMWindow(BindingState::instance())->frame();
if (frame && frame->page())
frame->page()->console()->addMessage(JSMessageSource, ErrorMessageLevel, "XPathNSResolver does not have a lookupNamespaceURI method.");
return String();
}
......
......@@ -42,7 +42,6 @@
#include "Chrome.h"
#include "ChromeClient.h"
#include "Comment.h"
#include "Console.h"
#include "ContentSecurityPolicy.h"
#include "ContextFeatures.h"
#include "CookieJar.h"
......@@ -124,6 +123,7 @@
#include "NodeTraversal.h"
#include "NodeWithIndex.h"
#include "Page.h"
#include "PageConsole.h"
#include "PageGroup.h"
#include "PageTransitionEvent.h"
#include "PlatformKeyboardEvent.h"
......@@ -4844,10 +4844,8 @@ void Document::addConsoleMessage(MessageSource source, MessageLevel level, const
return;
}
if (DOMWindow* window = domWindow()) {
if (Console* console = window->console())
console->addMessage(source, level, message, requestIdentifier, this);
}
if (Page* page = this->page())
page->console()->addMessage(source, level, message, requestIdentifier, this);
}
void Document::addMessage(MessageSource source, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallStack> callStack, ScriptState* state, unsigned long requestIdentifier)
......@@ -4857,10 +4855,8 @@ void Document::addMessage(MessageSource source, MessageLevel level, const String
return;
}
if (DOMWindow* window = domWindow()) {
if (Console* console = window->console())
console->addMessage(source, level, message, sourceURL, lineNumber, callStack, state, requestIdentifier);
}
if (Page* page = this->page())
page->console()->addMessage(source, level, message, sourceURL, lineNumber, callStack, state, requestIdentifier);
}
const SecurityOrigin* Document::topOrigin() const
......
......@@ -34,11 +34,11 @@
#include "PageDebuggerAgent.h"
#include "Console.h"
#include "InspectorOverlay.h"
#include "InspectorPageAgent.h"
#include "InstrumentingAgents.h"
#include "Page.h"
#include "PageConsole.h"
#include "PageScriptDebugServer.h"
namespace WebCore {
......@@ -88,12 +88,12 @@ PageScriptDebugServer& PageDebuggerAgent::scriptDebugServer()
void PageDebuggerAgent::muteConsole()
{
Console::mute();
PageConsole::mute();
}
void PageDebuggerAgent::unmuteConsole()
{
Console::unmute();
PageConsole::unmute();
}
InjectedScript PageDebuggerAgent::injectedScriptForEval(ErrorString* errorString, const int* executionContextId)
......
......@@ -34,7 +34,6 @@
#include "PageRuntimeAgent.h"
#include "Console.h"
#include "Document.h"
#include "InjectedScript.h"
#include "InjectedScriptManager.h"
......@@ -42,6 +41,7 @@
#include "InspectorState.h"
#include "InstrumentingAgents.h"
#include "Page.h"
#include "PageConsole.h"
#include "SecurityOrigin.h"
using WebCore::TypeBuilder::Runtime::ExecutionContextDescription;
......@@ -148,12 +148,12 @@ InjectedScript PageRuntimeAgent::injectedScriptForEval(ErrorString* errorString,
void PageRuntimeAgent::muteConsole()
{
Console::mute();
PageConsole::mute();
}
void PageRuntimeAgent::unmuteConsole()
{
Console::unmute();
PageConsole::unmute();
}
void PageRuntimeAgent::reportExecutionContextCreation()
......
......@@ -41,6 +41,7 @@
#include "InspectorController.h"
#include "MemoryInfo.h"
#include "Page.h"
#include "PageConsole.h"
#include "PageGroup.h"
#include "ScriptArguments.h"
#include "ScriptCallStack.h"
......@@ -61,10 +62,6 @@
namespace WebCore {
namespace {
int muteCount = 0;
}
Console::Console(Frame* frame)
: DOMWindowProperty(frame)
{
......@@ -74,126 +71,6 @@ Console::~Console()
{
}
static void printSourceURLAndLine(const String& sourceURL, unsigned lineNumber)
{
if (!sourceURL.isEmpty()) {
if (lineNumber > 0)
printf("%s:%d: ", sourceURL.utf8().data(), lineNumber);
else
printf("%s: ", sourceURL.utf8().data());
}
}
static void printMessageSourceAndLevelPrefix(MessageSource source, MessageLevel level)
{
const char* sourceString;
switch (source) {
case XMLMessageSource:
sourceString = "XML";
break;
case JSMessageSource:
sourceString = "JS";
break;
case NetworkMessageSource:
sourceString = "NETWORK";
break;
case ConsoleAPIMessageSource:
sourceString = "CONSOLEAPI";
break;
case StorageMessageSource:
sourceString = "STORAGE";
break;
case AppCacheMessageSource:
sourceString = "APPCACHE";
break;
case RenderingMessageSource:
sourceString = "RENDERING";
break;
case CSSMessageSource:
sourceString = "CSS";
break;
case SecurityMessageSource:
sourceString = "SECURITY";
break;
case OtherMessageSource:
sourceString = "OTHER";
break;
default:
ASSERT_NOT_REACHED();
sourceString = "UNKNOWN";
break;
}
const char* levelString;
switch (level) {
case DebugMessageLevel:
levelString = "DEBUG";
break;
case LogMessageLevel:
levelString = "LOG";
break;
case WarningMessageLevel:
levelString = "WARN";
break;
case ErrorMessageLevel:
levelString = "ERROR";
break;
default:
ASSERT_NOT_REACHED();
levelString = "UNKNOWN";
break;
}
printf("%s %s:", sourceString, levelString);
}
void Console::addMessage(MessageSource source, MessageLevel level, const String& message, unsigned long requestIdentifier, Document* document)
{
String url;
if (document)
url = document->url().string();
unsigned line = 0;
if (document && document->parsing() && !document->isInDocumentWrite() && document->scriptableDocumentParser()) {
ScriptableDocumentParser* parser = document->scriptableDocumentParser();
if (!parser->isWaitingForScripts() && !parser->isExecutingScript())
line = parser->lineNumber().oneBasedInt();
}
addMessage(source, level, message, url, line, 0, 0, requestIdentifier);
}
void Console::addMessage(MessageSource source, MessageLevel level, const String& message, PassRefPtr<ScriptCallStack> callStack)
{
addMessage(source, level, message, String(), 0, callStack, 0);
}
void Console::addMessage(MessageSource source, MessageLevel level, const String& message, const String& url, unsigned lineNumber, PassRefPtr<ScriptCallStack> callStack, ScriptState* state, unsigned long requestIdentifier)
{
if (muteCount && source != ConsoleAPIMessageSource)
return;
Page* page = this->page();
if (!page)
return;
if (callStack)
InspectorInstrumentation::addMessageToConsole(page, source, LogMessageType, level, message, callStack, requestIdentifier);
else
InspectorInstrumentation::addMessageToConsole(page, source, LogMessageType, level, message, url, lineNumber, state, requestIdentifier);
if (!m_frame->settings() || m_frame->settings()->privateBrowsingEnabled())
return;
page->chrome()->client()->addMessageToConsole(source, level, message, lineNumber, url);
if (!m_frame->settings()->logsPageMessagesToSystemConsoleEnabled() && !shouldPrintExceptions())
return;
printSourceURLAndLine(url, lineNumber);
printMessageSourceAndLevelPrefix(source, level);
printf(" %s\n", message.utf8().data());
}
static void internalAddMessage(Page* page, MessageType type, MessageLevel level, ScriptState* state, PassRefPtr<ScriptArguments> prpArguments, bool acceptNoArguments = false, bool printTrace = false)
{
RefPtr<ScriptArguments> arguments = prpArguments;
......@@ -212,17 +89,17 @@ static void internalAddMessage(Page* page, MessageType type, MessageLevel level,
bool gotMessage = arguments->getFirstArgumentAsString(message);
InspectorInstrumentation::addMessageToConsole(page, ConsoleAPIMessageSource, type, level, message, state, arguments);
if (!page->settings() || page->settings()->privateBrowsingEnabled())
if (page->settings()->privateBrowsingEnabled())
return;
if (gotMessage)
page->chrome()->client()->addMessageToConsole(ConsoleAPIMessageSource, type, level, message, lastCaller.lineNumber(), lastCaller.sourceURL());
if (!page->settings()->logsPageMessagesToSystemConsoleEnabled() && !Console::shouldPrintExceptions())
if (!page->settings()->logsPageMessagesToSystemConsoleEnabled() && !PageConsole::shouldPrintExceptions())
return;
printSourceURLAndLine(lastCaller.sourceURL(), lastCaller.lineNumber());
printMessageSourceAndLevelPrefix(ConsoleAPIMessageSource, level);
PageConsole::printSourceURLAndLine(lastCaller.sourceURL(), lastCaller.lineNumber());
PageConsole::printMessageSourceAndLevelPrefix(ConsoleAPIMessageSource, level);
for (size_t i = 0; i < arguments->argumentCount(); ++i) {
String argAsString = arguments->argumentAt(i).toString(arguments->globalState());
......@@ -388,19 +265,6 @@ void Console::groupEnd()
InspectorInstrumentation::addMessageToConsole(page(), ConsoleAPIMessageSource, EndGroupMessageType, LogMessageLevel, String(), String(), 0);
}
// static
void Console::mute()
{
muteCount++;
}
// static
void Console::unmute()
{
ASSERT(muteCount > 0);
muteCount--;
}
PassRefPtr<MemoryInfo> Console::memory() const
{
// FIXME: Because we create a new object here each time,
......@@ -408,18 +272,6 @@ PassRefPtr<MemoryInfo> Console::memory() const
return MemoryInfo::create(m_frame);
}
static bool printExceptions = false;
bool Console::shouldPrintExceptions()
{
return printExceptions;
}
void Console::setShouldPrintExceptions(bool print)
{
printExceptions = print;
}
Page* Console::page() const
{
if (!m_frame)
......
......@@ -29,10 +29,7 @@
#ifndef Console_h
#define Console_h
#include "ConsoleAPITypes.h"
#include "ConsoleTypes.h"
#include "DOMWindowProperty.h"
#include "ScriptCallStack.h"
#include "ScriptProfile.h"
#include "ScriptState.h"
#include "ScriptWrappable.h"
......@@ -42,12 +39,10 @@
namespace WebCore {
class Document;
class Frame;
class MemoryInfo;
class Page;
class ScriptArguments;
class ScriptCallStack;
#if ENABLE(JAVASCRIPT_DEBUGGER)
typedef Vector<RefPtr<ScriptProfile> > ProfilesArray;
......@@ -58,10 +53,6 @@ public:
static PassRefPtr<Console> create(Frame* frame) { return adoptRef(new Console(frame)); }
virtual ~Console();
void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallStack> = 0, ScriptState* = 0, unsigned long requestIdentifier = 0);
void addMessage(MessageSource, MessageLevel, const String& message, PassRefPtr<ScriptCallStack>);
void addMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0, Document* = 0);
void debug(ScriptState*, PassRefPtr<ScriptArguments>);
void error(ScriptState*, PassRefPtr<ScriptArguments>);
void info(ScriptState*, PassRefPtr<ScriptArguments>);
......@@ -87,12 +78,6 @@ public:
void groupCollapsed(ScriptState*, PassRefPtr<ScriptArguments>);
void groupEnd();
static void mute();
static void unmute();
static bool shouldPrintExceptions();
static void setShouldPrintExceptions(bool);
PassRefPtr<MemoryInfo> memory() const;
private:
......
......@@ -75,6 +75,7 @@
#include "MessageEvent.h"
#include "Navigator.h"
#include "Page.h"
#include "PageConsole.h"
#include "PageGroup.h"
#include "PageTransitionEvent.h"
#include "Performance.h"
......@@ -694,6 +695,13 @@ Console* DOMWindow::console() const
return m_console.get();
}
PageConsole* DOMWindow::pageConsole() const
{
if (!isCurrentlyDisplayedInFrame())
return 0;
return m_frame->page() ? m_frame->page()->console() : 0;
}
DOMApplicationCache* DOMWindow::applicationCache() const
{
if (!isCurrentlyDisplayedInFrame())
......@@ -884,7 +892,7 @@ void DOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTarg
if (!intendedTargetOrigin->isSameSchemeHostPort(document()->securityOrigin())) {
String message = "Unable to post message to " + intendedTargetOrigin->toString() +
". Recipient has origin " + document()->securityOrigin()->toString() + ".\n";
console()->addMessage(SecurityMessageSource, ErrorMessageLevel, message, stackTrace);
pageConsole()->addMessage(SecurityMessageSource, ErrorMessageLevel, message, stackTrace);
return;
}
}
......@@ -1798,7 +1806,7 @@ void DOMWindow::printErrorMessage(const String& message)
if (message.isEmpty())
return;
console()->addMessage(JSMessageSource, ErrorMessageLevel, message);
pageConsole()->addMessage(JSMessageSource, ErrorMessageLevel, message);
}
String DOMWindow::crossDomainAccessErrorMessage(DOMWindow* activeWindow)
......
......@@ -59,6 +59,7 @@ namespace WebCore {
class Navigator;
class Node;
class Page;
class PageConsole;
class Performance;
class PostMessageTimer;
class ScheduledAction;
......@@ -233,6 +234,7 @@ namespace WebCore {
PassRefPtr<WebKitPoint> webkitConvertPointFromNodeToPage(Node*, const WebKitPoint*) const;