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