Demo/bin/Debug/front_end/audits_module.js
(开头部分) 67KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
WebInspector.AuditsPanel=function()
{WebInspector.PanelWithSidebar.call(this,"audits");this.registerRequiredCSS("ui/panelEnablerView.css");this.registerRequiredCSS("audits/auditsPanel.css");var sidebarTree=new TreeOutline();sidebarTree.element.classList.add("sidebar-tree");this.panelSidebarElement().appendChild(sidebarTree.element);this.setDefaultFocusedElement(sidebarTree.element);this.auditsTreeElement=new WebInspector.SidebarSectionTreeElement("");sidebarTree.appendChild(this.auditsTreeElement);this.auditsTreeElement.listItemElement.classList.add("hidden");this.auditsItemTreeElement=new WebInspector.AuditsSidebarTreeElement(this);this.auditsTreeElement.appendChild(this.auditsItemTreeElement);this.auditResultsTreeElement=new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("RESULTS"));sidebarTree.appendChild(this.auditResultsTreeElement);this.auditResultsTreeElement.expand();this._constructCategories();this._auditController=new WebInspector.AuditController(this);this._launcherView=new WebInspector.AuditLauncherView(this._auditController);for(var id in this.categoriesById)
this._launcherView.addCategory(this.categoriesById[id]);var extensionCategories=WebInspector.extensionServer.auditCategories();for(var i=0;i<extensionCategories.length;++i){var category=extensionCategories[i];this.addCategory(new WebInspector.AuditExtensionCategory(category.extensionOrigin,category.id,category.displayName,category.ruleCount));}
WebInspector.extensionServer.addEventListener(WebInspector.ExtensionServer.Events.AuditCategoryAdded,this._extensionAuditCategoryAdded,this);}
WebInspector.AuditsPanel.prototype={get categoriesById()
{return this._auditCategoriesById;},addCategory:function(category)
{this.categoriesById[category.id]=category;this._launcherView.addCategory(category);},getCategory:function(id)
{return this.categoriesById[id];},_constructCategories:function()
{this._auditCategoriesById={};for(var categoryCtorID in WebInspector.AuditCategories){var auditCategory=new WebInspector.AuditCategories[categoryCtorID]();auditCategory._id=categoryCtorID;this.categoriesById[categoryCtorID]=auditCategory;}},auditFinishedCallback:function(mainResourceURL,results)
{var ordinal=1;for(var child of this.auditResultsTreeElement.children()){if(child.mainResourceURL===mainResourceURL)
ordinal++;}
var resultTreeElement=new WebInspector.AuditResultSidebarTreeElement(this,results,mainResourceURL,ordinal);this.auditResultsTreeElement.appendChild(resultTreeElement);resultTreeElement.revealAndSelect();},showResults:function(categoryResults)
{if(!categoryResults._resultView)
categoryResults._resultView=new WebInspector.AuditResultView(categoryResults);this.visibleView=categoryResults._resultView;},showLauncherView:function()
{this.visibleView=this._launcherView;},get visibleView()
{return this._visibleView;},set visibleView(x)
{if(this._visibleView===x)
return;if(this._visibleView)
this._visibleView.detach();this._visibleView=x;if(x)
this.splitWidget().setMainWidget(x);},wasShown:function()
{WebInspector.Panel.prototype.wasShown.call(this);if(!this._visibleView)
this.auditsItemTreeElement.select();},clearResults:function()
{this.auditsItemTreeElement.revealAndSelect();this.auditResultsTreeElement.removeChildren();},_extensionAuditCategoryAdded:function(event)
{var category=(event.data);this.addCategory(new WebInspector.AuditExtensionCategory(category.extensionOrigin,category.id,category.displayName,category.ruleCount));},__proto__:WebInspector.PanelWithSidebar.prototype}
WebInspector.AuditCategoryImpl=function(displayName)
{this._displayName=displayName;this._rules=[];}
WebInspector.AuditCategoryImpl.prototype={get id()
{return this._id;},get displayName()
{return this._displayName;},addRule:function(rule,severity)
{rule.severity=severity;this._rules.push(rule);},run:function(target,requests,ruleResultCallback,progress)
{this._ensureInitialized();var remainingRulesCount=this._rules.length;progress.setTotalWork(remainingRulesCount);function callbackWrapper(result)
{ruleResultCallback(result);progress.worked();if(!--remainingRulesCount)
progress.done();}
for(var i=0;i<this._rules.length;++i){if(!progress.isCanceled())
this._rules[i].run(target,requests,callbackWrapper,progress);else
callbackWrapper(null);}},_ensureInitialized:function()
{if(!this._initialized){if("initialize"in this)
this.initialize();this._initialized=true;}}}
WebInspector.AuditRule=function(id,displayName)
{this._id=id;this._displayName=displayName;}
WebInspector.AuditRule.Severity={Info:"info",Warning:"warning",Severe:"severe"}
WebInspector.AuditRule.SeverityOrder={"info":3,"warning":2,"severe":1}
WebInspector.AuditRule.prototype={get id()
{return this._id;},get displayName()
{return this._displayName;},set severity(severity)
{this._severity=severity;},run:function(target,requests,callback,progress)
{if(progress.isCanceled())
return;var result=new WebInspector.AuditRuleResult(this.displayName);result.severity=this._severity;this.doRun(target,requests,result,callback,progress);},doRun:function(target,requests,result,callback,progress)
{throw new Error("doRun() not implemented");}}
WebInspector.AuditCategoryResult=function(category)
{this.title=category.displayName;this.ruleResults=[];}
WebInspector.AuditCategoryResult.prototype={addRuleResult:function(ruleResult)
{this.ruleResults.push(ruleResult);}}
WebInspector.AuditRuleResult=function(value,expanded,className)
{this.value=value;this.className=className;this.expanded=expanded;this.violationCount=0;this._formatters={r:WebInspector.AuditRuleResult.linkifyDisplayName};var standardFormatters=Object.keys(String.standardFormatters);for(var i=0;i<standardFormatters.length;++i)
this._formatters[standardFormatters[i]]=String.standardFormatters[standardFormatters[i]];}
WebInspector.AuditRuleResult.linkifyDisplayName=function(url)
{return WebInspector.linkifyURLAsNode(url,WebInspector.displayNameForURL(url));}
WebInspector.AuditRuleResult.resourceDomain=function(domain)
{return domain||WebInspector.UIString("[empty domain]");}
后面还有 456 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。