| 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 15 matching lines...) Expand all Loading... |
| 26 #include "core/svg/SVGElementInstance.h" | 26 #include "core/svg/SVGElementInstance.h" |
| 27 #include "core/svg/SVGLength.h" | 27 #include "core/svg/SVGLength.h" |
| 28 | 28 |
| 29 namespace WebCore { | 29 namespace WebCore { |
| 30 | 30 |
| 31 // Animated property definitions | 31 // Animated property definitions |
| 32 DEFINE_ANIMATED_LENGTH(SVGLineElement, SVGNames::x1Attr, X1, x1) | 32 DEFINE_ANIMATED_LENGTH(SVGLineElement, SVGNames::x1Attr, X1, x1) |
| 33 DEFINE_ANIMATED_LENGTH(SVGLineElement, SVGNames::y1Attr, Y1, y1) | 33 DEFINE_ANIMATED_LENGTH(SVGLineElement, SVGNames::y1Attr, Y1, y1) |
| 34 DEFINE_ANIMATED_LENGTH(SVGLineElement, SVGNames::x2Attr, X2, x2) | 34 DEFINE_ANIMATED_LENGTH(SVGLineElement, SVGNames::x2Attr, X2, x2) |
| 35 DEFINE_ANIMATED_LENGTH(SVGLineElement, SVGNames::y2Attr, Y2, y2) | 35 DEFINE_ANIMATED_LENGTH(SVGLineElement, SVGNames::y2Attr, Y2, y2) |
| 36 DEFINE_ANIMATED_BOOLEAN(SVGLineElement, SVGNames::externalResourcesRequiredAttr,
ExternalResourcesRequired, externalResourcesRequired) | |
| 37 | 36 |
| 38 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGLineElement) | 37 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGLineElement) |
| 39 REGISTER_LOCAL_ANIMATED_PROPERTY(x1) | 38 REGISTER_LOCAL_ANIMATED_PROPERTY(x1) |
| 40 REGISTER_LOCAL_ANIMATED_PROPERTY(y1) | 39 REGISTER_LOCAL_ANIMATED_PROPERTY(y1) |
| 41 REGISTER_LOCAL_ANIMATED_PROPERTY(x2) | 40 REGISTER_LOCAL_ANIMATED_PROPERTY(x2) |
| 42 REGISTER_LOCAL_ANIMATED_PROPERTY(y2) | 41 REGISTER_LOCAL_ANIMATED_PROPERTY(y2) |
| 43 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) | |
| 44 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) | 42 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) |
| 45 END_REGISTER_ANIMATED_PROPERTIES | 43 END_REGISTER_ANIMATED_PROPERTIES |
| 46 | 44 |
| 47 inline SVGLineElement::SVGLineElement(Document& document) | 45 inline SVGLineElement::SVGLineElement(Document& document) |
| 48 : SVGGeometryElement(SVGNames::lineTag, document) | 46 : SVGGeometryElement(SVGNames::lineTag, document) |
| 49 , m_x1(LengthModeWidth) | 47 , m_x1(LengthModeWidth) |
| 50 , m_y1(LengthModeHeight) | 48 , m_y1(LengthModeHeight) |
| 51 , m_x2(LengthModeWidth) | 49 , m_x2(LengthModeWidth) |
| 52 , m_y2(LengthModeHeight) | 50 , m_y2(LengthModeHeight) |
| 53 { | 51 { |
| 54 ScriptWrappable::init(this); | 52 ScriptWrappable::init(this); |
| 55 registerAnimatedPropertiesForSVGLineElement(); | 53 registerAnimatedPropertiesForSVGLineElement(); |
| 56 } | 54 } |
| 57 | 55 |
| 58 PassRefPtr<SVGLineElement> SVGLineElement::create(Document& document) | 56 PassRefPtr<SVGLineElement> SVGLineElement::create(Document& document) |
| 59 { | 57 { |
| 60 return adoptRef(new SVGLineElement(document)); | 58 return adoptRef(new SVGLineElement(document)); |
| 61 } | 59 } |
| 62 | 60 |
| 63 bool SVGLineElement::isSupportedAttribute(const QualifiedName& attrName) | 61 bool SVGLineElement::isSupportedAttribute(const QualifiedName& attrName) |
| 64 { | 62 { |
| 65 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | 63 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); |
| 66 if (supportedAttributes.isEmpty()) { | 64 if (supportedAttributes.isEmpty()) { |
| 67 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes
); | |
| 68 supportedAttributes.add(SVGNames::x1Attr); | 65 supportedAttributes.add(SVGNames::x1Attr); |
| 69 supportedAttributes.add(SVGNames::x2Attr); | 66 supportedAttributes.add(SVGNames::x2Attr); |
| 70 supportedAttributes.add(SVGNames::y1Attr); | 67 supportedAttributes.add(SVGNames::y1Attr); |
| 71 supportedAttributes.add(SVGNames::y2Attr); | 68 supportedAttributes.add(SVGNames::y2Attr); |
| 72 } | 69 } |
| 73 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 70 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
| 74 } | 71 } |
| 75 | 72 |
| 76 void SVGLineElement::parseAttribute(const QualifiedName& name, const AtomicStrin
g& value) | 73 void SVGLineElement::parseAttribute(const QualifiedName& name, const AtomicStrin
g& value) |
| 77 { | 74 { |
| 78 SVGParsingError parseError = NoError; | 75 SVGParsingError parseError = NoError; |
| 79 | 76 |
| 80 if (!isSupportedAttribute(name)) | 77 if (!isSupportedAttribute(name)) |
| 81 SVGGeometryElement::parseAttribute(name, value); | 78 SVGGeometryElement::parseAttribute(name, value); |
| 82 else if (name == SVGNames::x1Attr) | 79 else if (name == SVGNames::x1Attr) |
| 83 setX1BaseValue(SVGLength::construct(LengthModeWidth, value, parseError))
; | 80 setX1BaseValue(SVGLength::construct(LengthModeWidth, value, parseError))
; |
| 84 else if (name == SVGNames::y1Attr) | 81 else if (name == SVGNames::y1Attr) |
| 85 setY1BaseValue(SVGLength::construct(LengthModeHeight, value, parseError)
); | 82 setY1BaseValue(SVGLength::construct(LengthModeHeight, value, parseError)
); |
| 86 else if (name == SVGNames::x2Attr) | 83 else if (name == SVGNames::x2Attr) |
| 87 setX2BaseValue(SVGLength::construct(LengthModeWidth, value, parseError))
; | 84 setX2BaseValue(SVGLength::construct(LengthModeWidth, value, parseError))
; |
| 88 else if (name == SVGNames::y2Attr) | 85 else if (name == SVGNames::y2Attr) |
| 89 setY2BaseValue(SVGLength::construct(LengthModeHeight, value, parseError)
); | 86 setY2BaseValue(SVGLength::construct(LengthModeHeight, value, parseError)
); |
| 90 else if (SVGExternalResourcesRequired::parseAttribute(name, value)) { | 87 else |
| 91 } else | |
| 92 ASSERT_NOT_REACHED(); | 88 ASSERT_NOT_REACHED(); |
| 93 | 89 |
| 94 reportAttributeParsingError(parseError, name, value); | 90 reportAttributeParsingError(parseError, name, value); |
| 95 } | 91 } |
| 96 | 92 |
| 97 void SVGLineElement::svgAttributeChanged(const QualifiedName& attrName) | 93 void SVGLineElement::svgAttributeChanged(const QualifiedName& attrName) |
| 98 { | 94 { |
| 99 if (!isSupportedAttribute(attrName)) { | 95 if (!isSupportedAttribute(attrName)) { |
| 100 SVGGeometryElement::svgAttributeChanged(attrName); | 96 SVGGeometryElement::svgAttributeChanged(attrName); |
| 101 return; | 97 return; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 114 RenderSVGShape* renderer = toRenderSVGShape(this->renderer()); | 110 RenderSVGShape* renderer = toRenderSVGShape(this->renderer()); |
| 115 if (!renderer) | 111 if (!renderer) |
| 116 return; | 112 return; |
| 117 | 113 |
| 118 if (isLengthAttribute) { | 114 if (isLengthAttribute) { |
| 119 renderer->setNeedsShapeUpdate(); | 115 renderer->setNeedsShapeUpdate(); |
| 120 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); | 116 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); |
| 121 return; | 117 return; |
| 122 } | 118 } |
| 123 | 119 |
| 124 if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) { | |
| 125 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); | |
| 126 return; | |
| 127 } | |
| 128 | |
| 129 ASSERT_NOT_REACHED(); | 120 ASSERT_NOT_REACHED(); |
| 130 } | 121 } |
| 131 | 122 |
| 132 bool SVGLineElement::selfHasRelativeLengths() const | 123 bool SVGLineElement::selfHasRelativeLengths() const |
| 133 { | 124 { |
| 134 return x1CurrentValue().isRelative() | 125 return x1CurrentValue().isRelative() |
| 135 || y1CurrentValue().isRelative() | 126 || y1CurrentValue().isRelative() |
| 136 || x2CurrentValue().isRelative() | 127 || x2CurrentValue().isRelative() |
| 137 || y2CurrentValue().isRelative(); | 128 || y2CurrentValue().isRelative(); |
| 138 } | 129 } |
| 139 | 130 |
| 140 } | 131 } |
| OLD | NEW |