summaryrefslogtreecommitdiffstats
path: root/WebCore/svg/properties
diff options
context:
space:
mode:
authorShimeng (Simon) Wang <swang@google.com>2010-12-07 17:22:45 -0800
committerShimeng (Simon) Wang <swang@google.com>2010-12-22 14:15:40 -0800
commit4576aa36e9a9671459299c7963ac95aa94beaea9 (patch)
tree3863574e050f168c0126ecb47c83319fab0972d8 /WebCore/svg/properties
parent55323ac613cc31553107b68603cb627264d22bb0 (diff)
downloadexternal_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.zip
external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.tar.gz
external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.tar.bz2
Merge WebKit at r73109: Initial merge by git.
Change-Id: I61f1a66d9642e3d8405d3ac6ccab2a53421c75d8
Diffstat (limited to 'WebCore/svg/properties')
-rw-r--r--WebCore/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h72
-rw-r--r--WebCore/svg/properties/SVGAnimatedPropertyMacros.h61
-rw-r--r--WebCore/svg/properties/SVGListProperty.h30
-rw-r--r--WebCore/svg/properties/SVGPathSegListPropertyTearOff.cpp110
-rw-r--r--WebCore/svg/properties/SVGPathSegListPropertyTearOff.h160
-rw-r--r--WebCore/svg/properties/SVGProperty.h1
-rw-r--r--WebCore/svg/properties/SVGPropertyTearOff.h11
-rw-r--r--WebCore/svg/properties/SVGPropertyTraits.h81
-rw-r--r--WebCore/svg/properties/SVGStaticPropertyTearOff.h2
-rw-r--r--WebCore/svg/properties/SVGStaticPropertyWithParentTearOff.h2
-rw-r--r--WebCore/svg/properties/SVGTransformListPropertyTearOff.h5
11 files changed, 428 insertions, 107 deletions
diff --git a/WebCore/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h b/WebCore/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h
new file mode 100644
index 0000000..f515ab4
--- /dev/null
+++ b/WebCore/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGAnimatedPathSegListPropertyTearOff_h
+#define SVGAnimatedPathSegListPropertyTearOff_h
+
+#if ENABLE(SVG)
+#include "SVGAnimatedListPropertyTearOff.h"
+#include "SVGPathSegList.h"
+#include "SVGPathSegListPropertyTearOff.h"
+
+namespace WebCore {
+
+class SVGPathSegListPropertyTearOff;
+
+class SVGAnimatedPathSegListPropertyTearOff : public SVGAnimatedListPropertyTearOff<SVGPathSegList> {
+public:
+ SVGProperty* baseVal(SVGPathSegRole role)
+ {
+ if (!m_baseVal)
+ m_baseVal = SVGPathSegListPropertyTearOff::create(this, BaseValRole, role);
+ return m_baseVal.get();
+ }
+
+ SVGProperty* animVal(SVGPathSegRole role)
+ {
+ if (!m_animVal)
+ m_animVal = SVGPathSegListPropertyTearOff::create(this, AnimValRole, role);
+ return m_animVal.get();
+ }
+
+ int removeItemFromList(const RefPtr<SVGPathSeg>& segment, bool shouldSynchronizeWrappers)
+ {
+ // This should ever be called for our baseVal, as animVal can't modify the list.
+ return static_pointer_cast<SVGPathSegListPropertyTearOff>(m_baseVal)->removeItemFromList(segment, shouldSynchronizeWrappers);
+ }
+
+private:
+ friend class SVGAnimatedProperty;
+
+ static PassRefPtr<SVGAnimatedPathSegListPropertyTearOff> create(SVGElement* contextElement, const QualifiedName& attributeName, SVGPathSegList& values)
+ {
+ ASSERT(contextElement);
+ return adoptRef(new SVGAnimatedPathSegListPropertyTearOff(contextElement, attributeName, values));
+ }
+
+ SVGAnimatedPathSegListPropertyTearOff(SVGElement* contextElement, const QualifiedName& attributeName, SVGPathSegList& values)
+ : SVGAnimatedListPropertyTearOff<SVGPathSegList>(contextElement, attributeName, values)
+ {
+ }
+};
+
+}
+
+#endif // ENABLE(SVG)
+#endif // SVGAnimatedPathSegListPropertyTearOff_h
diff --git a/WebCore/svg/properties/SVGAnimatedPropertyMacros.h b/WebCore/svg/properties/SVGAnimatedPropertyMacros.h
index 870d26e..a24a25d 100644
--- a/WebCore/svg/properties/SVGAnimatedPropertyMacros.h
+++ b/WebCore/svg/properties/SVGAnimatedPropertyMacros.h
@@ -111,8 +111,6 @@ PropertyType& LowerProperty##BaseValue() const \
void set##UpperProperty##BaseValue(const PropertyType& type) \
{ \
m_##LowerProperty.value = type; \
- SVGElement* contextElement = GetOwnerElementForType<OwnerType, IsDerivedFromSVGElement<OwnerType>::value>::ownerElement(this); \
- contextElement->invalidateSVGAttributes(); \
} \
\
void synchronize##UpperProperty() \
@@ -145,31 +143,64 @@ DECLARE_ANIMATED_PROPERTY_NEW_SHARED(OwnerType, DOMAttribute, SVGDOMAttributeIde
#define DECLARE_ANIMATED_STATIC_PROPERTY_NEW(OwnerType, DOMAttribute, PropertyType, UpperProperty, LowerProperty) \
DECLARE_ANIMATED_PROPERTY_NEW_SHARED(OwnerType, DOMAttribute, DOMAttribute.localName(), SVGAnimatedStaticPropertyTearOff<PropertyType>, PropertyType, UpperProperty, LowerProperty)
-#define DECLARE_ANIMATED_LIST_PROPERTY_NEW(OwnerType, DOMAttribute, PropertyType, UpperProperty, LowerProperty) \
-DECLARE_ANIMATED_PROPERTY_NEW_SHARED(OwnerType, DOMAttribute, DOMAttribute.localName(), SVGAnimatedListPropertyTearOff<PropertyType>, PropertyType, UpperProperty, LowerProperty) \
+// FIXME: Remove all macros above, once these two below are deployed everywhere.
+
+#define DEFINE_ANIMATED_PROPERTY(OwnerType, DOMAttribute, SVGDOMAttributeIdentifier, TearOffType, PropertyType, UpperProperty, LowerProperty) \
+void OwnerType::synchronize##UpperProperty() \
+{ \
+ if (!m_##LowerProperty.shouldSynchronize) \
+ return; \
+ AtomicString value(SVGPropertyTraits<PropertyType>::toString(LowerProperty##BaseValue())); \
+ SVGElement* contextElement = GetOwnerElementForType<OwnerType, IsDerivedFromSVGElement<OwnerType>::value>::ownerElement(this); \
+ SVGAnimatedPropertySynchronizer<IsDerivedFromSVGElement<OwnerType>::value>::synchronize(contextElement, DOMAttribute, value); \
+} \
\
-void detachAnimated##UpperProperty##ListWrappers(unsigned newListSize) \
+PassRefPtr<TearOffType> OwnerType::LowerProperty##Animated() \
{ \
+ m_##LowerProperty.shouldSynchronize = true; \
SVGElement* contextElement = GetOwnerElementForType<OwnerType, IsDerivedFromSVGElement<OwnerType>::value>::ownerElement(this); \
- SVGAnimatedProperty* wrapper = SVGAnimatedProperty::lookupWrapper<SVGAnimatedListPropertyTearOff<PropertyType> >(contextElement, DOMAttribute.localName()); \
- if (!wrapper) \
- return; \
- static_cast<SVGAnimatedListPropertyTearOff<PropertyType>*>(wrapper)->detachListWrappers(newListSize); \
+ return SVGAnimatedProperty::lookupOrCreateWrapper<TearOffType, PropertyType>(contextElement, DOMAttribute, SVGDOMAttributeIdentifier, m_##LowerProperty.value); \
}
-#define DECLARE_ANIMATED_TRANSFORM_LIST_PROPERTY_NEW(OwnerType, DOMAttribute, PropertyType, UpperProperty, LowerProperty) \
-DECLARE_ANIMATED_PROPERTY_NEW_SHARED(OwnerType, DOMAttribute, DOMAttribute.localName(), SVGAnimatedTransformListPropertyTearOff, PropertyType, UpperProperty, LowerProperty) \
+#define DECLARE_ANIMATED_PROPERTY(TearOffType, PropertyType, UpperProperty, LowerProperty) \
+public: \
+PropertyType& LowerProperty() const \
+{ \
+ return m_##LowerProperty.value; \
+} \
\
-void detachAnimated##UpperProperty##ListWrappers(unsigned newListSize) \
+PropertyType& LowerProperty##BaseValue() const \
+{ \
+ return m_##LowerProperty.value; \
+} \
+\
+void set##UpperProperty##BaseValue(const PropertyType& type) \
+{ \
+ m_##LowerProperty.value = type; \
+} \
+\
+PassRefPtr<TearOffType> LowerProperty##Animated(); \
+\
+private: \
+ void synchronize##UpperProperty(); \
+\
+ mutable SVGSynchronizableAnimatedProperty<PropertyType> m_##LowerProperty;
+
+#define DECLARE_ANIMATED_LIST_PROPERTY(TearOffType, PropertyType, UpperProperty, LowerProperty) \
+DECLARE_ANIMATED_PROPERTY(TearOffType, PropertyType, UpperProperty, LowerProperty) \
+void detachAnimated##UpperProperty##ListWrappers(unsigned newListSize);
+
+#define DEFINE_ANIMATED_LIST_PROPERTY(OwnerType, DOMAttribute, SVGDOMAttributeIdentifier, TearOffType, PropertyType, UpperProperty, LowerProperty) \
+DEFINE_ANIMATED_PROPERTY(OwnerType, DOMAttribute, SVGDOMAttributeIdentifier, TearOffType, PropertyType, UpperProperty, LowerProperty) \
+void OwnerType::detachAnimated##UpperProperty##ListWrappers(unsigned newListSize) \
{ \
SVGElement* contextElement = GetOwnerElementForType<OwnerType, IsDerivedFromSVGElement<OwnerType>::value>::ownerElement(this); \
- SVGAnimatedProperty* wrapper = SVGAnimatedProperty::lookupWrapper<SVGAnimatedTransformListPropertyTearOff>(contextElement, DOMAttribute.localName()); \
+ SVGAnimatedProperty* wrapper = SVGAnimatedProperty::lookupWrapper<TearOffType>(contextElement, DOMAttribute.localName()); \
if (!wrapper) \
return; \
- static_cast<SVGAnimatedTransformListPropertyTearOff*>(wrapper)->detachListWrappers(newListSize); \
+ static_cast<TearOffType*>(wrapper)->detachListWrappers(newListSize); \
}
-
}
#endif // ENABLE(SVG)
diff --git a/WebCore/svg/properties/SVGListProperty.h b/WebCore/svg/properties/SVGListProperty.h
index f143389..0985ddb 100644
--- a/WebCore/svg/properties/SVGListProperty.h
+++ b/WebCore/svg/properties/SVGListProperty.h
@@ -21,8 +21,8 @@
#define SVGListProperty_h
#if ENABLE(SVG)
-#include "ExceptionCode.h"
#include "SVGAnimatedProperty.h"
+#include "SVGException.h"
#include "SVGPropertyTearOff.h"
#include "SVGPropertyTraits.h"
@@ -110,7 +110,7 @@ public:
// Not specified, but FF/Opera do it this way, and it's just sane.
if (!passNewItem) {
- ec = TYPE_MISMATCH_ERR;
+ ec = SVGException::SVG_WRONG_TYPE_ERR;
return 0;
}
@@ -207,7 +207,7 @@ public:
// Not specified, but FF/Opera do it this way, and it's just sane.
if (!passNewItem) {
- ec = TYPE_MISMATCH_ERR;
+ ec = SVGException::SVG_WRONG_TYPE_ERR;
return 0;
}
@@ -258,6 +258,12 @@ public:
// Spec: If the item is already in this list, note that the index of the item to replace is before the removal of the item.
processIncomingListItemValue(newItem, &index);
+ if (values.isEmpty()) {
+ // 'newItem' already lived in our list, we removed it, and now we're empty, which means there's nothing to replace.
+ ec = INDEX_SIZE_ERR;
+ return ListItemType();
+ }
+
// Update the value at the desired position 'index'.
values.at(index) = newItem;
@@ -274,7 +280,7 @@ public:
// Not specified, but FF/Opera do it this way, and it's just sane.
if (!passNewItem) {
- ec = TYPE_MISMATCH_ERR;
+ ec = SVGException::SVG_WRONG_TYPE_ERR;
return 0;
}
@@ -286,6 +292,13 @@ public:
// Spec: If the item is already in this list, note that the index of the item to replace is before the removal of the item.
processIncomingListItemWrapper(newItem, &index);
+ if (values.isEmpty()) {
+ ASSERT(wrappers.isEmpty());
+ // 'passNewItem' already lived in our list, we removed it, and now we're empty, which means there's nothing to replace.
+ ec = INDEX_SIZE_ERR;
+ return 0;
+ }
+
// Detach the existing wrapper.
RefPtr<ListItemTearOff> oldItem = wrappers.at(index);
if (oldItem)
@@ -337,9 +350,10 @@ public:
// Detach the existing wrapper.
RefPtr<ListItemTearOff> oldItem = wrappers.at(index);
- if (oldItem)
- oldItem->detachWrapper();
+ if (!oldItem)
+ oldItem = ListItemTearOff::create(animatedList, UndefinedRole, values.at(index));
+ oldItem->detachWrapper();
wrappers.remove(index);
values.remove(index);
@@ -371,7 +385,7 @@ public:
// Not specified, but FF/Opera do it this way, and it's just sane.
if (!passNewItem) {
- ec = TYPE_MISMATCH_ERR;
+ ec = SVGException::SVG_WRONG_TYPE_ERR;
return 0;
}
@@ -392,6 +406,8 @@ public:
return newItem.release();
}
+ virtual SVGPropertyRole role() const { return m_role; }
+
protected:
SVGListProperty(SVGPropertyRole role)
: m_role(role)
diff --git a/WebCore/svg/properties/SVGPathSegListPropertyTearOff.cpp b/WebCore/svg/properties/SVGPathSegListPropertyTearOff.cpp
new file mode 100644
index 0000000..af1b30c
--- /dev/null
+++ b/WebCore/svg/properties/SVGPathSegListPropertyTearOff.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGPathSegListPropertyTearOff.h"
+
+#include "SVGAnimatedPathSegListPropertyTearOff.h"
+#include "SVGPathElement.h"
+#include "SVGPathSegWithContext.h"
+
+namespace WebCore {
+
+void SVGPathSegListPropertyTearOff::clear(ExceptionCode& ec)
+{
+ SVGPathSegList& values = m_animatedProperty->values();
+ if (values.isEmpty())
+ return;
+
+ unsigned size = values.size();
+ for (unsigned i = 0; i < size; ++i) {
+ ListItemType item = values.at(i);
+ static_cast<SVGPathSegWithContext*>(item.get())->setContextAndRole(0, PathSegUndefinedRole);
+ }
+
+ SVGPathSegListPropertyTearOff::Base::clearValues(values, ec);
+}
+
+SVGPathSegListPropertyTearOff::PassListItemType SVGPathSegListPropertyTearOff::getItem(unsigned index, ExceptionCode& ec)
+{
+ SVGPathSegList& values = m_animatedProperty->values();
+ ListItemType returnedItem = Base::getItemValues(values, index, ec);
+ if (returnedItem) {
+ ASSERT(static_cast<SVGPathSegWithContext*>(returnedItem.get())->contextElement() == contextElement());
+ ASSERT(static_cast<SVGPathSegWithContext*>(returnedItem.get())->role() == m_pathSegRole);
+ }
+ return returnedItem.release();
+}
+
+SVGPathSegListPropertyTearOff::PassListItemType SVGPathSegListPropertyTearOff::removeItem(unsigned index, ExceptionCode& ec)
+{
+ SVGPathSegList& values = m_animatedProperty->values();
+ SVGPathSegListPropertyTearOff::ListItemType removedItem = SVGPathSegListPropertyTearOff::Base::removeItemValues(values, index, ec);
+ if (removedItem)
+ static_cast<SVGPathSegWithContext*>(removedItem.get())->setContextAndRole(0, PathSegUndefinedRole);
+ return removedItem.release();
+}
+
+SVGPathElement* SVGPathSegListPropertyTearOff::contextElement() const
+{
+ SVGElement* contextElement = m_animatedProperty->contextElement();
+ ASSERT(contextElement);
+ ASSERT(contextElement->hasTagName(SVGNames::pathTag));
+ return static_cast<SVGPathElement*>(contextElement);
+}
+
+void SVGPathSegListPropertyTearOff::processIncomingListItemValue(const ListItemType& newItem, unsigned* indexToModify)
+{
+ SVGPathSegWithContext* newItemWithContext = static_cast<SVGPathSegWithContext*>(newItem.get());
+ SVGAnimatedProperty* animatedPropertyOfItem = newItemWithContext->animatedProperty();
+
+ // Alter the role, after calling animatedProperty(), as that may influence the returned animated property.
+ newItemWithContext->setContextAndRole(contextElement(), m_pathSegRole);
+
+ if (!animatedPropertyOfItem)
+ return;
+
+ // newItem belongs to a SVGPathElement, but its associated SVGAnimatedProperty is not an animated list tear off.
+ // (for example: "pathElement.pathSegList.appendItem(pathElement.createSVGPathSegClosepath())")
+ if (!animatedPropertyOfItem->isAnimatedListTearOff())
+ return;
+
+ // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list.
+ // 'newItem' is already living in another list. If it's not our list, synchronize the other lists wrappers after the removal.
+ bool livesInOtherList = animatedPropertyOfItem != m_animatedProperty;
+ int removedIndex = static_cast<SVGAnimatedPathSegListPropertyTearOff*>(animatedPropertyOfItem)->removeItemFromList(newItem.get(), livesInOtherList);
+ ASSERT(removedIndex != -1);
+
+ if (!indexToModify)
+ return;
+
+ // If the item lived in our list, adjust the insertion index.
+ if (!livesInOtherList) {
+ unsigned& index = *indexToModify;
+ // Spec: If the item is already in this list, note that the index of the item to (replace|insert before) is before the removal of the item.
+ if (static_cast<unsigned>(removedIndex) < index)
+ --index;
+ }
+}
+
+}
+
+#endif // ENABLE(SVG)
diff --git a/WebCore/svg/properties/SVGPathSegListPropertyTearOff.h b/WebCore/svg/properties/SVGPathSegListPropertyTearOff.h
new file mode 100644
index 0000000..94acda1
--- /dev/null
+++ b/WebCore/svg/properties/SVGPathSegListPropertyTearOff.h
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SVGPathSegListPropertyTearOff_h
+#define SVGPathSegListPropertyTearOff_h
+
+#if ENABLE(SVG)
+#include "SVGAnimatedListPropertyTearOff.h"
+#include "SVGPathSegList.h"
+
+namespace WebCore {
+
+class SVGPathElement;
+
+class SVGPathSegListPropertyTearOff : public SVGListProperty<SVGPathSegList> {
+public:
+ typedef SVGListProperty<SVGPathSegList> Base;
+ typedef SVGAnimatedListPropertyTearOff<SVGPathSegList> AnimatedListPropertyTearOff;
+ typedef SVGPropertyTraits<SVGPathSegList>::ListItemType ListItemType;
+ typedef PassRefPtr<SVGPathSeg> PassListItemType;
+
+ static PassRefPtr<SVGPathSegListPropertyTearOff> create(AnimatedListPropertyTearOff* animatedProperty, SVGPropertyRole role, SVGPathSegRole pathSegRole)
+ {
+ ASSERT(animatedProperty);
+ return adoptRef(new SVGPathSegListPropertyTearOff(animatedProperty, role, pathSegRole));
+ }
+
+ int removeItemFromList(const ListItemType& removeItem, bool shouldSynchronizeWrappers)
+ {
+ SVGPathSegList& values = m_animatedProperty->values();
+
+ unsigned size = values.size();
+ for (unsigned i = 0; i < size; ++i) {
+ ListItemType& item = values.at(i);
+ if (item != removeItem)
+ continue;
+
+ values.remove(i);
+
+ if (shouldSynchronizeWrappers)
+ commitChange();
+
+ return i;
+ }
+
+ return -1;
+ }
+
+ // SVGList API
+ void clear(ExceptionCode&);
+
+ unsigned numberOfItems() const
+ {
+ SVGPathSegList& values = m_animatedProperty->values();
+ return Base::numberOfItemsValues(values);
+ }
+
+ PassListItemType initialize(PassListItemType passNewItem, ExceptionCode& ec)
+ {
+ // Not specified, but FF/Opera do it this way, and it's just sane.
+ if (!passNewItem) {
+ ec = SVGException::SVG_WRONG_TYPE_ERR;
+ return 0;
+ }
+
+ ListItemType newItem = passNewItem;
+ SVGPathSegList& values = m_animatedProperty->values();
+ return Base::initializeValues(values, newItem, ec);
+ }
+
+ PassListItemType getItem(unsigned index, ExceptionCode&);
+
+ PassListItemType insertItemBefore(PassListItemType passNewItem, unsigned index, ExceptionCode& ec)
+ {
+ // Not specified, but FF/Opera do it this way, and it's just sane.
+ if (!passNewItem) {
+ ec = SVGException::SVG_WRONG_TYPE_ERR;
+ return 0;
+ }
+
+ ListItemType newItem = passNewItem;
+ SVGPathSegList& values = m_animatedProperty->values();
+ return Base::insertItemBeforeValues(values, newItem, index, ec);
+ }
+
+ PassListItemType replaceItem(PassListItemType passNewItem, unsigned index, ExceptionCode& ec)
+ {
+ // Not specified, but FF/Opera do it this way, and it's just sane.
+ if (!passNewItem) {
+ ec = SVGException::SVG_WRONG_TYPE_ERR;
+ return 0;
+ }
+
+ ListItemType newItem = passNewItem;
+ SVGPathSegList& values = m_animatedProperty->values();
+ return Base::replaceItemValues(values, newItem, index, ec);
+ }
+
+ PassListItemType removeItem(unsigned index, ExceptionCode&);
+
+ PassListItemType appendItem(PassListItemType passNewItem, ExceptionCode& ec)
+ {
+ // Not specified, but FF/Opera do it this way, and it's just sane.
+ if (!passNewItem) {
+ ec = SVGException::SVG_WRONG_TYPE_ERR;
+ return 0;
+ }
+
+ ListItemType newItem = passNewItem;
+ SVGPathSegList& values = m_animatedProperty->values();
+ return Base::appendItemValues(values, newItem, ec);
+ }
+
+private:
+ SVGPathSegListPropertyTearOff(AnimatedListPropertyTearOff* animatedProperty, SVGPropertyRole role, SVGPathSegRole pathSegRole)
+ : SVGListProperty<SVGPathSegList>(role)
+ , m_animatedProperty(animatedProperty)
+ , m_pathSegRole(pathSegRole)
+ {
+ }
+
+ SVGPathElement* contextElement() const;
+
+ virtual void commitChange()
+ {
+ SVGPathSegList& values = m_animatedProperty->values();
+ values.commitChange(m_animatedProperty->contextElement());
+ }
+
+ virtual void processIncomingListItemValue(const ListItemType& newItem, unsigned* indexToModify);
+ virtual void processIncomingListItemWrapper(RefPtr<ListItemTearOff>&, unsigned*)
+ {
+ ASSERT_NOT_REACHED();
+ }
+
+private:
+ RefPtr<AnimatedListPropertyTearOff> m_animatedProperty;
+ SVGPathSegRole m_pathSegRole;
+};
+
+}
+
+#endif // ENABLE(SVG)
+#endif // SVGListPropertyTearOff_h
diff --git a/WebCore/svg/properties/SVGProperty.h b/WebCore/svg/properties/SVGProperty.h
index 104fb0e..609e264 100644
--- a/WebCore/svg/properties/SVGProperty.h
+++ b/WebCore/svg/properties/SVGProperty.h
@@ -35,6 +35,7 @@ class SVGProperty : public RefCounted<SVGProperty> {
public:
virtual ~SVGProperty() { }
+ virtual SVGPropertyRole role() const = 0;
virtual void commitChange() = 0;
};
diff --git a/WebCore/svg/properties/SVGPropertyTearOff.h b/WebCore/svg/properties/SVGPropertyTearOff.h
index 219a4a6..d0eac3b 100644
--- a/WebCore/svg/properties/SVGPropertyTearOff.h
+++ b/WebCore/svg/properties/SVGPropertyTearOff.h
@@ -34,10 +34,10 @@ public:
// Used for child types (baseVal/animVal) of a SVGAnimated* property (for example: SVGAnimatedLength::baseVal()).
// Also used for list tear offs (for example: text.x.baseVal.getItem(0)).
- static PassRefPtr<Self> create(SVGAnimatedProperty* animatedProperty, SVGPropertyRole, PropertyType& value)
+ static PassRefPtr<Self> create(SVGAnimatedProperty* animatedProperty, SVGPropertyRole role, PropertyType& value)
{
ASSERT(animatedProperty);
- return adoptRef(new Self(animatedProperty, value));
+ return adoptRef(new Self(animatedProperty, role, value));
}
// Used for non-animated POD types (for example: SVGSVGElement::createSVGLength()).
@@ -91,9 +91,12 @@ public:
m_animatedProperty->commitChange();
}
+ virtual SVGPropertyRole role() const { return m_role; }
+
protected:
- SVGPropertyTearOff(SVGAnimatedProperty* animatedProperty, PropertyType& value)
+ SVGPropertyTearOff(SVGAnimatedProperty* animatedProperty, SVGPropertyRole role, PropertyType& value)
: m_animatedProperty(animatedProperty)
+ , m_role(role)
, m_value(&value)
, m_valueIsCopy(false)
{
@@ -103,6 +106,7 @@ protected:
SVGPropertyTearOff(const PropertyType& initialValue)
: m_animatedProperty(0)
+ , m_role(UndefinedRole)
, m_value(new PropertyType(initialValue))
, m_valueIsCopy(true)
{
@@ -115,6 +119,7 @@ protected:
}
RefPtr<SVGAnimatedProperty> m_animatedProperty;
+ SVGPropertyRole m_role;
PropertyType* m_value;
bool m_valueIsCopy : 1;
};
diff --git a/WebCore/svg/properties/SVGPropertyTraits.h b/WebCore/svg/properties/SVGPropertyTraits.h
index 5364853..0ed9339 100644
--- a/WebCore/svg/properties/SVGPropertyTraits.h
+++ b/WebCore/svg/properties/SVGPropertyTraits.h
@@ -22,16 +22,7 @@
#define SVGPropertyTraits_h
#if ENABLE(SVG)
-#include "FloatRect.h"
-#include "SVGAngle.h"
-#include "SVGLength.h"
-#include "SVGLengthList.h"
-#include "SVGNumberList.h"
-#include "SVGPointList.h"
-#include "SVGPreserveAspectRatio.h"
-#include "SVGStringList.h"
-#include "SVGTransformList.h"
-#include <wtf/text/StringBuilder.h>
+#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -39,12 +30,6 @@ template<typename PropertyType>
struct SVGPropertyTraits { };
template<>
-struct SVGPropertyTraits<SVGAngle> {
- static SVGAngle initialValue() { return SVGAngle(); }
- static String toString(const SVGAngle& type) { return type.valueAsString(); }
-};
-
-template<>
struct SVGPropertyTraits<bool> {
static bool initialValue() { return false; }
static String toString(bool type) { return type ? "true" : "false"; }
@@ -63,81 +48,17 @@ struct SVGPropertyTraits<long> {
};
template<>
-struct SVGPropertyTraits<SVGLength> {
- static SVGLength initialValue() { return SVGLength(); }
- static String toString(const SVGLength& type) { return type.valueAsString(); }
-};
-
-template<>
-struct SVGPropertyTraits<SVGLengthList> {
- typedef SVGLength ListItemType;
-
- static SVGLengthList initialValue() { return SVGLengthList(); }
- static String toString(const SVGLengthList& type) { return type.valueAsString(); }
-};
-
-template<>
struct SVGPropertyTraits<float> {
static float initialValue() { return 0; }
static String toString(float type) { return String::number(type); }
};
template<>
-struct SVGPropertyTraits<SVGNumberList> {
- typedef float ListItemType;
-
- static SVGNumberList initialValue() { return SVGNumberList(); }
- static String toString(const SVGNumberList& type) { return type.valueAsString(); }
-};
-
-template<>
-struct SVGPropertyTraits<SVGPreserveAspectRatio> {
- static SVGPreserveAspectRatio initialValue() { return SVGPreserveAspectRatio(); }
- static String toString(const SVGPreserveAspectRatio& type) { return type.valueAsString(); }
-};
-
-template<>
-struct SVGPropertyTraits<FloatRect> {
- static FloatRect initialValue() { return FloatRect(); }
- static String toString(const FloatRect& type)
- {
- StringBuilder builder;
- builder.append(String::number(type.x()));
- builder.append(' ');
- builder.append(String::number(type.y()));
- builder.append(' ');
- builder.append(String::number(type.width()));
- builder.append(' ');
- builder.append(String::number(type.height()));
- builder.append(' ');
- return builder.toString();
- }
-};
-
-template<>
struct SVGPropertyTraits<String> {
static String initialValue() { return String(); }
static String toString(const String& type) { return type; }
};
-template<>
-struct SVGPropertyTraits<SVGStringList> {
- typedef String ListItemType;
-};
-
-template<>
-struct SVGPropertyTraits<SVGPointList> {
- static SVGPointList initialValue() { return SVGPointList(); }
- typedef FloatPoint ListItemType;
-};
-
-template<>
-struct SVGPropertyTraits<SVGTransformList> {
- static SVGTransformList initialValue() { return SVGTransformList(); }
- static String toString(const SVGTransformList& type) { return type.valueAsString(); }
- typedef SVGTransform ListItemType;
-};
-
}
#endif
diff --git a/WebCore/svg/properties/SVGStaticPropertyTearOff.h b/WebCore/svg/properties/SVGStaticPropertyTearOff.h
index 8f31909..233880f 100644
--- a/WebCore/svg/properties/SVGStaticPropertyTearOff.h
+++ b/WebCore/svg/properties/SVGStaticPropertyTearOff.h
@@ -48,7 +48,7 @@ public:
private:
SVGStaticPropertyTearOff(ContextElement* contextElement, PropertyType& value, UpdateMethod update)
- : SVGPropertyTearOff<PropertyType>(0, value)
+ : SVGPropertyTearOff<PropertyType>(0, UndefinedRole, value)
, m_update(update)
, m_contextElement(contextElement)
{
diff --git a/WebCore/svg/properties/SVGStaticPropertyWithParentTearOff.h b/WebCore/svg/properties/SVGStaticPropertyWithParentTearOff.h
index 1e58341..cf47960 100644
--- a/WebCore/svg/properties/SVGStaticPropertyWithParentTearOff.h
+++ b/WebCore/svg/properties/SVGStaticPropertyWithParentTearOff.h
@@ -53,7 +53,7 @@ public:
private:
SVGStaticPropertyWithParentTearOff(SVGProperty* parent, PropertyType& value, UpdateMethod update)
- : SVGPropertyTearOff<PropertyType>(0, value)
+ : SVGPropertyTearOff<PropertyType>(0, UndefinedRole, value)
, m_update(update)
, m_parent(parent)
{
diff --git a/WebCore/svg/properties/SVGTransformListPropertyTearOff.h b/WebCore/svg/properties/SVGTransformListPropertyTearOff.h
index 636871a..d3ad1ca 100644
--- a/WebCore/svg/properties/SVGTransformListPropertyTearOff.h
+++ b/WebCore/svg/properties/SVGTransformListPropertyTearOff.h
@@ -22,6 +22,7 @@
#if ENABLE(SVG)
#include "SVGListPropertyTearOff.h"
+#include "SVGTransformList.h"
namespace WebCore {
@@ -53,6 +54,10 @@ public:
ListWrapperCache& wrappers = m_animatedProperty->wrappers();
ASSERT(values.size() == wrappers.size());
+ // Spec: If the list was empty, then a value of null is returned.
+ if (values.isEmpty())
+ return 0;
+
m_animatedProperty->detachListWrappers(0);
RefPtr<SVGPropertyTearOff<SVGTransform> > wrapper = SVGPropertyTearOff<SVGTransform>::create(values.consolidate());
wrappers.append(wrapper);