Bug 1468754 Part 3: Make the StyleRuleActor.setRuleText notify the ChangesActor.
MozReview-Commit-ID: 2ZfCArXts6W
--- a/devtools/server/actors/styles.js
+++ b/devtools/server/actors/styles.js
@@ -1297,26 +1297,36 @@ var StyleRuleActor = protocol.ActorClass
*/
async setRuleText(newText) {
if (!this.canSetRuleText) {
throw new Error("invalid call to setRuleText");
}
if (this.type === ELEMENT_STYLE) {
// For element style rules, set the node's style attribute.
+
+ // Note this change with the ChangesActor.
+ const changesActor = await this.pageStyle.inspector.getChanges();
+ const text = this.rawNode.getAttribute("style");
+ changesActor.pushAttributeChange(this.rawNode, null, "style", text, newText);
+
this.rawNode.setAttribute("style", newText);
} else {
// For stylesheet rules, set the text in the stylesheet.
const parentStyleSheet = this.pageStyle._sheetRef(this._parentSheet);
let {str: cssText} = await parentStyleSheet.getText();
const {offset, text} = getRuleText(cssText, this.line, this.column);
cssText = cssText.substring(0, offset) + newText +
cssText.substring(offset + text.length);
+ // Note this change with the ChangesActor.
+ const changesActor = await this.pageStyle.inspector.getChanges();
+ changesActor.pushStylesheetChange(parentStyleSheet, offset, text, newText);
+
await parentStyleSheet.update(cssText, false, UPDATE_PRESERVING_RULES);
}
this.authoredText = newText;
return this;
},