Changeset 136163 in webkit
- Timestamp:
- Nov 29, 2012, 2:16:19 PM (14 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
English.lproj/localizedStrings.js (modified) (1 diff)
-
inspector/front-end/NativeMemorySnapshotView.js (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r136152 r136163 1 2012-11-29 Alexei Filippov <alph@chromium.org> 2 3 Web Inspector: Allow sorting in NMI snapshot grid view 4 https://bugs.webkit.org/show_bug.cgi?id=102955 5 6 Reviewed by Yury Semikhatsky. 7 8 * English.lproj/localizedStrings.js: 9 * inspector/front-end/NativeMemorySnapshotView.js: 10 (WebInspector.NativeSnapshotDataGrid.prototype.sortingChanged): 11 (WebInspector.NativeSnapshotDataGrid.prototype._sortingFunction): 12 (WebInspector.NativeSnapshotNode): 13 (WebInspector.NativeSnapshotNode.prototype._storeState): 14 (WebInspector.NativeSnapshotNode.prototype._restoreState): 15 (WebInspector.NativeSnapshotNode.prototype.uid): 16 (WebInspector.NativeSnapshotNode.prototype._createSizeCell): 17 1 18 2012-11-29 Martin Robinson <mrobinson@igalia.com> 2 19 -
trunk/Source/WebCore/English.lproj/localizedStrings.js
r135487 r136163 232 232 localizedStrings["Install Timer"] = "Install Timer"; 233 233 localizedStrings["Invalid property value."] = "Invalid property value."; 234 localizedStrings["KB"] = "KB"; 234 235 localizedStrings["Key"] = "Key"; 235 236 localizedStrings["Shortcuts"] = "Shortcuts"; -
trunk/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js
r135608 r136163 56 56 { 57 57 var columns = { 58 object: { title: WebInspector.UIString("Object"), width: "200px", disclosure: true, sortable: false },59 size: { title: WebInspector.UIString("Size"), sortable: false},58 name: { title: WebInspector.UIString("Object"), width: "200px", disclosure: true, sortable: true }, 59 size: { title: WebInspector.UIString("Size"), sortable: true, sort: "descending" }, 60 60 }; 61 61 WebInspector.DataGrid.call(this, columns); 62 vartotalNode = new WebInspector.NativeSnapshotNode(profile, profile);62 this._totalNode = new WebInspector.NativeSnapshotNode(profile, profile); 63 63 if (WebInspector.settings.showNativeSnapshotUninstrumentedSize.get()) { 64 64 this.setRootNode(new WebInspector.DataGridNode(null, true)); 65 this.rootNode().appendChild(t otalNode)66 t otalNode.expand();65 this.rootNode().appendChild(this._totalNode) 66 this._totalNode.expand(); 67 67 } else { 68 this.setRootNode(t otalNode);69 t otalNode._populate();68 this.setRootNode(this._totalNode); 69 this._totalNode._populate(); 70 70 } 71 this.addEventListener("sorting changed", this.sortingChanged.bind(this), this); 71 72 } 72 73 73 74 WebInspector.NativeSnapshotDataGrid.prototype = { 75 sortingChanged: function() 76 { 77 var expandedNodes = {}; 78 this._totalNode._storeState(expandedNodes); 79 this._totalNode.removeChildren(); 80 this._totalNode._populate(); 81 this._totalNode._shouldRefreshChildren = true; 82 this._totalNode._restoreState(expandedNodes); 83 }, 84 85 /** 86 * @param {MemoryAgent.MemoryBlock} nodeA 87 * @param {MemoryAgent.MemoryBlock} nodeB 88 */ 89 _sortingFunction: function(nodeA, nodeB) 90 { 91 var sortColumnIdentifier = this.sortColumnIdentifier; 92 var sortAscending = this.sortOrder === "ascending"; 93 var field1 = nodeA[sortColumnIdentifier]; 94 var field2 = nodeB[sortColumnIdentifier]; 95 var result = field1 < field2 ? -1 : (field1 > field2 ? 1 : 0); 96 if (!sortAscending) 97 result = -result; 98 return result; 99 }, 100 74 101 __proto__: WebInspector.DataGrid.prototype 75 102 } … … 86 113 this._profile = profile; 87 114 var viewProperties = WebInspector.MemoryBlockViewProperties._forMemoryBlock(nodeData); 88 var data = { object: viewProperties._description, size: this._nodeData.size };115 var data = { name: viewProperties._description, size: this._nodeData.size }; 89 116 var hasChildren = !!nodeData.children && nodeData.children.length !== 0; 90 117 WebInspector.DataGridNode.call(this, data, hasChildren); … … 104 131 WebInspector.DataGridNode.prototype.createCell.call(this, columnIdentifier); 105 132 return cell; 133 }, 134 135 /** 136 * @param {Object} expandedNodes 137 */ 138 _storeState: function(expandedNodes) 139 { 140 if (!this.expanded) 141 return; 142 expandedNodes[this.uid()] = true; 143 for (var i in this.children) 144 this.children[i]._storeState(expandedNodes); 145 }, 146 147 /** 148 * @param {Object} expandedNodes 149 */ 150 _restoreState: function(expandedNodes) 151 { 152 if (!expandedNodes[this.uid()]) 153 return; 154 this.expand(); 155 for (var i in this.children) 156 this.children[i]._restoreState(expandedNodes); 157 }, 158 159 /** 160 * @return {string} 161 */ 162 uid: function() 163 { 164 if (!this._uid) 165 this._uid = (!this.parent || !this.parent.uid ? "" : this.parent.uid() || "") + "/" + this._nodeData.name; 166 return this._uid; 106 167 }, 107 168 … … 122 183 } 123 184 124 var sizeK iB = this._nodeData.size / 1024;185 var sizeKB = this._nodeData.size / 1024; 125 186 var totalSize = this._profile.size; 126 187 var percentage = this._nodeData.size / totalSize * 100; … … 130 191 131 192 var textDiv = document.createElement("div"); 132 textDiv.textContent = Number.withThousandsSeparator(sizeK iB.toFixed(0)) + "\u2009" + WebInspector.UIString("KiB");193 textDiv.textContent = Number.withThousandsSeparator(sizeKB.toFixed(0)) + "\u2009" + WebInspector.UIString("KB"); 133 194 textDiv.className = "size-text"; 134 195 cell.appendChild(textDiv); … … 158 219 _populate: function() { 159 220 this.removeEventListener("populate", this._populate, this); 160 function comparator(a, b) { 161 return b.size - a.size; 162 } 163 if (this._nodeData !== this._profile) 164 this._nodeData.children.sort(comparator); 221 this._nodeData.children.sort(this.dataGrid._sortingFunction.bind(this.dataGrid)); 165 222 for (var node in this._nodeData.children) { 166 223 var nodeData = this._nodeData.children[node];
Note:
See TracChangeset
for help on using the changeset viewer.