mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1143848 - Query Document from Parent in case of nested workers (r=bent)
--HG-- extra : rebase_source : bfdc5979488a489e4adf66fccbdce8fd65255db3
This commit is contained in:
parent
0f4cd2b27f
commit
4653f5de8c
@ -2662,6 +2662,28 @@ struct WorkerPrivate::PreemptingRunnableInfo final
|
||||
}
|
||||
};
|
||||
|
||||
template <class Derived>
|
||||
nsIDocument*
|
||||
WorkerPrivateParent<Derived>::GetDocument() const
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
if (mLoadInfo.mWindow) {
|
||||
return mLoadInfo.mWindow->GetExtantDoc();
|
||||
}
|
||||
// if we don't have a document, we should query the document
|
||||
// from the parent in case of a nested worker
|
||||
WorkerPrivate* parent = mParent;
|
||||
while (parent) {
|
||||
if (parent->mLoadInfo.mWindow) {
|
||||
return parent->mLoadInfo.mWindow->GetExtantDoc();
|
||||
}
|
||||
parent = parent->GetParent();
|
||||
}
|
||||
// couldn't query a document, give up and return nullptr
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
// Can't use NS_IMPL_CYCLE_COLLECTION_CLASS(WorkerPrivateParent) because of the
|
||||
// templates.
|
||||
template <class Derived>
|
||||
|
@ -581,12 +581,7 @@ public:
|
||||
return mLoadInfo.mChannel.forget();
|
||||
}
|
||||
|
||||
nsIDocument*
|
||||
GetDocument() const
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
return mLoadInfo.mWindow ? mLoadInfo.mWindow->GetExtantDoc() : nullptr;
|
||||
}
|
||||
nsIDocument* GetDocument() const;
|
||||
|
||||
nsPIDOMWindow*
|
||||
GetWindow()
|
||||
|
Loading…
Reference in New Issue
Block a user