Bug 1597453 - Fix uses of nsIDocShellTreeItem in mozilla::dom::PerformanceTiming::IsTopLevelContentDocument. r=kmag

Differential Revision: https://phabricator.services.mozilla.com/D59454

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tetsuharu OHZEKI 2020-01-16 04:47:51 +00:00
parent 1968353c48
commit e8ac806cd3

View File

@ -11,6 +11,7 @@
#include "mozilla/Telemetry.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "mozilla/dom/BrowsingContext.h"
#include "mozilla/dom/Document.h"
#include "nsITimedChannel.h"
@ -616,17 +617,11 @@ bool PerformanceTiming::IsTopLevelContentDocument() const {
if (!document) {
return false;
}
nsCOMPtr<nsIDocShell> docShell = document->GetDocShell();
if (!docShell) {
return false;
if (BrowsingContext* bc = document->GetBrowsingContext()) {
return bc->IsTopContent();
}
nsCOMPtr<nsIDocShellTreeItem> rootItem;
Unused << docShell->GetInProcessSameTypeRootTreeItem(
getter_AddRefs(rootItem));
if (rootItem.get() != static_cast<nsIDocShellTreeItem*>(docShell.get())) {
return false;
}
return rootItem->ItemType() == nsIDocShellTreeItem::typeContent;
return false;
}
nsTArray<nsCOMPtr<nsIServerTiming>> PerformanceTimingData::GetServerTiming() {