Diff
Modified: trunk/LayoutTests/ChangeLog (102446 => 102447)
--- trunk/LayoutTests/ChangeLog 2011-12-09 09:15:59 UTC (rev 102446)
+++ trunk/LayoutTests/ChangeLog 2011-12-09 09:25:58 UTC (rev 102447)
@@ -1,3 +1,13 @@
+2011-12-08 Vsevolod Vlasov <vse...@chromium.org>
+
+ Web Inspector: Introduce a Map class allowing to store values indexed by arbitrary objects.
+ https://bugs.webkit.org/show_bug.cgi?id=74084
+
+ Reviewed by Pavel Feldman.
+
+ * inspector/map-expected.txt: Added.
+ * inspector/map.html: Added.
+
2011-12-09 Csaba Osztrogonác <o...@webkit.org>
[Qt] Unreviewed gardening. Add Qt specific expected results.
Added: trunk/LayoutTests/inspector/map-expected.txt (0 => 102447)
--- trunk/LayoutTests/inspector/map-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/map-expected.txt 2011-12-09 09:25:58 UTC (rev 102447)
@@ -0,0 +1,100 @@
+Tests Map class.
+
+Bug 74084
+Dumping maps:
+ First map:
+ key1 : undefined
+ key2 : undefined
+ Second map:
+ key1 : undefined
+ key2 : undefined
+
+Dumping maps:
+ First map:
+ key1 : 2
+ key2 : undefined
+ Second map:
+ key1 : undefined
+ key2 : undefined
+
+Dumping maps:
+ First map:
+ key1 : 1
+ key2 : undefined
+ Second map:
+ key1 : undefined
+ key2 : undefined
+
+Dumping maps:
+ First map:
+ key1 : 1
+ key2 : undefined
+ Second map:
+ key1 : 1
+ key2 : undefined
+
+Dumping maps:
+ First map:
+ key1 : 1
+ key2 : undefined
+ Second map:
+ key1 : 2
+ key2 : undefined
+
+Dumping maps:
+ First map:
+ key1 : 1
+ key2 : 2
+ Second map:
+ key1 : 2
+ key2 : undefined
+
+Dumping maps:
+ First map:
+ key1 : 1
+ key2 : 2
+ Second map:
+ key1 : 2
+ key2 : 1
+
+Dumping maps:
+ First map:
+ key1 : 1
+ key2 : undefined
+ Second map:
+ key1 : 2
+ key2 : 1
+
+Dumping maps:
+ First map:
+ key1 : 1
+ key2 : undefined
+ Second map:
+ key1 : 2
+ key2 : undefined
+
+Dumping maps:
+ First map:
+ key1 : 1
+ key2 : undefined
+ Second map:
+ key1 : 2
+ key2 : undefined
+
+Dumping maps:
+ First map:
+ key1 : undefined
+ key2 : undefined
+ Second map:
+ key1 : 2
+ key2 : undefined
+
+Dumping maps:
+ First map:
+ key1 : undefined
+ key2 : undefined
+ Second map:
+ key1 : undefined
+ key2 : undefined
+
+
Property changes on: trunk/LayoutTests/inspector/map-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/inspector/map.html (0 => 102447)
--- trunk/LayoutTests/inspector/map.html (rev 0)
+++ trunk/LayoutTests/inspector/map.html 2011-12-09 09:25:58 UTC (rev 102447)
@@ -0,0 +1,71 @@
+<html>
+<head>
+<script src=""
+<script type="text/_javascript_">
+
+var test = function()
+{
+ function dumpMaps(map1, map2, key1, key2)
+ {
+ InspectorTest.addResult("Dumping maps:");
+ InspectorTest.addResult(" First map:");
+ InspectorTest.addResult(" key1 : " + map1.get(key1));
+ InspectorTest.addResult(" key2 : " + map1.get(key2));
+ InspectorTest.addResult(" Second map:");
+ InspectorTest.addResult(" key1 : " + map2.get(key1));
+ InspectorTest.addResult(" key2 : " + map2.get(key2));
+ InspectorTest.addResult("");
+ }
+
+ var key1 = {};
+ var key2 = {};
+ var value1 = 1;
+ var value2 = 2;
+ var map1 = new Map();
+ var map2 = new Map();
+
+ dumpMaps(map1, map2, key1, key2);
+
+ map1.put(key1, value2);
+ dumpMaps(map1, map2, key1, key2);
+
+ map1.put(key1, value1);
+ dumpMaps(map1, map2, key1, key2);
+
+ map2.put(key1, value1);
+ dumpMaps(map1, map2, key1, key2);
+
+ map2.put(key1, value2);
+ dumpMaps(map1, map2, key1, key2);
+
+ map1.put(key2, value2);
+ dumpMaps(map1, map2, key1, key2);
+
+ map2.put(key2, value1);
+ dumpMaps(map1, map2, key1, key2);
+
+ map1.remove(key2);
+ dumpMaps(map1, map2, key1, key2);
+
+ map2.remove(key2);
+ dumpMaps(map1, map2, key1, key2);
+
+ map2.remove(key2);
+ dumpMaps(map1, map2, key1, key2);
+
+ map1.remove(key1);
+ dumpMaps(map1, map2, key1, key2);
+
+ map2.remove(key1);
+ dumpMaps(map1, map2, key1, key2);
+
+ InspectorTest.completeTest();
+}
+
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests Map class.</p>
+<a href="" 74084</a>
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/map.html
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/ChangeLog (102446 => 102447)
--- trunk/Source/WebCore/ChangeLog 2011-12-09 09:15:59 UTC (rev 102446)
+++ trunk/Source/WebCore/ChangeLog 2011-12-09 09:25:58 UTC (rev 102447)
@@ -1,3 +1,20 @@
+2011-12-08 Vsevolod Vlasov <vse...@chromium.org>
+
+ Web Inspector: Introduce a Map class allowing to store values indexed by arbitrary objects.
+ https://bugs.webkit.org/show_bug.cgi?id=74084
+
+ Reviewed by Pavel Feldman.
+
+ Test: inspector/map.html
+
+ * inspector/front-end/treeoutline.js:
+ (TreeOutline):
+ ():
+ (TreeElement.prototype.collapse):
+ (TreeElement.prototype.expand):
+ * inspector/front-end/utilities.js:
+ ():
+
2011-12-09 Peter Rybin <peter.ry...@gmail.com>
Web Inspector: [protocol] generate C++ classes for protocol JSON named types
Modified: trunk/Source/WebCore/inspector/front-end/treeoutline.js (102446 => 102447)
--- trunk/Source/WebCore/inspector/front-end/treeoutline.js 2011-12-09 09:15:59 UTC (rev 102446)
+++ trunk/Source/WebCore/inspector/front-end/treeoutline.js 2011-12-09 09:25:58 UTC (rev 102447)
@@ -38,8 +38,6 @@
this.selectedTreeElement = null;
this._childrenListNode = listNode;
this._childrenListNode.removeChildren();
- this._knownTreeElements = [];
- this._treeElementsExpandedState = [];
this.expandTreeElementsWhenArrowing = false;
this.root = true;
this.hasChildren = false;
@@ -49,10 +47,11 @@
this._childrenListNode.tabIndex = 0;
this._childrenListNode.addEventListener("keydown", this._treeKeyDown.bind(this), true);
+
+ this._treeElementsMap = new Map();
+ this._expandedStateMap = new Map();
}
-TreeOutline._knownTreeElementNextIdentifier = 1;
-
TreeOutline.prototype.appendChild = function(child)
{
if (!child)
@@ -80,8 +79,7 @@
current = current.traverseNextTreeElement(false, child, true);
}
- if (child.hasChildren && child.treeOutline._treeElementsExpandedState[child.identifier] !== undefined)
- child.expanded = child.treeOutline._treeElementsExpandedState[child.identifier];
+ child.expanded = child.hasChildren && !!child.treeOutline._expandedStateMap.get(child.representedObject);
if (!this._childrenListNode) {
this._childrenListNode = this.treeOutline._childrenListNode.ownerDocument.createElement("ol");
@@ -131,8 +129,7 @@
current = current.traverseNextTreeElement(false, child, true);
}
- if (child.hasChildren && child.treeOutline._treeElementsExpandedState[child.identifier] !== undefined)
- child.expanded = child.treeOutline._treeElementsExpandedState[child.identifier];
+ child.expanded = child.hasChildren && !!child.treeOutline._expandedStateMap.get(child.representedObject);
if (!this._childrenListNode) {
this._childrenListNode = this.treeOutline._childrenListNode.ownerDocument.createElement("ol");
@@ -245,11 +242,11 @@
TreeOutline.prototype._rememberTreeElement = function(element)
{
- if (!this._knownTreeElements[element.identifier])
- this._knownTreeElements[element.identifier] = [];
-
+ if (!this._treeElementsMap.get(element.representedObject))
+ this._treeElementsMap.put(element.representedObject, []);
+
// check if the element is already known
- var elements = this._knownTreeElements[element.identifier];
+ var elements = this._treeElementsMap.get(element.representedObject);
if (elements.indexOf(element) !== -1)
return;
@@ -259,8 +256,8 @@
TreeOutline.prototype._forgetTreeElement = function(element)
{
- if (this._knownTreeElements[element.identifier])
- this._knownTreeElements[element.identifier].remove(element, true);
+ if (this._treeElementsMap.get(element.representedObject))
+ this._treeElementsMap.get(element.representedObject).remove(element, true);
}
TreeOutline.prototype._forgetChildrenRecursive = function(parentElement)
@@ -277,16 +274,9 @@
if (!representedObject)
return null;
- if ("__treeElementIdentifier" in representedObject) {
- // If this representedObject has a tree element identifier, and it is a known TreeElement
- // in our tree we can just return that tree element.
- var elements = this._knownTreeElements[representedObject.__treeElementIdentifier];
- if (elements) {
- for (var i = 0; i < elements.length; ++i)
- if (elements[i].representedObject === representedObject)
- return elements[i];
- }
- }
+ var elements = this._treeElementsMap.get(representedObject);
+ if (elements && elements.length)
+ return elements[0];
return null;
}
@@ -479,13 +469,6 @@
this._title = title;
this.representedObject = (representedObject || {});
- if (this.representedObject.__treeElementIdentifier)
- this.identifier = this.representedObject.__treeElementIdentifier;
- else {
- this.identifier = TreeOutline._knownTreeElementNextIdentifier++;
- this.representedObject.__treeElementIdentifier = this.identifier;
- }
-
this._hidden = false;
this._selectable = true;
this.expanded = false;
@@ -742,8 +725,9 @@
this._childrenListNode.classList.remove("expanded");
this.expanded = false;
+
if (this.treeOutline)
- this.treeOutline._treeElementsExpandedState[this.identifier] = false;
+ this.treeOutline._expandedStateMap.put(this.representedObject, false);
if (this.oncollapse)
this.oncollapse(this);
@@ -770,7 +754,7 @@
this.expanded = true;
if (this.treeOutline)
- this.treeOutline._treeElementsExpandedState[this.identifier] = true;
+ this.treeOutline._expandedStateMap.put(this.representedObject, true);
if (this.treeOutline && (!this._childrenListNode || this._shouldRefreshChildren)) {
if (this._childrenListNode && this._childrenListNode.parentNode)
Modified: trunk/Source/WebCore/inspector/front-end/utilities.js (102446 => 102447)
--- trunk/Source/WebCore/inspector/front-end/utilities.js 2011-12-09 09:15:59 UTC (rev 102446)
+++ trunk/Source/WebCore/inspector/front-end/utilities.js 2011-12-09 09:25:58 UTC (rev 102447)
@@ -1149,3 +1149,44 @@
}
return diffData;
}
+
+/**
+ * @constructor
+ */
+Map = function()
+{
+ this._map = {};
+}
+
+Map._lastObjectIdentifier = 0;
+
+Map.prototype = {
+ /**
+ * @param {Object} key
+ */
+ put: function(key, value)
+ {
+ var objectIdentifier = key.__identifier;
+ if (!objectIdentifier) {
+ objectIdentifier = ++Map._lastObjectIdentifier;
+ key.__identifier = objectIdentifier;
+ }
+ this._map[objectIdentifier] = value;
+ },
+
+ /**
+ * @param {Object} key
+ */
+ remove: function(key)
+ {
+ delete this._map[key.__identifier];
+ },
+
+ /**
+ * @param {Object} key
+ */
+ get: function(key)
+ {
+ return this._map[key.__identifier];
+ },
+}