summaryrefslogtreecommitdiff
path: root/Source/WebCore/svg/SVGStopElement.cpp
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2016-08-25 19:20:41 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-02-02 12:30:55 +0000
commit6882a04fb36642862b11efe514251d32070c3d65 (patch)
treeb7959826000b061fd5ccc7512035c7478742f7b0 /Source/WebCore/svg/SVGStopElement.cpp
parentab6df191029eeeb0b0f16f127d553265659f739e (diff)
downloadqtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebCore/svg/SVGStopElement.cpp')
-rw-r--r--Source/WebCore/svg/SVGStopElement.cpp62
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)