2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-12-23 08:54:23 +04:00
|
|
|
/* 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/. */
|
|
|
|
|
2018-12-30 21:18:30 +03:00
|
|
|
#include "DOMSVGAngle.h"
|
2018-12-31 22:00:42 +03:00
|
|
|
#include "SVGAngle.h"
|
2012-12-23 08:54:23 +04:00
|
|
|
#include "mozilla/dom/SVGAngleBinding.h"
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2018-12-30 21:18:30 +03:00
|
|
|
NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(DOMSVGAngle, mSVGElement)
|
2012-12-23 08:54:23 +04:00
|
|
|
|
2018-12-30 21:18:30 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMSVGAngle, AddRef)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMSVGAngle, Release)
|
2012-12-23 08:54:23 +04:00
|
|
|
|
2018-12-30 21:18:30 +03:00
|
|
|
DOMSVGAngle::DOMSVGAngle(SVGElement* aSVGElement)
|
|
|
|
: mSVGElement(aSVGElement), mType(DOMSVGAngle::CreatedValue) {
|
2018-12-31 22:00:42 +03:00
|
|
|
mVal = new SVGAngle();
|
2018-12-30 01:19:55 +03:00
|
|
|
mVal->Init();
|
|
|
|
}
|
|
|
|
|
2018-12-30 21:18:30 +03:00
|
|
|
JSObject* DOMSVGAngle::WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return SVGAngle_Binding::Wrap(aCx, this, aGivenProto);
|
2012-12-23 08:54:23 +04:00
|
|
|
}
|
|
|
|
|
2018-12-30 21:18:30 +03:00
|
|
|
uint16_t DOMSVGAngle::UnitType() const {
|
2012-12-23 08:54:23 +04:00
|
|
|
if (mType == AnimValue) {
|
|
|
|
return mVal->mAnimValUnit;
|
|
|
|
}
|
|
|
|
return mVal->mBaseValUnit;
|
|
|
|
}
|
|
|
|
|
2018-12-30 21:18:30 +03:00
|
|
|
float DOMSVGAngle::Value() const {
|
2012-12-23 08:54:23 +04:00
|
|
|
if (mType == AnimValue) {
|
|
|
|
return mVal->GetAnimValue();
|
|
|
|
}
|
|
|
|
return mVal->GetBaseValue();
|
|
|
|
}
|
|
|
|
|
2018-12-30 21:18:30 +03:00
|
|
|
void DOMSVGAngle::SetValue(float aValue, ErrorResult& rv) {
|
2012-12-23 08:54:23 +04:00
|
|
|
if (mType == AnimValue) {
|
|
|
|
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bool isBaseVal = mType == BaseValue;
|
2018-07-01 18:12:14 +03:00
|
|
|
mVal->SetBaseValue(aValue, mVal->mBaseValUnit,
|
|
|
|
isBaseVal ? mSVGElement.get() : nullptr, isBaseVal);
|
2012-12-23 08:54:23 +04:00
|
|
|
}
|
|
|
|
|
2018-12-30 21:18:30 +03:00
|
|
|
float DOMSVGAngle::ValueInSpecifiedUnits() const {
|
2012-12-23 08:54:23 +04:00
|
|
|
if (mType == AnimValue) {
|
|
|
|
return mVal->mAnimVal;
|
|
|
|
}
|
|
|
|
return mVal->mBaseVal;
|
|
|
|
}
|
|
|
|
|
2018-12-30 21:18:30 +03:00
|
|
|
void DOMSVGAngle::SetValueInSpecifiedUnits(float aValue, ErrorResult& rv) {
|
2012-12-23 08:54:23 +04:00
|
|
|
if (mType == AnimValue) {
|
|
|
|
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
|
|
|
return;
|
|
|
|
} else if (mType == BaseValue) {
|
|
|
|
mVal->SetBaseValueInSpecifiedUnits(aValue, mSVGElement);
|
|
|
|
} else {
|
|
|
|
mVal->mBaseVal = aValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-30 21:18:30 +03:00
|
|
|
void DOMSVGAngle::NewValueSpecifiedUnits(uint16_t unitType,
|
|
|
|
float valueInSpecifiedUnits,
|
|
|
|
ErrorResult& rv) {
|
2012-12-23 08:54:23 +04:00
|
|
|
if (mType == AnimValue) {
|
|
|
|
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rv = mVal->NewValueSpecifiedUnits(
|
|
|
|
unitType, valueInSpecifiedUnits,
|
2015-08-13 15:22:48 +03:00
|
|
|
mType == BaseValue ? mSVGElement.get() : nullptr);
|
2012-12-23 08:54:23 +04:00
|
|
|
}
|
|
|
|
|
2018-12-30 21:18:30 +03:00
|
|
|
void DOMSVGAngle::ConvertToSpecifiedUnits(uint16_t unitType, ErrorResult& rv) {
|
2012-12-23 08:54:23 +04:00
|
|
|
if (mType == AnimValue) {
|
|
|
|
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
|
|
|
return;
|
|
|
|
}
|
2015-08-13 15:22:48 +03:00
|
|
|
rv = mVal->ConvertToSpecifiedUnits(
|
|
|
|
unitType, mType == BaseValue ? mSVGElement.get() : nullptr);
|
2012-12-23 08:54:23 +04:00
|
|
|
}
|
|
|
|
|
2018-12-30 21:18:30 +03:00
|
|
|
void DOMSVGAngle::SetValueAsString(const nsAString& aValue, ErrorResult& rv) {
|
2012-12-23 08:54:23 +04:00
|
|
|
if (mType == AnimValue) {
|
|
|
|
rv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bool isBaseVal = mType == BaseValue;
|
2015-08-13 15:22:48 +03:00
|
|
|
rv = mVal->SetBaseValueString(aValue, isBaseVal ? mSVGElement.get() : nullptr,
|
|
|
|
isBaseVal);
|
2012-12-23 08:54:23 +04:00
|
|
|
}
|
|
|
|
|
2018-12-30 21:18:30 +03:00
|
|
|
void DOMSVGAngle::GetValueAsString(nsAString& aValue) {
|
2012-12-23 08:54:23 +04:00
|
|
|
if (mType == AnimValue) {
|
|
|
|
mVal->GetAnimValueString(aValue);
|
|
|
|
} else {
|
|
|
|
mVal->GetBaseValueString(aValue);
|
|
|
|
}
|
|
|
|
}
|