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

Delta Between Two Patch Sets: lib/cssInjection.js

Issue 29670575: Issue 5899 - Use CSS attribute selectors for collapsing media elements (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Use CSS attribute selectors for collapsing Created Feb. 22, 2018, 6:49 a.m.
Right Patch Set: Compare child name directly Created April 19, 2018, 9:56 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
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
(no file at all)
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 return; 115 return;
116 116
117 browser.tabs.removeCSS(tabId, { 117 browser.tabs.removeCSS(tabId, {
118 code: styleSheet, 118 code: styleSheet,
119 cssOrigin: "user", 119 cssOrigin: "user",
120 frameId, 120 frameId,
121 matchAboutBlank: true 121 matchAboutBlank: true
122 }); 122 });
123 } 123 }
124 124
125 function updateFrameStyles(tabId, frameId, selectors, groupName) 125 function updateFrameStyles(tabId, frameId, selectors, groupName, appendOnly)
126 { 126 {
127 let styleSheet = null; 127 let styleSheet = "";
128 if (selectors.length > 0) 128 if (selectors.length > 0)
129 styleSheet = createStyleSheet(selectors); 129 styleSheet = createStyleSheet(selectors);
130 130
131 let frame = ext.getFrame(tabId, frameId); 131 let frame = ext.getFrame(tabId, frameId);
132 if (!frame) 132 if (!frame)
133 return false; 133 return false;
134 134
135 if (!frame.injectedStyleSheets) 135 if (!frame.injectedStyleSheets)
136 frame.injectedStyleSheets = new Map(); 136 frame.injectedStyleSheets = new Map();
137 137
138 let oldStyleSheet = frame.injectedStyleSheets.get(groupName); 138 let oldStyleSheet = frame.injectedStyleSheets.get(groupName);
139
140 if (appendOnly && oldStyleSheet)
141 styleSheet = oldStyleSheet + styleSheet;
139 142
140 // Ideally we would compare the old and new style sheets and skip this code 143 // Ideally we would compare the old and new style sheets and skip this code
141 // if they're the same, but the old style sheet can be a leftover from a 144 // if they're the same, but the old style sheet can be a leftover from a
142 // previous instance of the frame. We must add the new style sheet 145 // previous instance of the frame. We must add the new style sheet
143 // regardless. 146 // regardless.
144 147
145 // Add the new style sheet first to keep previously hidden elements from 148 // Add the new style sheet first to keep previously hidden elements from
146 // reappearing momentarily. 149 // reappearing momentarily.
147 if (styleSheet && !addStyleSheet(tabId, frameId, styleSheet)) 150 if (styleSheet && !addStyleSheet(tabId, frameId, styleSheet))
148 return false; 151 return false;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // add styles for emulation filters inline. 200 // add styles for emulation filters inline.
198 if (!styleSheetRemovalSupported) 201 if (!styleSheetRemovalSupported)
199 response.inlineEmulated = true; 202 response.inlineEmulated = true;
200 203
201 return response; 204 return response;
202 }); 205 });
203 206
204 port.on("elemhide.injectSelectors", (message, sender) => 207 port.on("elemhide.injectSelectors", (message, sender) =>
205 { 208 {
206 updateFrameStyles(sender.page.id, sender.frame.id, message.selectors, 209 updateFrameStyles(sender.page.id, sender.frame.id, message.selectors,
207 message.groupName); 210 message.groupName, message.appendOnly);
208 }); 211 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld