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

Unified Diff: lib/cssInjection.js

Issue 29670575: Issue 5899 - Use CSS attribute selectors for collapsing media elements (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Check for "collapsing" group name Created March 2, 2018, 11:08 a.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
« include.preload.js ('K') | « include.preload.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/cssInjection.js
===================================================================
--- a/lib/cssInjection.js
+++ b/lib/cssInjection.js
@@ -94,31 +94,34 @@
browser.tabs.removeCSS(tabId, {
code: styleSheet,
cssOrigin: "user",
frameId,
matchAboutBlank: true
});
}
-function updateFrameStyles(tabId, frameId, selectors, groupName)
+function updateFrameStyles(tabId, frameId, selectors, groupName, appendOnly)
{
- let styleSheet = null;
+ let styleSheet = "";
if (selectors.length > 0)
styleSheet = createStyleSheet(selectors);
let frame = ext.getFrame(tabId, frameId);
if (!frame)
return false;
if (!frame.injectedStyleSheets)
frame.injectedStyleSheets = new Map();
let oldStyleSheet = frame.injectedStyleSheets.get(groupName);
+ if (appendOnly && oldStyleSheet)
+ styleSheet = oldStyleSheet + styleSheet;
+
// Ideally we would compare the old and new style sheets and skip this code
// 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.
// Add the new style sheet first to keep previously hidden elements from
// reappearing momentarily.
if (styleSheet && !addStyleSheet(tabId, frameId, styleSheet))
@@ -176,10 +179,10 @@
response.inlineEmulated = true;
return response;
});
port.on("elemhide.injectSelectors", (message, sender) =>
{
updateFrameStyles(sender.page.id, sender.frame.id, message.selectors,
- message.groupName);
+ message.groupName, message.appendOnly);
});
« include.preload.js ('K') | « include.preload.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld