mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1371956 - Use mApproximatelyVisibleFrames.EnsureInserted/EnsureRemoved to avoid doing unnecessary hashtable lookups. r=froydnj
MozReview-Commit-ID: 87A0v0APtFs
This commit is contained in:
parent
41a0eaaaa9
commit
7648c5aafb
@ -5768,10 +5768,8 @@ PresShell::MarkFramesInListApproximatelyVisible(const nsDisplayList& aList,
|
||||
|
||||
// Use the presshell containing the frame.
|
||||
auto* presShell = static_cast<PresShell*>(frame->PresContext()->PresShell());
|
||||
uint32_t count = presShell->mApproximatelyVisibleFrames.Count();
|
||||
MOZ_ASSERT(!presShell->AssumeAllFramesVisible());
|
||||
presShell->mApproximatelyVisibleFrames.PutEntry(frame);
|
||||
if (presShell->mApproximatelyVisibleFrames.Count() > count) {
|
||||
if (presShell->mApproximatelyVisibleFrames.EnsureInserted(frame)) {
|
||||
// The frame was added to mApproximatelyVisibleFrames, so increment its visible count.
|
||||
frame->IncApproximateVisibleCount();
|
||||
}
|
||||
@ -5909,9 +5907,7 @@ PresShell::MarkFramesInSubtreeApproximatelyVisible(nsIFrame* aFrame,
|
||||
aFrame->StyleVisibility()->IsVisible() &&
|
||||
(!aRemoveOnly || aFrame->GetVisibility() == Visibility::APPROXIMATELY_VISIBLE)) {
|
||||
MOZ_ASSERT(!AssumeAllFramesVisible());
|
||||
uint32_t count = mApproximatelyVisibleFrames.Count();
|
||||
mApproximatelyVisibleFrames.PutEntry(aFrame);
|
||||
if (mApproximatelyVisibleFrames.Count() > count) {
|
||||
if (mApproximatelyVisibleFrames.EnsureInserted(aFrame)) {
|
||||
// The frame was added to mApproximatelyVisibleFrames, so increment its visible count.
|
||||
aFrame->IncApproximateVisibleCount();
|
||||
}
|
||||
@ -6233,9 +6229,8 @@ PresShell::EnsureFrameInApproximatelyVisibleList(nsIFrame* aFrame)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!mApproximatelyVisibleFrames.Contains(aFrame)) {
|
||||
MOZ_ASSERT(!AssumeAllFramesVisible());
|
||||
mApproximatelyVisibleFrames.PutEntry(aFrame);
|
||||
if (mApproximatelyVisibleFrames.EnsureInserted(aFrame)) {
|
||||
// We inserted a new entry.
|
||||
aFrame->IncApproximateVisibleCount();
|
||||
}
|
||||
}
|
||||
@ -6258,11 +6253,8 @@ PresShell::RemoveFrameFromApproximatelyVisibleList(nsIFrame* aFrame)
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t count = mApproximatelyVisibleFrames.Count();
|
||||
mApproximatelyVisibleFrames.RemoveEntry(aFrame);
|
||||
|
||||
if (aFrame->TrackingVisibility() &&
|
||||
mApproximatelyVisibleFrames.Count() < count) {
|
||||
if (mApproximatelyVisibleFrames.EnsureRemoved(aFrame) &&
|
||||
aFrame->TrackingVisibility()) {
|
||||
// aFrame was in the hashtable, and we're still tracking its visibility,
|
||||
// so we need to decrement its visible count.
|
||||
aFrame->DecApproximateVisibleCount();
|
||||
|
Loading…
Reference in New Issue
Block a user