Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adds support for console.dir to the Inspector
        https://bugs.webkit.org/show_bug.cgi?id=19155

        Reviewed by Tim Hatcher.

        * bindings/js/JSConsoleCustom.cpp:
        (WebCore::JSConsole::dir):
        * page/Console.cpp:
        (WebCore::Console::dir):
        * page/Console.h: Added ObjectMessageLevel.
        * page/Console.idl: Added console.dir.
        * page/inspector/Console.js:
        (WebInspector.ConsoleMessage.prototypet.toMessageElement): Creates an
        ObjectPropertiesSection if the MessageLevel is Object.
        * page/inspector/ObjectPropertiesSection.js: "in" operator can't be
        used on primitive data types.
        * page/inspector/inspector.css:

Canonical link: https://commits.webkit.org/28195@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@35787 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
xeenon committed Aug 15, 2008
1 parent 575d194 commit 69b0e74
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 2 deletions.
21 changes: 21 additions & 0 deletions WebCore/ChangeLog
@@ -1,3 +1,24 @@
2008-08-15 Keishi Hattori <casey.hattori@gmail.com>

Adds support for console.dir to the Inspector

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

Reviewed by Tim Hatcher.

* bindings/js/JSConsoleCustom.cpp:
(WebCore::JSConsole::dir):
* page/Console.cpp:
(WebCore::Console::dir):
* page/Console.h: Added ObjectMessageLevel.
* page/Console.idl: Added console.dir.
* page/inspector/Console.js:
(WebInspector.ConsoleMessage.prototypet.toMessageElement): Creates an
ObjectPropertiesSection if the MessageLevel is Object.
* page/inspector/ObjectPropertiesSection.js: "in" operator can't be
used on primitive data types.
* page/inspector/inspector.css:

2008-08-15 Keishi Hattori <casey.hattori@gmail.com>

Adds support for clear() in the Inspector console.
Expand Down
6 changes: 6 additions & 0 deletions WebCore/bindings/js/JSConsoleCustom.cpp
Expand Up @@ -62,6 +62,12 @@ JSValue* JSConsole::warn(ExecState* exec, const ArgList& arguments)
return jsUndefined();
}

JSValue* JSConsole::dir(ExecState* exec, const ArgList& arguments)
{
impl()->dir(exec, arguments);
return jsUndefined();
}

JSValue* JSConsole::assertCondition(ExecState* exec, const ArgList& arguments)
{
ArgList messageParameters;
Expand Down
15 changes: 15 additions & 0 deletions WebCore/page/Console.cpp
Expand Up @@ -230,6 +230,21 @@ void Console::log(ExecState* exec, const ArgList& args)
printToStandardOut(LogMessageLevel, exec, args, url);
}

void Console::dir(ExecState* exec, const ArgList& args)
{
if (args.isEmpty())
return;

if (!m_frame)
return;

Page* page = m_frame->page();
if (!page)
return;

page->inspectorController()->addMessageToConsole(JSMessageSource, ObjectMessageLevel, exec, args, 0, String());
}

