| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 } | 63 } |
| 64 | 64 |
| 65 SVGPathElement* SVGPathSegListPropertyTearOff::contextElement() const | 65 SVGPathElement* SVGPathSegListPropertyTearOff::contextElement() const |
| 66 { | 66 { |
| 67 SVGElement* contextElement = m_animatedProperty->contextElement(); | 67 SVGElement* contextElement = m_animatedProperty->contextElement(); |
| 68 ASSERT(contextElement); | 68 ASSERT(contextElement); |
| 69 ASSERT(contextElement->hasTagName(SVGNames::pathTag)); | 69 ASSERT(contextElement->hasTagName(SVGNames::pathTag)); |
| 70 return static_cast<SVGPathElement*>(contextElement); | 70 return static_cast<SVGPathElement*>(contextElement); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void SVGPathSegListPropertyTearOff::processIncomingListItemValue(const ListItemT
ype& newItem, unsigned* indexToModify) | 73 bool SVGPathSegListPropertyTearOff::processIncomingListItemValue(const ListItemT
ype& newItem, unsigned* indexToModify) |
| 74 { | 74 { |
| 75 SVGPathSegWithContext* newItemWithContext = static_cast<SVGPathSegWithContex
t*>(newItem.get()); | 75 SVGPathSegWithContext* newItemWithContext = static_cast<SVGPathSegWithContex
t*>(newItem.get()); |
| 76 SVGAnimatedProperty* animatedPropertyOfItem = newItemWithContext->animatedPr
operty(); | 76 SVGAnimatedProperty* animatedPropertyOfItem = newItemWithContext->animatedPr
operty(); |
| 77 | 77 |
| 78 // Alter the role, after calling animatedProperty(), as that may influence t
he returned animated property. | 78 // Alter the role, after calling animatedProperty(), as that may influence t
he returned animated property. |
| 79 newItemWithContext->setContextAndRole(contextElement(), m_pathSegRole); | 79 newItemWithContext->setContextAndRole(contextElement(), m_pathSegRole); |
| 80 | 80 |
| 81 if (!animatedPropertyOfItem) | 81 if (!animatedPropertyOfItem) |
| 82 return; | 82 return true; |
| 83 | 83 |
| 84 // newItem belongs to a SVGPathElement, but its associated SVGAnimatedProper
ty is not an animated list tear off. | 84 // newItem belongs to a SVGPathElement, but its associated SVGAnimatedProper
ty is not an animated list tear off. |
| 85 // (for example: "pathElement.pathSegList.appendItem(pathElement.createSVGPa
thSegClosepath())") | 85 // (for example: "pathElement.pathSegList.appendItem(pathElement.createSVGPa
thSegClosepath())") |
| 86 if (!animatedPropertyOfItem->isAnimatedListTearOff()) | 86 if (!animatedPropertyOfItem->isAnimatedListTearOff()) |
| 87 return; | 87 return true; |
| 88 | 88 |
| 89 // Spec: If newItem is already in a list, it is removed from its previous li
st before it is inserted into this list. | 89 // Spec: If newItem is already in a list, it is removed from its previous li
st before it is inserted into this list. |
| 90 // 'newItem' is already living in another list. If it's not our list, synchr
onize the other lists wrappers after the removal. | 90 // 'newItem' is already living in another list. If it's not our list, synchr
onize the other lists wrappers after the removal. |
| 91 bool livesInOtherList = animatedPropertyOfItem != m_animatedProperty; | 91 bool livesInOtherList = animatedPropertyOfItem != m_animatedProperty; |
| 92 int removedIndex = static_cast<SVGAnimatedPathSegListPropertyTearOff*>(anima
tedPropertyOfItem)->removeItemFromList(newItem.get(), livesInOtherList); | 92 SVGAnimatedPathSegListPropertyTearOff* propertyTearOff = static_cast<SVGAnim
atedPathSegListPropertyTearOff*>(animatedPropertyOfItem); |
| 93 ASSERT(removedIndex != -1); | 93 int indexToRemove = propertyTearOff->findItem(newItem.get()); |
| 94 ASSERT(indexToRemove != -1); |
| 95 |
| 96 // Do not remove newItem if already in this list at the target index. |
| 97 if (!livesInOtherList && indexToModify && static_cast<unsigned>(indexToRemov
e) == *indexToModify) |
| 98 return false; |
| 99 |
| 100 propertyTearOff->removeItemFromList(indexToRemove, livesInOtherList); |
| 94 | 101 |
| 95 if (!indexToModify) | 102 if (!indexToModify) |
| 96 return; | 103 return true; |
| 97 | 104 |
| 98 // If the item lived in our list, adjust the insertion index. | 105 // If the item lived in our list, adjust the insertion index. |
| 99 if (!livesInOtherList) { | 106 if (!livesInOtherList) { |
| 100 unsigned& index = *indexToModify; | 107 unsigned& index = *indexToModify; |
| 101 // 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. | 108 // 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. |
| 102 if (static_cast<unsigned>(removedIndex) < index) | 109 if (static_cast<unsigned>(indexToRemove) < index) |
| 103 --index; | 110 --index; |
| 104 } | 111 } |
| 112 |
| 113 return true; |
| 105 } | 114 } |
| 106 | 115 |
| 107 } | 116 } |
| 108 | 117 |
| 109 #endif // ENABLE(SVG) | 118 #endif // ENABLE(SVG) |
| OLD | NEW |