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

Unified Diff: lib/contentFiltering.js

Issue 29958567: Issue 7104 - Clear style sheets when frame structure is updated (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Use state object (includes rebase) Created Dec. 18, 2018, 4:32 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ext/background.js ('K') | « ext/background.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/contentFiltering.js
===================================================================
--- a/lib/contentFiltering.js
+++ b/lib/contentFiltering.js
@@ -100,20 +100,20 @@
function updateFrameStyles(tabId, frameId, styleSheet, groupName = "standard",
appendOnly = false)
{
let frame = ext.getFrame(tabId, frameId);
if (!frame)
return false;
- if (!frame.injectedStyleSheets)
- frame.injectedStyleSheets = new Map();
+ if (!frame.state.injectedStyleSheets)
+ frame.state.injectedStyleSheets = new Map();
- let oldStyleSheet = frame.injectedStyleSheets.get(groupName);
+ let oldStyleSheet = frame.state.injectedStyleSheets.get(groupName);
if (appendOnly && oldStyleSheet)
styleSheet = oldStyleSheet + styleSheet;
// Ideally we would compare the old and new style sheets and skip this code
kzar 2018/12/19 10:22:00 This comment implies we can simplify the logic her
Manish Jethani 2018/12/19 13:03:54 I'd rather not touch this part now unless I'm sure
kzar 2018/12/19 13:07:15 Well fine by me if you worry about improving this
Manish Jethani 2018/12/19 13:27:10 It says "the old style sheet can be a leftover fro
Manish Jethani 2018/12/19 13:29:53 For some context, all of this was originally done
kzar 2018/12/19 13:35:42 Sure, how about this? // Ideally we would compare
Manish Jethani 2018/12/19 13:48:36 Done.
// if they're the same, but the old style sheet can be a leftover from a
// previous instance of the frame. We must add the new style sheet
// regardless.
@@ -129,17 +129,17 @@
if (oldStyleSheet && oldStyleSheet != styleSheet)
removeStyleSheet(tabId, frameId, oldStyleSheet);
// The standard style sheet is ~660 KB per frame (as of Adblock Plus 3.3.2).
// Keeping it in memory would only really be useful on Firefox, which allows
// us to remove it via the tabs.removeCSS API. By choosing not to hold on to
// it, we save potentially several megabytes per tab (#6967).
if (groupName != "standard")
- frame.injectedStyleSheets.set(groupName, styleSheet);
+ frame.state.injectedStyleSheets.set(groupName, styleSheet);
return true;
}
function getExecutableCode(script)
{
let code = executableCode.get(script);
if (code)
return code;
« ext/background.js ('K') | « ext/background.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld