| OLD | NEW |
| 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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 if (!styleSheetInfos || !styleSheetInfos.length) { | 482 if (!styleSheetInfos || !styleSheetInfos.length) { |
| 483 evalCallback([]); | 483 evalCallback([]); |
| 484 return; | 484 return; |
| 485 } | 485 } |
| 486 var styleSheetProcessor = new Audits.AuditRules.StyleSheetProcessor(styleShe
etInfos, progress, evalCallback); | 486 var styleSheetProcessor = new Audits.AuditRules.StyleSheetProcessor(styleShe
etInfos, progress, evalCallback); |
| 487 styleSheetProcessor.run(); | 487 styleSheetProcessor.run(); |
| 488 } | 488 } |
| 489 }; | 489 }; |
| 490 | 490 |
| 491 /** | 491 /** |
| 492 * @typedef {!{sourceURL: string, rules: !Array.<!SDK.CSSParser.StyleRule>}} | 492 * @typedef {!{sourceURL: string, rules: !Array.<!Common.FormatterWorkerPool.CSS
StyleRule>}} |
| 493 */ | 493 */ |
| 494 Audits.AuditRules.ParsedStyleSheet; | 494 Audits.AuditRules.ParsedStyleSheet; |
| 495 | 495 |
| 496 /** | 496 /** |
| 497 * @unrestricted | 497 * @unrestricted |
| 498 */ | 498 */ |
| 499 Audits.AuditRules.StyleSheetProcessor = class { | 499 Audits.AuditRules.StyleSheetProcessor = class { |
| 500 /** | 500 /** |
| 501 * @param {!Array.<!SDK.CSSStyleSheetHeader>} styleSheetHeaders | 501 * @param {!Array.<!SDK.CSSStyleSheetHeader>} styleSheetHeaders |
| 502 * @param {!Common.Progress} progress | 502 * @param {!Common.Progress} progress |
| (...skipping 26 matching lines...) Expand all Loading... |
| 529 _processNextStyleSheet() { | 529 _processNextStyleSheet() { |
| 530 if (!this._styleSheetHeaders.length) { | 530 if (!this._styleSheetHeaders.length) { |
| 531 this._finish(); | 531 this._finish(); |
| 532 return; | 532 return; |
| 533 } | 533 } |
| 534 this._currentStyleSheetHeader = this._styleSheetHeaders.shift(); | 534 this._currentStyleSheetHeader = this._styleSheetHeaders.shift(); |
| 535 this._parser.fetchAndParse(this._currentStyleSheetHeader, this._onStyleSheet
Parsed.bind(this)); | 535 this._parser.fetchAndParse(this._currentStyleSheetHeader, this._onStyleSheet
Parsed.bind(this)); |
| 536 } | 536 } |
| 537 | 537 |
| 538 /** | 538 /** |
| 539 * @param {!Array.<!SDK.CSSParser.Rule>} rules | 539 * @param {!Array.<!Common.FormatterWorkerPool.CSSRule>} rules |
| 540 */ | 540 */ |
| 541 _onStyleSheetParsed(rules) { | 541 _onStyleSheetParsed(rules) { |
| 542 if (this._progress.isCanceled()) { | 542 if (this._progress.isCanceled()) { |
| 543 this._finish(); | 543 this._finish(); |
| 544 return; | 544 return; |
| 545 } | 545 } |
| 546 | 546 |
| 547 var styleRules = []; | 547 var styleRules = []; |
| 548 for (var i = 0; i < rules.length; ++i) { | 548 for (var i = 0; i < rules.length; ++i) { |
| 549 var rule = rules[i]; | 549 var rule = rules[i]; |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1225 this.visitStyleSheet(styleSheet, result); | 1225 this.visitStyleSheet(styleSheet, result); |
| 1226 | 1226 |
| 1227 for (var i = 0; i < styleSheet.rules.length; ++i) | 1227 for (var i = 0; i < styleSheet.rules.length; ++i) |
| 1228 this._visitRule(styleSheet, styleSheet.rules[i], result); | 1228 this._visitRule(styleSheet, styleSheet.rules[i], result); |
| 1229 | 1229 |
| 1230 this.didVisitStyleSheet(styleSheet, result); | 1230 this.didVisitStyleSheet(styleSheet, result); |
| 1231 } | 1231 } |
| 1232 | 1232 |
| 1233 /** | 1233 /** |
| 1234 * @param {!Audits.AuditRules.ParsedStyleSheet} styleSheet | 1234 * @param {!Audits.AuditRules.ParsedStyleSheet} styleSheet |
| 1235 * @param {!SDK.CSSParser.StyleRule} rule | 1235 * @param {!Common.FormatterWorkerPool.CSSStyleRule} rule |
| 1236 * @param {!Audits.AuditRuleResult} result | 1236 * @param {!Audits.AuditRuleResult} result |
| 1237 */ | 1237 */ |
| 1238 _visitRule(styleSheet, rule, result) { | 1238 _visitRule(styleSheet, rule, result) { |
| 1239 this.visitRule(styleSheet, rule, result); | 1239 this.visitRule(styleSheet, rule, result); |
| 1240 var allProperties = rule.properties; | 1240 var allProperties = rule.properties; |
| 1241 for (var i = 0; i < allProperties.length; ++i) | 1241 for (var i = 0; i < allProperties.length; ++i) |
| 1242 this.visitProperty(styleSheet, rule, allProperties[i], result); | 1242 this.visitProperty(styleSheet, rule, allProperties[i], result); |
| 1243 this.didVisitRule(styleSheet, rule, result); | 1243 this.didVisitRule(styleSheet, rule, result); |
| 1244 } | 1244 } |
| 1245 | 1245 |
| 1246 /** | 1246 /** |
| 1247 * @param {!Audits.AuditRules.ParsedStyleSheet} styleSheet | 1247 * @param {!Audits.AuditRules.ParsedStyleSheet} styleSheet |
| 1248 * @param {!Audits.AuditRuleResult} result | 1248 * @param {!Audits.AuditRuleResult} result |
| 1249 */ | 1249 */ |
| 1250 visitStyleSheet(styleSheet, result) { | 1250 visitStyleSheet(styleSheet, result) { |
| 1251 // Subclasses can implement. | 1251 // Subclasses can implement. |
| 1252 } | 1252 } |
| 1253 | 1253 |
| 1254 /** | 1254 /** |
| 1255 * @param {!Audits.AuditRules.ParsedStyleSheet} styleSheet | 1255 * @param {!Audits.AuditRules.ParsedStyleSheet} styleSheet |
| 1256 * @param {!Audits.AuditRuleResult} result | 1256 * @param {!Audits.AuditRuleResult} result |
| 1257 */ | 1257 */ |
| 1258 didVisitStyleSheet(styleSheet, result) { | 1258 didVisitStyleSheet(styleSheet, result) { |
| 1259 // Subclasses can implement. | 1259 // Subclasses can implement. |
| 1260 } | 1260 } |
| 1261 | 1261 |
| 1262 /** | 1262 /** |
| 1263 * @param {!Audits.AuditRules.ParsedStyleSheet} styleSheet | 1263 * @param {!Audits.AuditRules.ParsedStyleSheet} styleSheet |
| 1264 * @param {!SDK.CSSParser.StyleRule} rule | 1264 * @param {!Common.FormatterWorkerPool.CSSStyleRule} rule |
| 1265 * @param {!Audits.AuditRuleResult} result | 1265 * @param {!Audits.AuditRuleResult} result |
| 1266 */ | 1266 */ |
| 1267 visitRule(styleSheet, rule, result) { | 1267 visitRule(styleSheet, rule, result) { |
| 1268 // Subclasses can implement. | 1268 // Subclasses can implement. |
| 1269 } | 1269 } |
| 1270 | 1270 |
| 1271 /** | 1271 /** |
| 1272 * @param {!Audits.AuditRules.ParsedStyleSheet} styleSheet | 1272 * @param {!Audits.AuditRules.ParsedStyleSheet} styleSheet |
| 1273 * @param {!SDK.CSSParser.StyleRule} rule | 1273 * @param {!Common.FormatterWorkerPool.CSSStyleRule} rule |
| 1274 * @param {!Audits.AuditRuleResult} result | 1274 * @param {!Audits.AuditRuleResult} result |
| 1275 */ | 1275 */ |
| 1276 didVisitRule(styleSheet, rule, result) { | 1276 didVisitRule(styleSheet, rule, result) { |
| 1277 // Subclasses can implement. | 1277 // Subclasses can implement. |
| 1278 } | 1278 } |
| 1279 | 1279 |
| 1280 /** | 1280 /** |
| 1281 * @param {!Audits.AuditRules.ParsedStyleSheet} styleSheet | 1281 * @param {!Audits.AuditRules.ParsedStyleSheet} styleSheet |
| 1282 * @param {!SDK.CSSParser.StyleRule} rule | 1282 * @param {!Common.FormatterWorkerPool.CSSStyleRule} rule |
| 1283 * @param {!SDK.CSSParser.Property} property | 1283 * @param {!Common.FormatterWorkerPool.CSSProperty} property |
| 1284 * @param {!Audits.AuditRuleResult} result | 1284 * @param {!Audits.AuditRuleResult} result |
| 1285 */ | 1285 */ |
| 1286 visitProperty(styleSheet, rule, property, result) { | 1286 visitProperty(styleSheet, rule, property, result) { |
| 1287 // Subclasses can implement. | 1287 // Subclasses can implement. |
| 1288 } | 1288 } |
| 1289 }; | 1289 }; |
| 1290 | 1290 |
| 1291 /** | 1291 /** |
| 1292 * @unrestricted | 1292 * @unrestricted |
| 1293 */ | 1293 */ |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1478 Number.bytesToString(cookieBytes)), | 1478 Number.bytesToString(cookieBytes)), |
| 1479 true); | 1479 true); |
| 1480 entry.addURLs(badUrls); | 1480 entry.addURLs(badUrls); |
| 1481 result.violationCount = badUrls.length; | 1481 result.violationCount = badUrls.length; |
| 1482 } | 1482 } |
| 1483 | 1483 |
| 1484 _collectorCallback(matchingResourceData, request, cookie) { | 1484 _collectorCallback(matchingResourceData, request, cookie) { |
| 1485 matchingResourceData[request.url] = (matchingResourceData[request.url] || 0)
+ cookie.size(); | 1485 matchingResourceData[request.url] = (matchingResourceData[request.url] || 0)
+ cookie.size(); |
| 1486 } | 1486 } |
| 1487 }; | 1487 }; |
| OLD | NEW |