Web Inspector: Replace Object.shallowMerge with ES2018 spread operator
https://bugs.webkit.org/show_bug.cgi?id=182219

Reviewed by Brian Burg.

* UserInterface/Base/Utilities.js:
(Object.shallowMerge): Deleted.
* UserInterface/Base/DOMUtilities.js:
(WI.linkifyNodeReference):
* UserInterface/Base/Main.js:
(WI.handlePossibleLinkClick):
(WI.openURL):
(WI.showSourceCodeLocation):
(WI.showOriginalUnformattedSourceCodeLocation):
(WI.showOriginalOrFormattedSourceCodeLocation):
(WI.showOriginalOrFormattedSourceCodeTextRange):
(WI.linkifyLocation):
* UserInterface/Views/DOMTreeElement.js:
(WI.DOMTreeElement.prototype._insertAdjacentHTML):
* UserInterface/Views/WebSocketContentView.js:
(WI.WebSocketContentView.prototype._addRow):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@227864 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog
index 6bec596..db3fefd 100644
--- a/Source/WebInspectorUI/ChangeLog
+++ b/Source/WebInspectorUI/ChangeLog
@@ -1,3 +1,27 @@
+2018-01-30  Devin Rousso  <webkit@devinrousso.com>
+
+        Web Inspector: Replace Object.shallowMerge with ES2018 spread operator
+        https://bugs.webkit.org/show_bug.cgi?id=182219
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Base/Utilities.js:
+        (Object.shallowMerge): Deleted.
+        * UserInterface/Base/DOMUtilities.js:
+        (WI.linkifyNodeReference):
+        * UserInterface/Base/Main.js:
+        (WI.handlePossibleLinkClick):
+        (WI.openURL):
+        (WI.showSourceCodeLocation):
+        (WI.showOriginalUnformattedSourceCodeLocation):
+        (WI.showOriginalOrFormattedSourceCodeLocation):
+        (WI.showOriginalOrFormattedSourceCodeTextRange):
+        (WI.linkifyLocation):
+        * UserInterface/Views/DOMTreeElement.js:
+        (WI.DOMTreeElement.prototype._insertAdjacentHTML):
+        * UserInterface/Views/WebSocketContentView.js:
+        (WI.WebSocketContentView.prototype._addRow):
+
 2018-01-26  Matt Baker  <mattbaker@apple.com>
 
         Web Inspector: Timelines content browser NavigationBar is squashed at narrow heights
diff --git a/Source/WebInspectorUI/UserInterface/Base/DOMUtilities.js b/Source/WebInspectorUI/UserInterface/Base/DOMUtilities.js
index 9f32906..5bb521d 100644
--- a/Source/WebInspectorUI/UserInterface/Base/DOMUtilities.js
+++ b/Source/WebInspectorUI/UserInterface/Base/DOMUtilities.js
@@ -65,7 +65,7 @@
 
     let link = document.createElement("span");
     link.append(displayName);
-    return WI.linkifyNodeReferenceElement(node, link, Object.shallowMerge(options, {displayName}));
+    return WI.linkifyNodeReferenceElement(node, link, {...options, displayName});
 };
 
 WI.linkifyNodeReferenceElement = function(node, element, options = {})
diff --git a/Source/WebInspectorUI/UserInterface/Base/Main.js b/Source/WebInspectorUI/UserInterface/Base/Main.js
index 6df1c07..28371f6 100644
--- a/Source/WebInspectorUI/UserInterface/Base/Main.js
+++ b/Source/WebInspectorUI/UserInterface/Base/Main.js
@@ -773,10 +773,11 @@
     event.preventDefault();
     event.stopPropagation();
 
-    this.openURL(anchorElement.href, frame, Object.shallowMerge(options, {
+    this.openURL(anchorElement.href, frame, {
+        ...options,
         lineNumber: anchorElement.lineNumber,
         ignoreSearchTab: !WI.isShowingSearchTab(),
-    }));
+    });
 
     return true;
 };
@@ -814,7 +815,7 @@
 
     if (resource) {
         let positionToReveal = new WI.SourceCodePosition(options.lineNumber, 0);
-        this.showSourceCode(resource, Object.shallowMerge(options, {positionToReveal}));
+        this.showSourceCode(resource, {...options, positionToReveal});
         return;
     }
 
