зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1315837 - Fix crash in mozilla::dom::Element::UpdateIntersectionObservation. r=mrbkap
--HG-- extra : rebase_source : 77edac309414e61dd103bc60668351d6e3548890
This commit is contained in:
Родитель
1381db9e9e
Коммит
0cb90d5992
|
@ -159,15 +159,23 @@ DOMIntersectionObserver::Observe(Element& aTarget)
|
||||||
void
|
void
|
||||||
DOMIntersectionObserver::Unobserve(Element& aTarget)
|
DOMIntersectionObserver::Unobserve(Element& aTarget)
|
||||||
{
|
{
|
||||||
if (!mObservationTargets.Contains(&aTarget)) {
|
if (UnlinkTarget(aTarget)) {
|
||||||
return;
|
aTarget.UnregisterIntersectionObserver(this);
|
||||||
}
|
}
|
||||||
if (mObservationTargets.Count() == 1) {
|
}
|
||||||
Disconnect();
|
|
||||||
return;
|
bool
|
||||||
}
|
DOMIntersectionObserver::UnlinkTarget(Element& aTarget)
|
||||||
aTarget.UnregisterIntersectionObserver(this);
|
{
|
||||||
mObservationTargets.RemoveEntry(&aTarget);
|
if (!mObservationTargets.Contains(&aTarget)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (mObservationTargets.Count() == 1) {
|
||||||
|
Disconnect();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
mObservationTargets.RemoveEntry(&aTarget);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -192,8 +200,10 @@ DOMIntersectionObserver::Disconnect()
|
||||||
target->UnregisterIntersectionObserver(this);
|
target->UnregisterIntersectionObserver(this);
|
||||||
}
|
}
|
||||||
mObservationTargets.Clear();
|
mObservationTargets.Clear();
|
||||||
nsIDocument* document = mOwner->GetExtantDoc();
|
if (mOwner) {
|
||||||
document->RemoveIntersectionObserver(this);
|
nsIDocument* document = mOwner->GetExtantDoc();
|
||||||
|
document->RemoveIntersectionObserver(this);
|
||||||
|
}
|
||||||
mConnected = false;
|
mConnected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,9 @@ public:
|
||||||
void Observe(Element& aTarget);
|
void Observe(Element& aTarget);
|
||||||
void Unobserve(Element& aTarget);
|
void Unobserve(Element& aTarget);
|
||||||
|
|
||||||
|
bool UnlinkTarget(Element& aTarget);
|
||||||
void Disconnect();
|
void Disconnect();
|
||||||
|
|
||||||
void TakeRecords(nsTArray<RefPtr<DOMIntersectionObserverEntry>>& aRetVal);
|
void TakeRecords(nsTArray<RefPtr<DOMIntersectionObserverEntry>>& aRetVal);
|
||||||
|
|
||||||
mozilla::dom::IntersectionCallback* IntersectionCallback() { return mCallback; }
|
mozilla::dom::IntersectionCallback* IntersectionCallback() { return mCallback; }
|
||||||
|
|
|
@ -297,6 +297,15 @@ nsNodeUtils::LastRelease(nsINode* aNode)
|
||||||
NodeWillBeDestroyed, (aNode));
|
NodeWillBeDestroyed, (aNode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (aNode->IsElement()) {
|
||||||
|
Element* elem = aNode->AsElement();
|
||||||
|
FragmentOrElement::nsDOMSlots* domSlots =
|
||||||
|
static_cast<FragmentOrElement::nsDOMSlots*>(slots);
|
||||||
|
for (auto& reg : domSlots->mRegisteredIntersectionObservers) {
|
||||||
|
reg.observer->UnlinkTarget(*elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
delete slots;
|
delete slots;
|
||||||
aNode->mSlots = nullptr;
|
aNode->mSlots = nullptr;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче