OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> | |
4 * | 3 * |
5 * This library is free software; you can redistribute it and/or | 4 * Redistribution and use in source and binary forms, with or without |
6 * modify it under the terms of the GNU Library General Public | 5 * modification, are permitted provided that the following conditions are |
7 * License as published by the Free Software Foundation; either | 6 * met: |
8 * version 2 of the License, or (at your option) any later version. | |
9 * | 7 * |
10 * This library is distributed in the hope that it will be useful, | 8 * * Redistributions of source code must retain the above copyright |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 * notice, this list of conditions and the following disclaimer. |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 10 * * Redistributions in binary form must reproduce the above |
13 * Library General Public License for more details. | 11 * copyright notice, this list of conditions and the following disclaimer |
| 12 * in the documentation and/or other materials provided with the |
| 13 * distribution. |
| 14 * * Neither the name of Google Inc. nor the names of its |
| 15 * contributors may be used to endorse or promote products derived from |
| 16 * this software without specific prior written permission. |
14 * | 17 * |
15 * You should have received a copy of the GNU Library General Public License | 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
16 * along with this library; see the file COPYING.LIB. If not, write to | 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
18 * Boston, MA 02110-1301, USA. | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
19 */ | 29 */ |
20 | 30 |
21 #ifndef SVGLengthList_h | 31 #ifndef SVGLengthList_h |
22 #define SVGLengthList_h | 32 #define SVGLengthList_h |
23 | 33 |
| 34 #include "bindings/v8/ScriptWrappable.h" |
24 #include "core/svg/SVGLength.h" | 35 #include "core/svg/SVGLength.h" |
25 #include "wtf/Vector.h" | 36 #include "core/svg/properties/NewSVGListPropertyHelper.h" |
| 37 #include "core/svg/properties/NewSVGListPropertyTearOffHelper.h" |
26 | 38 |
27 namespace WebCore { | 39 namespace WebCore { |
28 | 40 |
29 class SVGLengthList : public Vector<SVGLength> { | 41 class SVGLengthListTearOff; |
| 42 |
| 43 class SVGLengthList : public NewSVGListPropertyHelper<SVGLengthList, SVGLength>
{ |
30 public: | 44 public: |
31 SVGLengthList() { } | 45 typedef SVGLengthListTearOff TearOffType; |
32 | 46 |
33 void parse(const String& value, SVGLengthMode); | 47 static PassRefPtr<SVGLengthList> create(SVGLengthMode mode = LengthModeOther
) |
34 String valueAsString() const; | 48 { |
| 49 return adoptRef(new SVGLengthList(mode)); |
| 50 } |
| 51 |
| 52 ~SVGLengthList(); |
| 53 |
| 54 PassRefPtr<SVGLengthList> clone() const; |
| 55 |
| 56 void setValueAsString(const String&, ExceptionState&); |
| 57 |
| 58 // NewSVGPropertyBase: |
| 59 virtual PassRefPtr<NewSVGPropertyBase> cloneForAnimation(const String&) cons
t; |
| 60 virtual String valueAsString() const; |
| 61 |
| 62 virtual void add(PassRefPtr<NewSVGPropertyBase>, SVGElement*); |
| 63 virtual void calculateAnimatedValue(SVGAnimationElement*, float percentage,
unsigned repeatCount, PassRefPtr<NewSVGPropertyBase> fromValue, PassRefPtr<NewSV
GPropertyBase> toValue, PassRefPtr<NewSVGPropertyBase> toAtEndOfDurationValue, S
VGElement*); |
| 64 virtual float calculateDistance(PassRefPtr<NewSVGPropertyBase> to, SVGElemen
t*); |
35 | 65 |
36 private: | 66 private: |
37 template<typename CharType> | 67 SVGLengthList(SVGLengthMode); |
38 void parseInternal(const CharType*& ptr, const CharType* end, SVGLengthMode)
; | 68 |
| 69 bool adjustFromToListValues(const SVGLengthList* fromList, const SVGLengthLi
st* toList, float percentage, bool isToAnimation, bool resizeAnimatedListIfNeede
d); |
| 70 |
| 71 template <typename CharType> |
| 72 void parseInternal(const CharType*& ptr, const CharType* end, ExceptionState
&); |
| 73 |
| 74 SVGLengthMode m_mode; |
39 }; | 75 }; |
40 | 76 |
41 template<> | 77 class SVGLengthListTearOff : |
42 struct SVGPropertyTraits<SVGLengthList> { | 78 public NewSVGListPropertyTearOffHelper<SVGLengthListTearOff, SVGLengthList>, |
43 typedef SVGLength ListItemType; | 79 public ScriptWrappable { |
| 80 public: |
| 81 static PassRefPtr<SVGLengthListTearOff> create(PassRefPtr<SVGLengthList> tar
get, SVGElement* contextElement, PropertyIsAnimValType propertyIsAnimVal, const
QualifiedName& attributeName = nullQName()) |
| 82 { |
| 83 return adoptRef(new SVGLengthListTearOff(target, contextElement, propert
yIsAnimVal, attributeName)); |
| 84 } |
44 | 85 |
45 static SVGLengthList initialValue() { return SVGLengthList(); } | 86 static const char* propertyTypeName() { return "SVGLengthList"; } |
46 static String toString(const SVGLengthList& type) { return type.valueAsStrin
g(); } | 87 |
| 88 static SVGLengthListTearOff* upcastFrom(NewSVGPropertyTearOffBase* base) |
| 89 { |
| 90 // FIXME: add type checking |
| 91 return static_cast<SVGLengthListTearOff*>(base); |
| 92 } |
| 93 |
| 94 private: |
| 95 SVGLengthListTearOff(PassRefPtr<SVGLengthList> target, SVGElement* contextEl
ement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedName& attributeNa
me = nullQName()) |
| 96 : NewSVGListPropertyTearOffHelper<SVGLengthListTearOff, SVGLengthList>(t
arget, contextElement, propertyIsAnimVal, attributeName) |
| 97 { |
| 98 ScriptWrappable::init(this); |
| 99 } |
47 }; | 100 }; |
48 | 101 |
49 } // namespace WebCore | 102 } // namespace WebCore |
50 | 103 |
51 #endif | 104 #endif // SVGLengthList_h |
OLD | NEW |