/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** * Creates a StyleSheetsActor. StyleSheetsActor provides remote access to the * stylesheets of a document.
*/ class StyleSheetsActor extends Actor {
constructor(conn, targetActor) { super(conn, styleSheetsSpec);
this.targetActor = targetActor;
}
/** * The window we work with, taken from the parent actor.
*/
get window() { returnthis.targetActor.window;
}
/** * The current content document of the window we work with.
*/
get document() { returnthis.window.document;
}
getTraits() { return {
traits: {},
};
}
destroy() { for (const win of this.targetActor.windows) { // This flag only exists for devtools, so we are free to clear // it when we're done.
win.document.styleSheetChangeEventsEnabled = false;
}
super.destroy();
}
/** * Create a new style sheet in the document with the given text. * Return an actor for it. * * @param {object} request * Debugging protocol request object, with 'text property' * @param {string} fileName * If the stylesheet adding is from file, `fileName` indicates the path. * @return {object} * Object with 'styelSheet' property for form on new actor.
*/
async addStyleSheet(text, fileName = null) { const styleSheetsManager = this._getStyleSheetsManager();
await styleSheetsManager.addStyleSheet(this.document, text, fileName);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.