#include "config.h"
#include "core/svg/SVGTextContentElement.h"
-#include "CSSPropertyNames.h"
-#include "CSSValueKeywords.h"
-#include "SVGNames.h"
-#include "XMLNames.h"
-#include "bindings/v8/ExceptionMessages.h"
-#include "bindings/v8/ExceptionState.h"
-#include "bindings/v8/ExceptionStatePlaceholder.h"
+#include "bindings/core/v8/ExceptionMessages.h"
+#include "bindings/core/v8/ExceptionState.h"
+#include "bindings/core/v8/ExceptionStatePlaceholder.h"
+#include "core/CSSPropertyNames.h"
+#include "core/CSSValueKeywords.h"
+#include "core/SVGNames.h"
+#include "core/XMLNames.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"
-#include "core/svg/SVGElementInstance.h"
-namespace WebCore {
+namespace blink {
-// 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.
-class SVGAnimatedTextLength FINAL : public SVGAnimatedLength {
+class SVGAnimatedTextLength final : public SVGAnimatedLength {
public:
static PassRefPtr<SVGAnimatedTextLength> create(SVGTextContentElement* contextElement)
{
return adoptRef(new SVGAnimatedTextLength(contextElement));
}
- virtual SVGLengthTearOff* baseVal() OVERRIDE
+ virtual SVGLengthTearOff* baseVal() override
{
SVGTextContentElement* textContentElement = toSVGTextContentElement(contextElement());
if (!textContentElement->textLengthIsSpecifiedByUser())
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);
void SVGTextContentElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
- SVGParsingError parseError = NoError;
-
- if (!isSupportedAttribute(name))
- SVGGraphicsElement::parseAttribute(name, value);
- else if (name == SVGNames::lengthAdjustAttr) {
- SVGLengthAdjustType propertyValue = SVGPropertyTraits<SVGLengthAdjustType>::fromString(value);
- if (propertyValue > 0)
- setLengthAdjustBaseValue(propertyValue);
- } else if (name == SVGNames::textLengthAttr) {
- m_textLength->setBaseValueAsString(value, ForbidNegativeLengths, parseError);
- } else if (name.matches(XMLNames::spaceAttr)) {
- } else
- ASSERT_NOT_REACHED();
-
- reportAttributeParsingError(parseError, name, value);
+ parseAttributeNew(name, value);
}
void SVGTextContentElement::svgAttributeChanged(const QualifiedName& attrName)
if (attrName == SVGNames::textLengthAttr)
m_textLengthIsSpecifiedByUser = true;
- SVGElementInstance::InvalidationGuard invalidationGuard(this);
+ SVGElement::InvalidationGuard invalidationGuard(this);
if (RenderObject* renderer = this->renderer())
- RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
+ markForLayoutAndParentResourceInvalidation(renderer);
}
bool SVGTextContentElement::selfHasRelativeLengths() const
SVGElement* element = toSVGElement(renderer->node());
ASSERT(element);
-
- if (!element->isTextContent())
- return 0;
-
- return toSVGTextContentElement(element);
+ return isSVGTextContentElement(*element) ? toSVGTextContentElement(element) : 0;
}
}