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

Delta Between Two Patch Sets: lib/contentFiltering.js

Issue 29893559: Issue 6999 - Generate style sheets in background page (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Insert individual rules Created Oct. 2, 2018, 3:39 p.m.
Right Patch Set: Pass selectors if and only if trace is true Created Oct. 2, 2018, 7:07 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 | « include.preload.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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 239
240 if (!inline && !updateFrameStyles(sender.page.id, sender.frame.id, 240 if (!inline && !updateFrameStyles(sender.page.id, sender.frame.id,
241 styleSheet.code)) 241 styleSheet.code))
242 { 242 {
243 inline = true; 243 inline = true;
244 } 244 }
245 245
246 let response = {trace, inline, emulatedPatterns}; 246 let response = {trace, inline, emulatedPatterns};
247 247
248 if (inline) 248 if (inline)
249 response.rules = [...rulesFromStyleSheet(styleSheet.code)]; 249 response.rules = [...rulesFromStyleSheet(styleSheet.code)];
Sebastian Noack 2018/10/02 17:14:02 Why do we have to copy this array?
Sebastian Noack 2018/10/02 17:15:38 Ah, just figured it's a generator. I think I perso
Manish Jethani 2018/10/02 17:23:24 Yes, the spread operator is significantly faster (
Sebastian Noack 2018/10/02 17:28:21 I'd take that benchmark with a grain of salt, sinc
250 else if (trace) 250
Sebastian Noack 2018/10/02 17:14:02 Doesn't the content scripts needs the original sel
Manish Jethani 2018/10/02 19:07:46 Ah, you're right. Done.
251 if (trace)
251 response.selectors = styleSheet.selectors; 252 response.selectors = styleSheet.selectors;
252 253
253 return response; 254 return response;
254 }); 255 });
255 256
256 port.on("content.injectSelectors", (message, sender) => 257 port.on("content.injectSelectors", (message, sender) =>
257 { 258 {
258 let styleSheet = createStyleSheet(message.selectors); 259 let styleSheet = createStyleSheet(message.selectors);
259 if (!userStyleSheetsSupported || 260 if (!userStyleSheetsSupported ||
260 !updateFrameStyles(sender.page.id, sender.frame.id, styleSheet, 261 !updateFrameStyles(sender.page.id, sender.frame.id, styleSheet,
261 message.groupName, message.appendOnly)) 262 message.groupName, message.appendOnly))
262 { 263 {
263 return [...rulesFromStyleSheet(styleSheet)]; 264 return [...rulesFromStyleSheet(styleSheet)];
264 } 265 }
265 }); 266 });
266 267
267 fetch(browser.extension.getURL("/snippets.js"), {cache: "no-cache"}) 268 fetch(browser.extension.getURL("/snippets.js"), {cache: "no-cache"})
268 .then(response => response.ok ? response.text() : "") 269 .then(response => response.ok ? response.text() : "")
269 .then(text => 270 .then(text =>
270 { 271 {
271 snippetsLibrarySource = text; 272 snippetsLibrarySource = text;
272 }); 273 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld