CSSImageSetValue.h [plain text]
#pragma once
#include "CSSValueList.h"
#include "CachedResourceHandle.h"
#include "ResourceLoaderOptions.h"
#include <wtf/Function.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class CachedImage;
class CachedResourceLoader;
class CSSImageValue;
class Document;
namespace Style {
class BuilderState;
}
struct ImageWithScale {
RefPtr<CSSValue> value;
float scaleFactor { 1 };
};
class CSSImageSetValue final : public CSSValueList {
public:
static Ref<CSSImageSetValue> create();
~CSSImageSetValue();
ImageWithScale selectBestFitImage(const Document&);
CachedImage* cachedImage() const;
String customCSSText() const;
bool traverseSubresources(const WTF::Function<bool (const CachedResource&)>& handler) const;
void updateDeviceScaleFactor(const Document&);
Ref<CSSImageSetValue> imageSetWithStylesResolved(Style::BuilderState&);
private:
CSSImageSetValue();
ImageWithScale bestImageForScaleFactor();
void fillImageSet();
static inline bool compareByScaleFactor(ImageWithScale first, ImageWithScale second) { return first.scaleFactor < second.scaleFactor; }
RefPtr<CSSValue> m_selectedImageValue;
bool m_accessedBestFitImage { false };
ImageWithScale m_bestFitImage;
float m_deviceScaleFactor { 1 };
Vector<ImageWithScale> m_imagesInSet;
};
}
SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSImageSetValue, isImageSetValue())