Opened 14 months ago

Last modified 9 months ago

#6957 closed change

Combine element hiding selector matching with style sheet generation — at Version 1

Reported by: mjethani Assignee:
Priority: P3 Milestone:
Module: Core Keywords:
Cc: jsonesen, hfiguiere, sebastian Blocked By: #6956
Blocking: Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

https://codereview.adblockplus.org/29886555/
https://codereview.adblockplus.org/29893618/
https://codereview.adblockplus.org/29893628/
https://codereview.adblockplus.org/29897558/

Description (last modified by mjethani)

Background

After #6956, it will be possible for core to generate the style sheet on its own. In order to optimize style sheet generation in practice, it could be combined with the code for looking up selectors for a domain. The "default" style sheet, based on the list of "unconditional" selectors, would have to be generated only once and cached. Then each call to the style sheet generation code would only have to generate a second style sheet, based on some ~1,000 selectors that don't apply to all domains, and concatenate it with the default style sheet.

This would make the combination of selector lookup and style sheet generation much faster. It might also have benefits for memory usage, though this may no longer be a concern after #6967.

What to change

In lib/elemHide.js, add a new generateStyleSheetForDomain function that performs the same task as getSelectorsForDomain but also returns a generated style sheet (CSS code to be injected directly into the document). This function should generate the default style sheet, based on the list of "unconditional" selectors, only once and then always use the cached value for subsequent calls.

The cached default style sheet should be invalidated when the set of filters is updated.

Change History (1)

comment:1 Changed 14 months ago by mjethani

  • Blocked By 6956 added
  • Cc jsonesen hfiguiere added
  • Description modified (diff)
  • Ready set
  • Review URL(s) modified (diff)
  • Summary changed from Return cached string object for unconditional style sheet to Combine element hiding selector matching with style sheet generation
Note: See TracTickets for help on using tickets.