Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / svg / SVGViewSpec.h
blob59e022397c95df358f208e1aa204e1c64a04bc2f
1 /*
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.
20 #ifndef SVGViewSpec_h
21 #define SVGViewSpec_h
23 #include "bindings/core/v8/ScriptWrappable.h"
24 #include "core/svg/SVGFitToViewBox.h"
25 #include "core/svg/SVGSVGElement.h"
26 #include "core/svg/SVGZoomAndPan.h"
27 #include "platform/heap/Handle.h"
29 namespace blink {
31 class SVGViewSpec final : public RefCountedWillBeGarbageCollectedFinalized<SVGViewSpec>, public ScriptWrappable, public SVGZoomAndPan, public SVGFitToViewBox {
32 DEFINE_WRAPPERTYPEINFO();
33 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(SVGViewSpec);
34 public:
35 #if !ENABLE(OILPAN)
36 using RefCounted<SVGViewSpec>::ref;
37 using RefCounted<SVGViewSpec>::deref;
38 #endif
40 static PassRefPtrWillBeRawPtr<SVGViewSpec> create(SVGSVGElement* contextElement)
42 return adoptRefWillBeNoop(new SVGViewSpec(contextElement));
45 bool parseViewSpec(const String&);
46 void reset();
47 void detachContextElement();
48 template<typename T> void inheritViewAttributesFromElement(T*);
50 // JS API
51 SVGTransformList* transform() { return m_transform ? m_transform->baseValue() : 0; }
52 PassRefPtrWillBeRawPtr<SVGTransformListTearOff> transformFromJavascript() { return m_transform ? m_transform->baseVal() : 0; }
53 SVGElement* viewTarget() const;
54 String viewBoxString() const;
55 String preserveAspectRatioString() const;
56 String transformString() const;
57 String viewTargetString() const { return m_viewTargetString; }
58 // override SVGZoomAndPan.setZoomAndPan so can throw exception on write
59 void setZoomAndPan(unsigned short value) { } // read only
60 void setZoomAndPan(unsigned short value, ExceptionState&);
62 DECLARE_VIRTUAL_TRACE();
64 SVGSVGElement* contextElement() { return m_contextElement.get(); }
66 private:
67 explicit SVGViewSpec(SVGSVGElement*);
69 template<typename CharType>
70 bool parseViewSpecInternal(const CharType* ptr, const CharType* end);
72 RawPtrWillBeMember<SVGSVGElement> m_contextElement;
73 RefPtrWillBeMember<SVGAnimatedTransformList> m_transform;
74 String m_viewTargetString;
77 template <typename T>
78 void SVGViewSpec::inheritViewAttributesFromElement(T* inheritFromElement)
80 if (!inheritFromElement->hasEmptyViewBox())
81 viewBox()->baseValue()->setValue(inheritFromElement->viewBox()->currentValue()->value());
83 if (inheritFromElement->preserveAspectRatio()->isSpecified()) {
84 preserveAspectRatio()->baseValue()->setAlign(inheritFromElement->preserveAspectRatio()->currentValue()->align());
85 preserveAspectRatio()->baseValue()->setMeetOrSlice(inheritFromElement->preserveAspectRatio()->currentValue()->meetOrSlice());
88 if (inheritFromElement->hasAttribute(SVGNames::zoomAndPanAttr))
89 setZoomAndPan(inheritFromElement->zoomAndPan());
92 } // namespace blink
94 #endif // SVGViewSpec_h