Bug 218635

Summary: window.event should not be affected by nodes moving post-dispatch
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: DOMAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, esprehn+autocc, ews-watchlist, ggaren, kangil.han, rniwa, sam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Chris Dumez 2020-11-05 15:09:13 PST
window.event should not be affected by nodes moving post-dispatch:
- https://dom.spec.whatwg.org/#concept-event-listener-invoke

In particular, window.event should not get set when the event target was inside a shadow tree initially when dispatchEvent() got called, even if the event target gets moved out of the shadow tree during the execution of the event listeners.
Comment 1 Chris Dumez 2020-11-05 15:12:01 PST
Created attachment 413355 [details]
Patch
Comment 2 Geoffrey Garen 2020-11-05 16:28:07 PST
Comment on attachment 413355 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=413355&action=review

r=me

> Source/WebCore/dom/Event.cpp:134
> +    m_currentTargetIsInShadowTree = isInShadowTree.valueOr(is<Node>(currentTarget) && downcast<Node>(*currentTarget).isInShadowTree());

Fancy!
Comment 3 Darin Adler 2020-11-05 16:51:19 PST
Comment on attachment 413355 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=413355&action=review

>> Source/WebCore/dom/Event.cpp:134
>> +    m_currentTargetIsInShadowTree = isInShadowTree.valueOr(is<Node>(currentTarget) && downcast<Node>(*currentTarget).isInShadowTree());
> 
> Fancy!

Too fancy! The argument to valueOr is going to be computed unconditionally; do we really want that?
Comment 4 Chris Dumez 2020-11-05 16:56:37 PST
(In reply to Darin Adler from comment #3)
> Comment on attachment 413355 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=413355&action=review
> 
> >> Source/WebCore/dom/Event.cpp:134
> >> +    m_currentTargetIsInShadowTree = isInShadowTree.valueOr(is<Node>(currentTarget) && downcast<Node>(*currentTarget).isInShadowTree());
> > 
> > Fancy!
> 
> Too fancy! The argument to valueOr is going to be computed unconditionally;
> do we really want that?

Fair point. Will fix.
Comment 5 Chris Dumez 2020-11-05 16:58:56 PST
Created attachment 413376 [details]
Patch
Comment 6 EWS 2020-11-05 18:05:52 PST
Committed r269500: <https://trac.webkit.org/changeset/269500>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 413376 [details].
Comment 7 Radar WebKit Bug Importer 2020-11-05 18:06:24 PST
<rdar://problem/71102768>