#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/ExceptionStatePlaceholder.h"
#include "core/editing/FrameSelection.h"
-#include "core/frame/Frame.h"
+#include "core/frame/LocalFrame.h"
#include "core/rendering/RenderObject.h"
#include "core/rendering/svg/RenderSVGResource.h"
#include "core/rendering/svg/SVGTextQuery.h"
namespace WebCore {
-// Animated property definitions
+template<> const SVGEnumerationStringEntries& getStaticStringEntries<SVGLengthAdjustType>()
+{
+ DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ());
+ if (entries.isEmpty()) {
+ entries.append(std::make_pair(SVGLengthAdjustSpacing, "spacing"));
+ entries.append(std::make_pair(SVGLengthAdjustSpacingAndGlyphs, "spacingAndGlyphs"));
+ }
+ return entries;
+}
// SVGTextContentElement's 'textLength' attribute needs special handling.
// It should return getComputedTextLength() when textLength is not specified manually.
private:
SVGAnimatedTextLength(SVGTextContentElement* contextElement)
- : SVGAnimatedLength(contextElement, SVGNames::textLengthAttr, SVGLength::create(LengthModeOther))
+ : SVGAnimatedLength(contextElement, SVGNames::textLengthAttr, SVGLength::create(LengthModeOther), ForbidNegativeLengths)
{
}
};
-DEFINE_ANIMATED_ENUMERATION(SVGTextContentElement, SVGNames::lengthAdjustAttr, LengthAdjust, lengthAdjust, SVGLengthAdjustType)
-
-BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGTextContentElement)
- REGISTER_LOCAL_ANIMATED_PROPERTY(lengthAdjust)
- REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement)
-END_REGISTER_ANIMATED_PROPERTIES
SVGTextContentElement::SVGTextContentElement(const QualifiedName& tagName, Document& document)
: SVGGraphicsElement(tagName, document)
, m_textLength(SVGAnimatedTextLength::create(this))
, m_textLengthIsSpecifiedByUser(false)
- , m_lengthAdjust(SVGLengthAdjustSpacing)
+ , m_lengthAdjust(SVGAnimatedEnumeration<SVGLengthAdjustType>::create(this, SVGNames::lengthAdjustAttr, SVGLengthAdjustSpacing))
{
ScriptWrappable::init(this);
addToPropertyMap(m_textLength);
- registerAnimatedPropertiesForSVGTextContentElement();
+ addToPropertyMap(m_lengthAdjust);
}
unsigned SVGTextContentElement::getNumberOfChars()
if (charnum > getNumberOfChars()) {
exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::indexExceedsMaximumBound("charnum", charnum, getNumberOfChars()));
- return 0;
+ return nullptr;
}
FloatPoint point = SVGTextQuery(renderer()).startPositionOfCharacter(charnum);
if (charnum > getNumberOfChars()) {
exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::indexExceedsMaximumBound("charnum", charnum, getNumberOfChars()));
- return 0;
+ return nullptr;
}
FloatPoint point = SVGTextQuery(renderer()).endPositionOfCharacter(charnum);
if (charnum > getNumberOfChars()) {
exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::indexExceedsMaximumBound("charnum", charnum, getNumberOfChars()));
- return 0;
+ return nullptr;
}
FloatRect rect = SVGTextQuery(renderer()).extentOfCharacter(charnum);
if (!isSupportedAttribute(name))
SVGGraphicsElement::parseAttribute(name, value);
else if (name == SVGNames::lengthAdjustAttr) {
- SVGLengthAdjustType propertyValue = SVGPropertyTraits<SVGLengthAdjustType>::fromString(value);
- if (propertyValue > 0)
- setLengthAdjustBaseValue(propertyValue);
+ m_lengthAdjust->setBaseValueAsString(value, parseError);
} else if (name == SVGNames::textLengthAttr) {
- m_textLength->setBaseValueAsString(value, ForbidNegativeLengths, parseError);
+ m_textLength->setBaseValueAsString(value, parseError);
} else if (name.matches(XMLNames::spaceAttr)) {
} else
ASSERT_NOT_REACHED();
SVGElement* element = toSVGElement(renderer->node());
ASSERT(element);
-
- if (!element->isTextContent())
- return 0;
-
- return toSVGTextContentElement(element);
+ return isSVGTextContentElement(*element) ? toSVGTextContentElement(element) : 0;
}
}