Bug 218635 - window.event should not be affected by nodes moving post-dispatch
Summary: window.event should not be affected by nodes moving post-dispatch
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-11-05 15:09 PST by Chris Dumez
Modified: 2020-11-05 18:06 PST (History)
8 users (show)

See Also:


Attachments
Patch (9.38 KB, patch)
2020-11-05 15:12 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (9.36 KB, patch)
2020-11-05 16:58 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>