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

Side by Side Diff: lib/contentFiltering.js

Issue 29885568: Issue 6967 - Hold on to only non-standard style sheets (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Save only non-standard style sheets instead Created Sept. 20, 2018, 3:12 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 Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // reappearing momentarily. 154 // reappearing momentarily.
155 if (styleSheet && !addStyleSheet(tabId, frameId, styleSheet)) 155 if (styleSheet && !addStyleSheet(tabId, frameId, styleSheet))
156 return false; 156 return false;
157 157
158 // Sometimes the old and new style sheets can be exactly the same. In such a 158 // Sometimes the old and new style sheets can be exactly the same. In such a
159 // case, do not remove the "old" style sheet, because it is in fact the new 159 // case, do not remove the "old" style sheet, because it is in fact the new
160 // style sheet now. 160 // style sheet now.
161 if (oldStyleSheet && oldStyleSheet != styleSheet) 161 if (oldStyleSheet && oldStyleSheet != styleSheet)
162 removeStyleSheet(tabId, frameId, oldStyleSheet); 162 removeStyleSheet(tabId, frameId, oldStyleSheet);
163 163
164 frame.injectedStyleSheets.set(groupName, styleSheet); 164 // The standard style sheet is ~660 KB per frame (as of Adblock Plus 3.3.2).
165 // Keeping it in memory would only really be useful on Firefox, which allows
166 // us to remove it via the tabs.removeCSS API. By choosing not to hold on to
167 // it, we save potentially several megabytes per tab (#6967).
168 if (groupName != "standard")
169 frame.injectedStyleSheets.set(groupName, styleSheet);
165 return true; 170 return true;
166 } 171 }
167 172
168 function getExecutableCode(script) 173 function getExecutableCode(script)
169 { 174 {
170 let code = executableCode.get(script); 175 let code = executableCode.get(script);
171 if (code) 176 if (code)
172 return code; 177 return code;
173 178
174 code = compileScript(script, [snippetsLibrarySource]); 179 code = compileScript(script, [snippetsLibrarySource]);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 updateFrameStyles(sender.page.id, sender.frame.id, message.selectors, 293 updateFrameStyles(sender.page.id, sender.frame.id, message.selectors,
289 message.groupName, message.appendOnly); 294 message.groupName, message.appendOnly);
290 }); 295 });
291 296
292 fetch(browser.extension.getURL("/snippets.js"), {cache: "no-cache"}) 297 fetch(browser.extension.getURL("/snippets.js"), {cache: "no-cache"})
293 .then(response => response.ok ? response.text() : "") 298 .then(response => response.ok ? response.text() : "")
294 .then(text => 299 .then(text =>
295 { 300 {
296 snippetsLibrarySource = text; 301 snippetsLibrarySource = text;
297 }); 302 });
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