| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 */ | 18 */ |
| 19 | 19 |
| 20 #ifndef SVGMatrixTearOff_h | 20 #ifndef SVGMatrixTearOff_h |
| 21 #define SVGMatrixTearOff_h | 21 #define SVGMatrixTearOff_h |
| 22 | 22 |
| 23 #include "core/svg/SVGTransform.h" | 23 #include "core/svg/SVGTransform.h" |
| 24 #include "core/svg/properties/SVGPropertyTearOff.h" | 24 #include "core/svg/properties/SVGPropertyTearOff.h" |
| 25 | 25 |
| 26 namespace WebCore { | 26 namespace WebCore { |
| 27 | 27 |
| 28 class SVGMatrixTearOff : public SVGPropertyTearOff<SVGMatrix> { | 28 class SVGMatrixTearOff FINAL : public SVGPropertyTearOff<SVGMatrix> { |
| 29 public: | 29 public: |
| 30 // Used for child types (baseVal/animVal) of a SVGAnimated* property (for ex
ample: SVGAnimatedLength::baseVal()). | 30 // Used for child types (baseVal/animVal) of a SVGAnimated* property (for ex
ample: SVGAnimatedLength::baseVal()). |
| 31 // Also used for list tear offs (for example: text.x.baseVal.getItem(0)). | 31 // Also used for list tear offs (for example: text.x.baseVal.getItem(0)). |
| 32 static PassRefPtr<SVGMatrixTearOff> create(SVGAnimatedProperty* animatedProp
erty, SVGPropertyRole role, SVGMatrix& value) | 32 static PassRefPtr<SVGMatrixTearOff> create(SVGAnimatedProperty* animatedProp
erty, SVGPropertyRole role, SVGMatrix& value) |
| 33 { | 33 { |
| 34 ASSERT(animatedProperty); | 34 ASSERT(animatedProperty); |
| 35 return adoptRef(new SVGMatrixTearOff(animatedProperty, role, value)); | 35 return adoptRef(new SVGMatrixTearOff(animatedProperty, role, value)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Used for non-animated POD types (for example: SVGSVGElement::createSVGLen
gth()). | 38 // Used for non-animated POD types (for example: SVGSVGElement::createSVGLen
gth()). |
| 39 static PassRefPtr<SVGMatrixTearOff> create(const SVGMatrix& initialValue) | 39 static PassRefPtr<SVGMatrixTearOff> create(const SVGMatrix& initialValue) |
| 40 { | 40 { |
| 41 return adoptRef(new SVGMatrixTearOff(initialValue)); | 41 return adoptRef(new SVGMatrixTearOff(initialValue)); |
| 42 } | 42 } |
| 43 | 43 |
| 44 // Used for non-animated POD types that are not associated with a SVGAnimate
dProperty object, nor with a XML DOM attribute | 44 // Used for non-animated POD types that are not associated with a SVGAnimate
dProperty object, nor with a XML DOM attribute |
| 45 // and that contain a parent type that's exposed to the bindings via a SVGSt
aticPropertyTearOff object | 45 // and that contain a parent type that's exposed to the bindings via a SVGSt
aticPropertyTearOff object |
| 46 // (for example: SVGTransform::matrix). | 46 // (for example: SVGTransform::matrix). |
| 47 static PassRefPtr<SVGMatrixTearOff> create(SVGPropertyTearOff<SVGTransform>*
parent, SVGMatrix& value) | 47 static PassRefPtr<SVGMatrixTearOff> create(SVGPropertyTearOff<SVGTransform>*
parent, SVGMatrix& value) |
| 48 { | 48 { |
| 49 ASSERT(parent); | 49 ASSERT(parent); |
| 50 RefPtr<SVGMatrixTearOff> result = adoptRef(new SVGMatrixTearOff(parent,
value)); | 50 RefPtr<SVGMatrixTearOff> result = adoptRef(new SVGMatrixTearOff(parent,
value)); |
| 51 parent->addChild(result->m_weakFactory.createWeakPtr()); | 51 parent->addChild(result->m_weakFactory.createWeakPtr()); |
| 52 return result.release(); | 52 return result.release(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 virtual void commitChange() | 55 virtual void commitChange() OVERRIDE |
| 56 { | 56 { |
| 57 if (m_parent) { | 57 if (m_parent) { |
| 58 // This is a tear-off from a SVGPropertyTearOff<SVGTransform>. | 58 // This is a tear-off from a SVGPropertyTearOff<SVGTransform>. |
| 59 m_parent->propertyReference().updateSVGMatrix(); | 59 m_parent->propertyReference().updateSVGMatrix(); |
| 60 m_parent->commitChange(); | 60 m_parent->commitChange(); |
| 61 } else { | 61 } else { |
| 62 // This is either a detached tear-off or a reference tear-off from a
AnimatedProperty. | 62 // This is either a detached tear-off or a reference tear-off from a
AnimatedProperty. |
| 63 SVGPropertyTearOff<SVGMatrix>::commitChange(); | 63 SVGPropertyTearOff<SVGMatrix>::commitChange(); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 // SVGMatrixTearOff can be a child tear-off of a SVGTransform tear-off, | 67 // SVGMatrixTearOff can be a child tear-off of a SVGTransform tear-off, |
| 68 // which means that |m_value| may be pointing inside |m_value| of the other
tear-off. | 68 // which means that |m_value| may be pointing inside |m_value| of the other
tear-off. |
| 69 // This method is called from the parent SVGTransform tear-off when |m_paren
t->m_value| is updated, | 69 // This method is called from the parent SVGTransform tear-off when |m_paren
t->m_value| is updated, |
| 70 // so that |this->m_value| would point to valid location. | 70 // so that |this->m_value| would point to valid location. |
| 71 virtual void setValueForMatrixIfNeeded(SVGTransform* transform) | 71 virtual void setValueForMatrixIfNeeded(SVGTransform* transform) OVERRIDE |
| 72 { | 72 { |
| 73 setValue(transform->svgMatrix()); | 73 setValue(transform->svgMatrix()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 SVGPropertyTearOff<SVGTransform>* parent() { return m_parent; } | 76 SVGPropertyTearOff<SVGTransform>* parent() { return m_parent; } |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 SVGMatrixTearOff(SVGAnimatedProperty* animatedProperty, SVGPropertyRole role
, SVGMatrix& value) | 79 SVGMatrixTearOff(SVGAnimatedProperty* animatedProperty, SVGPropertyRole role
, SVGMatrix& value) |
| 80 : SVGPropertyTearOff<SVGMatrix>(animatedProperty, role, value) | 80 : SVGPropertyTearOff<SVGMatrix>(animatedProperty, role, value) |
| 81 , m_parent(0) | 81 , m_parent(0) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 99 | 99 |
| 100 // m_parent is kept alive from V8 wrapper. | 100 // m_parent is kept alive from V8 wrapper. |
| 101 SVGPropertyTearOff<SVGTransform>* m_parent; | 101 SVGPropertyTearOff<SVGTransform>* m_parent; |
| 102 | 102 |
| 103 WeakPtrFactory<SVGPropertyTearOffBase > m_weakFactory; | 103 WeakPtrFactory<SVGPropertyTearOffBase > m_weakFactory; |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 } | 106 } |
| 107 | 107 |
| 108 #endif // SVGMatrixTearOff_h | 108 #endif // SVGMatrixTearOff_h |
| OLD | NEW |