Chromium Code Reviews| 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 |
|
pdr.
2016/10/04 21:05:30
Nit: put "e.g.," on the previous line and split up
Nico
2016/10/04 21:10:23
Done.
| |
| 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 // (e.g. "textElement.x.baseVal.appendItem(rectElement.width.baseVal)") |
| 55 // Spec: If newItem is already in a list, then a new object is created with | |
| 56 // the same values as newItem and this item is inserted into the list. | |
| 55 // Otherwise, newItem itself is inserted into the list. | 57 // Otherwise, newItem itself is inserted into the list. |
| 56 if (newItem->isImmutable() || newItem->target()->ownerList() || | 58 if (newItem->isImmutable() || newItem->target()->ownerList() || |
| 57 newItem->contextElement()) { | 59 newItem->contextElement()) { |
| 58 // We have to copy the incoming |newItem|, | 60 // 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: | 61 // 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 | 62 // SVGProperty. Consider the example below: SVGRectElements |
| 61 // that's inserted into SVGTextElements SVGAnimatedLengthList 'x'. textEle ment.x.baseVal.getItem(0).value += 150 would | 63 // 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. | 64 // object that's inserted into SVGTextElements SVGAnimatedLengthList 'x'. |
| 65 // textElement.x.baseVal.getItem(0).value += 150 would mutate the | |
| 66 // rectElement width _and_ the textElement x list. That's obviously wrong, | |
| 67 // take care of that. | |
| 63 return newItem->target()->clone(); | 68 return newItem->target()->clone(); |
| 64 } | 69 } |
| 65 | 70 |
| 66 newItem->attachToSVGElementAttribute(contextElement, attributeName); | 71 newItem->attachToSVGElementAttribute(contextElement, attributeName); |
| 67 return newItem->target(); | 72 return newItem->target(); |
| 68 } | 73 } |
| 69 | 74 |
| 70 static ItemTearOffType* createTearOff(ItemPropertyType* value, | 75 static ItemTearOffType* createTearOff(ItemPropertyType* value, |
| 71 SVGElement* contextElement, | 76 SVGElement* contextElement, |
| 72 PropertyIsAnimValType propertyIsAnimVal, | 77 PropertyIsAnimValType propertyIsAnimVal, |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 QualifiedName::null()); | 211 QualifiedName::null()); |
| 207 } | 212 } |
| 208 | 213 |
| 209 private: | 214 private: |
| 210 Derived* toDerived() { return static_cast<Derived*>(this); } | 215 Derived* toDerived() { return static_cast<Derived*>(this); } |
| 211 }; | 216 }; |
| 212 | 217 |
| 213 } // namespace blink | 218 } // namespace blink |
| 214 | 219 |
| 215 #endif // SVGListPropertyTearOffHelper_h | 220 #endif // SVGListPropertyTearOffHelper_h |
| OLD | NEW |