| Index: lib/requestNotifier.js |
| =================================================================== |
| --- a/lib/requestNotifier.js |
| +++ b/lib/requestNotifier.js |
| @@ -148,61 +148,50 @@ RequestNotifier.prototype = |
| eventsPosted: 0, |
| /** |
| * Starts the initial scan of the window (will recurse into frames). |
| * @param {Window} wnd the window to be scanned |
| */ |
| startScan: function(wnd) |
| { |
| - let currentThread = Utils.threadManager.currentThread; |
| - |
| let doc = wnd.document; |
| let walker = doc.createTreeWalker(doc, Ci.nsIDOMNodeFilter.SHOW_ELEMENT, null, false); |
| - let runnable = |
| + let process = function() |
| { |
| - notifier: null, |
| + if (!this.listener) |
| + return; |
| - run: function() |
| + let node = walker.currentNode; |
| + let data = getEntry(nodeData, node); |
| + if (typeof data != "undefined") |
| + for (let k in data) |
| + this.notifyListener(wnd, node, data[k]); |
| + |
| + if (walker.nextNode()) |
| + Utils.runAsync(process); |
| + else |
| { |
| - if (!this.notifier.listener) |
| - return; |
| + // Done with the current window, start the scan for its frames |
| + for (let i = 0; i < wnd.frames.length; i++) |
| + this.startScan(wnd.frames[i]); |
| - let node = walker.currentNode; |
| - let data = getEntry(nodeData, node); |
| - if (typeof data != "undefined") |
| - for (let k in data) |
| - this.notifier.notifyListener(wnd, node, data[k]); |
| - |
| - if (walker.nextNode()) |
| - currentThread.dispatch(runnable, Ci.nsIEventTarget.DISPATCH_NORMAL); |
| - else |
| + this.eventsPosted--; |
| + if (!this.eventsPosted) |
| { |
| - // Done with the current window, start the scan for its frames |
| - for (let i = 0; i < wnd.frames.length; i++) |
| - this.notifier.startScan(wnd.frames[i]); |
| - |
| - this.notifier.eventsPosted--; |
| - if (!this.notifier.eventsPosted) |
| - { |
| - this.notifier.scanComplete = true; |
| - this.notifier.notifyListener(wnd, null, null); |
| - } |
| - |
| - this.notifier = null; |
| + this.scanComplete = true; |
| + this.notifyListener(wnd, null, null); |
| } |
| } |
| - }; |
| - runnable.notifier = this; |
| + }.bind(this); |
| - // Process each node in a separate event on current thread to allow other |
| - // events to process |
| + // Process each node in a separate event to allow other events to process |
| this.eventsPosted++; |
| - currentThread.dispatch(runnable, Ci.nsIEventTarget.DISPATCH_NORMAL); |
| + Utils.runAsync(process); |
| } |
| }; |
| RequestNotifier.storeSelection = function(/**Window*/ wnd, /**String*/ selection) |
| { |
| setEntry(windowSelection, wnd.document, selection); |
| }; |
| RequestNotifier.getSelection = function(/**Window*/ wnd) /**String*/ |