#ifndef CachedFont_h
#define CachedFont_h
#include "CachedResource.h"
#include "CachedResourceClient.h"
#include "Font.h"
#include "TextFlags.h"
namespace WebCore {
class CachedResourceLoader;
class FontDescription;
class FontPlatformData;
class SVGDocument;
class SVGFontElement;
struct FontCustomPlatformData;
class CachedFont : public CachedResource {
public:
CachedFont(const ResourceRequest&, SessionID, Type = FontResource);
virtual ~CachedFont();
void beginLoadIfNeeded(CachedResourceLoader&);
virtual bool stillNeedsLoad() const override { return !m_loadInitiated; }
virtual bool ensureCustomFontData(bool externalSVG, const AtomicString& remoteURI);
virtual RefPtr<Font> createFont(const FontDescription&, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, bool externalSVG);
protected:
FontPlatformData platformDataFromCustomData(float size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
bool ensureCustomFontData(SharedBuffer* data);
private:
virtual void checkNotify() override;
virtual bool mayTryReplaceEncodedData() const override;
virtual void load(CachedResourceLoader&, const ResourceLoaderOptions&) override;
virtual void didAddClient(CachedResourceClient*) override;
virtual void finishLoading(SharedBuffer*) override;
virtual void allClientsRemoved() override;
std::unique_ptr<FontCustomPlatformData> m_fontCustomPlatformData;
bool m_loadInitiated;
bool m_hasCreatedFontDataWrappingResource;
friend class MemoryCache;
};
}
SPECIALIZE_TYPE_TRAITS_CACHED_RESOURCE(CachedFont, CachedResource::FontResource)
#endif // CachedFont_h