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

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

Powered by Google App Engine
This is Rietveld 408576698