diff options
Diffstat (limited to 'Source/WebCore/svg/SVGTextPathElement.cpp')
-rw-r--r-- | Source/WebCore/svg/SVGTextPathElement.cpp | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/Source/WebCore/svg/SVGTextPathElement.cpp b/Source/WebCore/svg/SVGTextPathElement.cpp index 4138366ad..3cd2b8e7c 100644 --- a/Source/WebCore/svg/SVGTextPathElement.cpp +++ b/Source/WebCore/svg/SVGTextPathElement.cpp @@ -19,16 +19,13 @@ */ #include "config.h" - -#if ENABLE(SVG) #include "SVGTextPathElement.h" -#include "Attribute.h" #include "RenderSVGResource.h" #include "RenderSVGTextPath.h" -#include "SVGElementInstance.h" #include "SVGNames.h" #include "XLinkNames.h" +#include <wtf/NeverDestroyed.h> namespace WebCore { @@ -56,9 +53,9 @@ inline SVGTextPathElement::SVGTextPathElement(const QualifiedName& tagName, Docu registerAnimatedPropertiesForSVGTextPathElement(); } -PassRefPtr<SVGTextPathElement> SVGTextPathElement::create(const QualifiedName& tagName, Document& document) +Ref<SVGTextPathElement> SVGTextPathElement::create(const QualifiedName& tagName, Document& document) { - return adoptRef(new SVGTextPathElement(tagName, document)); + return adoptRef(*new SVGTextPathElement(tagName, document)); } SVGTextPathElement::~SVGTextPathElement() @@ -68,29 +65,27 @@ SVGTextPathElement::~SVGTextPathElement() void SVGTextPathElement::clearResourceReferences() { - document().accessSVGExtensions()->removeAllTargetReferencesForElement(this); + document().accessSVGExtensions().removeAllTargetReferencesForElement(this); } bool SVGTextPathElement::isSupportedAttribute(const QualifiedName& attrName) { - DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); - if (supportedAttributes.isEmpty()) { + static NeverDestroyed<HashSet<QualifiedName>> supportedAttributes; + if (supportedAttributes.get().isEmpty()) { SVGURIReference::addSupportedAttributes(supportedAttributes); - supportedAttributes.add(SVGNames::startOffsetAttr); - supportedAttributes.add(SVGNames::methodAttr); - supportedAttributes.add(SVGNames::spacingAttr); + supportedAttributes.get().add(SVGNames::startOffsetAttr); + supportedAttributes.get().add(SVGNames::methodAttr); + supportedAttributes.get().add(SVGNames::spacingAttr); } - return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); + return supportedAttributes.get().contains<SVGAttributeHashTranslator>(attrName); } void SVGTextPathElement::parseAttribute(const QualifiedName& name, const AtomicString& value) { SVGParsingError parseError = NoError; - if (!isSupportedAttribute(name)) - SVGTextContentElement::parseAttribute(name, value); - else if (name == SVGNames::startOffsetAttr) - setStartOffsetBaseValue(SVGLength::construct(LengthModeOther, value, parseError)); + if (name == SVGNames::startOffsetAttr) + setStartOffsetBaseValue(SVGLengthValue::construct(LengthModeOther, value, parseError)); else if (name == SVGNames::methodAttr) { SVGTextPathMethodType propertyValue = SVGPropertyTraits<SVGTextPathMethodType>::fromString(value); if (propertyValue > 0) @@ -99,11 +94,12 @@ void SVGTextPathElement::parseAttribute(const QualifiedName& name, const AtomicS SVGTextPathSpacingType propertyValue = SVGPropertyTraits<SVGTextPathSpacingType>::fromString(value); if (propertyValue > 0) setSpacingBaseValue(propertyValue); - } else if (SVGURIReference::parseAttribute(name, value)) { - } else - ASSERT_NOT_REACHED(); + } reportAttributeParsingError(parseError, name, value); + + SVGTextContentElement::parseAttribute(name, value); + SVGURIReference::parseAttribute(name, value); } void SVGTextPathElement::svgAttributeChanged(const QualifiedName& attrName) @@ -113,7 +109,7 @@ void SVGTextPathElement::svgAttributeChanged(const QualifiedName& attrName) return; } - SVGElementInstance::InvalidationGuard invalidationGuard(this); + InstanceInvalidationGuard guard(*this); if (SVGURIReference::isKnownAttribute(attrName)) { buildPendingResource(); @@ -127,9 +123,9 @@ void SVGTextPathElement::svgAttributeChanged(const QualifiedName& attrName) RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer); } -RenderPtr<RenderElement> SVGTextPathElement::createElementRenderer(PassRef<RenderStyle> style) +RenderPtr<RenderElement> SVGTextPathElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&) { - return createRenderer<RenderSVGTextPath>(*this, std::move(style)); + return createRenderer<RenderSVGTextPath>(*this, WTFMove(style)); } bool SVGTextPathElement::childShouldCreateRenderer(const Node& child) const @@ -156,38 +152,42 @@ bool SVGTextPathElement::rendererIsNeeded(const RenderStyle& style) void SVGTextPathElement::buildPendingResource() { clearResourceReferences(); - if (!inDocument()) + if (!isConnected()) return; String id; Element* target = SVGURIReference::targetElementFromIRIString(href(), document(), &id); if (!target) { // Do not register as pending if we are already pending this resource. - if (document().accessSVGExtensions()->isPendingResource(this, id)) + if (document().accessSVGExtensions().isPendingResource(this, id)) return; if (!id.isEmpty()) { - document().accessSVGExtensions()->addPendingResource(id, this); + document().accessSVGExtensions().addPendingResource(id, this); ASSERT(hasPendingResources()); } } else if (target->hasTagName(SVGNames::pathTag)) { // Register us with the target in the dependencies map. Any change of hrefElement // that leads to relayout/repainting now informs us, so we can react to it. - document().accessSVGExtensions()->addElementReferencingTarget(this, toSVGElement(target)); + document().accessSVGExtensions().addElementReferencingTarget(this, downcast<SVGElement>(target)); } } Node::InsertionNotificationRequest SVGTextPathElement::insertedInto(ContainerNode& rootParent) { SVGTextContentElement::insertedInto(rootParent); + return InsertionShouldCallFinishedInsertingSubtree; +} + +void SVGTextPathElement::finishedInsertingSubtree() +{ buildPendingResource(); - return InsertionDone; } void SVGTextPathElement::removedFrom(ContainerNode& rootParent) { SVGTextContentElement::removedFrom(rootParent); - if (rootParent.inDocument()) + if (rootParent.isConnected()) clearResourceReferences(); } @@ -198,5 +198,3 @@ bool SVGTextPathElement::selfHasRelativeLengths() const } } - -#endif // ENABLE(SVG) |