Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/svg/SVGFESpotLightElement.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/SVGFESpotLightElement.h"
8
#include "mozilla/dom/SVGFESpotLightElementBinding.h"
9
#include "nsSVGFilterInstance.h"
10
11
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FESpotLight)
12
13
using namespace mozilla::gfx;
14
15
namespace mozilla {
16
namespace dom {
17
18
JSObject*
19
SVGFESpotLightElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
20
0
{
21
0
  return SVGFESpotLightElement_Binding::Wrap(aCx, this, aGivenProto);
22
0
}
23
24
nsSVGElement::NumberInfo SVGFESpotLightElement::sNumberInfo[8] =
25
{
26
  { &nsGkAtoms::x, 0, false },
27
  { &nsGkAtoms::y, 0, false },
28
  { &nsGkAtoms::z, 0, false },
29
  { &nsGkAtoms::pointsAtX, 0, false },
30
  { &nsGkAtoms::pointsAtY, 0, false },
31
  { &nsGkAtoms::pointsAtZ, 0, false },
32
  { &nsGkAtoms::specularExponent, 1, false },
33
  { &nsGkAtoms::limitingConeAngle, 0, false }
34
};
35
36
//----------------------------------------------------------------------
37
// nsINode methods
38
39
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFESpotLightElement)
40
41
//----------------------------------------------------------------------
42
// nsFEUnstyledElement methods
43
44
bool
45
SVGFESpotLightElement::AttributeAffectsRendering(int32_t aNameSpaceID,
46
                                                 nsAtom* aAttribute) const
47
0
{
48
0
  return aNameSpaceID == kNameSpaceID_None &&
49
0
         (aAttribute == nsGkAtoms::x ||
50
0
          aAttribute == nsGkAtoms::y ||
51
0
          aAttribute == nsGkAtoms::z ||
52
0
          aAttribute == nsGkAtoms::pointsAtX ||
53
0
          aAttribute == nsGkAtoms::pointsAtY ||
54
0
          aAttribute == nsGkAtoms::pointsAtZ ||
55
0
          aAttribute == nsGkAtoms::specularExponent ||
56
0
          aAttribute == nsGkAtoms::limitingConeAngle);
57
0
}
58
59
//----------------------------------------------------------------------
60
61
LightType
62
SVGFESpotLightElement::ComputeLightAttributes(nsSVGFilterInstance* aInstance,
63
                                              nsTArray<float>& aFloatAttributes)
64
0
{
65
0
  aFloatAttributes.SetLength(kSpotLightNumAttributes);
66
0
  GetAnimatedNumberValues(&aFloatAttributes[kSpotLightPositionXIndex],
67
0
                          &aFloatAttributes[kSpotLightPositionYIndex],
68
0
                          &aFloatAttributes[kSpotLightPositionZIndex],
69
0
                          &aFloatAttributes[kSpotLightPointsAtXIndex],
70
0
                          &aFloatAttributes[kSpotLightPointsAtYIndex],
71
0
                          &aFloatAttributes[kSpotLightPointsAtZIndex],
72
0
                          &aFloatAttributes[kSpotLightFocusIndex],
73
0
                          &aFloatAttributes[kSpotLightLimitingConeAngleIndex],
74
0
                          nullptr);
75
0
  if (!mNumberAttributes[SVGFESpotLightElement::LIMITING_CONE_ANGLE].IsExplicitlySet()) {
76
0
    aFloatAttributes[kSpotLightLimitingConeAngleIndex] = 90;
77
0
  }
78
0
79
0
  return LightType::Spot;
80
0
}
81
82
already_AddRefed<SVGAnimatedNumber>
83
SVGFESpotLightElement::X()
84
0
{
85
0
  return mNumberAttributes[ATTR_X].ToDOMAnimatedNumber(this);
86
0
}
87
88
already_AddRefed<SVGAnimatedNumber>
89
SVGFESpotLightElement::Y()
90
0
{
91
0
  return mNumberAttributes[ATTR_Y].ToDOMAnimatedNumber(this);
92
0
}
93
94
already_AddRefed<SVGAnimatedNumber>
95
SVGFESpotLightElement::Z()
96
0
{
97
0
  return mNumberAttributes[ATTR_Z].ToDOMAnimatedNumber(this);
98
0
}
99
100
already_AddRefed<SVGAnimatedNumber>
101
SVGFESpotLightElement::PointsAtX()
102
0
{
103
0
  return mNumberAttributes[POINTS_AT_X].ToDOMAnimatedNumber(this);
104
0
}
105
106
already_AddRefed<SVGAnimatedNumber>
107
SVGFESpotLightElement::PointsAtY()
108
0
{
109
0
  return mNumberAttributes[POINTS_AT_Y].ToDOMAnimatedNumber(this);
110
0
}
111
112
already_AddRefed<SVGAnimatedNumber>
113
SVGFESpotLightElement::PointsAtZ()
114
0
{
115
0
  return mNumberAttributes[POINTS_AT_Z].ToDOMAnimatedNumber(this);
116
0
}
117
118
already_AddRefed<SVGAnimatedNumber>
119
SVGFESpotLightElement::SpecularExponent()
120
0
{
121
0
  return mNumberAttributes[SPECULAR_EXPONENT].ToDOMAnimatedNumber(this);
122
0
}
123
124
already_AddRefed<SVGAnimatedNumber>
125
SVGFESpotLightElement::LimitingConeAngle()
126
0
{
127
0
  return mNumberAttributes[LIMITING_CONE_ANGLE].ToDOMAnimatedNumber(this);
128
0
}
129
130
//----------------------------------------------------------------------
131
// nsSVGElement methods
132
133
nsSVGElement::NumberAttributesInfo
134
SVGFESpotLightElement::GetNumberInfo()
135
0
{
136
0
  return NumberAttributesInfo(mNumberAttributes, sNumberInfo,
137
0
                              ArrayLength(sNumberInfo));
138
0
}
139
140
} // namespace dom
141
} // namespace mozilla