15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/* 209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * Copyright (C) 2014 Google Inc. All rights reserved. 35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without 509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * modification, are permitted provided that the following conditions are 609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * met: 75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * * Redistributions of source code must retain the above copyright 909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * notice, this list of conditions and the following disclaimer. 1009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * * Redistributions in binary form must reproduce the above 1109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer 1209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * in the documentation and/or other materials provided with the 1309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * distribution. 1409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * * Neither the name of Google Inc. nor the names of its 1509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * contributors may be used to endorse or promote products derived from 1609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * this software without specific prior written permission. 175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 1809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */ 305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef SVGStringList_h 325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define SVGStringList_h 335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "bindings/v8/ScriptWrappable.h" 3509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "core/svg/SVGString.h" 3607a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch#include "core/svg/properties/SVGListPropertyHelper.h" 375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)namespace WebCore { 395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)class SVGStringListTearOff; 415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// Implementation of SVGStringList spec: 4309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// http://www.w3.org/TR/SVG/single-page.html#types-InterfaceSVGStringList 4409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// See SVGStringListTearOff for actual Javascript interface. 4509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// Unlike other SVG*List implementations, SVGStringList is NOT tied to SVGString. 4609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// SVGStringList operates directly on DOMString. 4709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// 4809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// In short: 4909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// SVGStringList has_a Vector<String>. 5009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// SVGStringList items are exposed to Javascript as DOMString (not SVGString) as in the spec. 5109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// SVGString is used only for boxing values for non-list string property SVGAnimatedString, 5209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)// and not used for SVGStringList. 5307a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochclass SVGStringList FINAL : public SVGPropertyBase { 545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)public: 5509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) typedef SVGStringListTearOff TearOffType; 5609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 5709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) static PassRefPtr<SVGStringList> create() 585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) { 5909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) return adoptRef(new SVGStringList()); 605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 6209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual ~SVGStringList(); 6309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 6409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) const Vector<String>& values() const { return m_values; } 6509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 6609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) // SVGStringList DOM Spec implementation. These are only to be called from SVGStringListTearOff: 67d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) unsigned long length() { return m_values.size(); } 6809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) void clear() { m_values.clear(); } 6909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) void initialize(const String&); 7009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) String getItem(size_t, ExceptionState&); 7109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) void insertItemBefore(const String&, size_t); 7209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) String removeItem(size_t, ExceptionState&); 7309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) void appendItem(const String&); 7409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) void replaceItem(const String&, size_t, ExceptionState&); 755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 7607a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch // SVGPropertyBase: 7709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) PassRefPtr<SVGStringList> clone(); 7809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) void setValueAsString(const String&, ExceptionState&); 7907a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch virtual PassRefPtr<SVGPropertyBase> cloneForAnimation(const String&) const OVERRIDE; 8009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual String valueAsString() const OVERRIDE; 815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 82d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) virtual void add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) OVERRIDE; 8307a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch virtual void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase> fromValue, PassRefPtr<SVGPropertyBase> toValue, PassRefPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement*) OVERRIDE; 8407a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch virtual float calculateDistance(PassRefPtr<SVGPropertyBase> to, SVGElement*) OVERRIDE; 8509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) 8609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) static AnimatedPropertyType classType() { return AnimatedStringList; } 875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)private: 8909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) SVGStringList(); 90591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch 9109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) template <typename CharType> 9209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) void parseInternal(const CharType*& ptr, const CharType* end); 9309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) bool checkIndexBound(size_t, ExceptionState&); 945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 9509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) Vector<String> m_values; 965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}; 975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} // namespace WebCore 995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 10009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#endif // SVGStringList_h 101