OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Rob Buis <buis@kde.org> | 2 * Copyright (C) 2007 Rob Buis <buis@kde.org> |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #ifndef SVGViewSpec_h | 20 #ifndef SVGViewSpec_h |
21 #define SVGViewSpec_h | 21 #define SVGViewSpec_h |
22 | 22 |
23 #include "bindings/core/v8/TraceWrapperMember.h" | |
24 #include "core/svg/SVGFitToViewBox.h" | 23 #include "core/svg/SVGFitToViewBox.h" |
25 #include "core/svg/SVGSVGElement.h" | 24 #include "core/svg/SVGSVGElement.h" |
26 #include "core/svg/SVGZoomAndPan.h" | 25 #include "core/svg/SVGZoomAndPan.h" |
27 #include "platform/heap/Handle.h" | 26 #include "platform/heap/Handle.h" |
28 | 27 |
29 namespace blink { | 28 namespace blink { |
30 | 29 |
31 class SVGViewSpec final : public GarbageCollectedFinalized<SVGViewSpec>, | 30 class SVGViewSpec final : public GarbageCollectedFinalized<SVGViewSpec>, |
32 public ScriptWrappable, | |
33 public SVGZoomAndPan, | 31 public SVGZoomAndPan, |
34 public SVGFitToViewBox { | 32 public SVGFitToViewBox { |
35 DEFINE_WRAPPERTYPEINFO(); | |
36 USING_GARBAGE_COLLECTED_MIXIN(SVGViewSpec); | 33 USING_GARBAGE_COLLECTED_MIXIN(SVGViewSpec); |
37 | 34 |
38 public: | 35 public: |
39 static SVGViewSpec* create(SVGSVGElement* contextElement) { | 36 static SVGViewSpec* create(SVGSVGElement* contextElement) { |
40 return new SVGViewSpec(contextElement); | 37 return new SVGViewSpec(contextElement); |
41 } | 38 } |
42 | 39 |
43 bool parseViewSpec(const String&); | 40 bool parseViewSpec(const String&); |
44 void reset(); | 41 void reset(); |
45 void detachContextElement(); | |
46 template <typename T> | 42 template <typename T> |
47 void inheritViewAttributesFromElement(T*); | 43 void inheritViewAttributesFromElement(T*); |
48 | 44 |
49 // JS API | |
50 SVGTransformList* transform() { | 45 SVGTransformList* transform() { |
51 return m_transform ? m_transform->baseValue() : 0; | 46 return m_transform ? m_transform->baseValue() : 0; |
52 } | 47 } |
53 SVGTransformListTearOff* transformFromJavascript() { | |
54 return m_transform ? m_transform->baseVal() : 0; | |
55 } | |
56 SVGElement* viewTarget() const; | |
57 String viewBoxString() const; | |
58 String preserveAspectRatioString() const; | |
59 String transformString() const; | |
60 String viewTargetString() const { return m_viewTargetString; } | |
61 // override SVGZoomAndPan.setZoomAndPan so can throw exception on write | |
62 void setZoomAndPan(unsigned short value) {} // read only | |
63 void setZoomAndPan(unsigned short value, ExceptionState&); | |
64 | 48 |
65 DECLARE_VIRTUAL_TRACE(); | 49 DECLARE_VIRTUAL_TRACE(); |
66 DECLARE_VIRTUAL_TRACE_WRAPPERS(); | |
67 | 50 |
68 SVGSVGElement* contextElement() { return m_contextElement.get(); } | 51 SVGSVGElement* contextElement() { return m_contextElement.get(); } |
69 | 52 |
70 private: | 53 private: |
71 explicit SVGViewSpec(SVGSVGElement*); | 54 explicit SVGViewSpec(SVGSVGElement*); |
72 | 55 |
73 template <typename CharType> | 56 template <typename CharType> |
74 bool parseViewSpecInternal(const CharType* ptr, const CharType* end); | 57 bool parseViewSpecInternal(const CharType* ptr, const CharType* end); |
75 | 58 |
76 TraceWrapperMember<SVGSVGElement> m_contextElement; | 59 Member<SVGSVGElement> m_contextElement; |
77 Member<SVGAnimatedTransformList> m_transform; | 60 Member<SVGAnimatedTransformList> m_transform; |
78 String m_viewTargetString; | 61 String m_viewTargetString; |
79 }; | 62 }; |
80 | 63 |
81 template <typename T> | 64 template <typename T> |
82 void SVGViewSpec::inheritViewAttributesFromElement(T* inheritFromElement) { | 65 void SVGViewSpec::inheritViewAttributesFromElement(T* inheritFromElement) { |
83 if (!inheritFromElement->hasEmptyViewBox()) | 66 if (!inheritFromElement->hasEmptyViewBox()) |
84 viewBox()->baseValue()->setValue( | 67 viewBox()->baseValue()->setValue( |
85 inheritFromElement->viewBox()->currentValue()->value()); | 68 inheritFromElement->viewBox()->currentValue()->value()); |
86 | 69 |
87 if (inheritFromElement->preserveAspectRatio()->isSpecified()) { | 70 if (inheritFromElement->preserveAspectRatio()->isSpecified()) { |
88 preserveAspectRatio()->baseValue()->setAlign( | 71 preserveAspectRatio()->baseValue()->setAlign( |
89 inheritFromElement->preserveAspectRatio()->currentValue()->align()); | 72 inheritFromElement->preserveAspectRatio()->currentValue()->align()); |
90 preserveAspectRatio()->baseValue()->setMeetOrSlice( | 73 preserveAspectRatio()->baseValue()->setMeetOrSlice( |
91 inheritFromElement->preserveAspectRatio() | 74 inheritFromElement->preserveAspectRatio() |
92 ->currentValue() | 75 ->currentValue() |
93 ->meetOrSlice()); | 76 ->meetOrSlice()); |
94 } | 77 } |
95 | 78 |
96 if (inheritFromElement->hasAttribute(SVGNames::zoomAndPanAttr)) | 79 if (inheritFromElement->hasAttribute(SVGNames::zoomAndPanAttr)) |
97 setZoomAndPan(inheritFromElement->zoomAndPan()); | 80 setZoomAndPan(inheritFromElement->zoomAndPan()); |
98 } | 81 } |
99 | 82 |
100 } // namespace blink | 83 } // namespace blink |
101 | 84 |
102 #endif // SVGViewSpec_h | 85 #endif // SVGViewSpec_h |
OLD | NEW |