Web Inspector: Don't output "No message" for multi-value logs like console.log(x, y)
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Jul 2017 02:27:08 +0000 (02:27 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Jul 2017 02:27:08 +0000 (02:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=174842

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2017-07-25
Reviewed by Matt Baker.

* Localizations/en.lproj/localizedStrings.js:
Removed "No message".

* UserInterface/Views/ConsoleMessageView.js:
(WebInspector.ConsoleMessageView.prototype._appendFormattedArguments):
Track whether or not outputting the next parameter will need a divider
in front of it or not.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js

index 4dfcee467da93db32898e612004158bb00d33fd5..7fa45bf13ec8e84b7d9b4934ed9fff778e946d1f 100644 (file)
@@ -1,3 +1,18 @@
+2017-07-25  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Don't output "No message" for multi-value logs like console.log(x, y)
+        https://bugs.webkit.org/show_bug.cgi?id=174842
+
+        Reviewed by Matt Baker.
+
+        * Localizations/en.lproj/localizedStrings.js:
+        Removed "No message".
+
+        * UserInterface/Views/ConsoleMessageView.js:
+        (WebInspector.ConsoleMessageView.prototype._appendFormattedArguments):
+        Track whether or not outputting the next parameter will need a divider
+        in front of it or not.
+
 2017-07-25  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Fix warnings about console.assert lines without semicolons
index 597835254f2d794ed944a1f7c9aac151cee89105..7268f5da889d5374a25f6df75e0de411c7ced25e 100644 (file)
@@ -586,7 +586,6 @@ localizedStrings["No Results Found"] = "No Results Found";
 localizedStrings["No Search Results"] = "No Search Results";
 localizedStrings["No Watch Expressions"] = "No Watch Expressions";
 localizedStrings["No matching ARIA role"] = "No matching ARIA role";
-localizedStrings["No message"] = "No message";
 localizedStrings["No preview available"] = "No preview available";
 localizedStrings["Node"] = "Node";
 localizedStrings["Node Removed"] = "Node Removed";
index 4f1019e1880a2349ef55ef2dd2b396574ae4b702..4bbe52b38d3276d616e6fb12cf75af339c797228 100644 (file)
@@ -444,14 +444,22 @@ WebInspector.ConsoleMessageView = class ConsoleMessageView extends WebInspector.
         if (shouldFormatWithStringSubstitution && this._isStackTrace(parameters[0]))
             shouldFormatWithStringSubstitution = false;
 
-        // Format string / message / default message.
+        let needsDivider = false;
+        function appendDividerIfNeeded() {
+            if (!needsDivider)
+                return null;
+            let element = builderElement.appendChild(document.createElement("span"));
+            element.classList.add("console-message-preview-divider");
+            element.textContent = ` ${enDash} `;
+            return element;
+        }
+
+        // Format string.
         if (shouldFormatWithStringSubstitution) {
             let result = this._formatWithSubstitutionString(parameters, builderElement);
             parameters = result.unusedSubstitutions;
             this._extraParameters = parameters;
-        } else {
-            let defaultMessage = WebInspector.UIString("No message");
-            builderElement.append(defaultMessage);
+            needsDivider = true;
         }
 
         // Trailing inline parameters.
@@ -469,9 +477,9 @@ WebInspector.ConsoleMessageView = class ConsoleMessageView extends WebInspector.
                 this._extraParameters = parameters;
 
                 for (let parameter of simpleParameters) {
-                    let enclosedElement = builderElement.appendChild(document.createElement("span"));
-                    enclosedElement.classList.add("console-message-preview-divider", "inline-lossless");
-                    enclosedElement.textContent = ` ${enDash} `;
+                    let dividerElement = appendDividerIfNeeded();
+                    if (dividerElement)
+                        dividerElement.classList.add("inline-lossless");
 
                     let previewContainer = builderElement.appendChild(document.createElement("span"));
                     previewContainer.classList.add("inline-lossless");
@@ -485,6 +493,8 @@ WebInspector.ConsoleMessageView = class ConsoleMessageView extends WebInspector.
                     let previewElement = isPreviewView ? preview.element : preview;
                     previewContainer.appendChild(previewElement);
 
+                    needsDivider = true;
+
                     // Simple displayable parameters should pretty much always be lossless.
                     // An exception might be a truncated string.
                     console.assert((isPreviewView && preview.lossless) || (!isPreviewView && this._shouldConsiderObjectLossless(parameter)));
@@ -495,9 +505,7 @@ WebInspector.ConsoleMessageView = class ConsoleMessageView extends WebInspector.
             if (parameters.length === 1 && !this._isStackTrace(parameters[0])) {
                 let parameter = parameters[0];
 
-                let enclosedElement = builderElement.appendChild(document.createElement("span"));
-                enclosedElement.classList.add("console-message-preview-divider");
-                enclosedElement.textContent = ` ${enDash} `;
+                let dividerElement = appendDividerIfNeeded();
 
                 let previewContainer = builderElement.appendChild(document.createElement("span"));
                 previewContainer.classList.add("console-message-preview");
@@ -511,10 +519,13 @@ WebInspector.ConsoleMessageView = class ConsoleMessageView extends WebInspector.
                 let previewElement = isPreviewView ? preview.element : preview;
                 previewContainer.appendChild(previewElement);
 
+                needsDivider = true;
+
                 // If this preview is effectively lossless, we can avoid making this console message expandable.
                 if ((isPreviewView && preview.lossless) || (!isPreviewView && this._shouldConsiderObjectLossless(parameter))) {
                     this._extraParameters = null;
-                    enclosedElement.classList.add("inline-lossless");
+                    if (dividerElement)
+                        dividerElement.classList.add("inline-lossless");
                     previewContainer.classList.add("inline-lossless");
                 }
             } else if (parameters.length) {