#ifndef FontResource_h
#define FontResource_h
#include "core/fetch/ResourceClient.h"
#include "core/fetch/ResourcePtr.h"
#include "platform/Timer.h"
#include "platform/fonts/FontOrientation.h"
#include "platform/fonts/FontWidthVariant.h"
#include "wtf/OwnPtr.h"
namespace WebCore {
class ResourceFetcher;
class FontPlatformData;
class SVGDocument;
class SVGFontElement;
class FontCustomPlatformData;
class FontResource FINAL : public Resource {
public:
typedef ResourceClient ClientType;
FontResource(const ResourceRequest&);
virtual ~FontResource();
virtual void load(ResourceFetcher*, const ResourceLoaderOptions&) OVERRIDE;
virtual void didAddClient(ResourceClient*) OVERRIDE;
virtual void allClientsRemoved() OVERRIDE;
void beginLoadIfNeeded(ResourceFetcher* dl);
virtual bool stillNeedsLoad() const OVERRIDE { return !m_loadInitiated; }
bool exceedsFontLoadWaitLimit() const { return m_exceedsFontLoadWaitLimit; }
bool ensureCustomFontData();
FontPlatformData platformDataFromCustomData(float size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth);
#if ENABLE(SVG_FONTS)
bool ensureSVGFontData();
SVGFontElement* getSVGFontById(const String&) const;
#endif
protected:
virtual bool isSafeToUnlock() const OVERRIDE;
private:
virtual void checkNotify() OVERRIDE;
void fontLoadWaitLimitCallback(Timer<FontResource>*);
OwnPtr<FontCustomPlatformData> m_fontData;
bool m_loadInitiated;
bool m_exceedsFontLoadWaitLimit;
Timer<FontResource> m_fontLoadWaitLimitTimer;
#if ENABLE(SVG_FONTS)
RefPtr<WebCore::SVGDocument> m_externalSVGDocument;
#endif
friend class MemoryCache;
};
DEFINE_RESOURCE_TYPE_CASTS(Font);
class FontResourceClient : public ResourceClient {
public:
virtual ~FontResourceClient() { }
static ResourceClientType expectedType() { return FontType; }
virtual ResourceClientType resourceClientType() const OVERRIDE FINAL { return expectedType(); }
virtual void fontLoaded(FontResource*) { }
virtual void didStartFontLoad(FontResource*) { }
virtual void fontLoadWaitLimitExceeded(FontResource*) { }
};
}
#endif