Skip to content

Commit

Permalink
remove the ability of element hiding
Browse files Browse the repository at this point in the history
  • Loading branch information
lovelywcm committed Feb 21, 2009
1 parent df8f909 commit 3f098a0
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 363 deletions.
3 changes: 0 additions & 3 deletions chrome/content/composer.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ function init() {
let typeGroup = E("typeGroup");
for each (let type in types)
{
if (type == aup.policy.type.ELEMHIDE)
continue;

let typeNode = document.createElement("checkbox");
typeNode.setAttribute("value", aup.policy.typeDescr[type].toLowerCase());
typeNode.setAttribute("label", aup.policy.localizedDescr[type].toLowerCase());
Expand Down
201 changes: 0 additions & 201 deletions chrome/content/elemhide.js

This file was deleted.

94 changes: 0 additions & 94 deletions chrome/content/filterClasses.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ aup.Filter = Filter;
*/
Filter.knownFilters = {__proto__: null};

/**
* Regular expression that element hiding filters should match
* @type RegExp
*/
Filter.elemhideRegExp = /^([^\/\*\|\@"]*?)#(?:([\w\-]+|\*)((?:\([\w\-]+(?:[$^*]?=[^\(\)"]*)?\))*)|#([^{}]+))$/;
/**
* Regular expression that RegExp filters specified as RegExps should match (with options already removed)
* @type RegExp
Expand Down Expand Up @@ -107,8 +102,6 @@ Filter.fromText = function(text)
return Filter.knownFilters[text];

let ret;
if (Filter.elemhideRegExp.test(text))
ret = ElemHideFilter.fromText(text, RegExp.$1, RegExp.$2, RegExp.$3, RegExp.$4);
else if (text[0] == "!")
ret = new CommentFilter(text);
else
Expand Down Expand Up @@ -530,90 +523,3 @@ WhitelistFilter.prototype =
__proto__: RegExpFilter.prototype
}
aup.WhitelistFilter = WhitelistFilter;

/**
* Class for element hiding filters
* @param {String} text see Filter()
* @param {String} domain Host name or domain the filter should be restricted to (can be null for no restriction)
* @param {String} selector CSS selector for the HTML elements that should be hidden
* @constructor
* @augments ActiveFilter
*/
function ElemHideFilter(text, domain, selector)
{
ActiveFilter.call(this, text);

this.domain = domain;
this.selector = selector;
}
ElemHideFilter.prototype =
{
__proto__: ActiveFilter.prototype,

/**
* Host name or domain the filter should be restricted to (can be null for no restriction)
* @type String
*/
domain: null,
/**
* CSS selector for the HTML elements that should be hidden
* @type String
*/
selector: null,

/**
* Random key associated with the filter - used to register hits from element hiding filters
* @type String
*/
key: null
};
aup.ElemHideFilter = ElemHideFilter;

/**
* Creates an element hiding filter from a pre-parsed text representation
*
* @param {String} text same as in Filter()
* @param {String} domain (optional) domain part of the text representation
* @param {String} tagName (optional) tag name part
* @param {String} attrRules (optional) attribute matching rules
* @param {String} selector (optional) raw CSS selector
* @return {ElemHideFilter or InvalidFilter}
*/
ElemHideFilter.fromText = function(text, domain, tagName, attrRules, selector)
{
domain = domain.replace(/^,+/, "").replace(/,+$/, "").replace(/,+/g, ",");

if (!selector)
{
if (tagName == "*")
tagName = "";

let id = null;
let additional = "";
if (attrRules) {
attrRules = attrRules.match(/\([\w\-]+(?:[$^*]?=[^\(\)"]*)?\)/g);
for each (let rule in attrRules) {
rule = rule.substr(1, rule.length - 2);
let separatorPos = rule.indexOf("=");
if (separatorPos > 0) {
rule = rule.replace(/=/, '="') + '"';
additional += "[" + rule + "]";
}
else {
if (id)
return new InvalidFilter(text, aup.getString("filter_elemhide_duplicate_id"));
else
id = rule;
}
}
}

if (id)
selector = tagName + "." + id + additional + "," + tagName + "#" + id + additional;
else if (tagName || additional)
selector = tagName + additional;
else
return new InvalidFilter(text, aup.getString("filter_elemhide_nocriteria"));
}
return new ElemHideFilter(text, domain, selector);
}
18 changes: 4 additions & 14 deletions chrome/content/filterListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
* ***** END LICENSE BLOCK ***** */

/*
* Component synchronizing filter storage with Matcher instances and elemhide.
* Component synchronizing filter storage with Matcher instances.
* This file is included from nsAutoProxy.js.
*/

/**
* This object will listen for changes in filters and subscription and forward these
* to Matcher instances and elemhide object.
* to Matcher instances.
* @class
*/
var filterListener =
Expand All @@ -47,7 +47,7 @@ var filterListener =
},

/**
* Notifies Matcher instances or elemhide object about a new filter
* Notifies Matcher instances about a new filter
* if necessary.
* @param {Filter} filter filter that has been added
*/
Expand All @@ -60,12 +60,10 @@ var filterListener =
blacklistMatcher.add(filter);
else if (filter instanceof WhitelistFilter)
whitelistMatcher.add(filter);
else if (filter instanceof ElemHideFilter)
elemhide.add(filter);
},

/**
* Notifies Matcher instances or elemhide object about removal of a filter
* Notifies Matcher instances about removal of a filter
* if necessary.
* @param {Filter} filter filter that has been removed
*/
Expand All @@ -78,8 +76,6 @@ var filterListener =
blacklistMatcher.remove(filter);
else if (filter instanceof WhitelistFilter)
whitelistMatcher.remove(filter);
else if (filter instanceof ElemHideFilter)
elemhide.remove(filter);
},

/**
Expand Down Expand Up @@ -136,14 +132,10 @@ var filterListener =
{
blacklistMatcher.clear();
whitelistMatcher.clear();
elemhide.clear();
for each (let subscription in subscriptions)
if (!subscription.disabled)
subscription.filters.forEach(this.addFilter, this);
}

if (elemhide.isDirty)
elemhide.apply();
},

/**
Expand All @@ -170,8 +162,6 @@ var filterListener =
});
}
filters.forEach(method, this);
if (elemhide.isDirty)
elemhide.apply();
}
}
};
Expand Down
Loading

0 comments on commit 3f098a0

Please sign in to comment.