Changeset 69010 in webkit
- Timestamp:
- Oct 4, 2010 6:42:42 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r69009 r69010 1 2010-10-04 Pavel Feldman <pfeldman@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: add total bar to the network panel. 6 https://bugs.webkit.org/show_bug.cgi?id=47081 7 8 * English.lproj/localizedStrings.js: 9 * inspector/front-end/ConsoleView.js: 10 (WebInspector.ConsoleView.createDividerElement): 11 * inspector/front-end/DataGrid.js: 12 (WebInspector.DataGrid.prototype.removeChild): 13 (WebInspector.DataGrid.prototype.sortNodes): 14 (WebInspector.DataGrid.prototype._clickInHeaderCell): 15 (WebInspector.DataGrid.prototype.markColumnAsSortedBy): 16 * inspector/front-end/NetworkPanel.js: 17 (WebInspector.NetworkPanel): 18 (WebInspector.NetworkPanel.prototype.resize): 19 (WebInspector.NetworkPanel.prototype._positionSummaryBar): 20 (WebInspector.NetworkPanel.prototype._createTimelineGrid): 21 (WebInspector.NetworkPanel.prototype._createSortingFunctions): 22 (WebInspector.NetworkPanel.prototype._sortItems): 23 (WebInspector.NetworkPanel.prototype._sortByTimeline): 24 (WebInspector.NetworkPanel.prototype._createFilterStatusBarItems): 25 (WebInspector.NetworkPanel.prototype._createSummaryBar): 26 (WebInspector.NetworkPanel.prototype._updateSummaryBar): 27 (WebInspector.NetworkPanel.prototype._updateFilter): 28 (WebInspector.NetworkPanel.prototype.show): 29 (WebInspector.NetworkPanel.prototype.refresh): 30 (WebInspector.NetworkPanel.prototype.reset): 31 (WebInspector.NetworkDataGridNode.SizeComparator): 32 (WebInspector.NetworkDataGridNode.ResourcePropertyComparator): 33 (WebInspector.NetworkTotalGridNode): 34 (WebInspector.NetworkTotalGridNode.prototype.createCells): 35 * inspector/front-end/ResourcesPanel.js: 36 (WebInspector.ResourcesPanel.prototype.createFilterPanel): 37 * inspector/front-end/inspector.css: 38 (.scope-bar-divider): 39 * inspector/front-end/networkPanel.css: 40 (.network-timeline-grid): 41 (.network-summary-bar): 42 (.network-summary-bar-bottom): 43 (.data-grid td .network-summary-bar): 44 1 45 2010-09-28 Luiz Agostini <luiz.agostini@openbossa.org> 2 46 -
trunk/WebCore/inspector/front-end/ConsoleView.js
r67852 r69010 65 65 function createDividerElement() { 66 66 var dividerElement = document.createElement("div"); 67 dividerElement.addStyleClass(" divider");67 dividerElement.addStyleClass("scope-bar-divider"); 68 68 this.filterBarElement.appendChild(dividerElement); 69 69 } -
trunk/WebCore/inspector/front-end/DataGrid.js
r68778 r69010 482 482 483 483 child.deselect(); 484 child._detach(); 484 485 485 486 this.children.remove(child, true); … … 542 543 }, 543 544 544 sortNodes: function(comparator, descending)545 sortNodes: function(comparator, reverseMode) 545 546 { 546 547 function comparatorWrapper(a, b) 547 548 { 549 if (a._dataGridNode._data.summaryRow) 550 return 1; 551 if (b._dataGridNode._data.summaryRow) 552 return -1; 553 548 554 var aDataGirdNode = a._dataGridNode; 549 555 var bDataGirdNode = b._dataGridNode; 550 if (!aDataGirdNode) 551 return 1; // Filler row. 552 if (!bDataGirdNode) 553 return -1; // Filler row. 554 return descending ? comparator(bDataGirdNode, aDataGirdNode) : comparator(aDataGirdNode, bDataGirdNode); 556 return reverseMode ? comparator(bDataGirdNode, aDataGirdNode) : comparator(aDataGirdNode, bDataGirdNode); 555 557 } 556 558 … … 560 562 561 563 var childNodes = tbody.childNodes; 562 var sortedNodes = Array.prototype.slice.call(childNodes); 563 sortedNodes.sort(comparatorWrapper.bind(this)); 564 565 var sortedNodesLength = sortedNodes.length; 564 var fillerRow = childNodes[childNodes.length - 1]; 565 566 var sortedRows = Array.prototype.slice.call(childNodes, 0, childNodes.length - 1); 567 sortedRows.sort(comparatorWrapper.bind(this)); 568 var sortedRowsLength = sortedRows.length; 569 566 570 tbody.removeChildren(); 567 for (var i = 0; i < sortedNodesLength; ++i) { 568 var node = sortedNodes[i]; 569 tbody.appendChild(node); 570 } 571 var previousSiblingNode = null; 572 for (var i = 0; i < sortedRowsLength; ++i) { 573 var row = sortedRows[i]; 574 var node = row._dataGridNode; 575 node.previousSibling = previousSiblingNode; 576 if (previousSiblingNode) 577 previousSiblingNode.nextSibling = node; 578 tbody.appendChild(row); 579 previousSiblingNode = node; 580 } 581 if (previousSiblingNode) 582 previousSiblingNode.nextSibling = null; 583 584 tbody.appendChild(fillerRow); 571 585 tbodyParent.appendChild(tbody); 572 586 }, … … 681 695 var sortOrder = this.sortOrder; 682 696 683 if (this._sortColumnCell) { 684 this._sortColumnCell.removeStyleClass("sort-ascending"); 685 this._sortColumnCell.removeStyleClass("sort-descending"); 686 } 697 if (this._sortColumnCell) 698 this._sortColumnCell.removeMatchingStyleClasses("sort-\\w+"); 687 699 688 700 if (cell == this._sortColumnCell) { … … 702 714 markColumnAsSortedBy: function(columnIdentifier, sortOrder) 703 715 { 704 if (this._sortColumnCell) { 705 this._sortColumnCell.removeStyleClass("sort-ascending"); 706 this._sortColumnCell.removeStyleClass("sort-descending"); 707 } 716 if (this._sortColumnCell) 717 this._sortColumnCell.removeMatchingStyleClasses("sort-\\w+"); 708 718 this._sortColumnCell = this._headerTableHeaders[columnIdentifier]; 709 719 this._sortColumnCell.addStyleClass("sort-" + sortOrder); -
trunk/WebCore/inspector/front-end/NetworkPanel.js
r68778 r69010 39 39 this._mainResourceDOMContentTime = -1; 40 40 41 this._categories = WebInspector.resourceCategories; 42 41 43 this._viewsContainerElement = document.createElement("div"); 42 44 this._viewsContainerElement.id = "network-views"; … … 44 46 45 47 this._createSortingFunctions(); 48 this._createTable(); 46 49 this._createTimelineGrid(); 47 this._createTable();48 50 this._createStatusbarButtons(); 49 this._createFilterPanel(); 51 this._createFilterStatusBarItems(); 52 this._createSummaryBar(); 50 53 51 54 this._popoverHelper = new WebInspector.PopoverHelper(this.element, this._getPopoverAnchor.bind(this), this._showPopover.bind(this), true); … … 80 83 WebInspector.Panel.prototype.resize.call(this); 81 84 this._dataGrid.updateWidths(); 85 this._positionSummaryBar(); 86 }, 87 88 _positionSummaryBar: function() 89 { 90 // Position the total bar. 91 const rowHeight = 22; 92 const summaryBarHeight = 22; 93 var offsetHeight = this.element.offsetHeight; 94 95 var parentElement = this._summaryBarElement.parentElement; 96 97 if (this._summaryBarElement.parentElement !== this.element && offsetHeight > (this._dataGrid.children.length - 1) * rowHeight + summaryBarHeight) { 98 this._dataGrid.removeChild(this._summaryBarRowNode); 99 this._summaryBarElement.addStyleClass("network-summary-bar-bottom"); 100 delete this._summaryBarRowNode; 101 this.element.appendChild(this._summaryBarElement); 102 this._dataGrid.element.style.bottom = "20px"; 103 return; 104 } 105 106 if (!this._summaryBarRowNode && offsetHeight - summaryBarHeight < this._dataGrid.children.length * rowHeight) { 107 this._summaryBarRowNode = new WebInspector.NetworkTotalGridNode(this._summaryBarElement); 108 this._summaryBarElement.removeStyleClass("network-summary-bar-bottom"); 109 this._dataGrid.appendChild(this._summaryBarRowNode); 110 this._dataGrid.element.style.bottom = 0; 111 this._sortItems(); 112 } 82 113 }, 83 114 … … 86 117 this._timelineGrid = new WebInspector.TimelineGrid(); 87 118 this._timelineGrid.element.addStyleClass("network-timeline-grid"); 88 this. element.appendChild(this._timelineGrid.element);119 this._dataGrid.element.appendChild(this._timelineGrid.element); 89 120 }, 90 121 … … 153 184 var option = document.createElement("option"); 154 185 option.value = "startTime"; 186 option.label = WebInspector.UIString("Timeline"); 187 timelineSorting.appendChild(option); 188 189 option = document.createElement("option"); 190 option.value = "startTime"; 155 191 option.label = WebInspector.UIString("Start Time"); 156 192 timelineSorting.appendChild(option); 157 193 158 varoption = document.createElement("option");194 option = document.createElement("option"); 159 195 option.value = "responseTime"; 160 196 option.label = WebInspector.UIString("Response Time"); 161 197 timelineSorting.appendChild(option); 162 198 163 varoption = document.createElement("option");199 option = document.createElement("option"); 164 200 option.value = "endTime"; 165 201 option.label = WebInspector.UIString("End Time"); 166 202 timelineSorting.appendChild(option); 167 203 168 varoption = document.createElement("option");204 option = document.createElement("option"); 169 205 option.value = "duration"; 170 206 option.label = WebInspector.UIString("Duration"); 171 207 timelineSorting.appendChild(option); 172 208 173 varoption = document.createElement("option");209 option = document.createElement("option"); 174 210 option.value = "latency"; 175 211 option.label = WebInspector.UIString("Latency"); … … 181 217 timelineSorting.addEventListener("click", function(event) { event.stopPropagation() }, false); 182 218 timelineSorting.addEventListener("change", this._sortByTimeline.bind(this), false); 219 this._timelineSortSelector = timelineSorting; 183 220 }, 184 221 … … 187 224 this._sortingFunctions = {}; 188 225 this._sortingFunctions.name = WebInspector.NetworkDataGridNode.NameComparator; 189 this._sortingFunctions.method = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "method", true);190 this._sortingFunctions.status = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "statusCode", true);191 this._sortingFunctions.type = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "mimeType", true);226 this._sortingFunctions.method = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "method", false); 227 this._sortingFunctions.status = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "statusCode", false); 228 this._sortingFunctions.type = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "mimeType", false); 192 229 this._sortingFunctions.size = WebInspector.NetworkDataGridNode.SizeComparator; 193 this._sortingFunctions.time = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "duration", true);194 this._sortingFunctions.timeline = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "startTime", true);195 this._sortingFunctions.startTime = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "startTime", true);196 this._sortingFunctions.endTime = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "endTime", true);197 this._sortingFunctions.responseTime = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "responseReceivedTime", true);198 this._sortingFunctions.duration = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "duration", false);199 this._sortingFunctions.latency = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "latency", false);230 this._sortingFunctions.time = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "duration", false); 231 this._sortingFunctions.timeline = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "startTime", false); 232 this._sortingFunctions.startTime = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "startTime", false); 233 this._sortingFunctions.endTime = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "endTime", false); 234 this._sortingFunctions.responseTime = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "responseReceivedTime", false); 235 this._sortingFunctions.duration = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "duration", true); 236 this._sortingFunctions.latency = WebInspector.NetworkDataGridNode.ResourcePropertyComparator.bind(null, "latency", true); 200 237 201 238 var timeCalculator = new WebInspector.NetworkTransferTimeCalculator(); 202 239 var durationCalculator = new WebInspector.NetworkTransferDurationCalculator(); 240 203 241 this._calculators = {}; 242 this._calculators.timeline = timeCalculator; 204 243 this._calculators.startTime = timeCalculator; 205 244 this._calculators.endTime = timeCalculator; … … 209 248 }, 210 249 211 _sortByTimeline: function(e)212 {213 var options = e.target.options;214 var selectedOption = options[e.target.selectedIndex];215 var value = selectedOption.value;216 217 var sortingFunction = this._sortingFunctions[value];218 this._dataGrid.sortNodes(sortingFunction);219 this.calculator = this._calculators[value];220 this._dataGrid.markColumnAsSortedBy("timeline", "ascending");221 },222 223 250 _sortItems: function() 224 251 { 225 252 var columnIdentifier = this._dataGrid.sortColumnIdentifier; 253 if (columnIdentifier === "timeline") { 254 this._sortByTimeline(); 255 return; 256 } 226 257 var sortingFunction = this._sortingFunctions[columnIdentifier]; 227 258 if (!sortingFunction) 228 259 return; 229 260 this._dataGrid.sortNodes(sortingFunction, this._dataGrid.sortOrder === "descending"); 230 }, 231 232 _createFilterPanel: function() 261 this._timelineSortSelector.selectedIndex = 0; 262 }, 263 264 _sortByTimeline: function() 265 { 266 if (this._timelineSortSelector.selectedIndex === 0) 267 return; // Do nothing - this is 'Timeline' caption. 268 var selectedOption = this._timelineSortSelector[this._timelineSortSelector.selectedIndex]; 269 var value = selectedOption.value; 270 271 var sortingFunction = this._sortingFunctions[value]; 272 this._dataGrid.sortNodes(sortingFunction); 273 this.calculator = this._calculators[value]; 274 if (this.calculator.startAtZero) 275 this._timelineGrid.hideEventDividers(); 276 else 277 this._timelineGrid.showEventDividers(); 278 this._dataGrid.markColumnAsSortedBy("timeline", "ascending"); 279 }, 280 281 _createFilterStatusBarItems: function() 233 282 { 234 283 var filterBarElement = document.createElement("div"); … … 252 301 // Add a divider 253 302 var dividerElement = document.createElement("div"); 254 dividerElement.addStyleClass(" divider");303 dividerElement.addStyleClass("scope-bar-divider"); 255 304 filterBarElement.appendChild(dividerElement); 256 305 257 var categories = { 258 documents: WebInspector.UIString("Documents"), 259 stylesheets: WebInspector.UIString("Stylesheets"), 260 images: WebInspector.UIString("Images"), 261 scripts: WebInspector.UIString("Scripts"), 262 xhr: WebInspector.UIString("XHR"), 263 fonts: WebInspector.UIString("Fonts"), 264 other: WebInspector.UIString("Other") 265 }; 266 for (var category in categories) 267 createFilterElement.call(this, category, categories[category]); 306 for (var category in this._categories) 307 createFilterElement.call(this, category, this._categories[category].title); 268 308 this._filterBarElement = filterBarElement; 309 }, 310 311 _createSummaryBar: function() 312 { 313 this._summaryBarElement = document.createElement("div"); 314 this._summaryBarElement.className = "network-summary-bar"; 315 this.element.appendChild(this._summaryBarElement); 316 }, 317 318 _updateSummaryBar: function() 319 { 320 this._positionSummaryBar(); // Grid is growing. 321 var numRequests = this._resources.length; 322 var transferSize = 0; 323 var baseTime = -1; 324 var maxTime = -1; 325 for (var i = 0; i < this._resources.length; ++i) { 326 var resource = this._resources[i]; 327 transferSize += resource.cached ? 0 : resource.transferSize; 328 if (resource === WebInspector.mainResource) 329 baseTime = resource.startTime; 330 if (resource.endTime > maxTime) 331 maxTime = resource.endTime; 332 } 333 var text = String.sprintf(WebInspector.UIString("%d requests"), numRequests); 334 text += " \u2758 " + String.sprintf(WebInspector.UIString("%s transferred"), Number.bytesToString(transferSize)); 335 if (baseTime !== -1 && this._mainResourceLoadTime !== -1 && this._mainResourceDOMContentTime !== -1) { 336 text += " \u2758 " + String.sprintf(WebInspector.UIString("%s (onload: %s, DOMContentLoaded: %s)"), 337 Number.secondsToString(maxTime - baseTime), 338 Number.secondsToString(this._mainResourceLoadTime - baseTime), 339 Number.secondsToString(this._mainResourceDOMContentTime - baseTime)); 340 } 341 this._summaryBarElement.textContent = text; 269 342 }, 270 343 … … 289 362 290 363 this._filter(e.target, selectMultiple); 291 292 // When we are updating our filtering, scroll to the top so we don't end up293 // in blank graph under all the resources.294 this.containerElement.scrollTop = 0;295 364 296 365 var searchField = document.getElementById("search"); … … 530 599 } 531 600 this._dataGrid.updateWidths(); 601 this._positionSummaryBar(); 532 602 }, 533 603 … … 617 687 this._staleResources = []; 618 688 this._sortItems(); 689 this._updateSummaryBar(); 619 690 this._dataGrid.updateWidths(); 620 691 }, … … 658 729 659 730 this._dataGrid.removeChildren(); 731 delete this._summaryBarRowNode; 660 732 this._updateDividersIfNeeded(true); 661 733 // End reset timeline. … … 1225 1297 WebInspector.NetworkTransferDurationCalculator.prototype.__proto__ = WebInspector.NetworkTimeCalculator.prototype; 1226 1298 1227 1228 1299 WebInspector.NetworkDataGridNode = function(resource) 1229 1300 { … … 1514 1585 WebInspector.NetworkDataGridNode.SizeComparator = function(a, b) 1515 1586 { 1516 if (a._resource.cached === b._resource.cached) 1517 return 0; 1518 if (b._resource.cached) 1587 if (b._resource.cached && !a._resource.cached) 1519 1588 return 1; 1520 if (a._resource.cached )1589 if (a._resource.cached && !b._resource.cached) 1521 1590 return -1; 1522 1591 … … 1524 1593 return 0; 1525 1594 1526 return a._resource.resourceSize > b._resource.resourceSize ? 1 : -1;1527 } 1528 1529 WebInspector.NetworkDataGridNode.ResourcePropertyComparator = function(propertyName, ascending, a, b)1595 return a._resource.resourceSize - b._resource.resourceSize; 1596 } 1597 1598 WebInspector.NetworkDataGridNode.ResourcePropertyComparator = function(propertyName, revert, a, b) 1530 1599 { 1531 1600 var aValue = a._resource[propertyName]; 1532 1601 var bValue = b._resource[propertyName]; 1533 1534 1602 if (aValue > bValue) 1535 return ascending ? 1 : -1;1603 return revert ? -1 : 1; 1536 1604 if (bValue > aValue) 1537 return ascending ? -1 :1;1605 return revert ? 1 : -1; 1538 1606 return 0; 1539 1607 } 1540 1608 1541 1609 WebInspector.NetworkDataGridNode.prototype.__proto__ = WebInspector.DataGridNode.prototype; 1610 1611 WebInspector.NetworkTotalGridNode = function(element) 1612 { 1613 this._summaryBarElement = element; 1614 WebInspector.DataGridNode.call(this, {summaryRow: true}); 1615 } 1616 1617 WebInspector.NetworkTotalGridNode.prototype = { 1618 createCells: function() 1619 { 1620 var td = document.createElement("td"); 1621 td.setAttribute("colspan", 7); 1622 td.className = "network-summary"; 1623 td.appendChild(this._summaryBarElement); 1624 this._element.appendChild(td); 1625 } 1626 } 1627 1628 WebInspector.NetworkTotalGridNode.prototype.__proto__ = WebInspector.DataGridNode.prototype; -
trunk/WebCore/inspector/front-end/ResourcesPanel.js
r68394 r69010 143 143 // Add a divider 144 144 var dividerElement = document.createElement("div"); 145 dividerElement.addStyleClass(" divider");145 dividerElement.addStyleClass("scope-bar-divider"); 146 146 this.filterBarElement.appendChild(dividerElement); 147 147 -
trunk/WebCore/inspector/front-end/inspector.css
r68778 r69010 2586 2586 } 2587 2587 2588 .scope-bar .divider {2588 .scope-bar-divider { 2589 2589 margin: 1px 9px 0 8px; 2590 2590 background-color: rgba(0, 0, 0, 0.4); -
trunk/WebCore/inspector/front-end/networkPanel.css
r68778 r69010 379 379 left: 0; 380 380 right: 0; 381 pointer-events: none; 381 382 } 382 383 … … 464 465 display: table-row; 465 466 } 467 468 /* Summary */ 469 470 .network-summary-bar { 471 background-color: rgb(101, 111, 130); 472 color: white; 473 height: 20px; 474 font-size: 11px; 475 font-weight: bold; 476 padding-top: 1px; 477 padding-left: 10px; 478 z-index: 2000; 479 white-space: pre; 480 } 481 482 .network-summary-bar-bottom { 483 position: absolute; 484 bottom: 0; 485 left: 0; 486 right: 0; 487 padding-top: 3px; 488 } 489 490 .data-grid td .network-summary-bar { 491 white-space: pre; 492 } 493 494 .network.panel .data-grid td.network-summary { 495 padding: 0; 496 }
Note: See TracChangeset
for help on using the changeset viewer.