#ifndef SVGTextRunRenderingContext_h
#define SVGTextRunRenderingContext_h
#include "platform/fonts/Font.h"
#include "platform/text/TextRun.h"
namespace WebCore {
class RenderObject;
class RenderSVGResource;
class SVGTextRunRenderingContext FINAL : public TextRun::RenderingContext {
public:
static PassRefPtr<SVGTextRunRenderingContext> create(RenderObject* renderer)
{
return adoptRef(new SVGTextRunRenderingContext(renderer));
}
RenderObject* renderer() const { return m_renderer; }
#if ENABLE(SVG_FONTS)
RenderSVGResource* activePaintingResource() const { return m_activePaintingResource; }
void setActivePaintingResource(RenderSVGResource* object) { m_activePaintingResource = object; }
virtual GlyphData glyphDataForCharacter(const Font&, const TextRun&, WidthIterator&, UChar32 character, bool mirror, int currentCharacter, unsigned& advanceLength) OVERRIDE;
virtual void drawSVGGlyphs(GraphicsContext*, const TextRun&, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const OVERRIDE;
virtual float floatWidthUsingSVGFont(const Font&, const TextRun&, int& charsConsumed, Glyph& glyphId) const OVERRIDE;
#endif
private:
SVGTextRunRenderingContext(RenderObject* renderer)
: m_renderer(renderer)
#if ENABLE(SVG_FONTS)
, m_activePaintingResource(0)
#endif
{
}
virtual ~SVGTextRunRenderingContext() { }
RenderObject* m_renderer;
#if ENABLE(SVG_FONTS)
RenderSVGResource* m_activePaintingResource;
#endif
};
inline bool textRunNeedsRenderingContext(const Font& font)
{
ASSERT(font.primaryFont());
return font.primaryFont()->isSVGFont();
}
}
#endif