RESOLVED FIXED Bug 19158
Inspector should support console.group/console.groupEnd
https://bugs.webkit.org/show_bug.cgi?id=19158
Summary Inspector should support console.group/console.groupEnd
Adam Roben (:aroben)
Reported 2008-05-20 16:16:46 PDT
The Inspector should support console.group/console.groupEnd for Firebug parity.
Attachments
prototype (5.13 KB, patch)
2008-06-28 05:49 PDT, Keishi Hattori
aroben: review-
interim report (9.75 KB, patch)
2008-06-30 22:20 PDT, Keishi Hattori
no flags
proposed patch (11.06 KB, patch)
2008-07-01 05:05 PDT, Keishi Hattori
no flags
minor mistake fix (11.05 KB, patch)
2008-07-01 05:56 PDT, Keishi Hattori
aroben: review-
screenshot of console.group usage in Firebug (14.10 KB, image/png)
2008-07-03 06:09 PDT, Adam Roben (:aroben)
no flags
collapsible (16.20 KB, patch)
2008-07-04 00:30 PDT, Keishi Hattori
no flags
comparison screenshot (9.93 KB, image/png)
2008-07-04 01:04 PDT, Keishi Hattori
no flags
improved (16.42 KB, patch)
2008-07-05 04:43 PDT, Keishi Hattori
no flags
Bug fixed (16.33 KB, patch)
2008-07-07 04:14 PDT, Keishi Hattori
aroben: review-
New screenshot (146.28 KB, patch)
2008-07-07 04:15 PDT, Keishi Hattori
no flags
Improved (17.54 KB, patch)
2008-07-17 11:41 PDT, Keishi Hattori
no flags
Minor fix (17.61 KB, patch)
2008-07-17 11:54 PDT, Keishi Hattori
no flags
Tabs replaced (17.72 KB, patch)
2008-07-21 08:43 PDT, Keishi Hattori
timothy: review-
Changed css (17.72 KB, patch)
2008-07-23 04:06 PDT, Keishi Hattori
no flags
Screenshot (6.37 KB, image/png)
2008-07-23 04:12 PDT, Keishi Hattori
no flags
Fixed css (17.65 KB, patch)
2008-07-23 07:35 PDT, Keishi Hattori
timothy: review+
Mark Rowe (bdash)
Comment 1 2008-05-20 16:23:09 PDT
Keishi Hattori
Comment 2 2008-06-28 05:49:00 PDT
Created attachment 21986 [details] prototype Prototype implementation of console.group/groupEnd. This patch works by using ConsoleMessage "startGroup" and "endGroup" to find out where the groups begin and end. This is very ugly, so I think maybe a new MessageLevel(something like GroupStartMessageLevel) might be good?
Adam Roben (:aroben)
Comment 3 2008-06-28 09:14:08 PDT
Comment on attachment 21986 [details] prototype I think we need a slightly different approach here. Here's the Firebug documentation for console.group: > console.group(object[, object, ...]) > Writes a message to the console and opens a nested > block to indent all future messages sent to the console. > Call console.groupEnd() to close the block. So it looks like console.group essentially does a console.log, then increases the indent level for all future console messages. console.groupEnd just decreases the indent level for all future console messages. So I think somewhere we're going to have to keep track of the current indent level. console.group will increment it, and console.groupEnd will decrement it. Every time a message is added to the console, we'll indent it according to the current indent level. We should probably store the indent level in the ConsoleMessage struct in InspectorController.cpp. Then we can pass the indent level down to the Inspector's JS with the rest of the message. This will let us get rid of the messy "startGroup"/"endGroup" special messages. Make sense?
Keishi Hattori
Comment 4 2008-06-30 22:20:40 PDT
Created attachment 22016 [details] interim report I fixed it to match your description. The prompt and command messages doesn't get grouped yet, so I'll have to do that next.
Keishi Hattori
Comment 5 2008-07-01 05:05:55 PDT
Created attachment 22024 [details] proposed patch Prompt and CommandMesssages get properly indented.
Keishi Hattori
Comment 6 2008-07-01 05:33:03 PDT
Oops, doesn't work when you close and reopen the inspector.
Keishi Hattori
Comment 7 2008-07-01 05:56:57 PDT
Created attachment 22026 [details] minor mistake fix fixed.
Adam Roben (:aroben)
Comment 8 2008-07-01 07:53:50 PDT
Comment on attachment 22026 [details] minor mistake fix This is looking really good! Pretty minor comments below. I guess I'll r- until we are actually showing the indentation in the messages. + page->inspectorController()->increaseGroupLevel(); + + return log(exec, arguments); Does Firebug increase the indent level before or after printing the message passed to console.group? We should match either way. You don't need the "return" keyword here since this function doesn't have a return value. @@ -179,6 +181,7 @@ struct ConsoleMessage { Vector<ProtectedPtr<JSValue> > wrappedArguments; unsigned line; String url; + unsigned group; }; Why don't we call this new member "groupLevel" to match the terminology in the rest of the patch? + void increaseGroupLevel(); + void decreaseGroupLevel(); + void setScriptGroupLevel(); I think setScriptGroupLevel can be a private function. + setGroupLevel: function(group) + { + this.groupLevel = group; + this.promptElement.style.marginLeft = (this.groupLevel * 10) + "px"; + }, I'm a little confused by this function. Is the point of it to indent the prompt itself? What's the purpose of that? + this.group = group; Let's call this "this.groupLevel" as well. What is Firebug's behavior when you evaluate something in the command line after console.group has been called? Is the expression you evaluated indented just like a call to console.log would be? If so, we need to modify _enterKeyPressed to pass the current group level to the ConsoleCommand constructor.
Adam Roben (:aroben)
Comment 9 2008-07-01 07:54:19 PDT
Tim might have some good ideas for how to indent the messages properly.
Timothy Hatcher
Comment 10 2008-07-01 09:54:11 PDT
Does Firebug make the groups collapsable? Either way we might want to make our groups collapsable I think. I would not indent the prompt, that seems really odd to me. I would guess the results of the prompt would be indented though.
Keishi Hattori
Comment 11 2008-07-03 05:54:38 PDT
Some behavior of the firebug implementation: - Arguments for console.group gets bold is text and gets treated like the title of the group. - As Tim mentioned they are collapsible Screenshot: http://gyazo.com/26d0c7eda57989ede5ba116ae3a0de9b.png
Adam Roben (:aroben)
Comment 12 2008-07-03 06:09:39 PDT
Created attachment 22063 [details] screenshot of console.group usage in Firebug
Keishi Hattori
Comment 13 2008-07-04 00:30:53 PDT
Created attachment 22082 [details] collapsible Features: - I added GroupTitle Message Level - Groups are collapsible by clicking on the group title message Todo: - group title disappear when collapsed - design
Keishi Hattori
Comment 14 2008-07-04 01:04:13 PDT
Created attachment 22085 [details] comparison screenshot very minor details console.group gets included in the group and console.groupEnd doesn't. This is the opposite of firebug. Also firebug doesn't indent groupEnd but is in the group(it collapses). They don't bug me but should we do the same?
Keishi Hattori
Comment 15 2008-07-05 04:43:00 PDT
Created attachment 22097 [details] improved I added triangles to show that they are collapsible. Title now shows fine. Bug: Top level group gets nested when you go to another page without ending a group.
Timothy Hatcher
Comment 16 2008-07-05 08:08:58 PDT
Can you attach an updated screenshot?
Keishi Hattori
Comment 17 2008-07-07 04:14:23 PDT
Created attachment 22125 [details] Bug fixed Sorry the previous patch might have been corrupted. I was able to fix the bug. I left out m_groupLevel=0; in InspectorController::didCommitLoad.
Keishi Hattori
Comment 18 2008-07-07 04:15:38 PDT
Created attachment 22126 [details] New screenshot here is the screen shot
Adam Roben (:aroben)
Comment 19 2008-07-07 12:44:48 PDT
(In reply to comment #14) > console.group gets included in the group and console.groupEnd doesn't. This is > the opposite of firebug. This will probably be fixed by bug 19931.
Adam Roben (:aroben)
Comment 20 2008-07-10 08:21:45 PDT
Comment on attachment 22125 [details] Bug fixed + const KURL& url = m_frame->loader()->url(); + + if (arguments.isEmpty()) + page->inspectorController()->addMessageToConsole(JSMessageSource, GroupTitleMessageLevel, String(), 0, url.string()); + else + page->inspectorController()->addMessageToConsole(JSMessageSource, GroupTitleMessageLevel, exec, arguments, 0, url.string()); I don't think we want to pass in the Frame's URL here. Just passing String() would be better. + callFunction(m_scriptContext, m_scriptObject, "startGroupInConsole", 0, NULL, exception); We use 0 instead of NULL in C++ code. (Ditto for endGroup.) + if (typeof msg.groupLevel === "number") { When will this be false? + while (msg.groupLevel > this.groupLevel) + this.startGroup(); + while (msg.groupLevel < this.groupLevel) + this.endGroup(); It seems like if the difference between msg.groupLevel and this.groupLevel were more than 1, we'd end up with groups without titles. Do we really want to allow that? + startGroup: function() { The opening brace should be on the next line, aligned with the "s" in "startGroup". Ditto for the other functions you added. + this.currentGroup.appendChild(groupElement);groupElement.className += " " + this.groupLevel; You're missing a newline after the semicolon here. You should use addStyleClass instead of manually appending to .className. Why do we need the groupLevel as part of the class name? _messagesClicked: function(event) { + var groupTitleElement = event.target.enclosingNodeOrSelfWithClass("console-group-title-level"); + if (groupTitleElement) { + var groupElement = groupTitleElement.enclosingNodeOrSelfWithClass("console-group"); + if (groupElement) There should be braces around the body of this if since it's more than one line. + if (groupElement.hasStyleClass("collapsed")) + groupElement.removeStyleClass("collapsed"); + else + groupElement.addStyleClass("collapsed"); + groupTitleElement.scrollIntoViewIfNeeded(true); + } Should we return at the end of the if block? @@ -605,6 +656,9 @@ WebInspector.ConsoleMessage.prototype = case WebInspector.ConsoleMessage.MessageLevel.Error: levelString = "Error"; break; + case WebInspector.ConsoleMessage.MessageLevel.GroupTitle: + levelString = "GroupTitle"; + break; } Indentation got a little funny here. There are tabs in inspector.css. Our pre-commit hook won't let us land the patch that way. Please replace the tabs with 4 spaces. I think this is really close!
Keishi Hattori
Comment 21 2008-07-17 11:41:25 PDT
Created attachment 22344 [details] Improved Sorry the quality of the previous patch was awful. I thought group deserves a javascript class so I added WebInspector.ConsoleGroup.
Keishi Hattori
Comment 22 2008-07-17 11:54:11 PDT
Created attachment 22347 [details] Minor fix I forgot to put in event.preventDefault
Oliver Hunt
Comment 23 2008-07-20 14:23:42 PDT
Comment on attachment 22347 [details] Minor fix You've introduced a number of tab characters into the changelog, WebCore/page/Console.idl alas i'm not up to the task of doing any real inspector patch reviewing
Keishi Hattori
Comment 24 2008-07-21 08:43:01 PDT
Created attachment 22405 [details] Tabs replaced I'll run a script to check for tabs from now on.
Timothy Hatcher
Comment 25 2008-07-21 10:42:27 PDT
Comment on attachment 22405 [details] Tabs replaced Please remove the red color. +.console-group .console-group { + border-left: 10px solid rgb(255, 0, 0); +} This would be better as margin-left: 10px; Otherwise this is ready to land!
Keishi Hattori
Comment 26 2008-07-23 04:06:56 PDT
Created attachment 22446 [details] Changed css I changed .console-group .console-group { border-left: 10px solid rgb(255, 0, 0); } to .console-group .console-group > .console-group-messages { margin-left: 10px; } This way group title indentation matches Firebug.
Keishi Hattori
Comment 27 2008-07-23 04:12:49 PDT
Created attachment 22447 [details] Screenshot Maybe the groups aren't apparent enough? More margin or some kind of background?
Timothy Hatcher
Comment 28 2008-07-23 06:57:15 PDT
(In reply to comment #27) > Created an attachment (id=22447) [edit] > Screenshot > > Maybe the groups aren't apparent enough? More margin or some kind of > background? > I think the disclosure triangle is too far from the group title. Maybe move it over to the right more. ANd the indent might need to be more, I don't think a background color is suitable. Try 16px and reducing the space between the disclosure triangle and group title.
Keishi Hattori
Comment 29 2008-07-23 07:35:26 PDT
Created attachment 22452 [details] Fixed css 16px margin looks perfect!!
Timothy Hatcher
Comment 30 2008-07-29 10:02:47 PDT
The new version looks better! I still think the disclosure arrow should be closer to the group title.
Timothy Hatcher
Comment 31 2008-07-29 10:05:32 PDT
Try: .console-group-title-level { background-image: url(Images/disclosureTriangleSmallDown.png); background-repeat: no-repeat; background-position: 6px 0; font-weight: bold; } .console-group.collapsed .console-group-title-level { background-image: url(Images/disclosureTriangleSmallRight.png); }
Timothy Hatcher
Comment 32 2008-07-29 10:06:19 PDT
Comment on attachment 22452 [details] Fixed css Try moving the disclosure arrow over to the right a bit. See my comment about shifting it 6px. Might look good with 8px too.
Timothy Hatcher
Comment 33 2008-07-29 10:40:39 PDT
Comment on attachment 22452 [details] Fixed css I am going to tweak the look locally and land.
Timothy Hatcher
Comment 34 2008-07-29 11:08:02 PDT
Landed in r35421.
Timothy Hatcher
Comment 35 2008-07-29 11:21:02 PDT
Found a major bug after landing. Filed as bug 20210.
Note You need to log in before you can comment on or make changes to this bug.