OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 typedef ItemProperty ItemPropertyType; | 44 typedef ItemProperty ItemPropertyType; |
45 typedef typename ItemPropertyType::TearOffType ItemTearOffType; | 45 typedef typename ItemPropertyType::TearOffType ItemTearOffType; |
46 | 46 |
47 static PassRefPtrWillBeRawPtr<ItemPropertyType> getValueForInsertionFromTear
Off(PassRefPtrWillBeRawPtr<ItemTearOffType> passNewItem, SVGElement* contextElem
ent, const QualifiedName& attributeName) | 47 static PassRefPtrWillBeRawPtr<ItemPropertyType> getValueForInsertionFromTear
Off(PassRefPtrWillBeRawPtr<ItemTearOffType> passNewItem, SVGElement* contextElem
ent, const QualifiedName& attributeName) |
48 { | 48 { |
49 RefPtrWillBeRawPtr<ItemTearOffType> newItem = passNewItem; | 49 RefPtrWillBeRawPtr<ItemTearOffType> newItem = passNewItem; |
50 | 50 |
51 // |newItem| is immutable, OR | 51 // |newItem| is immutable, OR |
52 // |newItem| belongs to a SVGElement, but it does not belong to an anima
ted list | 52 // |newItem| belongs to a SVGElement, but it does not belong to an anima
ted list |
53 // (for example: "textElement.x.baseVal.appendItem(rectElement.width.bas
eVal)") | 53 // (for example: "textElement.x.baseVal.appendItem(rectElement.width.bas
eVal)") |
54 if (newItem->isImmutable() | 54 // Spec: If newItem is already in a list, then a new object is created w
ith the same values as newItem and this item is inserted into the list. |
55 || (newItem->contextElement() && !newItem->target()->ownerList())) { | 55 // Otherwise, newItem itself is inserted into the list. |
| 56 if (newItem->isImmutable() || newItem->target()->ownerList() || newItem-
>contextElement()) { |
56 // We have to copy the incoming |newItem|, | 57 // We have to copy the incoming |newItem|, |
57 // Otherwise we'll end up having two tearoffs that operate on the sa
me SVGProperty. Consider the example below: | 58 // Otherwise we'll end up having two tearoffs that operate on the sa
me SVGProperty. Consider the example below: |
58 // SVGRectElements SVGAnimatedLength 'width' property baseVal points
to the same tear off object | 59 // SVGRectElements SVGAnimatedLength 'width' property baseVal points
to the same tear off object |
59 // that's inserted into SVGTextElements SVGAnimatedLengthList 'x'. t
extElement.x.baseVal.getItem(0).value += 150 would | 60 // that's inserted into SVGTextElements SVGAnimatedLengthList 'x'. t
extElement.x.baseVal.getItem(0).value += 150 would |
60 // mutate the rectElement width _and_ the textElement x list. That's
obviously wrong, take care of that. | 61 // mutate the rectElement width _and_ the textElement x list. That's
obviously wrong, take care of that. |
61 return newItem->target()->clone(); | 62 return newItem->target()->clone(); |
62 } | 63 } |
63 | 64 |
64 newItem->attachToSVGElementAttribute(contextElement, attributeName); | 65 newItem->attachToSVGElementAttribute(contextElement, attributeName); |
65 return newItem->target(); | 66 return newItem->target(); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 return ItemTraits::createTearOff(value, 0, PropertyIsNotAnimVal, Qualifi
edName::null()); | 213 return ItemTraits::createTearOff(value, 0, PropertyIsNotAnimVal, Qualifi
edName::null()); |
213 } | 214 } |
214 | 215 |
215 private: | 216 private: |
216 Derived* toDerived() { return static_cast<Derived*>(this); } | 217 Derived* toDerived() { return static_cast<Derived*>(this); } |
217 }; | 218 }; |
218 | 219 |
219 } | 220 } |
220 | 221 |
221 #endif // SVGListPropertyTearOffHelper_h | 222 #endif // SVGListPropertyTearOffHelper_h |
OLD | NEW |