Bug 31296 - Web Inspector: Should support console.groupCollapsed
authorjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 May 2010 13:44:21 +0000 (13:44 +0000)
committerjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 May 2010 13:44:21 +0000 (13:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=31296

Reviewed by Pavel Feldman

WebCore:

* inspector/InspectorController.cpp:
(WebCore::InspectorController::startGroup):
Set the message type based on whether or not it should be initially collapsed.
* inspector/InspectorController.h:

* inspector/front-end/ConsoleView.js:
Treat a StartGroupCollapsed message the same way as a StartGroup message, but display the tree for the group as collapsed.
(WebInspector.ConsoleView.prototype.addMessage):
(WebInspector.ConsoleMessage.prototype.toMessageElement):
(WebInspector.ConsoleMessage.prototype.toString):
(WebInspector.ConsoleGroup.prototype.addMessage):

* page/Console.cpp:
(WebCore::Console::groupCollapsed):
Create a group and indicate that it should be collapsed.
* page/Console.h:
Add the StartGroupCollapsed message type.

(WebCore::):
* page/Console.idl:
Create the JS bindings for groupCollapsed.

LayoutTests:

* fast/dom/Window/window-properties-expected.txt:
Update results to take into account added groupCollapsed function.

* inspector/console-tests-expected.txt:
* inspector/console-tests.html:
Add test for groupCollapsed and its results.

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

LayoutTests/ChangeLog
LayoutTests/fast/dom/Window/window-properties-expected.txt
LayoutTests/inspector/console-tests-expected.txt
LayoutTests/inspector/console-tests.html
WebCore/ChangeLog
WebCore/inspector/InspectorController.cpp
WebCore/inspector/InspectorController.h
WebCore/inspector/front-end/ConsoleView.js
WebCore/page/Console.cpp
WebCore/page/Console.h
WebCore/page/Console.idl

index 366650b..4b1f56a 100644 (file)
@@ -1,3 +1,17 @@
+2010-05-26  Jessie Berlin  <jberlin@webkit.org>
+
+        Reviewed by Pavel Feldman
+
+        Bug 31296 - Web Inspector: Should support console.groupCollapsed
+        https://bugs.webkit.org/show_bug.cgi?id=31296
+
+        * fast/dom/Window/window-properties-expected.txt:
+        Update results to take into account added groupCollapsed function.
+
+        * inspector/console-tests-expected.txt:
+        * inspector/console-tests.html:
+        Add test for groupCollapsed and its results.
+
 2010-05-26  Nikolas Zimmermann  <nzimmermann@rim.com>
 
         Not reviewed. Add results for svg/hixie/links/003-broken.xml for mac-leopard. All SVG tests pass with --tolerance 0 again for me on Leopard.
index 068a2cd..fcdd88f 100644 (file)
@@ -2055,6 +2055,7 @@ window.console.dir [function]
 window.console.dirxml [function]
 window.console.error [function]
 window.console.group [function]
+window.console.groupCollapsed [function]
 window.console.groupEnd [function]
 window.console.info [function]
 window.console.log [function]
index 7ce27a2..2942f5b 100644 (file)
@@ -22,4 +22,5 @@ console-tests.html:17count: 2 console-message console-js-source console-log-leve
 console-tests.html:18group console-message console-js-source console-log-level console-group-title
 console-message console-js-source console-log-level
 console-tests.html:201 2 3 console-message console-js-source console-log-level
+console-tests.html:21groupCollapsed console-message console-js-source console-log-level console-group-title
 
index 014f4ad..66529c8 100755 (executable)
@@ -18,6 +18,7 @@ function doit()
     console.group('group');
     console.groupEnd();
     console.log('1', '2', '3');
+    console.groupCollapsed('groupCollapsed');
 
     dumpConsoleMessagesWithClasses();
 }
index 915f540..22f8153 100644 (file)
@@ -1,3 +1,32 @@
+2010-05-26  Jessie Berlin  <jberlin@webkit.org>
+
+        Reviewed by Pavel Feldman
+
+        Bug 31296 - Web Inspector: Should support console.groupCollapsed
+        https://bugs.webkit.org/show_bug.cgi?id=31296
+
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::startGroup):
+        Set the message type based on whether or not it should be initially collapsed.
+        * inspector/InspectorController.h:
+
+        * inspector/front-end/ConsoleView.js:
+        Treat a StartGroupCollapsed message the same way as a StartGroup message, but display the tree for the group as collapsed.
+        (WebInspector.ConsoleView.prototype.addMessage):
+        (WebInspector.ConsoleMessage.prototype.toMessageElement):
+        (WebInspector.ConsoleMessage.prototype.toString):
+        (WebInspector.ConsoleGroup.prototype.addMessage):
+
+        * page/Console.cpp:
+        (WebCore::Console::groupCollapsed):
+        Create a group and indicate that it should be collapsed.
+        * page/Console.h:
+        Add the StartGroupCollapsed message type.
+
+        (WebCore::):
+        * page/Console.idl:
+        Create the JS bindings for groupCollapsed.
+
 2010-05-26  yael aharon  <yael.aharon@nokia.com>
 
         Reviewed by Kent Tamura.
index 15f44ae..98fa557 100644 (file)
@@ -336,11 +336,11 @@ void InspectorController::clearConsoleMessages()
         m_frontend->clearConsoleMessages();
 }
 
-void InspectorController::startGroup(MessageSource source, ScriptCallStack* callStack)
+void InspectorController::startGroup(MessageSource source, ScriptCallStack* callStack, bool collapsed)
 {
     ++m_groupLevel;
 
-    addConsoleMessage(callStack->state(), new ConsoleMessage(source, StartGroupMessageType, LogMessageLevel, callStack, m_groupLevel));
+    addConsoleMessage(callStack->state(), new ConsoleMessage(source, collapsed ? StartGroupCollapsedMessageType : StartGroupMessageType, LogMessageLevel, callStack, m_groupLevel));
 }
 
 void InspectorController::endGroup(MessageSource source, unsigned lineNumber, const String& sourceURL)
index d97cb20..de7f7a5 100644 (file)
@@ -213,7 +213,7 @@ public:
     void startTiming(const String& title);
     bool stopTiming(const String& title, double& elapsed);
 
-    void startGroup(MessageSource source, ScriptCallStack* callFrame);
+    void startGroup(MessageSource source, ScriptCallStack* callFrame, bool collapsed = false);
     void endGroup(MessageSource source, unsigned lineNumber, const String& sourceURL);
 
     void markTimeline(const String& message);
index b9f6d0a..8521cb3 100644 (file)
@@ -249,7 +249,7 @@ WebInspector.ConsoleView.prototype = {
 
             this.currentGroup = this.currentGroup.parentGroup;
         } else {
-            if (msg.type === WebInspector.ConsoleMessage.MessageType.StartGroup) {
+            if (msg.type === WebInspector.ConsoleMessage.MessageType.StartGroup || msg.type === WebInspector.ConsoleMessage.MessageType.StartGroupCollapsed) {
                 this.groupLevel++;
 
                 var group = new WebInspector.ConsoleGroup(this.currentGroup, this.groupLevel);
@@ -808,8 +808,8 @@ WebInspector.ConsoleMessage.prototype = {
                 element.addStyleClass("console-error-level");
                 break;
         }
-        
-        if (this.type === WebInspector.ConsoleMessage.MessageType.StartGroup)
+
+        if (this.type === WebInspector.ConsoleMessage.MessageType.StartGroup || this.type === WebInspector.ConsoleMessage.MessageType.StartGroupCollapsed)
             element.addStyleClass("console-group-title");
 
         if (this.elementsTreeOutline) {
@@ -894,6 +894,7 @@ WebInspector.ConsoleMessage.prototype = {
             case WebInspector.ConsoleMessage.MessageType.Trace:
                 typeString = "Trace";
                 break;
+            case WebInspector.ConsoleMessage.MessageType.StartGroupCollapsed:
             case WebInspector.ConsoleMessage.MessageType.StartGroup:
                 typeString = "Start Group";
                 break;
@@ -961,9 +962,10 @@ WebInspector.ConsoleMessage.MessageType = {
     Object: 1,
     Trace: 2,
     StartGroup: 3,
-    EndGroup: 4,
-    Assert: 5,
-    Result: 6
+    StartGroupCollapsed: 4,
+    EndGroup: 5,
+    Assert: 6,
+    Result: 7
 }
 
 WebInspector.ConsoleMessage.MessageLevel = {
@@ -1051,10 +1053,13 @@ WebInspector.ConsoleGroup.prototype = {
     addMessage: function(msg)
     {
         var element = msg.toMessageElement();
-        
-        if (msg.type === WebInspector.ConsoleMessage.MessageType.StartGroup) {
+
+        if (msg.type === WebInspector.ConsoleMessage.MessageType.StartGroup || msg.type === WebInspector.ConsoleMessage.MessageType.StartGroupCollapsed) {
             this.messagesElement.parentNode.insertBefore(element, this.messagesElement);
             element.addEventListener("click", this._titleClicked.bind(this), true);
+            var groupElement = element.enclosingNodeOrSelfWithClass("console-group");
+            if (groupElement && msg.type === WebInspector.ConsoleMessage.MessageType.StartGroupCollapsed)
+                groupElement.addStyleClass("collapsed");
         } else
             this.messagesElement.appendChild(element);
 
index 864b834..1d6c095 100644 (file)
@@ -427,6 +427,19 @@ void Console::group(ScriptCallStack* callStack)
 #endif
 }
 
+void Console::groupCollapsed(ScriptCallStack* callStack)
+{
+#if ENABLE(INSPECTOR)
+    Page* page = this->page();
+    if (!page)
+        return;
+
+    page->inspectorController()->startGroup(JSMessageSource, callStack, true);
+#else
+    UNUSED_PARAM(callStack);
+#endif
+}
+
 void Console::groupEnd()
 {
 #if ENABLE(INSPECTOR)
index 9a6d88c..18e311f 100644 (file)
@@ -62,6 +62,7 @@ enum MessageType {
     ObjectMessageType,
     TraceMessageType,
     StartGroupMessageType,
+    StartGroupCollapsedMessageType,
     EndGroupMessageType,
     AssertMessageType
 };
@@ -104,6 +105,7 @@ public:
     void time(const String&);
     void timeEnd(const String&, ScriptCallStack*);
     void group(ScriptCallStack*);
+    void groupCollapsed(ScriptCallStack*);
     void groupEnd();
 
     static bool shouldPrintExceptions();
index b3c0c24..9a7cdc0 100644 (file)
@@ -58,6 +58,7 @@ module window {
         void time(in [ConvertUndefinedOrNullToNullString] DOMString title);
         [CustomArgumentHandling] void timeEnd(in [ConvertUndefinedOrNullToNullString] DOMString title);
         [CustomArgumentHandling] void group();
+        [CustomArgumentHandling] void groupCollapsed();
         void groupEnd();
     };