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

Side by Side Diff: Source/devtools/front_end/sdk/CSSStyleModel.js

Issue 1273313002: DevTools: introduce dom markers, decorate hidden, forced state and breakpoint elements using marker… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: for landing Created 5 years, 4 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
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 this._styleLoader = new WebInspector.CSSStyleModel.ComputedStyleLoader(this) ; 42 this._styleLoader = new WebInspector.CSSStyleModel.ComputedStyleLoader(this) ;
43 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve ntTypes.MainFrameNavigated, this._mainFrameNavigated, this); 43 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve ntTypes.MainFrameNavigated, this._mainFrameNavigated, this);
44 target.registerCSSDispatcher(new WebInspector.CSSDispatcher(this)); 44 target.registerCSSDispatcher(new WebInspector.CSSDispatcher(this));
45 this._agent.enable().then(this._wasEnabled.bind(this)); 45 this._agent.enable().then(this._wasEnabled.bind(this));
46 /** @type {!Map.<string, !WebInspector.CSSStyleSheetHeader>} */ 46 /** @type {!Map.<string, !WebInspector.CSSStyleSheetHeader>} */
47 this._styleSheetIdToHeader = new Map(); 47 this._styleSheetIdToHeader = new Map();
48 /** @type {!Map.<string, !Object.<!PageAgent.FrameId, !Array.<!CSSAgent.Styl eSheetId>>>} */ 48 /** @type {!Map.<string, !Object.<!PageAgent.FrameId, !Array.<!CSSAgent.Styl eSheetId>>>} */
49 this._styleSheetIdsForURL = new Map(); 49 this._styleSheetIdsForURL = new Map();
50 } 50 }
51 51
52 WebInspector.CSSStyleModel.PseudoStatePropertyName = "pseudoState";
53
54 /** 52 /**
55 * @param {!WebInspector.CSSStyleModel} cssModel 53 * @param {!WebInspector.CSSStyleModel} cssModel
56 * @param {!Array.<!CSSAgent.RuleMatch>|undefined} matchArray 54 * @param {!Array.<!CSSAgent.RuleMatch>|undefined} matchArray
57 * @return {!Array.<!WebInspector.CSSRule>} 55 * @return {!Array.<!WebInspector.CSSRule>}
58 */ 56 */
59 WebInspector.CSSStyleModel.parseRuleMatchArrayPayload = function(cssModel, match Array) 57 WebInspector.CSSStyleModel.parseRuleMatchArrayPayload = function(cssModel, match Array)
60 { 58 {
61 if (!matchArray) 59 if (!matchArray)
62 return []; 60 return [];
63 61
64 var result = []; 62 var result = [];
65 for (var i = 0; i < matchArray.length; ++i) 63 for (var i = 0; i < matchArray.length; ++i)
66 result.push(WebInspector.CSSRule.parsePayload(cssModel, matchArray[i].ru le, matchArray[i].matchingSelectors)); 64 result.push(WebInspector.CSSRule.parsePayload(cssModel, matchArray[i].ru le, matchArray[i].matchingSelectors));
67 return result; 65 return result;
68 } 66 }
69 67
70 WebInspector.CSSStyleModel.Events = { 68 WebInspector.CSSStyleModel.Events = {
71 MediaQueryResultChanged: "MediaQueryResultChanged", 69 MediaQueryResultChanged: "MediaQueryResultChanged",
72 ModelWasEnabled: "ModelWasEnabled", 70 ModelWasEnabled: "ModelWasEnabled",
73 PseudoStateForced: "PseudoStateForced", 71 PseudoStateForced: "PseudoStateForced",
74 StyleSheetAdded: "StyleSheetAdded", 72 StyleSheetAdded: "StyleSheetAdded",
75 StyleSheetChanged: "StyleSheetChanged", 73 StyleSheetChanged: "StyleSheetChanged",
76 StyleSheetRemoved: "StyleSheetRemoved" 74 StyleSheetRemoved: "StyleSheetRemoved"
77 } 75 }
78 76
79 WebInspector.CSSStyleModel.MediaTypes = ["all", "braille", "embossed", "handheld ", "print", "projection", "screen", "speech", "tty", "tv"]; 77 WebInspector.CSSStyleModel.MediaTypes = ["all", "braille", "embossed", "handheld ", "print", "projection", "screen", "speech", "tty", "tv"];
80 78
79 WebInspector.CSSStyleModel.PseudoStateMarker = "pseudo-state-marker";
80
81 WebInspector.CSSStyleModel.prototype = { 81 WebInspector.CSSStyleModel.prototype = {
82 /** 82 /**
83 * @return {!Promise.<!Array.<!WebInspector.CSSMedia>>} 83 * @return {!Promise.<!Array.<!WebInspector.CSSMedia>>}
84 */ 84 */
85 mediaQueriesPromise: function() 85 mediaQueriesPromise: function()
86 { 86 {
87 /** 87 /**
88 * @param {?Protocol.Error} error 88 * @param {?Protocol.Error} error
89 * @param {?Array.<!CSSAgent.CSSMedia>} payload 89 * @param {?Array.<!CSSAgent.CSSMedia>} payload
90 * @return {!Array.<!WebInspector.CSSMedia>} 90 * @return {!Array.<!WebInspector.CSSMedia>}
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 }, 243 },
244 244
245 /** 245 /**
246 * @param {!WebInspector.DOMNode} node 246 * @param {!WebInspector.DOMNode} node
247 * @param {string} pseudoClass 247 * @param {string} pseudoClass
248 * @param {boolean} enable 248 * @param {boolean} enable
249 * @return {boolean} 249 * @return {boolean}
250 */ 250 */
251 forcePseudoState: function(node, pseudoClass, enable) 251 forcePseudoState: function(node, pseudoClass, enable)
252 { 252 {
253 var pseudoClasses = node.getUserProperty(WebInspector.CSSStyleModel.Pseu doStatePropertyName) || []; 253 var pseudoClasses = node.marker(WebInspector.CSSStyleModel.PseudoStateMa rker) || [];
254 if (enable) { 254 if (enable) {
255 if (pseudoClasses.indexOf(pseudoClass) >= 0) 255 if (pseudoClasses.indexOf(pseudoClass) >= 0)
256 return false; 256 return false;
257 pseudoClasses.push(pseudoClass); 257 pseudoClasses.push(pseudoClass);
258 node.setUserProperty(WebInspector.CSSStyleModel.PseudoStatePropertyN ame, pseudoClasses); 258 node.setMarker(WebInspector.CSSStyleModel.PseudoStateMarker, pseudoC lasses);
259 } else { 259 } else {
260 if (pseudoClasses.indexOf(pseudoClass) < 0) 260 if (pseudoClasses.indexOf(pseudoClass) < 0)
261 return false; 261 return false;
262 pseudoClasses.remove(pseudoClass); 262 pseudoClasses.remove(pseudoClass);
263 if (!pseudoClasses.length) 263 if (!pseudoClasses.length)
264 node.removeUserProperty(WebInspector.CSSStyleModel.PseudoStatePr opertyName); 264 node.setMarker(WebInspector.CSSStyleModel.PseudoStateMarker, nul l);
265 } 265 }
266 266
267 this._agent.forcePseudoState(node.id, pseudoClasses); 267 this._agent.forcePseudoState(node.id, pseudoClasses);
268 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.PseudoSt ateForced, { node: node, pseudoClass: pseudoClass, enable: enable }); 268 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.PseudoSt ateForced, { node: node, pseudoClass: pseudoClass, enable: enable });
269 return true; 269 return true;
270 }, 270 },
271 271
272 /** 272 /**
273 * @param {!WebInspector.DOMNode} node
274 * @return {?Array<string>} state
275 */
276 pseudoState: function(node)
277 {
278 return node.marker(WebInspector.CSSStyleModel.PseudoStateMarker) || [];
279 },
280
281 /**
273 * @param {!CSSAgent.CSSRule} rule 282 * @param {!CSSAgent.CSSRule} rule
274 * @param {!DOMAgent.NodeId} nodeId 283 * @param {!DOMAgent.NodeId} nodeId
275 * @param {string} newSelector 284 * @param {string} newSelector
276 * @param {function(?WebInspector.CSSRule)} userCallback 285 * @param {function(?WebInspector.CSSRule)} userCallback
277 */ 286 */
278 setRuleSelector: function(rule, nodeId, newSelector, userCallback) 287 setRuleSelector: function(rule, nodeId, newSelector, userCallback)
279 { 288 {
280 /** 289 /**
281 * @param {?Protocol.Error} error 290 * @param {?Protocol.Error} error
282 * @param {?CSSAgent.CSSRule} rulePayload 291 * @param {?CSSAgent.CSSRule} rulePayload
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 * @constructor 1964 * @constructor
1956 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle 1965 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle
1957 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle 1966 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle
1958 */ 1967 */
1959 WebInspector.CSSStyleModel.InlineStyleResult = function(inlineStyle, attributesS tyle) 1968 WebInspector.CSSStyleModel.InlineStyleResult = function(inlineStyle, attributesS tyle)
1960 { 1969 {
1961 this.inlineStyle = inlineStyle; 1970 this.inlineStyle = inlineStyle;
1962 this.attributesStyle = attributesStyle; 1971 this.attributesStyle = attributesStyle;
1963 } 1972 }
1964 1973
OLDNEW
« no previous file with comments | « Source/devtools/front_end/elements/module.json ('k') | Source/devtools/front_end/sdk/DOMModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698