Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/svg/SVGFEBlendElement.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/SVGFEBlendElement.h"
8
#include "mozilla/dom/SVGFEBlendElementBinding.h"
9
#include "nsSVGUtils.h"
10
11
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEBlend)
12
13
using namespace mozilla::gfx;
14
15
namespace mozilla {
16
namespace dom {
17
18
JSObject*
19
SVGFEBlendElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
20
0
{
21
0
  return SVGFEBlendElement_Binding::Wrap(aCx, this, aGivenProto);
22
0
}
23
24
nsSVGEnumMapping SVGFEBlendElement::sModeMap[] = {
25
  {&nsGkAtoms::normal, SVG_FEBLEND_MODE_NORMAL},
26
  {&nsGkAtoms::multiply, SVG_FEBLEND_MODE_MULTIPLY},
27
  {&nsGkAtoms::screen, SVG_FEBLEND_MODE_SCREEN},
28
  {&nsGkAtoms::darken, SVG_FEBLEND_MODE_DARKEN},
29
  {&nsGkAtoms::lighten, SVG_FEBLEND_MODE_LIGHTEN},
30
  {&nsGkAtoms::overlay, SVG_FEBLEND_MODE_OVERLAY},
31
  {&nsGkAtoms::colorDodge, SVG_FEBLEND_MODE_COLOR_DODGE},
32
  {&nsGkAtoms::colorBurn, SVG_FEBLEND_MODE_COLOR_BURN},
33
  {&nsGkAtoms::hardLight, SVG_FEBLEND_MODE_HARD_LIGHT},
34
  {&nsGkAtoms::softLight, SVG_FEBLEND_MODE_SOFT_LIGHT},
35
  {&nsGkAtoms::difference, SVG_FEBLEND_MODE_DIFFERENCE},
36
  {&nsGkAtoms::exclusion, SVG_FEBLEND_MODE_EXCLUSION},
37
  {&nsGkAtoms::hue, SVG_FEBLEND_MODE_HUE},
38
  {&nsGkAtoms::saturation, SVG_FEBLEND_MODE_SATURATION},
39
  {&nsGkAtoms::color, SVG_FEBLEND_MODE_COLOR},
40
  {&nsGkAtoms::luminosity, SVG_FEBLEND_MODE_LUMINOSITY},
41
  {nullptr, 0}
42
};
43
44
nsSVGElement::EnumInfo SVGFEBlendElement::sEnumInfo[1] =
45
{
46
  { &nsGkAtoms::mode,
47
    sModeMap,
48
    SVG_FEBLEND_MODE_NORMAL
49
  }
50
};
51
52
nsSVGElement::StringInfo SVGFEBlendElement::sStringInfo[3] =
53
{
54
  { &nsGkAtoms::result, kNameSpaceID_None, true },
55
  { &nsGkAtoms::in, kNameSpaceID_None, true },
56
  { &nsGkAtoms::in2, kNameSpaceID_None, true }
57
};
58
59
//----------------------------------------------------------------------
60
// nsINode methods
61
62
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEBlendElement)
63
64
//----------------------------------------------------------------------
65
// nsIDOMSVGFEBlendElement methods
66
67
already_AddRefed<SVGAnimatedString>
68
SVGFEBlendElement::In1()
69
0
{
70
0
  return mStringAttributes[IN1].ToDOMAnimatedString(this);
71
0
}
72
73
already_AddRefed<SVGAnimatedString>
74
SVGFEBlendElement::In2()
75
0
{
76
0
  return mStringAttributes[IN2].ToDOMAnimatedString(this);
77
0
}
78
79
already_AddRefed<SVGAnimatedEnumeration>
80
SVGFEBlendElement::Mode()
81
0
{
82
0
  return mEnumAttributes[MODE].ToDOMAnimatedEnum(this);
83
0
}
84
85
FilterPrimitiveDescription
86
SVGFEBlendElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
87
                                           const IntRect& aFilterSubregion,
88
                                           const nsTArray<bool>& aInputsAreTainted,
89
                                           nsTArray<RefPtr<SourceSurface>>& aInputImages)
90
0
{
91
0
  uint32_t mode = mEnumAttributes[MODE].GetAnimValue();
92
0
  BlendAttributes attributes;
93
0
  attributes.mBlendMode = mode;
94
0
  return FilterPrimitiveDescription(AsVariant(std::move(attributes)));
95
0
}
96
97
bool
98
SVGFEBlendElement::AttributeAffectsRendering(int32_t aNameSpaceID,
99
                                             nsAtom* aAttribute) const
100
0
{
101
0
  return SVGFEBlendElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
102
0
         (aNameSpaceID == kNameSpaceID_None &&
103
0
          (aAttribute == nsGkAtoms::in ||
104
0
           aAttribute == nsGkAtoms::in2 ||
105
0
           aAttribute == nsGkAtoms::mode));
106
0
}
107
108
void
109
SVGFEBlendElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
110
0
{
111
0
  aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
112
0
  aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN2], this));
113
0
}
114
115
//----------------------------------------------------------------------
116
// nsSVGElement methods
117
118
nsSVGElement::EnumAttributesInfo
119
SVGFEBlendElement::GetEnumInfo()
120
0
{
121
0
  return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
122
0
                            ArrayLength(sEnumInfo));
123
0
}
124
125
nsSVGElement::StringAttributesInfo
126
SVGFEBlendElement::GetStringInfo()
127
0
{
128
0
  return StringAttributesInfo(mStringAttributes, sStringInfo,
129
0
                              ArrayLength(sStringInfo));
130
0
}
131
132
} // namespace dom
133
} // namespace mozilla