зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1525326 - Remove backwards compatibility for custom unique ids for rules and stylesheets. r=gl
Since Firefox 67 tracked changes have unique identifiers as follows: - ruleId => StyleRuleActor.actorID - sourceId => StylesheetActor.actorID Given that we're at Firefox 70 and beyond the window where we support connecting to servers older than 3 versions, this patch removes the backwards compatibility provided by methods to generate unique ids based on attributes of the rule and stylesheet for the tracked change. Differential Revision: https://phabricator.services.mozilla.com/D37591 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
9613076e75
Коммит
e97022e21e
|
@ -4,8 +4,6 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { getSourceHash, getRuleHash } = require("../utils/changes-utils");
|
||||
|
||||
const { RESET_CHANGES, TRACK_CHANGE } = require("../actions/index");
|
||||
|
||||
/**
|
||||
|
@ -80,9 +78,7 @@ function createRule(ruleData, rules) {
|
|||
];
|
||||
}
|
||||
|
||||
// Bug 1525326: Remove getRuleHash() in Firefox 70. Until then, we fallback
|
||||
// to the custom hashing method if the server did not provide a rule with an id.
|
||||
return rule.id || getRuleHash(rule);
|
||||
return rule.id;
|
||||
})
|
||||
// Then, create new entries in the rules collection and assign dependencies.
|
||||
.map((ruleId, index, array) => {
|
||||
|
@ -216,11 +212,8 @@ const reducers = {
|
|||
state = cloneState(state);
|
||||
|
||||
const { selector, ancestors, ruleIndex } = change;
|
||||
// Bug 1525326: remove getSourceHash() and getRuleHash() in Firefox 70 after we no
|
||||
// longer support old servers which do not implement the id for the rule and source.
|
||||
const sourceId = change.source.id || getSourceHash(change.source);
|
||||
const ruleId =
|
||||
change.id || getRuleHash({ selectors: [selector], ancestors, ruleIndex });
|
||||
const sourceId = change.source.id;
|
||||
const ruleId = change.id;
|
||||
|
||||
// Copy or create object identifying the source (styelsheet/element) for this change.
|
||||
const source = Object.assign({}, state[sourceId], change.source);
|
||||
|
|
|
@ -6,58 +6,6 @@
|
|||
|
||||
const { getFormatStr, getStr } = require("./l10n");
|
||||
|
||||
/**
|
||||
* Generate a hash that uniquely identifies a stylesheet or element style attribute.
|
||||
*
|
||||
* @param {Object} source
|
||||
* Information about a stylesheet or element style attribute:
|
||||
* {
|
||||
* type: {String}
|
||||
* One of "stylesheet", "inline" or "element".
|
||||
* index: {Number|String}
|
||||
* Position of the styleshet in the list of stylesheets in the document.
|
||||
* If `type` is "element", `index` is the generated selector which
|
||||
* uniquely identifies the element in the document.
|
||||
* href: {String}
|
||||
* URL of the stylesheet or of the document when `type` is "element" or
|
||||
* "inline".
|
||||
* }
|
||||
* @return {String}
|
||||
*/
|
||||
function getSourceHash(source) {
|
||||
const { type, index, href } = source;
|
||||
|
||||
return `${type}${index}${href}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a hash that uniquely identifies a CSS rule.
|
||||
*
|
||||
* @param {Object} ruleData
|
||||
* Information about a CSS rule:
|
||||
* {
|
||||
* selectors: {Array}
|
||||
* Array of CSS selector text
|
||||
* ancestors: {Array}
|
||||
* Flattened CSS rule tree of the rule's ancestors with the root rule
|
||||
* at the beginning of the array and the leaf rule at the end.
|
||||
* ruleIndex: {Array}
|
||||
* Indexes of each ancestor rule within its parent rule.
|
||||
* }
|
||||
* @return {String}
|
||||
*/
|
||||
function getRuleHash(ruleData) {
|
||||
const { selectors = [], ancestors = [], ruleIndex } = ruleData;
|
||||
const atRules = ancestors.reduce((acc, rule) => {
|
||||
acc += `${rule.typeName} ${rule.conditionText ||
|
||||
rule.name ||
|
||||
rule.keyText}`;
|
||||
return acc;
|
||||
}, "");
|
||||
|
||||
return `${atRules}${selectors}${ruleIndex}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a human-friendly style source path to display in the Changes panel.
|
||||
* For element inline styles, return a string indicating that.
|
||||
|
@ -91,5 +39,3 @@ function getSourceForDisplay(source) {
|
|||
}
|
||||
|
||||
module.exports.getSourceForDisplay = getSourceForDisplay;
|
||||
module.exports.getSourceHash = getSourceHash;
|
||||
module.exports.getRuleHash = getRuleHash;
|
||||
|
|
Загрузка…
Ссылка в новой задаче