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 * Copyright (C) 2014 Samsung Electronics. All rights reserved. |
4 * | 5 * |
5 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
9 * | 10 * |
10 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 14 * Library General Public License for more details. |
14 * | 15 * |
15 * You should have received a copy of the GNU Library General Public License | 16 * 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 | 17 * along with this library; see the file COPYING.LIB. If not, write to |
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
19 */ | 20 */ |
20 | 21 |
21 #ifndef SVGZoomAndPan_h | 22 #ifndef SVGZoomAndPan_h |
22 #define SVGZoomAndPan_h | 23 #define SVGZoomAndPan_h |
23 | 24 |
24 #include "SVGNames.h" | 25 #include "SVGNames.h" |
25 #include "core/dom/QualifiedName.h" | 26 #include "core/dom/QualifiedName.h" |
26 #include "wtf/HashSet.h" | 27 #include "wtf/HashSet.h" |
27 | 28 |
28 namespace WebCore { | 29 namespace WebCore { |
29 | 30 |
| 31 class ExceptionState; |
| 32 class SVGViewSpec; |
| 33 |
30 enum SVGZoomAndPanType { | 34 enum SVGZoomAndPanType { |
31 SVGZoomAndPanUnknown = 0, | 35 SVGZoomAndPanUnknown = 0, |
32 SVGZoomAndPanDisable, | 36 SVGZoomAndPanDisable, |
33 SVGZoomAndPanMagnify | 37 SVGZoomAndPanMagnify |
34 }; | 38 }; |
35 | 39 |
36 class SVGZoomAndPan { | 40 class SVGZoomAndPan { |
37 public: | 41 public: |
38 // Forward declare enumerations in the W3C naming scheme, for IDL generation
. | 42 // Forward declare enumerations in the W3C naming scheme, for IDL generation
. |
39 enum { | 43 enum { |
40 SVG_ZOOMANDPAN_UNKNOWN = SVGZoomAndPanUnknown, | 44 SVG_ZOOMANDPAN_UNKNOWN = SVGZoomAndPanUnknown, |
41 SVG_ZOOMANDPAN_DISABLE = SVGZoomAndPanDisable, | 45 SVG_ZOOMANDPAN_DISABLE = SVGZoomAndPanDisable, |
42 SVG_ZOOMANDPAN_MAGNIFY = SVGZoomAndPanMagnify | 46 SVG_ZOOMANDPAN_MAGNIFY = SVGZoomAndPanMagnify |
43 }; | 47 }; |
44 | 48 |
45 static bool isKnownAttribute(const QualifiedName&); | 49 static bool isKnownAttribute(const QualifiedName&); |
46 static void addSupportedAttributes(HashSet<QualifiedName>&); | 50 static void addSupportedAttributes(HashSet<QualifiedName>&); |
47 | 51 |
48 static SVGZoomAndPanType parseFromNumber(unsigned short number) | 52 static SVGZoomAndPanType parseFromNumber(unsigned short number) |
49 { | 53 { |
50 if (!number || number > SVGZoomAndPanMagnify) | 54 if (!number || number > SVGZoomAndPanMagnify) |
51 return SVGZoomAndPanUnknown; | 55 return SVGZoomAndPanUnknown; |
52 return static_cast<SVGZoomAndPanType>(number); | 56 return static_cast<SVGZoomAndPanType>(number); |
53 } | 57 } |
54 | 58 |
55 static bool parseZoomAndPan(const LChar*& start, const LChar* end, SVGZoomAn
dPanType&); | 59 bool parseZoomAndPan(const LChar*& start, const LChar* end); |
56 static bool parseZoomAndPan(const UChar*& start, const UChar* end, SVGZoomAn
dPanType&); | 60 bool parseZoomAndPan(const UChar*& start, const UChar* end); |
57 | 61 |
58 template<class SVGElementTarget> | 62 bool parseAttribute(const QualifiedName& name, const AtomicString& value) |
59 static bool parseAttribute(SVGElementTarget* target, const QualifiedName& na
me, const AtomicString& value) | |
60 { | 63 { |
61 ASSERT(target); | |
62 if (name == SVGNames::zoomAndPanAttr) { | 64 if (name == SVGNames::zoomAndPanAttr) { |
63 SVGZoomAndPanType zoomAndPan = SVGZoomAndPanUnknown; | 65 m_zoomAndPan = SVGZoomAndPanUnknown; |
64 if (!value.isEmpty()) { | 66 if (!value.isEmpty()) { |
65 if (value.is8Bit()) { | 67 if (value.is8Bit()) { |
66 const LChar* start = value.characters8(); | 68 const LChar* start = value.characters8(); |
67 parseZoomAndPan(start, start + value.length(), zoomAndPan); | 69 parseZoomAndPan(start, start + value.length()); |
68 } else { | 70 } else { |
69 const UChar* start = value.characters16(); | 71 const UChar* start = value.characters16(); |
70 parseZoomAndPan(start, start + value.length(), zoomAndPan); | 72 parseZoomAndPan(start, start + value.length()); |
71 } | 73 } |
72 } | 74 } |
73 target->setZoomAndPan(zoomAndPan); | |
74 return true; | 75 return true; |
75 } | 76 } |
76 | 77 |
77 return false; | 78 return false; |
78 } | 79 } |
79 | 80 |
80 SVGZoomAndPanType zoomAndPan() const { return SVGZoomAndPanUnknown; } | 81 // SVGZoomAndPan JS API. |
| 82 static SVGZoomAndPanType zoomAndPan(SVGZoomAndPan* object) { return object->
m_zoomAndPan; } |
| 83 static void setZoomAndPan(SVGZoomAndPan* object, unsigned short value, Excep
tionState&) { object->setZoomAndPan(value); } |
| 84 static void setZoomAndPan(SVGViewSpec*, unsigned short, ExceptionState&); |
81 | 85 |
82 // These methods only exist to allow us to compile V8/JSSVGZoomAndPan.*. | 86 void setZoomAndPan(unsigned short value) { m_zoomAndPan = parseFromNumber(va
lue); } |
83 // These are never called, and thus ASSERT_NOT_REACHED. | 87 SVGZoomAndPanType zoomAndPan() const { return m_zoomAndPan; } |
84 void ref(); | 88 |
85 void deref(); | 89 protected: |
86 void setZoomAndPan(unsigned short); | 90 SVGZoomAndPan(); |
| 91 void resetZoomAndPan(); |
| 92 |
| 93 private: |
| 94 SVGZoomAndPanType m_zoomAndPan; |
87 }; | 95 }; |
88 | 96 |
89 } // namespace WebCore | 97 } // namespace WebCore |
90 | 98 |
91 #endif // SVGZoomAndPan_h | 99 #endif // SVGZoomAndPan_h |
OLD | NEW |