void Console::assertCondition(bool condition, ExecState* exec, const ArgList& args)
{
if (condition)
Expand Down
2 changes: 2 additions & 0 deletions WebCore/page/Console.h
Expand Up @@ -59,6 +59,7 @@ namespace WebCore {
LogMessageLevel,
WarningMessageLevel,
ErrorMessageLevel,
ObjectMessageLevel,
GroupTitleMessageLevel
};

Expand All @@ -75,6 +76,7 @@ namespace WebCore {
void info(KJS::ExecState*, const KJS::ArgList& arguments);
void log(KJS::ExecState*, const KJS::ArgList& arguments);
void warn(KJS::ExecState*, const KJS::ArgList& arguments);
void dir(KJS::ExecState*, const KJS::ArgList& arguments);
void assertCondition(bool condition, KJS::ExecState*, const KJS::ArgList& arguments);
void profile(KJS::ExecState*, const KJS::ArgList& arguments);
void profileEnd(KJS::ExecState*, const KJS::ArgList& arguments);
Expand Down
1 change: 1 addition & 0 deletions WebCore/page/Console.idl
Expand Up @@ -34,6 +34,7 @@ module window {
[Custom] void info();
[Custom] void log();
[Custom] void warn();
[Custom] void dir();
[Custom, ImplementationFunction=assertCondition] void assert(in boolean condition);

[Custom] void profile(in DOMString title);
Expand Down
16 changes: 15 additions & 1 deletion WebCore/page/inspector/Console.js
Expand Up @@ -347,6 +347,7 @@ WebInspector.Console.prototype = {
} catch (e) {} \
return nodes; \
}, \
dir: function() { return console.dir.apply(console, arguments) }, \
keys: function(o) { var a = []; for (k in o) a.push(k); return a; }, \
values: function(o) { var a = []; for (k in o) a.push(o[k]); return a; }, \
profile: function() { return console.profile.apply(console, arguments) }, \
Expand Down Expand Up @@ -515,6 +516,12 @@ WebInspector.ConsoleMessage = function(source, level, line, url, groupLevel)
this.url = url;
this.groupLevel = groupLevel;

if (this.level === WebInspector.ConsoleMessage.MessageLevel.Object) {
var propertiesSection = new WebInspector.ObjectPropertiesSection(arguments[5], null, null, null, true);
propertiesSection.element.addStyleClass("console-message");
this.propertiesSection = propertiesSection;
}

if (url && line > 0 && this.isErrorOrWarning()) {
// This _format call passes in true for the plainText argument. The result's textContent is
// used for inline message bubbles in SourceFrames, or other plain-text representations.
Expand Down Expand Up @@ -585,6 +592,9 @@ WebInspector.ConsoleMessage.prototype = {

toMessageElement: function()
{
if (this.level === WebInspector.ConsoleMessage.MessageLevel.Object)
return this.propertiesSection.element;

var element = document.createElement("div");
element.message = this;
element.className = "console-message";
Expand Down Expand Up @@ -686,6 +696,9 @@ WebInspector.ConsoleMessage.prototype = {
case WebInspector.ConsoleMessage.MessageLevel.Error:
levelString = "Error";
break;
case WebInspector.ConsoleMessage.MessageLevel.Object:
levelString = "Object";
break;
case WebInspector.ConsoleMessage.MessageLevel.GroupTitle:
levelString = "GroupTitle";
break;
Expand All @@ -709,7 +722,8 @@ WebInspector.ConsoleMessage.MessageLevel = {
Log: 1,
Warning: 2,
Error: 3,
GroupTitle: 4
Object: 4,
GroupTitle: 5
}

WebInspector.ConsoleCommand = function(command, result, formattedResultElement, level)
Expand Down
2 changes: 1 addition & 1 deletion WebCore/page/inspector/ObjectPropertiesSection.js
Expand Up @@ -108,7 +108,7 @@ WebInspector.ObjectPropertyTreeElement = function(parentObject, propertyName)
WebInspector.ObjectPropertyTreeElement.prototype = {
safePropertyValue: function(object, propertyName)
{
if ("__lookupGetter__" in object && object.__lookupGetter__(propertyName))
if (object["__lookupGetter__"] && object.__lookupGetter__(propertyName))
return;
return object[propertyName];
},
Expand Down
28 changes: 28 additions & 0 deletions WebCore/page/inspector/inspector.css
Expand Up @@ -579,6 +579,34 @@ body.console-visible #console {
opacity: 1;
}

.console-group-messages .section {
margin: 0;
}

.console-group-messages .section .header {
padding: 0 8px 0 0;
background-image: none;
border: none;
min-height: 16px;
}

.console-group-messages .section .header::before {
position: absolute;
top: 1px;
left: 12px;
width: 8px;
height: 8px;
content: url(Images/treeRightTriangleBlack.png);
}

.console-group-messages .section.expanded .header::before {
content: url(Images/treeDownTriangleBlack.png);
}

.console-group-messages .section .header .title {
color: black;
}

.auto-complete-text {
color: rgb(128, 128, 128);
-webkit-user-select: none;
Expand Down

0 comments on commit 69b0e74

Please sign in to comment.