Changeset 102447 in webkit
- Timestamp:
- Dec 9, 2011 1:25:58 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r102443 r102447 1 2011-12-08 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: Introduce a Map class allowing to store values indexed by arbitrary objects. 4 https://bugs.webkit.org/show_bug.cgi?id=74084 5 6 Reviewed by Pavel Feldman. 7 8 * inspector/map-expected.txt: Added. 9 * inspector/map.html: Added. 10 1 11 2011-12-09 Csaba Osztrogonác <ossy@webkit.org> 2 12 -
trunk/Source/WebCore/ChangeLog
r102441 r102447 1 2011-12-08 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: Introduce a Map class allowing to store values indexed by arbitrary objects. 4 https://bugs.webkit.org/show_bug.cgi?id=74084 5 6 Reviewed by Pavel Feldman. 7 8 Test: inspector/map.html 9 10 * inspector/front-end/treeoutline.js: 11 (TreeOutline): 12 (): 13 (TreeElement.prototype.collapse): 14 (TreeElement.prototype.expand): 15 * inspector/front-end/utilities.js: 16 (): 17 1 18 2011-12-09 Peter Rybin <peter.rybin@gmail.com> 2 19 -
trunk/Source/WebCore/inspector/front-end/treeoutline.js
r101509 r102447 39 39 this._childrenListNode = listNode; 40 40 this._childrenListNode.removeChildren(); 41 this._knownTreeElements = [];42 this._treeElementsExpandedState = [];43 41 this.expandTreeElementsWhenArrowing = false; 44 42 this.root = true; … … 50 48 this._childrenListNode.tabIndex = 0; 51 49 this._childrenListNode.addEventListener("keydown", this._treeKeyDown.bind(this), true); 52 } 53 54 TreeOutline._knownTreeElementNextIdentifier = 1; 50 51 this._treeElementsMap = new Map(); 52 this._expandedStateMap = new Map(); 53 } 55 54 56 55 TreeOutline.prototype.appendChild = function(child) … … 81 80 } 82 81 83 if (child.hasChildren && child.treeOutline._treeElementsExpandedState[child.identifier] !== undefined) 84 child.expanded = child.treeOutline._treeElementsExpandedState[child.identifier]; 82 child.expanded = child.hasChildren && !!child.treeOutline._expandedStateMap.get(child.representedObject); 85 83 86 84 if (!this._childrenListNode) { … … 132 130 } 133 131 134 if (child.hasChildren && child.treeOutline._treeElementsExpandedState[child.identifier] !== undefined) 135 child.expanded = child.treeOutline._treeElementsExpandedState[child.identifier]; 132 child.expanded = child.hasChildren && !!child.treeOutline._expandedStateMap.get(child.representedObject); 136 133 137 134 if (!this._childrenListNode) { … … 246 243 TreeOutline.prototype._rememberTreeElement = function(element) 247 244 { 248 if (!this._ knownTreeElements[element.identifier])249 this._ knownTreeElements[element.identifier] = [];250 245 if (!this._treeElementsMap.get(element.representedObject)) 246 this._treeElementsMap.put(element.representedObject, []); 247 251 248 // check if the element is already known 252 var elements = this._ knownTreeElements[element.identifier];249 var elements = this._treeElementsMap.get(element.representedObject); 253 250 if (elements.indexOf(element) !== -1) 254 251 return; … … 260 257 TreeOutline.prototype._forgetTreeElement = function(element) 261 258 { 262 if (this._ knownTreeElements[element.identifier])263 this._ knownTreeElements[element.identifier].remove(element, true);259 if (this._treeElementsMap.get(element.representedObject)) 260 this._treeElementsMap.get(element.representedObject).remove(element, true); 264 261 } 265 262 … … 278 275 return null; 279 276 280 if ("__treeElementIdentifier" in representedObject) { 281 // If this representedObject has a tree element identifier, and it is a known TreeElement 282 // in our tree we can just return that tree element. 283 var elements = this._knownTreeElements[representedObject.__treeElementIdentifier]; 284 if (elements) { 285 for (var i = 0; i < elements.length; ++i) 286 if (elements[i].representedObject === representedObject) 287 return elements[i]; 288 } 289 } 277 var elements = this._treeElementsMap.get(representedObject); 278 if (elements && elements.length) 279 return elements[0]; 290 280 return null; 291 281 } … … 480 470 this.representedObject = (representedObject || {}); 481 471 482 if (this.representedObject.__treeElementIdentifier)483 this.identifier = this.representedObject.__treeElementIdentifier;484 else {485 this.identifier = TreeOutline._knownTreeElementNextIdentifier++;486 this.representedObject.__treeElementIdentifier = this.identifier;487 }488 489 472 this._hidden = false; 490 473 this._selectable = true; … … 743 726 744 727 this.expanded = false; 728 745 729 if (this.treeOutline) 746 this.treeOutline._ treeElementsExpandedState[this.identifier] = false;730 this.treeOutline._expandedStateMap.put(this.representedObject, false); 747 731 748 732 if (this.oncollapse) … … 771 755 this.expanded = true; 772 756 if (this.treeOutline) 773 this.treeOutline._ treeElementsExpandedState[this.identifier] = true;757 this.treeOutline._expandedStateMap.put(this.representedObject, true); 774 758 775 759 if (this.treeOutline && (!this._childrenListNode || this._shouldRefreshChildren)) { -
trunk/Source/WebCore/inspector/front-end/utilities.js
r101670 r102447 1150 1150 return diffData; 1151 1151 } 1152 1153 /** 1154 * @constructor 1155 */ 1156 Map = function() 1157 { 1158 this._map = {}; 1159 } 1160 1161 Map._lastObjectIdentifier = 0; 1162 1163 Map.prototype = { 1164 /** 1165 * @param {Object} key 1166 */ 1167 put: function(key, value) 1168 { 1169 var objectIdentifier = key.__identifier; 1170 if (!objectIdentifier) { 1171 objectIdentifier = ++Map._lastObjectIdentifier; 1172 key.__identifier = objectIdentifier; 1173 } 1174 this._map[objectIdentifier] = value; 1175 }, 1176 1177 /** 1178 * @param {Object} key 1179 */ 1180 remove: function(key) 1181 { 1182 delete this._map[key.__identifier]; 1183 }, 1184 1185 /** 1186 * @param {Object} key 1187 */ 1188 get: function(key) 1189 { 1190 return this._map[key.__identifier]; 1191 }, 1192 }
Note: See TracChangeset
for help on using the changeset viewer.