summaryrefslogtreecommitdiffstats
path: root/dom/svg/DOMSVGAngle.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /dom/svg/DOMSVGAngle.cpp
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/svg/DOMSVGAngle.cpp')
-rw-r--r--dom/svg/DOMSVGAngle.cpp112
1 files changed, 112 insertions, 0 deletions
diff --git a/dom/svg/DOMSVGAngle.cpp b/dom/svg/DOMSVGAngle.cpp
new file mode 100644
index 0000000000..f2cc45fd87
--- /dev/null
+++ b/dom/svg/DOMSVGAngle.cpp
@@ -0,0 +1,112 @@
+/* -*- 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 "DOMSVGAngle.h"
+#include "SVGAnimatedOrient.h"
+#include "mozilla/dom/SVGAngleBinding.h"
+#include "mozilla/dom/SVGSVGElement.h"
+
+namespace mozilla::dom {
+
+NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(DOMSVGAngle, mSVGElement)
+
+DOMSVGAngle::DOMSVGAngle(SVGSVGElement* aSVGElement)
+ : mSVGElement(aSVGElement), mType(AngleType::CreatedValue) {
+ mVal = new SVGAnimatedOrient();
+ mVal->Init();
+}
+
+JSObject* DOMSVGAngle::WrapObject(JSContext* aCx,
+ JS::Handle<JSObject*> aGivenProto) {
+ return SVGAngle_Binding::Wrap(aCx, this, aGivenProto);
+}
+
+uint16_t DOMSVGAngle::UnitType() const {
+ if (mType == AngleType::AnimValue) {
+ mSVGElement->FlushAnimations();
+ return mVal->mAnimValUnit;
+ }
+ return mVal->mBaseValUnit;
+}
+
+float DOMSVGAngle::Value() const {
+ if (mType == AngleType::AnimValue) {
+ mSVGElement->FlushAnimations();
+ return mVal->GetAnimValue();
+ }
+ return mVal->GetBaseValue();
+}
+
+void DOMSVGAngle::SetValue(float aValue, ErrorResult& rv) {
+ if (mType == AngleType::AnimValue) {
+ rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
+ return;
+ }
+ bool isBaseVal = mType == AngleType::BaseValue;
+ mVal->SetBaseValue(aValue, mVal->mBaseValUnit,
+ isBaseVal ? mSVGElement.get() : nullptr, isBaseVal);
+}
+
+float DOMSVGAngle::ValueInSpecifiedUnits() const {
+ if (mType == AngleType::AnimValue) {
+ return mVal->mAnimVal;
+ }
+ return mVal->mBaseVal;
+}
+
+void DOMSVGAngle::SetValueInSpecifiedUnits(float aValue, ErrorResult& rv) {
+ if (mType == AngleType::AnimValue) {
+ rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
+ return;
+ }
+ if (mType == AngleType::BaseValue) {
+ mVal->SetBaseValueInSpecifiedUnits(aValue, mSVGElement);
+ } else {
+ mVal->mBaseVal = aValue;
+ }
+}
+
+void DOMSVGAngle::NewValueSpecifiedUnits(uint16_t unitType,
+ float valueInSpecifiedUnits,
+ ErrorResult& rv) {
+ if (mType == AngleType::AnimValue) {
+ rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
+ return;
+ }
+ rv = mVal->NewValueSpecifiedUnits(
+ unitType, valueInSpecifiedUnits,
+ mType == AngleType::BaseValue ? mSVGElement.get() : nullptr);
+}
+
+void DOMSVGAngle::ConvertToSpecifiedUnits(uint16_t unitType, ErrorResult& rv) {
+ if (mType == AngleType::AnimValue) {
+ rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
+ return;
+ }
+ rv = mVal->ConvertToSpecifiedUnits(
+ unitType, mType == AngleType::BaseValue ? mSVGElement.get() : nullptr);
+}
+
+void DOMSVGAngle::SetValueAsString(const nsAString& aValue, ErrorResult& rv) {
+ if (mType == AngleType::AnimValue) {
+ rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
+ return;
+ }
+ bool isBaseVal = mType == AngleType::BaseValue;
+ rv = mVal->SetBaseValueString(aValue, isBaseVal ? mSVGElement.get() : nullptr,
+ isBaseVal);
+}
+
+void DOMSVGAngle::GetValueAsString(nsAString& aValue) {
+ if (mType == AngleType::AnimValue) {
+ mSVGElement->FlushAnimations();
+ mVal->GetAnimAngleValueString(aValue);
+ } else {
+ mVal->GetBaseAngleValueString(aValue);
+ }
+}
+
+} // namespace mozilla::dom