From 64329d41b6daea412674c8422ebf9b409c3ba4d4 Mon Sep 17 00:00:00 2001 From: roytam1 Date: Mon, 20 Mar 2023 10:38:29 +0800 Subject: [PATCH] add comments and formatting in mozilla upstream "bug 1440809, ensure we don't try to treat non-DOM-Node event targets as such, r=masayuki (89c8025537a5)" --- dom/base/FragmentOrElement.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index ce7f662eb9..b8d7edc930 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -1022,7 +1022,12 @@ nsIContent::GetEventTargetParent(EventChainPreVisitor& aVisitor) nsContentUtils::Retarget(relatedTargetAsNode, this); nsCOMPtr targetInKnownToBeHandledScope = FindChromeAccessOnlySubtreeOwner(aVisitor.mTargetInKnownToBeHandledScope); - if (targetInKnownToBeHandledScope && nsContentUtils::ContentIsShadowIncludingDescendantOf( + // If aVisitor.mTargetInKnownToBeHandledScope wasn't nsINode, + // targetInKnownToBeHandledScope will be null. This may happen when + // dispatching event to Window object in a content page and + // propagating the event to a chrome Element. + if (targetInKnownToBeHandledScope && + nsContentUtils::ContentIsShadowIncludingDescendantOf( this, targetInKnownToBeHandledScope->SubtreeRoot())) { // Part of step 11.4. // "If target's root is a shadow-including inclusive ancestor of