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

Side by Side Diff: lib/child/cssProperties.js

Issue 29340718: Issue 3964 - Fix race condition, CSS property filters applying too early (Closed)
Patch Set: Created April 21, 2016, 12:56 p.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 Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 Services.scriptloader.loadSubScript( 55 Services.scriptloader.loadSubScript(
56 "chrome://adblockplus/content/cssProperties.js", scope); 56 "chrome://adblockplus/content/cssProperties.js", scope);
57 57
58 let onContentWindow = (subject, topic, data) => 58 let onContentWindow = (subject, topic, data) =>
59 { 59 {
60 if (!(subject instanceof Ci.nsIDOMWindow)) 60 if (!(subject instanceof Ci.nsIDOMWindow))
61 return; 61 return;
62 62
63 let onReady = event => 63 let onReady = event =>
64 { 64 {
65 subject.removeEventListener("DOMContentLoaded", onReady); 65 subject.removeEventListener("load", onReady);
66 let handler = new scope.CSSPropertyFilters(subject, selectors => 66 let handler = new scope.CSSPropertyFilters(subject, selectors =>
67 { 67 {
68 if (selectors.length == 0) 68 if (selectors.length == 0)
69 return; 69 return;
70 70
71 addUserCSS(subject, selectors.map( 71 addUserCSS(subject, selectors.map(
72 selector => selector + "{display: none !important;}" 72 selector => selector + "{display: none !important;}"
73 ).join("\n")); 73 ).join("\n"));
74 }); 74 });
75 75
76 // HACK: The content script just calls ext.backgroundPage.sendMessage 76 // HACK: The content script just calls ext.backgroundPage.sendMessage
77 // without indicating which window this is about. We'll store the window 77 // without indicating which window this is about. We'll store the window
78 // here because we know that messaging happens synchronously. 78 // here because we know that messaging happens synchronously.
79 senderWindow = subject; 79 senderWindow = subject;
80 handler.load(() => handler.apply()); 80 handler.load(() => handler.apply());
81 senderWindow = null; 81 senderWindow = null;
82 }; 82 };
83 83
84 subject.addEventListener("DOMContentLoaded", onReady); 84 subject.addEventListener("load", onReady);
85 }; 85 };
86 86
87 Services.obs.addObserver(onContentWindow, "content-document-global-created", 87 Services.obs.addObserver(onContentWindow, "content-document-global-created",
88 false); 88 false);
89 onShutdown.add(() => 89 onShutdown.add(() =>
90 { 90 {
91 Services.obs.removeObserver(onContentWindow, 91 Services.obs.removeObserver(onContentWindow,
92 "content-document-global-created"); 92 "content-document-global-created");
93 }); 93 });
94 } 94 }
95 95
96 initCSSPropertyFilters(); 96 initCSSPropertyFilters();
97 })(); 97 })();
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