Chromium Code Reviews| OLD | NEW |
|---|---|
| 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. | |
|
haraken
2014/01/29 05:18:00
Would you elaborate on the relationship between SV
kouhei (in TOK)
2014/01/30 08:18:56
Done.
| |
| 47 class SVGStringList FINAL : public NewSVGPropertyBase { | |
| 33 public: | 48 public: |
| 34 SVGStringList(const QualifiedName& attributeName) | 49 typedef SVGStringListTearOff TearOffType; |
| 35 : m_attributeName(attributeName) | 50 |
| 51 static PassRefPtr<SVGStringList> create() | |
| 36 { | 52 { |
| 53 return adoptRef(new SVGStringList()); | |
| 37 } | 54 } |
| 38 | 55 |
| 39 void reset(const String&); | 56 virtual ~SVGStringList(); |
| 40 void parse(const String&, UChar delimiter = ','); | |
| 41 | 57 |
| 42 // Only used by SVGStringListPropertyTearOff. | 58 const Vector<String>& values() const { return m_values; } |
| 43 void commitChange(SVGElement* contextElement); | |
| 44 | 59 |
| 45 String valueAsString() const; | 60 // SVGStringList DOM Spec implementation. These are only to be called from S VGStringListTearOff: |
| 61 unsigned long numberOfItems() { return m_values.size(); } | |
| 62 void clear() { m_values.clear(); } | |
| 63 void initialize(const String&); | |
| 64 String getItem(size_t, ExceptionState&); | |
| 65 void insertItemBefore(const String&, size_t); | |
| 66 String removeItem(size_t, ExceptionState&); | |
| 67 void appendItem(const String&); | |
| 68 void replaceItem(const String&, size_t, ExceptionState&); | |
| 69 | |
| 70 // NewSVGPropertyBase: | |
| 71 PassRefPtr<SVGStringList> clone(); | |
| 72 void setValueAsString(const String&, ExceptionState&); | |
| 73 virtual PassRefPtr<NewSVGPropertyBase> cloneForAnimation(const String&) cons t OVERRIDE; | |
| 74 virtual String valueAsString() const OVERRIDE; | |
| 75 | |
| 76 virtual void add(PassRefPtr<NewSVGPropertyBase>, SVGElement*) OVERRIDE; | |
| 77 virtual void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtr<NewSVGPropertyBase> fromValue, PassRefPtr<NewSV GPropertyBase> toValue, PassRefPtr<NewSVGPropertyBase> toAtEndOfDurationValue, S VGElement*) OVERRIDE; | |
| 78 virtual float calculateDistance(PassRefPtr<NewSVGPropertyBase> to, SVGElemen t*) OVERRIDE; | |
| 79 | |
| 80 static AnimatedPropertyType classType() { return AnimatedStringList; } | |
| 46 | 81 |
| 47 private: | 82 private: |
| 48 template<typename CharType> | 83 SVGStringList(); |
| 49 void parseInternal(const CharType*& ptr, const CharType* end, UChar delimite r); | |
| 50 | 84 |
| 51 const QualifiedName& m_attributeName; | 85 template <typename CharType> |
| 52 }; | 86 void parseInternal(const CharType*& ptr, const CharType* end); |
| 87 bool checkIndexBound(size_t, ExceptionState&); | |
| 53 | 88 |
| 54 template<> | 89 Vector<String> m_values; |
| 55 struct SVGPropertyTraits<SVGStringList> { | |
| 56 typedef String ListItemType; | |
| 57 }; | 90 }; |
| 58 | 91 |
| 59 } // namespace WebCore | 92 } // namespace WebCore |
| 60 | 93 |
| 61 #endif | 94 #endif // SVGStringList_h |
| OLD | NEW |