| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "core/svg/SVGEllipseElement.h" | 23 #include "core/svg/SVGEllipseElement.h" |
| 24 | 24 |
| 25 #include "core/rendering/svg/RenderSVGEllipse.h" | 25 #include "core/rendering/svg/RenderSVGEllipse.h" |
| 26 #include "core/rendering/svg/RenderSVGResource.h" | 26 #include "core/rendering/svg/RenderSVGResource.h" |
| 27 #include "core/svg/SVGElementInstance.h" | 27 #include "core/svg/SVGElementInstance.h" |
| 28 #include "core/svg/SVGLength.h" | 28 #include "core/svg/SVGLength.h" |
| 29 | 29 |
| 30 namespace WebCore { | 30 namespace WebCore { |
| 31 | 31 |
| 32 // Animated property definitions | 32 // Animated property definitions |
| 33 DEFINE_ANIMATED_LENGTH(SVGEllipseElement, SVGNames::cxAttr, Cx, cx) | |
| 34 DEFINE_ANIMATED_LENGTH(SVGEllipseElement, SVGNames::cyAttr, Cy, cy) | |
| 35 DEFINE_ANIMATED_LENGTH(SVGEllipseElement, SVGNames::rxAttr, Rx, rx) | |
| 36 DEFINE_ANIMATED_LENGTH(SVGEllipseElement, SVGNames::ryAttr, Ry, ry) | |
| 37 | |
| 38 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGEllipseElement) | 33 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGEllipseElement) |
| 39 REGISTER_LOCAL_ANIMATED_PROPERTY(cx) | |
| 40 REGISTER_LOCAL_ANIMATED_PROPERTY(cy) | |
| 41 REGISTER_LOCAL_ANIMATED_PROPERTY(rx) | |
| 42 REGISTER_LOCAL_ANIMATED_PROPERTY(ry) | |
| 43 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) | 34 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) |
| 44 END_REGISTER_ANIMATED_PROPERTIES | 35 END_REGISTER_ANIMATED_PROPERTIES |
| 45 | 36 |
| 46 inline SVGEllipseElement::SVGEllipseElement(Document& document) | 37 inline SVGEllipseElement::SVGEllipseElement(Document& document) |
| 47 : SVGGeometryElement(SVGNames::ellipseTag, document) | 38 : SVGGeometryElement(SVGNames::ellipseTag, document) |
| 48 , m_cx(LengthModeWidth) | 39 , m_cx(SVGAnimatedLength::create(this, SVGNames::cxAttr, SVGLength::create(L
engthModeWidth))) |
| 49 , m_cy(LengthModeHeight) | 40 , m_cy(SVGAnimatedLength::create(this, SVGNames::cyAttr, SVGLength::create(L
engthModeHeight))) |
| 50 , m_rx(LengthModeWidth) | 41 , m_rx(SVGAnimatedLength::create(this, SVGNames::rxAttr, SVGLength::create(L
engthModeWidth))) |
| 51 , m_ry(LengthModeHeight) | 42 , m_ry(SVGAnimatedLength::create(this, SVGNames::ryAttr, SVGLength::create(L
engthModeHeight))) |
| 52 { | 43 { |
| 53 ScriptWrappable::init(this); | 44 ScriptWrappable::init(this); |
| 45 |
| 46 addToPropertyMap(m_cx); |
| 47 addToPropertyMap(m_cy); |
| 48 addToPropertyMap(m_rx); |
| 49 addToPropertyMap(m_ry); |
| 54 registerAnimatedPropertiesForSVGEllipseElement(); | 50 registerAnimatedPropertiesForSVGEllipseElement(); |
| 55 } | 51 } |
| 56 | 52 |
| 57 PassRefPtr<SVGEllipseElement> SVGEllipseElement::create(Document& document) | 53 PassRefPtr<SVGEllipseElement> SVGEllipseElement::create(Document& document) |
| 58 { | 54 { |
| 59 return adoptRef(new SVGEllipseElement(document)); | 55 return adoptRef(new SVGEllipseElement(document)); |
| 60 } | 56 } |
| 61 | 57 |
| 62 bool SVGEllipseElement::isSupportedAttribute(const QualifiedName& attrName) | 58 bool SVGEllipseElement::isSupportedAttribute(const QualifiedName& attrName) |
| 63 { | 59 { |
| 64 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | 60 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); |
| 65 if (supportedAttributes.isEmpty()) { | 61 if (supportedAttributes.isEmpty()) { |
| 66 supportedAttributes.add(SVGNames::cxAttr); | 62 supportedAttributes.add(SVGNames::cxAttr); |
| 67 supportedAttributes.add(SVGNames::cyAttr); | 63 supportedAttributes.add(SVGNames::cyAttr); |
| 68 supportedAttributes.add(SVGNames::rxAttr); | 64 supportedAttributes.add(SVGNames::rxAttr); |
| 69 supportedAttributes.add(SVGNames::ryAttr); | 65 supportedAttributes.add(SVGNames::ryAttr); |
| 70 } | 66 } |
| 71 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 67 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
| 72 } | 68 } |
| 73 | 69 |
| 74 void SVGEllipseElement::parseAttribute(const QualifiedName& name, const AtomicSt
ring& value) | 70 void SVGEllipseElement::parseAttribute(const QualifiedName& name, const AtomicSt
ring& value) |
| 75 { | 71 { |
| 76 SVGParsingError parseError = NoError; | 72 SVGParsingError parseError = NoError; |
| 77 | 73 |
| 78 if (!isSupportedAttribute(name)) | 74 if (!isSupportedAttribute(name)) |
| 79 SVGGeometryElement::parseAttribute(name, value); | 75 SVGGeometryElement::parseAttribute(name, value); |
| 80 else if (name == SVGNames::cxAttr) | 76 else if (name == SVGNames::cxAttr) |
| 81 setCxBaseValue(SVGLength::construct(LengthModeWidth, value, parseError))
; | 77 m_cx->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
| 82 else if (name == SVGNames::cyAttr) | 78 else if (name == SVGNames::cyAttr) |
| 83 setCyBaseValue(SVGLength::construct(LengthModeHeight, value, parseError)
); | 79 m_cy->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
| 84 else if (name == SVGNames::rxAttr) | 80 else if (name == SVGNames::rxAttr) |
| 85 setRxBaseValue(SVGLength::construct(LengthModeWidth, value, parseError,
ForbidNegativeLengths)); | 81 m_rx->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
| 86 else if (name == SVGNames::ryAttr) | 82 else if (name == SVGNames::ryAttr) |
| 87 setRyBaseValue(SVGLength::construct(LengthModeHeight, value, parseError,
ForbidNegativeLengths)); | 83 m_ry->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
| 88 else | 84 else |
| 89 ASSERT_NOT_REACHED(); | 85 ASSERT_NOT_REACHED(); |
| 90 | 86 |
| 91 reportAttributeParsingError(parseError, name, value); | 87 reportAttributeParsingError(parseError, name, value); |
| 92 } | 88 } |
| 93 | 89 |
| 94 void SVGEllipseElement::svgAttributeChanged(const QualifiedName& attrName) | 90 void SVGEllipseElement::svgAttributeChanged(const QualifiedName& attrName) |
| 95 { | 91 { |
| 96 if (!isSupportedAttribute(attrName)) { | 92 if (!isSupportedAttribute(attrName)) { |
| 97 SVGGeometryElement::svgAttributeChanged(attrName); | 93 SVGGeometryElement::svgAttributeChanged(attrName); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 116 renderer->setNeedsShapeUpdate(); | 112 renderer->setNeedsShapeUpdate(); |
| 117 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); | 113 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); |
| 118 return; | 114 return; |
| 119 } | 115 } |
| 120 | 116 |
| 121 ASSERT_NOT_REACHED(); | 117 ASSERT_NOT_REACHED(); |
| 122 } | 118 } |
| 123 | 119 |
| 124 bool SVGEllipseElement::selfHasRelativeLengths() const | 120 bool SVGEllipseElement::selfHasRelativeLengths() const |
| 125 { | 121 { |
| 126 return cxCurrentValue().isRelative() | 122 return m_cx->currentValue()->isRelative() |
| 127 || cyCurrentValue().isRelative() | 123 || m_cy->currentValue()->isRelative() |
| 128 || rxCurrentValue().isRelative() | 124 || m_rx->currentValue()->isRelative() |
| 129 || ryCurrentValue().isRelative(); | 125 || m_ry->currentValue()->isRelative(); |
| 130 } | 126 } |
| 131 | 127 |
| 132 RenderObject* SVGEllipseElement::createRenderer(RenderStyle*) | 128 RenderObject* SVGEllipseElement::createRenderer(RenderStyle*) |
| 133 { | 129 { |
| 134 return new RenderSVGEllipse(this); | 130 return new RenderSVGEllipse(this); |
| 135 } | 131 } |
| 136 | 132 |
| 137 } | 133 } |
| OLD | NEW |