Title: [228645] releases/WebKitGTK/webkit-2.20
Revision
228645
Author
carlo...@webkit.org
Date
2018-02-19 03:24:12 -0800 (Mon, 19 Feb 2018)

Log Message

Merge r228214 - Web Inspector: Rename String.prototype.trimEnd to avoid conflicts with native trimEnd
https://bugs.webkit.org/show_bug.cgi?id=182545

Reviewed by Brian Burg.

Source/WebInspectorUI:

Rename:
- trimEnd to truncateEnd
- trimMiddle to truncateMiddle

* UserInterface/Base/Utilities.js:
(String.prototype.trimMiddle): Deleted.
(String.prototype.trimEnd): Deleted.
(String.prototype.truncateMiddle): Added.
(String.prototype.truncateEnd): Added.
Use strict mode. Scrict mode allows `this` to be a primitive (a string, in our case).
In non-strict mode, `this` is always an object. Without the strict mode,
"a".truncateEnd(42) !== "a", because truncateEnd returns a string object.

* UserInterface/Views/DOMTreeElement.js:
(WI.DOMTreeElement.prototype._buildAttributeDOM):
* UserInterface/Views/DOMTreeElementPathComponent.js:
(WI.DOMTreeElementPathComponent):
* UserInterface/Views/SearchResultTreeElement.js:
Remove an obvious comment.

(WI.SearchResultTreeElement.truncateAndHighlightTitle):
* UserInterface/Views/SpreadsheetStyleProperty.js:
(WI.SpreadsheetStyleProperty.prototype._renderValue):

LayoutTests:

* inspector/unit-tests/string-utilities-expected.txt:
* inspector/unit-tests/string-utilities.html:

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.20/LayoutTests/ChangeLog (228644 => 228645)


--- releases/WebKitGTK/webkit-2.20/LayoutTests/ChangeLog	2018-02-19 11:02:34 UTC (rev 228644)
+++ releases/WebKitGTK/webkit-2.20/LayoutTests/ChangeLog	2018-02-19 11:24:12 UTC (rev 228645)
@@ -1,3 +1,13 @@
+2018-02-06  Nikita Vasilyev  <nvasil...@apple.com>
+
+        Web Inspector: Rename String.prototype.trimEnd to avoid conflicts with native trimEnd
+        https://bugs.webkit.org/show_bug.cgi?id=182545
+
+        Reviewed by Brian Burg.
+
+        * inspector/unit-tests/string-utilities-expected.txt:
+        * inspector/unit-tests/string-utilities.html:
+
 2018-02-06  Said Abou-Hallawa  <sabouhall...@apple.com>
 
         Rendering SVG images with same size as WebGL texture doesn't work correctly

Modified: releases/WebKitGTK/webkit-2.20/LayoutTests/inspector/unit-tests/string-utilities-expected.txt (228644 => 228645)


--- releases/WebKitGTK/webkit-2.20/LayoutTests/inspector/unit-tests/string-utilities-expected.txt	2018-02-19 11:02:34 UTC (rev 228644)
+++ releases/WebKitGTK/webkit-2.20/LayoutTests/inspector/unit-tests/string-utilities-expected.txt	2018-02-19 11:24:12 UTC (rev 228645)
@@ -46,3 +46,13 @@
 PASS: Last line of a string with a traling line break should be empty.
 PASS: Last line of an empty string is the same empty string.
 
+-- Running test case: String.prototype.truncateMiddle
+PASS: String stays the same.
+PASS: Ellipsis is inserted in the middle.
+PASS: Ellipsis is inserted after the second character.
+
+-- Running test case: String.prototype.truncateEnd
+PASS: String stays the same.
+PASS: Ellipsis is inserted in the middle.
+PASS: Ellipsis is inserted after the third character.
+

Modified: releases/WebKitGTK/webkit-2.20/LayoutTests/inspector/unit-tests/string-utilities.html (228644 => 228645)


