From b2ca1f33d7f53327b8e47ee8311868fe2adbc988 Mon Sep 17 00:00:00 2001 From: Brindusan Cristian Date: Wed, 6 Feb 2019 13:08:39 +0200 Subject: [PATCH] Backed out changeset 89ba5f983e61 (bug 1525238) for dt failures at browser_changes_rule_selector.js and browser_inspector_highlighter-eyedropper-xul.js. --- .../inspector/changes/reducers/changes.js | 20 ++++++++----------- devtools/server/actors/styles.js | 4 ---- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/devtools/client/inspector/changes/reducers/changes.js b/devtools/client/inspector/changes/reducers/changes.js index 8b8b62f5b1fc..5516ffaadece 100644 --- a/devtools/client/inspector/changes/reducers/changes.js +++ b/devtools/client/inspector/changes/reducers/changes.js @@ -45,8 +45,6 @@ function cloneState(state = {}) { * @param {Object} ruleData * Information about a CSS rule: * { - * id: {String} - * Unique rule id. * selector: {String} * CSS selector text * ancestors: {Array} @@ -68,6 +66,7 @@ function createRule(ruleData, rules) { const ruleAncestry = [...ruleData.ancestors, { ...ruleData }]; return ruleAncestry + // First, generate a unique identifier for each rule. .map((rule, index) => { // Ensure each rule has ancestors excluding itself (expand the flattened rule tree). rule.ancestors = ruleAncestry.slice(0, index); @@ -78,9 +77,7 @@ function createRule(ruleData, rules) { `${rule.typeName} ${(rule.conditionText || rule.name || rule.keyText)}`; } - // 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 getRuleHash(rule); }) // Then, create new entries in the rules collection and assign dependencies. .map((ruleId, index, array) => { @@ -197,20 +194,19 @@ const reducers = { change = { ...defaults, ...change }; state = cloneState(state); + const { type, href, index, isFramed } = change.source; const { selector, ancestors, ruleIndex, type: changeType } = 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({ selector, ancestors, ruleIndex }); + const sourceId = getSourceHash(change.source); + const ruleId = getRuleHash({ selector, ancestors, ruleIndex }); // Copy or create object identifying the source (styelsheet/element) for this change. - const source = Object.assign({}, state[sourceId], change.source); + const source = Object.assign({}, state[sourceId], { type, href, index, isFramed }); // Copy or create collection of all rules ever changed in this source. const rules = Object.assign({}, source.rules); - // Reference or create object identifying the rule for this change. + // Refrence or create object identifying the rule for this change. let rule = rules[ruleId]; if (!rule) { - rule = createRule(change, rules); + rule = createRule({ selector, ancestors, ruleIndex }, rules); if (changeType.startsWith("rule-")) { rule.changeType = changeType; } diff --git a/devtools/server/actors/styles.js b/devtools/server/actors/styles.js index ae5dcf5a6b92..3cfafdc2a60a 100644 --- a/devtools/server/actors/styles.js +++ b/devtools/server/actors/styles.js @@ -1085,12 +1085,10 @@ var StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, { */ get metadata() { const data = {}; - data.id = this.actorID; // Collect information about the rule's ancestors (@media, @supports, @keyframes). // Used to show context for this change in the UI and to match the rule for undo/redo. data.ancestors = this.ancestorRules.map(rule => { return { - id: rule.actorID, // Rule type as number defined by CSSRule.type (ex: 4, 7, 12) // @see https://developer.mozilla.org/en-US/docs/Web/API/CSSRule type: rule.rawRule.type, @@ -1119,7 +1117,6 @@ var StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, { // Used to differentiate between elements which match the same generated selector // but live in different documents (ex: host document and iframe). href: this.rawNode.baseURI, - id: this.pageStyle.walker.getNode(this.rawNode).actorID, // Element style attributes don't have a rule index; use the generated selector. index: data.selector, // Whether the element lives in a different frame than the host document. @@ -1134,7 +1131,6 @@ var StyleRuleActor = protocol.ActorClassWithSpec(styleRuleSpec, { // Inline stylesheets have a null href; Use window URL instead. type: this.sheetActor.href ? "stylesheet" : "inline", href: this.sheetActor.href || this.sheetActor.window.location.toString(), - id: this.sheetActor.actorID, index: this.sheetActor.styleSheetIndex, // Whether the stylesheet lives in a different frame than the host document. isFramed: this.sheetActor.ownerWindow !== this.sheetActor.window,