Bug 207291

Summary: Expose methods to retrieve a PseudoElement given a PseudoId on Element
Product: WebKit Reporter: Antoine Quint <graouts>
Component: CSSAssignee: Nobody <webkit-unassigned>
Status: RESOLVED WONTFIX    
Severity: Normal CC: koivisto, rniwa, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 207290    

Description Antoine Quint 2020-02-05 13:11:52 PST
The Web Animations specification has added a `pseudoElement` property on `KeyframeEffect`, see bug 207290 tracking its implementation in WebKit. However, `Element` currently only exposes `beforePseudoElement` and `afterPseudoElement` and these are only created under certain circumstances, mostly if `content` is set for one of those pseudo-elements. It appears that pseudo-elements should also be created as needed to be the target of an animation, regardless of what `content` is set to. Specifically, the specification for `content: none` says:

    On elements, this inhibits the children of the element from being rendered as children of this element, as if the element was empty.
    On pseudo-elements it inhibits the creation of the pseudo-element as if it had display: none.
    In neither case does it prevent any pseudo-elements which have this element or pseudo-element as an originating element from being generated.

It would be great to have a method along the lines of `Element::ensurePseudoElement(PseudoId)` where we can get a `PseudoElement` for any of our known pseudo-elements.
Comment 1 Radar WebKit Bug Importer 2020-02-05 13:12:22 PST
<rdar://problem/59199400>
Comment 2 Ryosuke Niwa 2020-02-05 14:38:07 PST
PseudoElement class in general is extremely underspec’ed (e.g. lifetime of these objects is completely unspecified or badly specified). So we need to figure out how PseudoElement’s lifecycle is managed.
Comment 3 Antoine Quint 2020-02-06 00:20:26 PST
Note that this request is unrelated to exposing PseudoElement, the Web Animations API only exposes an Element/CSSOMString pair.
Comment 4 Antti Koivisto 2020-02-06 06:36:41 PST
PseudoElement is an implementation detail, not exposed to web in any direct way. It was a bad idea from the start.
Comment 5 Antti Koivisto 2020-02-06 06:40:17 PST
I think it was originally added to make before/after animatable. The right way to do that would have been to make Element/pseudo pairs animatable rather adding a confusing internal Element subclass.
Comment 6 Antti Koivisto 2020-02-06 06:44:53 PST
Note that only before/after generate PseudoElements. I deliberately got rid of ensurePseudoElement(PseudoId) functions at some point to reduce confusion and prevent people from writing code that would create PseudoElements in other cases.

The right direction here is to eliminate PseudoElement completely. Should be easier when the new animation system is fully in place.