--- releases/WebKitGTK/webkit-2.20/LayoutTests/inspector/unit-tests/string-utilities.html	2018-02-19 11:02:34 UTC (rev 228644)
+++ releases/WebKitGTK/webkit-2.20/LayoutTests/inspector/unit-tests/string-utilities.html	2018-02-19 11:24:12 UTC (rev 228645)
@@ -1,6 +1,7 @@
 <!doctype html>
 <html>
 <head>
+<meta charset="utf-8">
 <script src=""
 <script>
 function test()
@@ -78,6 +79,28 @@
         }
     });
 
+    suite.addTestCase({
+        name: "String.prototype.truncateMiddle",
+        test() {
+            const ellipsis = "\u2026";
+            InspectorTest.expectEqual("abcdef".truncateMiddle(6), "abcdef", "String stays the same.");
+            InspectorTest.expectEqual("abcdef".truncateMiddle(5), `ab${ellipsis}ef`, "Ellipsis is inserted in the middle.");
+            InspectorTest.expectEqual("abcdef".truncateMiddle(4), `ab${ellipsis}f`, "Ellipsis is inserted after the second character.");
+            return true;
+        }
+    });
+
+    suite.addTestCase({
+        name: "String.prototype.truncateEnd",
+        test() {
+            const ellipsis = "\u2026";
+            InspectorTest.expectEqual("abcdef".truncateEnd(6), "abcdef", "String stays the same.");
+            InspectorTest.expectEqual("abcdef".truncateEnd(5), "abcd" + ellipsis, "Ellipsis is inserted in the middle.");
+            InspectorTest.expectEqual("abcdef".truncateEnd(4), "abc" + ellipsis, "Ellipsis is inserted after the third character.");
+            return true;
+        }
+    });
+
     suite.runTestCasesAndFinish();
 }
 </script>

Modified: releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/ChangeLog (228644 => 228645)


--- releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/ChangeLog	2018-02-19 11:02:34 UTC (rev 228644)
+++ releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/ChangeLog	2018-02-19 11:24:12 UTC (rev 228645)
@@ -1,3 +1,34 @@
+2018-02-06  Nikita Vasilyev  <nvasil...@apple.com>
+
+        Web Inspector: Rename String.prototype.trimEnd to avoid conflicts with native trimEnd
+        https://bugs.webkit.org/show_bug.cgi?id=182545
+
+        Reviewed by Brian Burg.
+
+        Rename:
+        - trimEnd to truncateEnd
+        - trimMiddle to truncateMiddle
+
+        * UserInterface/Base/Utilities.js:
+        (String.prototype.trimMiddle): Deleted.
+        (String.prototype.trimEnd): Deleted.
+        (String.prototype.truncateMiddle): Added.
+        (String.prototype.truncateEnd): Added.
+        Use strict mode. Scrict mode allows `this` to be a primitive (a string, in our case).
+        In non-strict mode, `this` is always an object. Without the strict mode,
+        "a".truncateEnd(42) !== "a", because truncateEnd returns a string object.
+
+        * UserInterface/Views/DOMTreeElement.js:
+        (WI.DOMTreeElement.prototype._buildAttributeDOM):
+        * UserInterface/Views/DOMTreeElementPathComponent.js:
+        (WI.DOMTreeElementPathComponent):
+        * UserInterface/Views/SearchResultTreeElement.js:
+        Remove an obvious comment.
+
+        (WI.SearchResultTreeElement.truncateAndHighlightTitle):
+        * UserInterface/Views/SpreadsheetStyleProperty.js:
+        (WI.SpreadsheetStyleProperty.prototype._renderValue):
+
 2018-02-02  Devin Rousso  <web...@devinrousso.com>
 
         Web Inspector: Styles Redesign: Pasting multiple properties should create properties instead of a bad property

Modified: releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Base/Utilities.js (228644 => 228645)


--- releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Base/Utilities.js	2018-02-19 11:02:34 UTC (rev 228644)
+++ releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Base/Utilities.js	2018-02-19 11:24:12 UTC (rev 228645)
@@ -579,10 +579,12 @@
     }
 });
 
