incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmue...@apache.org
Subject [15/51] [partial] Apache-ization, port to node.js
Date Wed, 15 Feb 2012 17:42:37 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/HeapSnapshot.js
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/HeapSnapshot.js b/weinre.build/vendor/webkit/WebCore/inspector/front-end/HeapSnapshot.js
new file mode 100644
index 0000000..ef450af
--- /dev/null
+++ b/weinre.build/vendor/webkit/WebCore/inspector/front-end/HeapSnapshot.js
@@ -0,0 +1,909 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.HeapSnapshotArraySlice = function(snapshot, arrayName, start, end)
+{
+    // Note: we don't reference snapshot contents directly to avoid
+    // holding references to big chunks of data.
+    this._snapshot = snapshot;
+    this._arrayName = arrayName;
+    this._start = start;
+    this.length = end - start;
+}
+
+WebInspector.HeapSnapshotArraySlice.prototype = {
+    item: function(index)
+    {
+        return this._snapshot[this._arrayName][this._start + index];
+    }
+}
+
+WebInspector.HeapSnapshotEdge = function(snapshot, edges, edgeIndex)
+{
+    this._snapshot = snapshot;
+    this._edges = edges;
+    this.edgeIndex = edgeIndex || 0;
+}
+
+WebInspector.HeapSnapshotEdge.prototype = {
+    clone: function()
+    {
+        return new WebInspector.HeapSnapshotEdge(this._snapshot, this._edges, this.edgeIndex);
+    },
+
+    get hasStringName()
+    {
+        if (!this.isShortcut)
+            return this._hasStringName;
+        return isNaN(parseInt(this._name, 10));
+    },
+
+    get isElement()
+    {
+        return this._type() === this._snapshot._edgeElementType;
+    },
+
+    get isHidden()
+    {
+        return this._type() === this._snapshot._edgeHiddenType;
+    },
+
+    get isInternal()
+    {
+        return this._type() === this._snapshot._edgeInternalType;
+    },
+
+    get isShortcut()
+    {
+        return this._type() === this._snapshot._edgeShortcutType;
+    },
+
+    get name()
+    {
+        if (!this.isShortcut)
+            return this._name;
+        var numName = parseInt(this._name, 10);
+        return isNaN(numName) ? this._name : numName;
+    },
+
+    get node()
+    {
+        return new WebInspector.HeapSnapshotNode(this._snapshot, this.nodeIndex);
+    },
+
+    get nodeIndex()
+    {
+        return this._edges.item(this.edgeIndex + this._snapshot._edgeToNodeOffset);
+    },
+
+    get rawEdges()
+    {
+        return this._edges;
+    },
+
+    toString: function()
+    {
+        switch (this.type) {
+        case "context": return "->" + this.name;
+        case "element": return "[" + this.name + "]";
+        case "property":
+            return this.name.indexOf(" ") === -1 ? "." + this.name : "[\"" + this.name + "\"]";
+        case "shortcut":
+            var name = this.name;
+            if (typeof name === "string")
+                return this.name.indexOf(" ") === -1 ? "." + this.name : "[\"" + this.name + "\"]";
+            else
+                return "[" + this.name + "]";
+        case "internal":
+        case "hidden":
+            return "{" + this.name + "}";
+        };
+        return "?" + this.name + "?";
+    },
+
+    get type()
+    {
+        return this._snapshot._edgeTypes[this._type()];
+    },
+
+    get _hasStringName()
+    {
+        return !this.isElement && !this.isHidden;
+    },
+
+    get _name()
+    {
+        return this._hasStringName ? this._snapshot._strings[this._nameOrIndex] : this._nameOrIndex;
+    },
+
+    get _nameOrIndex()
+    {
+        return this._edges.item(this.edgeIndex + this._snapshot._edgeNameOffset);
+    },
+
+    _type: function()
+    {
+        return this._edges.item(this.edgeIndex + this._snapshot._edgeTypeOffset);
+    }
+};
+
+WebInspector.HeapSnapshotEdgeIterator = function(edge)
+{
+    this.edge = edge;
+}
+
+WebInspector.HeapSnapshotEdgeIterator.prototype = {
+    first: function()
+    {
+        this.edge.edgeIndex = 0;
+    },
+
+    hasNext: function()
+    {
+        return this.edge.edgeIndex < this.edge._edges.length;
+    },
+
+    get index()
+    {
+        return this.edge.edgeIndex;
+    },
+
+    set index(newIndex)
+    {
+        this.edge.edgeIndex = newIndex;
+    },
+
+    get item()
+    {
+        return this.edge;
+    },
+
+    next: function()
+    {
+        this.edge.edgeIndex += this.edge._snapshot._edgeFieldsCount;
+    }
+};
+
+WebInspector.HeapSnapshotNode = function(snapshot, nodeIndex)
+{
+    this._snapshot = snapshot;
+    this._firstNodeIndex = nodeIndex;
+    this.nodeIndex = nodeIndex;
+}
+
+WebInspector.HeapSnapshotNode.prototype = {
+    get className()
+    {
+        switch (this.type) {
+        case "hidden":
+            return WebInspector.UIString("(system)");
+        case "object":
+            return this.name;
+        case "code":
+            return WebInspector.UIString("(compiled code)");
+        default:
+            return "(" + this.type + ")";
+        }
+    },
+
+    dominatorIndex: function()
+    {
+        return this._nodes[this.nodeIndex + this._snapshot._dominatorOffset];
+    },
+
+    get edges()
+    {
+        return new WebInspector.HeapSnapshotEdgeIterator(new WebInspector.HeapSnapshotEdge(this._snapshot, this.rawEdges));
+    },
+
+    get edgesCount()
+    {
+        return this._nodes[this.nodeIndex + this._snapshot._edgesCountOffset];
+    },
+
+    get id()
+    {
+        return this._nodes[this.nodeIndex + this._snapshot._nodeIdOffset];
+    },
+
+    get instancesCount()
+    {
+        return this._nodes[this.nodeIndex + this._snapshot._nodeInstancesCountOffset];
+    },
+
+    get isHidden()
+    {
+        return this._type() === this._snapshot._nodeHiddenType;
+    },
+
+    get isRoot()
+    {
+        return this.nodeIndex === this._snapshot._rootNodeIndex;
+    },
+
+    get name()
+    {
+        return this._snapshot._strings[this._name()];
+    },
+
+    get rawEdges()
+    {
+        var firstEdgeIndex = this._firstEdgeIndex();
+        return new WebInspector.HeapSnapshotArraySlice(this._snapshot, "_nodes", firstEdgeIndex, firstEdgeIndex + this.edgesCount * this._snapshot._edgeFieldsCount);
+    },
+
+    get retainedSize()
+    {
+        return this._nodes[this.nodeIndex + this._snapshot._nodeRetainedSizeOffset];
+    },
+
+    get retainers()
+    {
+        return new WebInspector.HeapSnapshotEdgeIterator(new WebInspector.HeapSnapshotEdge(this._snapshot, this._snapshot.retainers(this)));
+    },
+
+    get selfSize()
+    {
+        return this._nodes[this.nodeIndex + this._snapshot._nodeSelfSizeOffset];
+    },
+
+    get type()
+    {
+        return this._snapshot._nodeTypes[this._type()];
+    },
+
+    _name: function()
+    {
+        return this._nodes[this.nodeIndex + this._snapshot._nodeNameOffset];
+    },
+
+    get _nodes()
+    {
+        return this._snapshot._nodes;
+    },
+
+    _firstEdgeIndex: function()
+    {
+        return this.nodeIndex + this._snapshot._firstEdgeOffset;
+    },
+
+    get _nextNodeIndex()
+    {
+        return this._firstEdgeIndex() + this.edgesCount * this._snapshot._edgeFieldsCount;
+    },
+
+    _type: function()
+    {
+        return this._nodes[this.nodeIndex + this._snapshot._nodeTypeOffset];
+    }
+};
+
+WebInspector.HeapSnapshotNodeIterator = function(node)
+{
+    this.node = node;
+}
+
+WebInspector.HeapSnapshotNodeIterator.prototype = {
+    first: function()
+    {
+        this.node.nodeIndex = this.node._firstNodeIndex;
+    },
+
+    hasNext: function()
+    {
+        return this.node.nodeIndex < this.node._nodes.length;
+    },
+
+    get index()
+    {
+        return this.node.nodeIndex;
+    },
+
+    set index(newIndex)
+    {
+        this.node.nodeIndex = newIndex;
+    },
+
+    get item()
+    {
+        return this.node;
+    },
+
+    next: function()
+    {
+        this.node.nodeIndex = this.node._nextNodeIndex;
+    }
+}
+
+WebInspector.HeapSnapshot = function(profile)
+{
+    this._nodes = profile.nodes;
+    this._strings = profile.strings;
+
+    this._init();
+}
+
+WebInspector.HeapSnapshot.prototype = {
+    _init: function()
+    {
+        this._metaNodeIndex = 0;
+        this._rootNodeIndex = 1;
+        var meta = this._nodes[this._metaNodeIndex];
+        this._nodeTypeOffset = meta.fields.indexOf("type");
+        this._nodeNameOffset = meta.fields.indexOf("name");
+        this._nodeIdOffset = meta.fields.indexOf("id");
+        this._nodeInstancesCountOffset = this._nodeIdOffset;
+        this._nodeSelfSizeOffset = meta.fields.indexOf("self_size");
+        this._nodeRetainedSizeOffset = meta.fields.indexOf("retained_size");
+        this._dominatorOffset = meta.fields.indexOf("dominator");
+        this._edgesCountOffset = meta.fields.indexOf("children_count");
+        this._firstEdgeOffset = meta.fields.indexOf("children");
+        this._nodeTypes = meta.types[this._nodeTypeOffset];
+        this._nodeHiddenType = this._nodeTypes.indexOf("hidden");
+        var edgesMeta = meta.types[this._firstEdgeOffset];
+        this._edgeFieldsCount = edgesMeta.fields.length;
+        this._edgeTypeOffset = edgesMeta.fields.indexOf("type");
+        this._edgeNameOffset = edgesMeta.fields.indexOf("name_or_index");
+        this._edgeToNodeOffset = edgesMeta.fields.indexOf("to_node");
+        this._edgeTypes = edgesMeta.types[this._edgeTypeOffset];
+        this._edgeElementType = this._edgeTypes.indexOf("element");
+        this._edgeHiddenType = this._edgeTypes.indexOf("hidden");
+        this._edgeInternalType = this._edgeTypes.indexOf("internal");
+        this._edgeShortcutType = this._edgeTypes.indexOf("shortcut");
+    },
+
+    dispose: function()
+    {
+        delete this._nodes;
+        delete this._strings;
+        if (this._idsMap)
+            delete this._idsMap;
+        if (this._retainers) {
+            delete this._retainers;
+            delete this._nodesToRetainers;
+        }
+        if (this._aggregates) {
+            delete this._aggregates;
+            this._aggregatesWithIndexes = false;
+        }
+    },
+
+    get allNodes()
+    {
+        return new WebInspector.HeapSnapshotNodeIterator(this.rootNode);
+    },
+
+    get nodesCount()
+    {
+        if (this._nodesCount)
+            return this._nodesCount;
+
+        this._nodesCount = 0;
+        for (var iter = this.allNodes; iter.hasNext(); iter.next())
+            ++this._nodesCount;
+        return this._nodesCount;
+    },
+
+    restore: function(profile)
+    {
+        this._nodes = profile.nodes;
+        this._strings = profile.strings;
+    },
+
+    get rootNode()
+    {
+        return new WebInspector.HeapSnapshotNode(this, this._rootNodeIndex);
+    },
+
+    get totalSize()
+    {
+        return this.rootNode.retainedSize;
+    },
+
+    get idsMap()
+    {
+        if (this._idsMap)
+            return this._idsMap;
+
+        this._idsMap = [];
+        for (var iter = this.allNodes; iter.hasNext(); iter.next()) {
+            this._idsMap[iter.node.id] = true;
+        }
+        return this._idsMap;
+    },
+
+    retainers: function(node)
+    {
+        if (!this._retainers)
+            this._buildRetainers();
+
+        var retIndexFrom = this._nodesToRetainers[node.nodeIndex];
+        var retIndexTo = this._nodesToRetainers[node._nextNodeIndex];
+        return new WebInspector.HeapSnapshotArraySlice(this, "_retainers", retIndexFrom, retIndexTo);
+    },
+
+    aggregates: function(withNodeIndexes)
+    {
+        if (!this._aggregates)
+            this._buildAggregates();
+        if (withNodeIndexes && !this._aggregatesWithIndexes)
+            this._buildAggregatesIndexes();
+        return this._aggregates;
+    },
+
+    _buildRetainers: function()
+    {
+        this._nodesToRetainers = [];
+        for (var nodesIter = this.allNodes; nodesIter.hasNext(); nodesIter.next()) {
+            var node = nodesIter.node;
+            if (!(node.nodeIndex in this._nodesToRetainers))
+                this._nodesToRetainers[node.nodeIndex] = 0;
+            for (var edgesIter = node.edges; edgesIter.hasNext(); edgesIter.next()) {
+                var edge = edgesIter.edge;
+                var nodeIndex = edge.nodeIndex;
+                if (!(nodeIndex in this._nodesToRetainers))
+                    this._nodesToRetainers[nodeIndex] = 0;
+                this._nodesToRetainers[nodeIndex] += this._edgeFieldsCount;
+            }
+        }
+        nodesIter = this.allNodes;
+        var node = nodesIter.node;
+        var prevIndex = this._nodesToRetainers[node.nodeIndex] = 0;
+        var prevRetsCount = this._nodesToRetainers[node.nodeIndex];
+        nodesIter.next();
+        for (; nodesIter.hasNext(); nodesIter.next()) {
+            node = nodesIter.node;
+            var savedRefsCount = this._nodesToRetainers[node.nodeIndex];
+            this._nodesToRetainers[node.nodeIndex] = prevIndex + prevRetsCount;
+            prevIndex = this._nodesToRetainers[node.nodeIndex];
+            prevRetsCount = savedRefsCount;
+        }
+        this._retainers = new Array(prevIndex + prevRetsCount);
+        this._nodesToRetainers[this._nodes.length] = this._retainers.length;
+        for (nodesIter = this.allNodes; nodesIter.hasNext(); nodesIter.next()) {
+            node = nodesIter.node;
+            var retsCount = this._nodesToRetainers[node._nextNodeIndex] - this._nodesToRetainers[node.nodeIndex];
+            if (retsCount > 0) {
+                this._retainers[this._nodesToRetainers[node.nodeIndex]] = retsCount;
+            }
+        }
+        for (nodesIter = this.allNodes; nodesIter.hasNext(); nodesIter.next()) {
+            node = nodesIter.node;
+            for (var edgesIter = node.edges; edgesIter.hasNext(); edgesIter.next()) {
+                var edge = edgesIter.edge;
+                var nodeIndex = edge.nodeIndex;
+                var retIndex = this._nodesToRetainers[nodeIndex];
+                this._retainers[retIndex] -= this._edgeFieldsCount;
+                var idx = retIndex + this._retainers[retIndex];
+                this._retainers[idx + this._edgeTypeOffset] = edge._type();
+                this._retainers[idx + this._edgeNameOffset] = edge._nameOrIndex;
+                this._retainers[idx + this._edgeToNodeOffset] = node.nodeIndex;
+            }
+        }
+    },
+
+    _buildAggregates: function()
+    {
+        this._aggregates = {};
+        for (var iter = this.allNodes; iter.hasNext(); iter.next()) {
+            var node = iter.node;
+            var className = node.className;
+            var nameMatters = node.type === "object";
+            if (node.selfSize === 0)
+                continue;
+            if (!(className in this._aggregates))
+                this._aggregates[className] = { count: 0, self: 0, maxRet: 0, type: node.type, name: nameMatters ? node.name : null, idxs: [] };
+            var clss = this._aggregates[className];
+            ++clss.count;
+            clss.self += node.selfSize;
+            if (node.retainedSize > clss.maxRet)
+                clss.maxRet = node.retainedSize;
+        }
+    },
+
+    _buildAggregatesIndexes: function()
+    {
+        for (var iter = this.allNodes; iter.hasNext(); iter.next()) {
+            var node = iter.node;
+            var className = node.className;
+            var clss = this._aggregates[className];
+            if (clss)
+                clss.idxs.push(node.nodeIndex);
+        }
+
+        var nodeA = new WebInspector.HeapSnapshotNode(this);
+        var nodeB = new WebInspector.HeapSnapshotNode(this);
+        for (var clss in this._aggregates)
+            this._aggregates[clss].idxs.sort(
+                function(idxA, idxB) {
+                    nodeA.nodeIndex = idxA;
+                    nodeB.nodeIndex = idxB;
+                    return nodeA.id < nodeB.id ? -1 : 1;
+                });
+
+        this._aggregatesWithIndexes = true;
+    }
+};
+
+WebInspector.HeapSnapshotFilteredOrderedIterator = function(snapshot, iterator, filter)
+{
+    this._snapshot = snapshot;
+    this._filter = filter;
+    this._iterator = iterator;
+    this._iterationOrder = null;
+    this._position = 0;
+    this._lastComparator = null;
+}
+
+WebInspector.HeapSnapshotFilteredOrderedIterator.prototype = {
+    _createIterationOrder: function()
+    {
+        this._iterationOrder = [];
+        var iterator = this._iterator;
+        if (!this._filter) {
+            for (iterator.first(); iterator.hasNext(); iterator.next())
+                this._iterationOrder.push(iterator.index);
+        } else {
+            for (iterator.first(); iterator.hasNext(); iterator.next()) {
+                if (this._filter(iterator.item))
+                    this._iterationOrder.push(iterator.index);
+            }
+        }
+    },
+
+    first: function()
+    {
+        this._position = 0;
+    },
+
+    hasNext: function()
+    {
+        return this._position < this._iterationOrder.length;
+    },
+
+    get isEmpty()
+    {
+        if (this._iterationOrder)
+            return !this._iterationOrder.length;
+        var iterator = this._iterator;
+        if (!this._filter) {
+            iterator.first();
+            return !iterator.hasNext();
+        }
+        for (iterator.first(); iterator.hasNext(); iterator.next())
+            if (this._filter(iterator.item)) return false;
+        return true;
+    },
+
+    get item()
+    {
+        this._iterator.index = this._iterationOrder[this._position];
+        return this._iterator.item;
+    },
+
+    get lastComparator()
+    {
+        return this._lastComparator;
+    },
+
+    get length()
+    {
+        if (!this._iterationOrder)
+            this._createIterationOrder();
+        return this._iterationOrder.length;
+    },
+
+    next: function()
+    {
+        ++this._position;
+    }
+}
+
+WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.createComparator = function(fieldNames)
+{
+    return {fieldName1:fieldNames[0], ascending1:fieldNames[1], fieldName2:fieldNames[2], ascending2:fieldNames[3]};
+}
+
+WebInspector.HeapSnapshotEdgesProvider = function(snapshot, rawEdges, filter)
+{
+    WebInspector.HeapSnapshotFilteredOrderedIterator.call(this, snapshot, new WebInspector.HeapSnapshotEdgeIterator(new WebInspector.HeapSnapshotEdge(snapshot, rawEdges)), filter);
+}
+
+WebInspector.HeapSnapshotEdgesProvider.prototype = {
+    sort: function(comparator)
+    {
+        if (this._lastComparator === comparator)
+            return false;
+        this._lastComparator = comparator;
+        var fieldName1 = comparator.fieldName1;
+        var fieldName2 = comparator.fieldName2;
+        var ascending1 = comparator.ascending1;
+        var ascending2 = comparator.ascending2;
+
+        var edgeA = this._iterator.item.clone();
+        var edgeB = edgeA.clone();
+        var nodeA = new WebInspector.HeapSnapshotNode(this._snapshot);
+        var nodeB = new WebInspector.HeapSnapshotNode(this._snapshot);
+
+        function sortByEdgeFieldName(ascending, indexA, indexB)
+        {
+            edgeA.edgeIndex = indexA;
+            edgeB.edgeIndex = indexB;
+            if (edgeB.name === "__proto__") return -1;
+            if (edgeA.name === "__proto__") return 1;
+            var result =
+                edgeA.hasStringName === edgeB.hasStringName ?
+                (edgeA.name < edgeB.name ? -1 : (edgeA.name > edgeB.name ? 1 : 0)) :
+                (edgeA.hasStringName ? -1 : 1);
+            return ascending ? result : -result;
+        }
+
+        function sortByNodeField(fieldName, ascending, indexA, indexB)
+        {
+            edgeA.edgeIndex = indexA;
+            edgeB.edgeIndex = indexB;
+            nodeA.nodeIndex = edgeA.nodeIndex;
+            nodeB.nodeIndex = edgeB.nodeIndex;
+            var valueA = nodeA[fieldName];
+            var valueB = nodeB[fieldName];
+            var result = valueA < valueB ? -1 : (valueA > valueB ? 1 : 0);
+            return ascending ? result : -result;
+        }
+
+        if (!this._iterationOrder)
+            this._createIterationOrder();
+
+        function sortByEdgeAndNode(indexA, indexB) {
+            var result = sortByEdgeFieldName(ascending1, indexA, indexB);
+            if (result === 0)
+                result = sortByNodeField(fieldName2, ascending2, indexA, indexB);
+            return result;
+        }
+
+        function sortByNodeAndEdge(indexA, indexB) {
+            var result = sortByNodeField(fieldName1, ascending1, indexA, indexB);
+            if (result === 0)
+                result = sortByEdgeFieldName(ascending2, indexA, indexB);
+            return result;
+        }
+
+        function sortByNodeAndNode(indexA, indexB) {
+            var result = sortByNodeField(fieldName1, ascending1, indexA, indexB);
+            if (result === 0)
+                result = sortByNodeField(fieldName2, ascending2, indexA, indexB);
+            return result;
+        }
+
+        if (fieldName1 === "!edgeName")
+            this._iterationOrder.sort(sortByEdgeAndNode);
+        else if (fieldName2 === "!edgeName")
+            this._iterationOrder.sort(sortByNodeAndEdge);
+        else
+            this._iterationOrder.sort(sortByNodeAndNode);
+        return true;
+    }
+};
+
+WebInspector.HeapSnapshotEdgesProvider.prototype.__proto__ = WebInspector.HeapSnapshotFilteredOrderedIterator.prototype;
+
+WebInspector.HeapSnapshotNodesProvider = function(snapshot, nodes, filter)
+{
+    WebInspector.HeapSnapshotFilteredOrderedIterator.call(this, snapshot, nodes, filter);
+}
+
+WebInspector.HeapSnapshotNodesProvider.prototype = {
+    sort: function(comparator)
+    {
+        if (this._lastComparator === comparator)
+            return false;
+        this._lastComparator = comparator;
+        var fieldName1 = comparator.fieldName1;
+        var fieldName2 = comparator.fieldName2;
+        var ascending1 = comparator.ascending1;
+        var ascending2 = comparator.ascending2;
+
+        var nodeA = new WebInspector.HeapSnapshotNode(this._snapshot);
+        var nodeB = new WebInspector.HeapSnapshotNode(this._snapshot);
+
+        function sortByNodeField(fieldName, ascending, indexA, indexB)
+        {
+            nodeA.nodeIndex = indexA;
+            nodeB.nodeIndex = indexB;
+            var valueA = nodeA[fieldName];
+            var valueB = nodeB[fieldName];
+            var result = valueA < valueB ? -1 : (valueA > valueB ? 1 : 0);
+            return ascending ? result : -result;
+        }
+
+        if (!this._iterationOrder)
+            this._createIterationOrder();
+
+        function sortByComparator(indexA, indexB) {
+            var result = sortByNodeField(fieldName1, ascending1, indexA, indexB);
+            if (result === 0)
+                result = sortByNodeField(fieldName2, ascending2, indexA, indexB);
+            return result;
+        }
+
+        this._iterationOrder.sort(sortByComparator);
+        return true;
+    }
+};
+
+WebInspector.HeapSnapshotNodesProvider.prototype.__proto__ = WebInspector.HeapSnapshotFilteredOrderedIterator.prototype;
+
+WebInspector.HeapSnapshotPathFinder = function(snapshot, targetNodeIndex)
+{
+    this._snapshot = snapshot;
+    this._maxLength = 1;
+    this._lengthLimit = 15;
+    this._targetNodeIndex = targetNodeIndex;
+    this._currentPath = null;
+    this._skipHidden = !WebInspector.DetailedHeapshotView.prototype.showHiddenData;
+    this._rootChildren = this._fillRootChildren();
+}
+
+WebInspector.HeapSnapshotPathFinder.prototype = {
+    findNext: function()
+    {
+        for (var i = 0; i < 100000; ++i) {
+            if (!this._buildNextPath()) {
+                if (++this._maxLength >= this._lengthLimit)
+                    return null;
+                this._currentPath = null;
+                if (!this._buildNextPath())
+                    return null;
+            }
+            if (this._isPathFound())
+                return {path:this._pathToString(this._currentPath), len:this._currentPath.length};
+        }
+
+        return false;
+    },
+
+    _fillRootChildren: function()
+    {
+        var result = [];
+        for (var iter = this._snapshot.rootNode.edges; iter.hasNext(); iter.next())
+            result[iter.edge.nodeIndex] = true;
+        return result;
+    },
+
+    _appendToCurrentPath: function(iter)
+    {
+        this._currentPath._cache[this._lastEdge.nodeIndex] = true;
+        this._currentPath.push(iter);
+    },
+
+    _removeLastFromCurrentPath: function()
+    {
+        this._currentPath.pop();
+        delete this._currentPath._cache[this._lastEdge.nodeIndex];
+    },
+
+    _hasInPath: function(nodeIndex)
+    {
+        return this._targetNodeIndex === nodeIndex
+            || !!this._currentPath._cache[nodeIndex];
+    },
+
+    _isPathFound: function()
+    {
+        return this._currentPath.length === this._maxLength
+            && this._lastEdge.nodeIndex in this._rootChildren;
+    },
+
+    get _lastEdgeIter()
+    {
+        return this._currentPath[this._currentPath.length - 1];
+    },
+
+    get _lastEdge()
+    {
+        return this._lastEdgeIter.edge;
+    },
+
+    _skipEdge: function(edge)
+    {
+        return (this._skipHidden && (edge.isHidden || edge.node.isHidden))
+            || this._hasInPath(edge.nodeIndex);
+    },
+
+    _nextEdgeIter: function()
+    {
+        var iter = this._lastEdgeIter;
+        while (this._skipEdge(iter.edge) && iter.hasNext())
+            iter.next();
+        return iter;
+    },
+
+    _buildNextPath: function()
+    {
+        if (this._currentPath !== null) {
+            var iter = this._lastEdgeIter;
+            while (true) {
+                iter.next();
+                if (iter.hasNext())
+                    return true;
+                while (true) {
+                    if (this._currentPath.length > 1) {
+                        this._removeLastFromCurrentPath();
+                        iter = this._lastEdgeIter;
+                        iter.next();
+                        iter = this._nextEdgeIter();
+                        if (iter.hasNext()) {
+                            while (this._currentPath.length < this._maxLength) {
+                                iter = this._nextEdgeIter();
+                                if (iter.hasNext())
+                                    this._appendToCurrentPath(iter.edge.node.retainers);
+                                else
+                                    return true;
+                            }
+                            return true;
+                        }
+                    } else
+                        return false;
+                }
+            }
+        } else {
+            var node = new WebInspector.HeapSnapshotNode(this._snapshot, this._targetNodeIndex);
+            this._currentPath = [node.retainers];
+            this._currentPath._cache = {};
+            while (this._currentPath.length < this._maxLength) {
+                var iter = this._nextEdgeIter();
+                if (iter.hasNext())
+                    this._appendToCurrentPath(iter.edge.node.retainers);
+                else
+                    break;
+            }
+            return true;
+        }
+    },
+
+    _nodeToString: function(node)
+    {
+        if (node.id === 1)
+            return node.name;
+        else
+            return node.name + "@" + node.id;
+    },
+
+    _pathToString: function(path)
+    {
+        if (!path)
+            return "";
+        var sPath = [];
+        for (var j = 0; j < path.length; ++j)
+            sPath.push(path[j].edge.toString());
+        sPath.push(this._nodeToString(path[path.length - 1].edge.node));
+        sPath.reverse();
+        return sPath.join("");
+    }
+};

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/HeapSnapshotView.js
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/HeapSnapshotView.js b/weinre.build/vendor/webkit/WebCore/inspector/front-end/HeapSnapshotView.js
new file mode 100644
index 0000000..44b95c3
--- /dev/null
+++ b/weinre.build/vendor/webkit/WebCore/inspector/front-end/HeapSnapshotView.js
@@ -0,0 +1,1032 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.HeapSnapshotView = function(parent, profile)
+{
+    WebInspector.View.call(this);
+
+    this.element.addStyleClass("heap-snapshot-view");
+
+    this.parent = parent;
+    this.parent.addEventListener("profile added", this._updateBaseOptions, this);
+
+    this.showCountAsPercent = false;
+    this.showSizeAsPercent = false;
+    this.showCountDeltaAsPercent = false;
+    this.showSizeDeltaAsPercent = false;
+
+    this.categories = {
+        code: new WebInspector.ResourceCategory("code", WebInspector.UIString("Code"), "rgb(255,121,0)"),
+        data: new WebInspector.ResourceCategory("data", WebInspector.UIString("Objects"), "rgb(47,102,236)")
+    };
+
+    var summaryContainer = document.createElement("div");
+    summaryContainer.id = "heap-snapshot-summary-container";
+
+    this.countsSummaryBar = new WebInspector.SummaryBar(this.categories);
+    this.countsSummaryBar.element.className = "heap-snapshot-summary";
+    this.countsSummaryBar.calculator = new WebInspector.HeapSummaryCountCalculator();
+    var countsLabel = document.createElement("div");
+    countsLabel.className = "heap-snapshot-summary-label";
+    countsLabel.textContent = WebInspector.UIString("Count");
+    this.countsSummaryBar.element.appendChild(countsLabel);
+    summaryContainer.appendChild(this.countsSummaryBar.element);
+
+    this.sizesSummaryBar = new WebInspector.SummaryBar(this.categories);
+    this.sizesSummaryBar.element.className = "heap-snapshot-summary";
+    this.sizesSummaryBar.calculator = new WebInspector.HeapSummarySizeCalculator();
+    var sizesLabel = document.createElement("label");
+    sizesLabel.className = "heap-snapshot-summary-label";
+    sizesLabel.textContent = WebInspector.UIString("Size");
+    this.sizesSummaryBar.element.appendChild(sizesLabel);
+    summaryContainer.appendChild(this.sizesSummaryBar.element);
+
+    this.element.appendChild(summaryContainer);
+
+    var columns = {
+        cons: { title: WebInspector.UIString("Constructor"), disclosure: true, sortable: true },
+        count: { title: WebInspector.UIString("Count"), width: "54px", sortable: true },
+        size: { title: WebInspector.UIString("Size"), width: "72px", sort: "descending", sortable: true },
+        // \xb1 is a "plus-minus" sign.
+        countDelta: { title: WebInspector.UIString("\xb1 Count"), width: "72px", sortable: true },
+        sizeDelta: { title: WebInspector.UIString("\xb1 Size"), width: "72px", sortable: true }
+    };
+
+    this.dataGrid = new WebInspector.DataGrid(columns);
+    this.dataGrid.addEventListener("sorting changed", this._sortData, this);
+    this.dataGrid.element.addEventListener("mousedown", this._mouseDownInDataGrid.bind(this), true);
+    this.element.appendChild(this.dataGrid.element);
+
+    this.profile = profile;
+
+    this.baseSelectElement = document.createElement("select");
+    this.baseSelectElement.className = "status-bar-item";
+    this.baseSelectElement.addEventListener("change", this._changeBase.bind(this), false);
+    this._updateBaseOptions();
+
+    this.percentButton = new WebInspector.StatusBarButton("", "percent-time-status-bar-item status-bar-item");
+    this.percentButton.addEventListener("click", this._percentClicked.bind(this), false);
+
+    this._loadProfile(this.profile, profileCallback.bind(this));
+
+    function profileCallback(profile)
+    {
+        var list = this._profiles();
+        var profileIndex;
+        for (var i = 0; i < list.length; ++i)
+            if (list[i].uid === profile.uid) {
+                profileIndex = i;
+                break;
+            }
+        if (profileIndex > 0)
+            this.baseSelectElement.selectedIndex = profileIndex - 1;
+        else
+            this.baseSelectElement.selectedIndex = profileIndex;
+        this._resetDataGridList(resetCompleted.bind(this));
+    }
+
+    function resetCompleted()
+    {
+        this.refresh();
+        this._updatePercentButton();
+    }
+}
+
+WebInspector.HeapSnapshotView.prototype = {
+    get statusBarItems()
+    {
+        return [this.baseSelectElement, this.percentButton.element];
+    },
+
+    get profile()
+    {
+        return this._profile;
+    },
+
+    set profile(profile)
+    {
+        this._profile = profile;
+    },
+
+    show: function(parentElement)
+    {
+        WebInspector.View.prototype.show.call(this, parentElement);
+        this.dataGrid.updateWidths();
+    },
+
+    hide: function()
+    {
+        WebInspector.View.prototype.hide.call(this);
+        this._currentSearchResultIndex = -1;
+    },
+
+    resize: function()
+    {
+        if (this.dataGrid)
+            this.dataGrid.updateWidths();
+    },
+
+    refresh: function()
+    {
+        this.dataGrid.removeChildren();
+
+        var children = this.snapshotDataGridList.children;
+        var count = children.length;
+        for (var index = 0; index < count; ++index)
+            this.dataGrid.appendChild(children[index]);
+
+        this._updateSummaryGraph();
+    },
+
+    refreshShowAsPercents: function()
+    {
+        this._updatePercentButton();
+        this.refreshVisibleData();
+    },
+
+    _deleteSearchMatchedFlags: function(node)
+    {
+        delete node._searchMatchedConsColumn;
+        delete node._searchMatchedCountColumn;
+        delete node._searchMatchedSizeColumn;
+        delete node._searchMatchedCountDeltaColumn;
+        delete node._searchMatchedSizeDeltaColumn;
+    },
+
+    searchCanceled: function()
+    {
+        if (this._searchResults) {
+            for (var i = 0; i < this._searchResults.length; ++i) {
+                var profileNode = this._searchResults[i].profileNode;
+                this._deleteSearchMatchedFlags(profileNode);
+                profileNode.refresh();
+            }
+        }
+
+        delete this._searchFinishedCallback;
+        this._currentSearchResultIndex = -1;
+        this._searchResults = [];
+    },
+
+    performSearch: function(query, finishedCallback)
+    {
+        // Call searchCanceled since it will reset everything we need before doing a new search.
+        this.searchCanceled();
+
+        query = query.trim();
+
+        if (!query.length)
+            return;
+
+        this._searchFinishedCallback = finishedCallback;
+
+        var helper = WebInspector.HeapSnapshotView.SearchHelper;
+
+        var operationAndNumber = helper.parseOperationAndNumber(query);
+        var operation = operationAndNumber[0];
+        var queryNumber = operationAndNumber[1];
+
+        var percentUnits = helper.percents.test(query);
+        var megaBytesUnits = helper.megaBytes.test(query);
+        var kiloBytesUnits = helper.kiloBytes.test(query);
+        var bytesUnits = helper.bytes.test(query);
+
+        var queryNumberBytes = (megaBytesUnits ? (queryNumber * 1024 * 1024) : (kiloBytesUnits ? (queryNumber * 1024) : queryNumber));
+
+        function matchesQuery(heapSnapshotDataGridNode)
+        {
+            WebInspector.HeapSnapshotView.prototype._deleteSearchMatchedFlags(heapSnapshotDataGridNode);
+
+            if (percentUnits) {
+                heapSnapshotDataGridNode._searchMatchedCountColumn = operation(heapSnapshotDataGridNode.countPercent, queryNumber);
+                heapSnapshotDataGridNode._searchMatchedSizeColumn = operation(heapSnapshotDataGridNode.sizePercent, queryNumber);
+                heapSnapshotDataGridNode._searchMatchedCountDeltaColumn = operation(heapSnapshotDataGridNode.countDeltaPercent, queryNumber);
+                heapSnapshotDataGridNode._searchMatchedSizeDeltaColumn = operation(heapSnapshotDataGridNode.sizeDeltaPercent, queryNumber);
+            } else if (megaBytesUnits || kiloBytesUnits || bytesUnits) {
+                heapSnapshotDataGridNode._searchMatchedSizeColumn = operation(heapSnapshotDataGridNode.size, queryNumberBytes);
+                heapSnapshotDataGridNode._searchMatchedSizeDeltaColumn = operation(heapSnapshotDataGridNode.sizeDelta, queryNumberBytes);
+            } else {
+                heapSnapshotDataGridNode._searchMatchedCountColumn = operation(heapSnapshotDataGridNode.count, queryNumber);
+                heapSnapshotDataGridNode._searchMatchedCountDeltaColumn = operation(heapSnapshotDataGridNode.countDelta, queryNumber);
+            }
+
+            if (heapSnapshotDataGridNode.constructorName.hasSubstring(query, true))
+                heapSnapshotDataGridNode._searchMatchedConsColumn = true;
+
+            if (heapSnapshotDataGridNode._searchMatchedConsColumn ||
+                heapSnapshotDataGridNode._searchMatchedCountColumn ||
+                heapSnapshotDataGridNode._searchMatchedSizeColumn ||
+                heapSnapshotDataGridNode._searchMatchedCountDeltaColumn ||
+                heapSnapshotDataGridNode._searchMatchedSizeDeltaColumn) {
+                heapSnapshotDataGridNode.refresh();
+                return true;
+            }
+
+            return false;
+        }
+
+        var current = this.snapshotDataGridList.children[0];
+        var depth = 0;
+        var info = {};
+
+        // The second and subsequent levels of heap snapshot nodes represent retainers,
+        // so recursive expansion will be infinite, since a graph is being traversed.
+        // So default to a recursion cap of 2 levels.
+        const maxDepth = 2;
+
+        while (current) {
+            if (matchesQuery(current))
+                this._searchResults.push({ profileNode: current });
+            current = current.traverseNextNode(false, null, (depth >= maxDepth), info);
+            depth += info.depthChange;
+        }
+
+        finishedCallback(this, this._searchResults.length);
+    },
+
+    // FIXME: move these methods to a superclass, inherit both views from it.
+    jumpToFirstSearchResult: WebInspector.CPUProfileView.prototype.jumpToFirstSearchResult,
+    jumpToLastSearchResult: WebInspector.CPUProfileView.prototype.jumpToLastSearchResult,
+    jumpToNextSearchResult: WebInspector.CPUProfileView.prototype.jumpToNextSearchResult,
+    jumpToPreviousSearchResult: WebInspector.CPUProfileView.prototype.jumpToPreviousSearchResult,
+    showingFirstSearchResult: WebInspector.CPUProfileView.prototype.showingFirstSearchResult,
+    showingLastSearchResult: WebInspector.CPUProfileView.prototype.showingLastSearchResult,
+    _jumpToSearchResult: WebInspector.CPUProfileView.prototype._jumpToSearchResult,
+
+    refreshVisibleData: function()
+    {
+        var child = this.dataGrid.children[0];
+        while (child) {
+            child.refresh();
+            child = child.traverseNextNode(false, null, true);
+        }
+        this._updateSummaryGraph();
+    },
+
+    _changeBase: function()
+    {
+        if (this.baseSnapshot.uid === this._profiles()[this.baseSelectElement.selectedIndex].uid)
+            return;
+
+        this._resetDataGridList(resetCompleted.bind(this));
+
+        function resetCompleted() {
+            this.refresh();
+
+            if (!this.currentQuery || !this._searchFinishedCallback || !this._searchResults)
+                return;
+
+            // The current search needs to be performed again. First negate out previous match
+            // count by calling the search finished callback with a negative number of matches.
+            // Then perform the search again with the same query and callback.
+            this._searchFinishedCallback(this, -this._searchResults.length);
+            this.performSearch(this.currentQuery, this._searchFinishedCallback);
+        }
+    },
+
+    _createSnapshotDataGridList: function()
+    {
+        if (this._snapshotDataGridList)
+          delete this._snapshotDataGridList;
+
+        this._snapshotDataGridList = new WebInspector.HeapSnapshotDataGridList(this, this.baseSnapshot.entries, this.profile.entries);
+        return this._snapshotDataGridList;
+    },
+
+    _profiles: function()
+    {
+        return WebInspector.panels.profiles.getProfiles(WebInspector.HeapSnapshotProfileType.TypeId);
+    },
+
+    _loadProfile: function(profile, callback)
+    {
+        WebInspector.panels.profiles.loadHeapSnapshot(profile.uid, callback);
+    },
+
+    processLoadedSnapshot: function(profile, loadedSnapshot)
+    {
+        var snapshot = WebInspector.HeapSnapshotView.prototype._convertSnapshot(loadedSnapshot);
+        profile.children = snapshot.children;
+        profile.entries = snapshot.entries;
+        profile.lowlevels = snapshot.lowlevels;
+        WebInspector.HeapSnapshotView.prototype._prepareProfile(profile);
+    },
+
+    _mouseDownInDataGrid: function(event)
+    {
+        if (event.detail < 2)
+            return;
+
+        var cell = event.target.enclosingNodeOrSelfWithNodeName("td");
+        if (!cell || (!cell.hasStyleClass("count-column") && !cell.hasStyleClass("size-column") && !cell.hasStyleClass("countDelta-column") && !cell.hasStyleClass("sizeDelta-column")))
+            return;
+
+        if (cell.hasStyleClass("count-column"))
+            this.showCountAsPercent = !this.showCountAsPercent;
+        else if (cell.hasStyleClass("size-column"))
+            this.showSizeAsPercent = !this.showSizeAsPercent;
+        else if (cell.hasStyleClass("countDelta-column"))
+            this.showCountDeltaAsPercent = !this.showCountDeltaAsPercent;
+        else if (cell.hasStyleClass("sizeDelta-column"))
+            this.showSizeDeltaAsPercent = !this.showSizeDeltaAsPercent;
+
+        this.refreshShowAsPercents();
+
+        event.preventDefault();
+        event.stopPropagation();
+    },
+
+    get _isShowingAsPercent()
+    {
+        return this.showCountAsPercent && this.showSizeAsPercent && this.showCountDeltaAsPercent && this.showSizeDeltaAsPercent;
+    },
+
+    _percentClicked: function(event)
+    {
+        var currentState = this._isShowingAsPercent;
+        this.showCountAsPercent = !currentState;
+        this.showSizeAsPercent = !currentState;
+        this.showCountDeltaAsPercent = !currentState;
+        this.showSizeDeltaAsPercent = !currentState;
+        this.refreshShowAsPercents();
+    },
+
+    _convertSnapshot: function(loadedSnapshot)
+    {
+        var snapshot = new WebInspector.HeapSnapshot(loadedSnapshot);
+        var result = {lowlevels: {}, entries: {}, children: {}};
+        var rootEdgesIter = snapshot.rootNode.edges;
+        for (var iter = rootEdgesIter; iter.hasNext(); iter.next()) {
+            var node = iter.edge.node;
+            if (node.isHidden)
+                result.lowlevels[node.name] = {count: node.instancesCount, size: node.selfSize, type: node.name};
+            else if (node.instancesCount)
+                result.entries[node.name] = {constructorName: node.name, count: node.instancesCount, size: node.selfSize};
+            else {
+                var entry = {constructorName: node.name};
+                for (var innerIter = node.edges; innerIter.hasNext(); innerIter.next()) {
+                    var edge = innerIter.edge;
+                    entry[edge.nodeIndex] = {constructorName: edge.node.name, count: edge.name};
+                }
+                result.children[rootEdgesIter.edge.nodeIndex] = entry;
+            }
+        }
+        return result;
+    },
+
+    _prepareProfile: function(profile)
+    {
+        for (var profileEntry in profile.entries)
+            profile.entries[profileEntry].retainers = {};
+        profile.clusters = {};
+
+        for (var addr in profile.children) {
+            var retainer = profile.children[addr];
+            var retainerId = retainer.constructorName + ":" + addr;
+            for (var childAddr in retainer) {
+                if (childAddr === "constructorName") continue;
+                var item = retainer[childAddr];
+                var itemId = item.constructorName + ":" + childAddr;
+                if ((item.constructorName === "Object" || item.constructorName === "Array")) {
+                    if (!(itemId in profile.clusters))
+                        profile.clusters[itemId] = { constructorName: itemId, retainers: {} };
+                    mergeRetainers(profile.clusters[itemId], item);
+                }
+                mergeRetainers(profile.entries[item.constructorName], item);
+            }
+        }
+
+        function mergeRetainers(entry, item)
+        {
+            if (!(retainer.constructorName in entry.retainers))
+               entry.retainers[retainer.constructorName] = { constructorName: retainer.constructorName, count: 0, clusters: {} };
+            var retainerEntry = entry.retainers[retainer.constructorName];
+            retainerEntry.count += item.count;
+            if (retainer.constructorName === "Object" || retainer.constructorName === "Array")
+                retainerEntry.clusters[retainerId] = true;
+        }
+    },
+
+    _resetDataGridList: function(callback)
+    {
+        this._loadProfile(this._profiles()[this.baseSelectElement.selectedIndex], profileLoaded.bind(this));
+
+        function profileLoaded(profile)
+        {
+            this.baseSnapshot = profile;
+            var lastComparator = WebInspector.HeapSnapshotDataGridList.propertyComparator("size", false);
+            if (this.snapshotDataGridList)
+                lastComparator = this.snapshotDataGridList.lastComparator;
+            this.snapshotDataGridList = this._createSnapshotDataGridList();
+            this.snapshotDataGridList.sort(lastComparator, true);
+            callback();
+        }
+    },
+
+    _sortData: function()
+    {
+        var sortAscending = this.dataGrid.sortOrder === "ascending";
+        var sortColumnIdentifier = this.dataGrid.sortColumnIdentifier;
+        var sortProperty = {
+            cons: ["constructorName", null],
+            count: ["count", "constructorName"],
+            size: ["size", "constructorName"],
+            countDelta: [this.showCountDeltaAsPercent ? "countDeltaPercent" : "countDelta", "constructorName"],
+            sizeDelta: [this.showSizeDeltaAsPercent ? "sizeDeltaPercent" : "sizeDelta", "constructorName"]
+        }[sortColumnIdentifier];
+
+        this.snapshotDataGridList.sort(WebInspector.HeapSnapshotDataGridList.propertyComparator(sortProperty[0], sortProperty[1], sortAscending));
+
+        this.refresh();
+    },
+
+    _updateBaseOptions: function()
+    {
+        var list = this._profiles();
+        // We're assuming that snapshots can only be added.
+        if (this.baseSelectElement.length === list.length)
+            return;
+
+        for (var i = this.baseSelectElement.length, n = list.length; i < n; ++i) {
+            var baseOption = document.createElement("option");
+            var title = list[i].title;
+            if (!title.indexOf(UserInitiatedProfileName))
+                title = WebInspector.UIString("Snapshot %d", title.substring(UserInitiatedProfileName.length + 1));
+            baseOption.label = WebInspector.UIString("Compared to %s", title);
+            this.baseSelectElement.appendChild(baseOption);
+        }
+    },
+
+    _updatePercentButton: function()
+    {
+        if (this._isShowingAsPercent) {
+            this.percentButton.title = WebInspector.UIString("Show absolute counts and sizes.");
+            this.percentButton.toggled = true;
+        } else {
+            this.percentButton.title = WebInspector.UIString("Show counts and sizes as percentages.");
+            this.percentButton.toggled = false;
+        }
+    },
+
+    _updateSummaryGraph: function()
+    {
+        this.countsSummaryBar.calculator.showAsPercent = this._isShowingAsPercent;
+        this.countsSummaryBar.update(this.profile.lowlevels);
+
+        this.sizesSummaryBar.calculator.showAsPercent = this._isShowingAsPercent;
+        this.sizesSummaryBar.update(this.profile.lowlevels);
+    }
+};
+
+WebInspector.HeapSnapshotView.prototype.__proto__ = WebInspector.View.prototype;
+
+WebInspector.HeapSnapshotView.SearchHelper = {
+    // In comparators, we assume that a value from a node is passed as the first parameter.
+    operations: {
+        LESS: function (a, b) { return a !== null && a < b; },
+        LESS_OR_EQUAL: function (a, b) { return a !== null && a <= b; },
+        EQUAL: function (a, b) { return a !== null && a === b; },
+        GREATER_OR_EQUAL: function (a, b) { return a !== null && a >= b; },
+        GREATER: function (a, b) { return a !== null && a > b; }
+    },
+
+    operationParsers: {
+        LESS: /^<(\d+)/,
+        LESS_OR_EQUAL: /^<=(\d+)/,
+        GREATER_OR_EQUAL: /^>=(\d+)/,
+        GREATER: /^>(\d+)/
+    },
+
+    parseOperationAndNumber: function(query)
+    {
+        var operations = WebInspector.HeapSnapshotView.SearchHelper.operations;
+        var parsers = WebInspector.HeapSnapshotView.SearchHelper.operationParsers;
+        for (var operation in parsers) {
+            var match = query.match(parsers[operation]);
+            if (match !== null)
+                return [operations[operation], parseFloat(match[1])];
+        }
+        return [operations.EQUAL, parseFloat(query)];
+    },
+
+    percents: /%$/,
+
+    megaBytes: /MB$/i,
+
+    kiloBytes: /KB$/i,
+
+    bytes: /B$/i
+}
+
+WebInspector.HeapSummaryCalculator = function(lowLevelField)
+{
+    this.total = 1;
+    this.lowLevelField = lowLevelField;
+}
+
+WebInspector.HeapSummaryCalculator.prototype = {
+    computeSummaryValues: function(lowLevels)
+    {
+        var highLevels = { data: 0, code: 0 };
+        this.total = 0;
+        for (var item in lowLevels) {
+            var highItem = this._highFromLow(item);
+            if (highItem) {
+                var value = lowLevels[item][this.lowLevelField];
+                highLevels[highItem] += value;
+                this.total += value;
+            }
+        }
+        var result = { categoryValues: highLevels };
+        if (!this.showAsPercent)
+            result.total = this.total;
+        return result;
+    },
+
+    formatValue: function(value)
+    {
+        if (this.showAsPercent)
+            return WebInspector.UIString("%.2f%%", value / this.total * 100.0);
+        else
+            return this._valueToString(value);
+    },
+
+    get showAsPercent()
+    {
+        return this._showAsPercent;
+    },
+
+    set showAsPercent(x)
+    {
+        this._showAsPercent = x;
+    }
+}
+
+WebInspector.HeapSummaryCountCalculator = function()
+{
+    WebInspector.HeapSummaryCalculator.call(this, "count");
+}
+
+WebInspector.HeapSummaryCountCalculator.prototype = {
+    _highFromLow: function(type)
+    {
+        if (type === "CODE_TYPE" || type === "SHARED_FUNCTION_INFO_TYPE" || type === "SCRIPT_TYPE") return "code";
+        if (type === "STRING_TYPE" || type === "HEAP_NUMBER_TYPE" || type.match(/^JS_/)) return "data";
+        return null;
+    },
+
+    _valueToString: function(value)
+    {
+        return value.toString();
+    }
+}
+
+WebInspector.HeapSummaryCountCalculator.prototype.__proto__ = WebInspector.HeapSummaryCalculator.prototype;
+
+WebInspector.HeapSummarySizeCalculator = function()
+{
+    WebInspector.HeapSummaryCalculator.call(this, "size");
+}
+
+WebInspector.HeapSummarySizeCalculator.prototype = {
+    _highFromLow: function(type)
+    {
+        if (type === "CODE_TYPE" || type === "SHARED_FUNCTION_INFO_TYPE" || type === "SCRIPT_TYPE")
+            return "code";
+        if (type === "STRING_TYPE" || type === "HEAP_NUMBER_TYPE" || type.match(/^JS_/) || type.match(/_ARRAY_TYPE$/))
+            return "data";
+        return null;
+    },
+
+    _valueToString: Number.bytesToString
+}
+
+WebInspector.HeapSummarySizeCalculator.prototype.__proto__ = WebInspector.HeapSummaryCalculator.prototype;
+
+WebInspector.HeapSnapshotDataGridNodeWithRetainers = function(owningTree)
+{
+    this.tree = owningTree;
+
+    WebInspector.DataGridNode.call(this, null, this._hasRetainers);
+
+    this.addEventListener("populate", this._populate, this);
+};
+
+WebInspector.HeapSnapshotDataGridNodeWithRetainers.prototype = {
+    isEmptySet: function(set)
+    {
+        for (var x in set)
+            return false;
+        return true;
+    },
+
+    get _hasRetainers()
+    {
+        return !this.isEmptySet(this.retainers);
+    },
+
+    get _parent()
+    {
+        // For top-level nodes, return owning tree as a parent, not data grid.
+        return this.parent !== this.dataGrid ? this.parent : this.tree;
+    },
+
+    _populate: function(event)
+    {
+        function appendDiffEntry(baseItem, snapshotItem)
+        {
+            this.appendChild(new WebInspector.HeapSnapshotDataGridRetainerNode(this.snapshotView, baseItem, snapshotItem, this.tree));
+        }
+
+        this.produceDiff(this.baseRetainers, this.retainers, appendDiffEntry.bind(this));
+
+        if (this._parent) {
+            var currentComparator = this._parent.lastComparator;
+            if (currentComparator)
+                this.sort(currentComparator, true);
+        }
+
+        this.removeEventListener("populate", this._populate, this);
+    },
+
+    produceDiff: function(baseEntries, currentEntries, callback)
+    {
+        for (var item in currentEntries)
+            callback(baseEntries[item], currentEntries[item]);
+
+        for (item in baseEntries) {
+            if (!(item in currentEntries))
+                callback(baseEntries[item], null);
+        }
+    },
+
+    sort: function(comparator, force) {
+        if (!force && this.lastComparator === comparator)
+            return;
+
+        this.children.sort(comparator);
+        var childCount = this.children.length;
+        for (var childIndex = 0; childIndex < childCount; ++childIndex)
+            this.children[childIndex]._recalculateSiblings(childIndex);
+        for (var i = 0; i < this.children.length; ++i) {
+            var child = this.children[i];
+            if (!force && (!child.expanded || child.lastComparator === comparator))
+                continue;
+            child.sort(comparator, force);
+        }
+        this.lastComparator = comparator;
+    },
+
+    signForDelta: function(delta) {
+        if (delta === 0)
+            return "";
+        if (delta > 0)
+            return "+";
+        else
+            return "\u2212";  // Math minus sign, same width as plus.
+    },
+
+    showDeltaAsPercent: function(value)
+    {
+        if (value === Number.POSITIVE_INFINITY)
+            return WebInspector.UIString("new");
+        else if (value === Number.NEGATIVE_INFINITY)
+            return WebInspector.UIString("deleted");
+        if (value > 1000.0)
+            return WebInspector.UIString("%s >1000%%", this.signForDelta(value));
+        return WebInspector.UIString("%s%.2f%%", this.signForDelta(value), Math.abs(value));
+    },
+
+    getTotalCount: function()
+    {
+        if (!this._count) {
+            this._count = 0;
+            for (var i = 0, n = this.children.length; i < n; ++i)
+                this._count += this.children[i].count;
+        }
+        return this._count;
+    },
+
+    getTotalSize: function()
+    {
+        if (!this._size) {
+            this._size = 0;
+            for (var i = 0, n = this.children.length; i < n; ++i)
+                this._size += this.children[i].size;
+        }
+        return this._size;
+    },
+
+    get countPercent()
+    {
+        return this.count / this._parent.getTotalCount() * 100.0;
+    },
+
+    get sizePercent()
+    {
+        return this.size / this._parent.getTotalSize() * 100.0;
+    },
+
+    get countDeltaPercent()
+    {
+        if (this.baseCount > 0) {
+            if (this.count > 0)
+                return this.countDelta / this.baseCount * 100.0;
+            else
+                return Number.NEGATIVE_INFINITY;
+        } else
+            return Number.POSITIVE_INFINITY;
+    },
+
+    get sizeDeltaPercent()
+    {
+        if (this.baseSize > 0) {
+            if (this.size > 0)
+                return this.sizeDelta / this.baseSize * 100.0;
+            else
+                return Number.NEGATIVE_INFINITY;
+        } else
+            return Number.POSITIVE_INFINITY;
+    },
+
+    get data()
+    {
+        var data = {};
+
+        data["cons"] = this.constructorName;
+
+        if (this.snapshotView.showCountAsPercent)
+            data["count"] = WebInspector.UIString("%.2f%%", this.countPercent);
+        else
+            data["count"] = this.count;
+
+        if (this.size !== null) {
+            if (this.snapshotView.showSizeAsPercent)
+                data["size"] = WebInspector.UIString("%.2f%%", this.sizePercent);
+            else
+                data["size"] = Number.bytesToString(this.size);
+        } else
+            data["size"] = "";
+
+        if (this.snapshotView.showCountDeltaAsPercent)
+            data["countDelta"] = this.showDeltaAsPercent(this.countDeltaPercent);
+        else
+            data["countDelta"] = WebInspector.UIString("%s%d", this.signForDelta(this.countDelta), Math.abs(this.countDelta));
+
+        if (this.sizeDelta !== null) {
+            if (this.snapshotView.showSizeDeltaAsPercent)
+                data["sizeDelta"] = this.showDeltaAsPercent(this.sizeDeltaPercent);
+            else
+                data["sizeDelta"] = WebInspector.UIString("%s%s", this.signForDelta(this.sizeDelta), Number.bytesToString(Math.abs(this.sizeDelta)));
+        } else
+            data["sizeDelta"] = "";
+
+        return data;
+    },
+
+    createCell: function(columnIdentifier)
+    {
+        var cell = WebInspector.DataGridNode.prototype.createCell.call(this, columnIdentifier);
+
+        if ((columnIdentifier === "cons" && this._searchMatchedConsColumn) ||
+            (columnIdentifier === "count" && this._searchMatchedCountColumn) ||
+            (columnIdentifier === "size" && this._searchMatchedSizeColumn) ||
+            (columnIdentifier === "countDelta" && this._searchMatchedCountDeltaColumn) ||
+            (columnIdentifier === "sizeDelta" && this._searchMatchedSizeDeltaColumn))
+            cell.addStyleClass("highlight");
+
+        return cell;
+    }
+};
+
+WebInspector.HeapSnapshotDataGridNodeWithRetainers.prototype.__proto__ = WebInspector.DataGridNode.prototype;
+
+WebInspector.HeapSnapshotDataGridNode = function(snapshotView, baseEntry, snapshotEntry, owningTree)
+{
+    this.snapshotView = snapshotView;
+
+    if (!snapshotEntry)
+        snapshotEntry = { constructorName: baseEntry.constructorName, count: 0, size: 0, retainers: {} };
+    this.constructorName = snapshotEntry.constructorName;
+    this.count = snapshotEntry.count;
+    this.size = snapshotEntry.size;
+    this.retainers = snapshotEntry.retainers;
+
+    if (!baseEntry)
+        baseEntry = { count: 0, size: 0, retainers: {} };
+    this.baseCount = baseEntry.count;
+    this.countDelta = this.count - this.baseCount;
+    this.baseSize = baseEntry.size;
+    this.sizeDelta = this.size - this.baseSize;
+    this.baseRetainers = baseEntry.retainers;
+
+    WebInspector.HeapSnapshotDataGridNodeWithRetainers.call(this, owningTree);
+};
+
+WebInspector.HeapSnapshotDataGridNode.prototype.__proto__ = WebInspector.HeapSnapshotDataGridNodeWithRetainers.prototype;
+
+WebInspector.HeapSnapshotDataGridList = function(snapshotView, baseEntries, snapshotEntries)
+{
+    this.tree = this;
+    this.snapshotView = snapshotView;
+    this.children = [];
+    this.lastComparator = null;
+    this.populateChildren(baseEntries, snapshotEntries);
+};
+
+WebInspector.HeapSnapshotDataGridList.prototype = {
+    appendChild: function(child)
+    {
+        this.insertChild(child, this.children.length);
+    },
+
+    insertChild: function(child, index)
+    {
+        this.children.splice(index, 0, child);
+    },
+
+    removeChildren: function()
+    {
+        this.children = [];
+    },
+
+    populateChildren: function(baseEntries, snapshotEntries)
+    {
+        function appendListEntry(baseItem, snapshotItem)
+        {
+            this.appendChild(new WebInspector.HeapSnapshotDataGridNode(this.snapshotView, baseItem, snapshotItem, this));
+        }
+        this.produceDiff(baseEntries, snapshotEntries, appendListEntry.bind(this));
+    },
+
+    produceDiff: WebInspector.HeapSnapshotDataGridNodeWithRetainers.prototype.produceDiff,
+    sort: WebInspector.HeapSnapshotDataGridNodeWithRetainers.prototype.sort,
+    getTotalCount: WebInspector.HeapSnapshotDataGridNodeWithRetainers.prototype.getTotalCount,
+    getTotalSize: WebInspector.HeapSnapshotDataGridNodeWithRetainers.prototype.getTotalSize
+};
+
+WebInspector.HeapSnapshotDataGridList.propertyComparators = [{}, {}];
+
+WebInspector.HeapSnapshotDataGridList.propertyComparator = function(property, property2, isAscending)
+{
+    var propertyHash = property + "#" + property2;
+    var comparator = this.propertyComparators[(isAscending ? 1 : 0)][propertyHash];
+    if (!comparator) {
+        comparator = function(lhs, rhs) {
+            var l = lhs[property], r = rhs[property];
+            var result = 0;
+            if (l !== null && r !== null) {
+                result = l < r ? -1 : (l > r ? 1 : 0);
+            }
+            if (result !== 0 || property2 === null) {
+                return isAscending ? result : -result;
+            } else {
+                l = lhs[property2];
+                r = rhs[property2];
+                return l < r ? -1 : (l > r ? 1 : 0);
+            }
+        };
+        this.propertyComparators[(isAscending ? 1 : 0)][propertyHash] = comparator;
+    }
+    return comparator;
+};
+
+WebInspector.HeapSnapshotDataGridRetainerNode = function(snapshotView, baseEntry, snapshotEntry, owningTree)
+{
+    this.snapshotView = snapshotView;
+
+    if (!snapshotEntry)
+        snapshotEntry = { constructorName: baseEntry.constructorName, count: 0, clusters: {} };
+    this.constructorName = snapshotEntry.constructorName;
+    this.count = snapshotEntry.count;
+    this.retainers = this._calculateRetainers(this.snapshotView.profile, snapshotEntry.clusters);
+
+    if (!baseEntry)
+        baseEntry = { count: 0, clusters: {} };
+    this.baseCount = baseEntry.count;
+    this.countDelta = this.count - this.baseCount;
+    this.baseRetainers = this._calculateRetainers(this.snapshotView.baseSnapshot, baseEntry.clusters);
+
+    this.size = null;
+    this.sizeDelta = null;
+
+    WebInspector.HeapSnapshotDataGridNodeWithRetainers.call(this, owningTree);
+}
+
+WebInspector.HeapSnapshotDataGridRetainerNode.prototype = {
+    get sizePercent()
+    {
+        return null;
+    },
+
+    get sizeDeltaPercent()
+    {
+        return null;
+    },
+
+    _calculateRetainers: function(snapshot, clusters)
+    {
+        var retainers = {};
+        if (this.isEmptySet(clusters)) {
+            if (this.constructorName in snapshot.entries)
+                return snapshot.entries[this.constructorName].retainers;
+        } else {
+            // In case when an entry is retained by clusters, we need to gather up the list
+            // of retainers by merging retainers of every cluster.
+            // E.g. having such a tree:
+            //   A
+            //     Object:1  10
+            //       X       3
+            //       Y       4
+            //     Object:2  5
+            //       X       6
+            //
+            // will result in a following retainers list: X 9, Y 4.
+            for (var clusterName in clusters) {
+                if (clusterName in snapshot.clusters) {
+                    var clusterRetainers = snapshot.clusters[clusterName].retainers;
+                    for (var clusterRetainer in clusterRetainers) {
+                        var clusterRetainerEntry = clusterRetainers[clusterRetainer];
+                        if (!(clusterRetainer in retainers))
+                            retainers[clusterRetainer] = { constructorName: clusterRetainerEntry.constructorName, count: 0, clusters: {} };
+                        retainers[clusterRetainer].count += clusterRetainerEntry.count;
+                        for (var clusterRetainerCluster in clusterRetainerEntry.clusters)
+                            retainers[clusterRetainer].clusters[clusterRetainerCluster] = true;
+                    }
+                }
+            }
+        }
+        return retainers;
+    }
+};
+
+WebInspector.HeapSnapshotDataGridRetainerNode.prototype.__proto__ = WebInspector.HeapSnapshotDataGridNodeWithRetainers.prototype;
+
+
+WebInspector.HeapSnapshotProfileType = function()
+{
+    WebInspector.ProfileType.call(this, WebInspector.HeapSnapshotProfileType.TypeId, WebInspector.UIString("HEAP SNAPSHOTS"));
+}
+
+WebInspector.HeapSnapshotProfileType.TypeId = "HEAP";
+
+WebInspector.HeapSnapshotProfileType.prototype = {
+    get buttonTooltip()
+    {
+        return WebInspector.UIString("Take heap snapshot.");
+    },
+
+    get buttonStyle()
+    {
+        return "heap-snapshot-status-bar-item status-bar-item";
+    },
+
+    buttonClicked: function()
+    {
+        InspectorBackend.takeHeapSnapshot(false);
+    },
+
+    get welcomeMessage()
+    {
+        return WebInspector.UIString("Get a heap snapshot by pressing the %s button on the status bar.");
+    },
+
+    createSidebarTreeElementForProfile: function(profile)
+    {
+        return new WebInspector.ProfileSidebarTreeElement(profile, WebInspector.UIString("Snapshot %d"), "heap-snapshot-sidebar-tree-item");
+    },
+
+    createView: function(profile)
+    {
+        return new WebInspector.HeapSnapshotView(WebInspector.panels.profiles, profile);
+    }
+}
+
+WebInspector.HeapSnapshotProfileType.prototype.__proto__ = WebInspector.ProfileType.prototype;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/HelpScreen.js
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/HelpScreen.js b/weinre.build/vendor/webkit/WebCore/inspector/front-end/HelpScreen.js
new file mode 100644
index 0000000..a1bbf1e
--- /dev/null
+++ b/weinre.build/vendor/webkit/WebCore/inspector/front-end/HelpScreen.js
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.HelpScreen = function(title)
+{
+    this._element = document.createElement("div");
+    this._element.className = "help-window-outer";
+    this._element.addEventListener("keydown", this._onKeyDown.bind(this), false);
+
+    var mainWindow = this._element.createChild("div", "help-window-main");
+    var captionWindow = mainWindow.createChild("div", "help-window-caption");
+    var closeButton = captionWindow.createChild("button", "help-close-button");
+    this.contentElement = mainWindow.createChild("div", "help-content");
+    this.contentElement.tabIndex = 0;
+    this.contentElement.addEventListener("blur", this._onBlur.bind(this), false);
+    captionWindow.createChild("h1", "help-window-title").innerText = title;
+
+    closeButton.innerText = "\u2716"; // Code stands for HEAVY MULTIPLICATION X.
+    closeButton.addEventListener("click", this._hide.bind(this), false);
+    this._closeKeys = [
+        WebInspector.KeyboardShortcut.Keys.Enter.code,
+        WebInspector.KeyboardShortcut.Keys.Esc.code,
+        WebInspector.KeyboardShortcut.Keys.Space.code,
+    ];
+    document.body.appendChild(this._element);
+}
+
+WebInspector.HelpScreen.prototype = {
+    show: function()
+    {
+        if (this._isShown)
+            return;
+
+        this._element.style.visibility = "visible";
+        this._isShown = true;
+        this._previousFocusElement = WebInspector.currentFocusElement;
+        WebInspector.currentFocusElement = this.contentElement;
+    },
+
+    _hide: function()
+    {
+        this._isShown = false;
+        this._element.style.visibility = "hidden";
+        WebInspector.currentFocusElement = this._previousFocusElement;
+    },
+
+    _onKeyDown: function(event)
+    {
+        if (this._isShown && this._closeKeys.indexOf(event.keyCode) >= 0) {
+            this._hide();
+            event.stopPropagation();
+        }
+    },
+
+    _onBlur: function()
+    {
+         // Pretend we're modal, grab focus back if we're still shown.
+        if (this._isShown)
+            WebInspector.currentFocusElement = this.contentElement;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/ImageView.js
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/ImageView.js b/weinre.build/vendor/webkit/WebCore/inspector/front-end/ImageView.js
new file mode 100644
index 0000000..917a9da
--- /dev/null
+++ b/weinre.build/vendor/webkit/WebCore/inspector/front-end/ImageView.js
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2007, 2008 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.ImageView = function(resource)
+{
+    WebInspector.ResourceView.call(this, resource);
+
+    this.element.addStyleClass("image");
+}
+
+WebInspector.ImageView.prototype = {
+    hasContent: function()
+    {
+        return true;
+    },
+
+    show: function(parentElement)
+    {
+        WebInspector.ResourceView.prototype.show.call(this, parentElement);
+        this._createContentIfNeeded();
+    },
+
+    _createContentIfNeeded: function()
+    {
+        if (this._container)
+            return;
+
+        var imageContainer = document.createElement("div");
+        imageContainer.className = "image";
+        this.element.appendChild(imageContainer);
+
+        var imagePreviewElement = document.createElement("img");
+        imagePreviewElement.addStyleClass("resource-image-view");
+        imageContainer.appendChild(imagePreviewElement);
+
+        this._container = document.createElement("div");
+        this._container.className = "info";
+        this.element.appendChild(this._container);
+
+        var imageNameElement = document.createElement("h1");
+        imageNameElement.className = "title";
+        imageNameElement.textContent = this.resource.displayName;
+        this._container.appendChild(imageNameElement);
+
+        var infoListElement = document.createElement("dl");
+        infoListElement.className = "infoList";
+
+        this.resource.populateImageSource(imagePreviewElement);
+
+        function onImageLoad()
+        {
+            var content = this.resource.content;
+            if (content)
+                var resourceSize = this._base64ToSize(content);
+            else
+                var resourceSize = this.resource.resourceSize;
+
+            var imageProperties = [
+                { name: WebInspector.UIString("Dimensions"), value: WebInspector.UIString("%d × %d", imagePreviewElement.naturalWidth, imagePreviewElement.naturalHeight) },
+                { name: WebInspector.UIString("File size"), value: Number.bytesToString(resourceSize) },
+                { name: WebInspector.UIString("MIME type"), value: this.resource.mimeType }
+            ];
+    
+            infoListElement.removeChildren();
+            for (var i = 0; i < imageProperties.length; ++i) {
+                var dt = document.createElement("dt");
+                dt.textContent = imageProperties[i].name;
+                infoListElement.appendChild(dt);
+                var dd = document.createElement("dd");
+                dd.textContent = imageProperties[i].value;
+                infoListElement.appendChild(dd);
+            }
+            var dt = document.createElement("dt");
+            dt.textContent = WebInspector.UIString("URL");
+            infoListElement.appendChild(dt);
+            var dd = document.createElement("dd");
+            dd.appendChild(WebInspector.linkifyURLAsNode(this.resource.url));
+            infoListElement.appendChild(dd);
+
+            this._container.appendChild(infoListElement);
+        }
+        imagePreviewElement.addEventListener("load", onImageLoad.bind(this), false);
+    },
+
+    _base64ToSize: function(content)
+    {
+        if (!content.length)
+            return 0;
+        var size = (content.length || 0) * 3 / 4;
+        if (content.length > 0 && content[content.length - 1] === "=")
+            size--;
+        if (content.length > 1 && content[content.length - 2] === "=")
+            size--;
+        return size;
+    }
+}
+
+WebInspector.ImageView.prototype.__proto__ = WebInspector.ResourceView.prototype;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/applicationCache.png
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/applicationCache.png b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/applicationCache.png
new file mode 100644
index 0000000..50bad87
Binary files /dev/null and b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/applicationCache.png differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/auditsIcon.png
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/auditsIcon.png b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/auditsIcon.png
new file mode 100644
index 0000000..ebeafdc
Binary files /dev/null and b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/auditsIcon.png differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/back.png
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/back.png b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/back.png
new file mode 100644
index 0000000..9363960
Binary files /dev/null and b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/back.png differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointBorder.png
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointBorder.png b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointBorder.png
new file mode 100644
index 0000000..0b1b550
Binary files /dev/null and b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointBorder.png differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointConditionalBorder.png
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointConditionalBorder.png b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointConditionalBorder.png
new file mode 100644
index 0000000..430e37e
Binary files /dev/null and b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointConditionalBorder.png differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointConditionalCounterBorder.png
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointConditionalCounterBorder.png b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointConditionalCounterBorder.png
new file mode 100644
index 0000000..b4a5030
Binary files /dev/null and b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointConditionalCounterBorder.png differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointCounterBorder.png
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointCounterBorder.png b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointCounterBorder.png
new file mode 100644
index 0000000..8b77b61
Binary files /dev/null and b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointCounterBorder.png differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointsActivateButtonGlyph.png
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointsActivateButtonGlyph.png b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointsActivateButtonGlyph.png
new file mode 100644
index 0000000..ce49aac
Binary files /dev/null and b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointsActivateButtonGlyph.png differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointsDeactivateButtonGlyph.png
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointsDeactivateButtonGlyph.png b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointsDeactivateButtonGlyph.png
new file mode 100644
index 0000000..5c5fcf6
Binary files /dev/null and b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/breakpointsDeactivateButtonGlyph.png differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/checker.png
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/checker.png b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/checker.png
new file mode 100644
index 0000000..8349908
Binary files /dev/null and b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/checker.png differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/clearConsoleButtonGlyph.png
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/clearConsoleButtonGlyph.png b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/clearConsoleButtonGlyph.png
new file mode 100644
index 0000000..b1f9465
Binary files /dev/null and b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/clearConsoleButtonGlyph.png differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/closeButtons.png
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/closeButtons.png b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/closeButtons.png
new file mode 100644
index 0000000..28158a4
Binary files /dev/null and b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/closeButtons.png differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/consoleButtonGlyph.png
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/consoleButtonGlyph.png b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/consoleButtonGlyph.png
new file mode 100644
index 0000000..d10d43c
Binary files /dev/null and b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/consoleButtonGlyph.png differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/consoleIcon.png
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/consoleIcon.png b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/consoleIcon.png
new file mode 100644
index 0000000..94ffa95
Binary files /dev/null and b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/consoleIcon.png differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/cookie.png
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/cookie.png b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/cookie.png
new file mode 100644
index 0000000..90c3c15
Binary files /dev/null and b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/cookie.png differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/database.png
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/database.png b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/database.png
new file mode 100644
index 0000000..339efa6
Binary files /dev/null and b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/database.png differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/databaseTable.png
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/databaseTable.png b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/databaseTable.png
new file mode 100644
index 0000000..3718708
Binary files /dev/null and b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/databaseTable.png differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/debuggerContinue.png
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/debuggerContinue.png b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/debuggerContinue.png
new file mode 100644
index 0000000..d90a855
Binary files /dev/null and b/weinre.build/vendor/webkit/WebCore/inspector/front-end/Images/debuggerContinue.png differ


Mime
View raw message