/src/mozilla-central/dom/svg/SVGFEOffsetElement.cpp
Line | Count | Source (jump to first uncovered line) |
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/SVGFEOffsetElement.h" |
8 | | #include "mozilla/dom/SVGFEOffsetElementBinding.h" |
9 | | #include "nsSVGFilterInstance.h" |
10 | | |
11 | | NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEOffset) |
12 | | |
13 | | using namespace mozilla::gfx; |
14 | | |
15 | | namespace mozilla { |
16 | | namespace dom { |
17 | | |
18 | | JSObject* |
19 | | SVGFEOffsetElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) |
20 | 0 | { |
21 | 0 | return SVGFEOffsetElement_Binding::Wrap(aCx, this, aGivenProto); |
22 | 0 | } |
23 | | |
24 | | nsSVGElement::NumberInfo SVGFEOffsetElement::sNumberInfo[2] = |
25 | | { |
26 | | { &nsGkAtoms::dx, 0, false }, |
27 | | { &nsGkAtoms::dy, 0, false } |
28 | | }; |
29 | | |
30 | | nsSVGElement::StringInfo SVGFEOffsetElement::sStringInfo[2] = |
31 | | { |
32 | | { &nsGkAtoms::result, kNameSpaceID_None, true }, |
33 | | { &nsGkAtoms::in, kNameSpaceID_None, true } |
34 | | }; |
35 | | |
36 | | //---------------------------------------------------------------------- |
37 | | // nsINode methods |
38 | | |
39 | | |
40 | | NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEOffsetElement) |
41 | | |
42 | | |
43 | | //---------------------------------------------------------------------- |
44 | | |
45 | | already_AddRefed<SVGAnimatedString> |
46 | | SVGFEOffsetElement::In1() |
47 | 0 | { |
48 | 0 | return mStringAttributes[IN1].ToDOMAnimatedString(this); |
49 | 0 | } |
50 | | |
51 | | already_AddRefed<SVGAnimatedNumber> |
52 | | SVGFEOffsetElement::Dx() |
53 | 0 | { |
54 | 0 | return mNumberAttributes[DX].ToDOMAnimatedNumber(this); |
55 | 0 | } |
56 | | |
57 | | already_AddRefed<SVGAnimatedNumber> |
58 | | SVGFEOffsetElement::Dy() |
59 | 0 | { |
60 | 0 | return mNumberAttributes[DY].ToDOMAnimatedNumber(this); |
61 | 0 | } |
62 | | |
63 | | FilterPrimitiveDescription |
64 | | SVGFEOffsetElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, |
65 | | const IntRect& aFilterSubregion, |
66 | | const nsTArray<bool>& aInputsAreTainted, |
67 | | nsTArray<RefPtr<SourceSurface>>& aInputImages) |
68 | 0 | { |
69 | 0 | OffsetAttributes atts; |
70 | 0 | IntPoint offset(int32_t(aInstance->GetPrimitiveNumber( |
71 | 0 | SVGContentUtils::X, &mNumberAttributes[DX])), |
72 | 0 | int32_t(aInstance->GetPrimitiveNumber( |
73 | 0 | SVGContentUtils::Y, &mNumberAttributes[DY]))); |
74 | 0 | atts.mValue = offset; |
75 | 0 | return FilterPrimitiveDescription(AsVariant(std::move(atts))); |
76 | 0 | } |
77 | | |
78 | | bool |
79 | | SVGFEOffsetElement::AttributeAffectsRendering(int32_t aNameSpaceID, |
80 | | nsAtom* aAttribute) const |
81 | 0 | { |
82 | 0 | return SVGFEOffsetElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) || |
83 | 0 | (aNameSpaceID == kNameSpaceID_None && |
84 | 0 | (aAttribute == nsGkAtoms::in || |
85 | 0 | aAttribute == nsGkAtoms::dx || |
86 | 0 | aAttribute == nsGkAtoms::dy)); |
87 | 0 | } |
88 | | |
89 | | void |
90 | | SVGFEOffsetElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources) |
91 | 0 | { |
92 | 0 | aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this)); |
93 | 0 | } |
94 | | |
95 | | //---------------------------------------------------------------------- |
96 | | // nsSVGElement methods |
97 | | |
98 | | nsSVGElement::NumberAttributesInfo |
99 | | SVGFEOffsetElement::GetNumberInfo() |
100 | 0 | { |
101 | 0 | return NumberAttributesInfo(mNumberAttributes, sNumberInfo, |
102 | 0 | ArrayLength(sNumberInfo)); |
103 | 0 | } |
104 | | |
105 | | nsSVGElement::StringAttributesInfo |
106 | | SVGFEOffsetElement::GetStringInfo() |
107 | 0 | { |
108 | 0 | return StringAttributesInfo(mStringAttributes, sStringInfo, |
109 | 0 | ArrayLength(sStringInfo)); |
110 | 0 | } |
111 | | |
112 | | } // namespace dom |
113 | | } // namespace mozilla |