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

Delta Between Two Patch Sets: lib/contentFiltering.js

Issue 29958567: Issue 7104 - Clear style sheets when frame structure is updated (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Use state object (includes rebase) Created Dec. 18, 2018, 4:32 p.m.
Right Patch Set: Update comment Created Dec. 19, 2018, 1:47 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 | « ext/background.js ('k') | 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 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 if (!frame.state.injectedStyleSheets) 108 if (!frame.state.injectedStyleSheets)
109 frame.state.injectedStyleSheets = new Map(); 109 frame.state.injectedStyleSheets = new Map();
110 110
111 let oldStyleSheet = frame.state.injectedStyleSheets.get(groupName); 111 let oldStyleSheet = frame.state.injectedStyleSheets.get(groupName);
112 112
113 if (appendOnly && oldStyleSheet) 113 if (appendOnly && oldStyleSheet)
114 styleSheet = oldStyleSheet + styleSheet; 114 styleSheet = oldStyleSheet + styleSheet;
115 115
116 // Ideally we would compare the old and new style sheets and skip this code 116 // Ideally we would compare the old and new style sheets and skip this code
117 // if they're the same, but the old style sheet can be a leftover from a 117 // if they're the same. But first we need to ensure that there are no edge
118 // previous instance of the frame. We must add the new style sheet 118 // cases that would cause the old style sheet to be a leftover from a
119 // regardless. 119 // previous instance of the frame (see issue #7180). For now, we add the new
120 // style sheet regardless.
120 121
121 // Add the new style sheet first to keep previously hidden elements from 122 // Add the new style sheet first to keep previously hidden elements from
122 // reappearing momentarily. 123 // reappearing momentarily.
123 if (styleSheet && !addStyleSheet(tabId, frameId, styleSheet)) 124 if (styleSheet && !addStyleSheet(tabId, frameId, styleSheet))
124 return false; 125 return false;
125 126
126 // Sometimes the old and new style sheets can be exactly the same. In such a 127 // Sometimes the old and new style sheets can be exactly the same. In such a
127 // case, do not remove the "old" style sheet, because it is in fact the new 128 // case, do not remove the "old" style sheet, because it is in fact the new
128 // style sheet now. 129 // style sheet now.
129 if (oldStyleSheet && oldStyleSheet != styleSheet) 130 if (oldStyleSheet && oldStyleSheet != styleSheet)
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 return [...rulesFromStyleSheet(styleSheet)]; 265 return [...rulesFromStyleSheet(styleSheet)];
265 } 266 }
266 }); 267 });
267 268
268 fetch(browser.extension.getURL("/snippets.js"), {cache: "no-cache"}) 269 fetch(browser.extension.getURL("/snippets.js"), {cache: "no-cache"})
269 .then(response => response.ok ? response.text() : "") 270 .then(response => response.ok ? response.text() : "")
270 .then(text => 271 .then(text =>
271 { 272 {
272 snippetsLibrarySource = text; 273 snippetsLibrarySource = text;
273 }); 274 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld