Changeset 35755 in webkit


Ignore:
Timestamp:
Aug 14, 2008 10:41:05 AM (16 years ago)
Author:
timothy@apple.com
Message:

Avoid formating ConsoleMessages twice unless the message will be
displayed in bubbles of a SourceFrame.

Reviewed by Kevin McCullough.

  • page/inspector/Console.js: (WebInspector.ConsoleMessage): Only format the plain text message if the URL and line are valid and the level is error or warning. (WebInspector.ConsoleMessage.prototype.isErrorOrWarning): Added. Helper to test for error or warning level.
  • page/inspector/SourceFrame.js: (WebInspector.SourceFrame.prototype.addMessage): Don't add the message if there is no message or valid line or if the msg isn't an error or warning.
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r35753 r35755  
     12008-08-14  Timothy Hatcher  <timothy@apple.com>
     2
     3        Avoid formating ConsoleMessages twice unless the message will be
     4        displayed in bubbles of a SourceFrame.
     5
     6        Reviewed by Kevin McCullough.
     7
     8        * page/inspector/Console.js:
     9        (WebInspector.ConsoleMessage): Only format the plain text message
     10        if the URL and line are valid and the level is error or warning.
     11        (WebInspector.ConsoleMessage.prototype.isErrorOrWarning): Added.
     12        Helper to test for error or warning level.
     13        * page/inspector/SourceFrame.js:
     14        (WebInspector.SourceFrame.prototype.addMessage): Don't add the
     15        message if there is no message or valid line or if the msg
     16        isn't an error or warning.
     17
    1182008-08-14  Jan Michael Alonzo  <jmalonzo@webkit.org>
    219
  • trunk/WebCore/page/inspector/Console.js

    r35676 r35755  
    514514    this.groupLevel = groupLevel;
    515515
    516     // This _format call passes in true for the plainText argument. The result's textContent is
    517     // used for inline message bubbles in SourceFrames, or other plain-text representations.
    518     this.message = this._format(Array.prototype.slice.call(arguments, 5), true).textContent;
     516    if (url && line > 0 && this.isErrorOrWarning()) {
     517        // This _format call passes in true for the plainText argument. The result's textContent is
     518        // used for inline message bubbles in SourceFrames, or other plain-text representations.
     519        // Right now we only need to generate this string if the URL and line are valid and the level
     520        // is error or warning, since SourceFrame only shows these messages.
     521        this.message = this._format(Array.prototype.slice.call(arguments, 5), true).textContent;
     522    }
    519523
    520524    // The formatedMessage property is used for the rich and interactive console.
     
    523527
    524528WebInspector.ConsoleMessage.prototype = {
     529    isErrorOrWarning: function()
     530    {
     531        return (this.level === WebInspector.ConsoleMessage.MessageLevel.Warning || this.level === WebInspector.ConsoleMessage.MessageLevel.Error);
     532    },
     533
    525534    _format: function(parameters, plainText)
    526     {   
     535    {
    527536        var formattedResult = document.createElement("span");
    528537
  • trunk/WebCore/page/inspector/SourceFrame.js

    r35677 r35755  
    136136    addMessage: function(msg)
    137137    {
     138        // Don't add the message if there is no message or valid line or if the msg isn't an error or warning.
     139        if (!msg.message || msg.line <= 0 || !msg.isErrorOrWarning())
     140            return;
    138141        this.messages.push(msg);
    139142        this._addMessageToSource(msg);
Note: See TracChangeset for help on using the changeset viewer.