diff options
Diffstat (limited to 'Source/WebCore/svg/SVGLinearGradientElement.cpp')
-rw-r--r-- | Source/WebCore/svg/SVGLinearGradientElement.cpp | 65 |
1 files changed, 28 insertions, 37 deletions
diff --git a/Source/WebCore/svg/SVGLinearGradientElement.cpp b/Source/WebCore/svg/SVGLinearGradientElement.cpp index 78b024f0e..948c6c3d7 100644 --- a/Source/WebCore/svg/SVGLinearGradientElement.cpp +++ b/Source/WebCore/svg/SVGLinearGradientElement.cpp @@ -22,21 +22,16 @@ */ #include "config.h" - -#if ENABLE(SVG) #include "SVGLinearGradientElement.h" -#include "Attribute.h" #include "Document.h" #include "FloatPoint.h" #include "LinearGradientAttributes.h" #include "RenderSVGResourceLinearGradient.h" -#include "SVGElementInstance.h" -#include "SVGLength.h" +#include "SVGLengthValue.h" #include "SVGNames.h" -#include "SVGTransform.h" -#include "SVGTransformList.h" #include "SVGUnitTypes.h" +#include <wtf/NeverDestroyed.h> namespace WebCore { @@ -66,41 +61,39 @@ inline SVGLinearGradientElement::SVGLinearGradientElement(const QualifiedName& t registerAnimatedPropertiesForSVGLinearGradientElement(); } -PassRefPtr<SVGLinearGradientElement> SVGLinearGradientElement::create(const QualifiedName& tagName, Document& document) +Ref<SVGLinearGradientElement> SVGLinearGradientElement::create(const QualifiedName& tagName, Document& document) { - return adoptRef(new SVGLinearGradientElement(tagName, document)); + return adoptRef(*new SVGLinearGradientElement(tagName, document)); } bool SVGLinearGradientElement::isSupportedAttribute(const QualifiedName& attrName) { - DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); - if (supportedAttributes.isEmpty()) { - supportedAttributes.add(SVGNames::x1Attr); - supportedAttributes.add(SVGNames::x2Attr); - supportedAttributes.add(SVGNames::y1Attr); - supportedAttributes.add(SVGNames::y2Attr); + static NeverDestroyed<HashSet<QualifiedName>> supportedAttributes; + if (supportedAttributes.get().isEmpty()) { + supportedAttributes.get().add(SVGNames::x1Attr); + supportedAttributes.get().add(SVGNames::x2Attr); + supportedAttributes.get().add(SVGNames::y1Attr); + supportedAttributes.get().add(SVGNames::y2Attr); } - return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); + return supportedAttributes.get().contains<SVGAttributeHashTranslator>(attrName); } void SVGLinearGradientElement::parseAttribute(const QualifiedName& name, const AtomicString& value) { SVGParsingError parseError = NoError; - if (!isSupportedAttribute(name)) - SVGGradientElement::parseAttribute(name, value); - else if (name == SVGNames::x1Attr) - setX1BaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); + if (name == SVGNames::x1Attr) + setX1BaseValue(SVGLengthValue::construct(LengthModeWidth, value, parseError)); else if (name == SVGNames::y1Attr) - setY1BaseValue(SVGLength::construct(LengthModeHeight, value, parseError)); + setY1BaseValue(SVGLengthValue::construct(LengthModeHeight, value, parseError)); else if (name == SVGNames::x2Attr) - setX2BaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); + setX2BaseValue(SVGLengthValue::construct(LengthModeWidth, value, parseError)); else if (name == SVGNames::y2Attr) - setY2BaseValue(SVGLength::construct(LengthModeHeight, value, parseError)); - else - ASSERT_NOT_REACHED(); + setY2BaseValue(SVGLengthValue::construct(LengthModeHeight, value, parseError)); reportAttributeParsingError(parseError, name, value); + + SVGGradientElement::parseAttribute(name, value); } void SVGLinearGradientElement::svgAttributeChanged(const QualifiedName& attrName) @@ -110,7 +103,7 @@ void SVGLinearGradientElement::svgAttributeChanged(const QualifiedName& attrName return; } - SVGElementInstance::InvalidationGuard invalidationGuard(this); + InstanceInvalidationGuard guard(*this); updateRelativeLengthsInformation(); @@ -118,9 +111,9 @@ void SVGLinearGradientElement::svgAttributeChanged(const QualifiedName& attrName object->setNeedsLayout(); } -RenderPtr<RenderElement> SVGLinearGradientElement::createElementRenderer(PassRef<RenderStyle> style) +RenderPtr<RenderElement> SVGLinearGradientElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&) { - return createRenderer<RenderSVGResourceLinearGradient>(*this, std::move(style)); + return createRenderer<RenderSVGResourceLinearGradient>(*this, WTFMove(style)); } static void setGradientAttributes(SVGGradientElement& element, LinearGradientAttributes& attributes, bool isLinear = true) @@ -144,19 +137,19 @@ static void setGradientAttributes(SVGGradientElement& element, LinearGradientAtt } if (isLinear) { - SVGLinearGradientElement* linear = toSVGLinearGradientElement(&element); + SVGLinearGradientElement& linear = downcast<SVGLinearGradientElement>(element); if (!attributes.hasX1() && element.hasAttribute(SVGNames::x1Attr)) - attributes.setX1(linear->x1()); + attributes.setX1(linear.x1()); if (!attributes.hasY1() && element.hasAttribute(SVGNames::y1Attr)) - attributes.setY1(linear->y1()); + attributes.setY1(linear.y1()); if (!attributes.hasX2() && element.hasAttribute(SVGNames::x2Attr)) - attributes.setX2(linear->x2()); + attributes.setX2(linear.x2()); if (!attributes.hasY2() && element.hasAttribute(SVGNames::y2Attr)) - attributes.setY2(linear->y2()); + attributes.setY2(linear.y2()); } } @@ -174,8 +167,8 @@ bool SVGLinearGradientElement::collectGradientAttributes(LinearGradientAttribute while (true) { // Respect xlink:href, take attributes from referenced element Node* refNode = SVGURIReference::targetElementFromIRIString(current->href(), document()); - if (refNode && isSVGGradientElement(*refNode)) { - current = toSVGGradientElement(refNode); + if (is<SVGGradientElement>(refNode)) { + current = downcast<SVGGradientElement>(refNode); // Cycle detection if (processedGradients.contains(current)) @@ -203,5 +196,3 @@ bool SVGLinearGradientElement::selfHasRelativeLengths() const } } - -#endif // ENABLE(SVG) |