Changeset 228645 in webkit


Ignore:
Timestamp:
Feb 19, 2018 3:24:12 AM (6 years ago)
Author:
Carlos Garcia Campos
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:
Location:
releases/WebKitGTK/webkit-2.20
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.20/LayoutTests/ChangeLog

    r228644 r228645  
     12018-02-06  Nikita Vasilyev  <nvasilyev@apple.com>
     2
     3        Web Inspector: Rename String.prototype.trimEnd to avoid conflicts with native trimEnd
     4        https://bugs.webkit.org/show_bug.cgi?id=182545
     5
     6        Reviewed by Brian Burg.
     7
     8        * inspector/unit-tests/string-utilities-expected.txt:
     9        * inspector/unit-tests/string-utilities.html:
     10
    1112018-02-06  Said Abou-Hallawa  <sabouhallawa@apple.com>
    212
  • releases/WebKitGTK/webkit-2.20/LayoutTests/inspector/unit-tests/string-utilities-expected.txt

    r222137 r228645  
    4747PASS: Last line of an empty string is the same empty string.
    4848
     49-- Running test case: String.prototype.truncateMiddle
     50PASS: String stays the same.
     51PASS: Ellipsis is inserted in the middle.
     52PASS: Ellipsis is inserted after the second character.
     53
     54-- Running test case: String.prototype.truncateEnd
     55PASS: String stays the same.
     56PASS: Ellipsis is inserted in the middle.
     57PASS: Ellipsis is inserted after the third character.
     58
  • releases/WebKitGTK/webkit-2.20/LayoutTests/inspector/unit-tests/string-utilities.html

    r222137 r228645  
    22<html>
    33<head>
     4<meta charset="utf-8">
    45<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
    56<script>
     
    7980    });
    8081
     82    suite.addTestCase({
     83        name: "String.prototype.truncateMiddle",
     84        test() {
     85            const ellipsis = "\u2026";
     86            InspectorTest.expectEqual("abcdef".truncateMiddle(6), "abcdef", "String stays the same.");
     87            InspectorTest.expectEqual("abcdef".truncateMiddle(5), `ab${ellipsis}ef`, "Ellipsis is inserted in the middle.");
     88            InspectorTest.expectEqual("abcdef".truncateMiddle(4), `ab${ellipsis}f`, "Ellipsis is inserted after the second character.");
     89            return true;
     90        }
     91    });
     92
     93    suite.addTestCase({
     94        name: "String.prototype.truncateEnd",
     95        test() {
     96            const ellipsis = "\u2026";
     97            InspectorTest.expectEqual("abcdef".truncateEnd(6), "abcdef", "String stays the same.");
     98            InspectorTest.expectEqual("abcdef".truncateEnd(5), "abcd" + ellipsis, "Ellipsis is inserted in the middle.");
     99            InspectorTest.expectEqual("abcdef".truncateEnd(4), "abc" + ellipsis, "Ellipsis is inserted after the third character.");
     100            return true;
     101        }
     102    });
     103
    81104    suite.runTestCasesAndFinish();
    82105}
  • releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/ChangeLog

    r228030 r228645  
     12018-02-06  Nikita Vasilyev  <nvasilyev@apple.com>
     2
     3        Web Inspector: Rename String.prototype.trimEnd to avoid conflicts with native trimEnd
     4        https://bugs.webkit.org/show_bug.cgi?id=182545
     5
     6        Reviewed by Brian Burg.
     7
     8        Rename:
     9        - trimEnd to truncateEnd
     10        - trimMiddle to truncateMiddle
     11
     12        * UserInterface/Base/Utilities.js:
     13        (String.prototype.trimMiddle): Deleted.
     14        (String.prototype.trimEnd): Deleted.
     15        (String.prototype.truncateMiddle): Added.
     16        (String.prototype.truncateEnd): Added.
     17        Use strict mode. Scrict mode allows `this` to be a primitive (a string, in our case).
     18        In non-strict mode, `this` is always an object. Without the strict mode,
     19        "a".truncateEnd(42) !== "a", because truncateEnd returns a string object.
     20
     21        * UserInterface/Views/DOMTreeElement.js:
     22        (WI.DOMTreeElement.prototype._buildAttributeDOM):
     23        * UserInterface/Views/DOMTreeElementPathComponent.js:
     24        (WI.DOMTreeElementPathComponent):
     25        * UserInterface/Views/SearchResultTreeElement.js:
     26        Remove an obvious comment.
     27
     28        (WI.SearchResultTreeElement.truncateAndHighlightTitle):
     29        * UserInterface/Views/SpreadsheetStyleProperty.js:
     30        (WI.SpreadsheetStyleProperty.prototype._renderValue):
     31
    1322018-02-02  Devin Rousso  <webkit@devinrousso.com>
    233
  • releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Base/Utilities.js

    r227864 r228645  
    580580});
    581581
    582 Object.defineProperty(String.prototype, "trimMiddle",
     582Object.defineProperty(String.prototype, "truncateMiddle",
    583583{
    584584    value(maxLength)
    585585    {
     586        "use strict";
     587
    586588        if (this.length <= maxLength)
    587589            return this;
     
    592594});
    593595
    594 Object.defineProperty(String.prototype, "trimEnd",
     596Object.defineProperty(String.prototype, "truncateEnd",
    595597{
    596598    value(maxLength)
    597599    {
     600        "use strict";
     601
    598602        if (this.length <= maxLength)
    599603            return this;
  • releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js

    r227864 r228645  
    12721272            } else {
    12731273                if (value.startsWith("data:"))
    1274                     value = value.trimMiddle(60);
     1274                    value = value.truncateMiddle(60);
    12751275
    12761276                attrValueElement = document.createElement("a");
  • releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Views/DOMTreeElementPathComponent.js

    r220119 r228645  
    4646        case Node.TEXT_NODE:
    4747            className = WI.DOMTreeElementPathComponent.DOMTextNodeIconStyleClassName;
    48             title = "\"" + node.nodeValue().trimEnd(32) + "\"";
     48            title = "\"" + node.nodeValue().truncateEnd(32) + "\"";
    4949            break;
    5050
    5151        case Node.COMMENT_NODE:
    5252            className = WI.DOMTreeElementPathComponent.DOMCommentIconStyleClassName;
    53             title = "<!--" + node.nodeValue().trimEnd(32) + "-->";
     53            title = "<!--" + node.nodeValue().truncateEnd(32) + "-->";
    5454            break;
    5555
     
    6666        case Node.CDATA_SECTION_NODE:
    6767            className = WI.DOMTreeElementPathComponent.DOMCharacterDataIconStyleClassName;
    68             title = "<![CDATA[" + node.trimEnd(32) + "]]>";
     68            title = "<![CDATA[" + node.truncateEnd(32) + "]]>";
    6969            break;
    7070
  • releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Views/SearchResultTreeElement.js

    r224499 r228645  
    6060            modifiedTitle = title;
    6161
    62         // Truncate the tail of the title so the tooltip isn't so large.
    63         modifiedTitle = modifiedTitle.trimEnd(searchTermIndex + searchTerm.length + charactersToShowAfterSearchMatch);
     62        modifiedTitle = modifiedTitle.truncateEnd(searchTermIndex + searchTerm.length + charactersToShowAfterSearchMatch);
    6463
    6564        console.assert(modifiedTitle.substring(searchTermIndex, searchTermIndex + searchTerm.length).toLowerCase() === searchTerm.toLowerCase());
  • releases/WebKitGTK/webkit-2.20/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js

    r228030 r228645  
    337337                let span = document.createElement("span");
    338338                span.classList.add(className);
    339                 span.textContent = token.value.trimMiddle(maxValueLength);
     339                span.textContent = token.value.truncateMiddle(maxValueLength);
    340340                return span;
    341341            }
Note: See TracChangeset for help on using the changeset viewer.