Bug 1315837 - Fix crash in mozilla::dom::Element::UpdateIntersectionObservation. r=mrbkap
This commit is contained in:
@@ -159,15 +159,23 @@ DOMIntersectionObserver::Observe(Element& aTarget)
|
||||
void
|
||||
DOMIntersectionObserver::Unobserve(Element& aTarget)
|
||||
{
|
||||
if (!mObservationTargets.Contains(&aTarget)) {
|
||||
return;
|
||||
if (UnlinkTarget(aTarget)) {
|
||||
aTarget.UnregisterIntersectionObserver(this);
|
||||
}
|
||||
if (mObservationTargets.Count() == 1) {
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
aTarget.UnregisterIntersectionObserver(this);
|
||||
mObservationTargets.RemoveEntry(&aTarget);
|
||||
}
|
||||
|
||||
bool
|
||||
DOMIntersectionObserver::UnlinkTarget(Element& aTarget)
|
||||
{
|
||||
if (!mObservationTargets.Contains(&aTarget)) {
|
||||
return false;
|
||||
}
|
||||
if (mObservationTargets.Count() == 1) {
|
||||
Disconnect();
|
||||
return false;
|
||||
}
|
||||
mObservationTargets.RemoveEntry(&aTarget);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -192,8 +200,10 @@ DOMIntersectionObserver::Disconnect()
|
||||
target->UnregisterIntersectionObserver(this);
|
||||
}
|
||||
mObservationTargets.Clear();
|
||||
nsIDocument* document = mOwner->GetExtantDoc();
|
||||
document->RemoveIntersectionObserver(this);
|
||||
if (mOwner) {
|
||||
nsIDocument* document = mOwner->GetExtantDoc();
|
||||
document->RemoveIntersectionObserver(this);
|
||||
}
|
||||
mConnected = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user