1 /*
2  * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
3  * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
4  * Copyright (C) 2005 Oliver Hunt <oliver@nerget.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB.  If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_SVG_SVG_FE_LIGHT_ELEMENT_H_
23 #define THIRD_PARTY_BLINK_RENDERER_CORE_SVG_SVG_FE_LIGHT_ELEMENT_H_
24 
25 #include "third_party/blink/renderer/core/svg/svg_element.h"
26 #include "third_party/blink/renderer/core/svg_names.h"
27 #include "third_party/blink/renderer/platform/graphics/filters/light_source.h"
28 #include "third_party/blink/renderer/platform/heap/handle.h"
29 
30 namespace blink {
31 
32 class Filter;
33 class SVGAnimatedNumber;
34 
35 class SVGFELightElement : public SVGElement {
36  public:
37   virtual scoped_refptr<LightSource> GetLightSource(Filter*) const = 0;
38   static SVGFELightElement* FindLightElement(const SVGElement&);
39 
40   FloatPoint3D GetPosition() const;
41   FloatPoint3D PointsAt() const;
42 
azimuth()43   SVGAnimatedNumber* azimuth() { return azimuth_.Get(); }
azimuth()44   const SVGAnimatedNumber* azimuth() const { return azimuth_.Get(); }
elevation()45   SVGAnimatedNumber* elevation() { return elevation_.Get(); }
elevation()46   const SVGAnimatedNumber* elevation() const { return elevation_.Get(); }
x()47   SVGAnimatedNumber* x() { return x_.Get(); }
x()48   const SVGAnimatedNumber* x() const { return x_.Get(); }
y()49   SVGAnimatedNumber* y() { return y_.Get(); }
y()50   const SVGAnimatedNumber* y() const { return y_.Get(); }
z()51   SVGAnimatedNumber* z() { return z_.Get(); }
z()52   const SVGAnimatedNumber* z() const { return z_.Get(); }
pointsAtX()53   SVGAnimatedNumber* pointsAtX() { return points_at_x_.Get(); }
pointsAtX()54   const SVGAnimatedNumber* pointsAtX() const { return points_at_x_.Get(); }
pointsAtY()55   SVGAnimatedNumber* pointsAtY() { return points_at_y_.Get(); }
pointsAtY()56   const SVGAnimatedNumber* pointsAtY() const { return points_at_y_.Get(); }
pointsAtZ()57   SVGAnimatedNumber* pointsAtZ() { return points_at_z_.Get(); }
pointsAtZ()58   const SVGAnimatedNumber* pointsAtZ() const { return points_at_z_.Get(); }
specularExponent()59   SVGAnimatedNumber* specularExponent() { return specular_exponent_.Get(); }
specularExponent()60   const SVGAnimatedNumber* specularExponent() const {
61     return specular_exponent_.Get();
62   }
limitingConeAngle()63   SVGAnimatedNumber* limitingConeAngle() { return limiting_cone_angle_.Get(); }
limitingConeAngle()64   const SVGAnimatedNumber* limitingConeAngle() const {
65     return limiting_cone_angle_.Get();
66   }
67 
68   void Trace(Visitor*) const override;
69 
70  protected:
71   SVGFELightElement(const QualifiedName&, Document&);
72 
73  private:
74   void SvgAttributeChanged(const QualifiedName&) final;
75   void ChildrenChanged(const ChildrenChange&) final;
76 
LayoutObjectIsNeeded(const ComputedStyle &)77   bool LayoutObjectIsNeeded(const ComputedStyle&) const override {
78     return false;
79   }
80 
81   Member<SVGAnimatedNumber> azimuth_;
82   Member<SVGAnimatedNumber> elevation_;
83   Member<SVGAnimatedNumber> x_;
84   Member<SVGAnimatedNumber> y_;
85   Member<SVGAnimatedNumber> z_;
86   Member<SVGAnimatedNumber> points_at_x_;
87   Member<SVGAnimatedNumber> points_at_y_;
88   Member<SVGAnimatedNumber> points_at_z_;
89   Member<SVGAnimatedNumber> specular_exponent_;
90   Member<SVGAnimatedNumber> limiting_cone_angle_;
91 };
92 
93 template <>
94 inline bool IsElementOfType<const SVGFELightElement>(const Node& node) {
95   return IsA<SVGFELightElement>(node);
96 }
97 template <>
98 struct DowncastTraits<SVGFELightElement> {
99   static bool AllowFrom(const Node& node) {
100     auto* svg_element = DynamicTo<SVGElement>(node);
101     return svg_element && AllowFrom(*svg_element);
102   }
103   static bool AllowFrom(const SVGElement& svg_element) {
104     return svg_element.HasTagName(svg_names::kFEDistantLightTag) ||
105            svg_element.HasTagName(svg_names::kFEPointLightTag) ||
106            svg_element.HasTagName(svg_names::kFESpotLightTag);
107   }
108 };
109 
110 }  // namespace blink
111 
112 #endif
113