Chromium Code Reviews| Index: Source/devtools/front_end/CSSStyleModel.js |
| diff --git a/Source/devtools/front_end/CSSStyleModel.js b/Source/devtools/front_end/CSSStyleModel.js |
| index 3b498de1ef125a5ded82cd23da522dcc7f24f98b..be266881b9b345307650675f0f933bbc6ddca5dd 100644 |
| --- a/Source/devtools/front_end/CSSStyleModel.js |
| +++ b/Source/devtools/front_end/CSSStyleModel.js |
| @@ -281,13 +281,17 @@ WebInspector.CSSStyleModel.prototype = { |
| }, |
| /** |
| - * @param {!DOMAgent.NodeId} nodeId |
| + * @param {!CSSAgent.StyleSheetId} styleSheetId |
| + * @param {!WebInspector.DOMNode} node |
| * @param {string} selector |
| * @param {function(!WebInspector.CSSRule)} successCallback |
| * @param {function()} failureCallback |
| */ |
| - addRule: function(nodeId, selector, successCallback, failureCallback) |
| + addRule: function(styleSheetId, node, selector, successCallback, failureCallback) |
| { |
| + this._pendingCommandsMajorState.push(true); |
| + CSSAgent.addRule(styleSheetId, selector, callback.bind(this)); |
| + |
| /** |
| * @param {?Protocol.Error} error |
| * @param {!CSSAgent.CSSRule} rulePayload |
| @@ -301,12 +305,48 @@ WebInspector.CSSStyleModel.prototype = { |
| failureCallback(); |
| } else { |
| WebInspector.domAgent.markUndoableState(); |
| - this._computeMatchingSelectors(rulePayload, nodeId, successCallback, failureCallback); |
| + this._computeMatchingSelectors(rulePayload, node.id, successCallback, failureCallback); |
| } |
| } |
| + }, |
| - this._pendingCommandsMajorState.push(true); |
| - CSSAgent.addRule(nodeId, selector, callback.bind(this)); |
| + /** |
| + * @param {!WebInspector.DOMNode} node |
| + * @param {function(?WebInspector.CSSStyleSheetHeader)} callback |
| + */ |
| + requestViaInspectorStylesheet: function(node, callback) |
|
lushnikov
2014/02/28 11:55:59
ensureViaInspectorStyleSheet?
vsevik
2014/02/28 14:35:28
I prefer requestViaInspectorStyleSheet.
|
| + { |
| + var frameId = node.frameId() || WebInspector.resourceTreeModel.mainFrame.id; |
| + var viaInspectorStyleSheetHeader; |
| + for (var styleSheetId in this._styleSheetIdToHeader) { |
| + var styleSheetHeader = this._styleSheetIdToHeader[styleSheetId]; |
| + if (styleSheetHeader.frameId === frameId && styleSheetHeader.isViaInspector()) { |
| + viaInspectorStyleSheetHeader = styleSheetHeader; |
|
lushnikov
2014/02/28 11:55:59
we don't need viaInspectorStyleSheetHeader var - l
vsevik
2014/02/28 14:35:28
Done.
|
| + break; |
| + } |
| + } |
| + |
| + if (viaInspectorStyleSheetHeader) { |
| + callback(viaInspectorStyleSheetHeader); |
| + return; |
| + } |
| + |
| + /** |
| + * @this {WebInspector.CSSStyleModel} |
| + * @param {?Protocol.Error} error |
| + * @param {!CSSAgent.StyleSheetId} styleSheetId |
| + */ |
| + function innerCallback(error, styleSheetId) |
| + { |
| + if (error) { |
| + console.error(error); |
| + callback(null); |
| + } |
| + |
| + callback(this._styleSheetIdToHeader[styleSheetId]); |
| + } |
| + |
| + CSSAgent.createViaInspectorStyleSheet(frameId, innerCallback.bind(this)); |
| }, |
| mediaQueryResultChanged: function() |
| @@ -1265,7 +1305,7 @@ WebInspector.CSSStyleSheetHeader.prototype = { |
| */ |
| resourceURL: function() |
| { |
| - return this.origin === "inspector" ? this._viaInspectorResourceURL() : this.sourceURL; |
| + return this.isViaInspector() ? this._viaInspectorResourceURL() : this.sourceURL; |
| }, |
| /** |
| @@ -1425,6 +1465,15 @@ WebInspector.CSSStyleSheetHeader.prototype = { |
| newText += "\n/*# sourceURL=" + this.sourceURL + " */"; |
| CSSAgent.setStyleSheetText(this.id, newText, callback); |
| }, |
| + |
| + /** |
| + * @return {boolean} |
| + */ |
| + isViaInspector: function() |
| + { |
| + return this.origin === "inspector"; |
| + }, |
| + |
| } |
| /** |