зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1315837 - Crash in mozilla::dom::Element::UpdateIntersectionObservation. r=mrbkap
This commit is contained in:
Родитель
8409f77b66
Коммит
bff9de0c6e
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,9 @@ protected:
|
|||
class DOMIntersectionObserver final : public nsISupports,
|
||||
public nsWrapperCache
|
||||
{
|
||||
virtual ~DOMIntersectionObserver() { }
|
||||
virtual ~DOMIntersectionObserver() {
|
||||
Disconnect();
|
||||
}
|
||||
|
||||
public:
|
||||
DOMIntersectionObserver(already_AddRefed<nsPIDOMWindowInner>&& aOwner,
|
||||
|
@ -142,7 +144,9 @@ public:
|
|||
void Observe(Element& aTarget);
|
||||
void Unobserve(Element& aTarget);
|
||||
|
||||
bool UnlinkTarget(Element& aTarget);
|
||||
void Disconnect();
|
||||
|
||||
void TakeRecords(nsTArray<RefPtr<DOMIntersectionObserverEntry>>& aRetVal);
|
||||
|
||||
mozilla::dom::IntersectionCallback* IntersectionCallback() { return mCallback; }
|
||||
|
|
|
@ -297,6 +297,15 @@ nsNodeUtils::LastRelease(nsINode* 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;
|
||||
aNode->mSlots = nullptr;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче