From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- dom/svg/SVGViewElement.cpp | 79 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 dom/svg/SVGViewElement.cpp (limited to 'dom/svg/SVGViewElement.cpp') diff --git a/dom/svg/SVGViewElement.cpp b/dom/svg/SVGViewElement.cpp new file mode 100644 index 0000000000..b7ea5a7541 --- /dev/null +++ b/dom/svg/SVGViewElement.cpp @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/SVGViewElement.h" +#include "mozilla/dom/SVGViewElementBinding.h" + +NS_IMPL_NS_NEW_SVG_ELEMENT(View) + +namespace mozilla::dom { + +using namespace SVGViewElement_Binding; + +JSObject* SVGViewElement::WrapNode(JSContext* aCx, + JS::Handle aGivenProto) { + return SVGViewElement_Binding::Wrap(aCx, this, aGivenProto); +} + +SVGEnumMapping SVGViewElement::sZoomAndPanMap[] = { + {nsGkAtoms::disable, SVG_ZOOMANDPAN_DISABLE}, + {nsGkAtoms::magnify, SVG_ZOOMANDPAN_MAGNIFY}, + {nullptr, 0}}; + +SVGElement::EnumInfo SVGViewElement::sEnumInfo[1] = { + {nsGkAtoms::zoomAndPan, sZoomAndPanMap, SVG_ZOOMANDPAN_MAGNIFY}}; + +//---------------------------------------------------------------------- +// Implementation + +SVGViewElement::SVGViewElement( + already_AddRefed&& aNodeInfo) + : SVGViewElementBase(std::move(aNodeInfo)) {} + +//---------------------------------------------------------------------- +// nsINode methods + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGViewElement) + +void SVGViewElement::SetZoomAndPan(uint16_t aZoomAndPan, ErrorResult& rv) { + if (aZoomAndPan == SVG_ZOOMANDPAN_DISABLE || + aZoomAndPan == SVG_ZOOMANDPAN_MAGNIFY) { + ErrorResult nestedRv; + mEnumAttributes[ZOOMANDPAN].SetBaseValue(aZoomAndPan, this, nestedRv); + MOZ_ASSERT(!nestedRv.Failed(), + "We already validated our aZoomAndPan value!"); + return; + } + + rv.ThrowRangeError(); +} + +//---------------------------------------------------------------------- + +already_AddRefed SVGViewElement::ViewBox() { + return mViewBox.ToSVGAnimatedRect(this); +} + +already_AddRefed +SVGViewElement::PreserveAspectRatio() { + return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(this); +} + +//---------------------------------------------------------------------- +// SVGElement methods + +SVGElement::EnumAttributesInfo SVGViewElement::GetEnumInfo() { + return EnumAttributesInfo(mEnumAttributes, sEnumInfo, ArrayLength(sEnumInfo)); +} + +SVGAnimatedViewBox* SVGViewElement::GetAnimatedViewBox() { return &mViewBox; } + +SVGAnimatedPreserveAspectRatio* +SVGViewElement::GetAnimatedPreserveAspectRatio() { + return &mPreserveAspectRatio; +} + +} // namespace mozilla::dom -- cgit v1.2.3