#pragma once
#include "CachedResource.h"
#include "CachedResourceClient.h"
#include "Font.h"
#include "TextFlags.h"
namespace WebCore {
class CachedResourceLoader;
class FontDescription;
class FontPlatformData;
struct FontSelectionSpecifiedCapabilities;
class SVGDocument;
class SVGFontElement;
struct FontCustomPlatformData;
template <typename T> class FontTaggedSettings;
typedef FontTaggedSettings<int> FontFeatureSettings;
class CachedFont : public CachedResource {
public:
CachedFont(CachedResourceRequest&&, const PAL::SessionID&, const CookieJar*, Type = Type::FontResource);
virtual ~CachedFont();
void beginLoadIfNeeded(CachedResourceLoader&);
bool stillNeedsLoad() const override { return !m_loadInitiated; }
virtual bool ensureCustomFontData(const AtomString& remoteURI);
static std::unique_ptr<FontCustomPlatformData> createCustomFontData(SharedBuffer&, const String& itemInCollection, bool& wrapping);
static FontPlatformData platformDataFromCustomData(FontCustomPlatformData&, const FontDescription&, bool bold, bool italic, const FontFeatureSettings&, FontSelectionSpecifiedCapabilities);
virtual RefPtr<Font> createFont(const FontDescription&, const AtomString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings&, FontSelectionSpecifiedCapabilities);
protected:
FontPlatformData platformDataFromCustomData(const FontDescription&, bool bold, bool italic, const FontFeatureSettings&, FontSelectionSpecifiedCapabilities);
bool ensureCustomFontData(SharedBuffer* data);
private:
String calculateItemInCollection() const;
void checkNotify(const NetworkLoadMetrics&) override;
bool mayTryReplaceEncodedData() const override;
void load(CachedResourceLoader&) override;
NO_RETURN_DUE_TO_ASSERT void setBodyDataFrom(const CachedResource&) final { ASSERT_NOT_REACHED(); }
void didAddClient(CachedResourceClient&) override;
void finishLoading(SharedBuffer*, const NetworkLoadMetrics&) override;
void allClientsRemoved() override;
bool m_loadInitiated;
bool m_hasCreatedFontDataWrappingResource;
std::unique_ptr<FontCustomPlatformData> m_fontCustomPlatformData;
friend class MemoryCache;
};
}
SPECIALIZE_TYPE_TRAITS_CACHED_RESOURCE(CachedFont, CachedResource::Type::FontResource)