/src/mozilla-central/dom/svg/SVGFEComponentTransferElement.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/SVGComponentTransferFunctionElement.h" |
8 | | #include "mozilla/dom/SVGFEComponentTransferElement.h" |
9 | | #include "mozilla/dom/SVGFEComponentTransferElementBinding.h" |
10 | | #include "nsSVGUtils.h" |
11 | | #include "mozilla/gfx/2D.h" |
12 | | |
13 | | NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEComponentTransfer) |
14 | | |
15 | | using namespace mozilla::gfx;; |
16 | | |
17 | | namespace mozilla { |
18 | | namespace dom { |
19 | | |
20 | | JSObject* |
21 | | SVGFEComponentTransferElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) |
22 | 0 | { |
23 | 0 | return SVGFEComponentTransferElement_Binding::Wrap(aCx, this, aGivenProto); |
24 | 0 | } |
25 | | |
26 | | nsSVGElement::StringInfo SVGFEComponentTransferElement::sStringInfo[2] = |
27 | | { |
28 | | { &nsGkAtoms::result, kNameSpaceID_None, true }, |
29 | | { &nsGkAtoms::in, kNameSpaceID_None, true } |
30 | | }; |
31 | | |
32 | | //---------------------------------------------------------------------- |
33 | | // nsINode methods |
34 | | |
35 | | NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEComponentTransferElement) |
36 | | |
37 | | already_AddRefed<SVGAnimatedString> |
38 | | SVGFEComponentTransferElement::In1() |
39 | 0 | { |
40 | 0 | return mStringAttributes[IN1].ToDOMAnimatedString(this); |
41 | 0 | } |
42 | | |
43 | | //---------------------------------------------------------------------- |
44 | | // nsSVGElement methods |
45 | | |
46 | | nsSVGElement::StringAttributesInfo |
47 | | SVGFEComponentTransferElement::GetStringInfo() |
48 | 0 | { |
49 | 0 | return StringAttributesInfo(mStringAttributes, sStringInfo, |
50 | 0 | ArrayLength(sStringInfo)); |
51 | 0 | } |
52 | | |
53 | | //-------------------------------------------- |
54 | | |
55 | | FilterPrimitiveDescription |
56 | | SVGFEComponentTransferElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, |
57 | | const IntRect& aFilterSubregion, |
58 | | const nsTArray<bool>& aInputsAreTainted, |
59 | | nsTArray<RefPtr<SourceSurface>>& aInputImages) |
60 | 0 | { |
61 | 0 | RefPtr<SVGComponentTransferFunctionElement> childForChannel[4]; |
62 | 0 |
|
63 | 0 | for (nsIContent* childContent = nsINode::GetFirstChild(); |
64 | 0 | childContent; |
65 | 0 | childContent = childContent->GetNextSibling()) { |
66 | 0 |
|
67 | 0 | RefPtr<SVGComponentTransferFunctionElement> child; |
68 | 0 | CallQueryInterface(childContent, |
69 | 0 | (SVGComponentTransferFunctionElement**)getter_AddRefs(child)); |
70 | 0 | if (child) { |
71 | 0 | childForChannel[child->GetChannel()] = child; |
72 | 0 | } |
73 | 0 | } |
74 | 0 |
|
75 | 0 | ComponentTransferAttributes atts; |
76 | 0 | for (int32_t i = 0; i < 4; i++) { |
77 | 0 | if (childForChannel[i]) { |
78 | 0 | childForChannel[i]->ComputeAttributes(i, atts); |
79 | 0 | } else { |
80 | 0 | atts.mTypes[i] = |
81 | 0 | (uint8_t)SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY; |
82 | 0 | } |
83 | 0 | } |
84 | 0 | return FilterPrimitiveDescription(AsVariant(std::move(atts))); |
85 | 0 | } |
86 | | |
87 | | bool |
88 | | SVGFEComponentTransferElement::AttributeAffectsRendering(int32_t aNameSpaceID, |
89 | | nsAtom* aAttribute) const |
90 | 0 | { |
91 | 0 | return SVGFEComponentTransferElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) || |
92 | 0 | (aNameSpaceID == kNameSpaceID_None && |
93 | 0 | aAttribute == nsGkAtoms::in); |
94 | 0 | } |
95 | | |
96 | | void |
97 | | SVGFEComponentTransferElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources) |
98 | 0 | { |
99 | 0 | aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this)); |
100 | 0 | } |
101 | | |
102 | | } // namespace dom |
103 | | } // namespace mozilla |