Changeset 37012 in webkit


Ignore:
Timestamp:
Sep 27, 2008 3:18:35 PM (16 years ago)
Author:
timothy@apple.com
Message:

Added support for console.trace.

JavaScriptCore:

2008-09-27 Keishi Hattori <casey.hattori@gmail.com>

Added Machine::retrieveCaller to the export list.

Reviewed by Kevin McCullough and Tim Hatcher.

WebCore:

2008-09-27 Keishi Hattori <casey.hattori@gmail.com>

Added support for console.trace.

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

Reviewed by Kevin McCullough and Tim Hatcher.

  • bindings/js/JSConsoleCustom.cpp: (WebCore::JSConsole::trace):
  • page/Console.cpp: (WebCore::Console::trace): Calls Machine::retrieveCaller to get a stack trace.
  • page/Console.h: (WebCore::): Added TraceMessageLevel.
  • page/Console.idl: Added console.trace.
  • page/inspector/Console.js: (ConsoleMessage): Added case for TraceMessageLevel.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r36999 r37012  
     12008-09-27  Keishi Hattori  <casey.hattori@gmail.com>
     2
     3        Added Machine::retrieveCaller to the export list.
     4
     5        Reviewed by Kevin McCullough and Tim Hatcher.
     6
     7        * JavaScriptCore.exp: Added Machine::retrieveCaller.
     8
    192008-09-27  Anders Carlsson  <andersca@apple.com>
    210
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r36877 r37012  
    316316__ZNK3JSC7JSValue7toFloatEPNS_9ExecStateE
    317317__ZNK3JSC7JSValue9toIntegerEPNS_9ExecStateE
     318__ZNK3JSC7Machine14retrieveCallerEPNS_9ExecStateEPNS_16InternalFunctionE
    318319__ZNK3JSC7Machine18retrieveLastCallerEPNS_9ExecStateERiS3_RNS_7UStringERPNS_7JSValueE
    319320__ZNK3JSC7UString10UTF8StringEb
  • trunk/WebCore/ChangeLog

    r37008 r37012  
     12008-09-27  Keishi Hattori  <casey.hattori@gmail.com>
     2
     3        Added support for console.trace.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=19157
     6
     7        Reviewed by Kevin McCullough and Tim Hatcher.
     8
     9        * bindings/js/JSConsoleCustom.cpp:
     10        (WebCore::JSConsole::trace):
     11        * page/Console.cpp:
     12        (WebCore::Console::trace): Calls Machine::retrieveCaller to
     13        get a stack trace.
     14        * page/Console.h:
     15        (WebCore::): Added TraceMessageLevel.
     16        * page/Console.idl: Added console.trace.
     17        * page/inspector/Console.js:
     18        (ConsoleMessage): Added case for TraceMessageLevel.
     19
    1202008-09-27  Anders Carlsson  <andersca@apple.com>
    221
  • trunk/WebCore/bindings/js/JSConsoleCustom.cpp

    r36263 r37012  
    7575}
    7676
     77JSValue* JSConsole::trace(ExecState* exec, const ArgList&)
     78{
     79    impl()->trace(exec);
     80    return jsUndefined();
     81}
     82
    7783JSValue* JSConsole::assertCondition(ExecState* exec, const ArgList& arguments)
    7884{
  • trunk/WebCore/page/Console.cpp

    r36263 r37012  
    277277}
    278278
     279void Console::trace(ExecState* exec)
     280{
     281    Page* page = this->page();
     282    if (!page)
     283        return;
     284
     285    int signedLineNumber;
     286    int sourceIdentifer;
     287    UString urlString;
     288    JSValue* func;
     289
     290    exec->machine()->retrieveLastCaller(exec, signedLineNumber, sourceIdentifer, urlString, func);
     291
     292    ArgList args;
     293    while (!func->isNull()) {
     294        args.append(func);
     295        func = exec->machine()->retrieveCaller(exec, static_cast<InternalFunction*>(func));
     296    }
     297   
     298    page->inspectorController()->addMessageToConsole(JSMessageSource, TraceMessageLevel, exec, args, 0, String());
     299}
     300
    279301void Console::assertCondition(bool condition, ExecState* exec, const ArgList& args)
    280302{
  • trunk/WebCore/page/Console.h

    r36263 r37012  
    6262        ObjectMessageLevel,
    6363        NodeMessageLevel,
     64        TraceMessageLevel,
    6465        StartGroupMessageLevel,
    6566        EndGroupMessageLevel
     
    8283        void dir(JSC::ExecState*, const JSC::ArgList&);
    8384        void dirxml(JSC::ExecState*, const JSC::ArgList& arguments);
     85        void trace(JSC::ExecState*);
    8486        void assertCondition(bool condition, JSC::ExecState*, const JSC::ArgList&);
    8587        void count(JSC::ExecState*, const JSC::ArgList&);
  • trunk/WebCore/page/Console.idl

    r36255 r37012  
    3737        [Custom] void dir();
    3838        [Custom] void dirxml();
     39        [Custom] void trace();
    3940        [Custom, ImplementationFunction=assertCondition] void assert(in boolean condition);
    4041        [Custom] void count();
  • trunk/WebCore/page/inspector/Console.js

    r36958 r37012  
    576576    this.repeatCount = repeatCount;
    577577
    578     if (this.level === WebInspector.ConsoleMessage.MessageLevel.Object) {
    579         var propertiesSection = new WebInspector.ObjectPropertiesSection(arguments[6], null, null, null, true);
    580         propertiesSection.element.addStyleClass("console-message");
    581         this.propertiesSection = propertiesSection;
    582     } else if (this.level === WebInspector.ConsoleMessage.MessageLevel.Node) {
    583         var node = arguments[6];
    584         if (!(node instanceof InspectorController.inspectedWindow().Node))
    585             return;
    586         this.elementsTreeOutline = new WebInspector.ElementsTreeOutline();
    587         this.elementsTreeOutline.rootDOMNode = node;
     578    switch (this.level) {
     579        case WebInspector.ConsoleMessage.MessageLevel.Object:
     580            var propertiesSection = new WebInspector.ObjectPropertiesSection(arguments[6], null, null, null, true);
     581            propertiesSection.element.addStyleClass("console-message");
     582            this.propertiesSection = propertiesSection;
     583            break;
     584        case WebInspector.ConsoleMessage.MessageLevel.Node:
     585            var node = arguments[6];
     586            if (!(node instanceof InspectorController.inspectedWindow().Node))
     587                return;
     588            this.elementsTreeOutline = new WebInspector.ElementsTreeOutline();
     589            this.elementsTreeOutline.rootDOMNode = node;
     590            break;
     591        case WebInspector.ConsoleMessage.MessageLevel.Trace:
     592            var span = document.createElement("span");
     593            span.addStyleClass("console-formatted-trace");
     594            var stack = Array.prototype.slice.call(arguments, 6);
     595            var funcNames = stack.map(function(f) {
     596                return f.name || WebInspector.UIString("(anonymous function)");
     597            });
     598            span.appendChild(document.createTextNode(funcNames.join("\n")));
     599            this.formattedMessage = span;
     600            break;
     601        default:
     602            // This _format call passes in true for the plainText argument. The result's textContent is
     603            // used for inline message bubbles in SourceFrames, or other plain-text representations.
     604            this.message = this._format(Array.prototype.slice.call(arguments, 6), true).textContent;
     605
     606            // The formatedMessage property is used for the rich and interactive console.
     607            this.formattedMessage = this._format(Array.prototype.slice.call(arguments, 6));
     608            break;
    588609    }
    589 
    590     // This _format call passes in true for the plainText argument. The result's textContent is
    591     // used for inline message bubbles in SourceFrames, or other plain-text representations.
    592     this.message = this._format(Array.prototype.slice.call(arguments, 6), true).textContent;
    593 
    594     // The formatedMessage property is used for the rich and interactive console.
    595     this.formattedMessage = this._format(Array.prototype.slice.call(arguments, 6));
    596610}
    597611
     
    813827    Object: 4,
    814828    Node: 5,
    815     StartGroup: 6,
    816     EndGroup: 7
     829    Trace: 6,
     830    StartGroup: 7,
     831    EndGroup: 8
    817832}
    818833
Note: See TracChangeset for help on using the changeset viewer.