Title: [260091] trunk/Source/WebInspectorUI
Revision
260091
Author
drou...@apple.com
Date
2020-04-14 13:23:15 -0700 (Tue, 14 Apr 2020)

Log Message

Web Inspector: Console: treat long strings as non-simple so they aren't truncated
https://bugs.webkit.org/show_bug.cgi?id=210511
<rdar://problem/49570592>

Reviewed by Joseph Pecoraro.

Treat strings longer than 140 characters (`WI.FormattedValue.MaxPreviewStringLength`) as not
simple so that `WI.ConsoleMessageView` makes itself expandable, which will show the full
length string when expanded (the truncated string is still shown when collapsed).

* UserInterface/Views/FormattedValue.js:
(WI.FormattedValue.isSimpleString): Added.
(WI.FormattedValue.hasSimpleDisplay):
* UserInterface/Views/ConsoleMessageView.js:
(WI.ConsoleMessageView.prototype._shouldConsiderObjectLossless):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (260090 => 260091)


--- trunk/Source/WebInspectorUI/ChangeLog	2020-04-14 19:15:45 UTC (rev 260090)
+++ trunk/Source/WebInspectorUI/ChangeLog	2020-04-14 20:23:15 UTC (rev 260091)
@@ -1,3 +1,21 @@
+2020-04-14  Devin Rousso  <drou...@apple.com>
+
+        Web Inspector: Console: treat long strings as non-simple so they aren't truncated
+        https://bugs.webkit.org/show_bug.cgi?id=210511
+        <rdar://problem/49570592>
+
+        Reviewed by Joseph Pecoraro.
+
+        Treat strings longer than 140 characters (`WI.FormattedValue.MaxPreviewStringLength`) as not
+        simple so that `WI.ConsoleMessageView` makes itself expandable, which will show the full
+        length string when expanded (the truncated string is still shown when collapsed).
+
+        * UserInterface/Views/FormattedValue.js:
+        (WI.FormattedValue.isSimpleString): Added.
+        (WI.FormattedValue.hasSimpleDisplay):
+        * UserInterface/Views/ConsoleMessageView.js:
+        (WI.ConsoleMessageView.prototype._shouldConsiderObjectLossless):
+
 2020-04-12  Darin Adler  <da...@apple.com>
 
         Fix a few mispellings of descendant and propagation

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js (260090 => 260091)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js	2020-04-14 19:15:45 UTC (rev 260090)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js	2020-04-14 20:23:15 UTC (rev 260091)
@@ -659,12 +659,8 @@
 
     _shouldConsiderObjectLossless(object)
     {
-        if (object.type === "string") {
-            const description = object.description;
-            const maxLength = WI.FormattedValue.MAX_PREVIEW_STRING_LENGTH;
-            const longOrMultiLineString = description.length > maxLength || description.slice(0, maxLength).includes("\n");
-            return !longOrMultiLineString;
-        }
+        if (object.type === "string")
+            return WI.FormattedValue.isSimpleString(object.description);
 
         return object.type !== "object" || object.subtype === "null" || object.subtype === "regexp";
     }

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js (260090 => 260091)


--- trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js	2020-04-14 19:15:45 UTC (rev 260090)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js	2020-04-14 20:23:15 UTC (rev 260091)
@@ -25,17 +25,27 @@
 
 WI.FormattedValue = {};
 
+WI.FormattedValue.MaxPreviewStringLength = 140;
+
+WI.FormattedValue.isSimpleString = function(string)
+{
+    return string.length <= WI.FormattedValue.MaxPreviewStringLength
+        && !string.slice(0, WI.FormattedValue.MaxPreviewStringLength).includes("\n");
+};
+
 WI.FormattedValue.hasSimpleDisplay = function(object)
 {
     switch (object.type) {
     case "boolean":
     case "number":
-    case "string":
     case "symbol":
     case "bigint":
     case "undefined":
         return true;
 
+    case "string":
+        return WI.FormattedValue.isSimpleString(object.description);
+
     case "function":
         return false;
 
@@ -229,7 +239,7 @@
 
     // String: quoted and replace newlines as nice unicode symbols.
     if (type === "string") {
-        displayString = displayString.truncate(WI.FormattedValue.MAX_PREVIEW_STRING_LENGTH);
+        displayString = displayString.truncate(WI.FormattedValue.MaxPreviewStringLength);
         span.textContent = doubleQuotedString(displayString.replace(/\n/g, "\u21B5"));
         return span;
     }
@@ -312,5 +322,3 @@
 
     return WI.FormattedValue.createElementForRemoteObject(object);
 };
-
-WI.FormattedValue.MAX_PREVIEW_STRING_LENGTH = 140;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to