Changeset 46391 in webkit
- Timestamp:
- Jul 25, 2009 2:44:06 AM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r46390 r46391 1 2009-07-24 Joseph Pecoraro <joepeck02@gmail.com> 2 3 Reviewed by Oliver Hunt. 4 5 Inspector: Properties Should be Sorted more Naturally 6 https://bugs.webkit.org/show_bug.cgi?id=27329 7 8 * inspector/front-end/ObjectPropertiesSection.js: 9 (WebInspector.ObjectPropertiesSection.prototype.update): use the displaySort when showing properties 10 (WebInspector.ObjectPropertiesSection.prototype._displaySort): alphaNumerical sort 11 (WebInspector.ObjectPropertyTreeElement.prototype.onpopulate): use the displaySort when showing properties 12 * inspector/front-end/utilities.js: 13 (Object.sortedProperties): allow for an optional sorting function in Object.sortedProperties 14 1 15 2009-07-24 Pavel Feldman <pfeldman@chromium.org> 2 16 -
trunk/WebCore/inspector/front-end/ObjectPropertiesSection.js
r45889 r46391 1 1 /* 2 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 3 * Copyright (C) 2009 Joseph Pecoraro 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 59 60 for (var prop in this.extraProperties) 60 61 properties.push(prop); 61 properties.sort( );62 properties.sort(this._displaySort); 62 63 63 64 this.propertiesTreeOutline.removeChildren(); … … 80 81 this.propertiesTreeOutline.appendChild(infoElement); 81 82 } 83 }, 84 85 _displaySort: function(a,b) { 86 87 // if used elsewhere make sure to 88 // - convert a and b to strings (not needed here, properties are all strings) 89 // - check if a == b (not needed here, no two properties can be the same) 90 91 var diff = 0; 92 var chunk = /^\d+|^\D+/; 93 var chunka, chunkb, anum, bnum; 94 while (diff === 0) { 95 if (!a && b) 96 return -1; 97 if (!b && a) 98 return 1; 99 chunka = a.match(chunk)[0]; 100 chunkb = b.match(chunk)[0]; 101 anum = !isNaN(chunka); 102 bnum = !isNaN(chunkb); 103 if (anum && !bnum) 104 return -1; 105 if (bnum && !anum) 106 return 1; 107 if (anum && bnum) { 108 diff = chunka - chunkb; 109 if (diff === 0 && chunka.length !== chunkb.length) { 110 if (!+chunka && !+chunkb) // chunks are strings of all 0s (special case) 111 return chunka.length - chunkb.length; 112 else 113 return chunkb.length - chunka.length; 114 } 115 } else if (chunka !== chunkb) 116 return (chunka < chunkb) ? -1 : 1; 117 a = a.substring(chunka.length); 118 b = b.substring(chunkb.length); 119 } 120 return diff; 82 121 } 83 122 } … … 110 149 111 150 var childObject = this.safePropertyValue(this.parentObject, this.propertyName); 112 var properties = Object.sortedProperties(childObject );151 var properties = Object.sortedProperties(childObject, WebInspector.ObjectPropertiesSection.prototype._displaySort); 113 152 for (var i = 0; i < properties.length; ++i) { 114 153 var propertyName = properties[i]; -
trunk/WebCore/inspector/front-end/utilities.js
r46345 r46391 95 95 } 96 96 97 Object.sortedProperties = function(obj )97 Object.sortedProperties = function(obj, sortFunc) 98 98 { 99 99 var properties = []; 100 100 for (var prop in obj) 101 101 properties.push(prop); 102 properties.sort( );102 properties.sort(sortFunc); 103 103 return properties; 104 104 }
Note: See TracChangeset
for help on using the changeset viewer.