Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Unified Diff: Source/WebCore/svg/properties/SVGPathSegListPropertyTearOff.cpp

Issue 12288020: Merge 142759 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1410/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}
}

Powered by Google App Engine
This is Rietveld 408576698