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/layout/svg/LayoutSVGGradientStop.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_TRACE(SVGStopElement
)
37 visitor
->trace(m_offset
);
38 SVGElement::trace(visitor
);
41 DEFINE_NODE_FACTORY(SVGStopElement
)
43 void SVGStopElement::svgAttributeChanged(const QualifiedName
& attrName
)
45 if (attrName
== SVGNames::offsetAttr
) {
46 SVGElement::InvalidationGuard
invalidationGuard(this);
49 markForLayoutAndParentResourceInvalidation(layoutObject());
53 SVGElement::svgAttributeChanged(attrName
);
56 LayoutObject
* SVGStopElement::createLayoutObject(const ComputedStyle
&)
58 return new LayoutSVGGradientStop(this);
61 bool SVGStopElement::layoutObjectIsNeeded(const ComputedStyle
&)
66 Color
SVGStopElement::stopColorIncludingOpacity() const
68 const ComputedStyle
* style
= layoutObject() ? layoutObject()->style() : nullptr;
69 // FIXME: This check for null style exists to address Bug WK 90814, a rare crash condition in
70 // which the layoutObject or style is null. This entire class is scheduled for removal (Bug WK 86941)
71 // and we will tolerate this null check until then.
73 return Color(Color::transparent
); // Transparent black.
75 const SVGComputedStyle
& svgStyle
= style
->svgStyle();
76 return svgStyle
.stopColor().combineWithAlpha(svgStyle
.stopOpacity());