Bug 1419144 - Part 8: Move TryGetTabChildGlobalAsEventTarget into nsContentUtils, r=smaug

MozReview-Commit-ID: 8vi1mAzmQUU
This commit is contained in:
Nika Layzell 2017-11-17 16:42:50 -05:00
Родитель 38a7e13386
Коммит e005db891d
5 изменённых файлов: 30 добавлений и 24 удалений

Просмотреть файл

@ -10999,3 +10999,20 @@ nsContentUtils::ContentIsLink(nsIContent* aContent)
aContent->AttrValueIs(kNameSpaceID_XLink, nsGkAtoms::type,
nsGkAtoms::simple, eCaseMatters));
}
/* static */ already_AddRefed<EventTarget>
nsContentUtils::TryGetTabChildGlobalAsEventTarget(nsISupports* aFrom)
{
nsCOMPtr<nsIFrameLoaderOwner> frameLoaderOwner = do_QueryInterface(aFrom);
if (!frameLoaderOwner) {
return nullptr;
}
RefPtr<nsFrameLoader> frameLoader = frameLoaderOwner->GetFrameLoader();
if (!frameLoader) {
return nullptr;
}
nsCOMPtr<EventTarget> target = frameLoader->GetTabChildGlobalAsEventTarget();
return target.forget();
}

Просмотреть файл

@ -3250,6 +3250,9 @@ public:
static bool ContentIsLink(nsIContent* aContent);
static already_AddRefed<mozilla::dom::EventTarget>
TryGetTabChildGlobalAsEventTarget(nsISupports* aFrom);
private:
static bool InitializeEventTable();

Просмотреть файл

@ -528,24 +528,6 @@ CreateNativeGlobalForInner(JSContext* aCx,
return NS_OK;
}
static
already_AddRefed<EventTarget>
TryGetTabChildGlobalAsEventTarget(nsISupports *aFrom)
{
nsCOMPtr<nsIFrameLoaderOwner> frameLoaderOwner = do_QueryInterface(aFrom);
if (!frameLoaderOwner) {
return nullptr;
}
RefPtr<nsFrameLoader> frameLoader = frameLoaderOwner->GetFrameLoader();
if (!frameLoader) {
return nullptr;
}
nsCOMPtr<EventTarget> target = frameLoader->GetTabChildGlobalAsEventTarget();
return target.forget();
}
template <class T>
nsIURI*
nsPIDOMWindow<T>::GetDocumentURI() const

Просмотреть файл

@ -1629,18 +1629,20 @@ nsGlobalWindowInner::UpdateParentTarget()
nsCOMPtr<Element> frameElement = GetOuterWindow()->GetFrameElementInternal();
nsCOMPtr<EventTarget> 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) {

Просмотреть файл

@ -2240,18 +2240,20 @@ nsGlobalWindowOuter::UpdateParentTarget()
nsCOMPtr<Element> frameElement = GetOuterWindow()->GetFrameElementInternal();
nsCOMPtr<EventTarget> 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) {