зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1553194 - Remove unnecessary isInherited from CssLogic constructor. r=pbro
`isInherited` is a callback function that checks if a given CSS property is inherited. It is misleadingly commented as a cache of inherited properties (which perhaps it is on the InspectorUtils implementation, but on the consumer side it is just a function). The actual call is done by InspectorUtils.isPropertyInherited. There is no need to pass the handler to CssLogic or to CssPropertyInfo since InspectorUtils is available in the same context as the definition of the consumers. There is no other use case where a custom handler is passed to check for inherited properties in so it is safe to remove this as an argument and just use InspectorUtils.isPropertyInherited where needed. This cleans up the code slightly. Differential Revision: https://phabricator.services.mozilla.com/D32016 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
a19ac2626e
Коммит
915619d9c1
|
@ -49,13 +49,7 @@ const COMPAREMODE = {
|
|||
"INTEGER": "int",
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {function} isInherited A function that determines if the CSS property
|
||||
* is inherited.
|
||||
*/
|
||||
function CssLogic(isInherited) {
|
||||
// The cache of examined CSS properties.
|
||||
this._isInherited = isInherited;
|
||||
function CssLogic() {
|
||||
this._propertyInfos = {};
|
||||
}
|
||||
|
||||
|
@ -216,7 +210,7 @@ CssLogic.prototype = {
|
|||
|
||||
let info = this._propertyInfos[property];
|
||||
if (!info) {
|
||||
info = new CssPropertyInfo(this, property, this._isInherited);
|
||||
info = new CssPropertyInfo(this, property);
|
||||
this._propertyInfos[property] = info;
|
||||
}
|
||||
|
||||
|
@ -509,7 +503,7 @@ CssLogic.prototype = {
|
|||
if (rule.getPropertyValue(property) &&
|
||||
(status == STATUS.MATCHED ||
|
||||
(status == STATUS.PARENT_MATCH &&
|
||||
this._isInherited(property)))) {
|
||||
InspectorUtils.isInheritedProperty(property)))) {
|
||||
result[property] = true;
|
||||
return false;
|
||||
}
|
||||
|
@ -1213,15 +1207,12 @@ CssSelector.prototype = {
|
|||
*
|
||||
* @param {CssLogic} cssLogic Reference to the parent CssLogic instance
|
||||
* @param {string} property The CSS property we are gathering information for
|
||||
* @param {function} isInherited A function that determines if the CSS property
|
||||
* is inherited.
|
||||
* @constructor
|
||||
*/
|
||||
function CssPropertyInfo(cssLogic, property, isInherited) {
|
||||
function CssPropertyInfo(cssLogic, property) {
|
||||
this._cssLogic = cssLogic;
|
||||
this.property = property;
|
||||
this._value = "";
|
||||
this._isInherited = isInherited;
|
||||
|
||||
// An array holding CssSelectorInfo objects for each of the matched selectors
|
||||
// that are inside a CSS rule. Only rules that hold the this.property are
|
||||
|
@ -1307,7 +1298,7 @@ CssPropertyInfo.prototype = {
|
|||
if (value &&
|
||||
(status == STATUS.MATCHED ||
|
||||
(status == STATUS.PARENT_MATCH &&
|
||||
this._isInherited(this.property)))) {
|
||||
InspectorUtils.isInheritedProperty(this.property)))) {
|
||||
const selectorInfo = new CssSelectorInfo(selector, this.property, value,
|
||||
status, distance);
|
||||
this._matchedSelectors.push(selectorInfo);
|
||||
|
|
|
@ -73,7 +73,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
|
|||
"creating a PageStyleActor.");
|
||||
}
|
||||
this.walker = inspector.walker;
|
||||
this.cssLogic = new CssLogic(InspectorUtils.isInheritedProperty);
|
||||
this.cssLogic = new CssLogic();
|
||||
|
||||
// Stores the association of DOM objects -> actors
|
||||
this.refMap = new Map();
|
||||
|
|
|
@ -31,12 +31,11 @@ Test that css-logic handles media-queries correctly
|
|||
const {require} = ChromeUtils.import("resource://devtools/shared/Loader.jsm");
|
||||
const Services = require("Services");
|
||||
const {CssLogic} = require("devtools/server/actors/inspector/css-logic");
|
||||
const InspectorUtils = require("InspectorUtils");
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
const div = document.querySelector("div");
|
||||
const cssLogic = new CssLogic(InspectorUtils.isInheritedProperty);
|
||||
const cssLogic = new CssLogic();
|
||||
cssLogic.highlight(div);
|
||||
cssLogic.processMatchedSelectors();
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ Test that css-logic calculates CSS specificity properly
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
createDocument();
|
||||
const cssLogic = new CssLogic(InspectorUtils.isInheritedProperty);
|
||||
const cssLogic = new CssLogic();
|
||||
|
||||
cssLogic.highlight(document.body);
|
||||
const cssSheet = cssLogic.sheets[0];
|
||||
|
|
Загрузка…
Ссылка в новой задаче