2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #ifndef SVGPathSegListPropertyTearOff_h
21 #define SVGPathSegListPropertyTearOff_h
24 #include "SVGAnimatedListPropertyTearOff.h"
25 #include "SVGPathSegList.h"
31 class SVGPathSegListPropertyTearOff : public SVGListProperty<SVGPathSegList> {
33 typedef SVGListProperty<SVGPathSegList> Base;
34 typedef SVGAnimatedListPropertyTearOff<SVGPathSegList> AnimatedListPropertyTearOff;
35 typedef SVGPropertyTraits<SVGPathSegList>::ListItemType ListItemType;
36 typedef PassRefPtr<SVGPathSeg> PassListItemType;
38 static PassRefPtr<SVGPathSegListPropertyTearOff> create(AnimatedListPropertyTearOff* animatedProperty, SVGPropertyRole role, SVGPathSegRole pathSegRole)
40 ASSERT(animatedProperty);
41 return adoptRef(new SVGPathSegListPropertyTearOff(animatedProperty, role, pathSegRole));
44 int removeItemFromList(const ListItemType& removeItem, bool shouldSynchronizeWrappers)
46 SVGPathSegList& values = m_animatedProperty->values();
48 unsigned size = values.size();
49 for (unsigned i = 0; i < size; ++i) {
50 ListItemType& item = values.at(i);
51 if (item != removeItem)
56 if (shouldSynchronizeWrappers)
66 void clear(ExceptionCode&);
68 unsigned numberOfItems() const
70 SVGPathSegList& values = m_animatedProperty->values();
71 return Base::numberOfItemsValues(values);
74 PassListItemType initialize(PassListItemType passNewItem, ExceptionCode& ec)
76 // Not specified, but FF/Opera do it this way, and it's just sane.
78 ec = SVGException::SVG_WRONG_TYPE_ERR;
82 ListItemType newItem = passNewItem;
83 SVGPathSegList& values = m_animatedProperty->values();
84 return Base::initializeValues(values, newItem, ec);
87 PassListItemType getItem(unsigned index, ExceptionCode&);
89 PassListItemType insertItemBefore(PassListItemType passNewItem, unsigned index, ExceptionCode& ec)
91 // Not specified, but FF/Opera do it this way, and it's just sane.
93 ec = SVGException::SVG_WRONG_TYPE_ERR;
97 ListItemType newItem = passNewItem;
98 SVGPathSegList& values = m_animatedProperty->values();
99 return Base::insertItemBeforeValues(values, newItem, index, ec);
102 PassListItemType replaceItem(PassListItemType passNewItem, unsigned index, ExceptionCode& ec)
104 // Not specified, but FF/Opera do it this way, and it's just sane.
106 ec = SVGException::SVG_WRONG_TYPE_ERR;
110 ListItemType newItem = passNewItem;
111 SVGPathSegList& values = m_animatedProperty->values();
112 return Base::replaceItemValues(values, newItem, index, ec);
115 PassListItemType removeItem(unsigned index, ExceptionCode&);
117 PassListItemType appendItem(PassListItemType passNewItem, ExceptionCode& ec)
119 // Not specified, but FF/Opera do it this way, and it's just sane.
121 ec = SVGException::SVG_WRONG_TYPE_ERR;
125 ListItemType newItem = passNewItem;
126 SVGPathSegList& values = m_animatedProperty->values();
127 return Base::appendItemValues(values, newItem, ec);
131 SVGPathSegListPropertyTearOff(AnimatedListPropertyTearOff* animatedProperty, SVGPropertyRole role, SVGPathSegRole pathSegRole)
132 : SVGListProperty<SVGPathSegList>(role)
133 , m_animatedProperty(animatedProperty)
134 , m_pathSegRole(pathSegRole)
138 SVGPathElement* contextElement() const;
140 virtual void commitChange()
142 SVGPathSegList& values = m_animatedProperty->values();
143 values.commitChange(m_animatedProperty->contextElement());
146 virtual void processIncomingListItemValue(const ListItemType& newItem, unsigned* indexToModify);
147 virtual void processIncomingListItemWrapper(RefPtr<ListItemTearOff>&, unsigned*)
149 ASSERT_NOT_REACHED();
153 RefPtr<AnimatedListPropertyTearOff> m_animatedProperty;
154 SVGPathSegRole m_pathSegRole;
159 #endif // ENABLE(SVG)
160 #endif // SVGListPropertyTearOff_h