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/. */
6
7 #include "mozilla/dom/SVGFEDistantLightElement.h"
8 #include "mozilla/dom/SVGFEDistantLightElementBinding.h"
9 #include "mozilla/SVGFilterInstance.h"
10
11 NS_IMPL_NS_NEW_SVG_ELEMENT(FEDistantLight)
12
13 using namespace mozilla::gfx;
14
15 namespace mozilla {
16 namespace dom {
17
WrapNode(JSContext * aCx,JS::Handle<JSObject * > aGivenProto)18 JSObject* SVGFEDistantLightElement::WrapNode(
19 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
20 return SVGFEDistantLightElement_Binding::Wrap(aCx, this, aGivenProto);
21 }
22
23 SVGElement::NumberInfo SVGFEDistantLightElement::sNumberInfo[2] = {
24 {nsGkAtoms::azimuth, 0, false}, {nsGkAtoms::elevation, 0, false}};
25
26 //----------------------------------------------------------------------
27 //----------------------------------------------------------------------
28 // nsINode methods
29
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEDistantLightElement)30 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEDistantLightElement)
31
32 // nsFEUnstyledElement methods
33
34 bool SVGFEDistantLightElement::AttributeAffectsRendering(
35 int32_t aNameSpaceID, nsAtom* aAttribute) const {
36 return aNameSpaceID == kNameSpaceID_None &&
37 (aAttribute == nsGkAtoms::azimuth ||
38 aAttribute == nsGkAtoms::elevation);
39 }
40
ComputeLightAttributes(SVGFilterInstance * aInstance,nsTArray<float> & aFloatAttributes)41 LightType SVGFEDistantLightElement::ComputeLightAttributes(
42 SVGFilterInstance* aInstance, nsTArray<float>& aFloatAttributes) {
43 float azimuth, elevation;
44 GetAnimatedNumberValues(&azimuth, &elevation, nullptr);
45
46 aFloatAttributes.SetLength(kDistantLightNumAttributes);
47 aFloatAttributes[kDistantLightAzimuthIndex] = azimuth;
48 aFloatAttributes[kDistantLightElevationIndex] = elevation;
49 return LightType::Distant;
50 }
51
Azimuth()52 already_AddRefed<DOMSVGAnimatedNumber> SVGFEDistantLightElement::Azimuth() {
53 return mNumberAttributes[AZIMUTH].ToDOMAnimatedNumber(this);
54 }
55
Elevation()56 already_AddRefed<DOMSVGAnimatedNumber> SVGFEDistantLightElement::Elevation() {
57 return mNumberAttributes[ELEVATION].ToDOMAnimatedNumber(this);
58 }
59
60 //----------------------------------------------------------------------
61 // SVGElement methods
62
GetNumberInfo()63 SVGElement::NumberAttributesInfo SVGFEDistantLightElement::GetNumberInfo() {
64 return NumberAttributesInfo(mNumberAttributes, sNumberInfo,
65 ArrayLength(sNumberInfo));
66 }
67
68 } // namespace dom
69 } // namespace mozilla
70