SVGTextLayoutAttributesBuilder.h [plain text]
#ifndef SVGTextLayoutAttributesBuilder_h
#define SVGTextLayoutAttributesBuilder_h
#if ENABLE(SVG)
#include "SVGTextMetricsBuilder.h"
#include <wtf/Vector.h>
namespace WebCore {
class RenderObject;
class RenderSVGInlineText;
class RenderSVGText;
class SVGTextPositioningElement;
class SVGTextLayoutAttributesBuilder {
WTF_MAKE_NONCOPYABLE(SVGTextLayoutAttributesBuilder);
public:
SVGTextLayoutAttributesBuilder();
bool buildLayoutAttributesForForSubtree(RenderSVGText*);
void buildLayoutAttributesForTextRenderer(RenderSVGInlineText*);
void rebuildMetricsForTextRenderer(RenderSVGInlineText*);
void clearTextPositioningElements() { m_textPositions.clear(); }
unsigned numberOfTextPositioningElements() const { return m_textPositions.size(); }
private:
struct TextPosition {
TextPosition(SVGTextPositioningElement* newElement = 0, unsigned newStart = 0, unsigned newLength = 0)
: element(newElement)
, start(newStart)
, length(newLength)
{
}
SVGTextPositioningElement* element;
unsigned start;
unsigned length;
};
void buildCharacterDataMap(RenderSVGText*);
void collectTextPositioningElements(RenderObject*, const UChar*& lastCharacter);
void fillCharacterDataMap(const TextPosition&);
private:
unsigned m_textLength;
Vector<TextPosition> m_textPositions;
SVGCharacterDataMap m_characterDataMap;
SVGTextMetricsBuilder m_metricsBuilder;
};
}
#endif // ENABLE(SVG)
#endif