float DOMSVGLength::GetValue(ErrorResult& aRv) { if (mVal) { if (mIsAnimValItem) { mSVGElement->FlushAnimations(); return mVal->GetAnimValue(mSVGElement); } return mVal->GetBaseValue(mSVGElement); } if (mIsAnimValItem && HasOwner()) { Element()->FlushAnimations(); // May make HasOwner() == false } if (HasOwner()) { float value = InternalItem().GetValueInUserUnits(Element(), Axis()); if (!IsFinite(value)) { aRv.Throw(NS_ERROR_FAILURE); } return value; } else if (mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER || mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_PX) { return mValue; } // else [SVGWG issue] Can't convert this length's value to user units // ReportToConsole aRv.Throw(NS_ERROR_FAILURE); return 0.0f; }
uint16_t DOMSVGLength::UnitType() { if (mVal) { if (mIsAnimValItem) { mSVGElement->FlushAnimations(); } return mVal->mSpecifiedUnitType; } if (mIsAnimValItem && HasOwner()) { Element()->FlushAnimations(); // May make HasOwner() == false } return HasOwner() ? InternalItem().GetUnit() : mUnit; }
float DOMSVGLength::ValueInSpecifiedUnits() { if (mVal) { if (mIsAnimValItem) { mSVGElement->FlushAnimations(); return mVal->mAnimVal; } return mVal->mBaseVal; } if (mIsAnimValItem && HasOwner()) { Element()->FlushAnimations(); // May make HasOwner() == false } return HasOwner() ? InternalItem().GetValueInCurrentUnits() : mValue; }
void DOMSVGLength::NewValueSpecifiedUnits(uint16_t aUnit, float aValue, ErrorResult& aRv) { if (mIsAnimValItem) { aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR); return; } if (mVal) { mVal->NewValueSpecifiedUnits(aUnit, aValue, mSVGElement); return; } if (!SVGLength::IsValidUnitType(aUnit)) { aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR); return; } if (HasOwner()) { if (InternalItem().GetUnit() == aUnit && InternalItem().GetValueInCurrentUnits() == aValue) { return; } AutoChangeLengthNotifier notifier(this); InternalItem().SetValueAndUnit(aValue, uint8_t(aUnit)); return; } mUnit = uint8_t(aUnit); mValue = aValue; }
void DOMSVGLength::SetValueAsString(const nsAString& aValue, ErrorResult& aRv) { if (mIsAnimValItem) { aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR); return; } if (mVal) { aRv = mVal->SetBaseValueString(aValue, mSVGElement, true); return; } SVGLength value; if (!value.SetValueFromString(aValue)) { aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR); return; } if (HasOwner()) { if (InternalItem() == value) { return; } AutoChangeLengthNotifier notifier(this); InternalItem() = value; return; } mValue = value.GetValueInCurrentUnits(); mUnit = value.GetUnit(); }
SVGLength DOMSVGLength::ToSVGLength() { if (HasOwner()) { return SVGLength(InternalItem().GetValueInCurrentUnits(), InternalItem().GetUnit()); } return SVGLength(mValue, mUnit); }
void DOMSVGTransform::NotifyElementDidChange(const nsAttrValue& aEmptyOrOldValue) { if (HasOwner()) { Element()->DidChangeTransformList(aEmptyOrOldValue); if (mList->mAList->IsAnimating()) { Element()->AnimationNeedsResample(); } } }
void DOMSVGLength::InsertingIntoList(DOMSVGLengthList* aList, uint8_t aAttrEnum, uint32_t aListIndex, bool aIsAnimValItem) { NS_ASSERTION(!HasOwner(), "Inserting item that is already in a list"); mList = aList; mAttrEnum = aAttrEnum; mListIndex = aListIndex; mIsAnimValItem = aIsAnimValItem; MOZ_ASSERT(IndexIsValid(), "Bad index for DOMSVGLength!"); }
void DOMSVGLength::GetValueAsString(nsAString& aValue) { if (mVal) { if (mIsAnimValItem) { mSVGElement->FlushAnimations(); mVal->GetAnimValueString(aValue); } else { mVal->GetBaseValueString(aValue); } return; } if (mIsAnimValItem && HasOwner()) { Element()->FlushAnimations(); // May make HasOwner() == false } if (HasOwner()) { InternalItem().GetValueAsString(aValue); return; } SVGLength(mValue, mUnit).GetValueAsString(aValue); }
void SVGTransform::InsertingIntoList(DOMSVGTransformList *aList, uint32_t aListIndex, bool aIsAnimValItem) { NS_ABORT_IF_FALSE(!HasOwner(), "Inserting item that is already in a list"); mList = aList; mListIndex = aListIndex; mIsAnimValItem = aIsAnimValItem; mTransform = nullptr; NS_ABORT_IF_FALSE(IndexIsValid(), "Bad index for DOMSVGLength!"); }
DOMSVGLength* DOMSVGLength::Copy() { NS_ASSERTION(HasOwner() || IsReflectingAttribute(), "unexpected caller"); DOMSVGLength* copy = new DOMSVGLength(); uint16_t unit; float value; if (mVal) { unit = mVal->mSpecifiedUnitType; value = mIsAnimValItem ? mVal->mAnimVal : mVal->mBaseVal; } else { SVGLength& length = InternalItem(); unit = length.GetUnit(); value = length.GetValueInCurrentUnits(); } copy->NewValueSpecifiedUnits(unit, value, IgnoreErrors()); return copy; }
void DOMSVGLength::ConvertToSpecifiedUnits(uint16_t aUnit, ErrorResult& aRv) { if (mIsAnimValItem) { aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR); return; } if (mVal) { mVal->ConvertToSpecifiedUnits(aUnit, mSVGElement); return; } if (!SVGLength::IsValidUnitType(aUnit)) { aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR); return; } if (HasOwner()) { if (InternalItem().GetUnit() == aUnit) { return; } float val = InternalItem().GetValueInSpecifiedUnit( aUnit, Element(), Axis()); if (IsFinite(val)) { AutoChangeLengthNotifier notifier(this); InternalItem().SetValueAndUnit(val, aUnit); return; } } else { SVGLength len(mValue, mUnit); float val = len.GetValueInSpecifiedUnit(aUnit, nullptr, 0); if (IsFinite(val)) { mValue = val; mUnit = aUnit; return; } } // else [SVGWG issue] Can't convert unit // ReportToConsole aRv.Throw(NS_ERROR_FAILURE); }
void DOMSVGLength::SetValue(float aUserUnitValue, ErrorResult& aRv) { if (mIsAnimValItem) { aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR); return; } if (mVal) { mVal->SetBaseValue(aUserUnitValue, mSVGElement, true); return; } // Although the value passed in is in user units, this method does not turn // this length into a user unit length. Instead it converts the user unit // value to this length's current unit and sets that, leaving this length's // unit as it is. if (HasOwner()) { if (InternalItem().GetValueInUserUnits(Element(), Axis()) == aUserUnitValue) { return; } float uuPerUnit = InternalItem().GetUserUnitsPerUnit(Element(), Axis()); if (uuPerUnit > 0) { float newValue = aUserUnitValue / uuPerUnit; if (IsFinite(newValue)) { AutoChangeLengthNotifier notifier(this); InternalItem().SetValueAndUnit(newValue, InternalItem().GetUnit()); return; } } } else if (mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER || mUnit == nsIDOMSVGLength::SVG_LENGTHTYPE_PX) { mValue = aUserUnitValue; return; } // else [SVGWG issue] Can't convert user unit value to this length's unit // ReportToConsole aRv.Throw(NS_ERROR_FAILURE); }
void DOMSVGLength::SetValueInSpecifiedUnits(float aValue, ErrorResult& aRv) { if (mIsAnimValItem) { aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR); return; } if (mVal) { mVal->SetBaseValueInSpecifiedUnits(aValue, mSVGElement, true); return; } if (HasOwner()) { if (InternalItem().GetValueInCurrentUnits() == aValue) { return; } AutoChangeLengthNotifier notifier(this); InternalItem().SetValueInCurrentUnits(aValue); return; } mValue = aValue; }
/** * * Set the window rectangle, and notify owner * * @param "const TRect& aWinRect" * The window rectangle * @xxxx * */ void TWindow::SetWinRectAndNotifyOwner(const TRect& aWinRect) { if (HasOwner()) iOwner->NotifyWindowChanged(aWinRect); }