Merge mozilla-central to autoland on a CLOSED TREE
[gecko.git] / dom / svg / SVGMaskElement.cpp
blob24aaa723823c8ec04aed990e6bd683ad05f6cbaa
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/. */
7 #include "mozilla/dom/SVGMaskElement.h"
9 #include "nsGkAtoms.h"
10 #include "mozilla/AlreadyAddRefed.h"
11 #include "mozilla/ArrayUtils.h"
12 #include "mozilla/dom/SVGLengthBinding.h"
13 #include "mozilla/dom/SVGMaskElementBinding.h"
14 #include "mozilla/dom/SVGUnitTypesBinding.h"
16 NS_IMPL_NS_NEW_SVG_ELEMENT(Mask)
18 namespace mozilla::dom {
20 using namespace SVGUnitTypes_Binding;
22 JSObject* SVGMaskElement::WrapNode(JSContext* aCx,
23 JS::Handle<JSObject*> aGivenProto) {
24 return SVGMaskElement_Binding::Wrap(aCx, this, aGivenProto);
27 //--------------------- Masks ------------------------
29 SVGElement::LengthInfo SVGMaskElement::sLengthInfo[4] = {
30 {nsGkAtoms::x, -10, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
31 SVGContentUtils::X},
32 {nsGkAtoms::y, -10, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
33 SVGContentUtils::Y},
34 {nsGkAtoms::width, 120, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
35 SVGContentUtils::X},
36 {nsGkAtoms::height, 120, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
37 SVGContentUtils::Y},
40 SVGElement::EnumInfo SVGMaskElement::sEnumInfo[2] = {
41 {nsGkAtoms::maskUnits, sSVGUnitTypesMap, SVG_UNIT_TYPE_OBJECTBOUNDINGBOX},
42 {nsGkAtoms::maskContentUnits, sSVGUnitTypesMap,
43 SVG_UNIT_TYPE_USERSPACEONUSE}};
45 //----------------------------------------------------------------------
46 // Implementation
48 SVGMaskElement::SVGMaskElement(
49 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
50 : SVGMaskElementBase(std::move(aNodeInfo)) {}
52 //----------------------------------------------------------------------
53 // nsINode method
55 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGMaskElement)
57 //----------------------------------------------------------------------
59 already_AddRefed<DOMSVGAnimatedEnumeration> SVGMaskElement::MaskUnits() {
60 return mEnumAttributes[MASKUNITS].ToDOMAnimatedEnum(this);
63 already_AddRefed<DOMSVGAnimatedEnumeration> SVGMaskElement::MaskContentUnits() {
64 return mEnumAttributes[MASKCONTENTUNITS].ToDOMAnimatedEnum(this);
67 already_AddRefed<DOMSVGAnimatedLength> SVGMaskElement::X() {
68 return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
71 already_AddRefed<DOMSVGAnimatedLength> SVGMaskElement::Y() {
72 return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
75 already_AddRefed<DOMSVGAnimatedLength> SVGMaskElement::Width() {
76 return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
79 already_AddRefed<DOMSVGAnimatedLength> SVGMaskElement::Height() {
80 return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
83 //----------------------------------------------------------------------
84 // SVGElement methods
86 /* virtual */
87 bool SVGMaskElement::HasValidDimensions() const {
88 return (!mLengthAttributes[ATTR_WIDTH].IsExplicitlySet() ||
89 mLengthAttributes[ATTR_WIDTH].GetAnimValInSpecifiedUnits() > 0) &&
90 (!mLengthAttributes[ATTR_HEIGHT].IsExplicitlySet() ||
91 mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0);
94 SVGElement::LengthAttributesInfo SVGMaskElement::GetLengthInfo() {
95 return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
96 ArrayLength(sLengthInfo));
99 SVGElement::EnumAttributesInfo SVGMaskElement::GetEnumInfo() {
100 return EnumAttributesInfo(mEnumAttributes, sEnumInfo, ArrayLength(sEnumInfo));
103 } // namespace mozilla::dom