Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(778)

Side by Side Diff: Source/core/svg/SVGStringList.h

Issue 148173018: [SVG] SVGAnimatedString{,List} migration to new SVG property impl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove debug print Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/svg/SVGString.cpp ('k') | Source/core/svg/SVGStringList.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2014 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 SVGStringList_h 31 #ifndef SVGStringList_h
22 #define SVGStringList_h 32 #define SVGStringList_h
23 33
24 #include "core/dom/QualifiedName.h" 34 #include "bindings/v8/ScriptWrappable.h"
25 #include "core/svg/properties/SVGPropertyTraits.h" 35 #include "core/svg/SVGString.h"
26 #include "wtf/Vector.h" 36 #include "core/svg/properties/NewSVGListPropertyHelper.h"
27 37
28 namespace WebCore { 38 namespace WebCore {
29 39
30 class SVGElement; 40 class SVGStringListTearOff;
31 41
32 class SVGStringList : public Vector<String> { 42 // Implementation of SVGStringList spec:
43 // http://www.w3.org/TR/SVG/single-page.html#types-InterfaceSVGStringList
44 // See SVGStringListTearOff for actual Javascript interface.
45 // Unlike other SVG*List implementations, SVGStringList is NOT tied to SVGString .
46 // SVGStringList operates directly on DOMString.
47 //
48 // In short:
49 // SVGStringList has_a Vector<String>.
50 // SVGStringList items are exposed to Javascript as DOMString (not SVGString) as in the spec.
51 // SVGString is used only for boxing values for non-list string property SVGAn imatedString,
52 // and not used for SVGStringList.
53 class SVGStringList FINAL : public NewSVGPropertyBase {
33 public: 54 public:
34 SVGStringList(const QualifiedName& attributeName) 55 typedef SVGStringListTearOff TearOffType;
35 : m_attributeName(attributeName) 56
57 static PassRefPtr<SVGStringList> create()
36 { 58 {
59 return adoptRef(new SVGStringList());
37 } 60 }
38 61
39 void reset(const String&); 62 virtual ~SVGStringList();
40 void parse(const String&, UChar delimiter = ',');
41 63
42 // Only used by SVGStringListPropertyTearOff. 64 const Vector<String>& values() const { return m_values; }
43 void commitChange(SVGElement* contextElement);
44 65
45 String valueAsString() const; 66 // SVGStringList DOM Spec implementation. These are only to be called from S VGStringListTearOff:
67 unsigned long numberOfItems() { return m_values.size(); }
68 void clear() { m_values.clear(); }
69 void initialize(const String&);
70 String getItem(size_t, ExceptionState&);
71 void insertItemBefore(const String&, size_t);
72 String removeItem(size_t, ExceptionState&);
73 void appendItem(const String&);
74 void replaceItem(const String&, size_t, ExceptionState&);
75
76 // NewSVGPropertyBase:
77 PassRefPtr<SVGStringList> clone();
78 void setValueAsString(const String&, ExceptionState&);
79 virtual PassRefPtr<NewSVGPropertyBase> cloneForAnimation(const String&) cons t OVERRIDE;
80 virtual String valueAsString() const OVERRIDE;
81
82 virtual void add(PassRefPtr<NewSVGPropertyBase>, SVGElement*) OVERRIDE;
83 virtual void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtr<NewSVGPropertyBase> fromValue, PassRefPtr<NewSV GPropertyBase> toValue, PassRefPtr<NewSVGPropertyBase> toAtEndOfDurationValue, S VGElement*) OVERRIDE;
84 virtual float calculateDistance(PassRefPtr<NewSVGPropertyBase> to, SVGElemen t*) OVERRIDE;
85
86 static AnimatedPropertyType classType() { return AnimatedStringList; }
46 87
47 private: 88 private:
48 template<typename CharType> 89 SVGStringList();
49 void parseInternal(const CharType*& ptr, const CharType* end, UChar delimite r);
50 90
51 const QualifiedName& m_attributeName; 91 template <typename CharType>
52 }; 92 void parseInternal(const CharType*& ptr, const CharType* end);
93 bool checkIndexBound(size_t, ExceptionState&);
53 94
54 template<> 95 Vector<String> m_values;
55 struct SVGPropertyTraits<SVGStringList> {
56 typedef String ListItemType;
57 }; 96 };
58 97
59 } // namespace WebCore 98 } // namespace WebCore
60 99
61 #endif 100 #endif // SVGStringList_h
OLDNEW
« no previous file with comments | « Source/core/svg/SVGString.cpp ('k') | Source/core/svg/SVGStringList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698