Bug 1936278 - Prevent search mode chiclet from being dismissed when clicking in page...
[gecko.git] / dom / svg / SVGFEPointLightElement.cpp
blob92055e92d4ca6c544a3ec18be6db56c96cd45175
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/SVGFEPointLightElement.h"
8 #include "mozilla/dom/SVGFEPointLightElementBinding.h"
9 #include "mozilla/SVGFilterInstance.h"
11 NS_IMPL_NS_NEW_SVG_ELEMENT(FEPointLight)
13 using namespace mozilla::gfx;
15 namespace mozilla::dom {
17 JSObject* SVGFEPointLightElement::WrapNode(JSContext* aCx,
18 JS::Handle<JSObject*> aGivenProto) {
19 return SVGFEPointLightElement_Binding::Wrap(aCx, this, aGivenProto);
22 SVGElement::NumberInfo SVGFEPointLightElement::sNumberInfo[3] = {
23 {nsGkAtoms::x, 0}, {nsGkAtoms::y, 0}, {nsGkAtoms::z, 0}};
25 //----------------------------------------------------------------------
26 // nsINode methods
28 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEPointLightElement)
30 //----------------------------------------------------------------------
31 // SVGFilterPrimitiveChildElement methods
33 bool SVGFEPointLightElement::AttributeAffectsRendering(
34 int32_t aNameSpaceID, nsAtom* aAttribute) const {
35 return aNameSpaceID == kNameSpaceID_None &&
36 (aAttribute == nsGkAtoms::x || aAttribute == nsGkAtoms::y ||
37 aAttribute == nsGkAtoms::z);
40 //----------------------------------------------------------------------
42 LightType SVGFEPointLightElement::ComputeLightAttributes(
43 SVGFilterInstance* aInstance, nsTArray<float>& aFloatAttributes) {
44 Point3D lightPos;
45 GetAnimatedNumberValues(&lightPos.x, &lightPos.y, &lightPos.z, nullptr);
46 lightPos = aInstance->ConvertLocation(lightPos);
47 aFloatAttributes.SetLength(kPointLightNumAttributes);
48 aFloatAttributes[kPointLightPositionXIndex] = lightPos.x;
49 aFloatAttributes[kPointLightPositionYIndex] = lightPos.y;
50 aFloatAttributes[kPointLightPositionZIndex] = lightPos.z;
51 return LightType::Point;
54 already_AddRefed<DOMSVGAnimatedNumber> SVGFEPointLightElement::X() {
55 return mNumberAttributes[ATTR_X].ToDOMAnimatedNumber(this);
58 already_AddRefed<DOMSVGAnimatedNumber> SVGFEPointLightElement::Y() {
59 return mNumberAttributes[ATTR_Y].ToDOMAnimatedNumber(this);
62 already_AddRefed<DOMSVGAnimatedNumber> SVGFEPointLightElement::Z() {
63 return mNumberAttributes[ATTR_Z].ToDOMAnimatedNumber(this);
66 //----------------------------------------------------------------------
67 // SVGElement methods
69 SVGElement::NumberAttributesInfo SVGFEPointLightElement::GetNumberInfo() {
70 return NumberAttributesInfo(mNumberAttributes, sNumberInfo,
71 std::size(sNumberInfo));
74 } // namespace mozilla::dom