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/SVGViewElement.h"
8 #include "mozilla/dom/SVGViewElementBinding.h"
10 NS_IMPL_NS_NEW_SVG_ELEMENT(View
)
12 namespace mozilla::dom
{
14 using namespace SVGViewElement_Binding
;
16 JSObject
* SVGViewElement::WrapNode(JSContext
* aCx
,
17 JS::Handle
<JSObject
*> aGivenProto
) {
18 return SVGViewElement_Binding::Wrap(aCx
, this, aGivenProto
);
21 SVGEnumMapping
SVGViewElement::sZoomAndPanMap
[] = {
22 {nsGkAtoms::disable
, SVG_ZOOMANDPAN_DISABLE
},
23 {nsGkAtoms::magnify
, SVG_ZOOMANDPAN_MAGNIFY
},
26 SVGElement::EnumInfo
SVGViewElement::sEnumInfo
[1] = {
27 {nsGkAtoms::zoomAndPan
, sZoomAndPanMap
, SVG_ZOOMANDPAN_MAGNIFY
}};
29 //----------------------------------------------------------------------
32 SVGViewElement::SVGViewElement(
33 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
)
34 : SVGViewElementBase(std::move(aNodeInfo
)) {}
36 //----------------------------------------------------------------------
39 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGViewElement
)
41 void SVGViewElement::SetZoomAndPan(uint16_t aZoomAndPan
, ErrorResult
& rv
) {
42 if (aZoomAndPan
== SVG_ZOOMANDPAN_DISABLE
||
43 aZoomAndPan
== SVG_ZOOMANDPAN_MAGNIFY
) {
45 mEnumAttributes
[ZOOMANDPAN
].SetBaseValue(aZoomAndPan
, this, nestedRv
);
46 MOZ_ASSERT(!nestedRv
.Failed(),
47 "We already validated our aZoomAndPan value!");
51 rv
.ThrowRangeError
<MSG_INVALID_ZOOMANDPAN_VALUE_ERROR
>();
54 //----------------------------------------------------------------------
56 already_AddRefed
<SVGAnimatedRect
> SVGViewElement::ViewBox() {
57 return mViewBox
.ToSVGAnimatedRect(this);
60 already_AddRefed
<DOMSVGAnimatedPreserveAspectRatio
>
61 SVGViewElement::PreserveAspectRatio() {
62 return mPreserveAspectRatio
.ToDOMAnimatedPreserveAspectRatio(this);
65 //----------------------------------------------------------------------
68 SVGElement::EnumAttributesInfo
SVGViewElement::GetEnumInfo() {
69 return EnumAttributesInfo(mEnumAttributes
, sEnumInfo
, ArrayLength(sEnumInfo
));
72 SVGAnimatedViewBox
* SVGViewElement::GetAnimatedViewBox() { return &mViewBox
; }
74 SVGAnimatedPreserveAspectRatio
*
75 SVGViewElement::GetAnimatedPreserveAspectRatio() {
76 return &mPreserveAspectRatio
;
79 } // namespace mozilla::dom