summaryrefslogtreecommitdiff
path: root/Source/WebCore/svg/SVGTextPositioningElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/svg/SVGTextPositioningElement.cpp')
-rw-r--r--Source/WebCore/svg/SVGTextPositioningElement.cpp114
1 files changed, 48 insertions, 66 deletions
diff --git a/Source/WebCore/svg/SVGTextPositioningElement.cpp b/Source/WebCore/svg/SVGTextPositioningElement.cpp
index 82e7063c5..c3678b4ee 100644
--- a/Source/WebCore/svg/SVGTextPositioningElement.cpp
+++ b/Source/WebCore/svg/SVGTextPositioningElement.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
* Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org>
+ * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -19,17 +20,18 @@
*/
#include "config.h"
-
-#if ENABLE(SVG)
#include "SVGTextPositioningElement.h"
-#include "Attribute.h"
+#include "RenderSVGInline.h"
#include "RenderSVGResource.h"
#include "RenderSVGText.h"
-#include "SVGElementInstance.h"
-#include "SVGLengthList.h"
+#include "SVGAltGlyphElement.h"
+#include "SVGLengthListValues.h"
#include "SVGNames.h"
-#include "SVGNumberList.h"
+#include "SVGNumberListValues.h"
+#include "SVGTRefElement.h"
+#include "SVGTSpanElement.h"
+#include "SVGTextElement.h"
namespace WebCore {
@@ -55,28 +57,10 @@ SVGTextPositioningElement::SVGTextPositioningElement(const QualifiedName& tagNam
registerAnimatedPropertiesForSVGTextPositioningElement();
}
-bool SVGTextPositioningElement::isSupportedAttribute(const QualifiedName& attrName)
-{
- DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
- if (supportedAttributes.isEmpty()) {
- supportedAttributes.add(SVGNames::xAttr);
- supportedAttributes.add(SVGNames::yAttr);
- supportedAttributes.add(SVGNames::dxAttr);
- supportedAttributes.add(SVGNames::dyAttr);
- supportedAttributes.add(SVGNames::rotateAttr);
- }
- return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
-}
-
void SVGTextPositioningElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
- if (!isSupportedAttribute(name)) {
- SVGTextContentElement::parseAttribute(name, value);
- return;
- }
-
if (name == SVGNames::xAttr) {
- SVGLengthList newList;
+ SVGLengthListValues newList;
newList.parse(value, LengthModeWidth);
detachAnimatedXListWrappers(newList.size());
setXBaseValue(newList);
@@ -84,7 +68,7 @@ void SVGTextPositioningElement::parseAttribute(const QualifiedName& name, const
}
if (name == SVGNames::yAttr) {
- SVGLengthList newList;
+ SVGLengthListValues newList;
newList.parse(value, LengthModeHeight);
detachAnimatedYListWrappers(newList.size());
setYBaseValue(newList);
@@ -92,7 +76,7 @@ void SVGTextPositioningElement::parseAttribute(const QualifiedName& name, const
}
if (name == SVGNames::dxAttr) {
- SVGLengthList newList;
+ SVGLengthListValues newList;
newList.parse(value, LengthModeWidth);
detachAnimatedDxListWrappers(newList.size());
setDxBaseValue(newList);
@@ -100,7 +84,7 @@ void SVGTextPositioningElement::parseAttribute(const QualifiedName& name, const
}
if (name == SVGNames::dyAttr) {
- SVGLengthList newList;
+ SVGLengthListValues newList;
newList.parse(value, LengthModeHeight);
detachAnimatedDyListWrappers(newList.size());
setDyBaseValue(newList);
@@ -108,70 +92,68 @@ void SVGTextPositioningElement::parseAttribute(const QualifiedName& name, const
}
if (name == SVGNames::rotateAttr) {
- SVGNumberList newList;
+ SVGNumberListValues newList;
newList.parse(value);
detachAnimatedRotateListWrappers(newList.size());
setRotateBaseValue(newList);
return;
}
- ASSERT_NOT_REACHED();
+ SVGTextContentElement::parseAttribute(name, value);
}
-void SVGTextPositioningElement::svgAttributeChanged(const QualifiedName& attrName)
+void SVGTextPositioningElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStyleProperties& style)
{
- if (!isSupportedAttribute(attrName)) {
- SVGTextContentElement::svgAttributeChanged(attrName);
+ if (name == SVGNames::xAttr || name == SVGNames::yAttr)
return;
- }
+ SVGTextContentElement::collectStyleForPresentationAttribute(name, value, style);
+}
- SVGElementInstance::InvalidationGuard invalidationGuard(this);
+bool SVGTextPositioningElement::isPresentationAttribute(const QualifiedName& name) const
+{
+ if (name == SVGNames::xAttr || name == SVGNames::yAttr)
+ return false;
+ return SVGTextContentElement::isPresentationAttribute(name);
+}
- bool updateRelativeLengths = attrName == SVGNames::xAttr
- || attrName == SVGNames::yAttr
- || attrName == SVGNames::dxAttr
- || attrName == SVGNames::dyAttr;
+void SVGTextPositioningElement::svgAttributeChanged(const QualifiedName& attrName)
+{
+ if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr || attrName == SVGNames::dxAttr || attrName == SVGNames::dyAttr || attrName == SVGNames::rotateAttr) {
+ InstanceInvalidationGuard guard(*this);
- if (updateRelativeLengths)
- updateRelativeLengthsInformation();
+ if (attrName != SVGNames::rotateAttr)
+ updateRelativeLengthsInformation();
- auto renderer = this->renderer();
- if (!renderer)
- return;
+ if (auto renderer = this->renderer()) {
+ if (auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*renderer))
+ textAncestor->setNeedsPositioningValuesUpdate();
+ RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer);
+ }
- if (updateRelativeLengths || attrName == SVGNames::rotateAttr) {
- if (RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(renderer))
- textRenderer->setNeedsPositioningValuesUpdate();
- RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer);
return;
}
- ASSERT_NOT_REACHED();
+ SVGTextContentElement::svgAttributeChanged(attrName);
}
-SVGTextPositioningElement* SVGTextPositioningElement::elementFromRenderer(RenderObject* renderer)
+SVGTextPositioningElement* SVGTextPositioningElement::elementFromRenderer(RenderBoxModelObject& renderer)
{
- if (!renderer)
- return 0;
+ if (!is<RenderSVGText>(renderer) && !is<RenderSVGInline>(renderer))
+ return nullptr;
- if (!renderer->isSVGText() && !renderer->isSVGInline())
- return 0;
+ ASSERT(renderer.element());
+ SVGElement& element = downcast<SVGElement>(*renderer.element());
- Node* node = renderer->node();
- ASSERT(node);
- ASSERT(node->isSVGElement());
-
- if (!node->hasTagName(SVGNames::textTag)
- && !node->hasTagName(SVGNames::tspanTag)
+ if (!is<SVGTextElement>(element)
+ && !is<SVGTSpanElement>(element)
#if ENABLE(SVG_FONTS)
- && !node->hasTagName(SVGNames::altGlyphTag)
+ && !is<SVGAltGlyphElement>(element)
#endif
- && !node->hasTagName(SVGNames::trefTag))
- return 0;
+ && !is<SVGTRefElement>(element))
+ return nullptr;
- return static_cast<SVGTextPositioningElement*>(node);
+ // FIXME: This should use downcast<>().
+ return &static_cast<SVGTextPositioningElement&>(element);
}
}
-
-#endif // ENABLE(SVG)