Bug 1061469 - Part 2: ImportManager::AddLoaderWithNewURI should only return main referrers. r=mrbkap
☠☠ backed out by 28d109731c7c ☠ ☠
authorGabor Krizsanits <gkrizsanits@mozilla.com>
Thu, 02 Oct 2014 09:53:57 +0200
changeset 231577 17c54acc6645fadfb5ce226ed366910d813eda40
parent 231576 e7c3be44c7031b95429745e535775984e324e8de
child 231578 27f8d501cef5cf165cb175a8494d207fdb658bd2
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs1061469
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1061469 - Part 2: ImportManager::AddLoaderWithNewURI should only return main referrers. r=mrbkap
content/base/src/ImportManager.cpp
--- a/content/base/src/ImportManager.cpp
+++ b/content/base/src/ImportManager.cpp
@@ -737,32 +737,40 @@ ImportManager::AddLoaderWithNewURI(Impor
 }
 
 nsRefPtr<ImportLoader> ImportManager::GetNearestPredecessor(nsINode* aNode)
 {
   // Return the previous link if there is any in the same document.
   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
       // there is no predecessor.
       return nullptr;
     }
     // Else we find the main referrer of the import parent of the link's document.
     // And do a recursion.
     ImportLoader* owner = Find(doc);
     MOZ_ASSERT(owner);
     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
 } // namespace mozilla