Bug 1619858 - Minimal cleanup of the image lazy loading code. r=hiro
We don't really need to wait till we have an inner window, really. The mOwner is only used to create a reflector, and we don't even want to expose this observer to script, so we could leave it null if we wanted. Differential Revision: https://phabricator.services.mozilla.com/D65369
This commit is contained in:
@@ -1262,12 +1262,9 @@ void HTMLImageElement::SetLazyLoading() {
|
||||
// There (maybe) is a race condition that we have no LazyLoadImageObserver
|
||||
// when the root document has been removed from the docshell.
|
||||
// In the case we don't need to worry about lazy-loading.
|
||||
if (DOMIntersectionObserver* lazyLoadObserver =
|
||||
OwnerDoc()->GetLazyLoadImageObserver()) {
|
||||
lazyLoadObserver->Observe(*this);
|
||||
mLazyLoading = true;
|
||||
UpdateImageState(true);
|
||||
}
|
||||
OwnerDoc()->EnsureLazyLoadImageObserver().Observe(*this);
|
||||
mLazyLoading = true;
|
||||
UpdateImageState(true);
|
||||
}
|
||||
|
||||
void HTMLImageElement::StartLoadingIfNeeded() {
|
||||
@@ -1290,13 +1287,7 @@ void HTMLImageElement::StopLazyLoadingAndStartLoadIfNeeded() {
|
||||
return;
|
||||
}
|
||||
mLazyLoading = false;
|
||||
|
||||
DOMIntersectionObserver* lazyLoadObserver =
|
||||
OwnerDoc()->GetLazyLoadImageObserver();
|
||||
MOZ_ASSERT(lazyLoadObserver);
|
||||
|
||||
lazyLoadObserver->Unobserve(*this);
|
||||
|
||||
OwnerDoc()->GetLazyLoadImageObserver()->Unobserve(*this);
|
||||
StartLoadingIfNeeded();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user