2010-10-15 Ilya Tikhonovsky <loislo@chromium.org>
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Oct 2010 15:20:36 +0000 (15:20 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Oct 2010 15:20:36 +0000 (15:20 +0000)
        Reviewed by Yury Semikhatsky.

        Web Inspector: extract consoleMessages related stuff from populateScriptObjects into separate function.

        This is a part of Inspector protocol sanitization activity.
        We want to populate console messages only if it is required by frontend.

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

        * inspector/Inspector.idl:
        * inspector/InspectorController.cpp:
        (WebCore::InspectorController::setConsoleMessagesEnabled):
        (WebCore::InspectorController::addConsoleMessage):
        (WebCore::InspectorController::disconnectFrontend):
        (WebCore::InspectorController::populateScriptObjects):
        * inspector/InspectorController.h:
        * inspector/InspectorState.cpp:
        (WebCore::InspectorState::InspectorState):
        * inspector/InspectorState.h:
        * inspector/front-end/inspector.js:
        (WebInspector.doLoadedDone):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@69853 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/inspector/Inspector.idl
WebCore/inspector/InspectorController.cpp
WebCore/inspector/InspectorController.h
WebCore/inspector/InspectorState.cpp
WebCore/inspector/InspectorState.h
WebCore/inspector/front-end/inspector.js

index bf23153fe630bb5949e22af9fee9371f01e9cbf1..d2d521f7496253da9ae47f7ac12641ec834236be 100644 (file)
@@ -1,3 +1,27 @@
+2010-10-15  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: extract consoleMessages related stuff from populateScriptObjects into separate function.
+
+        This is a part of Inspector protocol sanitization activity.
+        We want to populate console messages only if it is required by frontend.
+
+        https://bugs.webkit.org/show_bug.cgi?id=46802
+
+        * inspector/Inspector.idl:
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::setConsoleMessagesEnabled):
+        (WebCore::InspectorController::addConsoleMessage):
+        (WebCore::InspectorController::disconnectFrontend):
+        (WebCore::InspectorController::populateScriptObjects):
+        * inspector/InspectorController.h:
+        * inspector/InspectorState.cpp:
+        (WebCore::InspectorState::InspectorState):
+        * inspector/InspectorState.h:
+        * inspector/front-end/inspector.js:
+        (WebInspector.doLoadedDone):
+
 2010-10-15  Ryuan Choi  <ryuan.choi@samsung.com>
 
         Reviewed by Nikolas Zimmermann.
