OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
19 */ | 19 */ |
20 | 20 |
21 #ifndef SVGPreserveAspectRatio_h | 21 #ifndef SVGPreserveAspectRatio_h |
22 #define SVGPreserveAspectRatio_h | 22 #define SVGPreserveAspectRatio_h |
23 | 23 |
24 #include "core/svg/properties/NewSVGProperty.h" | 24 #include "core/svg/properties/SVGProperty.h" |
25 | 25 |
26 namespace WebCore { | 26 namespace WebCore { |
27 | 27 |
28 class AffineTransform; | 28 class AffineTransform; |
29 class FloatRect; | 29 class FloatRect; |
30 class SVGPreserveAspectRatioTearOff; | 30 class SVGPreserveAspectRatioTearOff; |
31 | 31 |
32 class SVGPreserveAspectRatio : public NewSVGPropertyBase { | 32 class SVGPreserveAspectRatio : public SVGPropertyBase { |
33 public: | 33 public: |
34 enum SVGPreserveAspectRatioType { | 34 enum SVGPreserveAspectRatioType { |
35 SVG_PRESERVEASPECTRATIO_UNKNOWN = 0, | 35 SVG_PRESERVEASPECTRATIO_UNKNOWN = 0, |
36 SVG_PRESERVEASPECTRATIO_NONE = 1, | 36 SVG_PRESERVEASPECTRATIO_NONE = 1, |
37 SVG_PRESERVEASPECTRATIO_XMINYMIN = 2, | 37 SVG_PRESERVEASPECTRATIO_XMINYMIN = 2, |
38 SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3, | 38 SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3, |
39 SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4, | 39 SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4, |
40 SVG_PRESERVEASPECTRATIO_XMINYMID = 5, | 40 SVG_PRESERVEASPECTRATIO_XMINYMID = 5, |
41 SVG_PRESERVEASPECTRATIO_XMIDYMID = 6, | 41 SVG_PRESERVEASPECTRATIO_XMIDYMID = 6, |
42 SVG_PRESERVEASPECTRATIO_XMAXYMID = 7, | 42 SVG_PRESERVEASPECTRATIO_XMAXYMID = 7, |
43 SVG_PRESERVEASPECTRATIO_XMINYMAX = 8, | 43 SVG_PRESERVEASPECTRATIO_XMINYMAX = 8, |
44 SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9, | 44 SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9, |
45 SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10 | 45 SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10 |
46 }; | 46 }; |
47 | 47 |
48 enum SVGMeetOrSliceType { | 48 enum SVGMeetOrSliceType { |
49 SVG_MEETORSLICE_UNKNOWN = 0, | 49 SVG_MEETORSLICE_UNKNOWN = 0, |
50 SVG_MEETORSLICE_MEET = 1, | 50 SVG_MEETORSLICE_MEET = 1, |
51 SVG_MEETORSLICE_SLICE = 2 | 51 SVG_MEETORSLICE_SLICE = 2 |
52 }; | 52 }; |
53 | 53 |
54 typedef SVGPreserveAspectRatioTearOff TearOffType; | 54 typedef SVGPreserveAspectRatioTearOff TearOffType; |
55 | 55 |
56 static PassRefPtr<SVGPreserveAspectRatio> create() | 56 static PassRefPtr<SVGPreserveAspectRatio> create() |
57 { | 57 { |
58 return adoptRef(new SVGPreserveAspectRatio()); | 58 return adoptRef(new SVGPreserveAspectRatio()); |
59 } | 59 } |
60 | 60 |
61 virtual PassRefPtr<SVGPreserveAspectRatio> clone() const; | 61 virtual PassRefPtr<SVGPreserveAspectRatio> clone() const; |
62 virtual PassRefPtr<NewSVGPropertyBase> cloneForAnimation(const String&) cons
t OVERRIDE; | 62 virtual PassRefPtr<SVGPropertyBase> cloneForAnimation(const String&) const O
VERRIDE; |
63 | 63 |
64 bool operator==(const SVGPreserveAspectRatio&) const; | 64 bool operator==(const SVGPreserveAspectRatio&) const; |
65 bool operator!=(const SVGPreserveAspectRatio& other) const { return !operato
r==(other); } | 65 bool operator!=(const SVGPreserveAspectRatio& other) const { return !operato
r==(other); } |
66 | 66 |
67 void setAlign(SVGPreserveAspectRatioType align) { m_align = align; } | 67 void setAlign(SVGPreserveAspectRatioType align) { m_align = align; } |
68 SVGPreserveAspectRatioType align() const { return m_align; } | 68 SVGPreserveAspectRatioType align() const { return m_align; } |
69 | 69 |
70 void setMeetOrSlice(SVGMeetOrSliceType meetOrSlice) { m_meetOrSlice = meetOr
Slice; } | 70 void setMeetOrSlice(SVGMeetOrSliceType meetOrSlice) { m_meetOrSlice = meetOr
Slice; } |
71 SVGMeetOrSliceType meetOrSlice() const { return m_meetOrSlice; } | 71 SVGMeetOrSliceType meetOrSlice() const { return m_meetOrSlice; } |
72 | 72 |
73 void transformRect(FloatRect& destRect, FloatRect& srcRect); | 73 void transformRect(FloatRect& destRect, FloatRect& srcRect); |
74 | 74 |
75 AffineTransform getCTM(float logicX, float logicY, | 75 AffineTransform getCTM(float logicX, float logicY, |
76 float logicWidth, float logicHeight, | 76 float logicWidth, float logicHeight, |
77 float physWidth, float physHeight) const; | 77 float physWidth, float physHeight) const; |
78 | 78 |
79 virtual String valueAsString() const OVERRIDE; | 79 virtual String valueAsString() const OVERRIDE; |
80 virtual void setValueAsString(const String&, ExceptionState&); | 80 virtual void setValueAsString(const String&, ExceptionState&); |
81 bool parse(const UChar*& ptr, const UChar* end, bool validate); | 81 bool parse(const UChar*& ptr, const UChar* end, bool validate); |
82 bool parse(const LChar*& ptr, const LChar* end, bool validate); | 82 bool parse(const LChar*& ptr, const LChar* end, bool validate); |
83 | 83 |
84 virtual void add(PassRefPtr<NewSVGPropertyBase>, SVGElement*) OVERRIDE; | 84 virtual void add(PassRefPtr<SVGPropertyBase>, SVGElement*) OVERRIDE; |
85 virtual void calculateAnimatedValue(SVGAnimationElement*, float percentage,
unsigned repeatCount, PassRefPtr<NewSVGPropertyBase> from, PassRefPtr<NewSVGProp
ertyBase> to, PassRefPtr<NewSVGPropertyBase> toAtEndOfDurationValue, SVGElement*
contextElement) OVERRIDE; | 85 virtual void calculateAnimatedValue(SVGAnimationElement*, float percentage,
unsigned repeatCount, PassRefPtr<SVGPropertyBase> from, PassRefPtr<SVGPropertyBa
se> to, PassRefPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextE
lement) OVERRIDE; |
86 virtual float calculateDistance(PassRefPtr<NewSVGPropertyBase> to, SVGElemen
t* contextElement) OVERRIDE; | 86 virtual float calculateDistance(PassRefPtr<SVGPropertyBase> to, SVGElement*
contextElement) OVERRIDE; |
87 | 87 |
88 static AnimatedPropertyType classType() { return AnimatedPreserveAspectRatio
; } | 88 static AnimatedPropertyType classType() { return AnimatedPreserveAspectRatio
; } |
89 | 89 |
90 private: | 90 private: |
91 SVGPreserveAspectRatio(); | 91 SVGPreserveAspectRatio(); |
92 | 92 |
93 void setDefault(); | 93 void setDefault(); |
94 template<typename CharType> | 94 template<typename CharType> |
95 bool parseInternal(const CharType*& ptr, const CharType* end, bool validate)
; | 95 bool parseInternal(const CharType*& ptr, const CharType* end, bool validate)
; |
96 | 96 |
97 SVGPreserveAspectRatioType m_align; | 97 SVGPreserveAspectRatioType m_align; |
98 SVGMeetOrSliceType m_meetOrSlice; | 98 SVGMeetOrSliceType m_meetOrSlice; |
99 }; | 99 }; |
100 | 100 |
101 inline PassRefPtr<SVGPreserveAspectRatio> toSVGPreserveAspectRatio(PassRefPtr<Ne
wSVGPropertyBase> passBase) | 101 inline PassRefPtr<SVGPreserveAspectRatio> toSVGPreserveAspectRatio(PassRefPtr<SV
GPropertyBase> passBase) |
102 { | 102 { |
103 RefPtr<NewSVGPropertyBase> base = passBase; | 103 RefPtr<SVGPropertyBase> base = passBase; |
104 ASSERT(base->type() == SVGPreserveAspectRatio::classType()); | 104 ASSERT(base->type() == SVGPreserveAspectRatio::classType()); |
105 return static_pointer_cast<SVGPreserveAspectRatio>(base.release()); | 105 return static_pointer_cast<SVGPreserveAspectRatio>(base.release()); |
106 } | 106 } |
107 | 107 |
108 } // namespace WebCore | 108 } // namespace WebCore |
109 | 109 |
110 #endif // SVGPreserveAspectRatio_h | 110 #endif // SVGPreserveAspectRatio_h |
OLD | NEW |