mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Backed out changeset 89ba5f983e61 (bug 1525238) for dt failures at browser_changes_rule_selector.js and browser_inspector_highlighter-eyedropper-xul.js.
This commit is contained in:
parent
d6292e3e7e
commit
b2ca1f33d7
@ -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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user