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

Side by Side Diff: lib/windowObserver.js

Issue 9318048: When applying to windows on install, use front-to-back order (seebug 819561) (Closed)
Patch Set: Created Feb. 4, 2013, 7:44 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of the Adblock Plus build tools, 2 * This file is part of the Adblock Plus build tools,
3 * Copyright (C) 2006-2012 Eyeo GmbH 3 * Copyright (C) 2006-2012 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 17 matching lines...) Expand all
28 * @param {String} [when] when to execute applyToWindow(). "start" means immed iately 28 * @param {String} [when] when to execute applyToWindow(). "start" means immed iately
29 * when the window opens, "ready" when its contents are available 29 * when the window opens, "ready" when its contents are available
30 * and "end" (default) means to wait until the "load" e vent. 30 * and "end" (default) means to wait until the "load" e vent.
31 * @constructor 31 * @constructor
32 */ 32 */
33 function WindowObserver(listener, when) 33 function WindowObserver(listener, when)
34 { 34 {
35 this._listener = listener; 35 this._listener = listener;
36 this._when = when; 36 this._when = when;
37 37
38 let e = Services.ww.getWindowEnumerator(); 38 let e = Services.wm.getZOrderDOMWindowEnumerator(null, true);
39 if (!e.hasMoreElements())
40 {
41 // On Linux the list returned will be empty, see bug 156333. Fall back to ra ndom order.
42 e = Services.wm.getEnumerator(null);
43 }
39 while (e.hasMoreElements()) 44 while (e.hasMoreElements())
40 { 45 {
41 let window = e.getNext().QueryInterface(Ci.nsIDOMWindow); 46 let window = e.getNext().QueryInterface(Ci.nsIDOMWindow);
42 if (when == "start" || window.document.readyState == "complete") 47 if (when == "start" || window.document.readyState == "complete")
43 this._listener.applyToWindow(window); 48 this._listener.applyToWindow(window);
44 else 49 else
45 this.observe(window, "chrome-document-global-created", null); 50 this.observe(window, "chrome-document-global-created", null);
46 } 51 }
47 52
48 Services.obs.addObserver(this, "chrome-document-global-created", true); 53 Services.obs.addObserver(this, "chrome-document-global-created", true);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 window.removeEventListener(event, listener, false); 95 window.removeEventListener(event, listener, false);
91 if (this._shutdownHandler) 96 if (this._shutdownHandler)
92 this._listener.applyToWindow(window); 97 this._listener.applyToWindow(window);
93 }.bind(this); 98 }.bind(this);
94 window.addEventListener(event, listener, false); 99 window.addEventListener(event, listener, false);
95 } 100 }
96 }, 101 },
97 102
98 QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObse rver]) 103 QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObse rver])
99 }; 104 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld