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 |
(...skipping 10 matching lines...) Expand all Loading... |
21 #define SVGViewSpec_h | 21 #define SVGViewSpec_h |
22 | 22 |
23 #include "core/svg/SVGZoomAndPan.h" | 23 #include "core/svg/SVGZoomAndPan.h" |
24 #include "platform/heap/Handle.h" | 24 #include "platform/heap/Handle.h" |
25 | 25 |
26 namespace blink { | 26 namespace blink { |
27 | 27 |
28 class FloatRect; | 28 class FloatRect; |
29 class SVGPreserveAspectRatio; | 29 class SVGPreserveAspectRatio; |
30 class SVGRect; | 30 class SVGRect; |
| 31 class SVGSVGElement; |
31 class SVGTransformList; | 32 class SVGTransformList; |
32 | 33 |
33 class SVGViewSpec final : public GarbageCollectedFinalized<SVGViewSpec>, | 34 class SVGViewSpec final : public GarbageCollectedFinalized<SVGViewSpec>, |
34 public SVGZoomAndPan { | 35 public SVGZoomAndPan { |
35 public: | 36 public: |
36 static SVGViewSpec* create() { return new SVGViewSpec(); } | 37 static SVGViewSpec* createForElement(SVGSVGElement&); |
37 | 38 |
38 bool parseViewSpec(const String&); | 39 bool parseViewSpec(const String&); |
39 void reset(); | 40 void reset(); |
40 template <typename T> | 41 template <typename T> |
41 void inheritViewAttributesFromElement(T*); | 42 void inheritViewAttributesFromElement(T&); |
42 | 43 |
43 SVGRect* viewBox() { return m_viewBox; } | 44 SVGRect* viewBox() { return m_viewBox; } |
44 SVGPreserveAspectRatio* preserveAspectRatio() { | 45 SVGPreserveAspectRatio* preserveAspectRatio() { |
45 return m_preserveAspectRatio; | 46 return m_preserveAspectRatio; |
46 } | 47 } |
47 SVGTransformList* transform() { return m_transform; } | 48 SVGTransformList* transform() { return m_transform; } |
48 | 49 |
49 DECLARE_VIRTUAL_TRACE(); | 50 DECLARE_VIRTUAL_TRACE(); |
50 | 51 |
51 private: | 52 private: |
52 SVGViewSpec(); | 53 SVGViewSpec(); |
53 | 54 |
54 template <typename CharType> | 55 template <typename CharType> |
55 bool parseViewSpecInternal(const CharType* ptr, const CharType* end); | 56 bool parseViewSpecInternal(const CharType* ptr, const CharType* end); |
56 | 57 |
57 void setViewBox(const FloatRect&); | 58 void setViewBox(const FloatRect&); |
58 void setPreserveAspectRatio(const SVGPreserveAspectRatio&); | 59 void setPreserveAspectRatio(const SVGPreserveAspectRatio&); |
59 | 60 |
60 Member<SVGRect> m_viewBox; | 61 Member<SVGRect> m_viewBox; |
61 Member<SVGPreserveAspectRatio> m_preserveAspectRatio; | 62 Member<SVGPreserveAspectRatio> m_preserveAspectRatio; |
62 Member<SVGTransformList> m_transform; | 63 Member<SVGTransformList> m_transform; |
63 }; | 64 }; |
64 | 65 |
65 template <typename T> | 66 template <typename T> |
66 void SVGViewSpec::inheritViewAttributesFromElement(T* inheritFromElement) { | 67 void SVGViewSpec::inheritViewAttributesFromElement(T& inheritFromElement) { |
67 if (!inheritFromElement->hasEmptyViewBox()) | 68 if (!inheritFromElement.hasEmptyViewBox()) |
68 setViewBox(inheritFromElement->viewBox()->currentValue()->value()); | 69 setViewBox(inheritFromElement.viewBox()->currentValue()->value()); |
69 | 70 |
70 if (inheritFromElement->preserveAspectRatio()->isSpecified()) { | 71 if (inheritFromElement.preserveAspectRatio()->isSpecified()) { |
71 setPreserveAspectRatio( | 72 setPreserveAspectRatio( |
72 *inheritFromElement->preserveAspectRatio()->currentValue()); | 73 *inheritFromElement.preserveAspectRatio()->currentValue()); |
73 } | 74 } |
74 | 75 |
75 if (inheritFromElement->hasAttribute(SVGNames::zoomAndPanAttr)) | 76 if (inheritFromElement.hasAttribute(SVGNames::zoomAndPanAttr)) |
76 setZoomAndPan(inheritFromElement->zoomAndPan()); | 77 setZoomAndPan(inheritFromElement.zoomAndPan()); |
77 } | 78 } |
78 | 79 |
79 } // namespace blink | 80 } // namespace blink |
80 | 81 |
81 #endif // SVGViewSpec_h | 82 #endif // SVGViewSpec_h |
OLD | NEW |