#ifndef SVGZoomAndPan_h
#define SVGZoomAndPan_h
#include "SVGNames.h"
#include "core/dom/QualifiedName.h"
#include "wtf/HashSet.h"
namespace WebCore {
class ExceptionState;
class SVGViewSpec;
enum SVGZoomAndPanType {
SVGZoomAndPanUnknown = 0,
SVGZoomAndPanDisable,
SVGZoomAndPanMagnify
};
class SVGZoomAndPan {
public:
enum {
SVG_ZOOMANDPAN_UNKNOWN = SVGZoomAndPanUnknown,
SVG_ZOOMANDPAN_DISABLE = SVGZoomAndPanDisable,
SVG_ZOOMANDPAN_MAGNIFY = SVGZoomAndPanMagnify
};
static bool isKnownAttribute(const QualifiedName&);
static void addSupportedAttributes(HashSet<QualifiedName>&);
static SVGZoomAndPanType parseFromNumber(unsigned short number)
{
if (!number || number > SVGZoomAndPanMagnify)
return SVGZoomAndPanUnknown;
return static_cast<SVGZoomAndPanType>(number);
}
bool parseZoomAndPan(const LChar*& start, const LChar* end);
bool parseZoomAndPan(const UChar*& start, const UChar* end);
bool parseAttribute(const QualifiedName& name, const AtomicString& value)
{
if (name == SVGNames::zoomAndPanAttr) {
m_zoomAndPan = SVGZoomAndPanUnknown;
if (!value.isEmpty()) {
if (value.is8Bit()) {
const LChar* start = value.characters8();
parseZoomAndPan(start, start + value.length());
} else {
const UChar* start = value.characters16();
parseZoomAndPan(start, start + value.length());
}
}
return true;
}
return false;
}
static SVGZoomAndPanType zoomAndPan(SVGZoomAndPan& object) { return object.m_zoomAndPan; }
static void setZoomAndPan(SVGZoomAndPan& object, unsigned short value, ExceptionState&) { object.setZoomAndPan(value); }
static void setZoomAndPan(SVGViewSpec&, unsigned short, ExceptionState&);
void setZoomAndPan(unsigned short value) { m_zoomAndPan = parseFromNumber(value); }
SVGZoomAndPanType zoomAndPan() const { return m_zoomAndPan; }
protected:
SVGZoomAndPan();
void resetZoomAndPan();
private:
SVGZoomAndPanType m_zoomAndPan;
};
}
#endif