Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / svg / SVGViewSpec.cpp
index 9db1355..adcea68 100644 (file)
@@ -21,8 +21,6 @@
 #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"
@@ -45,21 +43,18 @@ const SVGPropertyInfo* SVGViewSpec::transformPropertyInfo()
 }
 
 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()
@@ -68,15 +63,9 @@ 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)
@@ -100,7 +89,7 @@ String SVGViewSpec::transformString() const
 
 String SVGViewSpec::viewBoxString() const
 {
-    return m_viewBox->currentValue()->valueAsString();
+    return viewBox()->currentValue()->valueAsString();
 }
 
 SVGElement* SVGViewSpec::viewTarget() const
@@ -130,20 +119,19 @@ PassRefPtr<SVGAnimatedProperty> SVGViewSpec::lookupOrCreateTransformWrapper(SVGV
 
 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();
 }
 
@@ -176,7 +164,7 @@ bool SVGViewSpec::parseViewSpecInternal(const CharType* ptr, const CharType* end
                 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++;
@@ -198,7 +186,7 @@ bool SVGViewSpec::parseViewSpecInternal(const CharType* ptr, const CharType* end
             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;
@@ -209,7 +197,7 @@ bool SVGViewSpec::parseViewSpecInternal(const CharType* ptr, const CharType* end
             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;