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

Side by Side Diff: lib/elemHide.js

Issue 5636077285015552: Issue 656 - Replace some __proto__ with Object.create (Closed)
Patch Set: Created June 23, 2014, 8:46 a.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 | « chrome/content/ui/sidebar.js ('k') | lib/filterClasses.js » ('j') | 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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 15 matching lines...) Expand all
26 let {Prefs} = require("prefs"); 26 let {Prefs} = require("prefs");
27 let {ElemHideException} = require("filterClasses"); 27 let {ElemHideException} = require("filterClasses");
28 let {FilterNotifier} = require("filterNotifier"); 28 let {FilterNotifier} = require("filterNotifier");
29 let {AboutHandler} = require("elemHideHitRegistration"); 29 let {AboutHandler} = require("elemHideHitRegistration");
30 let {TimeLine} = require("timeline"); 30 let {TimeLine} = require("timeline");
31 31
32 /** 32 /**
33 * Lookup table, filters by their associated key 33 * Lookup table, filters by their associated key
34 * @type Object 34 * @type Object
35 */ 35 */
36 let filterByKey = {__proto__: null}; 36 let filterByKey = Object.create(null);
37 37
38 /** 38 /**
39 * Lookup table, keys of the filters by filter text 39 * Lookup table, keys of the filters by filter text
40 * @type Object 40 * @type Object
41 */ 41 */
42 let keyByFilter = {__proto__: null}; 42 let keyByFilter = Object.create(null);
43 43
44 /** 44 /**
45 * Lookup table, keys are known element hiding exceptions 45 * Lookup table, keys are known element hiding exceptions
46 * @type Object 46 * @type Object
47 */ 47 */
48 let knownExceptions = {__proto__: null}; 48 let knownExceptions = Object.create(null);
49 49
50 /** 50 /**
51 * Lookup table, lists of element hiding exceptions by selector 51 * Lookup table, lists of element hiding exceptions by selector
52 * @type Object 52 * @type Object
53 */ 53 */
54 let exceptions = {__proto__: null}; 54 let exceptions = Object.create(null);
55 55
56 /** 56 /**
57 * Currently applied stylesheet URL 57 * Currently applied stylesheet URL
58 * @type nsIURI 58 * @type nsIURI
59 */ 59 */
60 let styleURL = null; 60 let styleURL = null;
61 61
62 /** 62 /**
63 * Element hiding component 63 * Element hiding component
64 * @class 64 * @class
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 TimeLine.log("done determining stylesheet URL"); 101 TimeLine.log("done determining stylesheet URL");
102 102
103 TimeLine.leave("ElemHide.init() done"); 103 TimeLine.leave("ElemHide.init() done");
104 }, 104 },
105 105
106 /** 106 /**
107 * Removes all known filters 107 * Removes all known filters
108 */ 108 */
109 clear: function() 109 clear: function()
110 { 110 {
111 filterByKey = {__proto__: null}; 111 filterByKey = Object.create(null);
112 keyByFilter = {__proto__: null}; 112 keyByFilter = Object.create(null);
113 knownExceptions = {__proto__: null}; 113 knownExceptions = Object.create(null);
114 exceptions = {__proto__: null}; 114 exceptions = Object.create(null);
115 ElemHide.isDirty = false; 115 ElemHide.isDirty = false;
116 ElemHide.unapply(); 116 ElemHide.unapply();
117 }, 117 },
118 118
119 /** 119 /**
120 * Add a new element hiding filter 120 * Add a new element hiding filter
121 * @param {ElemHideFilter} filter 121 * @param {ElemHideFilter} filter
122 */ 122 */
123 add: function(filter) 123 add: function(filter)
124 { 124 {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 298
299 this._applying = true; 299 this._applying = true;
300 300
301 TimeLine.leave("ElemHide.apply() done", "ElemHideWrite"); 301 TimeLine.leave("ElemHide.apply() done", "ElemHideWrite");
302 }, 302 },
303 303
304 _generateCSSContent: function() 304 _generateCSSContent: function()
305 { 305 {
306 // Grouping selectors by domains 306 // Grouping selectors by domains
307 TimeLine.log("start grouping selectors"); 307 TimeLine.log("start grouping selectors");
308 let domains = {__proto__: null}; 308 let domains = Object.create(null);
309 let hasFilters = false; 309 let hasFilters = false;
310 for (let key in filterByKey) 310 for (let key in filterByKey)
311 { 311 {
312 let filter = filterByKey[key]; 312 let filter = filterByKey[key];
313 let domain = filter.selectorDomain || ""; 313 let domain = filter.selectorDomain || "";
314 314
315 let list; 315 let list;
316 if (domain in domains) 316 if (domain in domains)
317 list = domains[domain]; 317 list = domains[domain];
318 else 318 else
319 { 319 {
320 list = {__proto__: null}; 320 list = Object.create(null);
321 domains[domain] = list; 321 domains[domain] = list;
322 } 322 }
323 list[filter.selector] = key; 323 list[filter.selector] = key;
324 hasFilters = true; 324 hasFilters = true;
325 } 325 }
326 TimeLine.log("done grouping selectors"); 326 TimeLine.log("done grouping selectors");
327 327
328 if (!hasFilters) 328 if (!hasFilters)
329 throw Cr.NS_ERROR_NOT_AVAILABLE; 329 throw Cr.NS_ERROR_NOT_AVAILABLE;
330 330
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 410
411 if (specificOnly && (!domains || domains[""])) 411 if (specificOnly && (!domains || domains[""]))
412 continue; 412 continue;
413 413
414 if (filter.isActiveOnDomain(domain) && !this.getException(filter, domain)) 414 if (filter.isActiveOnDomain(domain) && !this.getException(filter, domain))
415 result.push(filter.selector); 415 result.push(filter.selector);
416 } 416 }
417 return result; 417 return result;
418 } 418 }
419 }; 419 };
OLDNEW
« no previous file with comments | « chrome/content/ui/sidebar.js ('k') | lib/filterClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld