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/SVGFEDistantLightElement.h"
8 #include "mozilla/dom/SVGFEDistantLightElementBinding.h"
9 #include "mozilla/SVGFilterInstance.h"
11 NS_IMPL_NS_NEW_SVG_ELEMENT(FEDistantLight
)
13 using namespace mozilla::gfx
;
15 namespace mozilla::dom
{
17 JSObject
* SVGFEDistantLightElement::WrapNode(
18 JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
) {
19 return SVGFEDistantLightElement_Binding::Wrap(aCx
, this, aGivenProto
);
22 SVGElement::NumberInfo
SVGFEDistantLightElement::sNumberInfo
[2] = {
23 {nsGkAtoms::azimuth
, 0}, {nsGkAtoms::elevation
, 0}};
25 //----------------------------------------------------------------------
26 //----------------------------------------------------------------------
29 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEDistantLightElement
)
31 // SVGFilterPrimitiveChildElement methods
33 bool SVGFEDistantLightElement::AttributeAffectsRendering(
34 int32_t aNameSpaceID
, nsAtom
* aAttribute
) const {
35 return aNameSpaceID
== kNameSpaceID_None
&&
36 (aAttribute
== nsGkAtoms::azimuth
||
37 aAttribute
== nsGkAtoms::elevation
);
40 LightType
SVGFEDistantLightElement::ComputeLightAttributes(
41 SVGFilterInstance
* aInstance
, nsTArray
<float>& aFloatAttributes
) {
42 float azimuth
, elevation
;
43 GetAnimatedNumberValues(&azimuth
, &elevation
, nullptr);
45 aFloatAttributes
.SetLength(kDistantLightNumAttributes
);
46 aFloatAttributes
[kDistantLightAzimuthIndex
] = azimuth
;
47 aFloatAttributes
[kDistantLightElevationIndex
] = elevation
;
48 return LightType::Distant
;
51 already_AddRefed
<DOMSVGAnimatedNumber
> SVGFEDistantLightElement::Azimuth() {
52 return mNumberAttributes
[AZIMUTH
].ToDOMAnimatedNumber(this);
55 already_AddRefed
<DOMSVGAnimatedNumber
> SVGFEDistantLightElement::Elevation() {
56 return mNumberAttributes
[ELEVATION
].ToDOMAnimatedNumber(this);
59 //----------------------------------------------------------------------
62 SVGElement::NumberAttributesInfo
SVGFEDistantLightElement::GetNumberInfo() {
63 return NumberAttributesInfo(mNumberAttributes
, sNumberInfo
,
64 std::size(sNumberInfo
));
67 } // namespace mozilla::dom