Web Inspector: Storage: values truncated in Local/Session table
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Apr 2019 19:02:23 +0000 (19:02 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Apr 2019 19:02:23 +0000 (19:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=178318
<rdar://problem/34998581>

Reviewed by Joseph Pecoraro.

* UserInterface/Views/DataGrid.js:
(WI.DataGrid):
(WI.DataGrid.prototype._copyTextForDataGridNode):
* UserInterface/Views/TimelineDataGrid.js:
(WI.TimelineDataGrid):
Refactor `WI.DataGrid` constructor to allow for more optional arguments.
Introduce a new optional argument `copyCallback` that can be used to override the text that
would be copied for any `WI.DataGridNode` in any column.

* UserInterface/Views/DOMStorageContentView.js:
(WI.DOMStorageContentView):
(WI.DOMStorageContentView.prototype.itemAdded):
(WI.DOMStorageContentView.prototype.itemUpdated):
(WI.DOMStorageContentView.prototype._populate):
(WI.DOMStorageContentView.prototype._dataGridCopy): Added.
Save the full non-truncated value as part of the `WI.DataGridNode`'s `data`. When copying,
use the full non-truncated value instead of what was shown in the DOM.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244350 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/DOMStorageContentView.js
Source/WebInspectorUI/UserInterface/Views/DataGrid.js
Source/WebInspectorUI/UserInterface/Views/TimelineDataGrid.js

index cc53ab1..ad40971 100644 (file)
@@ -1,3 +1,29 @@
+2019-04-16  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Storage: values truncated in Local/Session table
+        https://bugs.webkit.org/show_bug.cgi?id=178318
+        <rdar://problem/34998581>
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Views/DataGrid.js:
+        (WI.DataGrid):
+        (WI.DataGrid.prototype._copyTextForDataGridNode):
+        * UserInterface/Views/TimelineDataGrid.js:
+        (WI.TimelineDataGrid):
+        Refactor `WI.DataGrid` constructor to allow for more optional arguments.
+        Introduce a new optional argument `copyCallback` that can be used to override the text that
+        would be copied for any `WI.DataGridNode` in any column.
+
+        * UserInterface/Views/DOMStorageContentView.js:
+        (WI.DOMStorageContentView):
+        (WI.DOMStorageContentView.prototype.itemAdded):
+        (WI.DOMStorageContentView.prototype.itemUpdated):
+        (WI.DOMStorageContentView.prototype._populate):
+        (WI.DOMStorageContentView.prototype._dataGridCopy): Added.
+        Save the full non-truncated value as part of the `WI.DataGridNode`'s `data`. When copying,
+        use the full non-truncated value instead of what was shown in the DOM.
+
 2019-04-15  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: DOM Nodes should not show $0 when selected in Console area
index 7d951ba..2cd7e04 100644 (file)
@@ -41,7 +41,11 @@ WI.DOMStorageContentView = class DOMStorageContentView extends WI.ContentView
         columns.key = {title: WI.UIString("Key"), sortable: true};
         columns.value = {title: WI.UIString("Value"), sortable: true};
 
-        this._dataGrid = new WI.DataGrid(columns, this._editingCallback.bind(this), this._deleteCallback.bind(this));
+        this._dataGrid = new WI.DataGrid(columns, {
+            editingCallback: this._editingCallback.bind(this),
+            copyCallback: this._dataGridCopy.bind(this),
+            deleteCallback: this._deleteCallback.bind(this),
+        });
         this._dataGrid.sortOrder = WI.DataGrid.SortOrder.Ascending;
         this._dataGrid.sortColumnIdentifier = "key";
         this._dataGrid.createSettings("dom-storage-content-view");
@@ -85,6 +89,7 @@ WI.DOMStorageContentView = class DOMStorageContentView extends WI.ContentView
     itemAdded(event)
     {
         let {key, value} = event.data;
+        let originalValue = value;
         value = this._truncateValue(value);
 
         // Enforce key uniqueness.
@@ -93,13 +98,14 @@ WI.DOMStorageContentView = class DOMStorageContentView extends WI.ContentView
                 return;
         }
 
-        this._dataGrid.appendChild(new WI.DataGridNode({key, value}, false));
+        this._dataGrid.appendChild(new WI.DataGridNode({key, value, originalValue}, false));
         this._sortDataGrid();
     }
 
     itemUpdated(event)
     {
         let {key, value} = event.data;
+        let originalValue = value;
         value = this._truncateValue(value);
 
         let keyFound = false;
@@ -113,6 +119,7 @@ WI.DOMStorageContentView = class DOMStorageContentView extends WI.ContentView
 
                 keyFound = true;
                 childNode.data.value = value;
+                childNode.data.originalValue = originalValue;
                 childNode.refresh();
             }
         }
@@ -136,8 +143,9 @@ WI.DOMStorageContentView = class DOMStorageContentView extends WI.ContentView
                 if (!key || !value)
                     continue;
 
+                let originalValue = value;
                 value = this._truncateValue(value);
-                let node = new WI.DataGridNode({key, value}, false);
+                let node = new WI.DataGridNode({key, value, originalValue}, false);
                 this._dataGrid.appendChild(node);
             }
 
@@ -253,6 +261,13 @@ WI.DOMStorageContentView = class DOMStorageContentView extends WI.ContentView
         cleanup();
         domStorage.setItem(key, value);
     }
+
+    _dataGridCopy(node, columnIdentifier, text)
+    {
+        if (columnIdentifier === "value" && node.data.originalValue)
+            return node.data.originalValue;
+        return text;
+    }
 };
 
 WI.DOMStorageContentView.DuplicateKeyStyleClassName = "duplicate-key";
index a5ba539..18c504c 100644 (file)
@@ -25,7 +25,7 @@
 
 WI.DataGrid = class DataGrid extends WI.View
 {
-    constructor(columnsData, editCallback, deleteCallback, preferredColumnOrder)
+    constructor(columnsData, {editCallback, copyCallback, deleteCallback, preferredColumnOrder} = {})
     {
         super();
 
@@ -109,6 +109,9 @@ WI.DataGrid = class DataGrid extends WI.View
             this._editCallback = editCallback;
         }
 
+        if (copyCallback)
+            this._copyCallback = copyCallback;
+
         if (deleteCallback)
             this._deleteCallback = deleteCallback;
 
@@ -168,7 +171,7 @@ WI.DataGrid = class DataGrid extends WI.View
             };
         }
 
-        var dataGrid = new WI.DataGrid(columnsData, undefined, undefined, columnNames);
+        let dataGrid = new WI.DataGrid(columnsData, {preferredColumnOrder: columnNames});
         for (var i = 0; i < values.length / numColumns; ++i) {
             var data = {};
             for (var j = 0; j < columnNames.length; ++j)
@@ -1697,7 +1700,12 @@ WI.DataGrid = class DataGrid extends WI.View
 
     _copyTextForDataGridNode(node)
     {
-        let fields = node.dataGrid.orderedColumns.map((identifier) => this.textForDataGridNodeColumn(node, identifier));
+        let fields = node.dataGrid.orderedColumns.map((identifier) => {
+            let text = this.textForDataGridNodeColumn(node, identifier);
+            if (this._copyCallback)
+                text = this._copyCallback(node, identifier, text);
+            return text;
+        });
         return fields.join(this._copyTextDelimiter);
     }
 
index bd93000..f4cba4f 100644 (file)
@@ -25,9 +25,9 @@
 
 WI.TimelineDataGrid = class TimelineDataGrid extends WI.DataGrid
 {
-    constructor(columns, editCallback, deleteCallback)
+    constructor(columns)
     {
-        super(columns, editCallback, deleteCallback);
+        super(columns);
 
         this.element.classList.add("timeline");