Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/content/cssProperties.js

Issue 29335650: Issue 2595 - Use the core code from adblockpluscore (Closed)
Patch Set: Created Feb. 4, 2016, 6:35 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/content/ui/subscriptions.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/content/cssProperties.js
===================================================================
deleted file mode 100644
--- a/chrome/content/cssProperties.js
+++ /dev/null
@@ -1,87 +0,0 @@
-function CSSPropertyFilters(window, addSelectorsFunc) {
- this.window = window;
- this.addSelectorsFunc = addSelectorsFunc;
-}
-
-CSSPropertyFilters.prototype = {
- stringifyStyle: function(style)
- {
- var styles = [];
- for (var i = 0; i < style.length; i++)
- {
- var property = style.item(i);
- var value = style.getPropertyValue(property);
- var priority = style.getPropertyPriority(property);
- styles.push(property + ": " + value + (priority ? " !" + priority : "") + ";");
- }
- styles.sort();
- return styles.join(" ");
- },
-
- findSelectors: function(stylesheet, selectors)
- {
- var rules = stylesheet.cssRules;
- if (!rules)
- return;
-
- for (var i = 0; i < rules.length; i++)
- {
- var rule = rules[i];
- if (rule.type != this.window.CSSRule.STYLE_RULE)
- continue;
-
- var style = this.stringifyStyle(rule.style);
- for (var j = 0; j < this.patterns.length; j++)
- {
- var pattern = this.patterns[j];
- var regexp = pattern.regexp;
-
- if (typeof regexp == "string")
- regexp = pattern.regexp = new RegExp(regexp);
-
- if (regexp.test(style))
- selectors.push(pattern.prefix + rule.selectorText + pattern.suffix);
- }
- }
- },
-
- addSelectors: function(stylesheets)
- {
- var selectors = [];
- for (var i = 0; i < stylesheets.length; i++)
- this.findSelectors(stylesheets[i], selectors);
- this.addSelectorsFunc(selectors);
- },
-
- onLoad: function(event)
- {
- var stylesheet = event.target.sheet;
- if (stylesheet)
- this.addSelectors([stylesheet]);
- },
-
- load: function(callback)
- {
- ext.backgroundPage.sendMessage(
- {
- type: "filters.get",
- what: "cssproperties"
- },
- function(patterns)
- {
- this.patterns = patterns;
- callback();
- }.bind(this)
- );
- },
-
- apply: function()
- {
- if (this.patterns.length > 0)
- {
- var document = this.window.document;
- this.addSelectors(document.styleSheets);
- document.addEventListener("load", this.onLoad.bind(this), true);
- }
- }
-};
« no previous file with comments | « no previous file | chrome/content/ui/subscriptions.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld