Changeset 39537 in webkit


Ignore:
Timestamp:
Jan 1, 2009 5:08:20 PM (15 years ago)
Author:
oliver@apple.com
Message:

2008-12-29 Konstantin Käfer <kkaefer@gmail.com>

Reviewed by Tim Hatcher.

Fix for https://bugs.webkit.org/show_bug.cgi?id=17229
<rdar://problem/5732829> Inspector should show properties of all JS objects in Console

Prints objects not as plain text but makes them expandable so that
they can be inspected.

  • inspector/front-end/Console.js: (): added a parameter "inline" to the WebInspector.Console._format function which indicates

whether the object is printed in the context of another string (with console.log()) or
as sole element.

(.): objects and DOM nodes are now printed in an expandable form when they are printed alone

(i.e. not in the context of a console.log() string) so that they can be inspected.

  • inspector/front-end/PropertiesSection.js: (WebInspector.PropertiesSection.prototype.set title): Allow DOM Nodes as title instead of strings

in that case, the Node is inserted into the title instead of the string value of the passed
object. This is used for displaying linkified titles, for example when inspecting DOM nodes,
the syntax highlighted HTML representation is shown instead of the plain source code.

  • inspector/front-end/inspector.css: correct the offsetParent for the expandable object inspector.
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r39536 r39537  
     12008-12-29  Konstantin Käfer  <kkaefer@gmail.com>
     2
     3        Reviewed by Tim Hatcher.
     4
     5        Fix for https://bugs.webkit.org/show_bug.cgi?id=17229
     6        <rdar://problem/5732829> Inspector should show properties of all JS objects in Console
     7
     8        Prints objects not as plain text but makes them expandable so that
     9        they can be inspected.
     10
     11        * inspector/front-end/Console.js:
     12        (): added a parameter "inline" to the WebInspector.Console._format function which indicates
     13            whether the object is printed in the context of another string (with console.log()) or
     14            as sole element.
     15        (.): objects and DOM nodes are now printed in an expandable form when they are printed alone
     16            (i.e. not in the context of a console.log() string) so that they can be inspected.
     17        * inspector/front-end/PropertiesSection.js:
     18        (WebInspector.PropertiesSection.prototype.set title): Allow DOM Nodes as title instead of strings
     19            in that case, the Node is inserted into the title instead of the string value of the passed
     20            object. This is used for displaying linkified titles, for example when inspecting DOM nodes,
     21            the syntax highlighted HTML representation is shown instead of the plain source code.
     22        * inspector/front-end/inspector.css: correct the offsetParent for the expandable object inspector.
     23
    1242009-01-01  Darin Adler  <darin@apple.com>
    225
  • trunk/WebCore/inspector/front-end/Console.js

    r39367 r39537  
    478478    },
    479479
    480     _format: function(output)
     480    _format: function(output, inline)
    481481    {
    482482        var type = Object.type(output, InspectorController.inspectedWindow());
     
    510510        var span = document.createElement("span");
    511511        span.addStyleClass("console-formatted-" + type);
    512         this[formatter](output, span);
     512        this[formatter](output, span, inline);
    513513        return span;
    514514    },
    515515
    516     _formatvalue: function(val, elem)
     516    _formatvalue: function(val, elem, inline)
    517517    {
    518518        elem.appendChild(document.createTextNode(val));
    519519    },
    520520
    521     _formatstring: function(str, elem)
     521    _formatstring: function(str, elem, inline)
    522522    {
    523523        elem.appendChild(document.createTextNode("\"" + str + "\""));
    524524    },
    525525
    526     _formatregexp: function(re, elem)
     526    _formatregexp: function(re, elem, inline)
    527527    {
    528528        var formatted = String(re).replace(/([\\\/])/g, "\\$1").replace(/\\(\/[gim]*)$/, "$1").substring(1);
     
    530530    },
    531531
    532     _formatarray: function(arr, elem)
     532    _formatarray: function(arr, elem, inline)
    533533    {
    534534        elem.appendChild(document.createTextNode("["));
    535535        for (var i = 0; i < arr.length; ++i) {
    536             elem.appendChild(this._format(arr[i]));
     536            elem.appendChild(this._format(arr[i], true));
    537537            if (i < arr.length - 1)
    538538                elem.appendChild(document.createTextNode(", "));
     
    541541    },
    542542
    543     _formatnode: function(node, elem)
     543    _formatnode: function(node, elem, inline)
    544544    {
    545545        var anchor = document.createElement("a");
     
    549549        anchor.addEventListener("mouseover", this._mouseOverNode.bind(this), false);
    550550        anchor.addEventListener("mouseout", this._mouseOutOfNode.bind(this), false);
    551         elem.appendChild(anchor);
    552     },
    553 
    554     _formatobject: function(obj, elem)
    555     {
    556         elem.appendChild(document.createTextNode(Object.describe(obj)));
    557     },
    558 
    559     _formaterror: function(obj, elem)
     551
     552        if (inline)
     553            elem.appendChild(anchor);
     554        else
     555            elem.appendChild(new WebInspector.ObjectPropertiesSection(node, anchor, null, null, true).element);
     556    },
     557
     558    _formatobject: function(obj, elem, inline)
     559    {
     560        if (inline)
     561            elem.appendChild(document.createTextNode(Object.describe(obj)));
     562        else
     563            elem.appendChild(new WebInspector.ObjectPropertiesSection(obj, null, null, null, true).element);
     564    },
     565
     566    _formaterror: function(obj, elem, inline)
    560567    {
    561568        elem.appendChild(document.createTextNode(obj.name + ": " + obj.message + " "));
     
    637644        function formatForConsole(obj)
    638645        {
    639             return WebInspector.console._format(obj);
     646            return WebInspector.console._format(obj, true);
    640647        }
    641648
     
    669676            if (typeof parameters[i] === "string")
    670677                formattedResult.appendChild(WebInspector.linkifyStringAsFragment(parameters[i]));
     678            else if (parameters.length === 1)
     679                formattedResult.appendChild(WebInspector.console._format(parameters[0]));
    671680            else
    672681                formattedResult.appendChild(formatForConsole(parameters[i]));
  • trunk/WebCore/inspector/front-end/PropertiesSection.js

    r37523 r39537  
    7070            return;
    7171        this._title = x;
    72         this.titleElement.textContent = x;
     72
     73        if (x instanceof Node) {
     74            this.titleElement.removeChildren();
     75            this.titleElement.appendChild(x);
     76        } else
     77          this.titleElement.textContent = x;
    7378    },
    7479
  • trunk/WebCore/inspector/front-end/inspector.css

    r38236 r39537  
    619619}
    620620
     621.console-formatted-object .section, .console-formatted-node .section {
     622    position: static;
     623}
     624
    621625.auto-complete-text {
    622626    color: rgb(128, 128, 128);
Note: See TracChangeset for help on using the changeset viewer.