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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 PassRefPtr<SVGLineElement> SVGLineElement::create(const QualifiedName& tagName,
Document* document) | 60 PassRefPtr<SVGLineElement> SVGLineElement::create(const QualifiedName& tagName,
Document* document) |
61 { | 61 { |
62 return adoptRef(new SVGLineElement(tagName, document)); | 62 return adoptRef(new SVGLineElement(tagName, document)); |
63 } | 63 } |
64 | 64 |
65 bool SVGLineElement::isSupportedAttribute(const QualifiedName& attrName) | 65 bool SVGLineElement::isSupportedAttribute(const QualifiedName& attrName) |
66 { | 66 { |
67 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | 67 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); |
68 if (supportedAttributes.isEmpty()) { | 68 if (supportedAttributes.isEmpty()) { |
69 SVGTests::addSupportedAttributes(supportedAttributes); | |
70 SVGLangSpace::addSupportedAttributes(supportedAttributes); | 69 SVGLangSpace::addSupportedAttributes(supportedAttributes); |
71 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes
); | 70 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes
); |
72 supportedAttributes.add(SVGNames::x1Attr); | 71 supportedAttributes.add(SVGNames::x1Attr); |
73 supportedAttributes.add(SVGNames::x2Attr); | 72 supportedAttributes.add(SVGNames::x2Attr); |
74 supportedAttributes.add(SVGNames::y1Attr); | 73 supportedAttributes.add(SVGNames::y1Attr); |
75 supportedAttributes.add(SVGNames::y2Attr); | 74 supportedAttributes.add(SVGNames::y2Attr); |
76 } | 75 } |
77 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 76 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
78 } | 77 } |
79 | 78 |
80 void SVGLineElement::parseAttribute(const QualifiedName& name, const AtomicStrin
g& value) | 79 void SVGLineElement::parseAttribute(const QualifiedName& name, const AtomicStrin
g& value) |
81 { | 80 { |
82 SVGParsingError parseError = NoError; | 81 SVGParsingError parseError = NoError; |
83 | 82 |
84 if (!isSupportedAttribute(name)) | 83 if (!isSupportedAttribute(name)) |
85 SVGGraphicsElement::parseAttribute(name, value); | 84 SVGGraphicsElement::parseAttribute(name, value); |
86 else if (name == SVGNames::x1Attr) | 85 else if (name == SVGNames::x1Attr) |
87 setX1BaseValue(SVGLength::construct(LengthModeWidth, value, parseError))
; | 86 setX1BaseValue(SVGLength::construct(LengthModeWidth, value, parseError))
; |
88 else if (name == SVGNames::y1Attr) | 87 else if (name == SVGNames::y1Attr) |
89 setY1BaseValue(SVGLength::construct(LengthModeHeight, value, parseError)
); | 88 setY1BaseValue(SVGLength::construct(LengthModeHeight, value, parseError)
); |
90 else if (name == SVGNames::x2Attr) | 89 else if (name == SVGNames::x2Attr) |
91 setX2BaseValue(SVGLength::construct(LengthModeWidth, value, parseError))
; | 90 setX2BaseValue(SVGLength::construct(LengthModeWidth, value, parseError))
; |
92 else if (name == SVGNames::y2Attr) | 91 else if (name == SVGNames::y2Attr) |
93 setY2BaseValue(SVGLength::construct(LengthModeHeight, value, parseError)
); | 92 setY2BaseValue(SVGLength::construct(LengthModeHeight, value, parseError)
); |
94 else if (SVGTests::parseAttribute(name, value) | 93 else if (SVGLangSpace::parseAttribute(name, value) |
95 || SVGLangSpace::parseAttribute(name, value) | |
96 || SVGExternalResourcesRequired::parseAttribute(name, value)) { | 94 || SVGExternalResourcesRequired::parseAttribute(name, value)) { |
97 } else | 95 } else |
98 ASSERT_NOT_REACHED(); | 96 ASSERT_NOT_REACHED(); |
99 | 97 |
100 reportAttributeParsingError(parseError, name, value); | 98 reportAttributeParsingError(parseError, name, value); |
101 } | 99 } |
102 | 100 |
103 void SVGLineElement::svgAttributeChanged(const QualifiedName& attrName) | 101 void SVGLineElement::svgAttributeChanged(const QualifiedName& attrName) |
104 { | 102 { |
105 if (!isSupportedAttribute(attrName)) { | 103 if (!isSupportedAttribute(attrName)) { |
106 SVGGraphicsElement::svgAttributeChanged(attrName); | 104 SVGGraphicsElement::svgAttributeChanged(attrName); |
107 return; | 105 return; |
108 } | 106 } |
109 | 107 |
110 SVGElementInstance::InvalidationGuard invalidationGuard(this); | 108 SVGElementInstance::InvalidationGuard invalidationGuard(this); |
111 | 109 |
112 bool isLengthAttribute = attrName == SVGNames::x1Attr | 110 bool isLengthAttribute = attrName == SVGNames::x1Attr |
113 || attrName == SVGNames::y1Attr | 111 || attrName == SVGNames::y1Attr |
114 || attrName == SVGNames::x2Attr | 112 || attrName == SVGNames::x2Attr |
115 || attrName == SVGNames::y2Attr; | 113 || attrName == SVGNames::y2Attr; |
116 | 114 |
117 if (isLengthAttribute) | 115 if (isLengthAttribute) |
118 updateRelativeLengthsInformation(); | 116 updateRelativeLengthsInformation(); |
119 | 117 |
120 if (SVGTests::handleAttributeChange(this, attrName)) | |
121 return; | |
122 | |
123 RenderSVGShape* renderer = toRenderSVGShape(this->renderer()); | 118 RenderSVGShape* renderer = toRenderSVGShape(this->renderer()); |
124 if (!renderer) | 119 if (!renderer) |
125 return; | 120 return; |
126 | 121 |
127 if (isLengthAttribute) { | 122 if (isLengthAttribute) { |
128 renderer->setNeedsShapeUpdate(); | 123 renderer->setNeedsShapeUpdate(); |
129 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); | 124 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); |
130 return; | 125 return; |
131 } | 126 } |
132 | 127 |
133 if (SVGLangSpace::isKnownAttribute(attrName) || SVGExternalResourcesRequired
::isKnownAttribute(attrName)) { | 128 if (SVGLangSpace::isKnownAttribute(attrName) || SVGExternalResourcesRequired
::isKnownAttribute(attrName)) { |
134 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); | 129 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); |
135 return; | 130 return; |
136 } | 131 } |
137 | 132 |
138 ASSERT_NOT_REACHED(); | 133 ASSERT_NOT_REACHED(); |
139 } | 134 } |
140 | 135 |
141 bool SVGLineElement::selfHasRelativeLengths() const | 136 bool SVGLineElement::selfHasRelativeLengths() const |
142 { | 137 { |
143 return x1().isRelative() | 138 return x1().isRelative() |
144 || y1().isRelative() | 139 || y1().isRelative() |
145 || x2().isRelative() | 140 || x2().isRelative() |
146 || y2().isRelative(); | 141 || y2().isRelative(); |
147 } | 142 } |
148 | 143 |
149 } | 144 } |
OLD | NEW |