mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 15:58:39 +09:00
implement lazy-loading
This commit is contained in:
parent
8594600d9b
commit
629f4db8fe
5 changed files with 179 additions and 0 deletions
|
|
@ -13,6 +13,7 @@
|
|||
#include "imgRequestProxy.h"
|
||||
#include "Units.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsITimer.h"
|
||||
|
||||
namespace mozilla {
|
||||
class EventChainPreVisitor;
|
||||
|
|
@ -168,6 +169,14 @@ public:
|
|||
{
|
||||
SetHTMLAttr(nsGkAtoms::usemap, aUseMap, aError);
|
||||
}
|
||||
void GetLoading(nsAString& aLoading)
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::loading, aLoading);
|
||||
}
|
||||
void SetLoading(const nsAString& aLoading, ErrorResult& aError)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::loading, aLoading, aError);
|
||||
}
|
||||
void SetName(const nsAString& aName, ErrorResult& aError)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::name, aName, aError);
|
||||
|
|
@ -360,6 +369,15 @@ protected:
|
|||
RefPtr<ResponsiveImageSelector> mResponsiveSelector;
|
||||
|
||||
private:
|
||||
static void LazyLoadTimerCallback(nsITimer* aTimer, void* aClosure);
|
||||
|
||||
bool ShouldLazyLoadImage() const;
|
||||
bool IsProbablyVisibleForLazyLoad() const;
|
||||
bool ShouldDeferImageLoad() const;
|
||||
void EnsureLazyLoadTimer();
|
||||
void StopLazyLoadTimer();
|
||||
void MaybeLoadImageFromLazyTimer();
|
||||
|
||||
bool SourceElementMatches(nsIContent* aSourceNode);
|
||||
|
||||
static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||
|
|
@ -392,6 +410,8 @@ private:
|
|||
RefPtr<ImageLoadTask> mPendingImageLoadTask;
|
||||
nsCOMPtr<nsIPrincipal> mSrcTriggeringPrincipal;
|
||||
nsCOMPtr<nsIPrincipal> mSrcsetTriggeringPrincipal;
|
||||
nsCOMPtr<nsITimer> mLazyLoadTimer;
|
||||
bool mLazyLoadAlwaysLoad;
|
||||
|
||||
// Last URL that was attempted to load by this element.
|
||||
nsCOMPtr<nsIURI> mLastSelectedSource;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue