Bug 1698238 return default dictionary from GetUserMediaRequest#getConstraints() if...
[gecko.git] / dom / svg / SVGFEGaussianBlurElement.cpp
blobc818ba3d2938c419f9797e2adc4f55f77a8d39f9
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/SVGFEGaussianBlurElement.h"
8 #include "mozilla/dom/SVGFEGaussianBlurElementBinding.h"
9 #include "mozilla/SVGFilterInstance.h"
11 NS_IMPL_NS_NEW_SVG_ELEMENT(FEGaussianBlur)
13 using namespace mozilla::gfx;
15 namespace mozilla {
16 namespace dom {
18 JSObject* SVGFEGaussianBlurElement::WrapNode(
19 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
20 return SVGFEGaussianBlurElement_Binding::Wrap(aCx, this, aGivenProto);
23 SVGElement::NumberPairInfo SVGFEGaussianBlurElement::sNumberPairInfo[1] = {
24 {nsGkAtoms::stdDeviation, 0, 0}};
26 SVGElement::StringInfo SVGFEGaussianBlurElement::sStringInfo[2] = {
27 {nsGkAtoms::result, kNameSpaceID_None, true},
28 {nsGkAtoms::in, kNameSpaceID_None, true}};
30 //----------------------------------------------------------------------
31 // nsINode methods
33 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEGaussianBlurElement)
35 //----------------------------------------------------------------------
37 already_AddRefed<DOMSVGAnimatedString> SVGFEGaussianBlurElement::In1() {
38 return mStringAttributes[IN1].ToDOMAnimatedString(this);
41 already_AddRefed<DOMSVGAnimatedNumber>
42 SVGFEGaussianBlurElement::StdDeviationX() {
43 return mNumberPairAttributes[STD_DEV].ToDOMAnimatedNumber(
44 SVGAnimatedNumberPair::eFirst, this);
47 already_AddRefed<DOMSVGAnimatedNumber>
48 SVGFEGaussianBlurElement::StdDeviationY() {
49 return mNumberPairAttributes[STD_DEV].ToDOMAnimatedNumber(
50 SVGAnimatedNumberPair::eSecond, this);
53 void SVGFEGaussianBlurElement::SetStdDeviation(float stdDeviationX,
54 float stdDeviationY) {
55 mNumberPairAttributes[STD_DEV].SetBaseValues(stdDeviationX, stdDeviationY,
56 this);
59 FilterPrimitiveDescription SVGFEGaussianBlurElement::GetPrimitiveDescription(
60 SVGFilterInstance* aInstance, const IntRect& aFilterSubregion,
61 const nsTArray<bool>& aInputsAreTainted,
62 nsTArray<RefPtr<SourceSurface>>& aInputImages) {
63 float stdX = aInstance->GetPrimitiveNumber(SVGContentUtils::X,
64 &mNumberPairAttributes[STD_DEV],
65 SVGAnimatedNumberPair::eFirst);
66 float stdY = aInstance->GetPrimitiveNumber(SVGContentUtils::Y,
67 &mNumberPairAttributes[STD_DEV],
68 SVGAnimatedNumberPair::eSecond);
69 if (stdX < 0 || stdY < 0) {
70 return FilterPrimitiveDescription();
73 GaussianBlurAttributes atts;
74 atts.mStdDeviation = Size(stdX, stdY);
75 return FilterPrimitiveDescription(AsVariant(std::move(atts)));
78 bool SVGFEGaussianBlurElement::AttributeAffectsRendering(
79 int32_t aNameSpaceID, nsAtom* aAttribute) const {
80 return SVGFEGaussianBlurElementBase::AttributeAffectsRendering(aNameSpaceID,
81 aAttribute) ||
82 (aNameSpaceID == kNameSpaceID_None &&
83 (aAttribute == nsGkAtoms::in ||
84 aAttribute == nsGkAtoms::stdDeviation));
87 void SVGFEGaussianBlurElement::GetSourceImageNames(
88 nsTArray<SVGStringInfo>& aSources) {
89 aSources.AppendElement(SVGStringInfo(&mStringAttributes[IN1], this));
92 //----------------------------------------------------------------------
93 // SVGElement methods
95 SVGElement::NumberPairAttributesInfo
96 SVGFEGaussianBlurElement::GetNumberPairInfo() {
97 return NumberPairAttributesInfo(mNumberPairAttributes, sNumberPairInfo,
98 ArrayLength(sNumberPairInfo));
101 SVGElement::StringAttributesInfo SVGFEGaussianBlurElement::GetStringInfo() {
102 return StringAttributesInfo(mStringAttributes, sStringInfo,
103 ArrayLength(sStringInfo));
106 } // namespace dom
107 } // namespace mozilla