Backed out changeset 8102d0d48f8d (bug 1315837) for Android assertion failures in test_link_stylesheet.html
authorPhil Ringnalda <philringnalda@gmail.com>
Fri, 25 Nov 2016 21:53:20 -0800
changeset 352662 d87b17a47f600b30cad7e7a48dfaa42d3faa7678
parent 352661 bafd3cf3970490e029351e6befa56667f568f85f
child 352663 869b5adf0df8c609270d56b237561366ca921720
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1315837
milestone52.0a2
backs out8102d0d48f8d7ea0f6fa76710ca8c44c620190e3
Backed out changeset 8102d0d48f8d (bug 1315837) for Android assertion failures in test_link_stylesheet.html
dom/base/DOMIntersectionObserver.cpp
--- a/dom/base/DOMIntersectionObserver.cpp
+++ b/dom/base/DOMIntersectionObserver.cpp
@@ -165,22 +165,21 @@ DOMIntersectionObserver::Unobserve(Eleme
 }
 
 bool
 DOMIntersectionObserver::UnlinkTarget(Element& aTarget)
 {
     if (!mObservationTargets.Contains(&aTarget)) {
         return false;
     }
-
-    mObservationTargets.RemoveEntry(&aTarget);
-    if (mObservationTargets.Count() == 0) {
+    if (mObservationTargets.Count() == 1) {
         Disconnect();
         return false;
     }
+    mObservationTargets.RemoveEntry(&aTarget);
     return true;
 }
 
 void
 DOMIntersectionObserver::Connect()
 {
   if (mConnected) {
     return;
@@ -191,27 +190,26 @@ DOMIntersectionObserver::Connect()
 }
 
 void
 DOMIntersectionObserver::Disconnect()
 {
   if (!mConnected) {
     return;
   }
-
-  mConnected = false;
   for (auto iter = mObservationTargets.Iter(); !iter.Done(); iter.Next()) {
     Element* target = iter.Get()->GetKey();
     target->UnregisterIntersectionObserver(this);
   }
   mObservationTargets.Clear();
   if (mOwner) {
     nsIDocument* document = mOwner->GetExtantDoc();
     document->RemoveIntersectionObserver(this);
   }
+  mConnected = false;
 }
 
 void
 DOMIntersectionObserver::TakeRecords(nsTArray<RefPtr<DOMIntersectionObserverEntry>>& aRetVal)
 {
   aRetVal.SwapElements(mQueuedEntries);
   mQueuedEntries.Clear();
 }
@@ -275,20 +273,17 @@ DOMIntersectionObserver::Update(nsIDocum
     }
   } else {
     nsCOMPtr<nsIPresShell> presShell = aDocument->GetShell();
     if (presShell) {
       rootFrame = presShell->GetRootScrollFrame();
       if (rootFrame) {
         nsPresContext* presContext = rootFrame->PresContext();
         while (!presContext->IsRootContentDocument()) {
-          presContext = presContext->GetParentPresContext();
-          if (!presContext) {
-            break;
-          }
+          presContext = rootFrame->PresContext()->GetParentPresContext();
           rootFrame = presContext->PresShell()->GetRootScrollFrame();
         }
         root = rootFrame->GetContent()->AsElement();
         nsIScrollableFrame* scrollFrame = do_QueryFrame(rootFrame);
         rootRect = scrollFrame->GetScrollPortRect();
       }
     }
   }