Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/svg/SVGForeignObjectElement.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/ArrayUtils.h"
8
9
#include "nsCOMPtr.h"
10
#include "mozilla/dom/SVGDocument.h"
11
#include "mozilla/dom/SVGForeignObjectElement.h"
12
#include "mozilla/dom/SVGForeignObjectElementBinding.h"
13
#include "mozilla/dom/SVGLengthBinding.h"
14
15
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(ForeignObject)
16
17
namespace mozilla {
18
namespace dom {
19
20
JSObject*
21
SVGForeignObjectElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
22
0
{
23
0
  return SVGForeignObjectElement_Binding::Wrap(aCx, this, aGivenProto);
24
0
}
25
26
nsSVGElement::LengthInfo SVGForeignObjectElement::sLengthInfo[4] =
27
{
28
  { &nsGkAtoms::x, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
29
  { &nsGkAtoms::y, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
30
  { &nsGkAtoms::width, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
31
  { &nsGkAtoms::height, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
32
};
33
34
//----------------------------------------------------------------------
35
// Implementation
36
37
SVGForeignObjectElement::SVGForeignObjectElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
38
  : SVGGraphicsElement(std::move(aNodeInfo))
39
0
{
40
0
}
41
42
//----------------------------------------------------------------------
43
// nsINode methods
44
45
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGForeignObjectElement)
46
47
//----------------------------------------------------------------------
48
49
already_AddRefed<SVGAnimatedLength>
50
SVGForeignObjectElement::X()
51
0
{
52
0
  return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
53
0
}
54
55
already_AddRefed<SVGAnimatedLength>
56
SVGForeignObjectElement::Y()
57
0
{
58
0
  return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
59
0
}
60
61
already_AddRefed<SVGAnimatedLength>
62
SVGForeignObjectElement::Width()
63
0
{
64
0
  return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
65
0
}
66
67
already_AddRefed<SVGAnimatedLength>
68
SVGForeignObjectElement::Height()
69
0
{
70
0
  return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
71
0
}
72
73
//----------------------------------------------------------------------
74
// nsSVGElement methods
75
76
/* virtual */ gfxMatrix
77
SVGForeignObjectElement::PrependLocalTransformsTo(
78
  const gfxMatrix &aMatrix, SVGTransformTypes aWhich) const
79
0
{
80
0
  // 'transform' attribute:
81
0
  gfxMatrix fromUserSpace =
82
0
    SVGGraphicsElement::PrependLocalTransformsTo(aMatrix, aWhich);
83
0
  if (aWhich == eUserSpaceToParent) {
84
0
    return fromUserSpace;
85
0
  }
86
0
  // our 'x' and 'y' attributes:
87
0
  float x, y;
88
0
  const_cast<SVGForeignObjectElement*>(this)->
89
0
    GetAnimatedLengthValues(&x, &y, nullptr);
90
0
  gfxMatrix toUserSpace = gfxMatrix::Translation(x, y);
91
0
  if (aWhich == eChildToUserSpace) {
92
0
    return toUserSpace * aMatrix;
93
0
  }
94
0
  MOZ_ASSERT(aWhich == eAllTransforms, "Unknown TransformTypes");
95
0
  return toUserSpace * fromUserSpace;
96
0
}
97
98
/* virtual */ bool
99
SVGForeignObjectElement::HasValidDimensions() const
100
0
{
101
0
  return mLengthAttributes[ATTR_WIDTH].IsExplicitlySet() &&
102
0
         mLengthAttributes[ATTR_WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
103
0
         mLengthAttributes[ATTR_HEIGHT].IsExplicitlySet() &&
104
0
         mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0;
105
0
}
106
107
//----------------------------------------------------------------------
108
// nsIContent methods
109
110
NS_IMETHODIMP_(bool)
111
SVGForeignObjectElement::IsAttributeMapped(const nsAtom* name) const
112
0
{
113
0
  static const MappedAttributeEntry* const map[] = {
114
0
    sFEFloodMap,
115
0
    sFiltersMap,
116
0
    sFontSpecificationMap,
117
0
    sGradientStopMap,
118
0
    sLightingEffectsMap,
119
0
    sMarkersMap,
120
0
    sTextContentElementsMap,
121
0
    sViewportsMap
122
0
  };
123
0
124
0
  return FindAttributeDependence(name, map) ||
125
0
    SVGGraphicsElement::IsAttributeMapped(name);
126
0
}
127
128
//----------------------------------------------------------------------
129
// nsSVGElement methods
130
131
nsSVGElement::LengthAttributesInfo
132
SVGForeignObjectElement::GetLengthInfo()
133
0
{
134
0
  return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
135
0
                              ArrayLength(sLengthInfo));
136
0
}
137
138
} // namespace dom
139
} // namespace mozilla
140