Opened 2 years ago

Last modified 12 months ago

#6437 closed change

Optimize element hiding emulation for DOM modifications — at Version 1

Reported by: mjethani Assignee: mjethani
Priority: P2 Milestone:
Module: Core Keywords: circumvention
Cc: hfiguiere, kzar, sergz, amrmak, arthur Blocked By:
Blocking: Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Ross Verified working: yes
Review URL(s):

https://codereview.adblockplus.org/29712655/
https://codereview.adblockplus.org/29713565/
https://codereview.adblockplus.org/29714601/
https://codereview.adblockplus.org/29728579/
https://codereview.adblockplus.org/29730630/
https://codereview.adblockplus.org/29738589/

Description

Background

Element hiding emulation has an optimization for the case where only a new style sheet has been added to the document. In this case it does not do any processing for patterns containing only -abp-has and -abp-contains selectors. However this optimization does not exist for the other way. i.e. when there's a DOM mutation but no style sheet changes, -abp-properties selectors are still processed, even though they should be skipped (unless nested inside -abp-has of course). The code unnecessarily parses each CSS rule within each style sheet in the entire document for every batch of DOM mutations reported by MutationObserver.

Given that DOM mutations occur way more frequently than style sheet updates, this case should be optimized for first and foremost.

What to change

Implement optimized paths for DOM mutations without style sheet changes. In particular, patterns that do not contain any DOM-dependent selectors (e.g. div:-abp-properties(width: 100px;)) should not be processed. If there are only such patterns available and no others, the document's style sheets should not be parsed.

Needless to say, this should be done without breaking any functionality.

Change History (1)

comment:1 Changed 2 years ago by mjethani

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing
Note: See TracTickets for help on using tickets.