Web Inspector: order console message parameters for better optional parameters handling.
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Oct 2011 09:25:39 +0000 (09:25 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Oct 2011 09:25:39 +0000 (09:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=70809

Reviewed by Yury Semikhatsky.

Source/WebCore:

* inspector/Inspector.json:
* inspector/front-end/ConsoleMessage.js:
(WebInspector.ConsoleMessageImpl):
(WebInspector.ConsoleMessageImpl.prototype._formatMessage):
* inspector/front-end/ConsoleModel.js:
(WebInspector.ConsoleModel.prototype._messageRepeatCountUpdated):
(WebInspector.ConsoleMessage.create):
(WebInspector.ConsoleDispatcher.prototype.messageAdded):
* inspector/front-end/ConsoleView.js:
(WebInspector.ConsoleCommandResult):
(WebInspector.ConsoleMessage.create):
* inspector/front-end/ExtensionServer.js:
(WebInspector.ExtensionServer.prototype._onAddConsoleMessage):
* inspector/front-end/NetworkManager.js:
(WebInspector.NetworkDispatcher.prototype._updateResourceWithResponse):
* inspector/front-end/inspector.js:
(WebInspector.log.logMessage):
(WebInspector.log):

LayoutTests:

* inspector/console/console-preserve-log.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@98456 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/inspector/console/console-preserve-log.html
Source/WebCore/ChangeLog
Source/WebCore/inspector/Inspector.json
Source/WebCore/inspector/front-end/ConsoleMessage.js
Source/WebCore/inspector/front-end/ConsoleModel.js
Source/WebCore/inspector/front-end/ConsoleView.js
Source/WebCore/inspector/front-end/ExtensionServer.js
Source/WebCore/inspector/front-end/NetworkManager.js
Source/WebCore/inspector/front-end/inspector.js

index 07d2613..6dc3bf1 100644 (file)
@@ -1,3 +1,12 @@
+2011-10-26  Pavel Feldman  <pfeldman@google.com>
+
+        Web Inspector: order console message parameters for better optional parameters handling.
+        https://bugs.webkit.org/show_bug.cgi?id=70809
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/console/console-preserve-log.html:
+
 2011-10-26  Ryosuke Niwa  <rniwa@webkit.org>
 
         Fix rebaseline done in r98439.
index b32e926..5147999 100644 (file)
@@ -5,7 +5,7 @@
 <script>
 function test()
 {
-    WebInspector.console.addMessage(WebInspector.ConsoleMessage.createTextMessage("PASS"));
+    WebInspector.console.addMessage(WebInspector.ConsoleMessage.create(WebInspector.ConsoleMessage.MessageSource.Other, WebInspector.ConsoleMessage.MessageLevel, "PASS"));
     WebInspector.settings.preserveConsoleLog.set(true);
     InspectorTest.reloadPage(function() {
         InspectorTest.dumpConsoleMessages();
index 4c75a94..8db9e50 100644 (file)
@@ -1,3 +1,29 @@
+2011-10-26  Pavel Feldman  <pfeldman@google.com>
+
+        Web Inspector: order console message parameters for better optional parameters handling.
+        https://bugs.webkit.org/show_bug.cgi?id=70809
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/Inspector.json:
+        * inspector/front-end/ConsoleMessage.js:
+        (WebInspector.ConsoleMessageImpl):
+        (WebInspector.ConsoleMessageImpl.prototype._formatMessage):
+        * inspector/front-end/ConsoleModel.js:
+        (WebInspector.ConsoleModel.prototype._messageRepeatCountUpdated):
+        (WebInspector.ConsoleMessage.create):
+        (WebInspector.ConsoleDispatcher.prototype.messageAdded):
+        * inspector/front-end/ConsoleView.js:
+        (WebInspector.ConsoleCommandResult):
+        (WebInspector.ConsoleMessage.create):
+        * inspector/front-end/ExtensionServer.js:
+        (WebInspector.ExtensionServer.prototype._onAddConsoleMessage):
+        * inspector/front-end/NetworkManager.js:
+        (WebInspector.NetworkDispatcher.prototype._updateResourceWithResponse):
+        * inspector/front-end/inspector.js:
+        (WebInspector.log.logMessage):
+        (WebInspector.log):
+
 2011-10-26  Vsevolod Vlasov  <vsevik@chromium.org>
 
         Web Inspector: Debugger fails when there is an invalid watch expression.
index 53ba26a..e2a0c0d 100644 (file)
                     { "name": "url", "type": "string", "optional": true, "description": "URL of the message origin." },
                     { "name": "line", "type": "integer", "optional": true, "description": "Line number in the resource that generated this message." },
                     { "name": "repeatCount", "type": "integer", "optional": true, "description": "Repeat count for repeated messages." },
-                    { "name": "networkRequestId", "$ref": "Network.RequestId", "optional": true, "description": "Identifier of the network request associated with this message." },
                     { "name": "parameters", "type": "array", "items": { "$ref": "Runtime.RemoteObject" }, "optional": true, "description": "Message parameters in case of the formatted message." },
-                    { "name": "stackTrace", "$ref": "StackTrace", "optional": true, "description": "JavaScript stack trace for assertions and error messages." }
+                    { "name": "stackTrace", "$ref": "StackTrace", "optional": true, "description": "JavaScript stack trace for assertions and error messages." },
+                    { "name": "networkRequestId", "$ref": "Network.RequestId", "optional": true, "description": "Identifier of the network request associated with this message." }
                 ]
             },
             {
index e685541..27623bc 100644 (file)
 /**
  * @constructor
  * @extends {WebInspector.ConsoleMessage}
+ *
+ * @param {string} source
+ * @param {string} level
+ * @param {string} message
  * @param {WebInspector.DebuggerPresentationModel.Linkifier} linkifier
+ * @param {string=} type
+ * @param {string=} url
+ * @param {number=} line
+ * @param {number=} repeatCount
  * @param {Array.<RuntimeAgent.RemoteObject>=} parameters
  * @param {ConsoleAgent.StackTrace=} stackTrace
  * @param {WebInspector.Resource=} request
  */
-WebInspector.ConsoleMessageImpl = function(source, type, level, line, url, repeatCount, message, linkifier, parameters, stackTrace, request)
+WebInspector.ConsoleMessageImpl = function(source, level, message, linkifier, type, url, line, repeatCount, parameters, stackTrace, request)
 {
     WebInspector.ConsoleMessage.call();
 
     this._linkifier = linkifier;
     this.source = source;
-    this.type = type;
+    this.type = type || WebInspector.ConsoleMessage.MessageType.Log;
     this.level = level;
-    this.line = line;
-    this.url = url;
+    this.line = line || -1;
+    this.url = url || null;
+    repeatCount = repeatCount || 1;
     this.repeatCount = repeatCount;
     this.repeatDelta = repeatCount;
     this.totalRepeatCount = repeatCount;
@@ -129,9 +138,11 @@ WebInspector.ConsoleMessageImpl.prototype = {
                     messageText.appendChild(fragment);
                 }
             } else {
-                var isExternal = !WebInspector.resourceForURL(this.url);
-                var anchor = WebInspector.linkifyURLAsNode(this.url, this.url, "console-message-url", isExternal);
-                this._formattedMessage.appendChild(anchor);
+                if (this.url) {
+                    var isExternal = !WebInspector.resourceForURL(this.url);
+                    var anchor = WebInspector.linkifyURLAsNode(this.url, this.url, "console-message-url", isExternal);
+                    this._formattedMessage.appendChild(anchor);
+                }
                 messageText = this._format([this._messageText]);
             }
         } else {
index 213e7e1..90ef7a0 100644 (file)
@@ -121,7 +121,7 @@ WebInspector.ConsoleModel.prototype = {
             this._incrementErrorWarningCount(msg);
             this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.RepeatCountUpdated, msg);
         } else {
-            var msgCopy = WebInspector.ConsoleMessage.create(msg.source, msg.type, msg.level, msg.line, msg.url, count - prevRepeatCount, msg._messageText, msg._parameters, msg._stackTrace, msg._request);
+            var msgCopy = WebInspector.ConsoleMessage.create(msg.source, msg.level, msg._messageText, msg.type, msg.url, msg.line, count - prevRepeatCount, msg._parameters, msg._stackTrace, msg._request);
             msgCopy.totalRepeatCount = count;
             this.addMessage(msgCopy);
         }
@@ -162,28 +162,19 @@ WebInspector.ConsoleMessage.prototype = {
 
 /**
  * @param {string} source
- * @param {string} type
  * @param {string} level
- * @param {number} line
- * @param {string} url
- * @param {number} repeatCount
  * @param {string} message
+ * @param {string=} type
+ * @param {string=} url
+ * @param {number=} line
+ * @param {number=} repeatCount
  * @param {Array.<RuntimeAgent.RemoteObject>=} parameters
  * @param {ConsoleAgent.StackTrace=} stackTrace
  * @param {WebInspector.Resource=} request
  *
  * @return {WebInspector.ConsoleMessage}
  */
-WebInspector.ConsoleMessage.create = function(source, type, level, line, url, repeatCount, message, parameters, stackTrace, request)
-{
-}
-
-/**
- * @param {string} text
- * @param {string} level
- * @return {WebInspector.ConsoleMessage}
- */
-WebInspector.ConsoleMessage.createTextMessage = function(text, level)
+WebInspector.ConsoleMessage.create = function(source, level, message, type, url, line, repeatCount, parameters, stackTrace, request)
 {
 }
 
@@ -236,12 +227,12 @@ WebInspector.ConsoleDispatcher.prototype = {
     {
         var consoleMessage = WebInspector.ConsoleMessage.create(
             payload.source,
-            payload.type,
             payload.level,
-            payload.line,
+            payload.text,
+            payload.type,
             payload.url,
+            payload.line,
             payload.repeatCount,
-            payload.text,
             payload.parameters,
             payload.stackTrace,
             payload.networkRequestId ? WebInspector.networkResourceById(payload.networkRequestId) : undefined);
index f4f8432..75f48b9 100644 (file)
@@ -704,12 +704,13 @@ WebInspector.ConsoleCommand.prototype = {
 /**
  * @extends {WebInspector.ConsoleMessageImpl}
  * @constructor
+ * @param {WebInspector.DebuggerPresentationModel.Linkifier} linkifier
  */
 WebInspector.ConsoleCommandResult = function(result, wasThrown, originatingCommand, linkifier)
 {
     var level = (wasThrown ? WebInspector.ConsoleMessage.MessageLevel.Error : WebInspector.ConsoleMessage.MessageLevel.Log);
     this.originatingCommand = originatingCommand;
-    WebInspector.ConsoleMessageImpl.call(this, WebInspector.ConsoleMessage.MessageSource.JS, WebInspector.ConsoleMessage.MessageType.Result, level, -1, null, 1, null, linkifier, [result]);
+    WebInspector.ConsoleMessageImpl.call(this, WebInspector.ConsoleMessage.MessageSource.JS, level, "", linkifier, WebInspector.ConsoleMessage.MessageType.Result, undefined, undefined, undefined, [result]);
 }
 
 WebInspector.ConsoleCommandResult.prototype = {
@@ -788,13 +789,7 @@ WebInspector.ConsoleGroup.prototype = {
  */
 WebInspector.consoleView = null;
 
-WebInspector.ConsoleMessage.create = function(source, type, level, line, url, repeatCount, message, parameters, stackTrace, request)
+WebInspector.ConsoleMessage.create = function(source, level, message, type, url, line, repeatCount, parameters, stackTrace, request)
 {
-    return new WebInspector.ConsoleMessageImpl(source, type, level, line, url, repeatCount, message, WebInspector.consoleView._linkifier, parameters, stackTrace, request);
-}
-
-WebInspector.ConsoleMessage.createTextMessage = function(text, level)
-{
-    level = level || WebInspector.ConsoleMessage.MessageLevel.Log;
-    return new WebInspector.ConsoleMessageImpl(WebInspector.ConsoleMessage.MessageSource.ConsoleAPI, WebInspector.ConsoleMessage.MessageType.Log, level, 0, null, 1, null, WebInspector.consoleView._linkifier, [text], null);
+    return new WebInspector.ConsoleMessageImpl(source, level, message, WebInspector.consoleView._linkifier, type, url, line, repeatCount, parameters, stackTrace, request);
 }
index 5a55073..dc6d9fe 100644 (file)
@@ -339,12 +339,12 @@ WebInspector.ExtensionServer.prototype = {
 
         var consoleMessage = WebInspector.ConsoleMessage.create(
             WebInspector.ConsoleMessage.MessageSource.JS,
-            WebInspector.ConsoleMessage.MessageType.Log,
             level,
-            message.line,
+            message.text,
+            WebInspector.ConsoleMessage.MessageType.Log,
             message.url,
+            message.line,
             1,
-            message.text,
             null, // parameters
             null, // stackTrace
             null); // networkRequestId
index 1ebaf72..45944bf 100644 (file)
@@ -128,12 +128,10 @@ WebInspector.NetworkDispatcher.prototype = {
 
         if (!this._mimeTypeIsConsistentWithType(resource)) {
             WebInspector.console.addMessage(WebInspector.ConsoleMessage.create(WebInspector.ConsoleMessage.MessageSource.Other,
-                WebInspector.ConsoleMessage.MessageType.Log,
                 WebInspector.ConsoleMessage.MessageLevel.Warning,
-                -1,
-                this.url,
-                1,
-                WebInspector.UIString("Resource interpreted as %s but transferred with MIME type %s.", WebInspector.Resource.Type.toUIString(this.type), this.mimeType)));
+                WebInspector.UIString("Resource interpreted as %s but transferred with MIME type %s.", WebInspector.Resource.Type.toUIString(this.type), this.mimeType),
+                WebInspector.ConsoleMessage.MessageType.Log,
+                this.url));
         }
     },
 
index 91f71f7..d7e7652 100644 (file)
@@ -959,27 +959,11 @@ WebInspector.log = function(message, messageLevel, showConsole)
     // 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 = WebInspector.RemoteObject.fromPrimitiveValue(message);
-
         // post the message
         var msg = WebInspector.ConsoleMessage.create(
             WebInspector.ConsoleMessage.MessageSource.Other,
-            WebInspector.ConsoleMessage.MessageType.Log,
             messageLevel || WebInspector.ConsoleMessage.MessageLevel.Debug,
-            -1,
-            null,
-            repeatCount,
-            null,
-            [message],
-            null);
+            message);
 
         self.console.addMessage(msg);
         if (showConsole)