Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/svg/SVGFECompositeElement.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/SVGFECompositeElement.h"
8
#include "mozilla/dom/SVGFECompositeElementBinding.h"
9
10
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEComposite)
11
12
using namespace mozilla::gfx;
13
14
namespace mozilla {
15
namespace dom {
16
17
JSObject*
18
SVGFECompositeElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
19
0
{
20
0
  return SVGFECompositeElement_Binding::Wrap(aCx, this, aGivenProto);
21
0
}
22
23
nsSVGElement::NumberInfo SVGFECompositeElement::sNumberInfo[4] =
24
{
25
  { &nsGkAtoms::k1, 0, false },
26
  { &nsGkAtoms::k2, 0, false },
27
  { &nsGkAtoms::k3, 0, false },
28
  { &nsGkAtoms::k4, 0, false }
29
};
30
31
nsSVGEnumMapping SVGFECompositeElement::sOperatorMap[] = {
32
  {&nsGkAtoms::over, SVG_FECOMPOSITE_OPERATOR_OVER},
33
  {&nsGkAtoms::in, SVG_FECOMPOSITE_OPERATOR_IN},
34
  {&nsGkAtoms::out, SVG_FECOMPOSITE_OPERATOR_OUT},
35
  {&nsGkAtoms::atop, SVG_FECOMPOSITE_OPERATOR_ATOP},
36
  {&nsGkAtoms::xor_, SVG_FECOMPOSITE_OPERATOR_XOR},
37
  {&nsGkAtoms::arithmetic, SVG_FECOMPOSITE_OPERATOR_ARITHMETIC},
38
  {nullptr, 0}
39
};
40
41
nsSVGElement::EnumInfo SVGFECompositeElement::sEnumInfo[1] =
42
{
43
  { &nsGkAtoms::_operator,
44
    sOperatorMap,
45
    SVG_FECOMPOSITE_OPERATOR_OVER
46
  }
47
};
48
49
nsSVGElement::StringInfo SVGFECompositeElement::sStringInfo[3] =
50
{
51
  { &nsGkAtoms::result, kNameSpaceID_None, true },
52
  { &nsGkAtoms::in, kNameSpaceID_None, true },
53
  { &nsGkAtoms::in2, kNameSpaceID_None, true }
54
};
55
56
//----------------------------------------------------------------------
57
// nsINode methods
58
59
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFECompositeElement)
60
61
already_AddRefed<SVGAnimatedString>
62
SVGFECompositeElement::In1()
63
0
{
64
0
  return mStringAttributes[IN1].ToDOMAnimatedString(this);
65
0
}
66
67
already_AddRefed<SVGAnimatedString>
68
SVGFECompositeElement::In2()
69
0
{
70
0
  return mStringAttributes[IN2].ToDOMAnimatedString(this);
71
0
}
72
73
already_AddRefed<SVGAnimatedEnumeration>
74
SVGFECompositeElement::Operator()
75
0
{
76
0
  return mEnumAttributes[OPERATOR].ToDOMAnimatedEnum(this);
77
0
}
78
79
already_AddRefed<SVGAnimatedNumber>
80
SVGFECompositeElement::K1()
81
0
{
82
0
  return mNumberAttributes[ATTR_K1].ToDOMAnimatedNumber(this);
83
0
}
84
85
already_AddRefed<SVGAnimatedNumber>
86
SVGFECompositeElement::K2()
87
0
{
88
0
  return mNumberAttributes[ATTR_K2].ToDOMAnimatedNumber(this);
89
0
}
90
91
already_AddRefed<SVGAnimatedNumber>
92
SVGFECompositeElement::K3()
93
0
{
94
0
  return mNumberAttributes[ATTR_K3].ToDOMAnimatedNumber(this);
95
0
}
96
97
already_AddRefed<SVGAnimatedNumber>
98
SVGFECompositeElement::K4()
99
0
{
100
0
  return mNumberAttributes[ATTR_K4].ToDOMAnimatedNumber(this);
101
0
}
102
103
void
104
SVGFECompositeElement::SetK(float k1, float k2, float k3, float k4)
105
0
{
106
0
  mNumberAttributes[ATTR_K1].SetBaseValue(k1, this);
107
0
  mNumberAttributes[ATTR_K2].SetBaseValue(k2, this);
108
0
  mNumberAttributes[ATTR_K3].SetBaseValue(k3, this);
109
0
  mNumberAttributes[ATTR_K4].SetBaseValue(k4, this);
110
0
}
111
112
FilterPrimitiveDescription
113
SVGFECompositeElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
114
                                               const IntRect& aFilterSubregion,
115
                                               const nsTArray<bool>& aInputsAreTainted,
116
                                               nsTArray<RefPtr<SourceSurface>>& aInputImages)
117
0
{
118
0
  CompositeAttributes atts;
119
0
  uint32_t op = mEnumAttributes[OPERATOR].GetAnimValue();
120
0
  atts.mOperator = op;
121
0
122
0
  if (op == SVG_FECOMPOSITE_OPERATOR_ARITHMETIC) {
123
0
    float k[4];
124
0
    GetAnimatedNumberValues(k, k+1, k+2, k+3, nullptr);
125
0
    atts.mCoefficients.AppendElements(k, 4);
126
0
  }
127
0
128
0
  return FilterPrimitiveDescription(AsVariant(std::move(atts)));
129
0
}
130
131
bool
132
SVGFECompositeElement::AttributeAffectsRendering(int32_t aNameSpaceID,
133
                                                 nsAtom* aAttribute) const
134
0
{
135
0
  return SVGFECompositeElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
136
0
         (aNameSpaceID == kNameSpaceID_None &&
137
0
          (aAttribute == nsGkAtoms::in ||
138
0
           aAttribute == nsGkAtoms::in2 ||
139
0
           aAttribute == nsGkAtoms::k1 ||
140
0
           aAttribute == nsGkAtoms::k2 ||
141
0
           aAttribute == nsGkAtoms::k3 ||
142
0
           aAttribute == nsGkAtoms::k4 ||
143
0
           aAttribute == nsGkAtoms::_operator));
144
0
}
145
146
void
147
SVGFECompositeElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
148
0
{
149
0
  aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
150
0
  aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN2], this));
151
0
}
152
153
//----------------------------------------------------------------------
154
// nsSVGElement methods
155
156
nsSVGElement::NumberAttributesInfo
157
SVGFECompositeElement::GetNumberInfo()
158
0
{
159
0
  return NumberAttributesInfo(mNumberAttributes, sNumberInfo,
160
0
                              ArrayLength(sNumberInfo));
161
0
}
162
163
nsSVGElement::EnumAttributesInfo
164
SVGFECompositeElement::GetEnumInfo()
165
0
{
166
0
  return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
167
0
                            ArrayLength(sEnumInfo));
168
0
}
169
170
nsSVGElement::StringAttributesInfo
171
SVGFECompositeElement::GetStringInfo()
172
0
{
173
0
  return StringAttributesInfo(mStringAttributes, sStringInfo,
174
0
                              ArrayLength(sStringInfo));
175
0
}
176
177
} // namespace dom
178
} // namespace mozilla