OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 this.recursiveSortingEnter(); | 224 this.recursiveSortingEnter(); |
225 var children = this.allChildren(this.rootNode()); | 225 var children = this.allChildren(this.rootNode()); |
226 this.rootNode().removeChildren(); | 226 this.rootNode().removeChildren(); |
227 children.sort(sortFunction); | 227 children.sort(sortFunction); |
228 for (var i = 0, l = children.length; i < l; ++i) { | 228 for (var i = 0, l = children.length; i < l; ++i) { |
229 var child = children[i]; | 229 var child = children[i]; |
230 this.appendChildAfterSorting(child); | 230 this.appendChildAfterSorting(child); |
231 if (child.expanded) | 231 if (child.expanded) |
232 child.sort(); | 232 child.sort(); |
233 } | 233 } |
234 this.updateVisibleNodes(); | |
235 this.recursiveSortingLeave(); | 234 this.recursiveSortingLeave(); |
236 }, | 235 }, |
237 | 236 |
238 appendChildAfterSorting: function(child) | 237 appendChildAfterSorting: function(child) |
239 { | 238 { |
240 var revealed = child.revealed; | 239 var revealed = child.revealed; |
241 this.rootNode().appendChild(child); | 240 this.rootNode().appendChild(child); |
242 child.revealed = revealed; | 241 child.revealed = revealed; |
243 }, | 242 }, |
244 | 243 |
245 recursiveSortingEnter: function() | 244 recursiveSortingEnter: function() |
246 { | 245 { |
247 ++this._recursiveSortingDepth; | 246 ++this._recursiveSortingDepth; |
248 }, | 247 }, |
249 | 248 |
250 recursiveSortingLeave: function() | 249 recursiveSortingLeave: function() |
251 { | 250 { |
252 if (!this._recursiveSortingDepth) | 251 if (!this._recursiveSortingDepth) |
253 return; | 252 return; |
254 if (!--this._recursiveSortingDepth) | 253 if (--this._recursiveSortingDepth) |
255 this.dispatchEventToListeners("sorting complete"); | 254 return; |
255 this.updateVisibleNodes(); | |
256 this.dispatchEventToListeners("sorting complete"); | |
256 }, | 257 }, |
257 | 258 |
258 updateVisibleNodes: function() | 259 updateVisibleNodes: function() |
259 { | 260 { |
260 }, | 261 }, |
261 | 262 |
262 /** | 263 /** |
263 * @param {!WebInspector.DataGridNode} parent | 264 * @param {!WebInspector.DataGridNode} parent |
264 * @return {!Array.<!WebInspector.HeapSnapshotGridNode>} | 265 * @return {!Array.<!WebInspector.HeapSnapshotGridNode>} |
265 */ | 266 */ |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 topLevelNodes: function() | 325 topLevelNodes: function() |
325 { | 326 { |
326 return this.allChildren(this.rootNode()); | 327 return this.allChildren(this.rootNode()); |
327 }, | 328 }, |
328 | 329 |
329 appendChildAfterSorting: function(child) | 330 appendChildAfterSorting: function(child) |
330 { | 331 { |
331 // Do nothing here, it will be added in updateVisibleNodes. | 332 // Do nothing here, it will be added in updateVisibleNodes. |
332 }, | 333 }, |
333 | 334 |
334 updateVisibleNodes: function() | 335 /** |
336 * @param {number=} scrollTop | |
337 */ | |
338 updateVisibleNodes: function(scrollTop) | |
335 { | 339 { |
336 var scrollTop = this.scrollContainer.scrollTop; | 340 if (scrollTop === undefined) |
337 var children = this.topLevelNodes(); | 341 scrollTop = this.scrollContainer.scrollTop; |
342 var viewPortHeight = this.scrollContainer.offsetHeight; | |
343 var selectedNode = this.selectedNode; | |
344 this.rootNode().removeChildren(); | |
338 | 345 |
339 var topPadding = 0; | 346 this._topPaddingHeight = 0; |
340 for (var i = 0; i < children.length; ++i) { | 347 this._bottomPaddingHeight = 0; |
341 if (children[i].revealed) { | |
342 var newTop = topPadding + children[i].nodeHeight(); | |
343 if (newTop > scrollTop) | |
344 break; | |
345 topPadding = newTop; | |
346 } | |
347 } | |
348 | 348 |
349 this._addVisibleNodes(this.rootNode(), i, scrollTop - topPadding, topPad ding); | 349 this._addVisibleNodes(this.rootNode(), scrollTop, scrollTop + viewPortHe ight); |
350 }, | |
351 | 350 |
352 /** | 351 this._topPadding.setHeight(this._topPaddingHeight); |
353 * @param {!WebInspector.DataGridNode} parentNode | 352 this._bottomPadding.setHeight(this._bottomPaddingHeight); |
354 * @param {number} firstVisibleNodeIndex | |
355 * @param {number} firstNodeHiddenHeight | |
356 * @param {number} topPadding | |
357 */ | |
358 _addVisibleNodes: function(parentNode, firstVisibleNodeIndex, firstNodeHidde nHeight, topPadding) | |
359 { | |
360 var viewPortHeight = this.scrollContainer.offsetHeight; | |
361 | |
362 var children = this.allChildren(parentNode); | |
363 var selectedNode = this.selectedNode; | |
364 | |
365 parentNode.removeChildren(); | |
366 | |
367 // The height of the view port + invisible top part. | |
368 var heightToFill = viewPortHeight + firstNodeHiddenHeight; | |
369 var filledHeight = 0; | |
370 var i = firstVisibleNodeIndex; | |
371 while (i < children.length && filledHeight < heightToFill) { | |
372 if (children[i].revealed) { | |
373 parentNode.appendChild(children[i]); | |
374 filledHeight += children[i].nodeHeight(); | |
375 } | |
376 ++i; | |
377 } | |
378 | |
379 var bottomPadding = 0; | |
380 while (i < children.length) { | |
381 bottomPadding += children[i].nodeHeight(); | |
382 ++i; | |
383 } | |
384 | |
385 this._topPadding.setHeight(topPadding); | |
386 this._bottomPadding.setHeight(bottomPadding); | |
387 | 353 |
388 if (selectedNode) { | 354 if (selectedNode) { |
389 if (selectedNode.parent) { | 355 if (selectedNode.parent) { |
390 selectedNode.select(true); | 356 selectedNode.select(true); |
391 } else { | 357 } else { |
392 // Keep selection even if the node is not in the current viewpor t. | 358 // Keep selection even if the node is not in the current viewpor t. |
393 this.selectedNode = selectedNode; | 359 this.selectedNode = selectedNode; |
394 } | 360 } |
395 } | 361 } |
396 }, | 362 }, |
397 | 363 |
398 /** | 364 /** |
365 * @param {!WebInspector.DataGridNode} parentNode | |
366 * @param {number} topBound | |
367 * @param {number} bottomBound | |
368 * @return {number} | |
369 */ | |
370 _addVisibleNodes: function(parentNode, topBound, bottomBound) | |
371 { | |
372 if (!parentNode.expanded) | |
373 return 0; | |
374 | |
375 var children = this.allChildren(parentNode); | |
376 var topPadding = 0; | |
377 // Iterate over invisible nodes beyond the upper bound of viewport. | |
378 // Do not insert them into the grid, but count their total height. | |
379 for (var i = 0; i < children.length; ++i) { | |
380 var newTop = topPadding + this._nodeHeight(children[i]); | |
381 if (newTop > topBound) | |
382 break; | |
383 topPadding = newTop; | |
384 } | |
385 | |
386 // Put visible nodes into the data grid. | |
387 var position = topPadding; | |
388 for (; i < children.length && position < bottomBound; ++i) { | |
389 var child = children[i]; | |
390 var hasChildren = child.hasChildren; | |
391 child.removeChildren(); | |
392 child.hasChildren = hasChildren; | |
393 child._shouldRefreshChildren = true; | |
aandrey
2014/03/05 15:24:28
I think this will result in going to backend for t
alph
2014/03/05 15:40:54
Removed. It was a leftover, I do not actually need
| |
394 child.revealed = true; | |
395 parentNode.appendChild(child); | |
396 position += WebInspector.DataGridNode.NodeShallowHeight; | |
397 position += this._addVisibleNodes(child, topBound - position, bottom Bound - position); | |
398 } | |
399 | |
400 // Count the invisible nodes beyond the bottom bound of the viewport. | |
401 var bottomPadding = 0; | |
402 for (; i < children.length; ++i) | |
403 bottomPadding += this._nodeHeight(children[i]); | |
404 | |
405 this._topPaddingHeight += topPadding; | |
406 this._bottomPaddingHeight += bottomPadding; | |
407 return position + bottomPadding; | |
408 }, | |
409 | |
410 /** | |
411 * @param {!WebInspector.HeapSnapshotGridNode} node | |
412 * @return {number} | |
413 */ | |
414 _nodeHeight: function(node) | |
415 { | |
416 if (!node.revealed) | |
417 return 0; | |
418 var result = WebInspector.DataGridNode.NodeShallowHeight; | |
419 if (!node.expanded) | |
420 return result; | |
421 var children = this.allChildren(node); | |
422 for (var i = 0; i < children.length; i++) | |
423 result += this._nodeHeight(children[i]); | |
424 return result; | |
425 }, | |
426 | |
427 /** | |
399 * @override | 428 * @override |
400 * @return {?Element} | 429 * @return {?Element} |
401 */ | 430 */ |
402 defaultAttachLocation: function() | 431 defaultAttachLocation: function() |
403 { | 432 { |
404 return this._bottomPadding.element; | 433 return this._bottomPadding.element; |
405 }, | 434 }, |
406 | 435 |
436 /** | |
437 * @param {!WebInspector.HeapSnapshotGridNode} nodeToReveal | |
438 */ | |
407 _revealTopLevelNode: function(nodeToReveal) | 439 _revealTopLevelNode: function(nodeToReveal) |
408 { | 440 { |
409 var children = this.allChildren(this.rootNode()); | 441 var children = this.allChildren(this.rootNode()); |
410 | |
411 var topPadding = 0; | 442 var topPadding = 0; |
412 for (var i = 0; i < children.length; ++i) { | 443 for (var i = 0; i < children.length; ++i) { |
413 if (children[i] === nodeToReveal) | 444 if (children[i] === nodeToReveal) |
414 break; | 445 break; |
415 if (children[i].revealed) { | 446 if (children[i].revealed) { |
416 var newTop = topPadding + children[i].nodeHeight(); | 447 var newTop = topPadding + children[i].nodeHeight(); |
417 topPadding = newTop; | 448 topPadding = newTop; |
418 } | 449 } |
419 } | 450 } |
420 | 451 this.updateVisibleNodes(topPadding); |
421 this._addVisibleNodes(this.rootNode(), i, 0, topPadding); | |
422 }, | 452 }, |
423 | 453 |
424 /** | 454 /** |
425 * @param {!WebInspector.DataGridNode} parent | 455 * @param {!WebInspector.DataGridNode} parent |
426 * @return {!Array.<!WebInspector.DataGridNode>} | 456 * @return {!Array.<!WebInspector.HeapSnapshotGridNode>} |
427 */ | 457 */ |
428 allChildren: function(parent) | 458 allChildren: function(parent) |
429 { | 459 { |
430 return parent._allChildren || (parent._allChildren = []); | 460 return parent._allChildren || (parent._allChildren = []); |
431 }, | 461 }, |
432 | 462 |
433 /** | 463 /** |
434 * @param {!WebInspector.DataGridNode} parent | 464 * @param {!WebInspector.DataGridNode} parent |
435 * @param {!WebInspector.DataGridNode} node | 465 * @param {!WebInspector.DataGridNode} node |
436 */ | 466 */ |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1100 urlElement.style.maxWidth = "75%"; | 1130 urlElement.style.maxWidth = "75%"; |
1101 cell.insertBefore(urlElement, cell.firstChild); | 1131 cell.insertBefore(urlElement, cell.firstChild); |
1102 } | 1132 } |
1103 | 1133 |
1104 return cell; | 1134 return cell; |
1105 }, | 1135 }, |
1106 | 1136 |
1107 __proto__: WebInspector.DataGridNode.prototype | 1137 __proto__: WebInspector.DataGridNode.prototype |
1108 } | 1138 } |
1109 | 1139 |
OLD | NEW |