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 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 } | 1027 } |
1028 for (var i = 0; i < urlViolations[1].length; ++i) | 1028 for (var i = 0; i < urlViolations[1].length; ++i) |
1029 result.addFormatted("Link node %r should be moved to the doc
ument head in %r", urlViolations[1][i], url); | 1029 result.addFormatted("Link node %r should be moved to the doc
ument head in %r", urlViolations[1][i], url); |
1030 result.violationCount += urlViolations[1].length; | 1030 result.violationCount += urlViolations[1].length; |
1031 } | 1031 } |
1032 summary.value = WebInspector.UIString("CSS in the document body adve
rsely impacts rendering performance."); | 1032 summary.value = WebInspector.UIString("CSS in the document body adve
rsely impacts rendering performance."); |
1033 callback(result); | 1033 callback(result); |
1034 } | 1034 } |
1035 | 1035 |
1036 /** | 1036 /** |
| 1037 * @param {!WebInspector.DOMNode} root |
| 1038 * @param {!Array.<!DOMAgent.NodeId>=} inlineStyleNodeIds |
1037 * @param {!Array.<!DOMAgent.NodeId>=} nodeIds | 1039 * @param {!Array.<!DOMAgent.NodeId>=} nodeIds |
1038 */ | 1040 */ |
1039 function externalStylesheetsReceived(root, inlineStyleNodeIds, nodeIds) | 1041 function externalStylesheetsReceived(root, inlineStyleNodeIds, nodeIds) |
1040 { | 1042 { |
1041 if (progress.isCanceled()) | 1043 if (progress.isCanceled()) |
1042 return; | 1044 return; |
1043 | 1045 |
1044 if (!nodeIds) | 1046 if (!nodeIds) |
1045 return; | 1047 return; |
1046 var externalStylesheetNodeIds = nodeIds; | 1048 var externalStylesheetNodeIds = nodeIds; |
1047 var result = null; | 1049 var result = null; |
1048 if (inlineStyleNodeIds.length || externalStylesheetNodeIds.length) { | 1050 if (inlineStyleNodeIds.length || externalStylesheetNodeIds.length) { |
1049 var urlToViolationsArray = {}; | 1051 var urlToViolationsArray = {}; |
1050 var externalStylesheetHrefs = []; | 1052 var externalStylesheetHrefs = []; |
1051 for (var j = 0; j < externalStylesheetNodeIds.length; ++j) { | 1053 for (var j = 0; j < externalStylesheetNodeIds.length; ++j) { |
1052 var linkNode = target.domModel.nodeForId(externalStylesheetN
odeIds[j]); | 1054 var linkNode = target.domModel.nodeForId(externalStylesheetN
odeIds[j]); |
1053 var completeHref = WebInspector.ParsedURL.completeURL(linkNo
de.ownerDocument.baseURL, linkNode.getAttribute("href")); | 1055 var completeHref = WebInspector.ParsedURL.completeURL(linkNo
de.ownerDocument.baseURL, linkNode.getAttribute("href")); |
1054 externalStylesheetHrefs.push(completeHref || "<empty>"); | 1056 externalStylesheetHrefs.push(completeHref || "<empty>"); |
1055 } | 1057 } |
1056 urlToViolationsArray[root.documentURL] = [inlineStyleNodeIds.len
gth, externalStylesheetHrefs]; | 1058 urlToViolationsArray[root.documentURL] = [inlineStyleNodeIds.len
gth, externalStylesheetHrefs]; |
1057 result = urlToViolationsArray; | 1059 result = urlToViolationsArray; |
1058 } | 1060 } |
1059 evalCallback(result); | 1061 evalCallback(result); |
1060 } | 1062 } |
1061 | 1063 |
1062 /** | 1064 /** |
| 1065 * @param {!WebInspector.DOMNode} root |
1063 * @param {!Array.<!DOMAgent.NodeId>=} nodeIds | 1066 * @param {!Array.<!DOMAgent.NodeId>=} nodeIds |
1064 */ | 1067 */ |
1065 function inlineStylesReceived(root, nodeIds) | 1068 function inlineStylesReceived(root, nodeIds) |
1066 { | 1069 { |
1067 if (progress.isCanceled()) | 1070 if (progress.isCanceled()) |
1068 return; | 1071 return; |
1069 | 1072 |
1070 if (!nodeIds) | 1073 if (!nodeIds) |
1071 return; | 1074 return; |
1072 target.domModel.querySelectorAll(root.id, "body link[rel~='styleshee
t'][href]", externalStylesheetsReceived.bind(null, root, nodeIds)); | 1075 target.domModel.querySelectorAll(root.id, "body link[rel~='styleshee
t'][href]", externalStylesheetsReceived.bind(null, root, nodeIds)); |
1073 } | 1076 } |
1074 | 1077 |
| 1078 /** |
| 1079 * @param {!WebInspector.DOMNode} root |
| 1080 */ |
1075 function onDocumentAvailable(root) | 1081 function onDocumentAvailable(root) |
1076 { | 1082 { |
1077 if (progress.isCanceled()) | 1083 if (progress.isCanceled()) |
1078 return; | 1084 return; |
1079 | 1085 |
1080 target.domModel.querySelectorAll(root.id, "body style", inlineStyles
Received.bind(null, root)); | 1086 target.domModel.querySelectorAll(root.id, "body style", inlineStyles
Received.bind(null, root)); |
1081 } | 1087 } |
1082 | 1088 |
1083 target.domModel.requestDocument(onDocumentAvailable); | 1089 target.domModel.requestDocument(onDocumentAvailable); |
1084 }, | 1090 }, |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 result.violationCount = badUrls.length; | 1592 result.violationCount = badUrls.length; |
1587 }, | 1593 }, |
1588 | 1594 |
1589 _collectorCallback: function(matchingResourceData, request, cookie) | 1595 _collectorCallback: function(matchingResourceData, request, cookie) |
1590 { | 1596 { |
1591 matchingResourceData[request.url] = (matchingResourceData[request.url] |
| 0) + cookie.size(); | 1597 matchingResourceData[request.url] = (matchingResourceData[request.url] |
| 0) + cookie.size(); |
1592 }, | 1598 }, |
1593 | 1599 |
1594 __proto__: WebInspector.AuditRules.CookieRuleBase.prototype | 1600 __proto__: WebInspector.AuditRules.CookieRuleBase.prototype |
1595 } | 1601 } |
OLD | NEW |