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

Delta Between Two Patch Sets: lib/elemHide.js

Issue 30007559: Issue 7285 - Abstract caching logic (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Created Feb. 14, 2019, 5:36 a.m.
Right Patch Set: Add tests and change API and behavior slightly Created Feb. 16, 2019, 12:14 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
« lib/caching.js ('K') | « lib/caching.js ('k') | lib/matcher.js » ('j') | 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 return commonStyleSheet; 220 return commonStyleSheet;
221 } 221 }
222 222
223 /** 223 /**
224 * Returns the domain-specific style sheet that applies on a given domain. 224 * Returns the domain-specific style sheet that applies on a given domain.
225 * @param {string} domain 225 * @param {string} domain
226 * @returns {string} 226 * @returns {string}
227 */ 227 */
228 function getDomainSpecificStyleSheet(domain) 228 function getDomainSpecificStyleSheet(domain)
229 { 229 {
230 let styleSheet = styleSheetCache.read(domain); 230 let styleSheet = styleSheetCache.get(domain);
231 231
232 if (typeof styleSheet == "undefined") 232 if (typeof styleSheet == "undefined")
233 { 233 {
234 styleSheet = createStyleSheet(getConditionalSelectors(domain, false)); 234 styleSheet = createStyleSheet(getConditionalSelectors(domain, false));
235 styleSheetCache.save(domain, styleSheet); 235 styleSheetCache.set(domain, styleSheet);
236 } 236 }
237 237
238 return styleSheet; 238 return styleSheet;
239 } 239 }
240 240
241 ElemHideExceptions.on("added", ({domains, selector}) => 241 ElemHideExceptions.on("added", ({domains, selector}) =>
242 { 242 {
243 styleSheetCache.clear(); 243 styleSheetCache.clear();
244 commonStyleSheet = null; 244 commonStyleSheet = null;
245 245
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 { 494 {
495 let styleSheet = ""; 495 let styleSheet = "";
496 496
497 for (let selectorGroup of splitSelectors(selectors)) 497 for (let selectorGroup of splitSelectors(selectors))
498 styleSheet += createRule(selectorGroup); 498 styleSheet += createRule(selectorGroup);
499 499
500 return styleSheet; 500 return styleSheet;
501 } 501 }
502 502
503 exports.createStyleSheet = createStyleSheet; 503 exports.createStyleSheet = createStyleSheet;
LEFTRIGHT

Powered by Google App Engine
This is Rietveld