/* 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 { Ci } = require("chrome"); const protocol = require("devtools/shared/protocol"); const { LongStringActor } = require("devtools/server/actors/string"); const { MediaRuleActor } = require("devtools/server/actors/media-rule"); const { fetch } = require("devtools/shared/DevToolsUtils"); const { styleSheetSpec } = require("devtools/shared/specs/style-sheet"); const InspectorUtils = require("InspectorUtils"); const { getSourcemapBaseURL, } = require("devtools/server/actors/utils/source-map-utils"); loader.lazyRequireGetter( this, "CssLogic", "devtools/shared/inspector/css-logic" ); loader.lazyRequireGetter( this, ["addPseudoClassLock", "removePseudoClassLock"], "devtools/server/actors/highlighters/utils/markup", true ); loader.lazyRequireGetter( this, "loadSheet", "devtools/shared/layout/utils", 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