зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1371925 - Remove unnecessary hashtable lookups in DOMIntersectionObserver. r=froydnj
MozReview-Commit-ID: LUt03nCz3SD
This commit is contained in:
Родитель
a8cf987309
Коммит
4264d9480f
|
@ -150,12 +150,11 @@ DOMIntersectionObserver::GetThresholds(nsTArray<double>& aRetVal)
|
|||
void
|
||||
DOMIntersectionObserver::Observe(Element& aTarget)
|
||||
{
|
||||
if (mObservationTargets.Contains(&aTarget)) {
|
||||
return;
|
||||
if (mObservationTargets.EnsureInserted(&aTarget)) {
|
||||
// A new entry was created.
|
||||
aTarget.RegisterIntersectionObserver(this);
|
||||
Connect();
|
||||
}
|
||||
aTarget.RegisterIntersectionObserver(this);
|
||||
mObservationTargets.PutEntry(&aTarget);
|
||||
Connect();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -173,14 +172,11 @@ DOMIntersectionObserver::Unobserve(Element& aTarget)
|
|||
void
|
||||
DOMIntersectionObserver::UnlinkTarget(Element& aTarget)
|
||||
{
|
||||
if (!mObservationTargets.Contains(&aTarget)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mObservationTargets.RemoveEntry(&aTarget);
|
||||
if (mObservationTargets.Count() == 0) {
|
||||
Disconnect();
|
||||
}
|
||||
if (mObservationTargets.EnsureRemoved(&aTarget) &&
|
||||
mObservationTargets.Count() == 0) {
|
||||
// We removed the last entry.
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Загрузка…
Ссылка в новой задаче