diff options
Diffstat (limited to 'Source/WebCore/svg/SVGStopElement.cpp')
-rw-r--r-- | Source/WebCore/svg/SVGStopElement.cpp | 62 |
1 files changed, 18 insertions, 44 deletions
diff --git a/Source/WebCore/svg/SVGStopElement.cpp b/Source/WebCore/svg/SVGStopElement.cpp index 84b636c60..7dbac8091 100644 --- a/Source/WebCore/svg/SVGStopElement.cpp +++ b/Source/WebCore/svg/SVGStopElement.cpp @@ -19,15 +19,11 @@ */ #include "config.h" - -#if ENABLE(SVG) #include "SVGStopElement.h" -#include "Attribute.h" #include "Document.h" #include "RenderSVGGradientStop.h" #include "RenderSVGResource.h" -#include "SVGElementInstance.h" #include "SVGGradientElement.h" #include "SVGNames.h" @@ -38,37 +34,24 @@ DEFINE_ANIMATED_NUMBER(SVGStopElement, SVGNames::offsetAttr, Offset, offset) BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGStopElement) REGISTER_LOCAL_ANIMATED_PROPERTY(offset) - REGISTER_PARENT_ANIMATED_PROPERTIES(SVGStyledElement) + REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) END_REGISTER_ANIMATED_PROPERTIES -inline SVGStopElement::SVGStopElement(const QualifiedName& tagName, Document* document) - : SVGStyledElement(tagName, document) +inline SVGStopElement::SVGStopElement(const QualifiedName& tagName, Document& document) + : SVGElement(tagName, document) , m_offset(0) { ASSERT(hasTagName(SVGNames::stopTag)); registerAnimatedPropertiesForSVGStopElement(); } -PassRefPtr<SVGStopElement> SVGStopElement::create(const QualifiedName& tagName, Document* document) -{ - return adoptRef(new SVGStopElement(tagName, document)); -} - -bool SVGStopElement::isSupportedAttribute(const QualifiedName& attrName) +Ref<SVGStopElement> SVGStopElement::create(const QualifiedName& tagName, Document& document) { - DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); - if (supportedAttributes.isEmpty()) - supportedAttributes.add(SVGNames::offsetAttr); - return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); + return adoptRef(*new SVGStopElement(tagName, document)); } void SVGStopElement::parseAttribute(const QualifiedName& name, const AtomicString& value) { - if (!isSupportedAttribute(name)) { - SVGStyledElement::parseAttribute(name, value); - return; - } - if (name == SVGNames::offsetAttr) { if (value.endsWith('%')) setOffsetBaseValue(value.string().left(value.length() - 1).toFloat() / 100.0f); @@ -77,52 +60,43 @@ void SVGStopElement::parseAttribute(const QualifiedName& name, const AtomicStrin return; } - ASSERT_NOT_REACHED(); + SVGElement::parseAttribute(name, value); } void SVGStopElement::svgAttributeChanged(const QualifiedName& attrName) { - if (!isSupportedAttribute(attrName)) { - SVGStyledElement::svgAttributeChanged(attrName); - return; - } - - SVGElementInstance::InvalidationGuard invalidationGuard(this); - - if (!renderer()) - return; - if (attrName == SVGNames::offsetAttr) { - RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer()); + if (auto renderer = this->renderer()) { + InstanceInvalidationGuard guard(*this); + RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer); + } return; } - ASSERT_NOT_REACHED(); + SVGElement::svgAttributeChanged(attrName); } -RenderObject* SVGStopElement::createRenderer(RenderArena* arena, RenderStyle*) +RenderPtr<RenderElement> SVGStopElement::createElementRenderer(Ref<RenderStyle>&& style, const RenderTreePosition&) { - return new (arena) RenderSVGGradientStop(this); + return createRenderer<RenderSVGGradientStop>(*this, WTFMove(style)); } -bool SVGStopElement::rendererIsNeeded(const NodeRenderingContext&) +bool SVGStopElement::rendererIsNeeded(const RenderStyle&) { return true; } Color SVGStopElement::stopColorIncludingOpacity() const { - RenderStyle* style = renderer() ? renderer()->style() : 0; + RenderStyle* style = renderer() ? &renderer()->style() : nullptr; // FIXME: This check for null style exists to address Bug WK 90814, a rare crash condition in // which the renderer or style is null. This entire class is scheduled for removal (Bug WK 86941) // and we will tolerate this null check until then. - if (!style || !style->svgStyle()) + if (!style) return Color(Color::transparent, true); // Transparent black. - const SVGRenderStyle* svgStyle = style->svgStyle(); - return colorWithOverrideAlpha(svgStyle->stopColor().rgb(), svgStyle->stopOpacity()); + const SVGRenderStyle& svgStyle = style->svgStyle(); + return colorWithOverrideAlpha(svgStyle.stopColor().rgb(), svgStyle.stopOpacity()); } } - -#endif // ENABLE(SVG) |