@@ -1155,33 +1156,37 @@
 
 WI.showSourceCodeLocation = function(sourceCodeLocation, options = {})
 {
-    this.showSourceCode(sourceCodeLocation.displaySourceCode, Object.shallowMerge(options, {
+    this.showSourceCode(sourceCodeLocation.displaySourceCode, {
+        ...options,
         positionToReveal: sourceCodeLocation.displayPosition(),
-    }));
+    });
 };
 
 WI.showOriginalUnformattedSourceCodeLocation = function(sourceCodeLocation, options = {})
 {
-    this.showSourceCode(sourceCodeLocation.sourceCode, Object.shallowMerge(options, {
+    this.showSourceCode(sourceCodeLocation.sourceCode, {
+        ...options,
         positionToReveal: sourceCodeLocation.position(),
         forceUnformatted: true,
-    }));
+    });
 };
 
 WI.showOriginalOrFormattedSourceCodeLocation = function(sourceCodeLocation, options = {})
 {
-    this.showSourceCode(sourceCodeLocation.sourceCode, Object.shallowMerge(options, {
+    this.showSourceCode(sourceCodeLocation.sourceCode, {
+        ...options,
         positionToReveal: sourceCodeLocation.formattedPosition(),
-    }));
+    });
 };
 
 WI.showOriginalOrFormattedSourceCodeTextRange = function(sourceCodeTextRange, options = {})
 {
     var textRangeToSelect = sourceCodeTextRange.formattedTextRange;
-    this.showSourceCode(sourceCodeTextRange.sourceCode, Object.shallowMerge(options, {
+    this.showSourceCode(sourceCodeTextRange.sourceCode, {
+        ...options,
         positionToReveal: textRangeToSelect.startPosition(),
         textRangeToSelect,
-    }));
+    });
 };
 
 WI.showResourceRequest = function(resource, options = {})
@@ -2313,9 +2318,14 @@
     }
 
     let sourceCodeLocation = sourceCode.createSourceCodeLocation(sourceCodePosition.lineNumber, sourceCodePosition.columnNumber);
-    let linkElement = WI.createSourceCodeLocationLink(sourceCodeLocation, Object.shallowMerge(options, {dontFloat: true}));
+    let linkElement = WI.createSourceCodeLocationLink(sourceCodeLocation, {
+        ...options,
+        dontFloat: true,
+    });
+
     if (options.className)
         linkElement.classList.add(options.className);
+
     return linkElement;
 };
 
diff --git a/Source/WebInspectorUI/UserInterface/Base/Utilities.js b/Source/WebInspectorUI/UserInterface/Base/Utilities.js
index d17402f..691dd8e 100644
--- a/Source/WebInspectorUI/UserInterface/Base/Utilities.js
+++ b/Source/WebInspectorUI/UserInterface/Base/Utilities.js
@@ -87,20 +87,6 @@
     }
 });
 
-Object.defineProperty(Object, "shallowMerge",
-{
-    value(a, b)
-    {
-        let result = Object.shallowCopy(a);
-        let keys = Object.keys(b);
-        for (let i = 0; i < keys.length; ++i) {
-            console.assert(!result.hasOwnProperty(keys[i]) || result[keys[i]] === b[keys[i]], keys[i]);
-            result[keys[i]] = b[keys[i]];
-        }
-        return result;
-    }
-});
-
 Object.defineProperty(Object.prototype, "valueForCaseInsensitiveKey",
 {
     value(key)
diff --git a/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js b/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js
index 2e1fb3a..b910ff3 100644
--- a/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js
+++ b/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js
@@ -1601,7 +1601,7 @@
             this.expand();
         }
 
-        this._startEditingAsHTML(commitCallback, Object.shallowMerge(options, {position}));
+        this._startEditingAsHTML(commitCallback, {...options, position});
     }
 
     _addHTML(event)
diff --git a/Source/WebInspectorUI/UserInterface/Views/WebSocketContentView.js b/Source/WebInspectorUI/UserInterface/Views/WebSocketContentView.js
index 0a8ea64..9dec168 100644
--- a/Source/WebInspectorUI/UserInterface/Views/WebSocketContentView.js
+++ b/Source/WebInspectorUI/UserInterface/Views/WebSocketContentView.js
@@ -139,9 +139,9 @@
     {
         let node;
         if (this._showTimeColumn)
-            node = new WI.WebSocketDataGridNode(Object.shallowMerge({data, time}, attributes));
+            node = new WI.WebSocketDataGridNode({...attributes, data, time});
         else
-            node = new WI.WebSocketDataGridNode(Object.shallowMerge({data}, attributes));
+            node = new WI.WebSocketDataGridNode({...attributes, data});
 
         this._dataGrid.appendChild(node);