diff options
Diffstat (limited to 'Source/WebCore/svg/SVGPathElement.cpp')
-rw-r--r-- | Source/WebCore/svg/SVGPathElement.cpp | 230 |
1 files changed, 117 insertions, 113 deletions
diff --git a/Source/WebCore/svg/SVGPathElement.cpp b/Source/WebCore/svg/SVGPathElement.cpp index 3f3a08f18..18d799d9f 100644 --- a/Source/WebCore/svg/SVGPathElement.cpp +++ b/Source/WebCore/svg/SVGPathElement.cpp @@ -19,14 +19,10 @@ */ #include "config.h" - -#if ENABLE(SVG) #include "SVGPathElement.h" -#include "Attribute.h" #include "RenderSVGPath.h" #include "RenderSVGResource.h" -#include "SVGElementInstance.h" #include "SVGMPathElement.h" #include "SVGNames.h" #include "SVGPathSegArcAbs.h" @@ -47,19 +43,18 @@ #include "SVGPathSegLinetoVerticalAbs.h" #include "SVGPathSegLinetoVerticalRel.h" #include "SVGPathSegList.h" -#include "SVGPathSegListBuilder.h" -#include "SVGPathSegListPropertyTearOff.h" #include "SVGPathSegMovetoAbs.h" #include "SVGPathSegMovetoRel.h" #include "SVGPathUtilities.h" -#include "SVGSVGElement.h" +#include "SVGPoint.h" +#include <wtf/NeverDestroyed.h> namespace WebCore { // Define custom animated property 'd'. const SVGPropertyInfo* SVGPathElement::dPropertyInfo() { - static const SVGPropertyInfo* s_propertyInfo = 0; + static const SVGPropertyInfo* s_propertyInfo = nullptr; if (!s_propertyInfo) { s_propertyInfo = new SVGPropertyInfo(AnimatedPath, PropertyIsReadWrite, @@ -84,173 +79,164 @@ END_REGISTER_ANIMATED_PROPERTIES inline SVGPathElement::SVGPathElement(const QualifiedName& tagName, Document& document) : SVGGraphicsElement(tagName, document) - , m_pathByteStream(std::make_unique<SVGPathByteStream>()) , m_pathSegList(PathSegUnalteredRole) + , m_weakPtrFactory(this) , m_isAnimValObserved(false) { ASSERT(hasTagName(SVGNames::pathTag)); registerAnimatedPropertiesForSVGPathElement(); } -PassRefPtr<SVGPathElement> SVGPathElement::create(const QualifiedName& tagName, Document& document) +Ref<SVGPathElement> SVGPathElement::create(const QualifiedName& tagName, Document& document) { - return adoptRef(new SVGPathElement(tagName, document)); + return adoptRef(*new SVGPathElement(tagName, document)); } -float SVGPathElement::getTotalLength() +float SVGPathElement::getTotalLength() const { float totalLength = 0; getTotalLengthOfSVGPathByteStream(pathByteStream(), totalLength); return totalLength; } -SVGPoint SVGPathElement::getPointAtLength(float length) +Ref<SVGPoint> SVGPathElement::getPointAtLength(float length) const { - SVGPoint point; + FloatPoint point; getPointAtLengthOfSVGPathByteStream(pathByteStream(), length, point); - return point; + return SVGPoint::create(point); } -unsigned SVGPathElement::getPathSegAtLength(float length) +unsigned SVGPathElement::getPathSegAtLength(float length) const { unsigned pathSeg = 0; getSVGPathSegAtLengthFromSVGPathByteStream(pathByteStream(), length, pathSeg); return pathSeg; } -PassRefPtr<SVGPathSegClosePath> SVGPathElement::createSVGPathSegClosePath(SVGPathSegRole role) +Ref<SVGPathSegClosePath> SVGPathElement::createSVGPathSegClosePath(SVGPathSegRole role) { - return SVGPathSegClosePath::create(this, role); + return SVGPathSegClosePath::create(*this, role); } -PassRefPtr<SVGPathSegMovetoAbs> SVGPathElement::createSVGPathSegMovetoAbs(float x, float y, SVGPathSegRole role) +Ref<SVGPathSegMovetoAbs> SVGPathElement::createSVGPathSegMovetoAbs(float x, float y, SVGPathSegRole role) { - return SVGPathSegMovetoAbs::create(this, role, x, y); + return SVGPathSegMovetoAbs::create(*this, role, x, y); } -PassRefPtr<SVGPathSegMovetoRel> SVGPathElement::createSVGPathSegMovetoRel(float x, float y, SVGPathSegRole role) +Ref<SVGPathSegMovetoRel> SVGPathElement::createSVGPathSegMovetoRel(float x, float y, SVGPathSegRole role) { - return SVGPathSegMovetoRel::create(this, role, x, y); + return SVGPathSegMovetoRel::create(*this, role, x, y); } -PassRefPtr<SVGPathSegLinetoAbs> SVGPathElement::createSVGPathSegLinetoAbs(float x, float y, SVGPathSegRole role) +Ref<SVGPathSegLinetoAbs> SVGPathElement::createSVGPathSegLinetoAbs(float x, float y, SVGPathSegRole role) { - return SVGPathSegLinetoAbs::create(this, role, x, y); + return SVGPathSegLinetoAbs::create(*this, role, x, y); } -PassRefPtr<SVGPathSegLinetoRel> SVGPathElement::createSVGPathSegLinetoRel(float x, float y, SVGPathSegRole role) +Ref<SVGPathSegLinetoRel> SVGPathElement::createSVGPathSegLinetoRel(float x, float y, SVGPathSegRole role) { - return SVGPathSegLinetoRel::create(this, role, x, y); + return SVGPathSegLinetoRel::create(*this, role, x, y); } -PassRefPtr<SVGPathSegCurvetoCubicAbs> SVGPathElement::createSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2, SVGPathSegRole role) +Ref<SVGPathSegCurvetoCubicAbs> SVGPathElement::createSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2, SVGPathSegRole role) { - return SVGPathSegCurvetoCubicAbs::create(this, role, x, y, x1, y1, x2, y2); + return SVGPathSegCurvetoCubicAbs::create(*this, role, x, y, x1, y1, x2, y2); } -PassRefPtr<SVGPathSegCurvetoCubicRel> SVGPathElement::createSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2, SVGPathSegRole role) +Ref<SVGPathSegCurvetoCubicRel> SVGPathElement::createSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2, SVGPathSegRole role) { - return SVGPathSegCurvetoCubicRel::create(this, role, x, y, x1, y1, x2, y2); + return SVGPathSegCurvetoCubicRel::create(*this, role, x, y, x1, y1, x2, y2); } -PassRefPtr<SVGPathSegCurvetoQuadraticAbs> SVGPathElement::createSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1, SVGPathSegRole role) +Ref<SVGPathSegCurvetoQuadraticAbs> SVGPathElement::createSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1, SVGPathSegRole role) { - return SVGPathSegCurvetoQuadraticAbs::create(this, role, x, y, x1, y1); + return SVGPathSegCurvetoQuadraticAbs::create(*this, role, x, y, x1, y1); } -PassRefPtr<SVGPathSegCurvetoQuadraticRel> SVGPathElement::createSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1, SVGPathSegRole role) +Ref<SVGPathSegCurvetoQuadraticRel> SVGPathElement::createSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1, SVGPathSegRole role) { - return SVGPathSegCurvetoQuadraticRel::create(this, role, x, y, x1, y1); + return SVGPathSegCurvetoQuadraticRel::create(*this, role, x, y, x1, y1); } -PassRefPtr<SVGPathSegArcAbs> SVGPathElement::createSVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, SVGPathSegRole role) +Ref<SVGPathSegArcAbs> SVGPathElement::createSVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, SVGPathSegRole role) { - return SVGPathSegArcAbs::create(this, role, x, y, r1, r2, angle, largeArcFlag, sweepFlag); + return SVGPathSegArcAbs::create(*this, role, x, y, r1, r2, angle, largeArcFlag, sweepFlag); } -PassRefPtr<SVGPathSegArcRel> SVGPathElement::createSVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, SVGPathSegRole role) +Ref<SVGPathSegArcRel> SVGPathElement::createSVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, SVGPathSegRole role) { - return SVGPathSegArcRel::create(this, role, x, y, r1, r2, angle, largeArcFlag, sweepFlag); + return SVGPathSegArcRel::create(*this, role, x, y, r1, r2, angle, largeArcFlag, sweepFlag); } -PassRefPtr<SVGPathSegLinetoHorizontalAbs> SVGPathElement::createSVGPathSegLinetoHorizontalAbs(float x, SVGPathSegRole role) +Ref<SVGPathSegLinetoHorizontalAbs> SVGPathElement::createSVGPathSegLinetoHorizontalAbs(float x, SVGPathSegRole role) { - return SVGPathSegLinetoHorizontalAbs::create(this, role, x); + return SVGPathSegLinetoHorizontalAbs::create(*this, role, x); } -PassRefPtr<SVGPathSegLinetoHorizontalRel> SVGPathElement::createSVGPathSegLinetoHorizontalRel(float x, SVGPathSegRole role) +Ref<SVGPathSegLinetoHorizontalRel> SVGPathElement::createSVGPathSegLinetoHorizontalRel(float x, SVGPathSegRole role) { - return SVGPathSegLinetoHorizontalRel::create(this, role, x); + return SVGPathSegLinetoHorizontalRel::create(*this, role, x); } -PassRefPtr<SVGPathSegLinetoVerticalAbs> SVGPathElement::createSVGPathSegLinetoVerticalAbs(float y, SVGPathSegRole role) +Ref<SVGPathSegLinetoVerticalAbs> SVGPathElement::createSVGPathSegLinetoVerticalAbs(float y, SVGPathSegRole role) { - return SVGPathSegLinetoVerticalAbs::create(this, role, y); + return SVGPathSegLinetoVerticalAbs::create(*this, role, y); } -PassRefPtr<SVGPathSegLinetoVerticalRel> SVGPathElement::createSVGPathSegLinetoVerticalRel(float y, SVGPathSegRole role) +Ref<SVGPathSegLinetoVerticalRel> SVGPathElement::createSVGPathSegLinetoVerticalRel(float y, SVGPathSegRole role) { - return SVGPathSegLinetoVerticalRel::create(this, role, y); + return SVGPathSegLinetoVerticalRel::create(*this, role, y); } -PassRefPtr<SVGPathSegCurvetoCubicSmoothAbs> SVGPathElement::createSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2, SVGPathSegRole role) +Ref<SVGPathSegCurvetoCubicSmoothAbs> SVGPathElement::createSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2, SVGPathSegRole role) { - return SVGPathSegCurvetoCubicSmoothAbs::create(this, role, x, y, x2, y2); + return SVGPathSegCurvetoCubicSmoothAbs::create(*this, role, x, y, x2, y2); } -PassRefPtr<SVGPathSegCurvetoCubicSmoothRel> SVGPathElement::createSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2, SVGPathSegRole role) +Ref<SVGPathSegCurvetoCubicSmoothRel> SVGPathElement::createSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2, SVGPathSegRole role) { - return SVGPathSegCurvetoCubicSmoothRel::create(this, role, x, y, x2, y2); + return SVGPathSegCurvetoCubicSmoothRel::create(*this, role, x, y, x2, y2); } -PassRefPtr<SVGPathSegCurvetoQuadraticSmoothAbs> SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y, SVGPathSegRole role) +Ref<SVGPathSegCurvetoQuadraticSmoothAbs> SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y, SVGPathSegRole role) { - return SVGPathSegCurvetoQuadraticSmoothAbs::create(this, role, x, y); + return SVGPathSegCurvetoQuadraticSmoothAbs::create(*this, role, x, y); } -PassRefPtr<SVGPathSegCurvetoQuadraticSmoothRel> SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothRel(float x, float y, SVGPathSegRole role) +Ref<SVGPathSegCurvetoQuadraticSmoothRel> SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothRel(float x, float y, SVGPathSegRole role) { - return SVGPathSegCurvetoQuadraticSmoothRel::create(this, role, x, y); + return SVGPathSegCurvetoQuadraticSmoothRel::create(*this, role, x, y); } bool SVGPathElement::isSupportedAttribute(const QualifiedName& attrName) { - DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); - if (supportedAttributes.isEmpty()) { + static NeverDestroyed<HashSet<QualifiedName>> supportedAttributes; + if (supportedAttributes.get().isEmpty()) { SVGLangSpace::addSupportedAttributes(supportedAttributes); SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes); - supportedAttributes.add(SVGNames::dAttr); - supportedAttributes.add(SVGNames::pathLengthAttr); + supportedAttributes.get().add(SVGNames::dAttr); + supportedAttributes.get().add(SVGNames::pathLengthAttr); } - return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); + return supportedAttributes.get().contains<SVGAttributeHashTranslator>(attrName); } void SVGPathElement::parseAttribute(const QualifiedName& name, const AtomicString& value) { - if (!isSupportedAttribute(name)) { - SVGGraphicsElement::parseAttribute(name, value); - return; - } - if (name == SVGNames::dAttr) { - if (!buildSVGPathByteStreamFromString(value, m_pathByteStream.get(), UnalteredParsing)) - document().accessSVGExtensions()->reportError("Problem parsing d=\"" + value + "\""); + if (!buildSVGPathByteStreamFromString(value, m_pathByteStream, UnalteredParsing)) + document().accessSVGExtensions().reportError("Problem parsing d=\"" + value + "\""); return; } if (name == SVGNames::pathLengthAttr) { setPathLengthBaseValue(value.toFloat()); if (pathLengthBaseValue() < 0) - document().accessSVGExtensions()->reportError("A negative value for path attribute <pathLength> is not allowed"); + document().accessSVGExtensions().reportError("A negative value for path attribute <pathLength> is not allowed"); return; } - if (SVGLangSpace::parseAttribute(name, value)) - return; - if (SVGExternalResourcesRequired::parseAttribute(name, value)) - return; - - ASSERT_NOT_REACHED(); + SVGGraphicsElement::parseAttribute(name, value); + SVGExternalResourcesRequired::parseAttribute(name, value); } void SVGPathElement::svgAttributeChanged(const QualifiedName& attrName) @@ -260,14 +246,14 @@ void SVGPathElement::svgAttributeChanged(const QualifiedName& attrName) return; } - SVGElementInstance::InvalidationGuard invalidationGuard(this); + InstanceInvalidationGuard guard(*this); - RenderSVGPath* renderer = toRenderSVGPath(this->renderer()); + RenderSVGPath* renderer = downcast<RenderSVGPath>(this->renderer()); if (attrName == SVGNames::dAttr) { if (m_pathSegList.shouldSynchronize && !SVGAnimatedProperty::lookupWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff>(this, dPropertyInfo())->isAnimating()) { - SVGPathSegList newList(PathSegUnalteredRole); - buildSVGPathSegListFromByteStream(m_pathByteStream.get(), this, newList, UnalteredParsing); + SVGPathSegListValues newList(PathSegUnalteredRole); + buildSVGPathSegListValuesFromByteStream(m_pathByteStream, *this, newList, UnalteredParsing); m_pathSegList.value = newList; } @@ -285,10 +271,10 @@ void SVGPathElement::invalidateMPathDependencies() { // <mpath> can only reference <path> but this dependency is not handled in // markForLayoutAndParentResourceInvalidation so we update any mpath dependencies manually. - if (HashSet<SVGElement*>* dependencies = document().accessSVGExtensions()->setOfElementsReferencingTarget(this)) { - for (auto element : *dependencies) { - if (element->hasTagName(SVGNames::mpathTag)) - toSVGMPathElement(element)->targetPathChanged(); + if (HashSet<SVGElement*>* dependencies = document().accessSVGExtensions().setOfElementsReferencingTarget(this)) { + for (auto* element : *dependencies) { + if (is<SVGMPathElement>(*element)) + downcast<SVGMPathElement>(*element).targetPathChanged(); } } } @@ -306,61 +292,82 @@ void SVGPathElement::removedFrom(ContainerNode& rootParent) invalidateMPathDependencies(); } -SVGPathByteStream* SVGPathElement::pathByteStream() const +const SVGPathByteStream& SVGPathElement::pathByteStream() const { - SVGAnimatedProperty* property = SVGAnimatedProperty::lookupWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff>(this, dPropertyInfo()); + auto property = SVGAnimatedProperty::lookupWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff>(this, dPropertyInfo()); if (!property || !property->isAnimating()) - return m_pathByteStream.get(); - return static_cast<SVGAnimatedPathSegListPropertyTearOff*>(property)->animatedPathByteStream(); + return m_pathByteStream; + + SVGPathByteStream* animatedPathByteStream = static_cast<SVGAnimatedPathSegListPropertyTearOff*>(property.get())->animatedPathByteStream(); + if (!animatedPathByteStream) + return m_pathByteStream; + + return *animatedPathByteStream; } -PassRefPtr<SVGAnimatedProperty> SVGPathElement::lookupOrCreateDWrapper(SVGElement* contextElement) +Ref<SVGAnimatedProperty> SVGPathElement::lookupOrCreateDWrapper(SVGElement* contextElement) { ASSERT(contextElement); - SVGPathElement* ownerType = toSVGPathElement(contextElement); + SVGPathElement& ownerType = downcast<SVGPathElement>(*contextElement); - if (SVGAnimatedProperty* property = SVGAnimatedProperty::lookupWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff>(ownerType, dPropertyInfo())) - return property; + if (auto property = SVGAnimatedProperty::lookupWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff>(&ownerType, dPropertyInfo())) + return *property; - // Build initial SVGPathSegList. - buildSVGPathSegListFromByteStream(ownerType->m_pathByteStream.get(), ownerType, ownerType->m_pathSegList.value, UnalteredParsing); + if (ownerType.m_pathSegList.value.isEmpty()) + buildSVGPathSegListValuesFromByteStream(ownerType.m_pathByteStream, ownerType, ownerType.m_pathSegList.value, UnalteredParsing); - return SVGAnimatedProperty::lookupOrCreateWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff, SVGPathSegList> - (ownerType, dPropertyInfo(), ownerType->m_pathSegList.value); + return SVGAnimatedProperty::lookupOrCreateWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff, SVGPathSegListValues>(&ownerType, dPropertyInfo(), ownerType.m_pathSegList.value); } void SVGPathElement::synchronizeD(SVGElement* contextElement) { ASSERT(contextElement); - SVGPathElement* ownerType = toSVGPathElement(contextElement); - if (!ownerType->m_pathSegList.shouldSynchronize) + SVGPathElement& ownerType = downcast<SVGPathElement>(*contextElement); + if (!ownerType.m_pathSegList.shouldSynchronize) return; - ownerType->m_pathSegList.synchronize(ownerType, dPropertyInfo()->attributeName, ownerType->m_pathSegList.value.valueAsString()); + ownerType.m_pathSegList.synchronize(&ownerType, dPropertyInfo()->attributeName, ownerType.m_pathSegList.value.valueAsString()); +} + +void SVGPathElement::animatedPropertyWillBeDeleted() +{ + // m_pathSegList.shouldSynchronize is set to true when the 'd' wrapper for m_pathSegList + // is created and cached. We need to reset it back to false when this wrapper is deleted + // so we can be sure if shouldSynchronize is true, SVGAnimatedProperty::lookupWrapper() + // will return a valid cached 'd' wrapper for the m_pathSegList. + m_pathSegList.shouldSynchronize = false; } -SVGPathSegListPropertyTearOff* SVGPathElement::pathSegList() +Ref<SVGPathSegList> SVGPathElement::pathSegList() { m_pathSegList.shouldSynchronize = true; - return static_cast<SVGPathSegListPropertyTearOff*>(static_pointer_cast<SVGAnimatedPathSegListPropertyTearOff>(lookupOrCreateDWrapper(this))->baseVal()); + return static_reference_cast<SVGAnimatedPathSegListPropertyTearOff>(lookupOrCreateDWrapper(this))->baseVal(); } -SVGPathSegListPropertyTearOff* SVGPathElement::normalizedPathSegList() +RefPtr<SVGPathSegList> SVGPathElement::normalizedPathSegList() { // FIXME: https://bugs.webkit.org/show_bug.cgi?id=15412 - Implement normalized path segment lists! - return 0; + return nullptr; } -SVGPathSegListPropertyTearOff* SVGPathElement::animatedPathSegList() +Ref<SVGPathSegList> SVGPathElement::animatedPathSegList() { m_pathSegList.shouldSynchronize = true; m_isAnimValObserved = true; - return static_cast<SVGPathSegListPropertyTearOff*>(static_pointer_cast<SVGAnimatedPathSegListPropertyTearOff>(lookupOrCreateDWrapper(this))->animVal()); + return static_reference_cast<SVGAnimatedPathSegListPropertyTearOff>(lookupOrCreateDWrapper(this))->animVal(); } -SVGPathSegListPropertyTearOff* SVGPathElement::animatedNormalizedPathSegList() +RefPtr<SVGPathSegList> SVGPathElement::animatedNormalizedPathSegList() { // FIXME: https://bugs.webkit.org/show_bug.cgi?id=15412 - Implement normalized path segment lists! - return 0; + return nullptr; +} + +size_t SVGPathElement::approximateMemoryCost() const +{ + // This is an approximation for path memory cost since the path is parsed on demand. + size_t pathMemoryCost = (m_pathByteStream.size() / 10) * sizeof(FloatPoint); + // We need to account for the memory which is allocated by the RenderSVGPath::m_path. + return sizeof(*this) + (renderer() ? pathMemoryCost * 2 + sizeof(RenderSVGPath) : pathMemoryCost); } void SVGPathElement::pathSegListChanged(SVGPathSegRole role, ListModification listModification) @@ -372,9 +379,9 @@ void SVGPathElement::pathSegListChanged(SVGPathSegRole role, ListModification li case PathSegUnalteredRole: if (listModification == ListModificationAppend) { ASSERT(!m_pathSegList.value.isEmpty()); - appendSVGPathByteStreamFromSVGPathSeg(m_pathSegList.value.last(), m_pathByteStream.get(), UnalteredParsing); + appendSVGPathByteStreamFromSVGPathSeg(m_pathSegList.value.last().copyRef(), m_pathByteStream, UnalteredParsing); } else - buildSVGPathByteStreamFromSVGPathSegList(m_pathSegList.value, m_pathByteStream.get(), UnalteredParsing); + buildSVGPathByteStreamFromSVGPathSegListValues(m_pathSegList.value, m_pathByteStream, UnalteredParsing); break; case PathSegUndefinedRole: return; @@ -382,7 +389,7 @@ void SVGPathElement::pathSegListChanged(SVGPathSegRole role, ListModification li invalidateSVGAttributes(); - RenderSVGPath* renderer = toRenderSVGPath(this->renderer()); + RenderSVGPath* renderer = downcast<RenderSVGPath>(this->renderer()); if (!renderer) return; @@ -395,7 +402,7 @@ FloatRect SVGPathElement::getBBox(StyleUpdateStrategy styleUpdateStrategy) if (styleUpdateStrategy == AllowStyleUpdate) document().updateLayoutIgnorePendingStylesheets(); - RenderSVGPath* renderer = toRenderSVGPath(this->renderer()); + RenderSVGPath* renderer = downcast<RenderSVGPath>(this->renderer()); // FIXME: Eventually we should support getBBox for detached elements. if (!renderer) @@ -404,12 +411,9 @@ FloatRect SVGPathElement::getBBox(StyleUpdateStrategy styleUpdateStrategy) return renderer->path().boundingRect(); } -RenderPtr<RenderElement> SVGPathElement::createElementRenderer(PassRef<RenderStyle> style) +RenderPtr<RenderElement> SVGPathElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&) { - // By default, any subclass is expected to do path-based drawing - return createRenderer<RenderSVGPath>(*this, std::move(style)); + return createRenderer<RenderSVGPath>(*this, WTFMove(style)); } } - -#endif // ENABLE(SVG) |