#ifndef SVGTextQuery_h
#define SVGTextQuery_h
#include "core/rendering/svg/SVGTextFragment.h"
#include "platform/geometry/FloatPoint.h"
#include "platform/geometry/FloatRect.h"
#include "wtf/Vector.h"
namespace WebCore {
class InlineFlowBox;
class RenderObject;
class SVGInlineTextBox;
class SVGTextQuery {
public:
SVGTextQuery(RenderObject*);
unsigned numberOfCharacters() const;
float textLength() const;
float subStringLength(unsigned startPosition, unsigned length) const;
FloatPoint startPositionOfCharacter(unsigned position) const;
FloatPoint endPositionOfCharacter(unsigned position) const;
float rotationOfCharacter(unsigned position) const;
FloatRect extentOfCharacter(unsigned position) const;
int characterNumberAtPosition(const FloatPoint&) const;
struct Data;
private:
typedef bool (SVGTextQuery::*ProcessTextFragmentCallback)(Data*, const SVGTextFragment&) const;
bool executeQuery(Data*, ProcessTextFragmentCallback) const;
void collectTextBoxesInFlowBox(InlineFlowBox*);
bool mapStartEndPositionsIntoFragmentCoordinates(Data*, const SVGTextFragment&, int& startPosition, int& endPosition) const;
void modifyStartEndPositionsRespectingLigatures(Data*, int& startPosition, int& endPosition) const;
private:
bool numberOfCharactersCallback(Data*, const SVGTextFragment&) const;
bool textLengthCallback(Data*, const SVGTextFragment&) const;
bool subStringLengthCallback(Data*, const SVGTextFragment&) const;
bool startPositionOfCharacterCallback(Data*, const SVGTextFragment&) const;
bool endPositionOfCharacterCallback(Data*, const SVGTextFragment&) const;
bool rotationOfCharacterCallback(Data*, const SVGTextFragment&) const;
bool extentOfCharacterCallback(Data*, const SVGTextFragment&) const;
bool characterNumberAtPositionCallback(Data*, const SVGTextFragment&) const;
private:
Vector<SVGInlineTextBox*> m_textBoxes;
};
}
#endif