2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
22 #include "core/svg/SVGStopElement.h"
24 #include "core/rendering/svg/RenderSVGGradientStop.h"
28 inline SVGStopElement::SVGStopElement(Document& document)
29 : SVGElement(SVGNames::stopTag, document)
30 , m_offset(SVGAnimatedNumber::create(this, SVGNames::offsetAttr, SVGNumberAcceptPercentage::create()))
32 addToPropertyMap(m_offset);
35 DEFINE_NODE_FACTORY(SVGStopElement)
37 void SVGStopElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
39 parseAttributeNew(name, value);
42 void SVGStopElement::svgAttributeChanged(const QualifiedName& attrName)
44 if (attrName == SVGNames::offsetAttr) {
45 SVGElement::InvalidationGuard invalidationGuard(this);
48 markForLayoutAndParentResourceInvalidation(renderer());
52 SVGElement::svgAttributeChanged(attrName);
55 RenderObject* SVGStopElement::createRenderer(RenderStyle*)
57 return new RenderSVGGradientStop(this);
60 bool SVGStopElement::rendererIsNeeded(const RenderStyle&)
65 Color SVGStopElement::stopColorIncludingOpacity() const
67 RenderStyle* style = renderer() ? renderer()->style() : 0;
68 // FIXME: This check for null style exists to address Bug WK 90814, a rare crash condition in
69 // which the renderer or style is null. This entire class is scheduled for removal (Bug WK 86941)
70 // and we will tolerate this null check until then.
72 return Color(Color::transparent); // Transparent black.
74 const SVGRenderStyle& svgStyle = style->svgStyle();
75 return svgStyle.stopColor().combineWithAlpha(svgStyle.stopOpacity());