CSSImageGeneratorValue.h [plain text]
#pragma once
#include "CSSValue.h"
#include "FloatSizeHash.h"
#include <wtf/HashCountedSet.h>
namespace WebCore {
class CachedImage;
class CachedResourceLoader;
class GeneratedImage;
class Image;
class RenderElement;
struct ResourceLoaderOptions;
class CSSImageGeneratorValue : public CSSValue {
public:
~CSSImageGeneratorValue();
void addClient(RenderElement&);
void removeClient(RenderElement&);
const HashCountedSet<RenderElement*>& clients() const { return m_clients; }
RefPtr<Image> image(RenderElement&, const FloatSize&);
bool isFixedSize() const;
FloatSize fixedSize(const RenderElement&);
bool isPending() const;
bool knownToBeOpaque(const RenderElement&) const;
void loadSubimages(CachedResourceLoader&, const ResourceLoaderOptions&);
protected:
CSSImageGeneratorValue(ClassType);
GeneratedImage* cachedImageForSize(FloatSize);
void saveCachedImageForSize(FloatSize, GeneratedImage&);
static CachedImage* cachedImageForCSSValue(CSSValue&, CachedResourceLoader&, const ResourceLoaderOptions&);
static bool subimageIsPending(const CSSValue&);
private:
class CachedGeneratedImage;
void evictCachedGeneratedImage(FloatSize);
HashCountedSet<RenderElement*> m_clients;
HashMap<FloatSize, std::unique_ptr<CachedGeneratedImage>> m_images;
};
}
SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSImageGeneratorValue, isImageGeneratorValue())