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

Delta Between Two Patch Sets: lib/windowObserver.js

Issue 11624001: Fixed: WindowObserver ignoring primary browser window if instantiated before window visible (Closed)
Left Patch Set: Created Sept. 5, 2013, 3:44 p.m.
Right Patch Set: Created Sept. 16, 2013, 3:25 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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 windows = [];
Wladimir Palant 2013/09/09 08:04:22 You are reverting the change I made for https://bu
39 let e = Services.wm.getZOrderDOMWindowEnumerator(null, true);
39 while (e.hasMoreElements()) 40 while (e.hasMoreElements())
41 windows.push(e.getNext());
42
43 // Check if there are any windows that we missed
44 let eAll = Services.ww.getWindowEnumerator();
45 while (eAll.hasMoreElements())
40 { 46 {
41 let window = e.getNext().QueryInterface(Ci.nsIDOMWindow); 47 let element = eAll.getNext();
48 if (windows.indexOf(element) < 0)
49 windows.push(element);
50 }
51
52 for (let i = 0; i < windows.length; i++)
53 {
54 let window = windows[i].QueryInterface(Ci.nsIDOMWindow);
42 if (when == "start" || window.document.readyState == "complete") 55 if (when == "start" || window.document.readyState == "complete")
43 this._listener.applyToWindow(window); 56 this._listener.applyToWindow(window);
44 else 57 else
45 this.observe(window, "chrome-document-global-created", null); 58 this.observe(window, "chrome-document-global-created", null);
46 } 59 }
47 60
48 Services.obs.addObserver(this, "chrome-document-global-created", true); 61 Services.obs.addObserver(this, "chrome-document-global-created", true);
49 62
50 this._shutdownHandler = function() 63 this._shutdownHandler = function()
51 { 64 {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 window.removeEventListener(event, listener, false); 103 window.removeEventListener(event, listener, false);
91 if (this._shutdownHandler) 104 if (this._shutdownHandler)
92 this._listener.applyToWindow(window); 105 this._listener.applyToWindow(window);
93 }.bind(this); 106 }.bind(this);
94 window.addEventListener(event, listener, false); 107 window.addEventListener(event, listener, false);
95 } 108 }
96 }, 109 },
97 110
98 QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObse rver]) 111 QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObse rver])
99 }; 112 };
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld