diff options
Diffstat (limited to 'Source/WebCore/svg/SVGGradientElement.cpp')
-rw-r--r-- | Source/WebCore/svg/SVGGradientElement.cpp | 49 |
1 files changed, 16 insertions, 33 deletions
diff --git a/Source/WebCore/svg/SVGGradientElement.cpp b/Source/WebCore/svg/SVGGradientElement.cpp index d5d71efb8..e0659e69a 100644 --- a/Source/WebCore/svg/SVGGradientElement.cpp +++ b/Source/WebCore/svg/SVGGradientElement.cpp @@ -20,8 +20,6 @@ */ #include "config.h" - -#if ENABLE(SVG) #include "SVGGradientElement.h" #include "ElementIterator.h" @@ -29,13 +27,13 @@ #include "RenderSVGPath.h" #include "RenderSVGResourceLinearGradient.h" #include "RenderSVGResourceRadialGradient.h" -#include "SVGElementInstance.h" #include "SVGNames.h" #include "SVGStopElement.h" -#include "SVGTransformList.h" +#include "SVGTransformListValues.h" #include "SVGTransformable.h" #include "StyleResolver.h" #include "XLinkNames.h" +#include <wtf/NeverDestroyed.h> namespace WebCore { @@ -65,33 +63,28 @@ SVGGradientElement::SVGGradientElement(const QualifiedName& tagName, Document& d bool SVGGradientElement::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); SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes); - supportedAttributes.add(SVGNames::gradientUnitsAttr); - supportedAttributes.add(SVGNames::gradientTransformAttr); - supportedAttributes.add(SVGNames::spreadMethodAttr); + supportedAttributes.get().add(SVGNames::gradientUnitsAttr); + supportedAttributes.get().add(SVGNames::gradientTransformAttr); + supportedAttributes.get().add(SVGNames::spreadMethodAttr); } - return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); + return supportedAttributes.get().contains<SVGAttributeHashTranslator>(attrName); } void SVGGradientElement::parseAttribute(const QualifiedName& name, const AtomicString& value) { - if (!isSupportedAttribute(name)) { - SVGElement::parseAttribute(name, value); - return; - } - if (name == SVGNames::gradientUnitsAttr) { - SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes::SVGUnitType>::fromString(value); + auto propertyValue = SVGPropertyTraits<SVGUnitTypes::SVGUnitType>::fromString(value); if (propertyValue > 0) setGradientUnitsBaseValue(propertyValue); return; } if (name == SVGNames::gradientTransformAttr) { - SVGTransformList newList; + SVGTransformListValues newList; newList.parse(value); detachAnimatedGradientTransformListWrappers(newList.size()); setGradientTransformBaseValue(newList); @@ -99,18 +92,15 @@ void SVGGradientElement::parseAttribute(const QualifiedName& name, const AtomicS } if (name == SVGNames::spreadMethodAttr) { - SVGSpreadMethodType propertyValue = SVGPropertyTraits<SVGSpreadMethodType>::fromString(value); + auto propertyValue = SVGPropertyTraits<SVGSpreadMethodType>::fromString(value); if (propertyValue > 0) setSpreadMethodBaseValue(propertyValue); return; } - if (SVGURIReference::parseAttribute(name, value)) - return; - if (SVGExternalResourcesRequired::parseAttribute(name, value)) - return; - - ASSERT_NOT_REACHED(); + SVGElement::parseAttribute(name, value); + SVGURIReference::parseAttribute(name, value); + SVGExternalResourcesRequired::parseAttribute(name, value); } void SVGGradientElement::svgAttributeChanged(const QualifiedName& attrName) @@ -120,7 +110,7 @@ void SVGGradientElement::svgAttributeChanged(const QualifiedName& attrName) return; } - SVGElementInstance::InvalidationGuard invalidationGuard(this); + InstanceInvalidationGuard guard(*this); if (RenderObject* object = renderer()) object->setNeedsLayout(); @@ -143,7 +133,7 @@ Vector<Gradient::ColorStop> SVGGradientElement::buildStops() float previousOffset = 0.0f; for (auto& stop : childrenOfType<SVGStopElement>(*this)) { - Color color = stop.stopColorIncludingOpacity(); + const Color& color = stop.stopColorIncludingOpacity(); // Figure out right monotonic offset float offset = stop.offset(); @@ -161,11 +151,4 @@ Vector<Gradient::ColorStop> SVGGradientElement::buildStops() return stops; } -bool isSVGGradientElement(const Node& node) -{ - return node.hasTagName(SVGNames::radialGradientTag) || node.hasTagName(SVGNames::linearGradientTag); } - -} - -#endif // ENABLE(SVG) |