Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 14 matching lines...) Expand all Loading... | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @extends {WebInspector.SDKModel} | 33 * @extends {WebInspector.SDKModel} |
| 34 * @param {!WebInspector.Target} target | 34 * @param {!WebInspector.Target} target |
| 35 * @param {!WebInspector.DOMModel} domModel | |
| 36 * @param {!WebInspector.ResourceTreeModel} resourceTreeModel | |
| 35 */ | 37 */ |
| 36 WebInspector.CSSModel = function(target) | 38 WebInspector.CSSModel = function(target, domModel, resourceTreeModel) |
| 37 { | 39 { |
| 38 WebInspector.SDKModel.call(this, WebInspector.CSSModel, target); | 40 WebInspector.SDKModel.call(this, WebInspector.CSSModel, target); |
| 39 this._domModel = WebInspector.DOMModel.fromTarget(target); | 41 this._domModel = domModel; |
| 42 this._resourceTreeModel = resourceTreeModel; | |
|
dgozman
2016/07/22 17:19:43
TODO(lushnikov): CSSModel should not depend on fra
eostroukhov-old
2016/07/25 19:36:11
Done.
| |
| 40 this._agent = target.cssAgent(); | 43 this._agent = target.cssAgent(); |
| 41 this._styleLoader = new WebInspector.CSSModel.ComputedStyleLoader(this); | 44 this._styleLoader = new WebInspector.CSSModel.ComputedStyleLoader(this); |
| 42 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve ntTypes.MainFrameNavigated, this._mainFrameNavigated, this); | 45 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes .MainFrameNavigated, this._mainFrameNavigated, this); |
| 43 target.registerCSSDispatcher(new WebInspector.CSSDispatcher(this)); | 46 target.registerCSSDispatcher(new WebInspector.CSSDispatcher(this)); |
| 44 this._agent.enable().then(this._wasEnabled.bind(this)); | 47 this._agent.enable().then(this._wasEnabled.bind(this)); |
| 45 /** @type {!Map.<string, !WebInspector.CSSStyleSheetHeader>} */ | 48 /** @type {!Map.<string, !WebInspector.CSSStyleSheetHeader>} */ |
| 46 this._styleSheetIdToHeader = new Map(); | 49 this._styleSheetIdToHeader = new Map(); |
| 47 /** @type {!Map.<string, !Object.<!PageAgent.FrameId, !Array.<!CSSAgent.Styl eSheetId>>>} */ | 50 /** @type {!Map.<string, !Object.<!PageAgent.FrameId, !Array.<!CSSAgent.Styl eSheetId>>>} */ |
| 48 this._styleSheetIdsForURL = new Map(); | 51 this._styleSheetIdsForURL = new Map(); |
| 49 | 52 |
| 50 /** @type {!Map.<!WebInspector.CSSStyleSheetHeader, !Promise<string>>} */ | 53 /** @type {!Map.<!WebInspector.CSSStyleSheetHeader, !Promise<string>>} */ |
| 51 this._originalStyleSheetText = new Map(); | 54 this._originalStyleSheetText = new Map(); |
| 52 | 55 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 if (!this._sourceMapURLToHeaders.has(header.sourceMapURL)) | 232 if (!this._sourceMapURLToHeaders.has(header.sourceMapURL)) |
| 230 this._sourceMapByURL.delete(header.sourceMapURL); | 233 this._sourceMapByURL.delete(header.sourceMapURL); |
| 231 this.dispatchEventToListeners(WebInspector.CSSModel.Events.SourceMapDeta ched, header); | 234 this.dispatchEventToListeners(WebInspector.CSSModel.Events.SourceMapDeta ched, header); |
| 232 }, | 235 }, |
| 233 | 236 |
| 234 /** | 237 /** |
| 235 * @return {!WebInspector.DOMModel} | 238 * @return {!WebInspector.DOMModel} |
| 236 */ | 239 */ |
| 237 domModel: function() | 240 domModel: function() |
| 238 { | 241 { |
| 239 return /** @type {!WebInspector.DOMModel} */(this._domModel); | 242 return this._domModel; |
| 240 }, | 243 }, |
| 241 | 244 |
| 242 /** | 245 /** |
| 246 * @return {!WebInspector.ResourceTreeModel} | |
| 247 */ | |
| 248 resourceTreeModel: function() | |
|
dgozman
2016/07/22 17:19:43
Let's not expose it.
pfeldman
2016/07/22 17:33:47
We should not expose one model from another.
eostroukhov-old
2016/07/25 19:36:10
Done.
eostroukhov-old
2016/07/25 19:36:10
Done.
| |
| 249 { | |
| 250 return this._resourceTreeModel; | |
| 251 }, | |
| 252 | |
| 253 /** | |
| 243 * @param {!CSSAgent.StyleSheetId} styleSheetId | 254 * @param {!CSSAgent.StyleSheetId} styleSheetId |
| 244 * @param {!WebInspector.TextRange} range | 255 * @param {!WebInspector.TextRange} range |
| 245 * @param {string} text | 256 * @param {string} text |
| 246 * @param {boolean} majorChange | 257 * @param {boolean} majorChange |
| 247 * @return {!Promise<boolean>} | 258 * @return {!Promise<boolean>} |
| 248 */ | 259 */ |
| 249 setStyleText: function(styleSheetId, range, text, majorChange) | 260 setStyleText: function(styleSheetId, range, text, majorChange) |
| 250 { | 261 { |
| 251 var original = this._innerSetStyleTexts.bind(this, [styleSheetId], [rang e], [text], majorChange); | 262 var original = this._innerSetStyleTexts.bind(this, [styleSheetId], [rang e], [text], majorChange); |
| 252 var header = this.styleSheetHeaderForId(styleSheetId); | 263 var header = this.styleSheetHeaderForId(styleSheetId); |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 720 return new WebInspector.CSSStyleRule(this, rulePayload); | 731 return new WebInspector.CSSStyleRule(this, rulePayload); |
| 721 } | 732 } |
| 722 }, | 733 }, |
| 723 | 734 |
| 724 /** | 735 /** |
| 725 * @param {!WebInspector.DOMNode} node | 736 * @param {!WebInspector.DOMNode} node |
| 726 * @param {function(?WebInspector.CSSStyleSheetHeader)} userCallback | 737 * @param {function(?WebInspector.CSSStyleSheetHeader)} userCallback |
| 727 */ | 738 */ |
| 728 requestViaInspectorStylesheet: function(node, userCallback) | 739 requestViaInspectorStylesheet: function(node, userCallback) |
| 729 { | 740 { |
| 730 var frameId = node.frameId() || this.target().resourceTreeModel.mainFram e.id; | 741 var frameId = node.frameId() || this._resourceTreeModel.mainFrame.id; |
|
pfeldman
2016/07/22 17:33:47
We should instead send frameId along with the root
eostroukhov-old
2016/07/25 19:36:10
Done.
| |
| 731 var headers = this._styleSheetIdToHeader.valuesArray(); | 742 var headers = this._styleSheetIdToHeader.valuesArray(); |
| 732 for (var i = 0; i < headers.length; ++i) { | 743 for (var i = 0; i < headers.length; ++i) { |
| 733 var styleSheetHeader = headers[i]; | 744 var styleSheetHeader = headers[i]; |
| 734 if (styleSheetHeader.frameId === frameId && styleSheetHeader.isViaIn spector()) { | 745 if (styleSheetHeader.frameId === frameId && styleSheetHeader.isViaIn spector()) { |
| 735 userCallback(styleSheetHeader); | 746 userCallback(styleSheetHeader); |
| 736 return; | 747 return; |
| 737 } | 748 } |
| 738 } | 749 } |
| 739 | 750 |
| 740 /** | 751 /** |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1208 /** | 1219 /** |
| 1209 * @constructor | 1220 * @constructor |
| 1210 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle | 1221 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle |
| 1211 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle | 1222 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle |
| 1212 */ | 1223 */ |
| 1213 WebInspector.CSSModel.InlineStyleResult = function(inlineStyle, attributesStyle) | 1224 WebInspector.CSSModel.InlineStyleResult = function(inlineStyle, attributesStyle) |
| 1214 { | 1225 { |
| 1215 this.inlineStyle = inlineStyle; | 1226 this.inlineStyle = inlineStyle; |
| 1216 this.attributesStyle = attributesStyle; | 1227 this.attributesStyle = attributesStyle; |
| 1217 } | 1228 } |
| OLD | NEW |