-Object.defineProperty(String.prototype, "trimMiddle",
+Object.defineProperty(String.prototype, "truncateMiddle",
 {
     value(maxLength)
     {
+        "use strict";
+
         if (this.length <= maxLength)
             return this;
         var leftHalf = maxLength >> 1;
@@ -591,10 +593,12 @@
     }
 });
 
-Object.defineProperty(String.prototype, "trimEnd",
+Object.defineProperty(String.prototype, "truncateEnd",
 {
     value(maxLength)
     {
+        "use strict";
+
         if (this.length <= maxLength)
             return this;
         return this.substr(0, maxLength - 1) + ellipsis;

Modified: releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js (228644 => 228645)


--- releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js	2018-02-19 11:02:34 UTC (rev 228644)
+++ releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js	2018-02-19 11:24:12 UTC (rev 228645)
@@ -1271,7 +1271,7 @@
                 attrValueElement.textContent = value;
             } else {
                 if (value.startsWith("data:"))
-                    value = value.trimMiddle(60);
+                    value = value.truncateMiddle(60);
 
                 attrValueElement = document.createElement("a");
                 attrValueElement.href = ""

Modified: releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Views/DOMTreeElementPathComponent.js (228644 => 228645)


--- releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Views/DOMTreeElementPathComponent.js	2018-02-19 11:02:34 UTC (rev 228644)
+++ releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Views/DOMTreeElementPathComponent.js	2018-02-19 11:24:12 UTC (rev 228645)
@@ -45,12 +45,12 @@
 
         case Node.TEXT_NODE:
             className = WI.DOMTreeElementPathComponent.DOMTextNodeIconStyleClassName;
-            title = "\"" + node.nodeValue().trimEnd(32) + "\"";
+            title = "\"" + node.nodeValue().truncateEnd(32) + "\"";
             break;
 
         case Node.COMMENT_NODE:
             className = WI.DOMTreeElementPathComponent.DOMCommentIconStyleClassName;
-            title = "<!--" + node.nodeValue().trimEnd(32) + "-->";
+            title = "<!--" + node.nodeValue().truncateEnd(32) + "-->";
             break;
 
         case Node.DOCUMENT_TYPE_NODE:
@@ -65,7 +65,7 @@
 
         case Node.CDATA_SECTION_NODE:
             className = WI.DOMTreeElementPathComponent.DOMCharacterDataIconStyleClassName;
-            title = "<![CDATA[" + node.trimEnd(32) + "]]>";
+            title = "<![CDATA[" + node.truncateEnd(32) + "]]>";
             break;
 
         case Node.DOCUMENT_FRAGMENT_NODE:

Modified: releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Views/SearchResultTreeElement.js (228644 => 228645)


--- releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Views/SearchResultTreeElement.js	2018-02-19 11:02:34 UTC (rev 228644)
+++ releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Views/SearchResultTreeElement.js	2018-02-19 11:24:12 UTC (rev 228645)
@@ -59,8 +59,7 @@
         } else
             modifiedTitle = title;
 
-        // Truncate the tail of the title so the tooltip isn't so large.
-        modifiedTitle = modifiedTitle.trimEnd(searchTermIndex + searchTerm.length + charactersToShowAfterSearchMatch);
+        modifiedTitle = modifiedTitle.truncateEnd(searchTermIndex + searchTerm.length + charactersToShowAfterSearchMatch);
 
         console.assert(modifiedTitle.substring(searchTermIndex, searchTermIndex + searchTerm.length).toLowerCase() === searchTerm.toLowerCase());
 

Modified: releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js (228644 => 228645)


--- releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js	2018-02-19 11:02:34 UTC (rev 228644)
+++ releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js	2018-02-19 11:24:12 UTC (rev 228645)
@@ -336,7 +336,7 @@
             if (className) {
                 let span = document.createElement("span");
                 span.classList.add(className);
-                span.textContent = token.value.trimMiddle(maxValueLength);
+                span.textContent = token.value.truncateMiddle(maxValueLength);
                 return span;
             }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to