/* 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/. */ "use strict"; const protocol = require("resource://devtools/shared/protocol.js"); const { LongStringActor, } = require("resource://devtools/server/actors/string.js"); const { MediaRuleActor, } = require("resource://devtools/server/actors/media-rule.js"); const { fetch } = require("resource://devtools/shared/DevToolsUtils.js"); const { styleSheetSpec, } = require("resource://devtools/shared/specs/style-sheet.js"); const InspectorUtils = require("InspectorUtils"); const { getSourcemapBaseURL, } = require("resource://devtools/server/actors/utils/source-map-utils.js"); loader.lazyRequireGetter( this, "CssLogic", "resource://devtools/shared/inspector/css-logic.js" ); loader.lazyRequireGetter( this, ["addPseudoClassLock", "removePseudoClassLock"], "resource://devtools/server/actors/highlighters/utils/markup.js", true ); loader.lazyRequireGetter( this, "loadSheet", "resource://devtools/shared/layout/utils.js", true ); var TRANSITION_PSEUDO_CLASS = ":-moz-styleeditor-transitioning"; var TRANSITION_DURATION_MS = 500; var TRANSITION_BUFFER_MS = 1000; var TRANSITION_RULE_SELECTOR = `:root${TRANSITION_PSEUDO_CLASS}, :root${TRANSITION_PSEUDO_CLASS} *`; var TRANSITION_SHEET = "data:text/css;charset=utf-8," + encodeURIComponent(` ${TRANSITION_RULE_SELECTOR} { transition-duration: ${TRANSITION_DURATION_MS}ms !important; transition-delay: 0ms !important; transition-timing-function: ease-out !important; transition-property: all !important; } `); // The possible kinds of style-applied events. // UPDATE_PRESERVING_RULES means that the update is guaranteed to // preserve the number and order of rules on the style sheet. // UPDATE_GENERAL covers any other kind of change to the style sheet. const UPDATE_PRESERVING_RULES = 0; exports.UPDATE_PRESERVING_RULES = UPDATE_PRESERVING_RULES; const UPDATE_GENERAL = 1; exports.UPDATE_GENERAL = UPDATE_GENERAL; // If the user edits a style sheet, we stash a copy of the edited text // here, keyed by the style sheet. This way, if the tools are closed // and then reopened, the edited text will be available. A weak map // is used so that navigation by the user will eventually cause the // edited text to be collected. const modifiedStyleSheets = new WeakMap(); function getSheetText(sheet) { const cssText = modifiedStyleSheets.get(sheet); if (cssText !== undefined) { return Promise.resolve(cssText); } if (!sheet.href) { // this is an inline