Bug 1061469 - Part 2: ImportManager::AddLoaderWithNewURI should only return main referrers. r=mrbkap

This commit is contained in:
Gabor Krizsanits 2014-10-06 11:43:57 +02:00
Родитель 30b61be3f2
Коммит 980de54604
1 изменённых файлов: 15 добавлений и 7 удалений

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

@ -742,6 +742,19 @@ nsRefPtr<ImportLoader> ImportManager::GetNearestPredecessor(nsINode* aNode)
nsIDocument* doc = aNode->OwnerDoc();
int32_t idx = doc->IndexOfSubImportLink(aNode);
MOZ_ASSERT(idx != -1, "aNode must be a sub import link of its owner document");
for (; idx > 0; idx--) {
HTMLLinkElement* link =
static_cast<HTMLLinkElement*>(doc->GetSubImportLink(idx - 1));
nsCOMPtr<nsIURI> uri = link->GetHrefURI();
nsRefPtr<ImportLoader> ret;
mImports.Get(uri, getter_AddRefs(ret));
// Only main referrer links are interesting.
if (ret->GetMainReferrer() == link) {
return ret;
}
}
if (idx == 0) {
if (doc->IsMasterDocument()) {
// If there is no previous one, and it was the master document, then
@ -755,13 +768,8 @@ nsRefPtr<ImportLoader> ImportManager::GetNearestPredecessor(nsINode* aNode)
nsCOMPtr<nsINode> mainReferrer = owner->GetMainReferrer();
return GetNearestPredecessor(mainReferrer);
}
MOZ_ASSERT(idx > 0);
HTMLLinkElement* link =
static_cast<HTMLLinkElement*>(doc->GetSubImportLink(idx - 1));
nsCOMPtr<nsIURI> uri = link->GetHrefURI();
nsRefPtr<ImportLoader> ret;
mImports.Get(uri, getter_AddRefs(ret));
return ret;
return nullptr;
}
} // namespace dom