diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 6465f3789dd3..d306e6cd1dab 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -10999,3 +10999,20 @@ nsContentUtils::ContentIsLink(nsIContent* aContent) aContent->AttrValueIs(kNameSpaceID_XLink, nsGkAtoms::type, nsGkAtoms::simple, eCaseMatters)); } + +/* static */ already_AddRefed +nsContentUtils::TryGetTabChildGlobalAsEventTarget(nsISupports* aFrom) +{ + nsCOMPtr frameLoaderOwner = do_QueryInterface(aFrom); + if (!frameLoaderOwner) { + return nullptr; + } + + RefPtr frameLoader = frameLoaderOwner->GetFrameLoader(); + if (!frameLoader) { + return nullptr; + } + + nsCOMPtr target = frameLoader->GetTabChildGlobalAsEventTarget(); + return target.forget(); +} diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index 292729a55310..c24e5d269be1 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -3250,6 +3250,9 @@ public: static bool ContentIsLink(nsIContent* aContent); + static already_AddRefed + TryGetTabChildGlobalAsEventTarget(nsISupports* aFrom); + private: static bool InitializeEventTable(); diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 0a8fb735e460..2d25bd1adc6e 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -528,24 +528,6 @@ CreateNativeGlobalForInner(JSContext* aCx, return NS_OK; } -static -already_AddRefed -TryGetTabChildGlobalAsEventTarget(nsISupports *aFrom) -{ - nsCOMPtr frameLoaderOwner = do_QueryInterface(aFrom); - if (!frameLoaderOwner) { - return nullptr; - } - - RefPtr frameLoader = frameLoaderOwner->GetFrameLoader(); - if (!frameLoader) { - return nullptr; - } - - nsCOMPtr target = frameLoader->GetTabChildGlobalAsEventTarget(); - return target.forget(); -} - template nsIURI* nsPIDOMWindow::GetDocumentURI() const diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index 563404394c91..9968be81a4d2 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -1629,18 +1629,20 @@ nsGlobalWindowInner::UpdateParentTarget() nsCOMPtr frameElement = GetOuterWindow()->GetFrameElementInternal(); nsCOMPtr eventTarget = - TryGetTabChildGlobalAsEventTarget(frameElement); + nsContentUtils::TryGetTabChildGlobalAsEventTarget(frameElement); if (!eventTarget) { nsGlobalWindowOuter* topWin = GetScriptableTopInternal(); if (topWin) { frameElement = topWin->AsOuter()->GetFrameElementInternal(); - eventTarget = TryGetTabChildGlobalAsEventTarget(frameElement); + eventTarget = + nsContentUtils::TryGetTabChildGlobalAsEventTarget(frameElement); } } if (!eventTarget) { - eventTarget = TryGetTabChildGlobalAsEventTarget(mChromeEventHandler); + eventTarget = + nsContentUtils::TryGetTabChildGlobalAsEventTarget(mChromeEventHandler); } if (!eventTarget) { diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index c4d55a748bf5..92e6859f4856 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -2240,18 +2240,20 @@ nsGlobalWindowOuter::UpdateParentTarget() nsCOMPtr frameElement = GetOuterWindow()->GetFrameElementInternal(); nsCOMPtr eventTarget = - TryGetTabChildGlobalAsEventTarget(frameElement); + nsContentUtils::TryGetTabChildGlobalAsEventTarget(frameElement); if (!eventTarget) { nsGlobalWindowOuter* topWin = GetScriptableTopInternal(); if (topWin) { frameElement = topWin->GetFrameElementInternal(); - eventTarget = TryGetTabChildGlobalAsEventTarget(frameElement); + eventTarget = + nsContentUtils::TryGetTabChildGlobalAsEventTarget(frameElement); } } if (!eventTarget) { - eventTarget = TryGetTabChildGlobalAsEventTarget(mChromeEventHandler); + eventTarget = + nsContentUtils::TryGetTabChildGlobalAsEventTarget(mChromeEventHandler); } if (!eventTarget) {