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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/CSSModel.js

Issue 2455943003: Backend for css rule tracking (Closed)
Patch Set: Backend for CSS Rule tracking. Created 4 years, 1 month 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
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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 this._fireStyleSheetChanged(styleSheetId, edit); 432 this._fireStyleSheetChanged(styleSheetId, edit);
433 return true; 433 return true;
434 } 434 }
435 435
436 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.StyleRu leEdited); 436 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.StyleRu leEdited);
437 return this._ensureOriginalStyleSheetText(styleSheetId) 437 return this._ensureOriginalStyleSheetText(styleSheetId)
438 .then(() => this._agent.setKeyframeKey(styleSheetId, range, text, callba ck.bind(this))) 438 .then(() => this._agent.setKeyframeKey(styleSheetId, range, text, callba ck.bind(this)))
439 .catchException(false); 439 .catchException(false);
440 } 440 }
441 441
442 startRuleUsageTracking() {
443 this._agent.startRuleUsageTracking();
444 }
445
446 /**
447 * @return {!Promise<?Array<!WebInspector.CSSModel.RuleUsageTracker>>}
448 */
449 ruleListPromise() {
450 /**
451 * @param {?string} error
452 * @param {!Array<!CSSAgent.RuleUsage>=} ruleUsage
453 * @return {?Array<!WebInspector.CSSModel.RuleUsageTracker>}
454 */
455 function usedRulesCallback(error, ruleUsage) {
456 if (error || !ruleUsage)
457 return null;
458
459 return ruleUsage.map(rule => ({range: rule.range, styleSheetId: rule.style SheetId, wasUsed: rule.used}));
460 }
461
462 return this._agent.stopRuleUsageTracking(usedRulesCallback);
463 }
464
442 /** 465 /**
443 * @return {!Promise.<!Array.<!WebInspector.CSSMedia>>} 466 * @return {!Promise.<!Array.<!WebInspector.CSSMedia>>}
444 */ 467 */
445 mediaQueriesPromise() { 468 mediaQueriesPromise() {
446 /** 469 /**
447 * @param {?Protocol.Error} error 470 * @param {?Protocol.Error} error
448 * @param {?Array.<!CSSAgent.CSSMedia>} payload 471 * @param {?Array.<!CSSAgent.CSSMedia>} payload
449 * @return {!Array.<!WebInspector.CSSMedia>} 472 * @return {!Array.<!WebInspector.CSSMedia>}
450 * @this {!WebInspector.CSSModel} 473 * @this {!WebInspector.CSSModel}
451 */ 474 */
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 this._cachedMatchedCascadePromise = this.matchedStylesPromise(node.id); 1006 this._cachedMatchedCascadePromise = this.matchedStylesPromise(node.id);
984 return this._cachedMatchedCascadePromise; 1007 return this._cachedMatchedCascadePromise;
985 } 1008 }
986 1009
987 discardCachedMatchedCascade() { 1010 discardCachedMatchedCascade() {
988 delete this._cachedMatchedCascadeNode; 1011 delete this._cachedMatchedCascadeNode;
989 delete this._cachedMatchedCascadePromise; 1012 delete this._cachedMatchedCascadePromise;
990 } 1013 }
991 }; 1014 };
992 1015
1016 /** @typedef {!{range: !CSSAgent.SourceRange, styleSheetId: !CSSAgent.StyleSheet Id, wasUsed: boolean}} */
1017 WebInspector.CSSModel.RuleUsageTracker;
caseq 2016/11/03 00:13:08 Why is it called tracker? Is it tracking something
1018
993 /** @enum {symbol} */ 1019 /** @enum {symbol} */
994 WebInspector.CSSModel.Events = { 1020 WebInspector.CSSModel.Events = {
995 LayoutEditorChange: Symbol('LayoutEditorChange'), 1021 LayoutEditorChange: Symbol('LayoutEditorChange'),
996 FontsUpdated: Symbol('FontsUpdated'), 1022 FontsUpdated: Symbol('FontsUpdated'),
997 MediaQueryResultChanged: Symbol('MediaQueryResultChanged'), 1023 MediaQueryResultChanged: Symbol('MediaQueryResultChanged'),
998 ModelWasEnabled: Symbol('ModelWasEnabled'), 1024 ModelWasEnabled: Symbol('ModelWasEnabled'),
999 PseudoStateForced: Symbol('PseudoStateForced'), 1025 PseudoStateForced: Symbol('PseudoStateForced'),
1000 StyleSheetAdded: Symbol('StyleSheetAdded'), 1026 StyleSheetAdded: Symbol('StyleSheetAdded'),
1001 StyleSheetChanged: Symbol('StyleSheetChanged'), 1027 StyleSheetChanged: Symbol('StyleSheetChanged'),
1002 StyleSheetRemoved: Symbol('StyleSheetRemoved'), 1028 StyleSheetRemoved: Symbol('StyleSheetRemoved'),
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 WebInspector.CSSModel.InlineStyleResult = class { 1205 WebInspector.CSSModel.InlineStyleResult = class {
1180 /** 1206 /**
1181 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle 1207 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle
1182 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle 1208 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle
1183 */ 1209 */
1184 constructor(inlineStyle, attributesStyle) { 1210 constructor(inlineStyle, attributesStyle) {
1185 this.inlineStyle = inlineStyle; 1211 this.inlineStyle = inlineStyle;
1186 this.attributesStyle = attributesStyle; 1212 this.attributesStyle = attributesStyle;
1187 } 1213 }
1188 }; 1214 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698