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

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

Issue 2122353002: [DevTools] Make resource tree model optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 5 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 21 matching lines...) Expand all
32 * @constructor 32 * @constructor
33 * @extends {WebInspector.SDKModel} 33 * @extends {WebInspector.SDKModel}
34 * @param {!WebInspector.Target} target 34 * @param {!WebInspector.Target} target
35 */ 35 */
36 WebInspector.CSSModel = function(target) 36 WebInspector.CSSModel = function(target)
37 { 37 {
38 WebInspector.SDKModel.call(this, WebInspector.CSSModel, target); 38 WebInspector.SDKModel.call(this, WebInspector.CSSModel, target);
39 this._domModel = WebInspector.DOMModel.fromTarget(target); 39 this._domModel = WebInspector.DOMModel.fromTarget(target);
40 this._agent = target.cssAgent(); 40 this._agent = target.cssAgent();
41 this._styleLoader = new WebInspector.CSSModel.ComputedStyleLoader(this); 41 this._styleLoader = new WebInspector.CSSModel.ComputedStyleLoader(this);
42 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve ntTypes.MainFrameNavigated, this._mainFrameNavigated, this); 42 var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(target);
43 if (resourceTreeModel)
44 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventT ypes.MainFrameNavigated, this._mainFrameNavigated, this);
43 target.registerCSSDispatcher(new WebInspector.CSSDispatcher(this)); 45 target.registerCSSDispatcher(new WebInspector.CSSDispatcher(this));
44 this._agent.enable().then(this._wasEnabled.bind(this)); 46 this._agent.enable().then(this._wasEnabled.bind(this));
45 /** @type {!Map.<string, !WebInspector.CSSStyleSheetHeader>} */ 47 /** @type {!Map.<string, !WebInspector.CSSStyleSheetHeader>} */
46 this._styleSheetIdToHeader = new Map(); 48 this._styleSheetIdToHeader = new Map();
47 /** @type {!Map.<string, !Object.<!PageAgent.FrameId, !Array.<!CSSAgent.Styl eSheetId>>>} */ 49 /** @type {!Map.<string, !Object.<!PageAgent.FrameId, !Array.<!CSSAgent.Styl eSheetId>>>} */
48 this._styleSheetIdsForURL = new Map(); 50 this._styleSheetIdsForURL = new Map();
49 51
50 /** @type {!Map.<!WebInspector.CSSStyleSheetHeader, !Promise<string>>} */ 52 /** @type {!Map.<!WebInspector.CSSStyleSheetHeader, !Promise<string>>} */
51 this._originalStyleSheetText = new Map(); 53 this._originalStyleSheetText = new Map();
52 54
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 return new WebInspector.CSSStyleRule(this, rulePayload); 722 return new WebInspector.CSSStyleRule(this, rulePayload);
721 } 723 }
722 }, 724 },
723 725
724 /** 726 /**
725 * @param {!WebInspector.DOMNode} node 727 * @param {!WebInspector.DOMNode} node
726 * @param {function(?WebInspector.CSSStyleSheetHeader)} userCallback 728 * @param {function(?WebInspector.CSSStyleSheetHeader)} userCallback
727 */ 729 */
728 requestViaInspectorStylesheet: function(node, userCallback) 730 requestViaInspectorStylesheet: function(node, userCallback)
729 { 731 {
730 var frameId = node.frameId() || this.target().resourceTreeModel.mainFram e.id; 732 var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(this.t arget());
733 var frameId = node.frameId() || (resourceTreeModel && resourceTreeModel. mainFrame.id);
731 var headers = this._styleSheetIdToHeader.valuesArray(); 734 var headers = this._styleSheetIdToHeader.valuesArray();
732 for (var i = 0; i < headers.length; ++i) { 735 for (var i = 0; i < headers.length; ++i) {
733 var styleSheetHeader = headers[i]; 736 var styleSheetHeader = headers[i];
734 if (styleSheetHeader.frameId === frameId && styleSheetHeader.isViaIn spector()) { 737 if (styleSheetHeader.frameId === frameId && styleSheetHeader.isViaIn spector()) {
735 userCallback(styleSheetHeader); 738 userCallback(styleSheetHeader);
736 return; 739 return;
737 } 740 }
738 } 741 }
739 742
740 /** 743 /**
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 /** 1205 /**
1203 * @constructor 1206 * @constructor
1204 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle 1207 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle
1205 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle 1208 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle
1206 */ 1209 */
1207 WebInspector.CSSModel.InlineStyleResult = function(inlineStyle, attributesStyle) 1210 WebInspector.CSSModel.InlineStyleResult = function(inlineStyle, attributesStyle)
1208 { 1211 {
1209 this.inlineStyle = inlineStyle; 1212 this.inlineStyle = inlineStyle;
1210 this.attributesStyle = attributesStyle; 1213 this.attributesStyle = attributesStyle;
1211 } 1214 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698