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: Compare child name directly Created April 19, 2018, 9:56 p.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
« no previous file with comments | « 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
@@ -117,31 +117,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))
@@ -199,10 +202,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);
});
« no previous file with comments | « include.preload.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld