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 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 for (var i = 0; i < urlViolations[1].length; ++i) | 756 for (var i = 0; i < urlViolations[1].length; ++i) |
757 result.addChild(String.sprintf("Link node %s should be moved
to the document head in %s", WebInspector.AuditRuleResult.linkifyDisplayName(ur
lViolations[1][i]), WebInspector.AuditRuleResult.linkifyDisplayName(url))); | 757 result.addChild(String.sprintf("Link node %s should be moved
to the document head in %s", WebInspector.AuditRuleResult.linkifyDisplayName(ur
lViolations[1][i]), WebInspector.AuditRuleResult.linkifyDisplayName(url))); |
758 result.violationCount += urlViolations[1].length; | 758 result.violationCount += urlViolations[1].length; |
759 } | 759 } |
760 summary.value = String.sprintf("CSS in the document body adversely i
mpacts rendering performance."); | 760 summary.value = String.sprintf("CSS in the document body adversely i
mpacts rendering performance."); |
761 callback(result); | 761 callback(result); |
762 } | 762 } |
763 | 763 |
764 function externalStylesheetsReceived(root, inlineStyleNodeIds, nodeIds) | 764 function externalStylesheetsReceived(root, inlineStyleNodeIds, nodeIds) |
765 { | 765 { |
| 766 if (!nodeIds) { |
| 767 callback(null); |
| 768 return; |
| 769 } |
| 770 |
766 var externalStylesheetNodeIds = nodeIds; | 771 var externalStylesheetNodeIds = nodeIds; |
767 var result = null; | 772 var result = null; |
768 if (inlineStyleNodeIds.length || externalStylesheetNodeIds.length) { | 773 if (inlineStyleNodeIds.length || externalStylesheetNodeIds.length) { |
769 var urlToViolationsArray = {}; | 774 var urlToViolationsArray = {}; |
770 var externalStylesheetHrefs = []; | 775 var externalStylesheetHrefs = []; |
771 for (var j = 0; j < externalStylesheetNodeIds.length; ++j) { | 776 for (var j = 0; j < externalStylesheetNodeIds.length; ++j) { |
772 var linkNode = WebInspector.domAgent.nodeForId(externalStyle
sheetNodeIds[j]); | 777 var linkNode = WebInspector.domAgent.nodeForId(externalStyle
sheetNodeIds[j]); |
773 var completeHref = WebInspector.completeURL(linkNode.ownerDo
cument.documentURL, linkNode.getAttribute("href")); | 778 var completeHref = WebInspector.completeURL(linkNode.ownerDo
cument.documentURL, linkNode.getAttribute("href")); |
774 externalStylesheetHrefs.push(completeHref || "<empty>"); | 779 externalStylesheetHrefs.push(completeHref || "<empty>"); |
775 } | 780 } |
776 urlToViolationsArray[root.documentURL] = [inlineStyleNodeIds.len
gth, externalStylesheetHrefs]; | 781 urlToViolationsArray[root.documentURL] = [inlineStyleNodeIds.len
gth, externalStylesheetHrefs]; |
777 result = urlToViolationsArray; | 782 result = urlToViolationsArray; |
778 } | 783 } |
779 evalCallback(result); | 784 evalCallback(result); |
780 } | 785 } |
781 | 786 |
782 function inlineStylesReceived(root, nodeIds) | 787 function inlineStylesReceived(root, nodeIds) |
783 { | 788 { |
| 789 if (!nodeIds) { |
| 790 callback(null); |
| 791 return; |
| 792 } |
| 793 |
784 WebInspector.domAgent.querySelectorAll(root.id, "body link[rel~='sty
lesheet'][href]", externalStylesheetsReceived.bind(null, root, nodeIds)); | 794 WebInspector.domAgent.querySelectorAll(root.id, "body link[rel~='sty
lesheet'][href]", externalStylesheetsReceived.bind(null, root, nodeIds)); |
785 } | 795 } |
786 | 796 |
787 function onDocumentAvailable(root) | 797 function onDocumentAvailable(root) |
788 { | 798 { |
789 WebInspector.domAgent.querySelectorAll(root.id, "body style", inline
StylesReceived.bind(null, root)); | 799 WebInspector.domAgent.querySelectorAll(root.id, "body style", inline
StylesReceived.bind(null, root)); |
790 } | 800 } |
791 | 801 |
792 WebInspector.domAgent.requestDocument(onDocumentAvailable); | 802 WebInspector.domAgent.requestDocument(onDocumentAvailable); |
793 } | 803 } |
(...skipping 24 matching lines...) Expand all Loading... |
818 | 828 |
819 if (cssBeforeInlineCount) { | 829 if (cssBeforeInlineCount) { |
820 result.addChild(String.sprintf(" %d inline script block%s found
in the head between an external CSS file and another resource. To allow parallel
downloading, move the inline script before the external CSS file, or after the
next resource.", cssBeforeInlineCount, cssBeforeInlineCount > 1 ? "s were" : " w
as")); | 830 result.addChild(String.sprintf(" %d inline script block%s found
in the head between an external CSS file and another resource. To allow parallel
downloading, move the inline script before the external CSS file, or after the
next resource.", cssBeforeInlineCount, cssBeforeInlineCount > 1 ? "s were" : " w
as")); |
821 result.violationCount += cssBeforeInlineCount; | 831 result.violationCount += cssBeforeInlineCount; |
822 } | 832 } |
823 callback(result); | 833 callback(result); |
824 } | 834 } |
825 | 835 |
826 function cssBeforeInlineReceived(lateStyleIds, nodeIds) | 836 function cssBeforeInlineReceived(lateStyleIds, nodeIds) |
827 { | 837 { |
| 838 if (!nodeIds) { |
| 839 callback(null); |
| 840 return; |
| 841 } |
| 842 |
828 var cssBeforeInlineCount = nodeIds.length; | 843 var cssBeforeInlineCount = nodeIds.length; |
829 var result = null; | 844 var result = null; |
830 if (lateStyleIds.length || cssBeforeInlineCount) { | 845 if (lateStyleIds.length || cssBeforeInlineCount) { |
831 var lateStyleUrls = []; | 846 var lateStyleUrls = []; |
832 for (var i = 0; i < lateStyleIds.length; ++i) { | 847 for (var i = 0; i < lateStyleIds.length; ++i) { |
833 var lateStyleNode = WebInspector.domAgent.nodeForId(lateStyl
eIds[i]); | 848 var lateStyleNode = WebInspector.domAgent.nodeForId(lateStyl
eIds[i]); |
834 var completeHref = WebInspector.completeURL(lateStyleNode.ow
nerDocument.documentURL, lateStyleNode.getAttribute("href")); | 849 var completeHref = WebInspector.completeURL(lateStyleNode.ow
nerDocument.documentURL, lateStyleNode.getAttribute("href")); |
835 lateStyleUrls.push(completeHref || "<empty>"); | 850 lateStyleUrls.push(completeHref || "<empty>"); |
836 } | 851 } |
837 result = [ lateStyleUrls, cssBeforeInlineCount ]; | 852 result = [ lateStyleUrls, cssBeforeInlineCount ]; |
838 } | 853 } |
839 | 854 |
840 evalCallback(result); | 855 evalCallback(result); |
841 } | 856 } |
842 | 857 |
843 function lateStylesReceived(root, nodeIds) | 858 function lateStylesReceived(root, nodeIds) |
844 { | 859 { |
| 860 if (!nodeIds) { |
| 861 callback(null); |
| 862 return; |
| 863 } |
| 864 |
845 WebInspector.domAgent.querySelectorAll(root.id, "head link[rel~='sty
lesheet'][href] ~ script:not([src])", cssBeforeInlineReceived.bind(null, nodeIds
)); | 865 WebInspector.domAgent.querySelectorAll(root.id, "head link[rel~='sty
lesheet'][href] ~ script:not([src])", cssBeforeInlineReceived.bind(null, nodeIds
)); |
846 } | 866 } |
847 | 867 |
848 function onDocumentAvailable(root) | 868 function onDocumentAvailable(root) |
849 { | 869 { |
850 WebInspector.domAgent.querySelectorAll(root.id, "head script[src] ~
link[rel~='stylesheet'][href]", lateStylesReceived.bind(null, root)); | 870 WebInspector.domAgent.querySelectorAll(root.id, "head script[src] ~
link[rel~='stylesheet'][href]", lateStylesReceived.bind(null, root)); |
851 } | 871 } |
852 | 872 |
853 WebInspector.domAgent.requestDocument(onDocumentAvailable); | 873 WebInspector.domAgent.requestDocument(onDocumentAvailable); |
854 } | 874 } |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 result.violationCount = badUrls.length; | 1058 result.violationCount = badUrls.length; |
1039 }, | 1059 }, |
1040 | 1060 |
1041 _collectorCallback: function(matchingResourceData, resource, cookie) | 1061 _collectorCallback: function(matchingResourceData, resource, cookie) |
1042 { | 1062 { |
1043 matchingResourceData[resource.url] = (matchingResourceData[resource.url]
|| 0) + cookie.size; | 1063 matchingResourceData[resource.url] = (matchingResourceData[resource.url]
|| 0) + cookie.size; |
1044 } | 1064 } |
1045 } | 1065 } |
1046 | 1066 |
1047 WebInspector.AuditRules.StaticCookielessRule.prototype.__proto__ = WebInspector.
AuditRules.CookieRuleBase.prototype; | 1067 WebInspector.AuditRules.StaticCookielessRule.prototype.__proto__ = WebInspector.
AuditRules.CookieRuleBase.prototype; |
OLD | NEW |