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-05-21 15:12:37 +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/. */
|
2009-02-03 17:42:24 +03:00
|
|
|
|
|
|
|
#include "nsSVGViewBox.h"
|
2015-05-29 23:10:41 +03:00
|
|
|
|
|
|
|
#include "mozilla/Move.h"
|
2010-05-04 18:43:48 +04:00
|
|
|
#include "nsCharSeparatedTokenizer.h"
|
2010-02-19 00:51:00 +03:00
|
|
|
#include "nsSMILValue.h"
|
2013-10-01 11:50:40 +04:00
|
|
|
#include "nsTextFormatter.h"
|
2012-09-22 23:26:05 +04:00
|
|
|
#include "SVGContentUtils.h"
|
2010-02-19 00:51:00 +03:00
|
|
|
#include "SVGViewBoxSMILType.h"
|
|
|
|
|
2010-05-04 18:43:48 +04:00
|
|
|
#define NUM_VIEWBOX_COMPONENTS 4
|
2010-02-19 00:51:00 +03:00
|
|
|
using namespace mozilla;
|
2009-02-03 17:42:24 +03:00
|
|
|
|
2010-02-21 00:13:11 +03:00
|
|
|
/* Implementation of nsSVGViewBoxRect methods */
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2010-02-21 00:13:11 +03:00
|
|
|
nsSVGViewBoxRect::operator==(const nsSVGViewBoxRect& aOther) const
|
|
|
|
{
|
|
|
|
if (&aOther == this)
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2010-02-21 00:13:11 +03:00
|
|
|
|
2013-02-26 20:58:06 +04:00
|
|
|
return (none && aOther.none) ||
|
|
|
|
(!none && !aOther.none &&
|
|
|
|
x == aOther.x &&
|
|
|
|
y == aOther.y &&
|
|
|
|
width == aOther.width &&
|
|
|
|
height == aOther.height);
|
2010-02-21 00:13:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Cycle collection macros for nsSVGViewBox */
|
|
|
|
|
2013-05-16 22:06:21 +04:00
|
|
|
NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(nsSVGViewBox::DOMBaseVal, mSVGElement)
|
|
|
|
NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(nsSVGViewBox::DOMAnimVal, mSVGElement)
|
2009-02-03 17:42:24 +03:00
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSVGViewBox::DOMBaseVal)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGViewBox::DOMBaseVal)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSVGViewBox::DOMAnimVal)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGViewBox::DOMAnimVal)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGViewBox::DOMBaseVal)
|
2013-05-16 22:06:21 +04:00
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
2009-02-03 17:42:24 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGViewBox::DOMAnimVal)
|
2013-05-16 22:06:21 +04:00
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
2009-02-03 17:42:24 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2012-12-21 13:18:58 +04:00
|
|
|
static nsSVGAttrTearoffTable<nsSVGViewBox, nsSVGViewBox::DOMBaseVal>
|
|
|
|
sBaseSVGViewBoxTearoffTable;
|
|
|
|
static nsSVGAttrTearoffTable<nsSVGViewBox, nsSVGViewBox::DOMAnimVal>
|
|
|
|
sAnimSVGViewBoxTearoffTable;
|
2013-05-20 15:46:12 +04:00
|
|
|
nsSVGAttrTearoffTable<nsSVGViewBox, dom::SVGAnimatedRect>
|
2013-05-09 21:42:12 +04:00
|
|
|
nsSVGViewBox::sSVGAnimatedRectTearoffTable;
|
2012-12-21 13:18:58 +04:00
|
|
|
|
|
|
|
|
2010-02-21 00:13:11 +03:00
|
|
|
/* Implementation of nsSVGViewBox methods */
|
2009-02-03 17:42:24 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGViewBox::Init()
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
mHasBaseVal = false;
|
2016-06-01 19:21:03 +03:00
|
|
|
// We shouldn't use mBaseVal for rendering (its usages should be guarded with
|
|
|
|
// "mHasBaseVal" checks), but just in case we do by accident, this will
|
|
|
|
// ensure that we treat it as "none" and ignore its numeric values:
|
|
|
|
mBaseVal.none = true;
|
|
|
|
|
2013-02-26 20:58:06 +04:00
|
|
|
mAnimVal = nullptr;
|
2009-02-03 17:42:24 +03:00
|
|
|
}
|
|
|
|
|
2016-05-03 17:40:26 +03:00
|
|
|
bool
|
|
|
|
nsSVGViewBox::HasRect() const
|
|
|
|
{
|
|
|
|
// Check mAnimVal if we have one; otherwise, check mBaseVal if we have one;
|
|
|
|
// otherwise, just return false (we clearly do not have a rect).
|
|
|
|
const nsSVGViewBoxRect* rect = mAnimVal;
|
|
|
|
if (!rect) {
|
|
|
|
if (!mHasBaseVal) {
|
|
|
|
// no anim val, no base val --> no viewbox rect
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
rect = &mBaseVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
return !rect->none && rect->width >= 0 && rect->height >= 0;
|
|
|
|
}
|
|
|
|
|
2010-02-19 00:51:00 +03:00
|
|
|
void
|
2013-02-26 20:58:06 +04:00
|
|
|
nsSVGViewBox::SetAnimValue(const nsSVGViewBoxRect& aRect,
|
2010-02-19 00:51:00 +03:00
|
|
|
nsSVGElement *aSVGElement)
|
|
|
|
{
|
|
|
|
if (!mAnimVal) {
|
|
|
|
// it's okay if allocation fails - and no point in reporting that
|
2013-02-26 20:58:06 +04:00
|
|
|
mAnimVal = new nsSVGViewBoxRect(aRect);
|
2010-02-19 00:51:00 +03:00
|
|
|
} else {
|
2013-02-26 20:58:06 +04:00
|
|
|
if (aRect == *mAnimVal) {
|
2012-06-02 03:53:06 +04:00
|
|
|
return;
|
|
|
|
}
|
2013-02-26 20:58:06 +04:00
|
|
|
*mAnimVal = aRect;
|
2010-02-19 00:51:00 +03:00
|
|
|
}
|
|
|
|
aSVGElement->DidAnimateViewBox();
|
2009-02-03 17:42:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-05-17 14:02:41 +04:00
|
|
|
nsSVGViewBox::SetBaseValue(const nsSVGViewBoxRect& aRect,
|
2011-10-09 19:25:07 +04:00
|
|
|
nsSVGElement *aSVGElement)
|
2009-02-03 17:42:24 +03:00
|
|
|
{
|
2013-02-26 20:58:06 +04:00
|
|
|
if (!mHasBaseVal || mBaseVal == aRect) {
|
|
|
|
// This method is used to set a single x, y, width
|
|
|
|
// or height value. It can't create a base value
|
|
|
|
// as the other components may be undefined. We record
|
|
|
|
// the new value though, so as not to lose data.
|
|
|
|
mBaseVal = aRect;
|
2012-02-16 03:40:46 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAttrValue emptyOrOldValue = aSVGElement->WillChangeViewBox();
|
|
|
|
|
2012-05-17 14:02:41 +04:00
|
|
|
mBaseVal = aRect;
|
2011-10-17 18:59:28 +04:00
|
|
|
mHasBaseVal = true;
|
2009-02-03 17:42:24 +03:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
aSVGElement->DidChangeViewBox(emptyOrOldValue);
|
2010-02-19 00:51:00 +03:00
|
|
|
if (mAnimVal) {
|
|
|
|
aSVGElement->AnimationNeedsResample();
|
|
|
|
}
|
2009-02-03 17:42:24 +03:00
|
|
|
}
|
|
|
|
|
2010-02-19 00:51:00 +03:00
|
|
|
static nsresult
|
|
|
|
ToSVGViewBoxRect(const nsAString& aStr, nsSVGViewBoxRect *aViewBox)
|
2009-02-03 17:42:24 +03:00
|
|
|
{
|
2013-02-26 20:58:06 +04:00
|
|
|
if (aStr.EqualsLiteral("none")) {
|
|
|
|
aViewBox->none = true;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-07-23 12:41:17 +04:00
|
|
|
nsCharSeparatedTokenizerTemplate<IsSVGWhitespace>
|
2010-05-04 18:43:48 +04:00
|
|
|
tokenizer(aStr, ',',
|
|
|
|
nsCharSeparatedTokenizer::SEPARATOR_OPTIONAL);
|
|
|
|
float vals[NUM_VIEWBOX_COMPONENTS];
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t i;
|
2010-05-04 18:43:48 +04:00
|
|
|
for (i = 0; i < NUM_VIEWBOX_COMPONENTS && tokenizer.hasMoreTokens(); ++i) {
|
2013-10-01 11:50:40 +04:00
|
|
|
if (!SVGContentUtils::ParseNumber(tokenizer.nextToken(), vals[i])) {
|
|
|
|
return NS_ERROR_DOM_SYNTAX_ERR;
|
2010-05-04 18:43:48 +04:00
|
|
|
}
|
2009-02-03 17:42:24 +03:00
|
|
|
}
|
2010-05-04 18:43:48 +04:00
|
|
|
|
|
|
|
if (i != NUM_VIEWBOX_COMPONENTS || // Too few values.
|
|
|
|
tokenizer.hasMoreTokens() || // Too many values.
|
2013-09-17 16:52:39 +04:00
|
|
|
tokenizer.separatorAfterCurrentToken()) { // Trailing comma.
|
2010-05-04 18:43:48 +04:00
|
|
|
return NS_ERROR_DOM_SYNTAX_ERR;
|
2009-02-03 17:42:24 +03:00
|
|
|
}
|
|
|
|
|
2011-07-23 12:41:17 +04:00
|
|
|
aViewBox->x = vals[0];
|
|
|
|
aViewBox->y = vals[1];
|
|
|
|
aViewBox->width = vals[2];
|
|
|
|
aViewBox->height = vals[3];
|
2013-02-26 20:58:06 +04:00
|
|
|
aViewBox->none = false;
|
2011-07-23 12:41:17 +04:00
|
|
|
|
2010-05-04 18:43:48 +04:00
|
|
|
return NS_OK;
|
2009-02-03 17:42:24 +03:00
|
|
|
}
|
|
|
|
|
2010-02-19 00:51:00 +03:00
|
|
|
nsresult
|
|
|
|
nsSVGViewBox::SetBaseValueString(const nsAString& aValue,
|
2012-08-25 21:02:34 +04:00
|
|
|
nsSVGElement *aSVGElement,
|
|
|
|
bool aDoSetAttr)
|
2010-02-19 00:51:00 +03:00
|
|
|
{
|
|
|
|
nsSVGViewBoxRect viewBox;
|
2011-10-09 19:25:07 +04:00
|
|
|
|
2013-02-26 20:58:06 +04:00
|
|
|
nsresult rv = ToSVGViewBoxRect(aValue, &viewBox);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2013-07-24 08:48:12 +04:00
|
|
|
// Comparison against mBaseVal is only valid if we currently have a base val.
|
|
|
|
if (mHasBaseVal && viewBox == mBaseVal) {
|
2013-02-26 20:58:06 +04:00
|
|
|
return NS_OK;
|
2010-02-19 00:51:00 +03:00
|
|
|
}
|
2013-02-26 20:58:06 +04:00
|
|
|
|
|
|
|
nsAttrValue emptyOrOldValue;
|
|
|
|
if (aDoSetAttr) {
|
|
|
|
emptyOrOldValue = aSVGElement->WillChangeViewBox();
|
|
|
|
}
|
|
|
|
mHasBaseVal = true;
|
|
|
|
mBaseVal = viewBox;
|
|
|
|
|
|
|
|
if (aDoSetAttr) {
|
|
|
|
aSVGElement->DidChangeViewBox(emptyOrOldValue);
|
|
|
|
}
|
|
|
|
if (mAnimVal) {
|
|
|
|
aSVGElement->AnimationNeedsResample();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
2010-02-19 00:51:00 +03:00
|
|
|
}
|
|
|
|
|
2009-02-03 17:42:24 +03:00
|
|
|
void
|
|
|
|
nsSVGViewBox::GetBaseValueString(nsAString& aValue) const
|
|
|
|
{
|
2013-02-26 20:58:06 +04:00
|
|
|
if (mBaseVal.none) {
|
|
|
|
aValue.AssignLiteral("none");
|
|
|
|
return;
|
|
|
|
}
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t buf[200];
|
|
|
|
nsTextFormatter::snprintf(buf, sizeof(buf)/sizeof(char16_t),
|
2016-07-21 08:03:25 +03:00
|
|
|
u"%g %g %g %g",
|
2009-02-03 17:42:24 +03:00
|
|
|
(double)mBaseVal.x, (double)mBaseVal.y,
|
|
|
|
(double)mBaseVal.width, (double)mBaseVal.height);
|
|
|
|
aValue.Assign(buf);
|
|
|
|
}
|
|
|
|
|
2013-05-20 15:46:12 +04:00
|
|
|
|
|
|
|
already_AddRefed<dom::SVGAnimatedRect>
|
|
|
|
nsSVGViewBox::ToSVGAnimatedRect(nsSVGElement* aSVGElement)
|
2009-02-03 17:42:24 +03:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<dom::SVGAnimatedRect> domAnimatedRect =
|
2012-12-21 13:18:58 +04:00
|
|
|
sSVGAnimatedRectTearoffTable.GetTearoff(this);
|
|
|
|
if (!domAnimatedRect) {
|
2013-05-09 21:42:12 +04:00
|
|
|
domAnimatedRect = new dom::SVGAnimatedRect(this, aSVGElement);
|
2012-12-21 13:18:58 +04:00
|
|
|
sSVGAnimatedRectTearoffTable.AddTearoff(this, domAnimatedRect);
|
|
|
|
}
|
2009-02-03 17:42:24 +03:00
|
|
|
|
2013-05-20 15:46:12 +04:00
|
|
|
return domAnimatedRect.forget();
|
2009-02-03 17:42:24 +03:00
|
|
|
}
|
|
|
|
|
2013-05-20 15:46:12 +04:00
|
|
|
already_AddRefed<dom::SVGIRect>
|
|
|
|
nsSVGViewBox::ToDOMBaseVal(nsSVGElement *aSVGElement)
|
2012-12-21 13:18:58 +04:00
|
|
|
{
|
2013-02-26 20:58:06 +04:00
|
|
|
if (!mHasBaseVal || mBaseVal.none) {
|
2013-05-20 15:46:12 +04:00
|
|
|
return nullptr;
|
2013-02-26 20:58:06 +04:00
|
|
|
}
|
2013-05-20 15:46:12 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DOMBaseVal> domBaseVal =
|
2012-12-21 13:18:58 +04:00
|
|
|
sBaseSVGViewBoxTearoffTable.GetTearoff(this);
|
|
|
|
if (!domBaseVal) {
|
|
|
|
domBaseVal = new DOMBaseVal(this, aSVGElement);
|
|
|
|
sBaseSVGViewBoxTearoffTable.AddTearoff(this, domBaseVal);
|
|
|
|
}
|
2009-02-03 17:42:24 +03:00
|
|
|
|
2013-05-20 15:46:12 +04:00
|
|
|
return domBaseVal.forget();
|
2009-02-03 17:42:24 +03:00
|
|
|
}
|
|
|
|
|
2012-12-21 13:18:58 +04:00
|
|
|
nsSVGViewBox::DOMBaseVal::~DOMBaseVal()
|
2009-02-03 17:42:24 +03:00
|
|
|
{
|
2012-12-21 13:18:58 +04:00
|
|
|
sBaseSVGViewBoxTearoffTable.RemoveTearoff(mVal);
|
|
|
|
}
|
2009-02-03 17:42:24 +03:00
|
|
|
|
2013-05-20 15:46:12 +04:00
|
|
|
already_AddRefed<dom::SVGIRect>
|
|
|
|
nsSVGViewBox::ToDOMAnimVal(nsSVGElement *aSVGElement)
|
2012-12-21 13:18:58 +04:00
|
|
|
{
|
2013-02-26 20:58:06 +04:00
|
|
|
if ((mAnimVal && mAnimVal->none) ||
|
|
|
|
(!mAnimVal && (!mHasBaseVal || mBaseVal.none))) {
|
2013-05-20 15:46:12 +04:00
|
|
|
return nullptr;
|
2013-02-26 20:58:06 +04:00
|
|
|
}
|
2013-05-20 15:46:12 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DOMAnimVal> domAnimVal =
|
2012-12-21 13:18:58 +04:00
|
|
|
sAnimSVGViewBoxTearoffTable.GetTearoff(this);
|
|
|
|
if (!domAnimVal) {
|
|
|
|
domAnimVal = new DOMAnimVal(this, aSVGElement);
|
|
|
|
sAnimSVGViewBoxTearoffTable.AddTearoff(this, domAnimVal);
|
|
|
|
}
|
|
|
|
|
2013-05-20 15:46:12 +04:00
|
|
|
return domAnimVal.forget();
|
2009-02-03 17:42:24 +03:00
|
|
|
}
|
|
|
|
|
2012-12-21 13:18:58 +04:00
|
|
|
nsSVGViewBox::DOMAnimVal::~DOMAnimVal()
|
|
|
|
{
|
|
|
|
sAnimSVGViewBoxTearoffTable.RemoveTearoff(mVal);
|
|
|
|
}
|
|
|
|
|
2013-03-26 19:53:13 +04:00
|
|
|
void
|
|
|
|
nsSVGViewBox::DOMBaseVal::SetX(float aX, ErrorResult& aRv)
|
2009-02-03 17:42:24 +03:00
|
|
|
{
|
|
|
|
nsSVGViewBoxRect rect = mVal->GetBaseValue();
|
|
|
|
rect.x = aX;
|
2013-02-26 20:58:06 +04:00
|
|
|
mVal->SetBaseValue(rect, mSVGElement);
|
2009-02-03 17:42:24 +03:00
|
|
|
}
|
|
|
|
|
2013-03-26 19:53:13 +04:00
|
|
|
void
|
|
|
|
nsSVGViewBox::DOMBaseVal::SetY(float aY, ErrorResult& aRv)
|
2009-02-03 17:42:24 +03:00
|
|
|
{
|
|
|
|
nsSVGViewBoxRect rect = mVal->GetBaseValue();
|
|
|
|
rect.y = aY;
|
2013-02-26 20:58:06 +04:00
|
|
|
mVal->SetBaseValue(rect, mSVGElement);
|
2009-02-03 17:42:24 +03:00
|
|
|
}
|
|
|
|
|
2013-03-26 19:53:13 +04:00
|
|
|
void
|
|
|
|
nsSVGViewBox::DOMBaseVal::SetWidth(float aWidth, ErrorResult& aRv)
|
2009-02-03 17:42:24 +03:00
|
|
|
{
|
|
|
|
nsSVGViewBoxRect rect = mVal->GetBaseValue();
|
|
|
|
rect.width = aWidth;
|
2013-02-26 20:58:06 +04:00
|
|
|
mVal->SetBaseValue(rect, mSVGElement);
|
2009-02-03 17:42:24 +03:00
|
|
|
}
|
|
|
|
|
2013-03-26 19:53:13 +04:00
|
|
|
void
|
|
|
|
nsSVGViewBox::DOMBaseVal::SetHeight(float aHeight, ErrorResult& aRv)
|
2009-02-03 17:42:24 +03:00
|
|
|
{
|
|
|
|
nsSVGViewBoxRect rect = mVal->GetBaseValue();
|
|
|
|
rect.height = aHeight;
|
2013-02-26 20:58:06 +04:00
|
|
|
mVal->SetBaseValue(rect, mSVGElement);
|
2009-02-03 17:42:24 +03:00
|
|
|
}
|
2010-02-19 00:51:00 +03:00
|
|
|
|
|
|
|
nsISMILAttr*
|
|
|
|
nsSVGViewBox::ToSMILAttr(nsSVGElement *aSVGElement)
|
|
|
|
{
|
|
|
|
return new SMILViewBox(this, aSVGElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsSVGViewBox::SMILViewBox
|
|
|
|
::ValueFromString(const nsAString& aStr,
|
2013-03-19 07:18:45 +04:00
|
|
|
const dom::SVGAnimationElement* /*aSrcElement*/,
|
2010-02-21 00:13:11 +03:00
|
|
|
nsSMILValue& aValue,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool& aPreventCachingOfSandwich) const
|
2010-02-19 00:51:00 +03:00
|
|
|
{
|
|
|
|
nsSVGViewBoxRect viewBox;
|
|
|
|
nsresult res = ToSVGViewBoxRect(aStr, &viewBox);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
nsSMILValue val(&SVGViewBoxSMILType::sSingleton);
|
|
|
|
*static_cast<nsSVGViewBoxRect*>(val.mU.mPtr) = viewBox;
|
2015-05-29 23:10:41 +03:00
|
|
|
aValue = Move(val);
|
2011-10-17 18:59:28 +04:00
|
|
|
aPreventCachingOfSandwich = false;
|
2010-02-19 00:51:00 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSMILValue
|
|
|
|
nsSVGViewBox::SMILViewBox::GetBaseValue() const
|
|
|
|
{
|
|
|
|
nsSMILValue val(&SVGViewBoxSMILType::sSingleton);
|
2010-03-26 22:24:07 +03:00
|
|
|
*static_cast<nsSVGViewBoxRect*>(val.mU.mPtr) = mVal->mBaseVal;
|
2010-02-19 00:51:00 +03:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGViewBox::SMILViewBox::ClearAnimValue()
|
|
|
|
{
|
|
|
|
if (mVal->mAnimVal) {
|
2012-07-30 18:20:58 +04:00
|
|
|
mVal->mAnimVal = nullptr;
|
2010-02-19 00:51:00 +03:00
|
|
|
mSVGElement->DidAnimateViewBox();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsSVGViewBox::SMILViewBox::SetAnimValue(const nsSMILValue& aValue)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aValue.mType == &SVGViewBoxSMILType::sSingleton,
|
|
|
|
"Unexpected type to assign animated value");
|
|
|
|
if (aValue.mType == &SVGViewBoxSMILType::sSingleton) {
|
|
|
|
nsSVGViewBoxRect &vb = *static_cast<nsSVGViewBoxRect*>(aValue.mU.mPtr);
|
2013-02-26 20:58:06 +04:00
|
|
|
mVal->SetAnimValue(vb, mSVGElement);
|
2010-02-19 00:51:00 +03:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|