| 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 20 matching lines...) Expand all Loading... |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @extends {WebInspector.PanelWithSidebar} | 33 * @extends {WebInspector.PanelWithSidebar} |
| 34 */ | 34 */ |
| 35 WebInspector.AuditsPanel = function() | 35 WebInspector.AuditsPanel = function() |
| 36 { | 36 { |
| 37 WebInspector.PanelWithSidebar.call(this, "audits"); | 37 WebInspector.PanelWithSidebar.call(this, "audits"); |
| 38 this.registerRequiredCSS("ui/panelEnablerView.css"); | 38 this.registerRequiredCSS("ui/panelEnablerView.css"); |
| 39 this.registerRequiredCSS("audits/auditsPanel.css"); | 39 this.registerRequiredCSS("audits/auditsPanel.css"); |
| 40 | 40 |
| 41 var sidebarTree = new TreeOutline(); | 41 var sidebarTree = new TreeOutlineInShadow(); |
| 42 sidebarTree.element.classList.add("sidebar-tree"); | 42 sidebarTree.registerRequiredCSS("audits/auditsSidebarTree.css"); |
| 43 this.panelSidebarElement().appendChild(sidebarTree.element); | 43 this.panelSidebarElement().appendChild(sidebarTree.element); |
| 44 this.setDefaultFocusedElement(sidebarTree.element); | 44 this.setDefaultFocusedElement(sidebarTree.element); |
| 45 | 45 |
| 46 this.auditsTreeElement = new WebInspector.SidebarSectionTreeElement(""); | 46 this._auditsItemTreeElement = new WebInspector.AuditsSidebarTreeElement(this
); |
| 47 sidebarTree.appendChild(this.auditsTreeElement); | 47 sidebarTree.appendChild(this._auditsItemTreeElement); |
| 48 this.auditsTreeElement.listItemElement.classList.add("hidden"); | |
| 49 | 48 |
| 50 this.auditsItemTreeElement = new WebInspector.AuditsSidebarTreeElement(this)
; | 49 this._auditResultsTreeElement = new TreeElement(WebInspector.UIString("RESUL
TS"), true); |
| 51 this.auditsTreeElement.appendChild(this.auditsItemTreeElement); | 50 this._auditResultsTreeElement.selectable = false; |
| 52 | 51 this._auditResultsTreeElement.listItemElement.classList.add("audits-sidebar-
results"); |
| 53 this.auditResultsTreeElement = new WebInspector.SidebarSectionTreeElement(We
bInspector.UIString("RESULTS")); | 52 this._auditResultsTreeElement.expand(); |
| 54 sidebarTree.appendChild(this.auditResultsTreeElement); | 53 sidebarTree.appendChild(this._auditResultsTreeElement); |
| 55 this.auditResultsTreeElement.expand(); | |
| 56 | 54 |
| 57 this._constructCategories(); | 55 this._constructCategories(); |
| 58 | 56 |
| 59 this._auditController = new WebInspector.AuditController(this); | 57 this._auditController = new WebInspector.AuditController(this); |
| 60 this._launcherView = new WebInspector.AuditLauncherView(this._auditControlle
r); | 58 this._launcherView = new WebInspector.AuditLauncherView(this._auditControlle
r); |
| 61 for (var id in this.categoriesById) | 59 for (var id in this.categoriesById) |
| 62 this._launcherView.addCategory(this.categoriesById[id]); | 60 this._launcherView.addCategory(this.categoriesById[id]); |
| 63 | 61 |
| 64 var extensionCategories = WebInspector.extensionServer.auditCategories(); | 62 var extensionCategories = WebInspector.extensionServer.auditCategories(); |
| 65 for (var i = 0; i < extensionCategories.length; ++i) { | 63 for (var i = 0; i < extensionCategories.length; ++i) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } | 105 } |
| 108 }, | 106 }, |
| 109 | 107 |
| 110 /** | 108 /** |
| 111 * @param {string} mainResourceURL | 109 * @param {string} mainResourceURL |
| 112 * @param {!Array.<!WebInspector.AuditCategoryResult>} results | 110 * @param {!Array.<!WebInspector.AuditCategoryResult>} results |
| 113 */ | 111 */ |
| 114 auditFinishedCallback: function(mainResourceURL, results) | 112 auditFinishedCallback: function(mainResourceURL, results) |
| 115 { | 113 { |
| 116 var ordinal = 1; | 114 var ordinal = 1; |
| 117 for (var child of this.auditResultsTreeElement.children()) { | 115 for (var child of this._auditResultsTreeElement.children()) { |
| 118 if (child.mainResourceURL === mainResourceURL) | 116 if (child.mainResourceURL === mainResourceURL) |
| 119 ordinal++; | 117 ordinal++; |
| 120 } | 118 } |
| 121 | 119 |
| 122 var resultTreeElement = new WebInspector.AuditResultSidebarTreeElement(t
his, results, mainResourceURL, ordinal); | 120 var resultTreeElement = new WebInspector.AuditResultSidebarTreeElement(t
his, results, mainResourceURL, ordinal); |
| 123 this.auditResultsTreeElement.appendChild(resultTreeElement); | 121 this._auditResultsTreeElement.appendChild(resultTreeElement); |
| 124 resultTreeElement.revealAndSelect(); | 122 resultTreeElement.revealAndSelect(); |
| 125 }, | 123 }, |
| 126 | 124 |
| 127 /** | 125 /** |
| 128 * @param {!Array.<!WebInspector.AuditCategoryResult>} categoryResults | 126 * @param {!Array.<!WebInspector.AuditCategoryResult>} categoryResults |
| 129 */ | 127 */ |
| 130 showResults: function(categoryResults) | 128 showResults: function(categoryResults) |
| 131 { | 129 { |
| 132 if (!categoryResults._resultLocation) { | 130 if (!categoryResults._resultLocation) { |
| 133 categoryResults.sort((a, b) => (a.title || "").localeCompare(b.title
|| "")); | 131 categoryResults.sort((a, b) => (a.title || "").localeCompare(b.title
|| "")); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 160 this._visibleView = x; | 158 this._visibleView = x; |
| 161 | 159 |
| 162 if (x) | 160 if (x) |
| 163 this.splitWidget().setMainWidget(x); | 161 this.splitWidget().setMainWidget(x); |
| 164 }, | 162 }, |
| 165 | 163 |
| 166 wasShown: function() | 164 wasShown: function() |
| 167 { | 165 { |
| 168 WebInspector.Panel.prototype.wasShown.call(this); | 166 WebInspector.Panel.prototype.wasShown.call(this); |
| 169 if (!this._visibleView) | 167 if (!this._visibleView) |
| 170 this.auditsItemTreeElement.select(); | 168 this._auditsItemTreeElement.select(); |
| 171 }, | 169 }, |
| 172 | 170 |
| 173 clearResults: function() | 171 clearResults: function() |
| 174 { | 172 { |
| 175 this.auditsItemTreeElement.revealAndSelect(); | 173 this._auditsItemTreeElement.revealAndSelect(); |
| 176 this.auditResultsTreeElement.removeChildren(); | 174 this._auditResultsTreeElement.removeChildren(); |
| 177 }, | 175 }, |
| 178 | 176 |
| 179 /** | 177 /** |
| 180 * @param {!WebInspector.Event} event | 178 * @param {!WebInspector.Event} event |
| 181 */ | 179 */ |
| 182 _extensionAuditCategoryAdded: function(event) | 180 _extensionAuditCategoryAdded: function(event) |
| 183 { | 181 { |
| 184 var category = /** @type {!WebInspector.ExtensionAuditCategory} */ (even
t.data); | 182 var category = /** @type {!WebInspector.ExtensionAuditCategory} */ (even
t.data); |
| 185 this.addCategory(new WebInspector.AuditExtensionCategory(category.extens
ionOrigin, category.id, category.displayName, category.ruleCount)); | 183 this.addCategory(new WebInspector.AuditExtensionCategory(category.extens
ionOrigin, category.id, category.displayName, category.ruleCount)); |
| 186 }, | 184 }, |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 | 457 |
| 460 var formattedResult = String.format(format, substitutions, this._formatt
ers, fragment, append).formattedResult; | 458 var formattedResult = String.format(format, substitutions, this._formatt
ers, fragment, append).formattedResult; |
| 461 if (formattedResult instanceof Node) | 459 if (formattedResult instanceof Node) |
| 462 formattedResult.normalize(); | 460 formattedResult.normalize(); |
| 463 return this.addChild(formattedResult); | 461 return this.addChild(formattedResult); |
| 464 } | 462 } |
| 465 } | 463 } |
| 466 | 464 |
| 467 /** | 465 /** |
| 468 * @constructor | 466 * @constructor |
| 469 * @extends {WebInspector.SidebarTreeElement} | 467 * @extends {TreeElement} |
| 470 * @param {!WebInspector.AuditsPanel} panel | 468 * @param {!WebInspector.AuditsPanel} panel |
| 471 */ | 469 */ |
| 472 WebInspector.AuditsSidebarTreeElement = function(panel) | 470 WebInspector.AuditsSidebarTreeElement = function(panel) |
| 473 { | 471 { |
| 472 TreeElement.call(this, WebInspector.UIString("Audits"), false); |
| 473 this.selectable = true; |
| 474 this._panel = panel; | 474 this._panel = panel; |
| 475 this.small = false; | 475 this.listItemElement.classList.add("audits-sidebar-header"); |
| 476 WebInspector.SidebarTreeElement.call(this, "audits-sidebar-tree-item", WebIn
spector.UIString("Audits")); | 476 this.listItemElement.insertBefore(createElementWithClass("div", "icon"), thi
s.listItemElement.firstChild); |
| 477 } | 477 } |
| 478 | 478 |
| 479 WebInspector.AuditsSidebarTreeElement.prototype = { | 479 WebInspector.AuditsSidebarTreeElement.prototype = { |
| 480 onattach: function() | |
| 481 { | |
| 482 WebInspector.SidebarTreeElement.prototype.onattach.call(this); | |
| 483 }, | |
| 484 | |
| 485 /** | 480 /** |
| 486 * @override | 481 * @override |
| 487 * @return {boolean} | 482 * @return {boolean} |
| 488 */ | 483 */ |
| 489 onselect: function() | 484 onselect: function() |
| 490 { | 485 { |
| 491 this._panel.showLauncherView(); | 486 this._panel.showLauncherView(); |
| 492 return true; | 487 return true; |
| 493 }, | 488 }, |
| 494 | 489 |
| 495 get selectable() | 490 __proto__: TreeElement.prototype |
| 496 { | |
| 497 return true; | |
| 498 }, | |
| 499 | |
| 500 refresh: function() | |
| 501 { | |
| 502 this.refreshTitles(); | |
| 503 }, | |
| 504 | |
| 505 __proto__: WebInspector.SidebarTreeElement.prototype | |
| 506 } | 491 } |
| 507 | 492 |
| 508 /** | 493 /** |
| 509 * @constructor | 494 * @constructor |
| 510 * @extends {WebInspector.SidebarTreeElement} | 495 * @extends {TreeElement} |
| 511 * @param {!WebInspector.AuditsPanel} panel | 496 * @param {!WebInspector.AuditsPanel} panel |
| 512 * @param {!Array.<!WebInspector.AuditCategoryResult>} results | 497 * @param {!Array.<!WebInspector.AuditCategoryResult>} results |
| 513 * @param {string} mainResourceURL | 498 * @param {string} mainResourceURL |
| 514 * @param {number} ordinal | 499 * @param {number} ordinal |
| 515 */ | 500 */ |
| 516 WebInspector.AuditResultSidebarTreeElement = function(panel, results, mainResour
ceURL, ordinal) | 501 WebInspector.AuditResultSidebarTreeElement = function(panel, results, mainResour
ceURL, ordinal) |
| 517 { | 502 { |
| 503 TreeElement.call(this, String.sprintf("%s (%d)", mainResourceURL, ordinal),
false); |
| 504 this.selectable = true; |
| 518 this._panel = panel; | 505 this._panel = panel; |
| 519 this.results = results; | 506 this.results = results; |
| 520 this.mainResourceURL = mainResourceURL; | 507 this.mainResourceURL = mainResourceURL; |
| 521 WebInspector.SidebarTreeElement.call(this, "audit-result-sidebar-tree-item",
String.sprintf("%s (%d)", mainResourceURL, ordinal)); | 508 this.listItemElement.classList.add("audit-result-sidebar-tree-item"); |
| 509 this.listItemElement.insertBefore(createElementWithClass("div", "icon"), thi
s.listItemElement.firstChild); |
| 522 } | 510 } |
| 523 | 511 |
| 524 WebInspector.AuditResultSidebarTreeElement.prototype = { | 512 WebInspector.AuditResultSidebarTreeElement.prototype = { |
| 525 /** | 513 /** |
| 526 * @override | 514 * @override |
| 527 * @return {boolean} | 515 * @return {boolean} |
| 528 */ | 516 */ |
| 529 onselect: function() | 517 onselect: function() |
| 530 { | 518 { |
| 531 this._panel.showResults(this.results); | 519 this._panel.showResults(this.results); |
| 532 return true; | 520 return true; |
| 533 }, | 521 }, |
| 534 | 522 |
| 535 get selectable() | 523 __proto__: TreeElement.prototype |
| 536 { | |
| 537 return true; | |
| 538 }, | |
| 539 | |
| 540 __proto__: WebInspector.SidebarTreeElement.prototype | |
| 541 } | 524 } |
| 542 | 525 |
| 543 WebInspector.AuditsPanel.show = function() | 526 WebInspector.AuditsPanel.show = function() |
| 544 { | 527 { |
| 545 WebInspector.inspectorView.setCurrentPanel(WebInspector.AuditsPanel.instance
()); | 528 WebInspector.inspectorView.setCurrentPanel(WebInspector.AuditsPanel.instance
()); |
| 546 } | 529 } |
| 547 | 530 |
| 548 /** | 531 /** |
| 549 * @return {!WebInspector.AuditsPanel} | 532 * @return {!WebInspector.AuditsPanel} |
| 550 */ | 533 */ |
| 551 WebInspector.AuditsPanel.instance = function() | 534 WebInspector.AuditsPanel.instance = function() |
| 552 { | 535 { |
| 553 return /** @type {!WebInspector.AuditsPanel} */ (self.runtime.sharedInstance
(WebInspector.AuditsPanel)); | 536 return /** @type {!WebInspector.AuditsPanel} */ (self.runtime.sharedInstance
(WebInspector.AuditsPanel)); |
| 554 } | 537 } |
| 555 | 538 |
| 556 // Contributed audit rules should go into this namespace. | 539 // Contributed audit rules should go into this namespace. |
| 557 WebInspector.AuditRules = {}; | 540 WebInspector.AuditRules = {}; |
| 558 | 541 |
| 559 /** | 542 /** |
| 560 * Contributed audit categories should go into this namespace. | 543 * Contributed audit categories should go into this namespace. |
| 561 * @type {!Object.<string, function(new:WebInspector.AuditCategory)>} | 544 * @type {!Object.<string, function(new:WebInspector.AuditCategory)>} |
| 562 */ | 545 */ |
| 563 WebInspector.AuditCategories = {}; | 546 WebInspector.AuditCategories = {}; |
| OLD | NEW |