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 19 matching lines...) Expand all Loading... |
30 | 30 |
31 namespace WebCore { | 31 namespace WebCore { |
32 | 32 |
33 // Animated property definitions | 33 // Animated property definitions |
34 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::xAttr, X, x) | 34 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::xAttr, X, x) |
35 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::yAttr, Y, y) | 35 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::yAttr, Y, y) |
36 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::widthAttr, Width, width) | 36 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::widthAttr, Width, width) |
37 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::heightAttr, Height, height) | 37 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::heightAttr, Height, height) |
38 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::rxAttr, Rx, rx) | 38 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::rxAttr, Rx, rx) |
39 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::ryAttr, Ry, ry) | 39 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::ryAttr, Ry, ry) |
40 DEFINE_ANIMATED_BOOLEAN(SVGRectElement, SVGNames::externalResourcesRequiredAttr,
ExternalResourcesRequired, externalResourcesRequired) | |
41 | 40 |
42 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGRectElement) | 41 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGRectElement) |
43 REGISTER_LOCAL_ANIMATED_PROPERTY(x) | 42 REGISTER_LOCAL_ANIMATED_PROPERTY(x) |
44 REGISTER_LOCAL_ANIMATED_PROPERTY(y) | 43 REGISTER_LOCAL_ANIMATED_PROPERTY(y) |
45 REGISTER_LOCAL_ANIMATED_PROPERTY(width) | 44 REGISTER_LOCAL_ANIMATED_PROPERTY(width) |
46 REGISTER_LOCAL_ANIMATED_PROPERTY(height) | 45 REGISTER_LOCAL_ANIMATED_PROPERTY(height) |
47 REGISTER_LOCAL_ANIMATED_PROPERTY(rx) | 46 REGISTER_LOCAL_ANIMATED_PROPERTY(rx) |
48 REGISTER_LOCAL_ANIMATED_PROPERTY(ry) | 47 REGISTER_LOCAL_ANIMATED_PROPERTY(ry) |
49 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) | |
50 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) | 48 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) |
51 END_REGISTER_ANIMATED_PROPERTIES | 49 END_REGISTER_ANIMATED_PROPERTIES |
52 | 50 |
53 inline SVGRectElement::SVGRectElement(const QualifiedName& tagName, Document& do
cument) | 51 inline SVGRectElement::SVGRectElement(const QualifiedName& tagName, Document& do
cument) |
54 : SVGGraphicsElement(tagName, document) | 52 : SVGGraphicsElement(tagName, document) |
55 , m_x(LengthModeWidth) | 53 , m_x(LengthModeWidth) |
56 , m_y(LengthModeHeight) | 54 , m_y(LengthModeHeight) |
57 , m_width(LengthModeWidth) | 55 , m_width(LengthModeWidth) |
58 , m_height(LengthModeHeight) | 56 , m_height(LengthModeHeight) |
59 , m_rx(LengthModeWidth) | 57 , m_rx(LengthModeWidth) |
60 , m_ry(LengthModeHeight) | 58 , m_ry(LengthModeHeight) |
61 { | 59 { |
62 ASSERT(hasTagName(SVGNames::rectTag)); | 60 ASSERT(hasTagName(SVGNames::rectTag)); |
63 ScriptWrappable::init(this); | 61 ScriptWrappable::init(this); |
64 registerAnimatedPropertiesForSVGRectElement(); | 62 registerAnimatedPropertiesForSVGRectElement(); |
65 } | 63 } |
66 | 64 |
67 PassRefPtr<SVGRectElement> SVGRectElement::create(const QualifiedName& tagName,
Document& document) | 65 PassRefPtr<SVGRectElement> SVGRectElement::create(const QualifiedName& tagName,
Document& document) |
68 { | 66 { |
69 return adoptRef(new SVGRectElement(tagName, document)); | 67 return adoptRef(new SVGRectElement(tagName, document)); |
70 } | 68 } |
71 | 69 |
72 bool SVGRectElement::isSupportedAttribute(const QualifiedName& attrName) | 70 bool SVGRectElement::isSupportedAttribute(const QualifiedName& attrName) |
73 { | 71 { |
74 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | 72 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); |
75 if (supportedAttributes.isEmpty()) { | 73 if (supportedAttributes.isEmpty()) { |
76 SVGLangSpace::addSupportedAttributes(supportedAttributes); | 74 SVGLangSpace::addSupportedAttributes(supportedAttributes); |
77 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes
); | |
78 supportedAttributes.add(SVGNames::xAttr); | 75 supportedAttributes.add(SVGNames::xAttr); |
79 supportedAttributes.add(SVGNames::yAttr); | 76 supportedAttributes.add(SVGNames::yAttr); |
80 supportedAttributes.add(SVGNames::widthAttr); | 77 supportedAttributes.add(SVGNames::widthAttr); |
81 supportedAttributes.add(SVGNames::heightAttr); | 78 supportedAttributes.add(SVGNames::heightAttr); |
82 supportedAttributes.add(SVGNames::rxAttr); | 79 supportedAttributes.add(SVGNames::rxAttr); |
83 supportedAttributes.add(SVGNames::ryAttr); | 80 supportedAttributes.add(SVGNames::ryAttr); |
84 } | 81 } |
85 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 82 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
86 } | 83 } |
87 | 84 |
88 void SVGRectElement::parseAttribute(const QualifiedName& name, const AtomicStrin
g& value) | 85 void SVGRectElement::parseAttribute(const QualifiedName& name, const AtomicStrin
g& value) |
89 { | 86 { |
90 SVGParsingError parseError = NoError; | 87 SVGParsingError parseError = NoError; |
91 | 88 |
92 if (!isSupportedAttribute(name)) | 89 if (!isSupportedAttribute(name)) |
93 SVGGraphicsElement::parseAttribute(name, value); | 90 SVGGraphicsElement::parseAttribute(name, value); |
94 else if (name == SVGNames::xAttr) | 91 else if (name == SVGNames::xAttr) |
95 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); | 92 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); |
96 else if (name == SVGNames::yAttr) | 93 else if (name == SVGNames::yAttr) |
97 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError))
; | 94 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError))
; |
98 else if (name == SVGNames::rxAttr) | 95 else if (name == SVGNames::rxAttr) |
99 setRxBaseValue(SVGLength::construct(LengthModeWidth, value, parseError,
ForbidNegativeLengths)); | 96 setRxBaseValue(SVGLength::construct(LengthModeWidth, value, parseError,
ForbidNegativeLengths)); |
100 else if (name == SVGNames::ryAttr) | 97 else if (name == SVGNames::ryAttr) |
101 setRyBaseValue(SVGLength::construct(LengthModeHeight, value, parseError,
ForbidNegativeLengths)); | 98 setRyBaseValue(SVGLength::construct(LengthModeHeight, value, parseError,
ForbidNegativeLengths)); |
102 else if (name == SVGNames::widthAttr) | 99 else if (name == SVGNames::widthAttr) |
103 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro
r, ForbidNegativeLengths)); | 100 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro
r, ForbidNegativeLengths)); |
104 else if (name == SVGNames::heightAttr) | 101 else if (name == SVGNames::heightAttr) |
105 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr
ror, ForbidNegativeLengths)); | 102 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr
ror, ForbidNegativeLengths)); |
106 else if (SVGLangSpace::parseAttribute(name, value) | 103 else if (SVGLangSpace::parseAttribute(name, value)) { |
107 || SVGExternalResourcesRequired::parseAttribute(name, value)) { | |
108 } else | 104 } else |
109 ASSERT_NOT_REACHED(); | 105 ASSERT_NOT_REACHED(); |
110 | 106 |
111 reportAttributeParsingError(parseError, name, value); | 107 reportAttributeParsingError(parseError, name, value); |
112 } | 108 } |
113 | 109 |
114 void SVGRectElement::svgAttributeChanged(const QualifiedName& attrName) | 110 void SVGRectElement::svgAttributeChanged(const QualifiedName& attrName) |
115 { | 111 { |
116 if (!isSupportedAttribute(attrName)) { | 112 if (!isSupportedAttribute(attrName)) { |
117 SVGGraphicsElement::svgAttributeChanged(attrName); | 113 SVGGraphicsElement::svgAttributeChanged(attrName); |
(...skipping 15 matching lines...) Expand all Loading... |
133 RenderSVGShape* renderer = toRenderSVGShape(this->renderer()); | 129 RenderSVGShape* renderer = toRenderSVGShape(this->renderer()); |
134 if (!renderer) | 130 if (!renderer) |
135 return; | 131 return; |
136 | 132 |
137 if (isLengthAttribute) { | 133 if (isLengthAttribute) { |
138 renderer->setNeedsShapeUpdate(); | 134 renderer->setNeedsShapeUpdate(); |
139 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); | 135 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); |
140 return; | 136 return; |
141 } | 137 } |
142 | 138 |
143 if (SVGLangSpace::isKnownAttribute(attrName) || SVGExternalResourcesRequired
::isKnownAttribute(attrName)) { | 139 if (SVGLangSpace::isKnownAttribute(attrName)) { |
144 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); | 140 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); |
145 return; | 141 return; |
146 } | 142 } |
147 | 143 |
148 ASSERT_NOT_REACHED(); | 144 ASSERT_NOT_REACHED(); |
149 } | 145 } |
150 | 146 |
151 bool SVGRectElement::selfHasRelativeLengths() const | 147 bool SVGRectElement::selfHasRelativeLengths() const |
152 { | 148 { |
153 return xCurrentValue().isRelative() | 149 return xCurrentValue().isRelative() |
154 || yCurrentValue().isRelative() | 150 || yCurrentValue().isRelative() |
155 || widthCurrentValue().isRelative() | 151 || widthCurrentValue().isRelative() |
156 || heightCurrentValue().isRelative() | 152 || heightCurrentValue().isRelative() |
157 || rxCurrentValue().isRelative() | 153 || rxCurrentValue().isRelative() |
158 || ryCurrentValue().isRelative(); | 154 || ryCurrentValue().isRelative(); |
159 } | 155 } |
160 | 156 |
161 RenderObject* SVGRectElement::createRenderer(RenderStyle*) | 157 RenderObject* SVGRectElement::createRenderer(RenderStyle*) |
162 { | 158 { |
163 return new RenderSVGRect(this); | 159 return new RenderSVGRect(this); |
164 } | 160 } |
165 | 161 |
166 } | 162 } |
OLD | NEW |