Title: [193239] branches/safari-601-branch/Source/WebInspectorUI

Diff

Modified: branches/safari-601-branch/Source/WebInspectorUI/ChangeLog (193238 => 193239)


--- branches/safari-601-branch/Source/WebInspectorUI/ChangeLog	2015-12-03 19:00:48 UTC (rev 193238)
+++ branches/safari-601-branch/Source/WebInspectorUI/ChangeLog	2015-12-03 19:00:55 UTC (rev 193239)
@@ -1,5 +1,27 @@
 2015-12-02  Timothy Hatcher  <[email protected]>
 
+        Merge r190426. rdar://problem/23221163
+
+    2015-10-01  Nikita Vasilyev  <[email protected]>
+
+            Web Inspector: Clip string previews
+            https://bugs.webkit.org/show_bug.cgi?id=149708
+
+            Only show first 140 characters in strings previews.
+
+            Reviewed by Joseph Pecoraro.
+
+            * UserInterface/Base/Utilities.js:
+            (String.prototype.truncate): Added.
+            A smart trancate function that doesn't split words.
+
+            * UserInterface/Views/ConsoleMessageView.js:
+            (WebInspector.ConsoleMessageView.prototype._shouldConsiderObjectLossless):
+            * UserInterface/Views/FormattedValue.js:
+            (WebInspector.FormattedValue.createElementForTypesAndValue):
+
+2015-12-02  Timothy Hatcher  <[email protected]>
+
         Merge r190416. rdar://problem/23221163
 
     2015-09-30  João Oliveira  <[email protected]>

Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Base/Utilities.js (193238 => 193239)


--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Base/Utilities.js	2015-12-03 19:00:48 UTC (rev 193238)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Base/Utilities.js	2015-12-03 19:00:55 UTC (rev 193239)
@@ -474,6 +474,24 @@
     }
 });
 
+Object.defineProperty(String.prototype, "truncate",
+{
+    value: function(maxLength)
+    {
+        "use strict";
+
+        if (this.length <= maxLength)
+            return this;
+
+        var clipped = this.slice(0, maxLength);
+        var indexOfLastWhitespace = clipped.search(/\s\S*$/);
+        if (indexOfLastWhitespace > Math.floor(maxLength / 2))
+            clipped = clipped.slice(0, indexOfLastWhitespace - 1);
+
+        return clipped + "\u2026";
+    }
+});
+
 Object.defineProperty(String.prototype, "collapseWhitespace",
 {
     value: function()

Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Controllers/TypeTokenAnnotator.js (193238 => 193239)


--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Controllers/TypeTokenAnnotator.js	2015-12-03 19:00:48 UTC (rev 193238)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Controllers/TypeTokenAnnotator.js	2015-12-03 19:00:55 UTC (rev 193239)
@@ -147,7 +147,7 @@
         var isMultiLineComment = false;
         var isSingleLineComment = false;
         var shouldIgnore = false;
-        const isArrowFunction = node.type === WebInspector.ScriptSyntaxTree.NodeType.ArrowFunctionExpression;
+        var isArrowFunction = node.type === WebInspector.ScriptSyntaxTree.NodeType.ArrowFunctionExpression;
 
         function isLineTerminator(char)
         {

Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js (193238 => 193239)


--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js	2015-12-03 19:00:48 UTC (rev 193238)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js	2015-12-03 19:00:55 UTC (rev 193239)
@@ -465,6 +465,13 @@
 
     _shouldConsiderObjectLossless(object)
     {
+        if (object.type === "string") {
+            var description = object.description;
+            var maxLength = WebInspector.FormattedValue.MAX_PREVIEW_STRING_LENGTH;
+            var longOrMultiLineString = description.length > maxLength || description.slice(0, maxLength).includes("\n");
+            return !longOrMultiLineString;
+        }
+
         return object.type !== "object" || object.subtype === "null" || object.subtype === "regexp";
     }
 

Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js (193238 => 193239)


--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js	2015-12-03 19:00:48 UTC (rev 193238)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js	2015-12-03 19:00:55 UTC (rev 193239)
@@ -168,6 +168,7 @@
 
     // String: quoted and replace newlines as nice unicode symbols.
     if (type === "string") {
+        displayString = displayString.truncate(WebInspector.FormattedValue.MAX_PREVIEW_STRING_LENGTH);
         span.textContent = doubleQuotedString(displayString.replace(/\n/g, "\u21B5"));
         return span;
     }
@@ -238,3 +239,5 @@
 
     return WebInspector.FormattedValue.createElementForRemoteObject(object);
 };
+
+WebInspector.FormattedValue.MAX_PREVIEW_STRING_LENGTH = 140;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to