Support cosmetic filtering !important
display overrides in "Standard" blocking mode
#22474
Labels
bug
feature/shields/adblock
Blocking ads & trackers with Shields
feature/shields
The overall Shields feature in Brave.
features/shields/cosmetic-filtering
OS/Android
Fixes related to Android browser functionality
OS/Desktop
#22264 added support for most types of cosmetic filtering to override
!important
in-page style properties. It is still not yet supported in Standard shields mode due to the use ofdocument.adoptedStyleSheets
. TheaddRule
andremoveRule
APIs it provides are required to support protecting 1st-party page content, but this injection method but will fail to override an in-page style with a higher specificity if it has!important
.document.adoptedStyleSheets
is injected as an author-origin style at the end of the page's stylesheets.All other cosmetic filter CSS injection uses
WebDocument::InsertStyleSheet
, which inserts CSS as a user-origin style. This is ideal, other than the fact that there is no equivalent to theaddRule
andremoveRule
APIs for it. There isWebDocument::RemoveInsertedStyleSheet
, but building the equivalent injection system with one stylesheet per rule has prohibitive performance impact.The ideal solution will involve exposing the
addRule
andremoveRule
methods on the C++CSSStyleSheet
class so it can be used for user-origin stylesheets, but through a new public API in Blink code (sinceCSSStyleSheet
is not an exported member).The text was updated successfully, but these errors were encountered: