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

Side by Side Diff: lib/filterClasses.js

Issue 6055266931965952: Issue 1273 - Worked around WebKit getter misoptimization on Safari 8 (Closed)
Patch Set: Created Aug. 27, 2014, 9:48 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 | « lib/elemHide.js ('k') | 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 <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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 * @type Boolean 317 * @type Boolean
318 */ 318 */
319 domainSourceIsUpperCase: false, 319 domainSourceIsUpperCase: false,
320 320
321 /** 321 /**
322 * Map containing domains that this filter should match on/not match on or nul l if the filter should match on all domains 322 * Map containing domains that this filter should match on/not match on or nul l if the filter should match on all domains
323 * @type Object 323 * @type Object
324 */ 324 */
325 get domains() 325 get domains()
326 { 326 {
327 // despite this property is cached, the getter is called
Wladimir Palant 2014/08/27 12:52:55 "Despite this property being cached" please (capit
328 // several times on Safari, due to WebKit bug 132872
329 let prop = Object.getOwnPropertyDescriptor(this, "domains");
330 if (prop)
331 return prop.value;
332
327 let domains = null; 333 let domains = null;
328 334
329 if (this.domainSource) 335 if (this.domainSource)
330 { 336 {
331 let source = this.domainSource; 337 let source = this.domainSource;
332 if (!this.domainSourceIsUpperCase) { 338 if (!this.domainSourceIsUpperCase) {
333 // RegExpFilter already have uppercase domains 339 // RegExpFilter already have uppercase domains
334 source = source.toUpperCase(); 340 source = source.toUpperCase();
335 } 341 }
336 let list = source.split(this.domainSeparator); 342 let list = source.split(this.domainSeparator);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 * Expression from which a regular expression should be generated - for delaye d creation of the regexp property 513 * Expression from which a regular expression should be generated - for delaye d creation of the regexp property
508 * @type String 514 * @type String
509 */ 515 */
510 regexpSource: null, 516 regexpSource: null,
511 /** 517 /**
512 * Regular expression to be used when testing against this filter 518 * Regular expression to be used when testing against this filter
513 * @type RegExp 519 * @type RegExp
514 */ 520 */
515 get regexp() 521 get regexp()
516 { 522 {
523 // despite this property is cached, the getter is called
Wladimir Palant 2014/08/27 12:52:55 Same as above, "Despite this property being cached
524 // several times on Safari, due to WebKit bug 132872
525 let prop = Object.getOwnPropertyDescriptor(this, "regexp");
526 if (prop)
527 return prop.value;
528
517 // Remove multiple wildcards 529 // Remove multiple wildcards
518 let source = this.regexpSource 530 let source = this.regexpSource
519 .replace(/\*+/g, "*") // remove multiple wildcards 531 .replace(/\*+/g, "*") // remove multiple wildcards
520 .replace(/\^\|$/, "^") // remove anchors following separator placeho lder 532 .replace(/\^\|$/, "^") // remove anchors following separator placeho lder
521 .replace(/\W/g, "\\$&") // escape special symbols 533 .replace(/\W/g, "\\$&") // escape special symbols
522 .replace(/\\\*/g, ".*") // replace wildcards by .* 534 .replace(/\\\*/g, ".*") // replace wildcards by .*
523 // process separator placeholders (all ANSI characters but alphanumeric ch aracters and _%.-) 535 // process separator placeholders (all ANSI characters but alphanumeric ch aracters and _%.-)
524 .replace(/\\\^/g, "(?:[\\x00-\\x24\\x26-\\x2C\\x2F\\x3A-\\x40\\x5B-\\x5E\\ x60\\x7B-\\x7F]|$)") 536 .replace(/\\\^/g, "(?:[\\x00-\\x24\\x26-\\x2C\\x2F\\x3A-\\x40\\x5B-\\x5E\\ x60\\x7B-\\x7F]|$)")
525 .replace(/^\\\|\\\|/, "^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?") // process extended anchor at expression start 537 .replace(/^\\\|\\\|/, "^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?") // process extended anchor at expression start
526 .replace(/^\\\|/, "^") // process anchor at expression start 538 .replace(/^\\\|/, "^") // process anchor at expression start
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 function ElemHideException(text, domains, selector) 902 function ElemHideException(text, domains, selector)
891 { 903 {
892 ElemHideBase.call(this, text, domains, selector); 904 ElemHideBase.call(this, text, domains, selector);
893 } 905 }
894 exports.ElemHideException = ElemHideException; 906 exports.ElemHideException = ElemHideException;
895 907
896 ElemHideException.prototype = 908 ElemHideException.prototype =
897 { 909 {
898 __proto__: ElemHideBase.prototype 910 __proto__: ElemHideBase.prototype
899 }; 911 };
OLDNEW
« no previous file with comments | « lib/elemHide.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld