Index: Source/WebCore/svg/properties/SVGPathSegListPropertyTearOff.cpp |
=================================================================== |
--- Source/WebCore/svg/properties/SVGPathSegListPropertyTearOff.cpp (revision 143078) |
+++ Source/WebCore/svg/properties/SVGPathSegListPropertyTearOff.cpp (working copy) |
@@ -70,7 +70,7 @@ |
return static_cast<SVGPathElement*>(contextElement); |
} |
-void SVGPathSegListPropertyTearOff::processIncomingListItemValue(const ListItemType& newItem, unsigned* indexToModify) |
+bool SVGPathSegListPropertyTearOff::processIncomingListItemValue(const ListItemType& newItem, unsigned* indexToModify) |
{ |
SVGPathSegWithContext* newItemWithContext = static_cast<SVGPathSegWithContext*>(newItem.get()); |
SVGAnimatedProperty* animatedPropertyOfItem = newItemWithContext->animatedProperty(); |
@@ -79,29 +79,38 @@ |
newItemWithContext->setContextAndRole(contextElement(), m_pathSegRole); |
if (!animatedPropertyOfItem) |
- return; |
+ return true; |
// 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; |
+ return true; |
// 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); |
+ SVGAnimatedPathSegListPropertyTearOff* propertyTearOff = static_cast<SVGAnimatedPathSegListPropertyTearOff*>(animatedPropertyOfItem); |
+ int indexToRemove = propertyTearOff->findItem(newItem.get()); |
+ ASSERT(indexToRemove != -1); |
+ // Do not remove newItem if already in this list at the target index. |
+ if (!livesInOtherList && indexToModify && static_cast<unsigned>(indexToRemove) == *indexToModify) |
+ return false; |
+ |
+ propertyTearOff->removeItemFromList(indexToRemove, livesInOtherList); |
+ |
if (!indexToModify) |
- return; |
+ return true; |
// 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) |
+ if (static_cast<unsigned>(indexToRemove) < index) |
--index; |
} |
+ |
+ return true; |
} |
} |