#include "core/svg/SVGViewSpec.h"
#include "SVGNames.h"
-#include "bindings/v8/ExceptionMessages.h"
-#include "bindings/v8/ExceptionState.h"
#include "core/dom/Document.h"
#include "core/svg/SVGAnimatedTransformList.h"
#include "core/svg/SVGParserUtilities.h"
}
SVGViewSpec::SVGViewSpec(SVGSVGElement* contextElement)
- : m_contextElement(contextElement)
- , m_zoomAndPan(SVGZoomAndPanMagnify)
// Note: We make |viewBox| and |preserveAspectRatio|'s contextElement the target element of SVGViewSpec.
// This contextElement will be only used for keeping this alive from the tearoff.
// SVGSVGElement holds a strong-ref to this SVGViewSpec, so this is kept alive as:
// AnimatedProperty tearoff -(contextElement)-> SVGSVGElement -(RefPtr)-> SVGViewSpec.
- , m_viewBox(SVGAnimatedRect::create(contextElement, SVGNames::viewBoxAttr))
- , m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(contextElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create()))
+ : SVGFitToViewBox(contextElement, PropertyMapPolicySkip) // Note: addToPropertyMap is not needed, as SVGViewSpec do not correspond to an element.
+ , m_contextElement(contextElement)
{
ASSERT(m_contextElement);
ScriptWrappable::init(this);
- m_viewBox->setReadOnly();
- m_preserveAspectRatio->setReadOnly();
- // Note: addToPropertyMap is not needed, as SVGViewSpec do not correspond to an element.
+ viewBox()->setReadOnly();
+ preserveAspectRatio()->setReadOnly();
}
const AtomicString& SVGViewSpec::transformIdentifier()
return s_identifier;
}
-void SVGViewSpec::setZoomAndPan(unsigned short, ExceptionState& exceptionState)
-{
- // SVGViewSpec and all of its content is read-only.
- exceptionState.throwDOMException(NoModificationAllowedError, ExceptionMessages::readOnly());
-}
-
String SVGViewSpec::preserveAspectRatioString() const
{
- return m_preserveAspectRatio->baseValue()->valueAsString();
+ return preserveAspectRatio()->baseValue()->valueAsString();
}
void SVGViewSpec::setTransformString(const String& transform)
String SVGViewSpec::viewBoxString() const
{
- return m_viewBox->currentValue()->valueAsString();
+ return viewBox()->currentValue()->valueAsString();
}
SVGElement* SVGViewSpec::viewTarget() const
void SVGViewSpec::detachContextElement()
{
- m_viewBox = 0;
- m_preserveAspectRatio = 0;
+ clearViewBox();
+ clearPreserveAspectRatio();
m_contextElement = 0;
}
void SVGViewSpec::reset()
{
- m_zoomAndPan = SVGZoomAndPanMagnify;
+ resetZoomAndPan();
m_transform.clear();
- ASSERT(m_viewBox);
- m_viewBox->baseValue()->setValue(FloatRect());
- ASSERT(m_preserveAspectRatio);
- m_preserveAspectRatio->baseValue()->setAlign(SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID);
- m_preserveAspectRatio->baseValue()->setMeetOrSlice(SVGPreserveAspectRatio::SVG_MEETORSLICE_MEET);
+ updateViewBox(FloatRect());
+ ASSERT(preserveAspectRatio());
+ preserveAspectRatio()->baseValue()->setAlign(SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID);
+ preserveAspectRatio()->baseValue()->setMeetOrSlice(SVGPreserveAspectRatio::SVG_MEETORSLICE_MEET);
m_viewTargetString = emptyString();
}
float height = 0.0f;
if (!(parseNumber(ptr, end, x) && parseNumber(ptr, end, y) && parseNumber(ptr, end, width) && parseNumber(ptr, end, height, false)))
return false;
- m_viewBox->baseValue()->setValue(FloatRect(x, y, width, height));
+ updateViewBox(FloatRect(x, y, width, height));
if (ptr >= end || *ptr != ')')
return false;
ptr++;
if (ptr >= end || *ptr != '(')
return false;
ptr++;
- if (!parseZoomAndPan(ptr, end, m_zoomAndPan))
+ if (!parseZoomAndPan(ptr, end))
return false;
if (ptr >= end || *ptr != ')')
return false;
if (ptr >= end || *ptr != '(')
return false;
ptr++;
- if (!m_preserveAspectRatio->baseValue()->parse(ptr, end, false))
+ if (!preserveAspectRatio()->baseValue()->parse(ptr, end, false))
return false;
if (ptr >= end || *ptr != ')')
return false;