index 7cf5a15a0e1468292123ced6dfbe22bd03c50d20..c4773cffe4d2fac2f1ce5358b282eff8e6f3ddc4 100644 (file)
@@ -32,7 +32,6 @@
 
 module core {
     interface [Conditional=INSPECTOR] Inspector {
-        [notify] void addConsoleMessage(out Object messageObj);
         [notify] void addRecordToTimeline(out Object record);
         [notify] void addNodesToSearchResult(out Array nodeIds);
         [notify] void attributesUpdated(out long id, out Array attributes);
@@ -41,7 +40,6 @@ module core {
         [notify] void childNodeCountUpdated(out long id, out int newValue);
         [notify] void childNodeInserted(out long parentId, out long prevId, out Object node);
         [notify] void childNodeRemoved(out long parentId, out long id);
-        [notify] void consoleMessagesCleared();
         [notify] void didCommitLoad();
         [notify] void evaluateForTestInFrontend(out long testCallId, out String script);
         [notify] void disconnectFromBackend();
@@ -57,8 +55,6 @@ module core {
         [notify] void showPanel(out String panel);
         [notify] void timelineProfilerWasStarted();
         [notify] void timelineProfilerWasStopped();
-        [notify] void updateConsoleMessageExpiredCount(out unsigned long count);
-        [notify] void updateConsoleMessageRepeatCount(out unsigned long count);
         [notify] void updateFocusedNode(out long nodeId);
         [notify] void updateResource(out Value resource);
 
@@ -174,7 +170,14 @@ module core {
         [handler=DOM] void searchCanceled();
         [handler=DOM] void pushNodeByPathToFrontend(in String path, out long nodeId);
 
+        [handler=Controller] void setConsoleMessagesEnabled(in boolean enabled, out boolean newState);
+        [notify] void addConsoleMessage(out Object messageObj);
+        [notify] void updateConsoleMessageExpiredCount(out unsigned long count);
+        [notify] void updateConsoleMessageRepeatCount(out unsigned long count);
+
         [handler=Controller] void clearConsoleMessages();
+        [notify] void consoleMessagesCleared();
+
         [handler=Controller] void highlightDOMNode(in long nodeId);
         [handler=Controller] void hideDOMNodeHighlight();
         [handler=Controller] void openInInspectedWindow(in String url);
index b4358d4401b51a64f8f0c5934ed3a5f8d2dcab13..32bbea6bba0dea89d45f220505d4fe0d1767674d 100644 (file)
@@ -318,6 +318,25 @@ void InspectorController::hideHighlight()
     m_client->hideHighlight();
 }
 
+void InspectorController::setConsoleMessagesEnabled(bool enabled, bool* newState)
+{
+    *newState = enabled;
+    setConsoleMessagesEnabled(enabled);
+}
+
+void InspectorController::setConsoleMessagesEnabled(bool enabled)
+{
+    m_state->setBoolean(InspectorState::consoleMessagesEnabled, enabled);
+    if (!enabled)
+        return;
+
+    if (m_expiredConsoleMessageCount)
+        m_frontend->updateConsoleMessageExpiredCount(m_expiredConsoleMessageCount);
+    unsigned messageCount = m_consoleMessages.size();
+    for (unsigned i = 0; i < messageCount; ++i)
+        m_consoleMessages[i]->addToFrontend(m_frontend.get(), m_injectedScriptHost.get());
+}
+
 void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, ScriptCallStack* callStack, const String& message)
 {
     if (!enabled())
@@ -342,12 +361,12 @@ void InspectorController::addConsoleMessage(PassOwnPtr<ConsoleMessage> consoleMe
 
     if (m_previousMessage && m_previousMessage->isEqual(consoleMessage.get())) {
         m_previousMessage->incrementCount();
-        if (m_frontend)
+        if (m_state->getBoolean(InspectorState::consoleMessagesEnabled) && m_frontend)
             m_previousMessage->updateRepeatCountInConsole(m_frontend.get());
     } else {
         m_previousMessage = consoleMessage.get();
         m_consoleMessages.append(consoleMessage);
-        if (m_frontend)
+        if (m_state->getBoolean(InspectorState::consoleMessagesEnabled) && m_frontend)
             m_previousMessage->addToFrontend(m_frontend.get(), m_injectedScriptHost.get());
     }
 
@@ -552,6 +571,9 @@ void InspectorController::disconnectFrontend()
 {
     if (!m_frontend)
         return;
+
+    setConsoleMessagesEnabled(false);
+
     m_frontend.clear();
 
     InspectorInstrumentation::frontendDeleted();
@@ -631,12 +653,6 @@ void InspectorController::populateScriptObjects()
     if (m_nodeToFocus)
         focusNode();
 
-    if (m_expiredConsoleMessageCount)
-        m_frontend->updateConsoleMessageExpiredCount(m_expiredConsoleMessageCount);
-    unsigned messageCount = m_consoleMessages.size();
-    for (unsigned i = 0; i < messageCount; ++i)
-        m_consoleMessages[i]->addToFrontend(m_frontend.get(), m_injectedScriptHost.get());
-
 #if ENABLE(DATABASE)
     DatabaseResourcesMap::iterator databasesEnd = m_databaseResources.end();
     for (DatabaseResourcesMap::iterator it = m_databaseResources.begin(); it != databasesEnd; ++it)
index 86d823e319b3e45ec00b16e6c7dd5796550f0077..80ebca1bd8e92955d65600f82e7c721261491e87 100644 (file)
@@ -139,13 +139,11 @@ public:
     void showPanel(const String&);
     void close();
 
-    // We are in transition from JS transport via webInspector to native
-    // transport via InspectorClient. After migration, webInspector parameter should
-    // be removed.
     void connectFrontend();
     void reuseFrontend();
     void disconnectFrontend();
 
+    void setConsoleMessagesEnabled(bool enabled, bool* newState);
     void addMessageToConsole(MessageSource, MessageType, MessageLevel, ScriptCallStack*, const String& message);
     void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID);
     void clearConsoleMessages();
@@ -278,6 +276,7 @@ public:
 
 private:
     void getInspectorState(RefPtr<InspectorObject>* state);
+    void setConsoleMessagesEnabled(bool enabled);
 
     friend class InspectorBackend;
     friend class InspectorBackendDispatcher;
index b731b76c97d1cb6aa710e5f14466a324b9c44242..c33743da87a9a1eadf9ff44421b78cecb85f1065 100644 (file)
@@ -51,6 +51,7 @@ InspectorState::InspectorState(InspectorClient* client)
     registerBoolean(inspectorStartsAttached, true, (const char*)0, "InspectorStartsAttached");
     registerLong(inspectorAttachedHeight, InspectorController::defaultAttachedHeight, (const char*)0, "inspectorAttachedHeight");
     registerLong(pauseOnExceptionsState, 0, "pauseOnExceptionsState", (const char*)0);
+    registerBoolean(consoleMessagesEnabled, false, "consoleMessagesEnabled", (const char*)0);
 }
 
 void InspectorState::restoreFromInspectorCookie(const String& json)
index e6e6da89c36adb7b0dc507f6d371b960cf4035b0..fe14d6898a853c54e0a82eec06074868a43367cd 100644 (file)
@@ -54,6 +54,7 @@ public:
         inspectorStartsAttached,
         inspectorAttachedHeight,
         pauseOnExceptionsState,
+        consoleMessagesEnabled,
         lastPropertyId
     };
 
@@ -62,6 +63,7 @@ public:
     PassRefPtr<InspectorObject> generateStateObjectForFrontend();
     void restoreFromInspectorCookie(const String& jsonString);
     void loadFromSettings();
+    String getFrontendAlias(InspectorPropertyId propertyId);
 
     bool getBoolean(InspectorPropertyId propertyId);
     String getString(InspectorPropertyId propertyId);
index 69d6fc77de7be021ae6e75e2a61951d340b38893..87ae8a3b73ae06d4079826af4a54b90e55a86f6f 100644 (file)
@@ -603,6 +603,7 @@ WebInspector.doLoadedDone = function()
     InspectorBackend.getInspectorState(populateInspectorState);
 
     InspectorBackend.populateScriptObjects();
+    InspectorBackend.setConsoleMessagesEnabled(true);
 
     // As a DOMAgent method, this needs to happen after the frontend has loaded and the agent is available.
     InspectorBackend.getSupportedCSSProperties(WebInspector.CSSCompletions._load);