no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / dom / svg / SVGFESpotLightElement.cpp
blob6008ee3f27aa24b57c5a8ad07aba05fefc9eda80
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/dom/SVGFESpotLightElement.h"
8 #include "mozilla/dom/SVGFESpotLightElementBinding.h"
9 #include "mozilla/SVGFilterInstance.h"
11 NS_IMPL_NS_NEW_SVG_ELEMENT(FESpotLight)
13 using namespace mozilla::gfx;
15 namespace mozilla::dom {
17 JSObject* SVGFESpotLightElement::WrapNode(JSContext* aCx,
18 JS::Handle<JSObject*> aGivenProto) {
19 return SVGFESpotLightElement_Binding::Wrap(aCx, this, aGivenProto);
22 SVGElement::NumberInfo SVGFESpotLightElement::sNumberInfo[8] = {
23 {nsGkAtoms::x, 0},
24 {nsGkAtoms::y, 0},
25 {nsGkAtoms::z, 0},
26 {nsGkAtoms::pointsAtX, 0},
27 {nsGkAtoms::pointsAtY, 0},
28 {nsGkAtoms::pointsAtZ, 0},
29 {nsGkAtoms::specularExponent, 1},
30 {nsGkAtoms::limitingConeAngle, 0}};
32 //----------------------------------------------------------------------
33 // nsINode methods
35 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFESpotLightElement)
37 //----------------------------------------------------------------------
38 // SVGFilterPrimitiveChildElement methods
40 bool SVGFESpotLightElement::AttributeAffectsRendering(
41 int32_t aNameSpaceID, nsAtom* aAttribute) const {
42 return aNameSpaceID == kNameSpaceID_None &&
43 (aAttribute == nsGkAtoms::x || aAttribute == nsGkAtoms::y ||
44 aAttribute == nsGkAtoms::z || aAttribute == nsGkAtoms::pointsAtX ||
45 aAttribute == nsGkAtoms::pointsAtY ||
46 aAttribute == nsGkAtoms::pointsAtZ ||
47 aAttribute == nsGkAtoms::specularExponent ||
48 aAttribute == nsGkAtoms::limitingConeAngle);
51 //----------------------------------------------------------------------
53 LightType SVGFESpotLightElement::ComputeLightAttributes(
54 SVGFilterInstance* aInstance, nsTArray<float>& aFloatAttributes) {
55 aFloatAttributes.SetLength(kSpotLightNumAttributes);
56 GetAnimatedNumberValues(&aFloatAttributes[kSpotLightPositionXIndex],
57 &aFloatAttributes[kSpotLightPositionYIndex],
58 &aFloatAttributes[kSpotLightPositionZIndex],
59 &aFloatAttributes[kSpotLightPointsAtXIndex],
60 &aFloatAttributes[kSpotLightPointsAtYIndex],
61 &aFloatAttributes[kSpotLightPointsAtZIndex],
62 &aFloatAttributes[kSpotLightFocusIndex],
63 &aFloatAttributes[kSpotLightLimitingConeAngleIndex],
64 nullptr);
65 if (!mNumberAttributes[SVGFESpotLightElement::LIMITING_CONE_ANGLE]
66 .IsExplicitlySet()) {
67 aFloatAttributes[kSpotLightLimitingConeAngleIndex] = 90;
70 return LightType::Spot;
73 already_AddRefed<DOMSVGAnimatedNumber> SVGFESpotLightElement::X() {
74 return mNumberAttributes[ATTR_X].ToDOMAnimatedNumber(this);
77 already_AddRefed<DOMSVGAnimatedNumber> SVGFESpotLightElement::Y() {
78 return mNumberAttributes[ATTR_Y].ToDOMAnimatedNumber(this);
81 already_AddRefed<DOMSVGAnimatedNumber> SVGFESpotLightElement::Z() {
82 return mNumberAttributes[ATTR_Z].ToDOMAnimatedNumber(this);
85 already_AddRefed<DOMSVGAnimatedNumber> SVGFESpotLightElement::PointsAtX() {
86 return mNumberAttributes[POINTS_AT_X].ToDOMAnimatedNumber(this);
89 already_AddRefed<DOMSVGAnimatedNumber> SVGFESpotLightElement::PointsAtY() {
90 return mNumberAttributes[POINTS_AT_Y].ToDOMAnimatedNumber(this);
93 already_AddRefed<DOMSVGAnimatedNumber> SVGFESpotLightElement::PointsAtZ() {
94 return mNumberAttributes[POINTS_AT_Z].ToDOMAnimatedNumber(this);
97 already_AddRefed<DOMSVGAnimatedNumber>
98 SVGFESpotLightElement::SpecularExponent() {
99 return mNumberAttributes[SPECULAR_EXPONENT].ToDOMAnimatedNumber(this);
102 already_AddRefed<DOMSVGAnimatedNumber>
103 SVGFESpotLightElement::LimitingConeAngle() {
104 return mNumberAttributes[LIMITING_CONE_ANGLE].ToDOMAnimatedNumber(this);
107 //----------------------------------------------------------------------
108 // SVGElement methods
110 SVGElement::NumberAttributesInfo SVGFESpotLightElement::GetNumberInfo() {
111 return NumberAttributesInfo(mNumberAttributes, sNumberInfo,
112 ArrayLength(sNumberInfo));
115 } // namespace mozilla::dom