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

Delta Between Two Patch Sets: lib/requestNotifier.js

Issue 6305806509146112: Issue 427 - Remove non-standard function and getter syntax (Closed)
Left Patch Set: Created May 5, 2014, 12:18 p.m.
Right Patch Set: Wow sorry for those wrong braces, I am so used to a different style that I didn't even realize what… Created May 18, 2014, 10:51 a.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
« no previous file with change/comment | « lib/io.js ('k') | lib/subscriptionClasses.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 <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 26
27 let nodeData = new WeakMap(); 27 let nodeData = new WeakMap();
28 let windowStats = new WeakMap(); 28 let windowStats = new WeakMap();
29 let windowSelection = new WeakMap(); 29 let windowSelection = new WeakMap();
30 30
31 let setEntry, hasEntry, getEntry; 31 let setEntry, hasEntry, getEntry;
32 if (false) 32 if (false)
33 { 33 {
34 // This branch can be enabled again once all of bug 673468, bug 819131 and 34 // This branch can be enabled again once all of bug 673468, bug 819131 and
35 // bug 982561 are fixed and we can use weak maps. 35 // bug 982561 are fixed and we can use weak maps.
36 setEntry = function(map, key, value) { map.set(key, value); }; 36 setEntry = (map, key, value) => map.set(key, value);
37 hasEntry = function(map, key) { return map.has(key); }; 37 hasEntry = (map, key) => map.has(key);
38 getEntry = function(map, key) { return map.get(key); }; 38 getEntry = (map, key) => map.get(key);
39 } 39 }
40 else 40 else
41 { 41 {
42 // Fall back to user data 42 // Fall back to user data
43 let dataSeed = Math.random(); 43 let dataSeed = Math.random();
44 let nodeDataProp = "abpNodeData" + dataSeed; 44 let nodeDataProp = "abpNodeData" + dataSeed;
45 let windowStatsProp = "abpWindowStats" + dataSeed; 45 let windowStatsProp = "abpWindowStats" + dataSeed;
46 let windowSelectionProp = "abpWindowSelection" + dataSeed; 46 let windowSelectionProp = "abpWindowSelection" + dataSeed;
47 let getProp = function(map) 47 let getProp = function(map)
48 { 48 {
49 switch (map) 49 switch (map)
50 { 50 {
51 case nodeData: 51 case nodeData:
52 return nodeDataProp; 52 return nodeDataProp;
53 case windowStats: 53 case windowStats:
54 return windowStatsProp; 54 return windowStatsProp;
55 case windowSelection: 55 case windowSelection:
56 return windowSelectionProp; 56 return windowSelectionProp;
57 default: 57 default:
58 return null; 58 return null;
59 } 59 }
60 }; 60 };
61 61
62 setEntry = function(map, key, value) { 62 setEntry = (map, key, value) => key.setUserData(getProp(map), value, null);
63 key.setUserData(getProp(map), value, null); 63 hasEntry = (map, key) => key.getUserData(getProp(map));
64 }; 64 getEntry = (map, key) => key.getUserData(getProp(map)) || undefined;
65 hasEntry = function(map, key) {
66 return key.getUserData(getProp(map));
67 };
68 getEntry = function(map, key) {
69 return key.getUserData(getProp(map)) || undefined;
70 };
71 } 65 }
72 66
73 /** 67 /**
74 * List of notifiers in use - these notifiers need to receive notifications on 68 * List of notifiers in use - these notifiers need to receive notifications on
75 * new requests. 69 * new requests.
76 * @type RequestNotifier[] 70 * @type RequestNotifier[]
77 */ 71 */
78 let activeNotifiers = []; 72 let activeNotifiers = [];
79 73
80 /** 74 /**
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 location: null, 341 location: null,
348 /** 342 /**
349 * Filter that was applied to this request (if any) 343 * Filter that was applied to this request (if any)
350 * @type Filter 344 * @type Filter
351 */ 345 */
352 filter: null, 346 filter: null,
353 /** 347 /**
354 * String representation of the content type, e.g. "subdocument" 348 * String representation of the content type, e.g. "subdocument"
355 * @type String 349 * @type String
356 */ 350 */
357 get typeDescr() { return require("contentPolicy").Policy.typeDescr[this.type]; }, 351 get typeDescr()
352 {
353 return require("contentPolicy").Policy.typeDescr[this.type];
354 },
358 /** 355 /**
359 * User-visible localized representation of the content type, e.g. "frame" 356 * User-visible localized representation of the content type, e.g. "frame"
360 * @type String 357 * @type String
361 */ 358 */
362 get localizedDescr() { return require("contentPolicy").Policy.localizedDescr[t his.type]; }, 359 get localizedDescr()
360 {
361 return require("contentPolicy").Policy.localizedDescr[this.type];
362 },
363 363
364 /** 364 /**
365 * Attaches this request object to a DOM node. 365 * Attaches this request object to a DOM node.
366 */ 366 */
367 attachToNode: function(/**Node*/ node) 367 attachToNode: function(/**Node*/ node)
368 { 368 {
369 let existingData = getEntry(nodeData, node); 369 let existingData = getEntry(nodeData, node);
370 if (typeof existingData == "undefined") 370 if (typeof existingData == "undefined")
371 { 371 {
372 existingData = {}; 372 existingData = {};
373 setEntry(nodeData, node, existingData); 373 setEntry(nodeData, node, existingData);
374 } 374 }
375 375
376 // Add this request to the node data 376 // Add this request to the node data
377 existingData[this.type + " " + this.location] = this; 377 existingData[this.type + " " + this.location] = this;
378 } 378 }
379 }; 379 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld