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

Side by Side Diff: lib/filterClasses.js

Issue 6305806509146112: Issue 427 - Remove non-standard function and getter syntax (Closed)
Patch Set: Convert shorthand function expressions to arrow functions, this of course isn't possible for getter… Created May 10, 2014, 12:43 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
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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 __proto__: Filter.prototype, 232 __proto__: Filter.prototype,
233 233
234 _disabled: false, 234 _disabled: false,
235 _hitCount: 0, 235 _hitCount: 0,
236 _lastHit: 0, 236 _lastHit: 0,
237 237
238 /** 238 /**
239 * Defines whether the filter is disabled 239 * Defines whether the filter is disabled
240 * @type Boolean 240 * @type Boolean
241 */ 241 */
242 get disabled() this._disabled, 242 get disabled() {
Wladimir Palant 2014/05/15 07:12:38 Nit: Bracket on the next line please, same for the
243 return this._disabled;
244 },
243 set disabled(value) 245 set disabled(value)
244 { 246 {
245 if (value != this._disabled) 247 if (value != this._disabled)
246 { 248 {
247 let oldValue = this._disabled; 249 let oldValue = this._disabled;
248 this._disabled = value; 250 this._disabled = value;
249 FilterNotifier.triggerListeners("filter.disabled", this, value, oldValue); 251 FilterNotifier.triggerListeners("filter.disabled", this, value, oldValue);
250 } 252 }
251 return this._disabled; 253 return this._disabled;
252 }, 254 },
253 255
254 /** 256 /**
255 * Number of hits on the filter since the last reset 257 * Number of hits on the filter since the last reset
256 * @type Number 258 * @type Number
257 */ 259 */
258 get hitCount() this._hitCount, 260 get hitCount() {
261 return this._hitCount;
262 },
259 set hitCount(value) 263 set hitCount(value)
260 { 264 {
261 if (value != this._hitCount) 265 if (value != this._hitCount)
262 { 266 {
263 let oldValue = this._hitCount; 267 let oldValue = this._hitCount;
264 this._hitCount = value; 268 this._hitCount = value;
265 FilterNotifier.triggerListeners("filter.hitCount", this, value, oldValue); 269 FilterNotifier.triggerListeners("filter.hitCount", this, value, oldValue);
266 } 270 }
267 return this._hitCount; 271 return this._hitCount;
268 }, 272 },
269 273
270 /** 274 /**
271 * Last time the filter had a hit (in milliseconds since the beginning of the epoch) 275 * Last time the filter had a hit (in milliseconds since the beginning of the epoch)
272 * @type Number 276 * @type Number
273 */ 277 */
274 get lastHit() this._lastHit, 278 get lastHit() {
279 return this._lastHit;
280 },
275 set lastHit(value) 281 set lastHit(value)
276 { 282 {
277 if (value != this._lastHit) 283 if (value != this._lastHit)
278 { 284 {
279 let oldValue = this._lastHit; 285 let oldValue = this._lastHit;
280 this._lastHit = value; 286 this._lastHit = value;
281 FilterNotifier.triggerListeners("filter.lastHit", this, value, oldValue); 287 FilterNotifier.triggerListeners("filter.lastHit", this, value, oldValue);
282 } 288 }
283 return this._lastHit; 289 return this._lastHit;
284 }, 290 },
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 this.contentType = contentType; 463 this.contentType = contentType;
458 if (matchCase) 464 if (matchCase)
459 this.matchCase = matchCase; 465 this.matchCase = matchCase;
460 if (thirdParty != null) 466 if (thirdParty != null)
461 this.thirdParty = thirdParty; 467 this.thirdParty = thirdParty;
462 468
463 if (regexpSource.length >= 2 && regexpSource[0] == "/" && regexpSource[regexpS ource.length - 1] == "/") 469 if (regexpSource.length >= 2 && regexpSource[0] == "/" && regexpSource[regexpS ource.length - 1] == "/")
464 { 470 {
465 // The filter is a regular expression - convert it immediately to catch synt ax errors 471 // The filter is a regular expression - convert it immediately to catch synt ax errors
466 let regexp = new RegExp(regexpSource.substr(1, regexpSource.length - 2), thi s.matchCase ? "" : "i"); 472 let regexp = new RegExp(regexpSource.substr(1, regexpSource.length - 2), thi s.matchCase ? "" : "i");
467 this.__defineGetter__("regexp", function() regexp); 473 this.__defineGetter__("regexp", () => regexp);
468 } 474 }
469 else 475 else
470 { 476 {
471 // No need to convert this filter to regular expression yet, do it on demand 477 // No need to convert this filter to regular expression yet, do it on demand
472 this.regexpSource = regexpSource; 478 this.regexpSource = regexpSource;
473 } 479 }
474 } 480 }
475 exports.RegExpFilter = RegExpFilter; 481 exports.RegExpFilter = RegExpFilter;
476 482
477 RegExpFilter.prototype = 483 RegExpFilter.prototype =
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 .replace(/\\\^/g, "(?:[\\x00-\\x24\\x26-\\x2C\\x2F\\x3A-\\x40\\x5B-\\x5E\\ x60\\x7B-\\x7F]|$)") 521 .replace(/\\\^/g, "(?:[\\x00-\\x24\\x26-\\x2C\\x2F\\x3A-\\x40\\x5B-\\x5E\\ x60\\x7B-\\x7F]|$)")
516 .replace(/^\\\|\\\|/, "^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?") // process extended anchor at expression start 522 .replace(/^\\\|\\\|/, "^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?") // process extended anchor at expression start
517 .replace(/^\\\|/, "^") // process anchor at expression start 523 .replace(/^\\\|/, "^") // process anchor at expression start
518 .replace(/\\\|$/, "$") // process anchor at expression end 524 .replace(/\\\|$/, "$") // process anchor at expression end
519 .replace(/^(\.\*)/, "") // remove leading wildcards 525 .replace(/^(\.\*)/, "") // remove leading wildcards
520 .replace(/(\.\*)$/, ""); // remove trailing wildcards 526 .replace(/(\.\*)$/, ""); // remove trailing wildcards
521 527
522 let regexp = new RegExp(source, this.matchCase ? "" : "i"); 528 let regexp = new RegExp(source, this.matchCase ? "" : "i");
523 529
524 delete this.regexpSource; 530 delete this.regexpSource;
525 this.__defineGetter__("regexp", function() regexp); 531 this.__defineGetter__("regexp", () => regexp);
526 return this.regexp; 532 return this.regexp;
527 }, 533 },
528 /** 534 /**
529 * Content types the filter applies to, combination of values from RegExpFilte r.typeMap 535 * Content types the filter applies to, combination of values from RegExpFilte r.typeMap
530 * @type Number 536 * @type Number
531 */ 537 */
532 contentType: 0x7FFFFFFF, 538 contentType: 0x7FFFFFFF,
533 /** 539 /**
534 * Defines whether the filter should distinguish between lower and upper case letters 540 * Defines whether the filter should distinguish between lower and upper case letters
535 * @type Boolean 541 * @type Boolean
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 function ElemHideException(text, domains, selector) 888 function ElemHideException(text, domains, selector)
883 { 889 {
884 ElemHideBase.call(this, text, domains, selector); 890 ElemHideBase.call(this, text, domains, selector);
885 } 891 }
886 exports.ElemHideException = ElemHideException; 892 exports.ElemHideException = ElemHideException;
887 893
888 ElemHideException.prototype = 894 ElemHideException.prototype =
889 { 895 {
890 __proto__: ElemHideBase.prototype 896 __proto__: ElemHideBase.prototype
891 }; 897 };
OLDNEW

Powered by Google App Engine
This is Rietveld