2 * Copyright (C) 2007 Rob Buis <buis@kde.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
23 #include "bindings/v8/ScriptWrappable.h"
24 #include "core/svg/SVGAnimatedPreserveAspectRatio.h"
25 #include "core/svg/SVGAnimatedRect.h"
26 #include "core/svg/SVGFitToViewBox.h"
27 #include "core/svg/SVGSVGElement.h"
28 #include "core/svg/SVGTransformList.h"
29 #include "core/svg/SVGZoomAndPan.h"
30 #include "wtf/WeakPtr.h"
35 class SVGTransformListPropertyTearOff;
37 class SVGViewSpec FINAL : public RefCounted<SVGViewSpec>, public ScriptWrappable, public SVGZoomAndPan, public SVGFitToViewBox {
39 using RefCounted<SVGViewSpec>::ref;
40 using RefCounted<SVGViewSpec>::deref;
42 static PassRefPtr<SVGViewSpec> create(SVGSVGElement* contextElement)
44 return adoptRef(new SVGViewSpec(contextElement));
47 bool parseViewSpec(const String&);
50 SVGElement* viewTarget() const;
51 String viewBoxString() const;
53 String preserveAspectRatioString() const;
55 void setTransformString(const String&);
56 String transformString() const;
58 void setViewTargetString(const String& string) { m_viewTargetString = string; }
59 String viewTargetString() const { return m_viewTargetString; }
61 SVGZoomAndPanType zoomAndPan() const { return m_zoomAndPan; }
62 void setZoomAndPan(unsigned short zoomAndPan) { setZoomAndPanBaseValue(zoomAndPan); }
63 void setZoomAndPan(unsigned short, ExceptionState&);
64 void setZoomAndPanBaseValue(unsigned short zoomAndPan) { m_zoomAndPan = SVGZoomAndPan::parseFromNumber(zoomAndPan); }
66 SVGElement* contextElement() const { return m_contextElement; }
67 void detachContextElement();
69 // Custom non-animated 'transform' property.
70 SVGTransformListPropertyTearOff* transform();
71 SVGTransformList transformBaseValue() const { return m_transform; }
73 SVGAnimatedRect* viewBox() { return m_viewBox.get(); }
74 SVGAnimatedPreserveAspectRatio* preserveAspectRatio() { return m_preserveAspectRatio.get(); }
77 explicit SVGViewSpec(SVGSVGElement*);
79 static const SVGPropertyInfo* transformPropertyInfo();
81 static const AtomicString& transformIdentifier();
83 static PassRefPtr<SVGAnimatedProperty> lookupOrCreateTransformWrapper(SVGViewSpec* contextElement);
85 template<typename CharType>
86 bool parseViewSpecInternal(const CharType* ptr, const CharType* end);
88 // FIXME(oilpan): This is back-ptr to be cleared from contextElement.
89 SVGSVGElement* m_contextElement;
91 SVGZoomAndPanType m_zoomAndPan;
92 SVGTransformList m_transform;
93 RefPtr<SVGAnimatedRect> m_viewBox;
94 RefPtr<SVGAnimatedPreserveAspectRatio> m_preserveAspectRatio;
95 String m_viewTargetString;
98 } // namespace WebCore