CSSFontFaceSource.h [plain text]
#ifndef CSSFontFaceSource_h
#define CSSFontFaceSource_h
#include "CachedFontClient.h"
#include "CachedResourceHandle.h"
#include "SharedBuffer.h"
#if ENABLE(SVG_FONTS)
#include "SVGFontElement.h"
#include "SVGFontFaceElement.h"
#endif
#include "Timer.h"
#include <wtf/HashMap.h>
#include <wtf/text/AtomicString.h>
namespace WebCore {
class CachedFont;
class CSSFontFace;
class CSSFontSelector;
class Font;
class FontDescription;
class CSSFontFaceSource final : public CachedFontClient {
WTF_MAKE_FAST_ALLOCATED;
public:
CSSFontFaceSource(const String&, CachedFont* = nullptr);
virtual ~CSSFontFaceSource();
bool isLoaded() const;
bool isValid() const;
const AtomicString& string() const { return m_string; }
void setFontFace(CSSFontFace* face) { m_face = face; }
virtual void fontLoaded(CachedFont*) override;
RefPtr<Font> font(const FontDescription&, bool syntheticBold, bool syntheticItalic, CSSFontSelector*);
void pruneTable();
#if ENABLE(SVG_FONTS)
SVGFontFaceElement* svgFontFaceElement() const { return m_svgFontFaceElement.get(); }
void setSVGFontFaceElement(PassRefPtr<SVGFontFaceElement> element) { m_svgFontFaceElement = element; }
bool isSVGFontFaceSource() const { return m_svgFontFaceElement || m_hasExternalSVGFont; }
void setHasExternalSVGFont() { m_hasExternalSVGFont = true; }
#endif
#if ENABLE(FONT_LOAD_EVENTS)
bool isDecodeError() const;
bool ensureFontData();
#endif
private:
void startLoadingTimerFired();
AtomicString m_string; CachedResourceHandle<CachedFont> m_font; CSSFontFace* m_face; HashMap<unsigned, RefPtr<Font>> m_fontTable;
#if ENABLE(SVG_OTF_CONVERTER)
RefPtr<SharedBuffer> m_generatedOTFBuffer;
#endif
#if ENABLE(SVG_FONTS) || ENABLE(SVG_OTF_CONVERTER)
RefPtr<SVGFontFaceElement> m_svgFontFaceElement;
bool m_hasExternalSVGFont;
#endif
};
}
#endif