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

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

Issue 1350183004: DevTools: CSS.getMatchedStylesForNode protocol command to return inline styles (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix tests Created 5 years, 3 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
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 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 */ 934 */
935 function getStyles(nodeIds) 935 function getStyles(nodeIds)
936 { 936 {
937 if (progress.isCanceled()) { 937 if (progress.isCanceled()) {
938 callback(null); 938 callback(null);
939 return; 939 return;
940 } 940 }
941 var targetResult = {}; 941 var targetResult = {};
942 942
943 /** 943 /**
944 * @param {?WebInspector.CSSStyleModel.InlineStyleResult} inlineStyl eResult
945 */
946 function inlineCallback(inlineStyleResult)
947 {
948 if (!inlineStyleResult)
949 return;
950 targetResult.inlineStyle = inlineStyleResult.inlineStyle;
951 targetResult.attributesStyle = inlineStyleResult.attributesStyle ;
952 }
953
954 /**
955 * @param {?WebInspector.CSSStyleModel.MatchedStyleResult} matchedSt yleResult 944 * @param {?WebInspector.CSSStyleModel.MatchedStyleResult} matchedSt yleResult
956 */ 945 */
957 function matchedCallback(matchedStyleResult) 946 function matchedCallback(matchedStyleResult)
958 { 947 {
959 if (matchedStyleResult) 948 if (!matchedStyleResult)
960 targetResult.matchedCSSRules = matchedStyleResult.matchedCSS Rules; 949 return;
950 targetResult.matchedCSSRules = matchedStyleResult.matchedCSSRule s;
951 targetResult.inlineStyle = matchedStyleResult.inlineStyle;
952 targetResult.attributesStyle = matchedStyleResult.attributesStyl e;
961 } 953 }
962 954
963 /** 955 /**
964 * @param {?Map.<string, string>} computedStyle 956 * @param {?Map.<string, string>} computedStyle
965 */ 957 */
966 function computedCallback(computedStyle) 958 function computedCallback(computedStyle)
967 { 959 {
968 targetResult.computedStyle = computedStyle; 960 targetResult.computedStyle = computedStyle;
969 } 961 }
970 962
971 if (!nodeIds || !nodeIds.length) 963 if (!nodeIds || !nodeIds.length)
972 doneCallback(); 964 doneCallback();
973 965
974 var nodePromises = []; 966 var nodePromises = [];
975 for (var i = 0; nodeIds && i < nodeIds.length; ++i) { 967 for (var i = 0; nodeIds && i < nodeIds.length; ++i) {
976 var stylePromises = [ 968 var stylePromises = [
977 cssModel.matchedStylesPromise(nodeIds[i]).then(matchedCallba ck), 969 cssModel.matchedStylesPromise(nodeIds[i]).then(matchedCallba ck),
978 cssModel.inlineStylesPromise(nodeIds[i]).then(inlineCallback ),
979 cssModel.computedStylePromise(nodeIds[i]).then(computedCallb ack) 970 cssModel.computedStylePromise(nodeIds[i]).then(computedCallb ack)
980 ]; 971 ];
981 var nodePromise = Promise.all(stylePromises).then(imageStylesRea dy.bind(null, nodeIds[i], targetResult)); 972 var nodePromise = Promise.all(stylePromises).then(imageStylesRea dy.bind(null, nodeIds[i], targetResult));
982 nodePromises.push(nodePromise); 973 nodePromises.push(nodePromise);
983 } 974 }
984 Promise.all(nodePromises) 975 Promise.all(nodePromises)
985 .catchException(null) 976 .catchException(null)
986 .then(doneCallback); 977 .then(doneCallback);
987 } 978 }
988 979
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 result.violationCount = badUrls.length; 1638 result.violationCount = badUrls.length;
1648 }, 1639 },
1649 1640
1650 _collectorCallback: function(matchingResourceData, request, cookie) 1641 _collectorCallback: function(matchingResourceData, request, cookie)
1651 { 1642 {
1652 matchingResourceData[request.url] = (matchingResourceData[request.url] | | 0) + cookie.size(); 1643 matchingResourceData[request.url] = (matchingResourceData[request.url] | | 0) + cookie.size();
1653 }, 1644 },
1654 1645
1655 __proto__: WebInspector.AuditRules.CookieRuleBase.prototype 1646 __proto__: WebInspector.AuditRules.CookieRuleBase.prototype
1656 } 1647 }
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorCSSAgent.cpp ('k') | Source/devtools/front_end/elements/StylesSidebarPane.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698