Bug 1936278 - Prevent search mode chiclet from being dismissed when clicking in page...
[gecko.git] / dom / svg / SVGFEDiffuseLightingElement.cpp
blob20959d8c35c5f7f6fec2f2ab502c939097e3ed32
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/SVGFEDiffuseLightingElement.h"
8 #include "mozilla/dom/SVGFEDiffuseLightingElementBinding.h"
9 #include "mozilla/SVGFilterInstance.h"
10 #include "mozilla/dom/Document.h"
11 #include "mozilla/dom/BindContext.h"
13 NS_IMPL_NS_NEW_SVG_ELEMENT(FEDiffuseLighting)
15 using namespace mozilla::gfx;
17 namespace mozilla::dom {
19 JSObject* SVGFEDiffuseLightingElement::WrapNode(
20 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
21 return SVGFEDiffuseLightingElement_Binding::Wrap(aCx, this, aGivenProto);
24 //----------------------------------------------------------------------
25 // nsINode methods
27 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEDiffuseLightingElement)
29 //----------------------------------------------------------------------
31 already_AddRefed<DOMSVGAnimatedString> SVGFEDiffuseLightingElement::In1() {
32 return mStringAttributes[IN1].ToDOMAnimatedString(this);
35 already_AddRefed<DOMSVGAnimatedNumber>
36 SVGFEDiffuseLightingElement::SurfaceScale() {
37 return mNumberAttributes[SURFACE_SCALE].ToDOMAnimatedNumber(this);
40 already_AddRefed<DOMSVGAnimatedNumber>
41 SVGFEDiffuseLightingElement::DiffuseConstant() {
42 return mNumberAttributes[DIFFUSE_CONSTANT].ToDOMAnimatedNumber(this);
45 already_AddRefed<DOMSVGAnimatedNumber>
46 SVGFEDiffuseLightingElement::KernelUnitLengthX() {
47 return mNumberPairAttributes[KERNEL_UNIT_LENGTH].ToDOMAnimatedNumber(
48 SVGAnimatedNumberPair::eFirst, this);
51 already_AddRefed<DOMSVGAnimatedNumber>
52 SVGFEDiffuseLightingElement::KernelUnitLengthY() {
53 return mNumberPairAttributes[KERNEL_UNIT_LENGTH].ToDOMAnimatedNumber(
54 SVGAnimatedNumberPair::eSecond, this);
57 FilterPrimitiveDescription SVGFEDiffuseLightingElement::GetPrimitiveDescription(
58 SVGFilterInstance* aInstance, const IntRect& aFilterSubregion,
59 const nsTArray<bool>& aInputsAreTainted,
60 nsTArray<RefPtr<SourceSurface>>& aInputImages) {
61 float diffuseConstant = mNumberAttributes[DIFFUSE_CONSTANT].GetAnimValue();
63 DiffuseLightingAttributes atts;
64 atts.mLightingConstant = diffuseConstant;
65 if (!AddLightingAttributes(&atts, aInstance)) {
66 return FilterPrimitiveDescription();
69 return FilterPrimitiveDescription(AsVariant(std::move(atts)));
72 bool SVGFEDiffuseLightingElement::AttributeAffectsRendering(
73 int32_t aNameSpaceID, nsAtom* aAttribute) const {
74 return SVGFEDiffuseLightingElementBase::AttributeAffectsRendering(
75 aNameSpaceID, aAttribute) ||
76 (aNameSpaceID == kNameSpaceID_None &&
77 aAttribute == nsGkAtoms::diffuseConstant);
80 nsresult SVGFEDiffuseLightingElement::BindToTree(BindContext& aCtx,
81 nsINode& aParent) {
82 if (aCtx.InComposedDoc()) {
83 aCtx.OwnerDoc().SetUseCounter(eUseCounter_custom_feDiffuseLighting);
86 return SVGFEDiffuseLightingElementBase::BindToTree(aCtx, aParent);
89 } // namespace mozilla::dom