SVGFEDistantLightElement.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "mozilla/dom/SVGFEDistantLightElement.h"
  6. #include "mozilla/dom/SVGFEDistantLightElementBinding.h"
  7. #include "nsSVGFilterInstance.h"
  8. NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEDistantLight)
  9. using namespace mozilla::gfx;
  10. namespace mozilla {
  11. namespace dom {
  12. JSObject*
  13. SVGFEDistantLightElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
  14. {
  15. return SVGFEDistantLightElementBinding::Wrap(aCx, this, aGivenProto);
  16. }
  17. nsSVGElement::NumberInfo SVGFEDistantLightElement::sNumberInfo[2] =
  18. {
  19. { &nsGkAtoms::azimuth, 0, false },
  20. { &nsGkAtoms::elevation, 0, false }
  21. };
  22. //----------------------------------------------------------------------
  23. //----------------------------------------------------------------------
  24. // nsIDOMNode methods
  25. NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEDistantLightElement)
  26. // nsFEUnstyledElement methods
  27. bool
  28. SVGFEDistantLightElement::AttributeAffectsRendering(int32_t aNameSpaceID,
  29. nsIAtom* aAttribute) const
  30. {
  31. return aNameSpaceID == kNameSpaceID_None &&
  32. (aAttribute == nsGkAtoms::azimuth ||
  33. aAttribute == nsGkAtoms::elevation);
  34. }
  35. AttributeMap
  36. SVGFEDistantLightElement::ComputeLightAttributes(nsSVGFilterInstance* aInstance)
  37. {
  38. float azimuth, elevation;
  39. GetAnimatedNumberValues(&azimuth, &elevation, nullptr);
  40. AttributeMap map;
  41. map.Set(eLightType, (uint32_t)eLightTypeDistant);
  42. map.Set(eDistantLightAzimuth, azimuth);
  43. map.Set(eDistantLightElevation, elevation);
  44. return map;
  45. }
  46. already_AddRefed<SVGAnimatedNumber>
  47. SVGFEDistantLightElement::Azimuth()
  48. {
  49. return mNumberAttributes[AZIMUTH].ToDOMAnimatedNumber(this);
  50. }
  51. already_AddRefed<SVGAnimatedNumber>
  52. SVGFEDistantLightElement::Elevation()
  53. {
  54. return mNumberAttributes[ELEVATION].ToDOMAnimatedNumber(this);
  55. }
  56. //----------------------------------------------------------------------
  57. // nsSVGElement methods
  58. nsSVGElement::NumberAttributesInfo
  59. SVGFEDistantLightElement::GetNumberInfo()
  60. {
  61. return NumberAttributesInfo(mNumberAttributes, sNumberInfo,
  62. ArrayLength(sNumberInfo));
  63. }
  64. } // namespace dom
  65. } // namespace mozilla