deleted file mode 100644
--- a/devtools/server/tests/mochitest/test_css-logic-inheritance.html
+++ /dev/null
@@ -1,46 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-Test that css-logic handles inherited properties correctly
--->
-<head>
- <meta charset="utf-8">
- <title>Test css-logic inheritance</title>
- <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
- <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
-</head>
-<body>
- <div style="margin-left:10px; font-size: 5px">
- <div id="innerdiv">Inner div</div>
- </div>
- <script type="application/javascript;version=1.8">
-
- window.onload = function() {
- var { classes: Cc, utils: Cu, interfaces: Ci } = Components;
- const DOMUtils = Cc["@mozilla.org/inspector/dom-utils;1"]
- .getService(Ci.inIDOMUtils);
-
- const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
- var Services = require("Services");
- const {CssLogic} = require("devtools/shared/inspector/css-logic");
-
-
- SimpleTest.waitForExplicitFinish();
-
- let cssLogic = new CssLogic(DOMUtils.isInheritedProperty);
- cssLogic.highlight(document.getElementById("innerdiv"));
-
- let marginProp = cssLogic.getPropertyInfo("margin-left");
- is(marginProp.matchedRuleCount, 0,
- "margin-left should not be included in matched selectors.");
-
- let fontSizeProp = cssLogic.getPropertyInfo("font-size");
- is(fontSizeProp.matchedRuleCount, 1,
- "font-size should be included in matched selectors.");
-
- SimpleTest.finish();
- }
-
- </script>
-</body>
-</html>
--- a/devtools/shared/inspector/css-logic.js
+++ b/devtools/shared/inspector/css-logic.js
@@ -426,34 +426,16 @@ CssLogic.prototype = {
sheets.splice(i, 1);
i--;
}
}
}
},
/**
- * Process *some* cached stylesheets in the document using your callback. The
- * callback function should return true in order to halt processing.
- *
- * @param {function} callback the function you want executed for some of the
- * CssSheet objects cached.
- * @param {object} scope the scope you want for the callback function. scope
- * will be the this object when callback executes.
- * @return {Boolean} true if callback returns true during any iteration,
- * otherwise false is returned.
- */
- forSomeSheets: function (callback, scope) {
- for (let cacheId in this._sheets) {
- if (this._sheets[cacheId].some(callback, scope)) {
- return true;
- }
- }
- return false;
- },
/**
* Get the number nsIDOMCSSRule objects in the document, counted from all of
* the stylesheets. System sheets are excluded. If a filter is active, this
* tells only the number of nsIDOMCSSRule objects inside the selected
* CSSStyleSheet.
*
* WARNING: This only provides an estimate of the rule count, and the results
@@ -696,50 +678,16 @@ CssLogic.getShortName = function (elemen
let temp = element;
while ((temp = temp.previousElementSibling)) {
priorSiblings++;
}
return element.tagName + "[" + priorSiblings + "]";
};
/**
- * Get an array of short names from the given element to document.body.
- *
- * @param {nsIDOMElement} element the element for which you want the array of
- * short names.
- * @return {array} The array of elements.
- * <p>Each element is an object of the form:
- * <ul>
- * <li>{ display: "what to display for the given (parent) element",
- * <li> element: referenceToTheElement }
- * </ul>
- */
-CssLogic.getShortNamePath = function (element) {
- let doc = element.ownerDocument;
- let reply = [];
-
- if (!element) {
- return reply;
- }
-
- // We want to exclude nodes high up the tree (body/html) unless the user
- // has selected that node, in which case we need to report something.
- do {
- reply.unshift({
- display: CssLogic.getShortName(element),
- element: element
- });
- element = element.parentNode;
- } while (element && element != doc.body && element != doc.head &&
- element != doc);
-
- return reply;
-};
-
-/**
* Get a string list of selectors for a given DOMRule.
*
* @param {DOMRule} domRule
* The DOMRule to parse.
* @return {Array}
* An array of string selectors.
*/
CssLogic.getSelectors = function (domRule) {
@@ -1181,17 +1129,16 @@ function CssSheet(cssLogic, domSheet, in
this._rules = {};
this._ruleCount = -1;
}
CssSheet.prototype = {
_passId: null,
_contentSheet: null,
- _mediaMatches: null,
/**
* Tells if the stylesheet is provided by the browser or not.
*
* @return {boolean} false if this is a browser-provided stylesheet, or true
* otherwise.
*/
get contentSheet() {
@@ -1205,28 +1152,16 @@ CssSheet.prototype = {
* Tells if the stylesheet is disabled or not.
* @return {boolean} true if this stylesheet is disabled, or false otherwise.
*/
get disabled() {
return this.domSheet.disabled;
},
/**
- * Tells if the stylesheet matches the current browser view media.
- * @return {boolean} true if this stylesheet matches the current browser view
- * media, or false otherwise.
- */
- get mediaMatches() {
- if (this._mediaMatches === null) {
- this._mediaMatches = this._cssLogic.mediaMatches(this.domSheet);
- }
- return this._mediaMatches;
- },
-
- /**
* Get a source for a stylesheet, using CssLogic.href
*
* @return {string} the address of the stylesheet.
*/
get href() {
if (this._href) {
return this._href;
}
@@ -1319,78 +1254,16 @@ CssSheet.prototype = {
rule = new CssRule(this, domRule);
this._rules[cacheId].push(rule);
}
return rule;
},
- /**
- * Process each rule in this stylesheet using your callback function. Your
- * function receives one argument: the CssRule object for each CSSStyleRule
- * inside the stylesheet.
- *
- * Note that this method also iterates through @media rules inside the
- * stylesheet.
- *
- * @param {function} callback the function you want to execute for each of
- * the style rules.
- * @param {object} scope the scope you want for the callback function. scope
- * will be the this object when callback executes.
- */
- forEachRule: function (callback, scope) {
- let ruleCount = 0;
- let domRules = this.domSheet.cssRules;
-
- function _iterator(domRule) {
- if (domRule.type == CSSRule.STYLE_RULE) {
- callback.call(scope, this.getRule(domRule));
- ruleCount++;
- } else if (domRule.type == CSSRule.MEDIA_RULE &&
- domRule.cssRules && this._cssLogic.mediaMatches(domRule)) {
- Array.prototype.forEach.call(domRule.cssRules, _iterator, this);
- }
- }
-
- Array.prototype.forEach.call(domRules, _iterator, this);
-
- this._ruleCount = ruleCount;
- },
-
- /**
- * Process *some* rules in this stylesheet using your callback function. Your
- * function receives one argument: the CssRule object for each CSSStyleRule
- * inside the stylesheet. In order to stop processing the callback function
- * needs to return a value.
- *
- * Note that this method also iterates through @media rules inside the
- * stylesheet.
- *
- * @param {function} callback the function you want to execute for each of
- * the style rules.
- * @param {object} scope the scope you want for the callback function. scope
- * will be the this object when callback executes.
- * @return {Boolean} true if callback returns true during any iteration,
- * otherwise false is returned.
- */
- forSomeRules: function (callback, scope) {
- let domRules = this.domSheet.cssRules;
- function _iterator(domRule) {
- if (domRule.type == CSSRule.STYLE_RULE) {
- return callback.call(scope, this.getRule(domRule));
- } else if (domRule.type == CSSRule.MEDIA_RULE &&
- domRule.cssRules && this._cssLogic.mediaMatches(domRule)) {
- return Array.prototype.some.call(domRule.cssRules, _iterator, this);
- }
- return false;
- }
- return Array.prototype.some.call(domRules, _iterator, this);
- },
-
toString: function () {
return "CssSheet[" + this.shortSource + "]";
}
};
/**
* Information about a single CSSStyleRule.
*
@@ -1657,20 +1530,16 @@ CssSelector.prototype = {
* @constructor
*/
function CssPropertyInfo(cssLogic, property, isInherited) {
this._cssLogic = cssLogic;
this.property = property;
this._value = "";
this._isInherited = isInherited;
- // The number of matched rules holding the this.property style property.
- // Additionally, only rules that come from allowed stylesheets are counted.
- this._matchedRuleCount = 0;
-
// 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
// counted. This includes rules that come from filtered stylesheets (those
// that have sheetAllowed = false).
this._matchedSelectors = null;
}
CssPropertyInfo.prototype = {
@@ -1690,32 +1559,16 @@ CssPropertyInfo.prototype = {
console.log("Error reading computed style for " + this.property);
console.log(ex);
}
}
return this._value;
},
/**
- * Retrieve the number of matched rules holding the this.property style
- * property. Only rules that come from allowed stylesheets are counted.
- *
- * @return {number} the number of matched rules.
- */
- get matchedRuleCount() {
- if (!this._matchedSelectors) {
- this._findMatchedSelectors();
- } else if (this.needRefilter) {
- this._refilterSelectors();
- }
-
- return this._matchedRuleCount;
- },
-
- /**
* Retrieve the array holding CssSelectorInfo objects for each of the matched
* selectors, from each of the matched rules. Only selectors coming from
* allowed stylesheets are included in the array.
*
* @return {array} the list of CssSelectorInfo objects of selectors that match
* the highlighted element and its parents.
*/
get matchedSelectors() {
@@ -1732,17 +1585,16 @@ CssPropertyInfo.prototype = {
* Find the selectors that match the highlighted element and its parents.
* Uses CssLogic.processMatchedSelectors() to find the matched selectors,
* passing in a reference to CssPropertyInfo._processMatchedSelector() to
* create CssSelectorInfo objects, which we then sort
* @private
*/
_findMatchedSelectors: function () {
this._matchedSelectors = [];
- this._matchedRuleCount = 0;
this.needRefilter = false;
this._cssLogic.processMatchedSelectors(this._processMatchedSelector, this);
// Sort the selectors by how well they match the given element.
this._matchedSelectors.sort(function (selectorInfo1, selectorInfo2) {
if (selectorInfo1.status > selectorInfo2.status) {
return -1;
@@ -1771,19 +1623,16 @@ CssPropertyInfo.prototype = {
let value = cssRule.getPropertyValue(this.property);
if (value &&
(status == CssLogic.STATUS.MATCHED ||
(status == CssLogic.STATUS.PARENT_MATCH &&
this._isInherited(this.property)))) {
let selectorInfo = new CssSelectorInfo(selector, this.property, value,
status);
this._matchedSelectors.push(selectorInfo);
- if (this._cssLogic._passId !== cssRule._passId && cssRule.sheetAllowed) {
- this._matchedRuleCount++;
- }
}
},
/**
* Refilter the matched selectors array when the CssLogic.sourceFilter
* changes. This allows for quick filter changes.
* @private
*/
@@ -1798,17 +1647,16 @@ CssPropertyInfo.prototype = {
ruleCount++;
}
cssRule._passId = passId;
}
};
if (this._matchedSelectors) {
this._matchedSelectors.forEach(iterator);
- this._matchedRuleCount = ruleCount;
}
this.needRefilter = false;
},
toString: function () {
return "CssPropertyInfo[" + this.property + "]";
},