| 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 23 matching lines...) Expand all Loading... |
| 34 DEFINE_ANIMATED_ENUMERATION(SVGTextPathElement, SVGNames::spacingAttr, Spacing,
spacing, SVGTextPathSpacingType) | 34 DEFINE_ANIMATED_ENUMERATION(SVGTextPathElement, SVGNames::spacingAttr, Spacing,
spacing, SVGTextPathSpacingType) |
| 35 | 35 |
| 36 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGTextPathElement) | 36 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGTextPathElement) |
| 37 REGISTER_LOCAL_ANIMATED_PROPERTY(method) | 37 REGISTER_LOCAL_ANIMATED_PROPERTY(method) |
| 38 REGISTER_LOCAL_ANIMATED_PROPERTY(spacing) | 38 REGISTER_LOCAL_ANIMATED_PROPERTY(spacing) |
| 39 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTextContentElement) | 39 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTextContentElement) |
| 40 END_REGISTER_ANIMATED_PROPERTIES | 40 END_REGISTER_ANIMATED_PROPERTIES |
| 41 | 41 |
| 42 inline SVGTextPathElement::SVGTextPathElement(Document& document) | 42 inline SVGTextPathElement::SVGTextPathElement(Document& document) |
| 43 : SVGTextContentElement(SVGNames::textPathTag, document) | 43 : SVGTextContentElement(SVGNames::textPathTag, document) |
| 44 , SVGURIReference(this) |
| 44 , m_startOffset(SVGAnimatedLength::create(this, SVGNames::startOffsetAttr, S
VGLength::create(LengthModeOther))) | 45 , m_startOffset(SVGAnimatedLength::create(this, SVGNames::startOffsetAttr, S
VGLength::create(LengthModeOther))) |
| 45 , m_href(SVGAnimatedString::create(this, XLinkNames::hrefAttr, SVGString::cr
eate())) | |
| 46 , m_method(SVGTextPathMethodAlign) | 46 , m_method(SVGTextPathMethodAlign) |
| 47 , m_spacing(SVGTextPathSpacingExact) | 47 , m_spacing(SVGTextPathSpacingExact) |
| 48 { | 48 { |
| 49 ScriptWrappable::init(this); | 49 ScriptWrappable::init(this); |
| 50 | 50 |
| 51 addToPropertyMap(m_startOffset); | 51 addToPropertyMap(m_startOffset); |
| 52 addToPropertyMap(m_href); | |
| 53 registerAnimatedPropertiesForSVGTextPathElement(); | 52 registerAnimatedPropertiesForSVGTextPathElement(); |
| 54 } | 53 } |
| 55 | 54 |
| 56 PassRefPtr<SVGTextPathElement> SVGTextPathElement::create(Document& document) | 55 PassRefPtr<SVGTextPathElement> SVGTextPathElement::create(Document& document) |
| 57 { | 56 { |
| 58 return adoptRef(new SVGTextPathElement(document)); | 57 return adoptRef(new SVGTextPathElement(document)); |
| 59 } | 58 } |
| 60 | 59 |
| 61 SVGTextPathElement::~SVGTextPathElement() | 60 SVGTextPathElement::~SVGTextPathElement() |
| 62 { | 61 { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 77 supportedAttributes.add(SVGNames::methodAttr); | 76 supportedAttributes.add(SVGNames::methodAttr); |
| 78 supportedAttributes.add(SVGNames::spacingAttr); | 77 supportedAttributes.add(SVGNames::spacingAttr); |
| 79 } | 78 } |
| 80 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 79 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
| 81 } | 80 } |
| 82 | 81 |
| 83 void SVGTextPathElement::parseAttribute(const QualifiedName& name, const AtomicS
tring& value) | 82 void SVGTextPathElement::parseAttribute(const QualifiedName& name, const AtomicS
tring& value) |
| 84 { | 83 { |
| 85 SVGParsingError parseError = NoError; | 84 SVGParsingError parseError = NoError; |
| 86 | 85 |
| 87 if (!isSupportedAttribute(name)) | 86 if (!isSupportedAttribute(name)) { |
| 88 SVGTextContentElement::parseAttribute(name, value); | 87 SVGTextContentElement::parseAttribute(name, value); |
| 89 else if (name == SVGNames::startOffsetAttr) | 88 } else if (name == SVGNames::startOffsetAttr) { |
| 90 m_startOffset->setBaseValueAsString(value, AllowNegativeLengths, parseEr
ror); | 89 m_startOffset->setBaseValueAsString(value, AllowNegativeLengths, parseEr
ror); |
| 91 else if (name == SVGNames::methodAttr) { | 90 } else if (name == SVGNames::methodAttr) { |
| 92 SVGTextPathMethodType propertyValue = SVGPropertyTraits<SVGTextPathMetho
dType>::fromString(value); | 91 SVGTextPathMethodType propertyValue = SVGPropertyTraits<SVGTextPathMetho
dType>::fromString(value); |
| 93 if (propertyValue > 0) | 92 if (propertyValue > 0) |
| 94 setMethodBaseValue(propertyValue); | 93 setMethodBaseValue(propertyValue); |
| 95 } else if (name == SVGNames::spacingAttr) { | 94 } else if (name == SVGNames::spacingAttr) { |
| 96 SVGTextPathSpacingType propertyValue = SVGPropertyTraits<SVGTextPathSpac
ingType>::fromString(value); | 95 SVGTextPathSpacingType propertyValue = SVGPropertyTraits<SVGTextPathSpac
ingType>::fromString(value); |
| 97 if (propertyValue > 0) | 96 if (propertyValue > 0) |
| 98 setSpacingBaseValue(propertyValue); | 97 setSpacingBaseValue(propertyValue); |
| 99 } else if (name.matches(XLinkNames::hrefAttr)) { | 98 } else if (SVGURIReference::parseAttribute(name, value, parseError)) { |
| 100 m_href->setBaseValueAsString(value, parseError); | 99 } else { |
| 101 } else | |
| 102 ASSERT_NOT_REACHED(); | 100 ASSERT_NOT_REACHED(); |
| 101 } |
| 103 | 102 |
| 104 reportAttributeParsingError(parseError, name, value); | 103 reportAttributeParsingError(parseError, name, value); |
| 105 } | 104 } |
| 106 | 105 |
| 107 void SVGTextPathElement::svgAttributeChanged(const QualifiedName& attrName) | 106 void SVGTextPathElement::svgAttributeChanged(const QualifiedName& attrName) |
| 108 { | 107 { |
| 109 if (!isSupportedAttribute(attrName)) { | 108 if (!isSupportedAttribute(attrName)) { |
| 110 SVGTextContentElement::svgAttributeChanged(attrName); | 109 SVGTextContentElement::svgAttributeChanged(attrName); |
| 111 return; | 110 return; |
| 112 } | 111 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 140 return false; | 139 return false; |
| 141 } | 140 } |
| 142 | 141 |
| 143 void SVGTextPathElement::buildPendingResource() | 142 void SVGTextPathElement::buildPendingResource() |
| 144 { | 143 { |
| 145 clearResourceReferences(); | 144 clearResourceReferences(); |
| 146 if (!inDocument()) | 145 if (!inDocument()) |
| 147 return; | 146 return; |
| 148 | 147 |
| 149 AtomicString id; | 148 AtomicString id; |
| 150 Element* target = SVGURIReference::targetElementFromIRIString(m_href->curren
tValue()->value(), document(), &id); | 149 Element* target = SVGURIReference::targetElementFromIRIString(hrefString(),
document(), &id); |
| 151 if (!target) { | 150 if (!target) { |
| 152 // Do not register as pending if we are already pending this resource. | 151 // Do not register as pending if we are already pending this resource. |
| 153 if (document().accessSVGExtensions()->isElementPendingResource(this, id)
) | 152 if (document().accessSVGExtensions()->isElementPendingResource(this, id)
) |
| 154 return; | 153 return; |
| 155 | 154 |
| 156 if (!id.isEmpty()) { | 155 if (!id.isEmpty()) { |
| 157 document().accessSVGExtensions()->addPendingResource(id, this); | 156 document().accessSVGExtensions()->addPendingResource(id, this); |
| 158 ASSERT(hasPendingResources()); | 157 ASSERT(hasPendingResources()); |
| 159 } | 158 } |
| 160 } else if (target->hasTagName(SVGNames::pathTag)) { | 159 } else if (target->hasTagName(SVGNames::pathTag)) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 178 clearResourceReferences(); | 177 clearResourceReferences(); |
| 179 } | 178 } |
| 180 | 179 |
| 181 bool SVGTextPathElement::selfHasRelativeLengths() const | 180 bool SVGTextPathElement::selfHasRelativeLengths() const |
| 182 { | 181 { |
| 183 return m_startOffset->currentValue()->isRelative() | 182 return m_startOffset->currentValue()->isRelative() |
| 184 || SVGTextContentElement::selfHasRelativeLengths(); | 183 || SVGTextContentElement::selfHasRelativeLengths(); |
| 185 } | 184 } |
| 186 | 185 |
| 187 } | 186 } |
| OLD | NEW |