Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 { | 52 { |
53 let notifier = notifiers.get(message.data); | 53 let notifier = notifiers.get(message.data); |
54 if (notifier) | 54 if (notifier) |
55 notifier.shutdown(); | 55 notifier.shutdown(); |
56 } | 56 } |
57 | 57 |
58 /** | 58 /** |
59 * Creates a notifier object for a particular window. After creation the window | 59 * Creates a notifier object for a particular window. After creation the window |
60 * will first be scanned for previously saved requests. Once that scan is | 60 * will first be scanned for previously saved requests. Once that scan is |
61 * complete only new requests for this window will be reported. | 61 * complete only new requests for this window will be reported. |
62 * @param {Window} wnd window to attach the notifier to | 62 * @param {Window} window window to attach the notifier to |
63 * @param {Integer} id Parent notifier ID to be messaged | 63 * @param {Integer} notifierID Parent notifier ID to be messaged |
Thomas Greiner
2015/11/12 12:24:06
Detail: The documented parameter names here do not
Wladimir Palant
2015/11/12 12:40:57
Done.
| |
64 */ | 64 */ |
65 function RequestNotifier(window, notifierID) | 65 function RequestNotifier(window, notifierID) |
66 { | 66 { |
67 this.window = window; | 67 this.window = window; |
68 this.id = notifierID; | 68 this.id = notifierID; |
69 notifiers.set(this.id, this); | 69 notifiers.set(this.id, this); |
70 this.startScan(window); | 70 this.startScan(window); |
71 } | 71 } |
72 exports.RequestNotifier = RequestNotifier; | 72 exports.RequestNotifier = RequestNotifier; |
73 | 73 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 * Starts the initial scan of the window (will recurse into frames). | 122 * Starts the initial scan of the window (will recurse into frames). |
123 * @param {Window} wnd the window to be scanned | 123 * @param {Window} wnd the window to be scanned |
124 */ | 124 */ |
125 startScan: function(wnd) | 125 startScan: function(wnd) |
126 { | 126 { |
127 let doc = wnd.document; | 127 let doc = wnd.document; |
128 let walker = doc.createTreeWalker(doc, Ci.nsIDOMNodeFilter.SHOW_ELEMENT, nul l, false); | 128 let walker = doc.createTreeWalker(doc, Ci.nsIDOMNodeFilter.SHOW_ELEMENT, nul l, false); |
129 | 129 |
130 let process = function() | 130 let process = function() |
131 { | 131 { |
132 // Don't do anything if the notifier was shut down already. | |
132 if (!this.window) | 133 if (!this.window) |
Thomas Greiner
2015/11/12 12:24:06
Detail: I guess you don't need to pass `wnd` anymo
Wladimir Palant
2015/11/12 12:40:57
You misunderstood the check here. startScan is bei
| |
133 return; | 134 return; |
134 | 135 |
135 let node = walker.currentNode; | 136 let node = walker.currentNode; |
136 let data = nodeData.get(node); | 137 let data = nodeData.get(node); |
137 if (typeof data != "undefined") | 138 if (typeof data != "undefined") |
138 for (let k in data) | 139 for (let k in data) |
139 this.notifyListener(data[k]); | 140 this.notifyListener(data[k]); |
140 | 141 |
141 if (walker.nextNode()) | 142 if (walker.nextNode()) |
142 Utils.runAsync(process); | 143 Utils.runAsync(process); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 stats.filters[filter.text]++; | 219 stats.filters[filter.text]++; |
219 else | 220 else |
220 stats.filters[filter.text] = 1; | 221 stats.filters[filter.text] = 1; |
221 } | 222 } |
222 | 223 |
223 // Notify listeners | 224 // Notify listeners |
224 for (let notifier of notifiers.values()) | 225 for (let notifier of notifiers.values()) |
225 if (!notifier.window || notifier.window == topWnd) | 226 if (!notifier.window || notifier.window == topWnd) |
226 notifier.notifyListener(entry); | 227 notifier.notifyListener(entry); |
227 } | 228 } |
LEFT | RIGHT |