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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 public: | 43 public: |
44 typedef ItemProperty ItemPropertyType; | 44 typedef ItemProperty ItemPropertyType; |
45 typedef typename ItemPropertyType::TearOffType ItemTearOffType; | 45 typedef typename ItemPropertyType::TearOffType ItemTearOffType; |
46 | 46 |
47 static ItemPropertyType* getValueForInsertionFromTearOff( | 47 static ItemPropertyType* getValueForInsertionFromTearOff( |
48 ItemTearOffType* newItem, | 48 ItemTearOffType* newItem, |
49 SVGElement* contextElement, | 49 SVGElement* contextElement, |
50 const QualifiedName& attributeName) { | 50 const QualifiedName& attributeName) { |
51 // |newItem| is immutable, OR | 51 // |newItem| is immutable, OR |
52 // |newItem| belongs to a SVGElement, but it does not belong to an animated
list | 52 // |newItem| belongs to a SVGElement, but it does not belong to an animated |
53 // (for example: "textElement.x.baseVal.appendItem(rectElement.width.baseVal
)") | 53 // list, e.g. "textElement.x.baseVal.appendItem(rectElement.width.baseVal)" |
54 // Spec: If newItem is already in a list, then a new object is created with
the same values as newItem and this item is inserted into the list. | 54 // Spec: If newItem is already in a list, then a new object is created with |
| 55 // the same values as newItem and this item is inserted into the list. |
55 // Otherwise, newItem itself is inserted into the list. | 56 // Otherwise, newItem itself is inserted into the list. |
56 if (newItem->isImmutable() || newItem->target()->ownerList() || | 57 if (newItem->isImmutable() || newItem->target()->ownerList() || |
57 newItem->contextElement()) { | 58 newItem->contextElement()) { |
58 // We have to copy the incoming |newItem|, | 59 // We have to copy the incoming |newItem|, |
59 // Otherwise we'll end up having two tearoffs that operate on the same SVG
Property. Consider the example below: | 60 // Otherwise we'll end up having two tearoffs that operate on the same |
60 // SVGRectElements SVGAnimatedLength 'width' property baseVal points to th
e same tear off object | 61 // SVGProperty. Consider the example below: SVGRectElements |
61 // that's inserted into SVGTextElements SVGAnimatedLengthList 'x'. textEle
ment.x.baseVal.getItem(0).value += 150 would | 62 // SVGAnimatedLength 'width' property baseVal points to the same tear off |
62 // mutate the rectElement width _and_ the textElement x list. That's obvio
usly wrong, take care of that. | 63 // object that's inserted into SVGTextElements SVGAnimatedLengthList 'x'. |
| 64 // textElement.x.baseVal.getItem(0).value += 150 would mutate the |
| 65 // rectElement width _and_ the textElement x list. That's obviously wrong, |
| 66 // take care of that. |
63 return newItem->target()->clone(); | 67 return newItem->target()->clone(); |
64 } | 68 } |
65 | 69 |
66 newItem->attachToSVGElementAttribute(contextElement, attributeName); | 70 newItem->attachToSVGElementAttribute(contextElement, attributeName); |
67 return newItem->target(); | 71 return newItem->target(); |
68 } | 72 } |
69 | 73 |
70 static ItemTearOffType* createTearOff(ItemPropertyType* value, | 74 static ItemTearOffType* createTearOff(ItemPropertyType* value, |
71 SVGElement* contextElement, | 75 SVGElement* contextElement, |
72 PropertyIsAnimValType propertyIsAnimVal, | 76 PropertyIsAnimValType propertyIsAnimVal, |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 QualifiedName::null()); | 210 QualifiedName::null()); |
207 } | 211 } |
208 | 212 |
209 private: | 213 private: |
210 Derived* toDerived() { return static_cast<Derived*>(this); } | 214 Derived* toDerived() { return static_cast<Derived*>(this); } |
211 }; | 215 }; |
212 | 216 |
213 } // namespace blink | 217 } // namespace blink |
214 | 218 |
215 #endif // SVGListPropertyTearOffHelper_h | 219 #endif // SVGListPropertyTearOffHelper_h |
OLD | NEW |