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

Side by Side Diff: lib/elemHide.js

Issue 29775605: Noissue - Update JSDoc to mark optionals in lib/elemHide.js (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created May 9, 2018, 5:15 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * Lookup table, filter by selector. (Only used for selectors that are 35 * Lookup table, filter by selector. (Only used for selectors that are
36 * unconditionally matched for all domains.) 36 * unconditionally matched for all domains.)
37 * @type {Map.<string,Filter>} 37 * @type {Map.<string,Filter>}
38 */ 38 */
39 let filterBySelector = new Map(); 39 let filterBySelector = new Map();
40 40
41 /** 41 /**
42 * This array caches the keys of filterBySelector table (selectors 42 * This array caches the keys of filterBySelector table (selectors
43 * which unconditionally apply on all domains). It will be null if the 43 * which unconditionally apply on all domains). It will be null if the
44 * cache needs to be rebuilt. 44 * cache needs to be rebuilt.
45 * @type {?string[]}
45 */ 46 */
46 let unconditionalSelectors = null; 47 let unconditionalSelectors = null;
47 48
48 /** 49 /**
49 * Map to be used instead when a filter has a blank domains property. 50 * Map to be used instead when a filter has a blank domains property.
51 * @type {Map.<string,boolean>}
52 * @const
50 */ 53 */
51 let defaultDomains = new Map([["", true]]); 54 let defaultDomains = new Map([["", true]]);
52 55
53 /** 56 /**
54 * Set containing known element hiding and exception filters 57 * Set containing known element hiding and exception filters
55 * @type {Set.<ElemHideBase>} 58 * @type {Set.<ElemHideBase>}
56 */ 59 */
57 let knownFilters = new Set(); 60 let knownFilters = new Set();
58 61
59 /** 62 /**
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 181 }
179 182
180 knownFilters.delete(filter); 183 knownFilters.delete(filter);
181 FilterNotifier.emit("elemhideupdate"); 184 FilterNotifier.emit("elemhideupdate");
182 }, 185 },
183 186
184 /** 187 /**
185 * Checks whether an exception rule is registered for a filter on a particular 188 * Checks whether an exception rule is registered for a filter on a particular
186 * domain. 189 * domain.
187 * @param {Filter} filter 190 * @param {Filter} filter
188 * @param {string} docDomain 191 * @param {?string} docDomain
189 * @return {ElemHideException} 192 * @return {?ElemHideException}
190 */ 193 */
191 getException(filter, docDomain) 194 getException(filter, docDomain)
192 { 195 {
193 let list = exceptions.get(filter.selector); 196 let list = exceptions.get(filter.selector);
194 if (!list) 197 if (!list)
195 return null; 198 return null;
196 199
197 for (let i = list.length - 1; i >= 0; i--) 200 for (let i = list.length - 1; i >= 0; i--)
198 { 201 {
199 if (list[i].isActiveOnDomain(docDomain)) 202 if (list[i].isActiveOnDomain(docDomain))
(...skipping 10 matching lines...) Expand all
210 getUnconditionalSelectors() 213 getUnconditionalSelectors()
211 { 214 {
212 if (!unconditionalSelectors) 215 if (!unconditionalSelectors)
213 unconditionalSelectors = [...filterBySelector.keys()]; 216 unconditionalSelectors = [...filterBySelector.keys()];
214 return unconditionalSelectors.slice(); 217 return unconditionalSelectors.slice();
215 }, 218 },
216 219
217 /** 220 /**
218 * Constant used by getSelectorsForDomain to return all selectors applying to 221 * Constant used by getSelectorsForDomain to return all selectors applying to
219 * a particular hostname. 222 * a particular hostname.
223 * @type {number}
Manish Jethani 2018/05/09 17:16:57 Unrelated but helpful.
224 * @const
220 */ 225 */
221 ALL_MATCHING: 0, 226 ALL_MATCHING: 0,
222 227
223 /** 228 /**
224 * Constant used by getSelectorsForDomain to exclude selectors which apply to 229 * Constant used by getSelectorsForDomain to exclude selectors which apply to
225 * all websites without exception. 230 * all websites without exception.
231 * @type {number}
232 * @const
226 */ 233 */
227 NO_UNCONDITIONAL: 1, 234 NO_UNCONDITIONAL: 1,
228 235
229 /** 236 /**
230 * Constant used by getSelectorsForDomain to return only selectors for filters 237 * Constant used by getSelectorsForDomain to return only selectors for filters
231 * which specifically match the given host name. 238 * which specifically match the given host name.
239 * @type {number}
240 * @const
232 */ 241 */
233 SPECIFIC_ONLY: 2, 242 SPECIFIC_ONLY: 2,
234 243
235 /** 244 /**
236 * Determines from the current filter list which selectors should be applied 245 * Determines from the current filter list which selectors should be applied
237 * on a particular host name. 246 * on a particular host name.
238 * @param {string} domain 247 * @param {string} domain
239 * @param {number} [criteria] 248 * @param {number} [criteria]
240 * One of the following: ElemHide.ALL_MATCHING, ElemHide.NO_UNCONDITIONAL or 249 * One of the following: ElemHide.ALL_MATCHING, ElemHide.NO_UNCONDITIONAL or
241 * ElemHide.SPECIFIC_ONLY. 250 * ElemHide.SPECIFIC_ONLY.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 if (currentDomain == "") 291 if (currentDomain == "")
283 break; 292 break;
284 293
285 let nextDot = currentDomain.indexOf("."); 294 let nextDot = currentDomain.indexOf(".");
286 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); 295 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1);
287 } 296 }
288 297
289 return selectors; 298 return selectors;
290 } 299 }
291 }; 300 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld