[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

eric at webkit.org eric at webkit.org
Thu Oct 29 20:31:59 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit a45299ed6926c60df9b98acc22790daea8432091
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Sep 22 17:41:46 2009 +0000

    2009-09-22  Patrick Mueller  <Patrick_Mueller at us.ibm.com>
    
            Reviewed by Timothy Hatcher.
    
            WebInspector.log() function not protected if console not yet created
            https://bugs.webkit.org/show_bug.cgi?id=29336
    
            No new tests.  Only affects Web Inspector developers adding logging
            to their code during development.
    
            * inspector/front-end/inspector.js:
            (WebInspector.log.isLogAvailable):
            (WebInspector.log.flushQueue):
            (WebInspector.log.flushQueueIfAvailable):
            (WebInspector.log.logMessage):
            (WebInspector.log):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48641 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 543ee5b..fa1ccf8 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,20 @@
+2009-09-22  Patrick Mueller  <Patrick_Mueller at us.ibm.com>
+
+        Reviewed by Timothy Hatcher.
+
+        WebInspector.log() function not protected if console not yet created
+        https://bugs.webkit.org/show_bug.cgi?id=29336
+        
+        No new tests.  Only affects Web Inspector developers adding logging
+        to their code during development.
+
+        * inspector/front-end/inspector.js:
+        (WebInspector.log.isLogAvailable):
+        (WebInspector.log.flushQueue):
+        (WebInspector.log.flushQueueIfAvailable):
+        (WebInspector.log.logMessage):
+        (WebInspector.log):
+
 2009-09-22  Yaar Schnitman  <yaar at chromium.org>
 
         Reviewed by David Levin.
diff --git a/WebCore/inspector/front-end/inspector.js b/WebCore/inspector/front-end/inspector.js
index a61b53b..ade1d88 100644
--- a/WebCore/inspector/front-end/inspector.js
+++ b/WebCore/inspector/front-end/inspector.js
@@ -1128,16 +1128,86 @@ WebInspector.addMessageToConsole = function(payload)
 
 WebInspector.log = function(message)
 {
-    var msg = new WebInspector.ConsoleMessage(
-        WebInspector.ConsoleMessage.MessageSource.Other,
-        WebInspector.ConsoleMessage.MessageType.Log,
-        WebInspector.ConsoleMessage.MessageLevel.Debug,
-        -1,
-        null,
-        null,
-        1,
-        message);
-    this.console.addMessage(msg);
+    // remember 'this' for setInterval() callback
+    var self = this;
+    
+    // return indication if we can actually log a message
+    function isLogAvailable()
+    {
+        return WebInspector.ConsoleMessage && WebInspector.ObjectProxy && self.console;
+    }
+    
+    // flush the queue of pending messages
+    function flushQueue()
+    {
+        var queued = WebInspector.log.queued;
+        if (!queued) 
+            return;
+            
+        for (var i = 0; i < queued.length; ++i)
+            logMessage(queued[i]);
+        
+        delete WebInspector.log.queued;
+    }
+
+    // flush the queue if it console is available
+    // - this function is run on an interval
+    function flushQueueIfAvailable()
+    {
+        if (!isLogAvailable())
+            return;
+            
+        clearInterval(WebInspector.log.interval);
+        delete WebInspector.log.interval;
+        
+        flushQueue();
+    }
+    
+    // actually log the message
+    function logMessage(message)
+    {
+        var repeatCount = 1;
+        if (message == WebInspector.log.lastMessage)
+            repeatCount = WebInspector.log.repeatCount + 1;
+    
+        WebInspector.log.lastMessage = message;
+        WebInspector.log.repeatCount = repeatCount;
+        
+        // ConsoleMessage expects a proxy object
+        message = new WebInspector.ObjectProxy(null, [], 0, message, false);
+        
+        // post the message
+        var msg = new WebInspector.ConsoleMessage(
+            WebInspector.ConsoleMessage.MessageSource.Other,
+            WebInspector.ConsoleMessage.MessageType.Log,
+            WebInspector.ConsoleMessage.MessageLevel.Debug,
+            -1,
+            null,
+            null,
+            repeatCount,
+            message);
+    
+        self.console.addMessage(msg);
+    }
+    
+    // if we can't log the message, queue it
+    if (!isLogAvailable()) {
+        if (!WebInspector.log.queued)
+            WebInspector.log.queued = [];
+            
+        WebInspector.log.queued.push(message);
+        
+        if (!WebInspector.log.interval)
+            WebInspector.log.interval = setInterval(flushQueueIfAvailable, 1000);
+        
+        return;
+    }
+
+    // flush the pending queue if any
+    flushQueue();
+
+    // log the message
+    logMessage(message);
 }
 
 WebInspector.addProfile = function(profile)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list