OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2010 Rob Buis <rwlbuis@gmail.com> | 3 * Copyright (C) 2010 Rob Buis <rwlbuis@gmail.com> |
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 14 matching lines...) Expand all Loading... |
25 #include "XLinkNames.h" | 25 #include "XLinkNames.h" |
26 #include "core/rendering/svg/RenderSVGResource.h" | 26 #include "core/rendering/svg/RenderSVGResource.h" |
27 #include "core/rendering/svg/RenderSVGTextPath.h" | 27 #include "core/rendering/svg/RenderSVGTextPath.h" |
28 #include "core/svg/SVGElementInstance.h" | 28 #include "core/svg/SVGElementInstance.h" |
29 | 29 |
30 namespace WebCore { | 30 namespace WebCore { |
31 | 31 |
32 // Animated property definitions | 32 // Animated property definitions |
33 DEFINE_ANIMATED_ENUMERATION(SVGTextPathElement, SVGNames::methodAttr, Method, me
thod, SVGTextPathMethodType) | 33 DEFINE_ANIMATED_ENUMERATION(SVGTextPathElement, SVGNames::methodAttr, Method, me
thod, SVGTextPathMethodType) |
34 DEFINE_ANIMATED_ENUMERATION(SVGTextPathElement, SVGNames::spacingAttr, Spacing,
spacing, SVGTextPathSpacingType) | 34 DEFINE_ANIMATED_ENUMERATION(SVGTextPathElement, SVGNames::spacingAttr, Spacing,
spacing, SVGTextPathSpacingType) |
35 DEFINE_ANIMATED_STRING(SVGTextPathElement, XLinkNames::hrefAttr, Href, href) | |
36 | 35 |
37 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGTextPathElement) | 36 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGTextPathElement) |
38 REGISTER_LOCAL_ANIMATED_PROPERTY(method) | 37 REGISTER_LOCAL_ANIMATED_PROPERTY(method) |
39 REGISTER_LOCAL_ANIMATED_PROPERTY(spacing) | 38 REGISTER_LOCAL_ANIMATED_PROPERTY(spacing) |
40 REGISTER_LOCAL_ANIMATED_PROPERTY(href) | |
41 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTextContentElement) | 39 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTextContentElement) |
42 END_REGISTER_ANIMATED_PROPERTIES | 40 END_REGISTER_ANIMATED_PROPERTIES |
43 | 41 |
44 inline SVGTextPathElement::SVGTextPathElement(Document& document) | 42 inline SVGTextPathElement::SVGTextPathElement(Document& document) |
45 : SVGTextContentElement(SVGNames::textPathTag, document) | 43 : SVGTextContentElement(SVGNames::textPathTag, document) |
46 , m_startOffset(SVGAnimatedLength::create(this, SVGNames::startOffsetAttr, S
VGLength::create(LengthModeOther))) | 44 , m_startOffset(SVGAnimatedLength::create(this, SVGNames::startOffsetAttr, S
VGLength::create(LengthModeOther))) |
| 45 , m_href(SVGAnimatedString::create(this, XLinkNames::hrefAttr, SVGString::cr
eate())) |
47 , m_method(SVGTextPathMethodAlign) | 46 , m_method(SVGTextPathMethodAlign) |
48 , m_spacing(SVGTextPathSpacingExact) | 47 , m_spacing(SVGTextPathSpacingExact) |
49 { | 48 { |
50 ScriptWrappable::init(this); | 49 ScriptWrappable::init(this); |
51 | 50 |
52 addToPropertyMap(m_startOffset); | 51 addToPropertyMap(m_startOffset); |
| 52 addToPropertyMap(m_href); |
53 registerAnimatedPropertiesForSVGTextPathElement(); | 53 registerAnimatedPropertiesForSVGTextPathElement(); |
54 } | 54 } |
55 | 55 |
56 PassRefPtr<SVGTextPathElement> SVGTextPathElement::create(Document& document) | 56 PassRefPtr<SVGTextPathElement> SVGTextPathElement::create(Document& document) |
57 { | 57 { |
58 return adoptRef(new SVGTextPathElement(document)); | 58 return adoptRef(new SVGTextPathElement(document)); |
59 } | 59 } |
60 | 60 |
61 SVGTextPathElement::~SVGTextPathElement() | 61 SVGTextPathElement::~SVGTextPathElement() |
62 { | 62 { |
(...skipping 26 matching lines...) Expand all Loading... |
89 else if (name == SVGNames::startOffsetAttr) | 89 else if (name == SVGNames::startOffsetAttr) |
90 m_startOffset->setBaseValueAsString(value, AllowNegativeLengths, parseEr
ror); | 90 m_startOffset->setBaseValueAsString(value, AllowNegativeLengths, parseEr
ror); |
91 else if (name == SVGNames::methodAttr) { | 91 else if (name == SVGNames::methodAttr) { |
92 SVGTextPathMethodType propertyValue = SVGPropertyTraits<SVGTextPathMetho
dType>::fromString(value); | 92 SVGTextPathMethodType propertyValue = SVGPropertyTraits<SVGTextPathMetho
dType>::fromString(value); |
93 if (propertyValue > 0) | 93 if (propertyValue > 0) |
94 setMethodBaseValue(propertyValue); | 94 setMethodBaseValue(propertyValue); |
95 } else if (name == SVGNames::spacingAttr) { | 95 } else if (name == SVGNames::spacingAttr) { |
96 SVGTextPathSpacingType propertyValue = SVGPropertyTraits<SVGTextPathSpac
ingType>::fromString(value); | 96 SVGTextPathSpacingType propertyValue = SVGPropertyTraits<SVGTextPathSpac
ingType>::fromString(value); |
97 if (propertyValue > 0) | 97 if (propertyValue > 0) |
98 setSpacingBaseValue(propertyValue); | 98 setSpacingBaseValue(propertyValue); |
99 } else if (SVGURIReference::parseAttribute(name, value)) { | 99 } else if (name.matches(XLinkNames::hrefAttr)) { |
| 100 m_href->setBaseValueAsString(value, parseError); |
100 } else | 101 } else |
101 ASSERT_NOT_REACHED(); | 102 ASSERT_NOT_REACHED(); |
102 | 103 |
103 reportAttributeParsingError(parseError, name, value); | 104 reportAttributeParsingError(parseError, name, value); |
104 } | 105 } |
105 | 106 |
106 void SVGTextPathElement::svgAttributeChanged(const QualifiedName& attrName) | 107 void SVGTextPathElement::svgAttributeChanged(const QualifiedName& attrName) |
107 { | 108 { |
108 if (!isSupportedAttribute(attrName)) { | 109 if (!isSupportedAttribute(attrName)) { |
109 SVGTextContentElement::svgAttributeChanged(attrName); | 110 SVGTextContentElement::svgAttributeChanged(attrName); |
(...skipping 29 matching lines...) Expand all Loading... |
139 return false; | 140 return false; |
140 } | 141 } |
141 | 142 |
142 void SVGTextPathElement::buildPendingResource() | 143 void SVGTextPathElement::buildPendingResource() |
143 { | 144 { |
144 clearResourceReferences(); | 145 clearResourceReferences(); |
145 if (!inDocument()) | 146 if (!inDocument()) |
146 return; | 147 return; |
147 | 148 |
148 AtomicString id; | 149 AtomicString id; |
149 Element* target = SVGURIReference::targetElementFromIRIString(hrefCurrentVal
ue(), document(), &id); | 150 Element* target = SVGURIReference::targetElementFromIRIString(m_href->curren
tValue()->value(), document(), &id); |
150 if (!target) { | 151 if (!target) { |
151 // Do not register as pending if we are already pending this resource. | 152 // Do not register as pending if we are already pending this resource. |
152 if (document().accessSVGExtensions()->isElementPendingResource(this, id)
) | 153 if (document().accessSVGExtensions()->isElementPendingResource(this, id)
) |
153 return; | 154 return; |
154 | 155 |
155 if (!id.isEmpty()) { | 156 if (!id.isEmpty()) { |
156 document().accessSVGExtensions()->addPendingResource(id, this); | 157 document().accessSVGExtensions()->addPendingResource(id, this); |
157 ASSERT(hasPendingResources()); | 158 ASSERT(hasPendingResources()); |
158 } | 159 } |
159 } else if (target->hasTagName(SVGNames::pathTag)) { | 160 } else if (target->hasTagName(SVGNames::pathTag)) { |
(...skipping 17 matching lines...) Expand all Loading... |
177 clearResourceReferences(); | 178 clearResourceReferences(); |
178 } | 179 } |
179 | 180 |
180 bool SVGTextPathElement::selfHasRelativeLengths() const | 181 bool SVGTextPathElement::selfHasRelativeLengths() const |
181 { | 182 { |
182 return m_startOffset->currentValue()->isRelative() | 183 return m_startOffset->currentValue()->isRelative() |
183 || SVGTextContentElement::selfHasRelativeLengths(); | 184 || SVGTextContentElement::selfHasRelativeLengths(); |
184 } | 185 } |
185 | 186 |
186 } | 187 } |
OLD | NEW |