| OLD | NEW | 
|---|
| 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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 446   }, | 446   }, | 
| 447 | 447 | 
| 448   get dependsOnCharacterData() | 448   get dependsOnCharacterData() | 
| 449   { | 449   { | 
| 450     // Observe changes to character data only if there's a contains selector in | 450     // Observe changes to character data only if there's a contains selector in | 
| 451     // one of the patterns. | 451     // one of the patterns. | 
| 452     return getCachedPropertyValue( | 452     return getCachedPropertyValue( | 
| 453       this, "_dependsOnCharacterData", | 453       this, "_dependsOnCharacterData", | 
| 454       () => this.selectors.some(selector => selector.dependsOnCharacterData) | 454       () => this.selectors.some(selector => selector.dependsOnCharacterData) | 
| 455     ); | 455     ); | 
|  | 456   }, | 
|  | 457 | 
|  | 458   matchesMutationTypes(mutationTypes) | 
|  | 459   { | 
|  | 460     let mutationTypeMatchMap = getCachedPropertyValue( | 
|  | 461       this, "_mutationTypeMatchMap", | 
|  | 462       () => new Map([ | 
|  | 463         // All types of DOM-dependent patterns are affected by mutations of | 
|  | 464         // type "childList". | 
|  | 465         ["childList", true], | 
|  | 466         ["attributes", this.maybeDependsOnAttributes], | 
|  | 467         ["characterData", this.dependsOnCharacterData] | 
|  | 468       ]) | 
|  | 469     ); | 
|  | 470 | 
|  | 471     for (let mutationType of mutationTypes) | 
|  | 472     { | 
|  | 473       if (mutationTypeMatchMap.get(mutationType)) | 
|  | 474         return true; | 
|  | 475     } | 
|  | 476 | 
|  | 477     return false; | 
| 456   } | 478   } | 
| 457 }; | 479 }; | 
| 458 | 480 | 
|  | 481 function extractMutationTypes(mutations) | 
|  | 482 { | 
|  | 483   let types = new Set(); | 
|  | 484 | 
|  | 485   for (let mutation of mutations) | 
|  | 486   { | 
|  | 487     types.add(mutation.type); | 
|  | 488 | 
|  | 489     // There are only 3 types of mutations: "attributes", "characterData", and | 
|  | 490     // "childList". | 
|  | 491     if (types.size == 3) | 
|  | 492       break; | 
|  | 493   } | 
|  | 494 | 
|  | 495   return types; | 
|  | 496 } | 
|  | 497 | 
| 459 function filterPatterns(patterns, {stylesheets, mutations}) | 498 function filterPatterns(patterns, {stylesheets, mutations}) | 
| 460 { | 499 { | 
| 461   if (!stylesheets && !mutations) | 500   if (!stylesheets && !mutations) | 
| 462     return patterns.slice(); | 501     return patterns.slice(); | 
| 463 | 502 | 
|  | 503   let mutationTypes = mutations ? extractMutationTypes(mutations) : null; | 
|  | 504 | 
| 464   return patterns.filter( | 505   return patterns.filter( | 
| 465     pattern => (stylesheets && pattern.dependsOnStyles) || | 506     pattern => (stylesheets && pattern.dependsOnStyles) || | 
| 466                (mutations && pattern.dependsOnDOM) | 507                (mutations && pattern.dependsOnDOM && | 
|  | 508                 pattern.matchesMutationTypes(mutationTypes)) | 
| 467   ); | 509   ); | 
| 468 } | 510 } | 
| 469 | 511 | 
| 470 function shouldObserveAttributes(patterns) | 512 function shouldObserveAttributes(patterns) | 
| 471 { | 513 { | 
| 472   return patterns.some(pattern => pattern.maybeDependsOnAttributes); | 514   return patterns.some(pattern => pattern.maybeDependsOnAttributes); | 
| 473 } | 515 } | 
| 474 | 516 | 
| 475 function shouldObserveCharacterData(patterns) | 517 function shouldObserveCharacterData(patterns) | 
| 476 { | 518 { | 
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 809           characterData: shouldObserveCharacterData(this.patterns), | 851           characterData: shouldObserveCharacterData(this.patterns), | 
| 810           subtree: true | 852           subtree: true | 
| 811         } | 853         } | 
| 812       ); | 854       ); | 
| 813       this.document.addEventListener("load", this.onLoad.bind(this), true); | 855       this.document.addEventListener("load", this.onLoad.bind(this), true); | 
| 814     } | 856     } | 
| 815   } | 857   } | 
| 816 }; | 858 }; | 
| 817 | 859 | 
| 818 exports.ElemHideEmulation = ElemHideEmulation; | 860 exports.ElemHideEmulation = ElemHideEmulation; | 
| OLD | NEW | 
|---|