nsresult SVGViewBoxSMILType::Interpolate(const nsSMILValue& aStartVal, const nsSMILValue& aEndVal, double aUnitDistance, nsSMILValue& aResult) const { NS_PRECONDITION(aStartVal.mType == aEndVal.mType, "Trying to interpolate different types"); NS_PRECONDITION(aStartVal.mType == this, "Unexpected types for interpolation"); NS_PRECONDITION(aResult.mType == this, "Unexpected result type"); const nsSVGViewBoxRect* start = static_cast<const nsSVGViewBoxRect*>(aStartVal.mU.mPtr); const nsSVGViewBoxRect* end = static_cast<const nsSVGViewBoxRect*>(aEndVal.mU.mPtr); nsSVGViewBoxRect* current = static_cast<nsSVGViewBoxRect*>(aResult.mU.mPtr); float x = (start->x + (end->x - start->x) * aUnitDistance); float y = (start->y + (end->y - start->y) * aUnitDistance); float width = (start->width + (end->width - start->width) * aUnitDistance); float height = (start->height + (end->height - start->height) * aUnitDistance); *current = nsSVGViewBoxRect(x, y, width, height); return NS_OK; }
nsSVGViewBoxRect SVGMarkerElement::GetViewBoxRect() { if (mViewBox.HasRect()) { return mViewBox.GetAnimValue(); } return nsSVGViewBoxRect( 0, 0, mLengthAttributes[MARKERWIDTH].GetAnimValue(mCoordCtx), mLengthAttributes[MARKERHEIGHT].GetAnimValue(mCoordCtx)); }