diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-07-31 11:52:57 +1000 |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-07-31 11:52:57 +1000 |
commit | aa9cf406d62004519ad54596e1c391f9a6439210 (patch) | |
tree | dd562b9c296981f2761b76623911be8496c7af84 /src/3rdparty/webkit/WebCore/inspector/front-end/ObjectPropertiesSection.js | |
parent | 987aec28b950e1c9817a20a9dd71afc071cd93ea (diff) | |
parent | 56b6a5924008ab5cdbae36e9662eddba923acd5e (diff) |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Diffstat (limited to 'src/3rdparty/webkit/WebCore/inspector/front-end/ObjectPropertiesSection.js')
-rw-r--r-- | src/3rdparty/webkit/WebCore/inspector/front-end/ObjectPropertiesSection.js | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ObjectPropertiesSection.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ObjectPropertiesSection.js index 59e73747a..d8c34d7fb 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ObjectPropertiesSection.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ObjectPropertiesSection.js @@ -1,5 +1,6 @@ /* * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * Copyright (C) 2009 Joseph Pecoraro * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -58,7 +59,7 @@ WebInspector.ObjectPropertiesSection.prototype = { if (this.extraProperties) for (var prop in this.extraProperties) properties.push(prop); - properties.sort(); + properties.sort(this._displaySort); this.propertiesTreeOutline.removeChildren(); @@ -79,6 +80,44 @@ WebInspector.ObjectPropertiesSection.prototype = { var infoElement = new TreeElement(title, null, false); this.propertiesTreeOutline.appendChild(infoElement); } + }, + + _displaySort: function(a,b) { + + // if used elsewhere make sure to + // - convert a and b to strings (not needed here, properties are all strings) + // - check if a == b (not needed here, no two properties can be the same) + + var diff = 0; + var chunk = /^\d+|^\D+/; + var chunka, chunkb, anum, bnum; + while (diff === 0) { + if (!a && b) + return -1; + if (!b && a) + return 1; + chunka = a.match(chunk)[0]; + chunkb = b.match(chunk)[0]; + anum = !isNaN(chunka); + bnum = !isNaN(chunkb); + if (anum && !bnum) + return -1; + if (bnum && !anum) + return 1; + if (anum && bnum) { + diff = chunka - chunkb; + if (diff === 0 && chunka.length !== chunkb.length) { + if (!+chunka && !+chunkb) // chunks are strings of all 0s (special case) + return chunka.length - chunkb.length; + else + return chunkb.length - chunka.length; + } + } else if (chunka !== chunkb) + return (chunka < chunkb) ? -1 : 1; + a = a.substring(chunka.length); + b = b.substring(chunkb.length); + } + return diff; } } @@ -109,7 +148,7 @@ WebInspector.ObjectPropertyTreeElement.prototype = { this.removeChildren(); var childObject = this.safePropertyValue(this.parentObject, this.propertyName); - var properties = Object.sortedProperties(childObject); + var properties = Object.sortedProperties(childObject, WebInspector.ObjectPropertiesSection.prototype._displaySort); for (var i = 0; i < properties.length; ++i) { var propertyName = properties[i]; if (propertyName === "__treeElementIdentifier") @@ -156,7 +195,7 @@ WebInspector.ObjectPropertyTreeElement.prototype = { var hasSubProperties = false; var type = typeof childObject; if (childObject && (type === "object" || type === "function")) { - for (subPropertyName in childObject) { + for (var subPropertyName in childObject) { if (subPropertyName === "__treeElementIdentifier") continue; hasSubProperties = true; |