From dd1a49ff93cfed8bfaaaa90afdc2b75b280099df Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Thu, 2 Sep 2021 02:17:43 +0100 Subject: [PATCH] LibWeb: Add missing shadow including ancestor checks in EventDispatcher --- Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp b/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp index d6cb1ca939..b133205df5 100644 --- a/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp @@ -28,9 +28,8 @@ namespace Web::DOM { // FIXME: This shouldn't be here, as retargeting is not only used by the event dispatcher. // When moving this function, it needs to be generalized. https://dom.spec.whatwg.org/#retarget -static EventTarget* retarget(EventTarget* left, [[maybe_unused]] EventTarget* right) +static EventTarget* retarget(EventTarget* left, EventTarget* right) { - // FIXME for (;;) { if (!is(left)) return left; @@ -40,7 +39,8 @@ static EventTarget* retarget(EventTarget* left, [[maybe_unused]] EventTarget* ri if (!is(left_root)) return left; - // FIXME: If right is a node and left’s root is a shadow-including inclusive ancestor of right, return left. + if (is(right) && left_root->is_shadow_including_inclusive_ancestor_of(verify_cast(*right))) + return left; auto* left_shadow_root = verify_cast(left_root); left = left_shadow_root->host(); @@ -201,8 +201,8 @@ bool EventDispatcher::dispatch(NonnullRefPtr target, NonnullRefPtr< touch_targets.append(retarget(touch_target, parent)); } - // FIXME: or parent is a node and target’s root is a shadow-including inclusive ancestor of parent, then: - if (is(parent)) { + if (is(parent) + || (is(parent) && verify_cast(*target).is_shadow_including_inclusive_ancestor_of(verify_cast(*parent)))) { if (is_activation_event && event->bubbles() && !activation_target && parent->activation_behaviour) activation_target = parent;