Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: Source/devtools/front_end/AuditRules.js

Issue 148523012: DevTools: [CSS] remove getAllStylesheets method from protocol (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix testcase extension Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/inspector/InspectorCSSAgent.cpp ('k') | Source/devtools/front_end/CSSStyleModel.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 return; 472 return;
473 473
474 if (styleSheet) { 474 if (styleSheet) {
475 styleSheet.sourceURL = sourceURL; 475 styleSheet.sourceURL = sourceURL;
476 styleSheets.push(styleSheet); 476 styleSheets.push(styleSheet);
477 } 477 }
478 if (continuation) 478 if (continuation)
479 continuation(styleSheets); 479 continuation(styleSheets);
480 } 480 }
481 481
482 /** 482 var styleSheetInfos = WebInspector.cssModel.allStyleSheets();
483 * @param {?Protocol.Error} error 483 if (!styleSheetInfos || !styleSheetInfos.length) {
484 * @param {!Array.<!CSSAgent.CSSStyleSheetHeader>} styleSheetInfos 484 evalCallback([]);
485 */ 485 return;
486 function allStylesCallback(error, styleSheetInfos)
487 {
488 if (progress.isCanceled())
489 return;
490
491 if (error || !styleSheetInfos || !styleSheetInfos.length)
492 return evalCallback([]);
493 var styleSheets = [];
494 for (var i = 0; i < styleSheetInfos.length; ++i) {
495 var info = styleSheetInfos[i];
496 WebInspector.CSSStyleSheet.createForId(info.styleSheetId, styleS heetCallback.bind(null, styleSheets, info.sourceURL, i == styleSheetInfos.length - 1 ? evalCallback : null));
497 }
498 } 486 }
499 487 var styleSheets = [];
500 CSSAgent.getAllStyleSheets(allStylesCallback); 488 for (var i = 0; i < styleSheetInfos.length; ++i) {
489 var info = styleSheetInfos[i];
490 WebInspector.CSSStyleSheet.createForId(info.id, styleSheetCallback.b ind(null, styleSheets, info.sourceURL, i == styleSheetInfos.length - 1 ? evalCal lback : null));
491 }
501 }, 492 },
502 493
503 __proto__: WebInspector.AuditRule.prototype 494 __proto__: WebInspector.AuditRule.prototype
504 } 495 }
505 496
506 /** 497 /**
507 * @constructor 498 * @constructor
508 * @extends {WebInspector.AuditRule} 499 * @extends {WebInspector.AuditRule}
509 */ 500 */
510 WebInspector.AuditRules.CacheControlRule = function(id, name) 501 WebInspector.AuditRules.CacheControlRule = function(id, name)
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 1133
1143 WebInspector.AuditRules.CSSRuleBase.prototype = { 1134 WebInspector.AuditRules.CSSRuleBase.prototype = {
1144 /** 1135 /**
1145 * @param {!Array.<!WebInspector.NetworkRequest>} requests 1136 * @param {!Array.<!WebInspector.NetworkRequest>} requests
1146 * @param {!WebInspector.AuditRuleResult} result 1137 * @param {!WebInspector.AuditRuleResult} result
1147 * @param {function(?WebInspector.AuditRuleResult)} callback 1138 * @param {function(?WebInspector.AuditRuleResult)} callback
1148 * @param {!WebInspector.Progress} progress 1139 * @param {!WebInspector.Progress} progress
1149 */ 1140 */
1150 doRun: function(requests, result, callback, progress) 1141 doRun: function(requests, result, callback, progress)
1151 { 1142 {
1152 CSSAgent.getAllStyleSheets(sheetsCallback.bind(this)); 1143 var headers = WebInspector.cssModel.allStyleSheets();
1153 1144
1154 /** 1145 if (!headers.length) {
1155 * @param {?Protocol.Error} error 1146 callback(null);
1156 * @param {!Array.<!CSSAgent.CSSStyleSheetHeader>} headers 1147 return;
1157 * @this {WebInspector.AuditRules.CSSRuleBase} 1148 }
1158 */ 1149 for (var i = 0; i < headers.length; ++i) {
1159 function sheetsCallback(error, headers) 1150 var header = headers[i];
1160 { 1151 if (header.disabled)
1161 if (error) 1152 continue; // Do not check disabled stylesheets.
1162 return callback(null);
1163 1153
1164 if (!headers.length) 1154 this._visitStyleSheet(header.id, i === headers.length - 1 ? finished Callback : null, result, progress);
1165 return callback(null);
1166 for (var i = 0; i < headers.length; ++i) {
1167 var header = headers[i];
1168 if (header.disabled)
1169 continue; // Do not check disabled stylesheets.
1170
1171 this._visitStyleSheet(header.styleSheetId, i === headers.length - 1 ? finishedCallback : null, result, progress);
1172 }
1173 } 1155 }
1174 1156
1175 function finishedCallback() 1157 function finishedCallback()
1176 { 1158 {
1177 callback(result); 1159 callback(result);
1178 } 1160 }
1179 }, 1161 },
1180 1162
1181 _visitStyleSheet: function(styleSheetId, callback, result, progress) 1163 _visitStyleSheet: function(styleSheetId, callback, result, progress)
1182 { 1164 {
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 result.violationCount = badUrls.length; 1492 result.violationCount = badUrls.length;
1511 }, 1493 },
1512 1494
1513 _collectorCallback: function(matchingResourceData, request, cookie) 1495 _collectorCallback: function(matchingResourceData, request, cookie)
1514 { 1496 {
1515 matchingResourceData[request.url] = (matchingResourceData[request.url] | | 0) + cookie.size(); 1497 matchingResourceData[request.url] = (matchingResourceData[request.url] | | 0) + cookie.size();
1516 }, 1498 },
1517 1499
1518 __proto__: WebInspector.AuditRules.CookieRuleBase.prototype 1500 __proto__: WebInspector.AuditRules.CookieRuleBase.prototype
1519 } 1501 }
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorCSSAgent.cpp ('k') | Source/devtools/front_end/CSSStyleModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698