How CSS Pseudo Elements are handled

42 views
Skip to first unread message

kalyani Shinde

unread,
Aug 21, 2023, 10:23:28 AM8/21/23
to blink-dev
Hi Team,

I have recently started working with chromium/blink, so quite new to this code. 
I wanted to understand where and how css pseudo elements(e.g webkit-scrollbar) are handled while applying style to any element. These elements are not treated as PseudoElement when we do "GetPseudoElement" on StyleResolveState which finally applies to any element.
Simple question here is to know how to identify this particular style change(state <StyleResolverState>) is defined for Css PseudoElement. 

Thanks in advance.

Rune Lillesveen

unread,
Aug 22, 2023, 12:48:56 PM8/22/23
to kalyani Shinde, blink-dev
In short, Blink first detects the presence of pseudo element style when matching rules for the originating element. If all but the pseudo element part of the selector matches, we mark the element as having pseudo element style:


For tree-abiding pseudo elements that generate a PseudoElement, such elements are then generated from Element::UpdatePseudoElement(), ultimately checking the flag that was set when computing the originating element's style:


For scrollbars, CustomScrollbar is created based on the HasPseudoElementStyle() here:


And the styling for the various scrollbar parts is computed here:


Hope that helps.

--
Rune Lillesveen

Reply all
Reply to author
Forward
0 new messages