diff options
author | Ben Murdoch <benm@google.com> | 2011-06-02 12:07:03 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-10 10:47:21 +0100 |
commit | 2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 (patch) | |
tree | e4964fbd1cb70599f7718ff03e50ea1dab33890b /Source/WebCore/svg/SVGTextContentElement.cpp | |
parent | 87bdf0060a247bfbe668342b87e0874182e0ffa9 (diff) | |
download | external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.zip external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.gz external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.bz2 |
Merge WebKit at r84325: Initial merge by git.
Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b
Diffstat (limited to 'Source/WebCore/svg/SVGTextContentElement.cpp')
-rw-r--r-- | Source/WebCore/svg/SVGTextContentElement.cpp | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/Source/WebCore/svg/SVGTextContentElement.cpp b/Source/WebCore/svg/SVGTextContentElement.cpp index a719c28..4021b4f 100644 --- a/Source/WebCore/svg/SVGTextContentElement.cpp +++ b/Source/WebCore/svg/SVGTextContentElement.cpp @@ -27,6 +27,7 @@ #include "CSSValueKeywords.h" #include "Frame.h" #include "RenderObject.h" +#include "RenderSVGResource.h" #include "SVGDocumentExtensions.h" #include "SVGNames.h" #include "SVGTextQuery.h" @@ -36,17 +37,38 @@ namespace WebCore { // Animated property definitions -DEFINE_ANIMATED_LENGTH(SVGTextContentElement, SVGNames::textLengthAttr, TextLength, textLength) DEFINE_ANIMATED_ENUMERATION(SVGTextContentElement, SVGNames::lengthAdjustAttr, LengthAdjust, lengthAdjust) DEFINE_ANIMATED_BOOLEAN(SVGTextContentElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired) SVGTextContentElement::SVGTextContentElement(const QualifiedName& tagName, Document* document) : SVGStyledElement(tagName, document) + , m_specifiedTextLength(LengthModeOther) , m_textLength(LengthModeOther) , m_lengthAdjust(LENGTHADJUST_SPACING) { } +void SVGTextContentElement::synchronizeTextLength() +{ + if (!m_textLength.shouldSynchronize) + return; + AtomicString value(SVGPropertyTraits<SVGLength>::toString(m_specifiedTextLength)); + SVGAnimatedPropertySynchronizer<true>::synchronize(this, SVGNames::textLengthAttr, value); +} + +PassRefPtr<SVGAnimatedLength> SVGTextContentElement::textLengthAnimated() +{ + DEFINE_STATIC_LOCAL(SVGLength, defaultTextLength, (LengthModeOther)); + if (m_specifiedTextLength == defaultTextLength) { + ExceptionCode ec = 0; + m_textLength.value.newValueSpecifiedUnits(LengthTypeNumber, getComputedTextLength(), ec); + ASSERT(!ec); + } + + m_textLength.shouldSynchronize = true; + return SVGAnimatedProperty::lookupOrCreateWrapper<SVGAnimatedLength, SVGLength>(this, SVGNames::textLengthAttr, SVGNames::textLengthAttr.localName(), m_textLength.value); +} + unsigned SVGTextContentElement::getNumberOfChars() const { document()->updateLayoutIgnorePendingStylesheets(); @@ -165,8 +187,8 @@ void SVGTextContentElement::parseMappedAttribute(Attribute* attr) else if (attr->value() == "spacingAndGlyphs") setLengthAdjustBaseValue(LENGTHADJUST_SPACINGANDGLYPHS); } else if (attr->name() == SVGNames::textLengthAttr) { - setTextLengthBaseValue(SVGLength(LengthModeOther, attr->value())); - if (textLengthBaseValue().value(this) < 0.0) + m_textLength.value = SVGLength(LengthModeOther, attr->value()); + if (m_textLength.value.value(this) < 0) document()->accessSVGExtensions()->reportError("A negative value for text attribute <textLength> is not allowed"); } else { if (SVGTests::parseMappedAttribute(attr)) @@ -218,7 +240,16 @@ void SVGTextContentElement::svgAttributeChanged(const QualifiedName& attrName) if (SVGTests::handleAttributeChange(this, attrName)) return; - // FIXME: also handle attribute changes for lengthAdjust and textLength + if (attrName == SVGNames::textLengthAttr) + m_specifiedTextLength = m_textLength.value; + + RenderObject* renderer = this->renderer(); + if (!renderer) + return; + + if (attrName == SVGNames::textLengthAttr + || attrName == SVGNames::lengthAdjustAttr) + RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); } void SVGTextContentElement::fillPassedAttributeToPropertyTypeMap(AttributeToPropertyTypeMap& attributeToPropertyTypeMap) @@ -229,15 +260,6 @@ void SVGTextContentElement::fillPassedAttributeToPropertyTypeMap(AttributeToProp attributeToPropertyTypeMap.set(SVGNames::lengthAdjustAttr, AnimatedEnumeration); } -bool SVGTextContentElement::isKnownAttribute(const QualifiedName& attrName) -{ - return attrName.matches(SVGNames::lengthAdjustAttr) - || attrName.matches(SVGNames::textLengthAttr) - || SVGLangSpace::isKnownAttribute(attrName) - || SVGExternalResourcesRequired::isKnownAttribute(attrName) - || SVGStyledElement::isKnownAttribute(attrName); -} - bool SVGTextContentElement::selfHasRelativeLengths() const { // Any element of the <text> subtree is advertized as using relative lengths. |