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

Delta Between Two Patch Sets: lib/cssInjection.js

Issue 29545645: Issue 5695 - Use tabs.insertCSS if extensionTypes.CSSOrigin exists (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Simplify further Created Sept. 17, 2017, 1:38 p.m.
Right Patch Set: Flatten out logic and remove blank line Created Sept. 20, 2017, 2:14 a.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 24 matching lines...) Expand all
35 code: selectors.join(", ") + "{display: none !important;}", 35 code: selectors.join(", ") + "{display: none !important;}",
36 cssOrigin: "user", 36 cssOrigin: "user",
37 frameId, 37 frameId,
38 matchAboutBlank: true, 38 matchAboutBlank: true,
39 runAt: "document_start" 39 runAt: "document_start"
40 }); 40 });
41 } 41 }
42 42
43 port.on("elemhide.getSelectors", (msg, sender) => 43 port.on("elemhide.getSelectors", (msg, sender) =>
44 { 44 {
45 let selectors = null; 45 let selectors = [];
46 let trace = devtools && devtools.hasPanel(sender.page); 46 let trace = devtools && devtools.hasPanel(sender.page);
47 let inject = !userStyleSheetsSupported; 47 let inject = !userStyleSheetsSupported;
Manish Jethani 2017/09/17 13:51:38 The trace and inject values are pretty much consta
48 48
49 if (!checkWhitelisted(sender.page, sender.frame, 49 if (!checkWhitelisted(sender.page, sender.frame,
50 RegExpFilter.typeMap.DOCUMENT | 50 RegExpFilter.typeMap.DOCUMENT |
51 RegExpFilter.typeMap.ELEMHIDE)) 51 RegExpFilter.typeMap.ELEMHIDE))
52 { 52 {
53 let specificOnly = checkWhitelisted(sender.page, sender.frame, 53 let specificOnly = checkWhitelisted(sender.page, sender.frame,
54 RegExpFilter.typeMap.GENERICHIDE); 54 RegExpFilter.typeMap.GENERICHIDE);
55 selectors = ElemHide.getSelectorsForDomain( 55 selectors = ElemHide.getSelectorsForDomain(
56 extractHostFromFrame(sender.frame), 56 extractHostFromFrame(sender.frame),
57 specificOnly ? ElemHide.SPECIFIC_ONLY : ElemHide.ALL_MATCHING 57 specificOnly ? ElemHide.SPECIFIC_ONLY : ElemHide.ALL_MATCHING
58 ); 58 );
59
60 if (!inject && selectors.length > 0)
Manish Jethani 2017/09/17 13:51:38 This has been moved inside the if block. If we're
61 hideElements(sender.page.id, sender.frame.id, selectors);
62 } 59 }
63 60
61 if (!inject && selectors.length > 0)
62 hideElements(sender.page.id, sender.frame.id, selectors);
63
64 let response = {trace, inject}; 64 let response = {trace, inject};
Manish Jethani 2017/09/17 13:51:38 trace and inject pretty much have to be passed as
65 65 if (trace || inject)
66 if ((trace || inject) && selectors && selectors.length > 0)
Manish Jethani 2017/09/17 13:51:38 Include a selectors property only if either trace
Manish Jethani 2017/09/17 15:09:19 Or: let selectors = null; ... ... ... r
Sebastian Noack 2017/09/18 22:46:37 How about this? let selectors = []; ... if
Manish Jethani 2017/09/19 05:47:26 OK, I like this. Done.
Sebastian Noack 2017/09/19 23:09:17 Yes, you have to check for selectors.length regard
Manish Jethani 2017/09/20 01:36:29 With the latest patch there's no check for selecto
Sebastian Noack 2017/09/20 01:51:52 Sure, but why don't you just flatten the logic by
Manish Jethani 2017/09/20 02:23:59 Done. selectors starting out as null or an empty
67 response.selectors = selectors; 66 response.selectors = selectors;
68 67
69 return response; 68 return response;
70 }); 69 });
71 70
72 port.on("elemhide.injectSelectors", (msg, sender) => 71 port.on("elemhide.injectSelectors", (msg, sender) =>
73 { 72 {
74 hideElements(sender.page.id, sender.frame.id, msg.selectors); 73 hideElements(sender.page.id, sender.frame.id, msg.selectors);
75 }); 74 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld