| Index: lib/filterListener.js |
| =================================================================== |
| --- a/lib/filterListener.js |
| +++ b/lib/filterListener.js |
| @@ -29,48 +29,28 @@ let {FilterNotifier} = require("filterNo |
| let {ElemHide} = require("elemHide"); |
| let {CSSRules} = require("cssRules"); |
| let {defaultMatcher} = require("matcher"); |
| let {ActiveFilter, RegExpFilter, ElemHideBase, CSSPropertyFilter} = |
| require("filterClasses"); |
| let {Prefs} = require("prefs"); |
| /** |
| - * Value of the FilterListener.batchMode property. |
| - * @type Boolean |
| - */ |
| -let batchMode = false; |
| - |
| -/** |
| * Increases on filter changes, filters will be saved if it exceeds 1. |
| * @type Integer |
| */ |
| let isDirty = 0; |
| /** |
| * This object can be used to change properties of the filter change listeners. |
| * @class |
| */ |
| let FilterListener = |
| { |
| /** |
| - * Set to true when executing many changes, changes will only be fully applied after this variable is set to false again. |
| - * @type Boolean |
| - */ |
| - get batchMode() |
| - { |
| - return batchMode; |
| - }, |
| - set batchMode(value) |
| - { |
| - batchMode = value; |
| - flushElemHide(); |
| - }, |
| - |
| - /** |
| * Increases "dirty factor" of the filters and calls FilterStorage.saveToDisk() |
| * if it becomes 1 or more. Save is executed delayed to prevent multiple |
| * subsequent calls. If the parameter is 0 it forces saving filters if any |
| * changes were recorded after the previous save. |
| */ |
| setDirty: function(/**Integer*/ factor) |
| { |
| if (factor == 0 && isDirty > 0) |
| @@ -126,41 +106,27 @@ function init() |
| FilterNotifier.on("subscription.homepage", onGenericChange); |
| FilterNotifier.on("subscription.downloadStatus", onGenericChange); |
| FilterNotifier.on("subscription.lastCheck", onGenericChange); |
| FilterNotifier.on("subscription.errors", onGenericChange); |
| FilterNotifier.on("load", onLoad); |
| FilterNotifier.on("save", onSave); |
| - |
| - if ("nsIStyleSheetService" in Ci) |
| - ElemHide.init(); |
| - else |
| - flushElemHide = function() {}; // No global stylesheet in Chrome & Co. |
| FilterStorage.loadFromDisk(); |
| Services.obs.addObserver(HistoryPurgeObserver, "browser:purge-session-history", true); |
| onShutdown.add(function() |
| { |
| Services.obs.removeObserver(HistoryPurgeObserver, "browser:purge-session-history"); |
| }); |
| } |
| init(); |
| /** |
| - * Calls ElemHide.apply() if necessary. |
| - */ |
| -function flushElemHide() |
| -{ |
| - if (!batchMode && ElemHide.isDirty) |
| - ElemHide.apply(); |
| -} |
| - |
| -/** |
| * Notifies Matcher instances or ElemHide object about a new filter |
| * if necessary. |
| * @param {Filter} filter filter that has been added |
| */ |
| function addFilter(filter) |
| { |
| if (!(filter instanceof ActiveFilter) || filter.disabled) |
| return; |
| @@ -239,57 +205,49 @@ function addFilters(filters) |
| addFilter(filters[current]); |
| } |
| function onSubscriptionAdded(subscription) |
| { |
| FilterListener.setDirty(1); |
| if (!subscription.disabled) |
| - { |
| addFilters(subscription.filters); |
| - flushElemHide(); |
| - } |
| } |
| function onSubscriptionRemoved(subscription) |
| { |
| FilterListener.setDirty(1); |
| if (!subscription.disabled) |
| - { |
| subscription.filters.forEach(removeFilter); |
| - flushElemHide(); |
| - } |
| } |
| function onSubscriptionDisabled(subscription, newValue) |
| { |
| FilterListener.setDirty(1); |
| if (subscription.url in FilterStorage.knownSubscriptions) |
| { |
| if (newValue == false) |
| addFilters(subscription.filters); |
| else |
| subscription.filters.forEach(removeFilter); |
| - flushElemHide(); |
| } |
| } |
| function onSubscriptionUpdated(subscription) |
| { |
| FilterListener.setDirty(1); |
| if (subscription.url in FilterStorage.knownSubscriptions && |
| !subscription.disabled) |
| { |
| subscription.oldFilters.forEach(removeFilter); |
| addFilters(subscription.filters); |
| - flushElemHide(); |
| } |
| } |
| function onFilterHitCount(filter, newValue) |
| { |
| if (newValue == 0) |
| FilterListener.setDirty(0); |
| else |
| @@ -301,42 +259,35 @@ function onFilterLastHit() |
| FilterListener.setDirty(0.002); |
| } |
| function onFilterAdded(filter) |
| { |
| FilterListener.setDirty(1); |
| if (!filter.disabled) |
| - { |
| addFilter(filter); |
| - flushElemHide(); |
| - } |
| } |
| function onFilterRemoved(filter) |
| { |
| FilterListener.setDirty(1); |
| if (!filter.disabled) |
| - { |
| removeFilter(filter); |
| - flushElemHide(); |
| - } |
| } |
| function onFilterDisabled(filter, newValue) |
| { |
| FilterListener.setDirty(1); |
| if (newValue == false) |
| addFilter(filter); |
| else |
| removeFilter(filter); |
| - flushElemHide(); |
| } |
| function onGenericChange() |
| { |
| FilterListener.setDirty(1); |
| } |
| function onLoad() |
| @@ -344,15 +295,14 @@ function onLoad() |
| isDirty = 0; |
| defaultMatcher.clear(); |
| ElemHide.clear(); |
| CSSRules.clear(); |
| for (let subscription of FilterStorage.subscriptions) |
| if (!subscription.disabled) |
| addFilters(subscription.filters); |
| - flushElemHide(); |
| } |
| function onSave() |
| { |
| isDirty = 0; |
| } |