Changeset 209115 in webkit
- Timestamp:
- Nov 29, 2016 8:22:21 PM (7 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r209089 r209115 1 2016-11-29 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: Improve name sorting in HeapSnapshot data grids 4 https://bugs.webkit.org/show_bug.cgi?id=165170 5 <rdar://problem/28784421> 6 7 Reviewed by Matt Baker. 8 9 When sorting the Name column, group named properties and unnamed 10 properties and sort them each individually: 11 12 - Sort named properties by their property name (property names will be unique if they exist) 13 - Sort unnamed properties by their class name (guaranteed) 14 - Sort any tied class names by their object id 15 16 This makes using the Object Graph with Name sort easier to follow. 17 In the ascending sort you see all the named properties first, 18 followed by the unnamed (internal) properties. 19 20 * UserInterface/Views/HeapSnapshotContentView.js: 21 (WebInspector.HeapSnapshotObjectGraphContentView): 22 Since this data grid column now sorts on more than just the "Class Name" 23 rename it to "Name". 24 25 * UserInterface/Views/HeapSnapshotDataGridTree.js: 26 (WebInspector.HeapSnapshotDataGridTree.buildSortComparator): 27 Make the sort of the `className` column more general to handle sorting 28 by property names, class names, and object identifiers. 29 30 * UserInterface/Views/HeapSnapshotInstanceDataGridNode.js: 31 (WebInspector.HeapSnapshotInstanceDataGridNode.prototype.get propertyName): 32 (WebInspector.HeapSnapshotInstanceDataGridNode.prototype.createCellContent): 33 Provide a lazy `propertyName` accessor where we compute it once and stash 34 it on the DataGridNode to avoid extra work when resorting. 35 36 (WebInspector.HeapSnapshotInstanceDataGridNode.prototype._populate.propertyName): 37 (WebInspector.HeapSnapshotInstanceDataGridNode.prototype._populate): 38 In the initial populated sort, provide the necessary property name property 39 the sort comparator expects. 40 1 41 2016-11-29 Matt Baker <mattbaker@apple.com> 2 42 -
trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
r209062 r209115 141 141 localizedStrings["Child Layers"] = "Child Layers"; 142 142 localizedStrings["Children"] = "Children"; 143 localizedStrings["Class Name"] = "Class Name";144 143 localizedStrings["Classes"] = "Classes"; 145 144 localizedStrings["Clear"] = "Clear"; -
trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotContentView.js
r205425 r209115 119 119 }, 120 120 className: { 121 title: WebInspector.UIString(" ClassName"),121 title: WebInspector.UIString("Name"), 122 122 sortable: true, 123 123 disclosure: true, … … 148 148 }, 149 149 className: { 150 title: WebInspector.UIString(" ClassName"),150 title: WebInspector.UIString("Name"), 151 151 sortable: true, 152 152 disclosure: true, -
trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotDataGridTree.js
r205425 r209115 52 52 let multiplier = sortOrder === WebInspector.DataGrid.SortOrder.Ascending ? 1 : -1; 53 53 let numberCompare = (columnIdentifier, a, b) => multiplier * (a.data[columnIdentifier] - b.data[columnIdentifier]); 54 let localeCompare = (columnIdentifier, a, b) => multiplier * (a.data[columnIdentifier].localeCompare(b.data[columnIdentifier])); 54 let nameCompare = (a, b) => { 55 // Sort by property name if available. Property names before no property name. 56 if (a.propertyName || b.propertyName) { 57 if (a.propertyName && !b.propertyName) 58 return multiplier * -1; 59 if (!a.propertyName && b.propertyName) 60 return multiplier * 1; 61 let propertyNameCompare = a.propertyName.localeCompare(b.propertyName); 62 console.assert(propertyNameCompare !== 0, "Property names should be unique, we shouldn't have equal property names."); 63 return multiplier * propertyNameCompare; 64 } 65 66 // Sort by class name and object id if no property name. 67 let classNameCompare = a.data.className.localeCompare(b.data.className); 68 if (classNameCompare) 69 return multiplier * classNameCompare; 70 if (a.data.id || b.data.id) 71 return multiplier * (a.data.id - b.data.id); 72 return 0; 73 }; 55 74 56 75 switch (columnIdentifier) { … … 62 81 return numberCompare.bind(this, "count"); 63 82 case "className": 64 return localeCompare.bind(this, "className");83 return nameCompare; 65 84 } 66 85 } -
trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstanceDataGridNode.js
r208304 r209115 98 98 get selectable() { return false; } 99 99 100 get propertyName() 101 { 102 if (!this._edge) 103 return ""; 104 105 if (!this._propertyName) 106 this._propertyName = WebInspector.HeapSnapshotRootPath.pathComponentForIndividualEdge(this._edge); 107 return this._propertyName; 108 } 109 100 110 createCells() 101 111 { … … 147 157 if (this._edge) { 148 158 let nameElement = containerElement.appendChild(document.createElement("span")); 149 let edgeText = WebInspector.HeapSnapshotRootPath.pathComponentForIndividualEdge(this._edge);150 if ( edgeText)151 nameElement.textContent = edgeText+ ": " + this._node.className + " ";159 let propertyName = this.propertyName; 160 if (propertyName) 161 nameElement.textContent = propertyName + ": " + this._node.className + " "; 152 162 else 153 163 nameElement.textContent = this._node.className + " "; … … 209 219 this.removeEventListener("populate", this._populate, this); 210 220 221 function propertyName(edge) { 222 return edge ? WebInspector.HeapSnapshotRootPath.pathComponentForIndividualEdge(edge) : ""; 223 } 224 211 225 this._node.retainedNodes((instances, edges) => { 212 226 // Reference edge from instance so we can get it after sorting. … … 215 229 216 230 instances.sort((a, b) => { 217 let fakeDataGridNodeA = {data: a };218 let fakeDataGridNodeB = {data: b };231 let fakeDataGridNodeA = {data: a, propertyName: propertyName(a.__edge)}; 232 let fakeDataGridNodeB = {data: b, propertyName: propertyName(b.__edge)}; 219 233 return this._tree._sortComparator(fakeDataGridNodeA, fakeDataGridNodeB); 220 234 });
Note: See TracChangeset
for help on using the changeset viewer.