Opened 6 years ago

Last modified 4 years ago

#521 closed change

Inject our stylesheet on per-site basis rather than globally — at Version 8

Reported by: trev Assignee: tschuster
Priority: P3 Milestone: Adblock-Plus-2.8-for-Firefox
Module: Adblock-Plus-for-Firefox Keywords:
Cc: fhd, arthur, greiner, mapx, saroyanm, Compuitguy, trev, famlam Blocked By:
Blocking: #524 Platform: Firefox
Ready: yes Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

http://codereview.adblockplus.org/6201308310667264/
https://codereview.adblockplus.org/29346613/

Description (last modified by trev)

Background

Currently we register a large global stylesheet in Firefox, it is being applied to every single webpage. According to https://bugzilla.mozilla.org/show_bug.cgi?id=988266 there is no memory use advantage however, essentially a copy of this stylesheet is being injected into each document.

What to change

We can stick to a single stylesheet file for now and merely decide individually on whether we want to inject it into a webpage. We can listen to some notification like content-document-global-created and use nsIDOMWindowUtils.loadSheet() to inject the stylesheet. This will solve several issues:

  • No stylesheet is injected into whitelisted pages and pages where element hiding is disabled - meaning also no side-effects from element hiding that were unavoidable so far.
  • The ugly protocol whitelist for generic rules can go, we simply won't inject the stylesheet into chrome:// documents and such.
  • More consistent behavior - changes to element hiding rules apply only after page reload, same as with other filters.
  • No hang when Adblock Plus is enabled or disabled globally coming from the stylesheet being injected into all open tabs simultaneously.
  • We can get rid of the current ugly approach to implement exceptions via -moz-binding once bug 349813 is fixed.

Change History (8)

comment:1 Changed 6 years ago by tschuster

I will try to prototype this.

comment:2 Changed 6 years ago by trev

  • Description modified (diff)

comment:3 Changed 6 years ago by trev

  • Owner set to tschuster

comment:4 follow-up: Changed 6 years ago by tschuster

  • The ugly protocol whitelist for generic rules can go, we simply won't inject the stylesheet into chrome:// documents and such.

I think if we use "content-document-global-created" we are guaranteed not to inject into chrome :)

  • More consistent behavior - changes to element hiding rules apply only after page reload, same as with other filters.

Perfect, if we had to apply changes immediately this would turn out be rather difficult.

comment:5 Changed 6 years ago by mapx

  • Cc smultron45@… added

comment:6 in reply to: ↑ 4 Changed 6 years ago by trev

Replying to tschuster:

I think if we use "content-document-global-created" we are guaranteed not to inject into chrome :)

content-document-global-created is about the distinction between chrome and content meaning which side of the security boundary you are on - it isn't about privileges. Privileged documents can be loaded into the content area (e.g. Add-ons Manager page).

comment:7 Changed 6 years ago by trev

  • Blocking 524 added

comment:8 Changed 6 years ago by tschuster

  • Review URL(s) modified (diff)
Note: See TracTickets for help on using tickets.