2001-12-12 07:59:31 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2013-12-09 02:52:54 +00:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2012-12-14 23:58:45 +00:00
|
|
|
#include "mozilla/DebugOnly.h"
|
2014-03-15 19:00:16 +00:00
|
|
|
#include "mozilla/unused.h"
|
2011-10-11 05:50:08 +00:00
|
|
|
|
2012-12-14 23:58:45 +00:00
|
|
|
#include "nsSVGElement.h"
|
|
|
|
|
2013-01-09 23:02:45 +00:00
|
|
|
#include "mozilla/dom/SVGSVGElement.h"
|
2013-03-02 06:08:42 +00:00
|
|
|
#include "mozilla/dom/SVGTests.h"
|
2013-09-10 17:03:28 +00:00
|
|
|
#include "nsContentUtils.h"
|
2013-03-11 22:05:58 +00:00
|
|
|
#include "nsICSSDeclaration.h"
|
2001-12-12 07:59:31 +00:00
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIDOMMutationEvent.h"
|
2014-10-04 11:13:30 +00:00
|
|
|
#include "nsSVGPathGeometryElement.h"
|
2014-02-27 10:51:15 +00:00
|
|
|
#include "mozilla/InternalMutationEvent.h"
|
2012-07-27 14:03:27 +00:00
|
|
|
#include "nsError.h"
|
2001-12-12 07:59:31 +00:00
|
|
|
#include "nsIPresShell.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2011-03-11 02:48:57 +00:00
|
|
|
#include "mozilla/css/StyleRule.h"
|
2001-12-12 07:59:31 +00:00
|
|
|
#include "nsRuleWalker.h"
|
2010-06-28 22:49:35 +00:00
|
|
|
#include "mozilla/css/Declaration.h"
|
2004-06-08 01:32:29 +00:00
|
|
|
#include "nsCSSProps.h"
|
2010-03-02 20:59:32 +00:00
|
|
|
#include "nsCSSParser.h"
|
2014-03-17 06:56:53 +00:00
|
|
|
#include "mozilla/EventListenerManager.h"
|
2013-02-11 23:25:56 +00:00
|
|
|
#include "nsLayoutUtils.h"
|
2013-04-14 22:56:34 +00:00
|
|
|
#include "nsSVGAnimatedTransformList.h"
|
2006-04-14 15:09:39 +00:00
|
|
|
#include "nsSVGLength2.h"
|
2006-07-28 18:10:48 +00:00
|
|
|
#include "nsSVGNumber2.h"
|
2011-07-01 07:19:52 +00:00
|
|
|
#include "nsSVGNumberPair.h"
|
2007-09-18 12:09:26 +00:00
|
|
|
#include "nsSVGInteger.h"
|
2011-07-01 07:19:52 +00:00
|
|
|
#include "nsSVGIntegerPair.h"
|
2007-10-10 10:07:59 +00:00
|
|
|
#include "nsSVGAngle.h"
|
2007-09-26 09:22:08 +00:00
|
|
|
#include "nsSVGBoolean.h"
|
2007-08-27 23:11:14 +00:00
|
|
|
#include "nsSVGEnum.h"
|
2009-02-03 14:42:24 +00:00
|
|
|
#include "nsSVGViewBox.h"
|
2008-06-14 09:01:02 +00:00
|
|
|
#include "nsSVGString.h"
|
2013-07-07 07:27:51 +00:00
|
|
|
#include "mozilla/dom/SVGAnimatedEnumeration.h"
|
2010-12-03 16:40:23 +00:00
|
|
|
#include "SVGAnimatedNumberList.h"
|
2010-07-16 21:42:12 +00:00
|
|
|
#include "SVGAnimatedLengthList.h"
|
2010-12-08 12:15:53 +00:00
|
|
|
#include "SVGAnimatedPointList.h"
|
2010-11-08 15:07:00 +00:00
|
|
|
#include "SVGAnimatedPathSegList.h"
|
2012-09-22 19:26:05 +00:00
|
|
|
#include "SVGContentUtils.h"
|
2009-01-15 04:38:07 +00:00
|
|
|
#include "nsIFrame.h"
|
2006-04-14 15:09:39 +00:00
|
|
|
#include <stdarg.h>
|
2010-03-16 23:17:33 +00:00
|
|
|
#include "nsSMILMappedAttribute.h"
|
2010-04-28 23:00:54 +00:00
|
|
|
#include "SVGMotionSMILAttr.h"
|
2012-02-15 23:40:45 +00:00
|
|
|
#include "nsAttrValueOrString.h"
|
2012-08-06 12:02:08 +00:00
|
|
|
#include "nsSMILAnimationController.h"
|
2012-12-23 08:22:58 +00:00
|
|
|
#include "mozilla/dom/SVGElementBinding.h"
|
2014-03-15 19:00:16 +00:00
|
|
|
#include "mozilla/unused.h"
|
2014-10-03 04:53:24 +00:00
|
|
|
#include "RestyleManager.h"
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2010-07-26 00:25:38 +00:00
|
|
|
using namespace mozilla;
|
2012-11-14 22:10:08 +00:00
|
|
|
using namespace mozilla::dom;
|
2010-07-26 00:25:38 +00:00
|
|
|
|
2010-04-12 15:53:59 +00:00
|
|
|
// This is needed to ensure correct handling of calls to the
|
|
|
|
// vararg-list methods in this file:
|
|
|
|
// nsSVGElement::GetAnimated{Length,Number,Integer}Values
|
|
|
|
// See bug 547964 for details:
|
2013-11-11 08:03:59 +00:00
|
|
|
static_assert(sizeof(void*) == sizeof(nullptr),
|
|
|
|
"nullptr should be the correct size");
|
2010-04-12 15:53:59 +00:00
|
|
|
|
2013-03-28 01:23:10 +00:00
|
|
|
nsresult
|
2014-06-20 02:01:40 +00:00
|
|
|
NS_NewSVGElement(Element **aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
2013-03-28 01:23:10 +00:00
|
|
|
{
|
|
|
|
nsRefPtr<nsSVGElement> it = new nsSVGElement(aNodeInfo);
|
|
|
|
nsresult rv = it->Init();
|
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
it.forget(aResult);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGElement)
|
2010-04-12 15:53:59 +00:00
|
|
|
|
2007-08-27 23:11:14 +00:00
|
|
|
nsSVGEnumMapping nsSVGElement::sSVGUnitTypesMap[] = {
|
2013-02-18 02:14:02 +00:00
|
|
|
{&nsGkAtoms::userSpaceOnUse, SVG_UNIT_TYPE_USERSPACEONUSE},
|
|
|
|
{&nsGkAtoms::objectBoundingBox, SVG_UNIT_TYPE_OBJECTBOUNDINGBOX},
|
2012-07-30 14:20:58 +00:00
|
|
|
{nullptr, 0}
|
2007-08-27 23:11:14 +00:00
|
|
|
};
|
|
|
|
|
2014-06-20 02:01:40 +00:00
|
|
|
nsSVGElement::nsSVGElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2011-09-30 09:25:34 +00:00
|
|
|
: nsSVGElementBase(aNodeInfo)
|
2001-12-12 07:59:31 +00:00
|
|
|
{
|
2006-04-14 15:09:39 +00:00
|
|
|
}
|
|
|
|
|
2012-12-23 08:22:58 +00:00
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
nsSVGElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2012-12-23 08:22:58 +00:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
return SVGElementBinding::Wrap(aCx, this, aGivenProto);
|
2012-12-23 08:22:58 +00:00
|
|
|
}
|
|
|
|
|
2012-12-23 08:22:22 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2013-06-14 22:37:27 +00:00
|
|
|
/* readonly attribute SVGAnimatedString className; */
|
2012-12-23 08:22:22 +00:00
|
|
|
NS_IMETHODIMP
|
2014-05-30 07:36:53 +00:00
|
|
|
nsSVGElement::GetSVGClassName(nsISupports** aClassName)
|
2012-12-23 08:22:22 +00:00
|
|
|
{
|
2014-03-15 19:00:15 +00:00
|
|
|
*aClassName = ClassName().take();
|
2012-12-23 08:22:58 +00:00
|
|
|
return NS_OK;
|
2012-12-23 08:22:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute nsIDOMCSSStyleDeclaration style; */
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGElement::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
|
|
|
|
{
|
2013-01-11 08:42:59 +00:00
|
|
|
NS_ADDREF(*aStyle = Style());
|
|
|
|
return NS_OK;
|
2012-12-23 08:22:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGElement::DidAnimateClass()
|
|
|
|
{
|
|
|
|
nsAutoString src;
|
|
|
|
mClassAttribute.GetAnimValue(src, this);
|
|
|
|
if (!mClassAnimAttr) {
|
|
|
|
mClassAnimAttr = new nsAttrValue();
|
|
|
|
}
|
|
|
|
mClassAnimAttr->ParseAtomArray(src);
|
|
|
|
|
|
|
|
nsIPresShell* shell = OwnerDoc()->GetShell();
|
|
|
|
if (shell) {
|
|
|
|
shell->RestyleForAnimation(this, eRestyle_Self);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-14 15:09:39 +00:00
|
|
|
nsresult
|
|
|
|
nsSVGElement::Init()
|
|
|
|
{
|
|
|
|
// Set up length attributes - can't do this in the constructor
|
|
|
|
// because we can't do a virtual call at that point
|
|
|
|
|
2006-07-28 18:10:48 +00:00
|
|
|
LengthAttributesInfo lengthInfo = GetLengthInfo();
|
2006-04-14 15:09:39 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t i;
|
2006-07-28 21:03:00 +00:00
|
|
|
for (i = 0; i < lengthInfo.mLengthCount; i++) {
|
2007-11-22 08:54:31 +00:00
|
|
|
lengthInfo.Reset(i);
|
2006-07-28 18:10:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NumberAttributesInfo numberInfo = GetNumberInfo();
|
|
|
|
|
2006-07-28 21:03:00 +00:00
|
|
|
for (i = 0; i < numberInfo.mNumberCount; i++) {
|
2007-11-22 08:54:31 +00:00
|
|
|
numberInfo.Reset(i);
|
2006-04-14 15:09:39 +00:00
|
|
|
}
|
2004-05-18 20:58:12 +00:00
|
|
|
|
2011-07-01 07:19:52 +00:00
|
|
|
NumberPairAttributesInfo numberPairInfo = GetNumberPairInfo();
|
|
|
|
|
|
|
|
for (i = 0; i < numberPairInfo.mNumberPairCount; i++) {
|
|
|
|
numberPairInfo.Reset(i);
|
|
|
|
}
|
|
|
|
|
2007-09-18 12:09:26 +00:00
|
|
|
IntegerAttributesInfo integerInfo = GetIntegerInfo();
|
|
|
|
|
|
|
|
for (i = 0; i < integerInfo.mIntegerCount; i++) {
|
2007-11-22 08:54:31 +00:00
|
|
|
integerInfo.Reset(i);
|
2007-09-18 12:09:26 +00:00
|
|
|
}
|
|
|
|
|
2011-07-01 07:19:52 +00:00
|
|
|
IntegerPairAttributesInfo integerPairInfo = GetIntegerPairInfo();
|
|
|
|
|
|
|
|
for (i = 0; i < integerPairInfo.mIntegerPairCount; i++) {
|
|
|
|
integerPairInfo.Reset(i);
|
|
|
|
}
|
|
|
|
|
2007-10-10 10:07:59 +00:00
|
|
|
AngleAttributesInfo angleInfo = GetAngleInfo();
|
|
|
|
|
|
|
|
for (i = 0; i < angleInfo.mAngleCount; i++) {
|
2007-11-22 08:54:31 +00:00
|
|
|
angleInfo.Reset(i);
|
2007-10-10 10:07:59 +00:00
|
|
|
}
|
|
|
|
|
2007-09-26 09:22:08 +00:00
|
|
|
BooleanAttributesInfo booleanInfo = GetBooleanInfo();
|
|
|
|
|
|
|
|
for (i = 0; i < booleanInfo.mBooleanCount; i++) {
|
2007-11-22 08:54:31 +00:00
|
|
|
booleanInfo.Reset(i);
|
2007-09-26 09:22:08 +00:00
|
|
|
}
|
|
|
|
|
2007-08-27 23:11:14 +00:00
|
|
|
EnumAttributesInfo enumInfo = GetEnumInfo();
|
|
|
|
|
|
|
|
for (i = 0; i < enumInfo.mEnumCount; i++) {
|
2007-11-22 08:54:31 +00:00
|
|
|
enumInfo.Reset(i);
|
2007-08-27 23:11:14 +00:00
|
|
|
}
|
|
|
|
|
2009-02-03 14:42:24 +00:00
|
|
|
nsSVGViewBox *viewBox = GetViewBox();
|
|
|
|
|
|
|
|
if (viewBox) {
|
|
|
|
viewBox->Init();
|
|
|
|
}
|
|
|
|
|
2010-12-20 00:45:29 +00:00
|
|
|
SVGAnimatedPreserveAspectRatio *preserveAspectRatio =
|
2009-01-05 01:19:38 +00:00
|
|
|
GetPreserveAspectRatio();
|
|
|
|
|
|
|
|
if (preserveAspectRatio) {
|
|
|
|
preserveAspectRatio->Init();
|
|
|
|
}
|
|
|
|
|
2010-07-16 21:42:12 +00:00
|
|
|
LengthListAttributesInfo lengthListInfo = GetLengthListInfo();
|
|
|
|
|
|
|
|
for (i = 0; i < lengthListInfo.mLengthListCount; i++) {
|
|
|
|
lengthListInfo.Reset(i);
|
|
|
|
}
|
|
|
|
|
2010-12-03 16:40:23 +00:00
|
|
|
NumberListAttributesInfo numberListInfo = GetNumberListInfo();
|
|
|
|
|
|
|
|
for (i = 0; i < numberListInfo.mNumberListCount; i++) {
|
|
|
|
numberListInfo.Reset(i);
|
|
|
|
}
|
|
|
|
|
2010-12-08 12:15:53 +00:00
|
|
|
// No need to reset SVGPointList since the default value is always the same
|
|
|
|
// (an empty list).
|
|
|
|
|
|
|
|
// No need to reset SVGPathData since the default value is always the same
|
2010-11-08 15:07:00 +00:00
|
|
|
// (an empty list).
|
|
|
|
|
2008-06-14 09:01:02 +00:00
|
|
|
StringAttributesInfo stringInfo = GetStringInfo();
|
|
|
|
|
|
|
|
for (i = 0; i < stringInfo.mStringCount; i++) {
|
|
|
|
stringInfo.Reset(i);
|
|
|
|
}
|
|
|
|
|
2006-04-14 15:09:39 +00:00
|
|
|
return NS_OK;
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods
|
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(nsSVGElement, nsSVGElementBase,
|
|
|
|
nsIDOMNode, nsIDOMElement,
|
|
|
|
nsIDOMSVGElement)
|
2001-12-12 07:59:31 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
2013-03-28 01:23:10 +00:00
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods
|
|
|
|
|
2008-01-01 10:51:40 +00:00
|
|
|
nsresult
|
|
|
|
nsSVGElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
2008-07-13 11:30:48 +00:00
|
|
|
nsIContent* aBindingParent,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aCompileEventHandlers)
|
2008-01-01 10:51:40 +00:00
|
|
|
{
|
|
|
|
nsresult rv = nsSVGElementBase::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2011-04-08 02:29:50 +00:00
|
|
|
if (!MayHaveStyle()) {
|
2008-01-01 10:51:40 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
const nsAttrValue* oldVal = mAttrsAndChildren.GetAttr(nsGkAtoms::style);
|
|
|
|
|
|
|
|
if (oldVal && oldVal->Type() == nsAttrValue::eCSSStyleRule) {
|
|
|
|
// we need to force a reparse because the baseURI of the document
|
2010-02-24 04:37:46 +00:00
|
|
|
// may have changed, and in particular because we may be clones of
|
|
|
|
// XBL anonymous content now being bound to the document we should
|
|
|
|
// render in and due to the hacky way in which we implement the
|
|
|
|
// interaction of XBL and SVG resources. Once we have a sane
|
|
|
|
// ownerDocument on XBL anonymous content, this can all go away.
|
2008-01-01 10:51:40 +00:00
|
|
|
nsAttrValue attrValue;
|
|
|
|
nsAutoString stringValue;
|
|
|
|
oldVal->ToString(stringValue);
|
2008-02-19 17:52:00 +00:00
|
|
|
// Force in data doc, since we already have a style rule
|
2011-10-17 14:59:28 +00:00
|
|
|
ParseStyleAttribute(stringValue, attrValue, true);
|
2008-01-01 10:51:40 +00:00
|
|
|
// Don't bother going through SetInlineStyleRule, we don't want to fire off
|
|
|
|
// mutation events or document notifications anyway
|
|
|
|
rv = mAttrsAndChildren.SetAndTakeAttr(nsGkAtoms::style, attrValue);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-01-09 23:54:21 +00:00
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
2012-02-14 02:00:56 +00:00
|
|
|
const nsAttrValue* aValue, bool aNotify)
|
|
|
|
{
|
2012-02-15 23:40:45 +00:00
|
|
|
// We don't currently use nsMappedAttributes within SVG. If this changes, we
|
|
|
|
// need to be very careful because some nsAttrValues used by SVG point to
|
|
|
|
// member data of SVG elements and if an nsAttrValue outlives the SVG element
|
|
|
|
// whose data it points to (by virtue of being stored in
|
|
|
|
// mAttrsAndChildren->mMappedAttributes, meaning it's shared between
|
|
|
|
// elements), the pointer will dangle. See bug 724680.
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(!mAttrsAndChildren.HasMappedAttrs(),
|
|
|
|
"Unexpected use of nsMappedAttributes within SVG");
|
2012-02-15 23:40:45 +00:00
|
|
|
|
2004-03-09 08:44:53 +00:00
|
|
|
// If this is an svg presentation attribute we need to map it into
|
|
|
|
// the content stylerule.
|
|
|
|
// XXX For some reason incremental mapping doesn't work, so for now
|
|
|
|
// just delete the style rule and lazily reconstruct it in
|
|
|
|
// GetContentStyleRule()
|
2005-10-28 02:59:38 +00:00
|
|
|
if (aNamespaceID == kNameSpaceID_None && IsAttributeMapped(aName)) {
|
2012-07-30 14:20:58 +00:00
|
|
|
mContentStyleRule = nullptr;
|
2005-10-28 02:59:38 +00:00
|
|
|
}
|
|
|
|
|
2013-01-02 20:24:07 +00:00
|
|
|
if (IsEventAttributeName(aName) && aValue) {
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(aValue->Type() == nsAttrValue::eString,
|
|
|
|
"Expected string value for script body");
|
2012-08-30 16:25:10 +00:00
|
|
|
nsresult rv = SetEventHandler(GetEventNameForAttr(aName),
|
|
|
|
aValue->GetStringValue());
|
2005-10-28 02:59:38 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
2007-08-06 15:27:19 +00:00
|
|
|
return nsSVGElementBase::AfterSetAttr(aNamespaceID, aName, aValue, aNotify);
|
2005-10-28 02:59:38 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::ParseAttribute(int32_t aNamespaceID,
|
2005-11-29 16:37:15 +00:00
|
|
|
nsIAtom* aAttribute,
|
2005-10-28 02:59:38 +00:00
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
|
|
|
{
|
2008-12-27 22:52:30 +00:00
|
|
|
nsresult rv = NS_OK;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool foundMatch = false;
|
2012-02-15 23:40:44 +00:00
|
|
|
bool didSetResult = false;
|
|
|
|
|
2006-04-14 15:09:39 +00:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
|
|
|
// Check for nsSVGLength2 attribute
|
2006-07-28 18:10:48 +00:00
|
|
|
LengthAttributesInfo lengthInfo = GetLengthInfo();
|
2007-10-10 10:07:59 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t i;
|
2008-06-14 09:01:02 +00:00
|
|
|
for (i = 0; i < lengthInfo.mLengthCount; i++) {
|
2006-07-28 18:10:48 +00:00
|
|
|
if (aAttribute == *lengthInfo.mLengthInfo[i].mName) {
|
2011-10-17 14:59:28 +00:00
|
|
|
rv = lengthInfo.mLengths[i].SetBaseValueString(aValue, this, false);
|
2007-11-22 08:54:31 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
lengthInfo.Reset(i);
|
2012-02-15 23:40:45 +00:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(lengthInfo.mLengths[i], &aValue);
|
|
|
|
didSetResult = true;
|
2007-11-22 08:54:31 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
foundMatch = true;
|
2008-06-14 09:01:02 +00:00
|
|
|
break;
|
2006-07-28 18:10:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-16 21:42:12 +00:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for SVGAnimatedLengthList attribute
|
|
|
|
LengthListAttributesInfo lengthListInfo = GetLengthListInfo();
|
|
|
|
for (i = 0; i < lengthListInfo.mLengthListCount; i++) {
|
|
|
|
if (aAttribute == *lengthListInfo.mLengthListInfo[i].mName) {
|
|
|
|
rv = lengthListInfo.mLengthLists[i].SetBaseValueString(aValue);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
lengthListInfo.Reset(i);
|
2012-02-15 23:40:45 +00:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(lengthListInfo.mLengthLists[i].GetBaseValue(),
|
|
|
|
&aValue);
|
|
|
|
didSetResult = true;
|
2010-07-16 21:42:12 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
foundMatch = true;
|
2010-07-16 21:42:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-03 16:40:23 +00:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for SVGAnimatedNumberList attribute
|
|
|
|
NumberListAttributesInfo numberListInfo = GetNumberListInfo();
|
|
|
|
for (i = 0; i < numberListInfo.mNumberListCount; i++) {
|
|
|
|
if (aAttribute == *numberListInfo.mNumberListInfo[i].mName) {
|
|
|
|
rv = numberListInfo.mNumberLists[i].SetBaseValueString(aValue);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
numberListInfo.Reset(i);
|
2012-02-15 23:40:46 +00:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(numberListInfo.mNumberLists[i].GetBaseValue(),
|
|
|
|
&aValue);
|
|
|
|
didSetResult = true;
|
2010-12-03 16:40:23 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
foundMatch = true;
|
2010-12-03 16:40:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-08 12:15:53 +00:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for SVGAnimatedPointList attribute
|
|
|
|
if (GetPointListAttrName() == aAttribute) {
|
|
|
|
SVGAnimatedPointList* pointList = GetAnimatedPointList();
|
|
|
|
if (pointList) {
|
2012-02-15 23:40:46 +00:00
|
|
|
pointList->SetBaseValueString(aValue);
|
|
|
|
// The spec says we parse everything up to the failure, so we DON'T
|
|
|
|
// need to check the result of SetBaseValueString or call
|
|
|
|
// pointList->ClearBaseValue() if it fails
|
|
|
|
aResult.SetTo(pointList->GetBaseValue(), &aValue);
|
|
|
|
didSetResult = true;
|
2011-10-17 14:59:28 +00:00
|
|
|
foundMatch = true;
|
2010-12-08 12:15:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-08 15:07:00 +00:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for SVGAnimatedPathSegList attribute
|
|
|
|
if (GetPathDataAttrName() == aAttribute) {
|
|
|
|
SVGAnimatedPathSegList* segList = GetAnimPathSegList();
|
|
|
|
if (segList) {
|
2012-02-15 23:40:46 +00:00
|
|
|
segList->SetBaseValueString(aValue);
|
|
|
|
// The spec says we parse everything up to the failure, so we DON'T
|
|
|
|
// need to check the result of SetBaseValueString or call
|
|
|
|
// segList->ClearBaseValue() if it fails
|
|
|
|
aResult.SetTo(segList->GetBaseValue(), &aValue);
|
|
|
|
didSetResult = true;
|
2011-10-17 14:59:28 +00:00
|
|
|
foundMatch = true;
|
2010-11-08 15:07:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-14 09:01:02 +00:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for nsSVGNumber2 attribute
|
|
|
|
NumberAttributesInfo numberInfo = GetNumberInfo();
|
|
|
|
for (i = 0; i < numberInfo.mNumberCount; i++) {
|
|
|
|
if (aAttribute == *numberInfo.mNumberInfo[i].mName) {
|
2011-10-09 15:25:07 +00:00
|
|
|
rv = numberInfo.mNumbers[i].SetBaseValueString(aValue, this);
|
2008-06-14 09:01:02 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
numberInfo.Reset(i);
|
2012-02-15 23:40:45 +00:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(numberInfo.mNumbers[i].GetBaseValue(), &aValue);
|
|
|
|
didSetResult = true;
|
2008-06-14 09:01:02 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
foundMatch = true;
|
2008-06-14 09:01:02 +00:00
|
|
|
break;
|
2007-11-22 08:54:31 +00:00
|
|
|
}
|
2006-04-14 15:09:39 +00:00
|
|
|
}
|
|
|
|
}
|
2007-08-27 23:11:14 +00:00
|
|
|
|
2011-07-01 07:19:52 +00:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for nsSVGNumberPair attribute
|
|
|
|
NumberPairAttributesInfo numberPairInfo = GetNumberPairInfo();
|
|
|
|
for (i = 0; i < numberPairInfo.mNumberPairCount; i++) {
|
|
|
|
if (aAttribute == *numberPairInfo.mNumberPairInfo[i].mName) {
|
2011-10-09 15:25:07 +00:00
|
|
|
rv = numberPairInfo.mNumberPairs[i].SetBaseValueString(aValue, this);
|
2011-07-01 07:19:52 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
numberPairInfo.Reset(i);
|
2012-02-15 23:40:45 +00:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(numberPairInfo.mNumberPairs[i], &aValue);
|
|
|
|
didSetResult = true;
|
2011-07-01 07:19:52 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
foundMatch = true;
|
2011-07-01 07:19:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-14 09:01:02 +00:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for nsSVGInteger attribute
|
|
|
|
IntegerAttributesInfo integerInfo = GetIntegerInfo();
|
|
|
|
for (i = 0; i < integerInfo.mIntegerCount; i++) {
|
|
|
|
if (aAttribute == *integerInfo.mIntegerInfo[i].mName) {
|
2011-10-09 15:25:07 +00:00
|
|
|
rv = integerInfo.mIntegers[i].SetBaseValueString(aValue, this);
|
2008-06-14 09:01:02 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
integerInfo.Reset(i);
|
2012-02-15 23:40:45 +00:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(integerInfo.mIntegers[i].GetBaseValue(), &aValue);
|
|
|
|
didSetResult = true;
|
2008-06-14 09:01:02 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
foundMatch = true;
|
2008-06-14 09:01:02 +00:00
|
|
|
break;
|
2007-11-22 08:54:31 +00:00
|
|
|
}
|
2007-09-18 12:09:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-01 07:19:52 +00:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for nsSVGIntegerPair attribute
|
|
|
|
IntegerPairAttributesInfo integerPairInfo = GetIntegerPairInfo();
|
|
|
|
for (i = 0; i < integerPairInfo.mIntegerPairCount; i++) {
|
|
|
|
if (aAttribute == *integerPairInfo.mIntegerPairInfo[i].mName) {
|
2012-02-15 23:40:45 +00:00
|
|
|
rv =
|
|
|
|
integerPairInfo.mIntegerPairs[i].SetBaseValueString(aValue, this);
|
2011-07-01 07:19:52 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
integerPairInfo.Reset(i);
|
2012-02-15 23:40:45 +00:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(integerPairInfo.mIntegerPairs[i], &aValue);
|
|
|
|
didSetResult = true;
|
2011-07-01 07:19:52 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
foundMatch = true;
|
2011-07-01 07:19:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-14 09:01:02 +00:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for nsSVGAngle attribute
|
|
|
|
AngleAttributesInfo angleInfo = GetAngleInfo();
|
|
|
|
for (i = 0; i < angleInfo.mAngleCount; i++) {
|
|
|
|
if (aAttribute == *angleInfo.mAngleInfo[i].mName) {
|
2011-10-17 14:59:28 +00:00
|
|
|
rv = angleInfo.mAngles[i].SetBaseValueString(aValue, this, false);
|
2008-06-14 09:01:02 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
angleInfo.Reset(i);
|
2012-02-15 23:40:45 +00:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(angleInfo.mAngles[i], &aValue);
|
|
|
|
didSetResult = true;
|
2008-06-14 09:01:02 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
foundMatch = true;
|
2008-06-14 09:01:02 +00:00
|
|
|
break;
|
2007-11-22 08:54:31 +00:00
|
|
|
}
|
2007-10-10 10:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-14 09:01:02 +00:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for nsSVGBoolean attribute
|
|
|
|
BooleanAttributesInfo booleanInfo = GetBooleanInfo();
|
|
|
|
for (i = 0; i < booleanInfo.mBooleanCount; i++) {
|
|
|
|
if (aAttribute == *booleanInfo.mBooleanInfo[i].mName) {
|
2012-08-24 07:29:09 +00:00
|
|
|
nsIAtom *valAtom = NS_GetStaticAtom(aValue);
|
|
|
|
rv = valAtom ? booleanInfo.mBooleans[i].SetBaseValueAtom(valAtom, this) :
|
|
|
|
NS_ERROR_DOM_SYNTAX_ERR;
|
2008-06-14 09:01:02 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
booleanInfo.Reset(i);
|
2012-02-15 23:40:45 +00:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(valAtom);
|
|
|
|
didSetResult = true;
|
2008-06-14 09:01:02 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
foundMatch = true;
|
2008-06-14 09:01:02 +00:00
|
|
|
break;
|
2007-11-22 08:54:31 +00:00
|
|
|
}
|
2007-09-26 09:22:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-14 09:01:02 +00:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for nsSVGEnum attribute
|
|
|
|
EnumAttributesInfo enumInfo = GetEnumInfo();
|
|
|
|
for (i = 0; i < enumInfo.mEnumCount; i++) {
|
|
|
|
if (aAttribute == *enumInfo.mEnumInfo[i].mName) {
|
2012-02-15 23:40:44 +00:00
|
|
|
nsCOMPtr<nsIAtom> valAtom = do_GetAtom(aValue);
|
|
|
|
rv = enumInfo.mEnums[i].SetBaseValueAtom(valAtom, this);
|
2008-06-14 09:01:02 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
enumInfo.Reset(i);
|
2012-02-15 23:40:44 +00:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(valAtom);
|
|
|
|
didSetResult = true;
|
2008-06-14 09:01:02 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
foundMatch = true;
|
2008-06-14 09:01:02 +00:00
|
|
|
break;
|
2007-11-22 08:54:31 +00:00
|
|
|
}
|
2007-08-27 23:11:14 +00:00
|
|
|
}
|
|
|
|
}
|
2009-01-05 01:19:38 +00:00
|
|
|
|
2011-12-31 09:44:03 +00:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for conditional processing attributes
|
2013-03-28 01:23:09 +00:00
|
|
|
nsCOMPtr<SVGTests> tests = do_QueryObject(this);
|
2011-12-31 09:44:03 +00:00
|
|
|
if (tests && tests->ParseConditionalProcessingAttribute(
|
|
|
|
aAttribute, aValue, aResult)) {
|
|
|
|
foundMatch = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for StringList attribute
|
|
|
|
StringListAttributesInfo stringListInfo = GetStringListInfo();
|
|
|
|
for (i = 0; i < stringListInfo.mStringListCount; i++) {
|
|
|
|
if (aAttribute == *stringListInfo.mStringListInfo[i].mName) {
|
2012-02-15 23:40:46 +00:00
|
|
|
rv = stringListInfo.mStringLists[i].SetValue(aValue);
|
2011-12-31 09:44:03 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
stringListInfo.Reset(i);
|
2012-02-15 23:40:46 +00:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(stringListInfo.mStringLists[i], &aValue);
|
|
|
|
didSetResult = true;
|
2011-12-31 09:44:03 +00:00
|
|
|
}
|
|
|
|
foundMatch = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-03 14:42:24 +00:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for nsSVGViewBox attribute
|
|
|
|
if (aAttribute == nsGkAtoms::viewBox) {
|
|
|
|
nsSVGViewBox* viewBox = GetViewBox();
|
|
|
|
if (viewBox) {
|
2012-08-25 17:02:34 +00:00
|
|
|
rv = viewBox->SetBaseValueString(aValue, this, false);
|
2009-02-03 14:42:24 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
viewBox->Init();
|
2012-02-15 23:40:46 +00:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(*viewBox, &aValue);
|
|
|
|
didSetResult = true;
|
2009-02-03 14:42:24 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
foundMatch = true;
|
2009-02-03 14:42:24 +00:00
|
|
|
}
|
2010-12-20 00:45:29 +00:00
|
|
|
// Check for SVGAnimatedPreserveAspectRatio attribute
|
2009-02-03 14:42:24 +00:00
|
|
|
} else if (aAttribute == nsGkAtoms::preserveAspectRatio) {
|
2010-12-20 00:45:29 +00:00
|
|
|
SVGAnimatedPreserveAspectRatio *preserveAspectRatio =
|
2009-02-03 14:42:24 +00:00
|
|
|
GetPreserveAspectRatio();
|
|
|
|
if (preserveAspectRatio) {
|
2012-08-25 17:02:34 +00:00
|
|
|
rv = preserveAspectRatio->SetBaseValueString(aValue, this, false);
|
2009-02-03 14:42:24 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
preserveAspectRatio->Init();
|
2012-02-15 23:40:46 +00:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(*preserveAspectRatio, &aValue);
|
|
|
|
didSetResult = true;
|
2009-02-03 14:42:24 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
foundMatch = true;
|
2009-01-05 01:19:38 +00:00
|
|
|
}
|
2011-09-25 21:04:31 +00:00
|
|
|
// Check for SVGAnimatedTransformList attribute
|
|
|
|
} else if (GetTransformListAttrName() == aAttribute) {
|
2012-07-30 00:35:26 +00:00
|
|
|
// The transform attribute is being set, so we must ensure that the
|
2013-04-14 22:56:34 +00:00
|
|
|
// nsSVGAnimatedTransformList is/has been allocated:
|
|
|
|
nsSVGAnimatedTransformList *transformList =
|
2012-07-30 00:35:26 +00:00
|
|
|
GetAnimatedTransformList(DO_ALLOCATE);
|
|
|
|
rv = transformList->SetBaseValueString(aValue);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
transformList->ClearBaseValue();
|
|
|
|
} else {
|
|
|
|
aResult.SetTo(transformList->GetBaseValue(), &aValue);
|
|
|
|
didSetResult = true;
|
2011-09-25 21:04:31 +00:00
|
|
|
}
|
2012-07-30 00:35:26 +00:00
|
|
|
foundMatch = true;
|
2009-01-05 01:19:38 +00:00
|
|
|
}
|
|
|
|
}
|
2012-12-23 08:22:22 +00:00
|
|
|
|
|
|
|
if (aAttribute == nsGkAtoms::_class) {
|
|
|
|
mClassAttribute.SetBaseValue(aValue, this, false);
|
|
|
|
aResult.ParseAtomArray(aValue);
|
|
|
|
return true;
|
|
|
|
}
|
2004-07-22 16:38:05 +00:00
|
|
|
}
|
2005-10-28 02:59:38 +00:00
|
|
|
|
2008-06-14 09:01:02 +00:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for nsSVGString attribute
|
|
|
|
StringAttributesInfo stringInfo = GetStringInfo();
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < stringInfo.mStringCount; i++) {
|
2008-06-14 09:01:02 +00:00
|
|
|
if (aNamespaceID == stringInfo.mStringInfo[i].mNamespaceID &&
|
|
|
|
aAttribute == *stringInfo.mStringInfo[i].mName) {
|
2011-10-17 14:59:28 +00:00
|
|
|
stringInfo.mStrings[i].SetBaseValue(aValue, this, false);
|
|
|
|
foundMatch = true;
|
2008-06-14 09:01:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-27 22:52:30 +00:00
|
|
|
if (foundMatch) {
|
|
|
|
if (NS_FAILED(rv)) {
|
2011-10-18 10:53:36 +00:00
|
|
|
ReportAttributeParseFailure(OwnerDoc(), aAttribute, aValue);
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2008-12-27 22:52:30 +00:00
|
|
|
}
|
2012-02-15 23:40:44 +00:00
|
|
|
if (!didSetResult) {
|
|
|
|
aResult.SetTo(aValue);
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2008-12-27 22:52:30 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 15:27:19 +00:00
|
|
|
return nsSVGElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
2005-11-29 16:37:15 +00:00
|
|
|
aResult);
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
2011-10-08 06:32:44 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::UnsetAttrInternal(int32_t aNamespaceID, nsIAtom* aName,
|
2011-10-08 06:32:44 +00:00
|
|
|
bool aNotify)
|
2004-07-22 16:38:05 +00:00
|
|
|
{
|
2010-02-24 04:37:47 +00:00
|
|
|
// XXXbz there's a bunch of redundancy here with AfterSetAttr.
|
|
|
|
// Maybe consolidate?
|
|
|
|
|
2006-04-14 15:09:39 +00:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
|
|
|
// If this is an svg presentation attribute, remove rule to force an update
|
|
|
|
if (IsAttributeMapped(aName))
|
2012-07-30 14:20:58 +00:00
|
|
|
mContentStyleRule = nullptr;
|
2006-04-14 15:09:39 +00:00
|
|
|
|
2013-01-02 20:24:07 +00:00
|
|
|
if (IsEventAttributeName(aName)) {
|
2014-03-17 06:56:53 +00:00
|
|
|
EventListenerManager* manager = GetExistingListenerManager();
|
2006-04-14 15:09:39 +00:00
|
|
|
if (manager) {
|
|
|
|
nsIAtom* eventName = GetEventNameForAttr(aName);
|
2013-08-16 10:06:24 +00:00
|
|
|
manager->RemoveEventHandler(eventName, EmptyString());
|
2006-04-14 15:09:39 +00:00
|
|
|
}
|
2011-10-08 06:32:44 +00:00
|
|
|
return;
|
2008-06-14 09:01:02 +00:00
|
|
|
}
|
|
|
|
|
2011-01-23 17:08:17 +00:00
|
|
|
// Check if this is a length attribute going away
|
|
|
|
LengthAttributesInfo lenInfo = GetLengthInfo();
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < lenInfo.mLengthCount; i++) {
|
2011-01-23 17:08:17 +00:00
|
|
|
if (aName == *lenInfo.mLengthInfo[i].mName) {
|
2012-02-15 23:40:45 +00:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-01-23 17:08:17 +00:00
|
|
|
lenInfo.Reset(i);
|
2011-10-08 06:32:44 +00:00
|
|
|
return;
|
2006-04-14 15:09:39 +00:00
|
|
|
}
|
2008-06-14 09:01:02 +00:00
|
|
|
}
|
|
|
|
|
2011-01-23 17:08:17 +00:00
|
|
|
// Check if this is a length list attribute going away
|
|
|
|
LengthListAttributesInfo lengthListInfo = GetLengthListInfo();
|
2010-07-16 21:42:12 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < lengthListInfo.mLengthListCount; i++) {
|
2011-01-23 17:08:17 +00:00
|
|
|
if (aName == *lengthListInfo.mLengthListInfo[i].mName) {
|
2012-02-15 23:40:45 +00:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-01-23 17:08:17 +00:00
|
|
|
lengthListInfo.Reset(i);
|
2011-10-08 06:32:44 +00:00
|
|
|
return;
|
2010-07-16 21:42:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-23 17:08:17 +00:00
|
|
|
// Check if this is a number list attribute going away
|
|
|
|
NumberListAttributesInfo numberListInfo = GetNumberListInfo();
|
2010-12-03 16:40:23 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < numberListInfo.mNumberListCount; i++) {
|
2011-01-23 17:08:17 +00:00
|
|
|
if (aName == *numberListInfo.mNumberListInfo[i].mName) {
|
2012-02-15 23:40:46 +00:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-01-23 17:08:17 +00:00
|
|
|
numberListInfo.Reset(i);
|
2011-10-08 06:32:44 +00:00
|
|
|
return;
|
2010-12-03 16:40:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-23 17:08:17 +00:00
|
|
|
// Check if this is a point list attribute going away
|
|
|
|
if (GetPointListAttrName() == aName) {
|
|
|
|
SVGAnimatedPointList *pointList = GetAnimatedPointList();
|
|
|
|
if (pointList) {
|
2012-02-15 23:40:46 +00:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-01-23 17:08:17 +00:00
|
|
|
pointList->ClearBaseValue();
|
2011-10-08 06:32:44 +00:00
|
|
|
return;
|
2010-12-08 12:15:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-23 17:08:17 +00:00
|
|
|
// Check if this is a path segment list attribute going away
|
|
|
|
if (GetPathDataAttrName() == aName) {
|
|
|
|
SVGAnimatedPathSegList *segList = GetAnimPathSegList();
|
|
|
|
if (segList) {
|
2012-02-15 23:40:46 +00:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-01-23 17:08:17 +00:00
|
|
|
segList->ClearBaseValue();
|
2011-10-08 06:32:44 +00:00
|
|
|
return;
|
2010-11-08 15:07:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-23 17:08:17 +00:00
|
|
|
// Check if this is a number attribute going away
|
|
|
|
NumberAttributesInfo numInfo = GetNumberInfo();
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < numInfo.mNumberCount; i++) {
|
2011-01-23 17:08:17 +00:00
|
|
|
if (aName == *numInfo.mNumberInfo[i].mName) {
|
|
|
|
numInfo.Reset(i);
|
2011-10-08 06:32:44 +00:00
|
|
|
return;
|
2006-07-28 18:10:48 +00:00
|
|
|
}
|
2008-06-14 09:01:02 +00:00
|
|
|
}
|
2007-08-27 23:11:14 +00:00
|
|
|
|
2011-07-01 07:19:52 +00:00
|
|
|
// Check if this is a number pair attribute going away
|
|
|
|
NumberPairAttributesInfo numPairInfo = GetNumberPairInfo();
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < numPairInfo.mNumberPairCount; i++) {
|
2011-07-01 07:19:52 +00:00
|
|
|
if (aName == *numPairInfo.mNumberPairInfo[i].mName) {
|
2012-02-15 23:40:45 +00:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-07-01 07:19:52 +00:00
|
|
|
numPairInfo.Reset(i);
|
2011-10-08 06:32:44 +00:00
|
|
|
return;
|
2011-07-01 07:19:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-23 17:08:17 +00:00
|
|
|
// Check if this is an integer attribute going away
|
|
|
|
IntegerAttributesInfo intInfo = GetIntegerInfo();
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < intInfo.mIntegerCount; i++) {
|
2011-01-23 17:08:17 +00:00
|
|
|
if (aName == *intInfo.mIntegerInfo[i].mName) {
|
|
|
|
intInfo.Reset(i);
|
2011-10-08 06:32:44 +00:00
|
|
|
return;
|
2007-09-18 12:09:26 +00:00
|
|
|
}
|
2008-06-14 09:01:02 +00:00
|
|
|
}
|
2007-09-18 12:09:26 +00:00
|
|
|
|
2011-07-01 07:19:52 +00:00
|
|
|
// Check if this is an integer pair attribute going away
|
|
|
|
IntegerPairAttributesInfo intPairInfo = GetIntegerPairInfo();
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < intPairInfo.mIntegerPairCount; i++) {
|
2011-07-01 07:19:52 +00:00
|
|
|
if (aName == *intPairInfo.mIntegerPairInfo[i].mName) {
|
2012-02-15 23:40:45 +00:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-07-01 07:19:52 +00:00
|
|
|
intPairInfo.Reset(i);
|
2011-10-08 06:32:44 +00:00
|
|
|
return;
|
2011-07-01 07:19:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-23 17:08:17 +00:00
|
|
|
// Check if this is an angle attribute going away
|
|
|
|
AngleAttributesInfo angleInfo = GetAngleInfo();
|
2007-10-10 10:07:59 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < angleInfo.mAngleCount; i++) {
|
2011-01-23 17:08:17 +00:00
|
|
|
if (aName == *angleInfo.mAngleInfo[i].mName) {
|
2012-02-15 23:40:45 +00:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-01-23 17:08:17 +00:00
|
|
|
angleInfo.Reset(i);
|
2011-10-08 06:32:44 +00:00
|
|
|
return;
|
2007-10-10 10:07:59 +00:00
|
|
|
}
|
2008-06-14 09:01:02 +00:00
|
|
|
}
|
2007-10-10 10:07:59 +00:00
|
|
|
|
2011-01-23 17:08:17 +00:00
|
|
|
// Check if this is a boolean attribute going away
|
|
|
|
BooleanAttributesInfo boolInfo = GetBooleanInfo();
|
2007-09-26 09:22:08 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < boolInfo.mBooleanCount; i++) {
|
2011-01-23 17:08:17 +00:00
|
|
|
if (aName == *boolInfo.mBooleanInfo[i].mName) {
|
|
|
|
boolInfo.Reset(i);
|
2011-10-08 06:32:44 +00:00
|
|
|
return;
|
2007-09-26 09:22:08 +00:00
|
|
|
}
|
2008-06-14 09:01:02 +00:00
|
|
|
}
|
2007-09-26 09:22:08 +00:00
|
|
|
|
2011-01-23 17:08:17 +00:00
|
|
|
// Check if this is an enum attribute going away
|
|
|
|
EnumAttributesInfo enumInfo = GetEnumInfo();
|
2007-08-27 23:11:14 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < enumInfo.mEnumCount; i++) {
|
2011-01-23 17:08:17 +00:00
|
|
|
if (aName == *enumInfo.mEnumInfo[i].mName) {
|
|
|
|
enumInfo.Reset(i);
|
2011-10-08 06:32:44 +00:00
|
|
|
return;
|
2007-08-27 23:11:14 +00:00
|
|
|
}
|
2008-06-14 09:01:02 +00:00
|
|
|
}
|
2009-01-05 01:19:38 +00:00
|
|
|
|
2011-01-23 17:08:17 +00:00
|
|
|
// Check if this is a nsViewBox attribute going away
|
|
|
|
if (aName == nsGkAtoms::viewBox) {
|
|
|
|
nsSVGViewBox* viewBox = GetViewBox();
|
|
|
|
if (viewBox) {
|
2012-02-15 23:40:46 +00:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-01-23 17:08:17 +00:00
|
|
|
viewBox->Init();
|
2011-10-08 06:32:44 +00:00
|
|
|
return;
|
2009-01-05 01:19:38 +00:00
|
|
|
}
|
|
|
|
}
|
2011-10-08 06:32:44 +00:00
|
|
|
|
2011-01-23 17:08:17 +00:00
|
|
|
// Check if this is a preserveAspectRatio attribute going away
|
|
|
|
if (aName == nsGkAtoms::preserveAspectRatio) {
|
|
|
|
SVGAnimatedPreserveAspectRatio *preserveAspectRatio =
|
|
|
|
GetPreserveAspectRatio();
|
|
|
|
if (preserveAspectRatio) {
|
2012-02-15 23:40:46 +00:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-01-23 17:08:17 +00:00
|
|
|
preserveAspectRatio->Init();
|
2011-10-08 06:32:44 +00:00
|
|
|
return;
|
2011-01-23 17:08:17 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-25 21:04:31 +00:00
|
|
|
|
|
|
|
// Check if this is a transform list attribute going away
|
|
|
|
if (GetTransformListAttrName() == aName) {
|
2013-04-14 22:56:34 +00:00
|
|
|
nsSVGAnimatedTransformList *transformList = GetAnimatedTransformList();
|
2011-09-25 21:04:31 +00:00
|
|
|
if (transformList) {
|
2012-02-15 23:40:46 +00:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-09-25 21:04:31 +00:00
|
|
|
transformList->ClearBaseValue();
|
2011-10-08 06:32:44 +00:00
|
|
|
return;
|
2011-09-25 21:04:31 +00:00
|
|
|
}
|
|
|
|
}
|
2011-12-31 09:44:03 +00:00
|
|
|
|
|
|
|
// Check for conditional processing attributes
|
2013-03-28 01:23:09 +00:00
|
|
|
nsCOMPtr<SVGTests> tests = do_QueryObject(this);
|
2011-12-31 09:44:03 +00:00
|
|
|
if (tests && tests->IsConditionalProcessingAttribute(aName)) {
|
2012-02-15 23:40:46 +00:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-12-31 09:44:03 +00:00
|
|
|
tests->UnsetAttr(aName);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if this is a string list attribute going away
|
|
|
|
StringListAttributesInfo stringListInfo = GetStringListInfo();
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < stringListInfo.mStringListCount; i++) {
|
2011-12-31 09:44:03 +00:00
|
|
|
if (aName == *stringListInfo.mStringListInfo[i].mName) {
|
2012-02-15 23:40:46 +00:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-12-31 09:44:03 +00:00
|
|
|
stringListInfo.Reset(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-12-23 08:22:22 +00:00
|
|
|
|
|
|
|
if (aName == nsGkAtoms::_class) {
|
|
|
|
mClassAttribute.Init();
|
|
|
|
return;
|
|
|
|
}
|
2004-07-22 16:38:05 +00:00
|
|
|
}
|
|
|
|
|
2011-01-23 17:08:17 +00:00
|
|
|
// Check if this is a string attribute going away
|
|
|
|
StringAttributesInfo stringInfo = GetStringInfo();
|
2008-06-14 09:01:02 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < stringInfo.mStringCount; i++) {
|
2011-01-23 17:08:17 +00:00
|
|
|
if (aNamespaceID == stringInfo.mStringInfo[i].mNamespaceID &&
|
|
|
|
aName == *stringInfo.mStringInfo[i].mName) {
|
|
|
|
stringInfo.Reset(i);
|
2011-10-08 06:32:44 +00:00
|
|
|
return;
|
2008-06-14 09:01:02 +00:00
|
|
|
}
|
|
|
|
}
|
2011-10-08 06:32:44 +00:00
|
|
|
}
|
2008-06-14 09:01:02 +00:00
|
|
|
|
2011-10-08 06:32:44 +00:00
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::UnsetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
2011-10-08 06:32:44 +00:00
|
|
|
bool aNotify)
|
|
|
|
{
|
|
|
|
UnsetAttrInternal(aNamespaceID, aName, aNotify);
|
|
|
|
return nsSVGElementBase::UnsetAttr(aNamespaceID, aName, aNotify);
|
2004-07-22 16:38:05 +00:00
|
|
|
}
|
|
|
|
|
2008-08-05 12:01:47 +00:00
|
|
|
nsChangeHint
|
|
|
|
nsSVGElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aModType) const
|
2008-08-05 12:01:47 +00:00
|
|
|
{
|
|
|
|
nsChangeHint retval =
|
|
|
|
nsSVGElementBase::GetAttributeChangeHint(aAttribute, aModType);
|
|
|
|
|
2013-03-28 01:23:09 +00:00
|
|
|
nsCOMPtr<SVGTests> tests = do_QueryObject(const_cast<nsSVGElement*>(this));
|
2011-12-31 09:44:03 +00:00
|
|
|
if (tests && tests->IsConditionalProcessingAttribute(aAttribute)) {
|
2008-08-05 12:01:47 +00:00
|
|
|
// It would be nice to only reconstruct the frame if the value returned by
|
2013-03-02 06:08:42 +00:00
|
|
|
// SVGTests::PassesConditionalProcessingTests has changed, but we don't
|
2011-12-31 09:44:03 +00:00
|
|
|
// know that
|
2008-08-05 12:01:47 +00:00
|
|
|
NS_UpdateHint(retval, nsChangeHint_ReconstructFrame);
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::IsNodeOfType(uint32_t aFlags) const
|
2004-07-06 22:52:03 +00:00
|
|
|
{
|
2011-12-08 06:32:11 +00:00
|
|
|
return !(aFlags & ~eCONTENT);
|
2004-07-06 22:52:03 +00:00
|
|
|
}
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
|
|
|
|
{
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
// printf("nsSVGElement(%p)::WalkContentStyleRules()\n", this);
|
|
|
|
#endif
|
2004-03-09 08:44:53 +00:00
|
|
|
if (!mContentStyleRule)
|
|
|
|
UpdateContentStyleRule();
|
|
|
|
|
2009-12-11 16:13:19 +00:00
|
|
|
if (mContentStyleRule) {
|
|
|
|
mContentStyleRule->RuleMatched();
|
2004-03-09 08:44:53 +00:00
|
|
|
aRuleWalker->Forward(mContentStyleRule);
|
2009-12-11 16:13:19 +00:00
|
|
|
}
|
2004-03-09 08:44:53 +00:00
|
|
|
|
2014-09-13 13:17:35 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGElement::WalkAnimatedContentStyleRules(nsRuleWalker* aRuleWalker)
|
|
|
|
{
|
2010-03-16 23:17:33 +00:00
|
|
|
// Update & walk the animated content style rule, to include style from
|
|
|
|
// animated mapped attributes. But first, get nsPresContext to check
|
|
|
|
// whether this is a "no-animation restyle". (This should match the check
|
|
|
|
// in nsHTMLCSSStyleSheet::RulesMatching(), where we determine whether to
|
|
|
|
// apply the SMILOverrideStyle.)
|
Bug 960465 patch 17 - Remove separate animation and non-animation phases of restyling. r=birtles
Note that this means that when we start transitions, we post restyles
that are processed during the current restyling operation, rather than
in a later phase. This depends on patch 11, which makes the transition
manager skip style changes that it posts while starting transitions, to
ensure that this doesn't lead to an infinite loop. This also depends on
patch 16, which only consumes restyle data for the primary frame, to
ensure that the animation restyles posted are processed properly. It
also depends on patch 14, which makes us retain data on finished
transitions, to avoid triggering extra transitions on descendants when
both an ancestor and a descendant transition an inherited property, and
the descendant does so faster.
This fixes a known failure in layout/style/test/test_animations.html and
test_animations_omta.html (as visible in the patch). I believe this is
because this patch changes us to compute keyframe values for animations
on top of a style context *with* animation data rather than one without,
which means what we're computing them on top of changes each time. (The
purpose of patch 3 was to avoid this in the case where avoiding it
matters, i.e., implicit 0% and 100% keyframes.)
2015-02-16 22:15:05 +00:00
|
|
|
RestyleManager* restyleManager = aRuleWalker->PresContext()->RestyleManager();
|
|
|
|
if (!restyleManager->SkipAnimationRules()) {
|
|
|
|
// update/walk the animated content style rule.
|
2011-10-18 11:19:44 +00:00
|
|
|
css::StyleRule* animContentStyleRule = GetAnimatedContentStyleRule();
|
|
|
|
if (!animContentStyleRule) {
|
|
|
|
UpdateAnimatedContentStyleRule();
|
|
|
|
animContentStyleRule = GetAnimatedContentStyleRule();
|
|
|
|
}
|
|
|
|
if (animContentStyleRule) {
|
|
|
|
animContentStyleRule->RuleMatched();
|
|
|
|
aRuleWalker->Forward(animContentStyleRule);
|
2010-03-16 23:17:33 +00:00
|
|
|
}
|
|
|
|
}
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
2012-02-19 20:49:34 +00:00
|
|
|
NS_IMETHODIMP_(bool)
|
|
|
|
nsSVGElement::IsAttributeMapped(const nsIAtom* name) const
|
|
|
|
{
|
|
|
|
if (name == nsGkAtoms::lang) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return nsSVGElementBase::IsAttributeMapped(name);
|
|
|
|
}
|
|
|
|
|
2004-02-09 20:48:20 +00:00
|
|
|
// PresentationAttributes-FillStroke
|
2012-11-14 22:10:08 +00:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2004-02-09 20:48:20 +00:00
|
|
|
nsSVGElement::sFillStrokeMap[] = {
|
2006-12-26 17:47:52 +00:00
|
|
|
{ &nsGkAtoms::fill },
|
|
|
|
{ &nsGkAtoms::fill_opacity },
|
|
|
|
{ &nsGkAtoms::fill_rule },
|
2013-01-12 23:27:53 +00:00
|
|
|
{ &nsGkAtoms::paint_order },
|
2006-12-26 17:47:52 +00:00
|
|
|
{ &nsGkAtoms::stroke },
|
|
|
|
{ &nsGkAtoms::stroke_dasharray },
|
|
|
|
{ &nsGkAtoms::stroke_dashoffset },
|
|
|
|
{ &nsGkAtoms::stroke_linecap },
|
|
|
|
{ &nsGkAtoms::stroke_linejoin },
|
|
|
|
{ &nsGkAtoms::stroke_miterlimit },
|
|
|
|
{ &nsGkAtoms::stroke_opacity },
|
|
|
|
{ &nsGkAtoms::stroke_width },
|
2012-05-18 08:34:25 +00:00
|
|
|
{ &nsGkAtoms::vector_effect },
|
2012-07-30 14:20:58 +00:00
|
|
|
{ nullptr }
|
2004-02-09 20:48:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// PresentationAttributes-Graphics
|
2012-11-14 22:10:08 +00:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2004-02-09 20:48:20 +00:00
|
|
|
nsSVGElement::sGraphicsMap[] = {
|
2006-12-26 17:47:52 +00:00
|
|
|
{ &nsGkAtoms::clip_path },
|
|
|
|
{ &nsGkAtoms::clip_rule },
|
2007-01-30 13:19:55 +00:00
|
|
|
{ &nsGkAtoms::colorInterpolation },
|
2006-12-26 17:47:52 +00:00
|
|
|
{ &nsGkAtoms::cursor },
|
|
|
|
{ &nsGkAtoms::display },
|
|
|
|
{ &nsGkAtoms::filter },
|
|
|
|
{ &nsGkAtoms::image_rendering },
|
|
|
|
{ &nsGkAtoms::mask },
|
|
|
|
{ &nsGkAtoms::opacity },
|
|
|
|
{ &nsGkAtoms::pointer_events },
|
|
|
|
{ &nsGkAtoms::shape_rendering },
|
|
|
|
{ &nsGkAtoms::text_rendering },
|
|
|
|
{ &nsGkAtoms::visibility },
|
2012-07-30 14:20:58 +00:00
|
|
|
{ nullptr }
|
2004-02-09 20:48:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// PresentationAttributes-TextContentElements
|
2012-11-14 22:10:08 +00:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2004-02-09 20:48:20 +00:00
|
|
|
nsSVGElement::sTextContentElementsMap[] = {
|
2012-07-09 01:09:49 +00:00
|
|
|
// Properties that we don't support are commented out.
|
|
|
|
// { &nsGkAtoms::alignment_baseline },
|
|
|
|
// { &nsGkAtoms::baseline_shift },
|
2006-12-26 17:47:52 +00:00
|
|
|
{ &nsGkAtoms::direction },
|
|
|
|
{ &nsGkAtoms::dominant_baseline },
|
2012-07-09 01:09:49 +00:00
|
|
|
// { &nsGkAtoms::glyph_orientation_horizontal },
|
|
|
|
// { &nsGkAtoms::glyph_orientation_vertical },
|
|
|
|
// { &nsGkAtoms::kerning },
|
2006-12-26 17:47:52 +00:00
|
|
|
{ &nsGkAtoms::letter_spacing },
|
|
|
|
{ &nsGkAtoms::text_anchor },
|
|
|
|
{ &nsGkAtoms::text_decoration },
|
|
|
|
{ &nsGkAtoms::unicode_bidi },
|
|
|
|
{ &nsGkAtoms::word_spacing },
|
2012-07-30 14:20:58 +00:00
|
|
|
{ nullptr }
|
2004-02-09 20:48:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// PresentationAttributes-FontSpecification
|
2012-11-14 22:10:08 +00:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2004-02-09 20:48:20 +00:00
|
|
|
nsSVGElement::sFontSpecificationMap[] = {
|
2006-12-26 17:47:52 +00:00
|
|
|
{ &nsGkAtoms::font_family },
|
|
|
|
{ &nsGkAtoms::font_size },
|
|
|
|
{ &nsGkAtoms::font_size_adjust },
|
|
|
|
{ &nsGkAtoms::font_stretch },
|
|
|
|
{ &nsGkAtoms::font_style },
|
|
|
|
{ &nsGkAtoms::font_variant },
|
|
|
|
{ &nsGkAtoms::fontWeight },
|
2012-07-30 14:20:58 +00:00
|
|
|
{ nullptr }
|
2004-02-09 20:48:20 +00:00
|
|
|
};
|
|
|
|
|
2004-10-14 23:02:53 +00:00
|
|
|
// PresentationAttributes-GradientStop
|
2012-11-14 22:10:08 +00:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2004-10-14 23:02:53 +00:00
|
|
|
nsSVGElement::sGradientStopMap[] = {
|
2006-12-26 17:47:52 +00:00
|
|
|
{ &nsGkAtoms::stop_color },
|
|
|
|
{ &nsGkAtoms::stop_opacity },
|
2012-07-30 14:20:58 +00:00
|
|
|
{ nullptr }
|
2004-10-14 23:02:53 +00:00
|
|
|
};
|
|
|
|
|
2004-10-27 00:25:08 +00:00
|
|
|
// PresentationAttributes-Viewports
|
2012-11-14 22:10:08 +00:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2004-10-27 00:25:08 +00:00
|
|
|
nsSVGElement::sViewportsMap[] = {
|
2006-12-26 17:47:52 +00:00
|
|
|
{ &nsGkAtoms::overflow },
|
|
|
|
{ &nsGkAtoms::clip },
|
2012-07-30 14:20:58 +00:00
|
|
|
{ nullptr }
|
2004-10-27 00:25:08 +00:00
|
|
|
};
|
|
|
|
|
2004-12-09 03:16:15 +00:00
|
|
|
// PresentationAttributes-Makers
|
2012-11-14 22:10:08 +00:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2004-12-09 03:16:15 +00:00
|
|
|
nsSVGElement::sMarkersMap[] = {
|
2006-12-26 17:47:52 +00:00
|
|
|
{ &nsGkAtoms::marker_end },
|
|
|
|
{ &nsGkAtoms::marker_mid },
|
|
|
|
{ &nsGkAtoms::marker_start },
|
2012-07-30 14:20:58 +00:00
|
|
|
{ nullptr }
|
2004-12-09 03:16:15 +00:00
|
|
|
};
|
|
|
|
|
2004-12-09 23:51:25 +00:00
|
|
|
// PresentationAttributes-Color
|
2012-11-14 22:10:08 +00:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2004-12-09 23:51:25 +00:00
|
|
|
nsSVGElement::sColorMap[] = {
|
2006-12-26 17:47:52 +00:00
|
|
|
{ &nsGkAtoms::color },
|
2012-07-30 14:20:58 +00:00
|
|
|
{ nullptr }
|
2004-12-09 23:51:25 +00:00
|
|
|
};
|
|
|
|
|
2007-01-30 13:19:55 +00:00
|
|
|
// PresentationAttributes-Filters
|
2012-11-14 22:10:08 +00:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2007-01-30 13:19:55 +00:00
|
|
|
nsSVGElement::sFiltersMap[] = {
|
|
|
|
{ &nsGkAtoms::colorInterpolationFilters },
|
2012-07-30 14:20:58 +00:00
|
|
|
{ nullptr }
|
2007-01-30 13:19:55 +00:00
|
|
|
};
|
|
|
|
|
2007-01-08 16:48:56 +00:00
|
|
|
// PresentationAttributes-feFlood
|
2012-11-14 22:10:08 +00:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2007-01-08 16:48:56 +00:00
|
|
|
nsSVGElement::sFEFloodMap[] = {
|
|
|
|
{ &nsGkAtoms::flood_color },
|
|
|
|
{ &nsGkAtoms::flood_opacity },
|
2012-07-30 14:20:58 +00:00
|
|
|
{ nullptr }
|
2007-01-08 16:48:56 +00:00
|
|
|
};
|
2004-12-09 23:51:25 +00:00
|
|
|
|
2007-07-26 06:57:42 +00:00
|
|
|
// PresentationAttributes-LightingEffects
|
2012-11-14 22:10:08 +00:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2007-07-26 06:57:42 +00:00
|
|
|
nsSVGElement::sLightingEffectsMap[] = {
|
|
|
|
{ &nsGkAtoms::lighting_color },
|
2012-07-30 14:20:58 +00:00
|
|
|
{ nullptr }
|
2007-07-26 06:57:42 +00:00
|
|
|
};
|
|
|
|
|
2012-12-21 00:15:22 +00:00
|
|
|
// PresentationAttributes-mask
|
|
|
|
/* static */ const Element::MappedAttributeEntry
|
|
|
|
nsSVGElement::sMaskMap[] = {
|
|
|
|
{ &nsGkAtoms::mask_type },
|
|
|
|
{ nullptr }
|
|
|
|
};
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMElement methods
|
|
|
|
|
2012-11-14 22:10:08 +00:00
|
|
|
// forwarded to Element implementations
|
2001-12-12 07:59:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMSVGElement methods
|
|
|
|
|
|
|
|
/* readonly attribute nsIDOMSVGSVGElement ownerSVGElement; */
|
|
|
|
NS_IMETHODIMP
|
2013-02-08 19:55:07 +00:00
|
|
|
nsSVGElement::GetOwnerSVGElement(nsIDOMSVGElement * *aOwnerSVGElement)
|
2001-12-12 07:59:31 +00:00
|
|
|
{
|
2013-08-07 17:40:52 +00:00
|
|
|
NS_IF_ADDREF(*aOwnerSVGElement = GetOwnerSVGElement());
|
|
|
|
return NS_OK;
|
2012-12-23 08:22:58 +00:00
|
|
|
}
|
2012-12-23 08:22:58 +00:00
|
|
|
|
2013-01-09 23:02:45 +00:00
|
|
|
SVGSVGElement*
|
2013-08-07 17:40:52 +00:00
|
|
|
nsSVGElement::GetOwnerSVGElement()
|
2012-12-23 08:22:58 +00:00
|
|
|
{
|
2013-08-07 17:40:52 +00:00
|
|
|
return GetCtx(); // this may return nullptr
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute nsIDOMSVGElement viewportElement; */
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGElement::GetViewportElement(nsIDOMSVGElement * *aViewportElement)
|
|
|
|
{
|
2013-01-06 06:25:55 +00:00
|
|
|
nsSVGElement* elem = GetViewportElement();
|
2013-03-28 01:23:09 +00:00
|
|
|
NS_ADDREF(*aViewportElement = elem);
|
2009-07-23 08:35:59 +00:00
|
|
|
return NS_OK;
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
2013-01-06 06:25:55 +00:00
|
|
|
nsSVGElement*
|
2012-12-23 08:22:58 +00:00
|
|
|
nsSVGElement::GetViewportElement()
|
|
|
|
{
|
2013-01-06 06:25:55 +00:00
|
|
|
return SVGContentUtils::GetNearestViewportElement(this);
|
2012-12-23 08:22:58 +00:00
|
|
|
}
|
|
|
|
|
2013-06-14 22:37:27 +00:00
|
|
|
already_AddRefed<SVGAnimatedString>
|
2012-12-23 08:22:58 +00:00
|
|
|
nsSVGElement::ClassName()
|
|
|
|
{
|
2013-02-07 08:08:56 +00:00
|
|
|
return mClassAttribute.ToDOMAnimatedString(this);
|
2012-12-23 08:22:58 +00:00
|
|
|
}
|
|
|
|
|
2010-03-16 23:17:32 +00:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Helper class: MappedAttrParser, for parsing values of mapped attributes
|
2010-06-28 22:49:35 +00:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2013-04-12 03:20:09 +00:00
|
|
|
class MOZ_STACK_CLASS MappedAttrParser {
|
2010-03-16 23:17:32 +00:00
|
|
|
public:
|
2010-06-28 22:49:35 +00:00
|
|
|
MappedAttrParser(css::Loader* aLoader,
|
2010-03-16 23:17:32 +00:00
|
|
|
nsIURI* aDocURI,
|
|
|
|
already_AddRefed<nsIURI> aBaseURI,
|
|
|
|
nsIPrincipal* aNodePrincipal);
|
|
|
|
~MappedAttrParser();
|
|
|
|
|
|
|
|
// Parses a mapped attribute value.
|
|
|
|
void ParseMappedAttrValue(nsIAtom* aMappedAttrName,
|
2012-06-10 23:44:50 +00:00
|
|
|
const nsAString& aMappedAttrValue);
|
2010-03-16 23:17:32 +00:00
|
|
|
|
|
|
|
// If we've parsed any values for mapped attributes, this method returns
|
2011-03-11 02:48:57 +00:00
|
|
|
// a new already_AddRefed css::StyleRule that incorporates the parsed
|
2010-06-28 22:49:35 +00:00
|
|
|
// values. Otherwise, this method returns null.
|
2011-03-11 02:48:57 +00:00
|
|
|
already_AddRefed<css::StyleRule> CreateStyleRule();
|
2010-03-16 23:17:32 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// MEMBER DATA
|
|
|
|
// -----------
|
|
|
|
nsCSSParser mParser;
|
|
|
|
|
|
|
|
// Arguments for nsCSSParser::ParseProperty
|
|
|
|
nsIURI* mDocURI;
|
|
|
|
nsCOMPtr<nsIURI> mBaseURI;
|
|
|
|
nsIPrincipal* mNodePrincipal;
|
|
|
|
|
|
|
|
// Declaration for storing parsed values (lazily initialized)
|
2010-06-28 22:49:35 +00:00
|
|
|
css::Declaration* mDecl;
|
2010-03-16 23:17:32 +00:00
|
|
|
};
|
|
|
|
|
2010-06-28 22:49:35 +00:00
|
|
|
MappedAttrParser::MappedAttrParser(css::Loader* aLoader,
|
2010-03-16 23:17:32 +00:00
|
|
|
nsIURI* aDocURI,
|
|
|
|
already_AddRefed<nsIURI> aBaseURI,
|
|
|
|
nsIPrincipal* aNodePrincipal)
|
|
|
|
: mParser(aLoader), mDocURI(aDocURI), mBaseURI(aBaseURI),
|
2012-07-30 14:20:58 +00:00
|
|
|
mNodePrincipal(aNodePrincipal), mDecl(nullptr)
|
2010-03-16 23:17:32 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
MappedAttrParser::~MappedAttrParser()
|
|
|
|
{
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(!mDecl,
|
|
|
|
"If mDecl was initialized, it should have been converted "
|
|
|
|
"into a style rule (and had its pointer cleared)");
|
2010-03-16 23:17:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MappedAttrParser::ParseMappedAttrValue(nsIAtom* aMappedAttrName,
|
2012-06-10 23:44:50 +00:00
|
|
|
const nsAString& aMappedAttrValue)
|
2010-03-16 23:17:32 +00:00
|
|
|
{
|
|
|
|
if (!mDecl) {
|
2010-06-28 22:49:35 +00:00
|
|
|
mDecl = new css::Declaration();
|
2010-03-16 23:17:32 +00:00
|
|
|
mDecl->InitializeEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the nsCSSProperty ID for our mapped attribute.
|
|
|
|
nsCSSProperty propertyID =
|
2012-07-13 23:59:05 +00:00
|
|
|
nsCSSProps::LookupProperty(nsDependentAtomString(aMappedAttrName),
|
2014-03-07 17:14:23 +00:00
|
|
|
nsCSSProps::eEnabledForAllContent);
|
2012-02-19 20:49:34 +00:00
|
|
|
if (propertyID != eCSSProperty_UNKNOWN) {
|
|
|
|
bool changed; // outparam for ParseProperty. (ignored)
|
|
|
|
mParser.ParseProperty(propertyID, aMappedAttrValue, mDocURI, mBaseURI,
|
2012-11-15 16:36:15 +00:00
|
|
|
mNodePrincipal, mDecl, &changed, false, true);
|
2012-02-19 20:49:34 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(aMappedAttrName == nsGkAtoms::lang,
|
|
|
|
"Only 'lang' should be unrecognized!");
|
2012-02-19 20:49:34 +00:00
|
|
|
// nsCSSParser doesn't know about 'lang', so we need to handle it specially.
|
|
|
|
if (aMappedAttrName == nsGkAtoms::lang) {
|
|
|
|
propertyID = eCSSProperty__x_lang;
|
|
|
|
nsCSSExpandedDataBlock block;
|
|
|
|
mDecl->ExpandTo(&block);
|
|
|
|
nsCSSValue cssValue(PromiseFlatString(aMappedAttrValue), eCSSUnit_Ident);
|
|
|
|
block.AddLonghandProperty(propertyID, cssValue);
|
|
|
|
mDecl->ValueAppended(propertyID);
|
|
|
|
mDecl->CompressFrom(&block);
|
|
|
|
}
|
2010-03-16 23:17:32 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 02:48:57 +00:00
|
|
|
already_AddRefed<css::StyleRule>
|
2010-03-16 23:17:32 +00:00
|
|
|
MappedAttrParser::CreateStyleRule()
|
|
|
|
{
|
|
|
|
if (!mDecl) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr; // No mapped attributes were parsed
|
2010-03-16 23:17:32 +00:00
|
|
|
}
|
|
|
|
|
2014-07-14 22:57:54 +00:00
|
|
|
nsRefPtr<css::StyleRule> rule = new css::StyleRule(nullptr, mDecl, 0, 0);
|
2012-07-30 14:20:58 +00:00
|
|
|
mDecl = nullptr; // We no longer own the declaration -- drop our pointer to it
|
2010-03-16 23:17:32 +00:00
|
|
|
return rule.forget();
|
|
|
|
}
|
|
|
|
|
2010-06-28 22:49:35 +00:00
|
|
|
} // anonymous namespace
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation Helpers:
|
|
|
|
|
2004-03-09 08:44:53 +00:00
|
|
|
void
|
|
|
|
nsSVGElement::UpdateContentStyleRule()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!mContentStyleRule, "we already have a content style rule");
|
2010-03-02 20:59:32 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t attrCount = mAttrsAndChildren.AttrCount();
|
2010-03-02 20:59:32 +00:00
|
|
|
if (!attrCount) {
|
|
|
|
// nothing to do
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-18 10:53:36 +00:00
|
|
|
nsIDocument* doc = OwnerDoc();
|
2010-03-16 23:17:32 +00:00
|
|
|
MappedAttrParser mappedAttrParser(doc->CSSLoader(), doc->GetDocumentURI(),
|
|
|
|
GetBaseURI(), NodePrincipal());
|
2004-08-10 00:02:47 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < attrCount; ++i) {
|
2005-12-30 20:12:35 +00:00
|
|
|
const nsAttrName* attrName = mAttrsAndChildren.AttrNameAt(i);
|
2004-03-09 08:44:53 +00:00
|
|
|
if (!attrName->IsAtom() || !IsAttributeMapped(attrName->Atom()))
|
|
|
|
continue;
|
|
|
|
|
2012-02-19 20:49:34 +00:00
|
|
|
if (attrName->NamespaceID() != kNameSpaceID_None &&
|
|
|
|
!attrName->Equals(nsGkAtoms::lang, kNameSpaceID_XML)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attrName->Equals(nsGkAtoms::lang, kNameSpaceID_None) &&
|
|
|
|
HasAttr(kNameSpaceID_XML, nsGkAtoms::lang)) {
|
|
|
|
continue; // xml:lang has precedence
|
|
|
|
}
|
|
|
|
|
2015-03-03 11:09:00 +00:00
|
|
|
if (IsSVGElement(nsGkAtoms::svg)) {
|
2011-12-27 10:27:42 +00:00
|
|
|
// Special case: we don't want <svg> 'width'/'height' mapped into style
|
|
|
|
// if the attribute value isn't a valid <length> according to SVG (which
|
|
|
|
// only supports a subset of the CSS <length> values). We don't enforce
|
2013-01-09 23:02:45 +00:00
|
|
|
// this by checking the attribute value in SVGSVGElement::
|
2011-12-27 10:27:42 +00:00
|
|
|
// IsAttributeMapped since we don't want that method to depend on the
|
|
|
|
// value of the attribute that is being checked. Rather we just prevent
|
|
|
|
// the actual mapping here, as necessary.
|
|
|
|
if (attrName->Atom() == nsGkAtoms::width &&
|
|
|
|
!GetAnimatedLength(nsGkAtoms::width)->HasBaseVal()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (attrName->Atom() == nsGkAtoms::height &&
|
|
|
|
!GetAnimatedLength(nsGkAtoms::height)->HasBaseVal()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-09 08:44:53 +00:00
|
|
|
nsAutoString value;
|
|
|
|
mAttrsAndChildren.AttrAt(i)->ToString(value);
|
2010-03-16 23:17:32 +00:00
|
|
|
mappedAttrParser.ParseMappedAttrValue(attrName->Atom(), value);
|
2004-12-18 12:14:32 +00:00
|
|
|
}
|
2010-03-16 23:17:32 +00:00
|
|
|
mContentStyleRule = mappedAttrParser.CreateStyleRule();
|
2004-03-09 08:44:53 +00:00
|
|
|
}
|
|
|
|
|
2010-03-16 23:17:33 +00:00
|
|
|
static void
|
|
|
|
ParseMappedAttrAnimValueCallback(void* aObject,
|
|
|
|
nsIAtom* aPropertyName,
|
|
|
|
void* aPropertyValue,
|
|
|
|
void* aData)
|
|
|
|
{
|
2013-08-29 15:39:56 +00:00
|
|
|
MOZ_ASSERT(aPropertyName != SMIL_MAPPED_ATTR_STYLERULE_ATOM,
|
|
|
|
"animated content style rule should have been removed "
|
|
|
|
"from properties table already (we're rebuilding it now)");
|
|
|
|
|
|
|
|
MappedAttrParser* mappedAttrParser = static_cast<MappedAttrParser*>(aData);
|
|
|
|
MOZ_ASSERT(mappedAttrParser, "parser should be non-null");
|
|
|
|
|
|
|
|
nsStringBuffer* animValBuf = static_cast<nsStringBuffer*>(aPropertyValue);
|
|
|
|
MOZ_ASSERT(animValBuf, "animated value should be non-null");
|
|
|
|
|
|
|
|
nsString animValStr;
|
2013-09-10 17:03:28 +00:00
|
|
|
nsContentUtils::PopulateStringFromStringBuffer(animValBuf, animValStr);
|
2013-08-29 15:39:56 +00:00
|
|
|
|
|
|
|
mappedAttrParser->ParseMappedAttrValue(aPropertyName, animValStr);
|
2010-03-16 23:17:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for freeing animated content style rule, in property table.
|
|
|
|
static void
|
|
|
|
ReleaseStyleRule(void* aObject, /* unused */
|
|
|
|
nsIAtom* aPropertyName,
|
|
|
|
void* aPropertyValue,
|
|
|
|
void* aData /* unused */)
|
|
|
|
{
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(aPropertyName == SMIL_MAPPED_ATTR_STYLERULE_ATOM,
|
|
|
|
"unexpected property name, for animated content style rule");
|
2011-03-11 02:48:57 +00:00
|
|
|
css::StyleRule* styleRule = static_cast<css::StyleRule*>(aPropertyValue);
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(styleRule, "unexpected null style rule");
|
2010-03-16 23:17:33 +00:00
|
|
|
styleRule->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGElement::UpdateAnimatedContentStyleRule()
|
|
|
|
{
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(!GetAnimatedContentStyleRule(),
|
|
|
|
"Animated content style rule already set");
|
2010-03-16 23:17:33 +00:00
|
|
|
|
2011-10-18 10:53:36 +00:00
|
|
|
nsIDocument* doc = OwnerDoc();
|
2010-03-16 23:17:33 +00:00
|
|
|
if (!doc) {
|
|
|
|
NS_ERROR("SVG element without owner document");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MappedAttrParser mappedAttrParser(doc->CSSLoader(), doc->GetDocumentURI(),
|
|
|
|
GetBaseURI(), NodePrincipal());
|
2010-04-23 02:41:38 +00:00
|
|
|
doc->PropertyTable(SMIL_MAPPED_ATTR_ANIMVAL)->
|
|
|
|
Enumerate(this, ParseMappedAttrAnimValueCallback, &mappedAttrParser);
|
2010-03-16 23:17:33 +00:00
|
|
|
|
2011-03-11 02:48:57 +00:00
|
|
|
nsRefPtr<css::StyleRule>
|
2010-03-16 23:17:33 +00:00
|
|
|
animContentStyleRule(mappedAttrParser.CreateStyleRule());
|
|
|
|
|
|
|
|
if (animContentStyleRule) {
|
2010-07-11 12:30:35 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
nsresult rv =
|
|
|
|
#endif
|
|
|
|
SetProperty(SMIL_MAPPED_ATTR_ANIMVAL,
|
|
|
|
SMIL_MAPPED_ATTR_STYLERULE_ATOM,
|
|
|
|
animContentStyleRule.get(),
|
|
|
|
ReleaseStyleRule);
|
2014-03-15 19:00:16 +00:00
|
|
|
unused << animContentStyleRule.forget();
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(rv == NS_OK,
|
|
|
|
"SetProperty failed (or overwrote something)");
|
2010-03-16 23:17:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-11 02:48:57 +00:00
|
|
|
css::StyleRule*
|
2010-03-16 23:17:33 +00:00
|
|
|
nsSVGElement::GetAnimatedContentStyleRule()
|
|
|
|
{
|
|
|
|
return
|
2011-03-11 02:48:57 +00:00
|
|
|
static_cast<css::StyleRule*>(GetProperty(SMIL_MAPPED_ATTR_ANIMVAL,
|
|
|
|
SMIL_MAPPED_ATTR_STYLERULE_ATOM,
|
2012-07-30 14:20:58 +00:00
|
|
|
nullptr));
|
2010-03-16 23:17:33 +00:00
|
|
|
}
|
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
/**
|
|
|
|
* Helper methods for the type-specific WillChangeXXX methods.
|
|
|
|
*
|
|
|
|
* This method sends out appropriate pre-change notifications so that selector
|
|
|
|
* restyles (e.g. due to changes that cause |elem[attr="val"]| to start/stop
|
|
|
|
* matching) work, and it returns an nsAttrValue that _may_ contain the
|
|
|
|
* attribute's pre-change value.
|
|
|
|
*
|
|
|
|
* The nsAttrValue returned by this method depends on whether there are
|
|
|
|
* mutation event listeners listening for changes to this element's attributes.
|
|
|
|
* If not, then the object returned is empty. If there are, then the
|
|
|
|
* nsAttrValue returned contains a serialized copy of the attribute's value
|
|
|
|
* prior to the change, and this object should be passed to the corresponding
|
|
|
|
* DidChangeXXX method call (assuming a WillChangeXXX call is required for the
|
|
|
|
* SVG type - see comment below). This is necessary so that the 'prevValue'
|
|
|
|
* property of the mutation event that is dispatched will correctly contain the
|
|
|
|
* old value.
|
|
|
|
*
|
|
|
|
* The reason we need to serialize the old value if there are mutation
|
|
|
|
* event listeners is because the underlying nsAttrValue for the attribute
|
|
|
|
* points directly to a parsed representation of the attribute (e.g. an
|
|
|
|
* SVGAnimatedLengthList*) that is a member of the SVG element. That object
|
|
|
|
* will have changed by the time DidChangeXXX has been called, so without the
|
|
|
|
* serialization of the old attribute value that we provide, DidChangeXXX
|
|
|
|
* would have no way to get the old value to pass to SetAttrAndNotify.
|
|
|
|
*
|
|
|
|
* We only return the old value when there are mutation event listeners because
|
|
|
|
* it's not needed otherwise, and because it's expensive to serialize the old
|
|
|
|
* value. This is especially true for list type attributes, which may be built
|
|
|
|
* up via the SVG DOM resulting in a large number of Will/DidModifyXXX calls
|
|
|
|
* before the script finally finishes setting the attribute.
|
|
|
|
*
|
|
|
|
* Note that unlike using SetParsedAttr, using Will/DidChangeXXX does NOT check
|
|
|
|
* and filter out redundant changes. Before calling WillChangeXXX, the caller
|
|
|
|
* should check whether the new and old values are actually the same, and skip
|
|
|
|
* calling Will/DidChangeXXX if they are.
|
|
|
|
*
|
|
|
|
* Also note that not all SVG types use this scheme. For types that can be
|
|
|
|
* represented by an nsAttrValue without pointing back to an SVG object (e.g.
|
|
|
|
* enums, booleans, integers) we can simply use SetParsedAttr which will do all
|
|
|
|
* of the above for us. For such types there is no matching WillChangeXXX
|
|
|
|
* method, only DidChangeXXX which calls SetParsedAttr.
|
|
|
|
*/
|
|
|
|
nsAttrValue
|
|
|
|
nsSVGElement::WillChangeValue(nsIAtom* aName)
|
|
|
|
{
|
|
|
|
// We need an empty attr value:
|
2012-07-30 14:20:58 +00:00
|
|
|
// a) to pass to BeforeSetAttr when GetParsedAttr returns nullptr
|
2012-02-15 23:40:45 +00:00
|
|
|
// b) to store the old value in the case we have mutation listeners
|
|
|
|
// We can use the same value for both purposes since (a) happens before (b).
|
|
|
|
// Also, we should be careful to always return this value to benefit from
|
|
|
|
// return value optimization.
|
|
|
|
nsAttrValue emptyOrOldAttrValue;
|
|
|
|
const nsAttrValue* attrValue = GetParsedAttr(aName);
|
|
|
|
|
|
|
|
// This is not strictly correct--the attribute value parameter for
|
|
|
|
// BeforeSetAttr should reflect the value that *will* be set but that implies
|
|
|
|
// allocating, e.g. an extra nsSVGLength2, and isn't necessary at the moment
|
|
|
|
// since no SVG elements overload BeforeSetAttr. For now we just pass the
|
|
|
|
// current value.
|
|
|
|
nsAttrValueOrString attrStringOrValue(attrValue ? *attrValue
|
|
|
|
: emptyOrOldAttrValue);
|
|
|
|
DebugOnly<nsresult> rv =
|
|
|
|
BeforeSetAttr(kNameSpaceID_None, aName, &attrStringOrValue,
|
|
|
|
kNotifyDocumentObservers);
|
|
|
|
// SVG elements aren't expected to overload BeforeSetAttr in such a way that
|
|
|
|
// it may fail. So long as this is the case we don't need to check and pass on
|
|
|
|
// the return value which simplifies the calling code significantly.
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv), "Unexpected failure from BeforeSetAttr");
|
2012-02-15 23:40:45 +00:00
|
|
|
|
|
|
|
// We only need to set the old value if we have listeners since otherwise it
|
|
|
|
// isn't used.
|
|
|
|
if (attrValue &&
|
|
|
|
nsContentUtils::HasMutationListeners(this,
|
|
|
|
NS_EVENT_BITS_MUTATION_ATTRMODIFIED,
|
|
|
|
this)) {
|
|
|
|
emptyOrOldAttrValue.SetToSerialized(*attrValue);
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t modType = attrValue
|
|
|
|
? static_cast<uint8_t>(nsIDOMMutationEvent::MODIFICATION)
|
|
|
|
: static_cast<uint8_t>(nsIDOMMutationEvent::ADDITION);
|
2012-02-15 23:40:45 +00:00
|
|
|
nsNodeUtils::AttributeWillChange(this, kNameSpaceID_None, aName, modType);
|
|
|
|
|
|
|
|
return emptyOrOldAttrValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper methods for the type-specific DidChangeXXX methods.
|
|
|
|
*
|
|
|
|
* aEmptyOrOldValue will normally be the object returned from the corresponding
|
|
|
|
* WillChangeXXX call. This is because:
|
|
|
|
* a) WillChangeXXX will ensure the object is set when we have mutation
|
|
|
|
* listeners, and
|
|
|
|
* b) WillChangeXXX will ensure the object represents a serialized version of
|
|
|
|
* the old attribute value so that the value doesn't change when the
|
|
|
|
* underlying SVG type is updated.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
nsSVGElement::DidChangeValue(nsIAtom* aName,
|
|
|
|
const nsAttrValue& aEmptyOrOldValue,
|
|
|
|
nsAttrValue& aNewValue)
|
|
|
|
{
|
|
|
|
bool hasListeners =
|
|
|
|
nsContentUtils::HasMutationListeners(this,
|
|
|
|
NS_EVENT_BITS_MUTATION_ATTRMODIFIED,
|
|
|
|
this);
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t modType = HasAttr(kNameSpaceID_None, aName)
|
|
|
|
? static_cast<uint8_t>(nsIDOMMutationEvent::MODIFICATION)
|
|
|
|
: static_cast<uint8_t>(nsIDOMMutationEvent::ADDITION);
|
2012-07-30 14:20:58 +00:00
|
|
|
SetAttrAndNotify(kNameSpaceID_None, aName, nullptr, aEmptyOrOldValue,
|
2012-02-15 23:40:45 +00:00
|
|
|
aNewValue, modType, hasListeners, kNotifyDocumentObservers,
|
|
|
|
kCallAfterSetAttr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGElement::MaybeSerializeAttrBeforeRemoval(nsIAtom* aName, bool aNotify)
|
|
|
|
{
|
|
|
|
if (!aNotify ||
|
|
|
|
!nsContentUtils::HasMutationListeners(this,
|
|
|
|
NS_EVENT_BITS_MUTATION_ATTRMODIFIED,
|
|
|
|
this)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-04 23:38:03 +00:00
|
|
|
const nsAttrValue* attrValue = mAttrsAndChildren.GetAttr(aName);
|
|
|
|
if (!attrValue)
|
|
|
|
return;
|
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
nsAutoString serializedValue;
|
2012-03-04 23:38:03 +00:00
|
|
|
attrValue->ToString(serializedValue);
|
|
|
|
nsAttrValue oldAttrValue(serializedValue);
|
|
|
|
mAttrsAndChildren.SetAndTakeAttr(aName, oldAttrValue);
|
2012-02-15 23:40:45 +00:00
|
|
|
}
|
|
|
|
|
2005-08-25 21:31:09 +00:00
|
|
|
/* static */
|
|
|
|
nsIAtom* nsSVGElement::GetEventNameForAttr(nsIAtom* aAttr)
|
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
if (aAttr == nsGkAtoms::onload)
|
|
|
|
return nsGkAtoms::onSVGLoad;
|
|
|
|
if (aAttr == nsGkAtoms::onunload)
|
|
|
|
return nsGkAtoms::onSVGUnload;
|
|
|
|
if (aAttr == nsGkAtoms::onresize)
|
|
|
|
return nsGkAtoms::onSVGResize;
|
|
|
|
if (aAttr == nsGkAtoms::onscroll)
|
|
|
|
return nsGkAtoms::onSVGScroll;
|
|
|
|
if (aAttr == nsGkAtoms::onzoom)
|
|
|
|
return nsGkAtoms::onSVGZoom;
|
2010-07-31 07:02:52 +00:00
|
|
|
if (aAttr == nsGkAtoms::onbegin)
|
|
|
|
return nsGkAtoms::onbeginEvent;
|
|
|
|
if (aAttr == nsGkAtoms::onrepeat)
|
|
|
|
return nsGkAtoms::onrepeatEvent;
|
|
|
|
if (aAttr == nsGkAtoms::onend)
|
|
|
|
return nsGkAtoms::onendEvent;
|
2005-08-25 21:31:09 +00:00
|
|
|
|
|
|
|
return aAttr;
|
|
|
|
}
|
2006-04-14 15:09:39 +00:00
|
|
|
|
2013-01-09 23:02:45 +00:00
|
|
|
SVGSVGElement *
|
2011-06-16 10:53:13 +00:00
|
|
|
nsSVGElement::GetCtx() const
|
2006-04-14 15:09:39 +00:00
|
|
|
{
|
2011-04-08 05:27:57 +00:00
|
|
|
nsIContent* ancestor = GetFlattenedTreeParent();
|
2011-02-26 10:21:11 +00:00
|
|
|
|
2015-03-03 11:08:59 +00:00
|
|
|
while (ancestor && ancestor->IsSVGElement()) {
|
2015-03-03 11:09:00 +00:00
|
|
|
if (ancestor->IsSVGElement(nsGkAtoms::foreignObject)) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2011-02-26 10:21:11 +00:00
|
|
|
}
|
2015-03-03 11:09:00 +00:00
|
|
|
if (ancestor->IsSVGElement(nsGkAtoms::svg)) {
|
2013-01-09 23:02:45 +00:00
|
|
|
return static_cast<SVGSVGElement*>(ancestor);
|
2011-02-26 10:21:11 +00:00
|
|
|
}
|
2011-04-08 05:27:57 +00:00
|
|
|
ancestor = ancestor->GetFlattenedTreeParent();
|
2011-02-26 10:21:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// we don't have an ancestor <svg> element...
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2006-04-14 15:09:39 +00:00
|
|
|
}
|
|
|
|
|
2013-12-26 20:13:57 +00:00
|
|
|
/* virtual */ gfxMatrix
|
|
|
|
nsSVGElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
|
2012-02-17 08:12:47 +00:00
|
|
|
TransformTypes aWhich) const
|
2009-04-29 04:31:34 +00:00
|
|
|
{
|
|
|
|
return aMatrix;
|
|
|
|
}
|
|
|
|
|
2006-04-14 15:09:39 +00:00
|
|
|
nsSVGElement::LengthAttributesInfo
|
|
|
|
nsSVGElement::GetLengthInfo()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return LengthAttributesInfo(nullptr, nullptr, 0);
|
2006-04-14 15:09:39 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void nsSVGElement::LengthAttributesInfo::Reset(uint8_t aAttrEnum)
|
2007-11-22 08:54:31 +00:00
|
|
|
{
|
|
|
|
mLengths[aAttrEnum].Init(mLengthInfo[aAttrEnum].mCtxType,
|
|
|
|
aAttrEnum,
|
|
|
|
mLengthInfo[aAttrEnum].mDefaultValue,
|
|
|
|
mLengthInfo[aAttrEnum].mDefaultUnitType);
|
|
|
|
}
|
|
|
|
|
2011-06-20 20:15:42 +00:00
|
|
|
void
|
|
|
|
nsSVGElement::SetLength(nsIAtom* aName, const nsSVGLength2 &aLength)
|
|
|
|
{
|
|
|
|
LengthAttributesInfo lengthInfo = GetLengthInfo();
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < lengthInfo.mLengthCount; i++) {
|
2011-06-20 20:15:42 +00:00
|
|
|
if (aName == *lengthInfo.mLengthInfo[i].mName) {
|
|
|
|
lengthInfo.mLengths[i] = aLength;
|
2011-10-08 06:32:44 +00:00
|
|
|
DidAnimateLength(i);
|
2011-06-20 20:15:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(false, "no length found to set");
|
2011-06-20 20:15:42 +00:00
|
|
|
}
|
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
nsAttrValue
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::WillChangeLength(uint8_t aAttrEnum)
|
2006-04-14 15:09:39 +00:00
|
|
|
{
|
2012-02-15 23:40:45 +00:00
|
|
|
return WillChangeValue(*GetLengthInfo().mLengthInfo[aAttrEnum].mName);
|
|
|
|
}
|
2006-04-14 15:09:39 +00:00
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidChangeLength(uint8_t aAttrEnum,
|
2012-02-15 23:40:45 +00:00
|
|
|
const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2006-04-14 15:09:39 +00:00
|
|
|
LengthAttributesInfo info = GetLengthInfo();
|
|
|
|
|
|
|
|
NS_ASSERTION(info.mLengthCount > 0,
|
|
|
|
"DidChangeLength on element with no length attribs");
|
|
|
|
NS_ASSERTION(aAttrEnum < info.mLengthCount, "aAttrEnum out of range");
|
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 14:20:58 +00:00
|
|
|
newValue.SetTo(info.mLengths[aAttrEnum], nullptr);
|
2006-04-14 15:09:39 +00:00
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
DidChangeValue(*info.mLengthInfo[aAttrEnum].mName, aEmptyOrOldValue,
|
|
|
|
newValue);
|
2006-04-14 15:09:39 +00:00
|
|
|
}
|
|
|
|
|
2009-01-15 04:38:07 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidAnimateLength(uint8_t aAttrEnum)
|
2009-01-15 04:38:07 +00:00
|
|
|
{
|
2014-10-04 11:13:30 +00:00
|
|
|
ClearAnyCachedPath();
|
|
|
|
|
2009-01-15 04:38:07 +00:00
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
LengthAttributesInfo info = GetLengthInfo();
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mLengthInfo[aAttrEnum].mName,
|
|
|
|
nsIDOMMutationEvent::MODIFICATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-27 10:27:42 +00:00
|
|
|
nsSVGLength2*
|
|
|
|
nsSVGElement::GetAnimatedLength(const nsIAtom *aAttrName)
|
|
|
|
{
|
|
|
|
LengthAttributesInfo lengthInfo = GetLengthInfo();
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < lengthInfo.mLengthCount; i++) {
|
2011-12-27 10:27:42 +00:00
|
|
|
if (aAttrName == *lengthInfo.mLengthInfo[i].mName) {
|
|
|
|
return &lengthInfo.mLengths[i];
|
|
|
|
}
|
|
|
|
}
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(false, "no matching length found");
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2011-12-27 10:27:42 +00:00
|
|
|
}
|
|
|
|
|
2006-04-14 15:09:39 +00:00
|
|
|
void
|
|
|
|
nsSVGElement::GetAnimatedLengthValues(float *aFirst, ...)
|
|
|
|
{
|
|
|
|
LengthAttributesInfo info = GetLengthInfo();
|
|
|
|
|
|
|
|
NS_ASSERTION(info.mLengthCount > 0,
|
|
|
|
"GetAnimatedLengthValues on element with no length attribs");
|
|
|
|
|
2013-01-09 23:02:45 +00:00
|
|
|
SVGSVGElement *ctx = nullptr;
|
2006-04-14 15:09:39 +00:00
|
|
|
|
|
|
|
float *f = aFirst;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t i = 0;
|
2006-04-14 15:09:39 +00:00
|
|
|
|
|
|
|
va_list args;
|
|
|
|
va_start(args, aFirst);
|
|
|
|
|
|
|
|
while (f && i < info.mLengthCount) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t type = info.mLengths[i].GetSpecifiedUnitType();
|
2006-04-14 15:09:39 +00:00
|
|
|
if (!ctx) {
|
|
|
|
if (type != nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER &&
|
|
|
|
type != nsIDOMSVGLength::SVG_LENGTHTYPE_PX)
|
2007-03-09 16:27:01 +00:00
|
|
|
ctx = GetCtx();
|
2006-04-14 15:09:39 +00:00
|
|
|
}
|
2007-06-25 16:12:35 +00:00
|
|
|
if (type == nsIDOMSVGLength::SVG_LENGTHTYPE_EMS ||
|
|
|
|
type == nsIDOMSVGLength::SVG_LENGTHTYPE_EXS)
|
|
|
|
*f = info.mLengths[i++].GetAnimValue(this);
|
|
|
|
else
|
|
|
|
*f = info.mLengths[i++].GetAnimValue(ctx);
|
2006-04-14 15:09:39 +00:00
|
|
|
f = va_arg(args, float*);
|
|
|
|
}
|
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
}
|
2006-07-28 18:10:48 +00:00
|
|
|
|
2010-07-16 21:42:12 +00:00
|
|
|
nsSVGElement::LengthListAttributesInfo
|
|
|
|
nsSVGElement::GetLengthListInfo()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return LengthListAttributesInfo(nullptr, nullptr, 0);
|
2010-07-16 21:42:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::LengthListAttributesInfo::Reset(uint8_t aAttrEnum)
|
2010-07-16 21:42:12 +00:00
|
|
|
{
|
|
|
|
mLengthLists[aAttrEnum].ClearBaseValue(aAttrEnum);
|
|
|
|
// caller notifies
|
|
|
|
}
|
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
nsAttrValue
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::WillChangeLengthList(uint8_t aAttrEnum)
|
2010-07-16 21:42:12 +00:00
|
|
|
{
|
2012-02-15 23:40:45 +00:00
|
|
|
return WillChangeValue(*GetLengthListInfo().mLengthListInfo[aAttrEnum].mName);
|
|
|
|
}
|
2010-07-16 21:42:12 +00:00
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidChangeLengthList(uint8_t aAttrEnum,
|
2012-02-15 23:40:45 +00:00
|
|
|
const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2010-07-16 21:42:12 +00:00
|
|
|
LengthListAttributesInfo info = GetLengthListInfo();
|
|
|
|
|
|
|
|
NS_ASSERTION(info.mLengthListCount > 0,
|
|
|
|
"DidChangeLengthList on element with no length list attribs");
|
|
|
|
NS_ASSERTION(aAttrEnum < info.mLengthListCount, "aAttrEnum out of range");
|
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 14:20:58 +00:00
|
|
|
newValue.SetTo(info.mLengthLists[aAttrEnum].GetBaseValue(), nullptr);
|
2010-07-16 21:42:12 +00:00
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
DidChangeValue(*info.mLengthListInfo[aAttrEnum].mName, aEmptyOrOldValue,
|
|
|
|
newValue);
|
2010-07-16 21:42:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidAnimateLengthList(uint8_t aAttrEnum)
|
2010-07-16 21:42:12 +00:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
LengthListAttributesInfo info = GetLengthListInfo();
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mLengthListInfo[aAttrEnum].mName,
|
|
|
|
nsIDOMMutationEvent::MODIFICATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGElement::GetAnimatedLengthListValues(SVGUserUnitList *aFirst, ...)
|
|
|
|
{
|
|
|
|
LengthListAttributesInfo info = GetLengthListInfo();
|
|
|
|
|
|
|
|
NS_ASSERTION(info.mLengthListCount > 0,
|
|
|
|
"GetAnimatedLengthListValues on element with no length list attribs");
|
|
|
|
|
|
|
|
SVGUserUnitList *list = aFirst;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t i = 0;
|
2010-07-16 21:42:12 +00:00
|
|
|
|
|
|
|
va_list args;
|
|
|
|
va_start(args, aFirst);
|
|
|
|
|
|
|
|
while (list && i < info.mLengthListCount) {
|
|
|
|
list->Init(&(info.mLengthLists[i].GetAnimValue()), this, info.mLengthListInfo[i].mAxis);
|
|
|
|
++i;
|
|
|
|
list = va_arg(args, SVGUserUnitList*);
|
|
|
|
}
|
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
|
|
|
|
SVGAnimatedLengthList*
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::GetAnimatedLengthList(uint8_t aAttrEnum)
|
2010-07-16 21:42:12 +00:00
|
|
|
{
|
|
|
|
LengthListAttributesInfo info = GetLengthListInfo();
|
|
|
|
if (aAttrEnum < info.mLengthListCount) {
|
|
|
|
return &(info.mLengthLists[aAttrEnum]);
|
|
|
|
}
|
|
|
|
NS_NOTREACHED("Bad attrEnum");
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2010-07-16 21:42:12 +00:00
|
|
|
}
|
|
|
|
|
2010-11-08 15:07:00 +00:00
|
|
|
|
2010-12-03 16:40:23 +00:00
|
|
|
nsSVGElement::NumberListAttributesInfo
|
|
|
|
nsSVGElement::GetNumberListInfo()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return NumberListAttributesInfo(nullptr, nullptr, 0);
|
2010-12-03 16:40:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::NumberListAttributesInfo::Reset(uint8_t aAttrEnum)
|
2010-12-03 16:40:23 +00:00
|
|
|
{
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(aAttrEnum < mNumberListCount, "Bad attr enum");
|
2010-12-03 16:40:23 +00:00
|
|
|
mNumberLists[aAttrEnum].ClearBaseValue(aAttrEnum);
|
|
|
|
// caller notifies
|
|
|
|
}
|
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
nsAttrValue
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::WillChangeNumberList(uint8_t aAttrEnum)
|
2010-12-03 16:40:23 +00:00
|
|
|
{
|
2012-02-15 23:40:46 +00:00
|
|
|
return WillChangeValue(*GetNumberListInfo().mNumberListInfo[aAttrEnum].mName);
|
|
|
|
}
|
2010-12-03 16:40:23 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidChangeNumberList(uint8_t aAttrEnum,
|
2012-02-15 23:40:46 +00:00
|
|
|
const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2010-12-03 16:40:23 +00:00
|
|
|
NumberListAttributesInfo info = GetNumberListInfo();
|
|
|
|
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(info.mNumberListCount > 0,
|
|
|
|
"DidChangeNumberList on element with no number list attribs");
|
|
|
|
MOZ_ASSERT(aAttrEnum < info.mNumberListCount,
|
|
|
|
"aAttrEnum out of range");
|
2010-12-03 16:40:23 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 14:20:58 +00:00
|
|
|
newValue.SetTo(info.mNumberLists[aAttrEnum].GetBaseValue(), nullptr);
|
2010-12-03 16:40:23 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
DidChangeValue(*info.mNumberListInfo[aAttrEnum].mName, aEmptyOrOldValue,
|
|
|
|
newValue);
|
2010-12-03 16:40:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidAnimateNumberList(uint8_t aAttrEnum)
|
2010-12-03 16:40:23 +00:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
NumberListAttributesInfo info = GetNumberListInfo();
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(aAttrEnum < info.mNumberListCount, "aAttrEnum out of range");
|
2010-12-03 16:40:23 +00:00
|
|
|
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mNumberListInfo[aAttrEnum].mName,
|
|
|
|
nsIDOMMutationEvent::MODIFICATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SVGAnimatedNumberList*
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::GetAnimatedNumberList(uint8_t aAttrEnum)
|
2010-12-03 16:40:23 +00:00
|
|
|
{
|
|
|
|
NumberListAttributesInfo info = GetNumberListInfo();
|
|
|
|
if (aAttrEnum < info.mNumberListCount) {
|
|
|
|
return &(info.mNumberLists[aAttrEnum]);
|
|
|
|
}
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(false, "Bad attrEnum");
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2010-12-03 16:40:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SVGAnimatedNumberList*
|
|
|
|
nsSVGElement::GetAnimatedNumberList(nsIAtom *aAttrName)
|
|
|
|
{
|
|
|
|
NumberListAttributesInfo info = GetNumberListInfo();
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < info.mNumberListCount; i++) {
|
2010-12-03 16:40:23 +00:00
|
|
|
if (aAttrName == *info.mNumberListInfo[i].mName) {
|
|
|
|
return &info.mNumberLists[i];
|
|
|
|
}
|
|
|
|
}
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(false, "Bad caller");
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2010-12-03 16:40:23 +00:00
|
|
|
}
|
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
nsAttrValue
|
|
|
|
nsSVGElement::WillChangePointList()
|
2010-12-08 12:15:53 +00:00
|
|
|
{
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(GetPointListAttrName(),
|
|
|
|
"Changing non-existent point list?");
|
2012-02-15 23:40:46 +00:00
|
|
|
return WillChangeValue(GetPointListAttrName());
|
|
|
|
}
|
2010-12-08 12:15:53 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
void
|
|
|
|
nsSVGElement::DidChangePointList(const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(GetPointListAttrName(),
|
|
|
|
"Changing non-existent point list?");
|
2010-12-08 12:15:53 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 14:20:58 +00:00
|
|
|
newValue.SetTo(GetAnimatedPointList()->GetBaseValue(), nullptr);
|
2010-12-08 12:15:53 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
DidChangeValue(GetPointListAttrName(), aEmptyOrOldValue, newValue);
|
2010-12-08 12:15:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGElement::DidAnimatePointList()
|
|
|
|
{
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(GetPointListAttrName(),
|
|
|
|
"Animating non-existent path data?");
|
2010-12-08 12:15:53 +00:00
|
|
|
|
2014-10-04 11:13:30 +00:00
|
|
|
ClearAnyCachedPath();
|
|
|
|
|
2010-12-08 12:15:53 +00:00
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
GetPointListAttrName(),
|
|
|
|
nsIDOMMutationEvent::MODIFICATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
nsAttrValue
|
|
|
|
nsSVGElement::WillChangePathSegList()
|
|
|
|
{
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(GetPathDataAttrName(),
|
|
|
|
"Changing non-existent path seg list?");
|
2012-02-15 23:40:46 +00:00
|
|
|
return WillChangeValue(GetPathDataAttrName());
|
|
|
|
}
|
|
|
|
|
2010-11-08 15:07:00 +00:00
|
|
|
void
|
2012-02-15 23:40:46 +00:00
|
|
|
nsSVGElement::DidChangePathSegList(const nsAttrValue& aEmptyOrOldValue)
|
2010-11-08 15:07:00 +00:00
|
|
|
{
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(GetPathDataAttrName(),
|
|
|
|
"Changing non-existent path seg list?");
|
2010-11-08 15:07:00 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 14:20:58 +00:00
|
|
|
newValue.SetTo(GetAnimPathSegList()->GetBaseValue(), nullptr);
|
2010-11-08 15:07:00 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
DidChangeValue(GetPathDataAttrName(), aEmptyOrOldValue, newValue);
|
2010-11-08 15:07:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGElement::DidAnimatePathSegList()
|
|
|
|
{
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(GetPathDataAttrName(),
|
|
|
|
"Animating non-existent path data?");
|
2010-11-08 15:07:00 +00:00
|
|
|
|
2014-10-04 11:13:30 +00:00
|
|
|
ClearAnyCachedPath();
|
|
|
|
|
2010-11-08 15:07:00 +00:00
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
GetPathDataAttrName(),
|
|
|
|
nsIDOMMutationEvent::MODIFICATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-28 18:10:48 +00:00
|
|
|
nsSVGElement::NumberAttributesInfo
|
|
|
|
nsSVGElement::GetNumberInfo()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return NumberAttributesInfo(nullptr, nullptr, 0);
|
2006-07-28 18:10:48 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void nsSVGElement::NumberAttributesInfo::Reset(uint8_t aAttrEnum)
|
2007-11-22 08:54:31 +00:00
|
|
|
{
|
|
|
|
mNumbers[aAttrEnum].Init(aAttrEnum,
|
|
|
|
mNumberInfo[aAttrEnum].mDefaultValue);
|
|
|
|
}
|
|
|
|
|
2006-07-28 18:10:48 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidChangeNumber(uint8_t aAttrEnum)
|
2006-07-28 18:10:48 +00:00
|
|
|
{
|
|
|
|
NumberAttributesInfo info = GetNumberInfo();
|
|
|
|
|
|
|
|
NS_ASSERTION(info.mNumberCount > 0,
|
|
|
|
"DidChangeNumber on element with no number attribs");
|
|
|
|
NS_ASSERTION(aAttrEnum < info.mNumberCount, "aAttrEnum out of range");
|
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
nsAttrValue attrValue;
|
2012-07-30 14:20:58 +00:00
|
|
|
attrValue.SetTo(info.mNumbers[aAttrEnum].GetBaseValue(), nullptr);
|
2006-07-28 18:10:48 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
SetParsedAttr(kNameSpaceID_None, *info.mNumberInfo[aAttrEnum].mName, nullptr,
|
2011-10-17 14:59:28 +00:00
|
|
|
attrValue, true);
|
2006-07-28 18:10:48 +00:00
|
|
|
}
|
|
|
|
|
2009-12-29 06:34:27 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidAnimateNumber(uint8_t aAttrEnum)
|
2009-12-29 06:34:27 +00:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
NumberAttributesInfo info = GetNumberInfo();
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mNumberInfo[aAttrEnum].mName,
|
|
|
|
nsIDOMMutationEvent::MODIFICATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-28 18:10:48 +00:00
|
|
|
void
|
|
|
|
nsSVGElement::GetAnimatedNumberValues(float *aFirst, ...)
|
|
|
|
{
|
|
|
|
NumberAttributesInfo info = GetNumberInfo();
|
|
|
|
|
|
|
|
NS_ASSERTION(info.mNumberCount > 0,
|
|
|
|
"GetAnimatedNumberValues on element with no number attribs");
|
|
|
|
|
|
|
|
float *f = aFirst;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t i = 0;
|
2006-07-28 18:10:48 +00:00
|
|
|
|
|
|
|
va_list args;
|
|
|
|
va_start(args, aFirst);
|
|
|
|
|
|
|
|
while (f && i < info.mNumberCount) {
|
2010-02-25 18:20:43 +00:00
|
|
|
*f = info.mNumbers[i++].GetAnimValue();
|
2006-07-28 18:10:48 +00:00
|
|
|
f = va_arg(args, float*);
|
|
|
|
}
|
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
|
2011-07-01 07:19:52 +00:00
|
|
|
nsSVGElement::NumberPairAttributesInfo
|
|
|
|
nsSVGElement::GetNumberPairInfo()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return NumberPairAttributesInfo(nullptr, nullptr, 0);
|
2011-07-01 07:19:52 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void nsSVGElement::NumberPairAttributesInfo::Reset(uint8_t aAttrEnum)
|
2011-07-01 07:19:52 +00:00
|
|
|
{
|
|
|
|
mNumberPairs[aAttrEnum].Init(aAttrEnum,
|
|
|
|
mNumberPairInfo[aAttrEnum].mDefaultValue1,
|
|
|
|
mNumberPairInfo[aAttrEnum].mDefaultValue2);
|
|
|
|
}
|
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
nsAttrValue
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::WillChangeNumberPair(uint8_t aAttrEnum)
|
2011-07-01 07:19:52 +00:00
|
|
|
{
|
2012-02-15 23:40:45 +00:00
|
|
|
return WillChangeValue(*GetNumberPairInfo().mNumberPairInfo[aAttrEnum].mName);
|
|
|
|
}
|
2011-07-01 07:19:52 +00:00
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidChangeNumberPair(uint8_t aAttrEnum,
|
2012-02-15 23:40:45 +00:00
|
|
|
const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2011-07-01 07:19:52 +00:00
|
|
|
NumberPairAttributesInfo info = GetNumberPairInfo();
|
|
|
|
|
|
|
|
NS_ASSERTION(info.mNumberPairCount > 0,
|
|
|
|
"DidChangePairNumber on element with no number pair attribs");
|
|
|
|
NS_ASSERTION(aAttrEnum < info.mNumberPairCount, "aAttrEnum out of range");
|
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 14:20:58 +00:00
|
|
|
newValue.SetTo(info.mNumberPairs[aAttrEnum], nullptr);
|
2011-07-01 07:19:52 +00:00
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
DidChangeValue(*info.mNumberPairInfo[aAttrEnum].mName, aEmptyOrOldValue,
|
|
|
|
newValue);
|
2011-07-01 07:19:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidAnimateNumberPair(uint8_t aAttrEnum)
|
2011-07-01 07:19:52 +00:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
NumberPairAttributesInfo info = GetNumberPairInfo();
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mNumberPairInfo[aAttrEnum].mName,
|
|
|
|
nsIDOMMutationEvent::MODIFICATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-18 12:09:26 +00:00
|
|
|
nsSVGElement::IntegerAttributesInfo
|
|
|
|
nsSVGElement::GetIntegerInfo()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return IntegerAttributesInfo(nullptr, nullptr, 0);
|
2007-09-18 12:09:26 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void nsSVGElement::IntegerAttributesInfo::Reset(uint8_t aAttrEnum)
|
2007-11-22 08:54:31 +00:00
|
|
|
{
|
|
|
|
mIntegers[aAttrEnum].Init(aAttrEnum,
|
|
|
|
mIntegerInfo[aAttrEnum].mDefaultValue);
|
|
|
|
}
|
|
|
|
|
2007-09-18 12:09:26 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidChangeInteger(uint8_t aAttrEnum)
|
2007-09-18 12:09:26 +00:00
|
|
|
{
|
|
|
|
IntegerAttributesInfo info = GetIntegerInfo();
|
|
|
|
|
|
|
|
NS_ASSERTION(info.mIntegerCount > 0,
|
|
|
|
"DidChangeInteger on element with no integer attribs");
|
|
|
|
NS_ASSERTION(aAttrEnum < info.mIntegerCount, "aAttrEnum out of range");
|
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
nsAttrValue attrValue;
|
2012-07-30 14:20:58 +00:00
|
|
|
attrValue.SetTo(info.mIntegers[aAttrEnum].GetBaseValue(), nullptr);
|
2007-09-18 12:09:26 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
SetParsedAttr(kNameSpaceID_None, *info.mIntegerInfo[aAttrEnum].mName, nullptr,
|
2011-10-17 14:59:28 +00:00
|
|
|
attrValue, true);
|
2007-09-18 12:09:26 +00:00
|
|
|
}
|
|
|
|
|
2010-02-18 21:51:00 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidAnimateInteger(uint8_t aAttrEnum)
|
2010-02-18 21:51:00 +00:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
IntegerAttributesInfo info = GetIntegerInfo();
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mIntegerInfo[aAttrEnum].mName,
|
|
|
|
nsIDOMMutationEvent::MODIFICATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-18 12:09:26 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::GetAnimatedIntegerValues(int32_t *aFirst, ...)
|
2007-09-18 12:09:26 +00:00
|
|
|
{
|
|
|
|
IntegerAttributesInfo info = GetIntegerInfo();
|
|
|
|
|
|
|
|
NS_ASSERTION(info.mIntegerCount > 0,
|
|
|
|
"GetAnimatedIntegerValues on element with no integer attribs");
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t *n = aFirst;
|
|
|
|
uint32_t i = 0;
|
2007-09-18 12:09:26 +00:00
|
|
|
|
|
|
|
va_list args;
|
|
|
|
va_start(args, aFirst);
|
|
|
|
|
|
|
|
while (n && i < info.mIntegerCount) {
|
2010-02-25 18:20:43 +00:00
|
|
|
*n = info.mIntegers[i++].GetAnimValue();
|
2012-08-22 15:56:38 +00:00
|
|
|
n = va_arg(args, int32_t*);
|
2007-09-18 12:09:26 +00:00
|
|
|
}
|
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
|
2011-07-01 07:19:52 +00:00
|
|
|
nsSVGElement::IntegerPairAttributesInfo
|
|
|
|
nsSVGElement::GetIntegerPairInfo()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return IntegerPairAttributesInfo(nullptr, nullptr, 0);
|
2011-07-01 07:19:52 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void nsSVGElement::IntegerPairAttributesInfo::Reset(uint8_t aAttrEnum)
|
2011-07-01 07:19:52 +00:00
|
|
|
{
|
|
|
|
mIntegerPairs[aAttrEnum].Init(aAttrEnum,
|
|
|
|
mIntegerPairInfo[aAttrEnum].mDefaultValue1,
|
|
|
|
mIntegerPairInfo[aAttrEnum].mDefaultValue2);
|
|
|
|
}
|
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
nsAttrValue
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::WillChangeIntegerPair(uint8_t aAttrEnum)
|
2011-07-01 07:19:52 +00:00
|
|
|
{
|
2012-02-15 23:40:45 +00:00
|
|
|
return WillChangeValue(
|
|
|
|
*GetIntegerPairInfo().mIntegerPairInfo[aAttrEnum].mName);
|
|
|
|
}
|
2011-07-01 07:19:52 +00:00
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidChangeIntegerPair(uint8_t aAttrEnum,
|
2012-02-15 23:40:45 +00:00
|
|
|
const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2011-07-01 07:19:52 +00:00
|
|
|
IntegerPairAttributesInfo info = GetIntegerPairInfo();
|
|
|
|
|
|
|
|
NS_ASSERTION(info.mIntegerPairCount > 0,
|
|
|
|
"DidChangeIntegerPair on element with no integer pair attribs");
|
|
|
|
NS_ASSERTION(aAttrEnum < info.mIntegerPairCount, "aAttrEnum out of range");
|
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 14:20:58 +00:00
|
|
|
newValue.SetTo(info.mIntegerPairs[aAttrEnum], nullptr);
|
2011-07-01 07:19:52 +00:00
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
DidChangeValue(*info.mIntegerPairInfo[aAttrEnum].mName, aEmptyOrOldValue,
|
|
|
|
newValue);
|
2011-07-01 07:19:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidAnimateIntegerPair(uint8_t aAttrEnum)
|
2011-07-01 07:19:52 +00:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
IntegerPairAttributesInfo info = GetIntegerPairInfo();
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mIntegerPairInfo[aAttrEnum].mName,
|
|
|
|
nsIDOMMutationEvent::MODIFICATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-10 10:07:59 +00:00
|
|
|
nsSVGElement::AngleAttributesInfo
|
|
|
|
nsSVGElement::GetAngleInfo()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return AngleAttributesInfo(nullptr, nullptr, 0);
|
2007-10-10 10:07:59 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void nsSVGElement::AngleAttributesInfo::Reset(uint8_t aAttrEnum)
|
2007-11-22 08:54:31 +00:00
|
|
|
{
|
|
|
|
mAngles[aAttrEnum].Init(aAttrEnum,
|
|
|
|
mAngleInfo[aAttrEnum].mDefaultValue,
|
|
|
|
mAngleInfo[aAttrEnum].mDefaultUnitType);
|
|
|
|
}
|
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
nsAttrValue
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::WillChangeAngle(uint8_t aAttrEnum)
|
2007-10-10 10:07:59 +00:00
|
|
|
{
|
2012-02-15 23:40:45 +00:00
|
|
|
return WillChangeValue(*GetAngleInfo().mAngleInfo[aAttrEnum].mName);
|
|
|
|
}
|
2007-10-10 10:07:59 +00:00
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidChangeAngle(uint8_t aAttrEnum,
|
2012-02-15 23:40:45 +00:00
|
|
|
const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2007-10-10 10:07:59 +00:00
|
|
|
AngleAttributesInfo info = GetAngleInfo();
|
|
|
|
|
|
|
|
NS_ASSERTION(info.mAngleCount > 0,
|
|
|
|
"DidChangeAngle on element with no angle attribs");
|
|
|
|
NS_ASSERTION(aAttrEnum < info.mAngleCount, "aAttrEnum out of range");
|
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 14:20:58 +00:00
|
|
|
newValue.SetTo(info.mAngles[aAttrEnum], nullptr);
|
2007-10-10 10:07:59 +00:00
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
DidChangeValue(*info.mAngleInfo[aAttrEnum].mName, aEmptyOrOldValue, newValue);
|
2007-10-10 10:07:59 +00:00
|
|
|
}
|
|
|
|
|
2010-02-18 21:50:59 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidAnimateAngle(uint8_t aAttrEnum)
|
2010-02-18 21:50:59 +00:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
AngleAttributesInfo info = GetAngleInfo();
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mAngleInfo[aAttrEnum].mName,
|
|
|
|
nsIDOMMutationEvent::MODIFICATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-26 09:22:08 +00:00
|
|
|
nsSVGElement::BooleanAttributesInfo
|
|
|
|
nsSVGElement::GetBooleanInfo()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return BooleanAttributesInfo(nullptr, nullptr, 0);
|
2007-09-26 09:22:08 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void nsSVGElement::BooleanAttributesInfo::Reset(uint8_t aAttrEnum)
|
2007-11-22 08:54:31 +00:00
|
|
|
{
|
|
|
|
mBooleans[aAttrEnum].Init(aAttrEnum,
|
|
|
|
mBooleanInfo[aAttrEnum].mDefaultValue);
|
|
|
|
}
|
|
|
|
|
2007-09-26 09:22:08 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidChangeBoolean(uint8_t aAttrEnum)
|
2007-09-26 09:22:08 +00:00
|
|
|
{
|
|
|
|
BooleanAttributesInfo info = GetBooleanInfo();
|
|
|
|
|
|
|
|
NS_ASSERTION(info.mBooleanCount > 0,
|
2007-10-10 10:07:59 +00:00
|
|
|
"DidChangeBoolean on element with no boolean attribs");
|
2007-09-26 09:22:08 +00:00
|
|
|
NS_ASSERTION(aAttrEnum < info.mBooleanCount, "aAttrEnum out of range");
|
|
|
|
|
2012-02-15 23:40:45 +00:00
|
|
|
nsAttrValue attrValue(info.mBooleans[aAttrEnum].GetBaseValueAtom());
|
2012-07-30 14:20:58 +00:00
|
|
|
SetParsedAttr(kNameSpaceID_None, *info.mBooleanInfo[aAttrEnum].mName, nullptr,
|
2011-10-17 14:59:28 +00:00
|
|
|
attrValue, true);
|
2007-09-26 09:22:08 +00:00
|
|
|
}
|
|
|
|
|
2010-01-24 16:42:08 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidAnimateBoolean(uint8_t aAttrEnum)
|
2010-01-24 16:42:08 +00:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
BooleanAttributesInfo info = GetBooleanInfo();
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mBooleanInfo[aAttrEnum].mName,
|
|
|
|
nsIDOMMutationEvent::MODIFICATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-27 23:11:14 +00:00
|
|
|
nsSVGElement::EnumAttributesInfo
|
|
|
|
nsSVGElement::GetEnumInfo()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return EnumAttributesInfo(nullptr, nullptr, 0);
|
2007-08-27 23:11:14 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void nsSVGElement::EnumAttributesInfo::Reset(uint8_t aAttrEnum)
|
2007-11-22 08:54:31 +00:00
|
|
|
{
|
|
|
|
mEnums[aAttrEnum].Init(aAttrEnum,
|
|
|
|
mEnumInfo[aAttrEnum].mDefaultValue);
|
|
|
|
}
|
|
|
|
|
2007-08-27 23:11:14 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidChangeEnum(uint8_t aAttrEnum)
|
2007-08-27 23:11:14 +00:00
|
|
|
{
|
|
|
|
EnumAttributesInfo info = GetEnumInfo();
|
|
|
|
|
|
|
|
NS_ASSERTION(info.mEnumCount > 0,
|
2007-09-18 12:09:26 +00:00
|
|
|
"DidChangeEnum on element with no enum attribs");
|
2007-08-27 23:11:14 +00:00
|
|
|
NS_ASSERTION(aAttrEnum < info.mEnumCount, "aAttrEnum out of range");
|
|
|
|
|
2012-02-15 23:40:44 +00:00
|
|
|
nsAttrValue attrValue(info.mEnums[aAttrEnum].GetBaseValueAtom(this));
|
2012-07-30 14:20:58 +00:00
|
|
|
SetParsedAttr(kNameSpaceID_None, *info.mEnumInfo[aAttrEnum].mName, nullptr,
|
2011-10-17 14:59:28 +00:00
|
|
|
attrValue, true);
|
2007-08-27 23:11:14 +00:00
|
|
|
}
|
|
|
|
|
2010-01-23 18:59:03 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidAnimateEnum(uint8_t aAttrEnum)
|
2010-01-23 18:59:03 +00:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
EnumAttributesInfo info = GetEnumInfo();
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mEnumInfo[aAttrEnum].mName,
|
|
|
|
nsIDOMMutationEvent::MODIFICATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-03 14:42:24 +00:00
|
|
|
nsSVGViewBox *
|
|
|
|
nsSVGElement::GetViewBox()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2009-02-03 14:42:24 +00:00
|
|
|
}
|
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
nsAttrValue
|
|
|
|
nsSVGElement::WillChangeViewBox()
|
2009-02-03 14:42:24 +00:00
|
|
|
{
|
2012-02-15 23:40:46 +00:00
|
|
|
return WillChangeValue(nsGkAtoms::viewBox);
|
|
|
|
}
|
2009-02-03 14:42:24 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
void
|
|
|
|
nsSVGElement::DidChangeViewBox(const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2009-02-03 14:42:24 +00:00
|
|
|
nsSVGViewBox *viewBox = GetViewBox();
|
|
|
|
|
|
|
|
NS_ASSERTION(viewBox, "DidChangeViewBox on element with no viewBox attrib");
|
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 14:20:58 +00:00
|
|
|
newValue.SetTo(*viewBox, nullptr);
|
2009-02-03 14:42:24 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
DidChangeValue(nsGkAtoms::viewBox, aEmptyOrOldValue, newValue);
|
2009-02-03 14:42:24 +00:00
|
|
|
}
|
|
|
|
|
2010-02-18 21:51:00 +00:00
|
|
|
void
|
|
|
|
nsSVGElement::DidAnimateViewBox()
|
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
nsGkAtoms::viewBox,
|
|
|
|
nsIDOMMutationEvent::MODIFICATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-20 00:45:29 +00:00
|
|
|
SVGAnimatedPreserveAspectRatio *
|
2009-01-05 01:19:38 +00:00
|
|
|
nsSVGElement::GetPreserveAspectRatio()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2009-01-05 01:19:38 +00:00
|
|
|
}
|
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
nsAttrValue
|
|
|
|
nsSVGElement::WillChangePreserveAspectRatio()
|
2009-01-05 01:19:38 +00:00
|
|
|
{
|
2012-02-15 23:40:46 +00:00
|
|
|
return WillChangeValue(nsGkAtoms::preserveAspectRatio);
|
|
|
|
}
|
2009-01-05 01:19:38 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
void
|
|
|
|
nsSVGElement::DidChangePreserveAspectRatio(const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2010-12-20 00:45:29 +00:00
|
|
|
SVGAnimatedPreserveAspectRatio *preserveAspectRatio =
|
|
|
|
GetPreserveAspectRatio();
|
2009-01-05 01:19:38 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(preserveAspectRatio,
|
2012-02-15 23:40:46 +00:00
|
|
|
"DidChangePreserveAspectRatio on element with no "
|
|
|
|
"preserveAspectRatio attrib");
|
2009-01-05 01:19:38 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 14:20:58 +00:00
|
|
|
newValue.SetTo(*preserveAspectRatio, nullptr);
|
2009-01-05 01:19:38 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
DidChangeValue(nsGkAtoms::preserveAspectRatio, aEmptyOrOldValue, newValue);
|
2009-01-05 01:19:38 +00:00
|
|
|
}
|
|
|
|
|
2010-02-08 02:28:01 +00:00
|
|
|
void
|
|
|
|
nsSVGElement::DidAnimatePreserveAspectRatio()
|
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
nsGkAtoms::preserveAspectRatio,
|
|
|
|
nsIDOMMutationEvent::MODIFICATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
nsAttrValue
|
|
|
|
nsSVGElement::WillChangeTransformList()
|
2010-03-02 15:36:31 +00:00
|
|
|
{
|
2012-02-15 23:40:46 +00:00
|
|
|
return WillChangeValue(GetTransformListAttrName());
|
|
|
|
}
|
2011-09-25 21:04:31 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
void
|
|
|
|
nsSVGElement::DidChangeTransformList(const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(GetTransformListAttrName(),
|
|
|
|
"Changing non-existent transform list?");
|
2011-09-25 21:04:31 +00:00
|
|
|
|
2012-07-30 00:35:26 +00:00
|
|
|
// The transform attribute is being set, so we must ensure that the
|
|
|
|
// SVGAnimatedTransformList is/has been allocated:
|
2012-02-15 23:40:46 +00:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 14:20:58 +00:00
|
|
|
newValue.SetTo(GetAnimatedTransformList(DO_ALLOCATE)->GetBaseValue(), nullptr);
|
2011-09-25 21:04:31 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
DidChangeValue(GetTransformListAttrName(), aEmptyOrOldValue, newValue);
|
2011-09-25 21:04:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-04-07 19:52:12 +00:00
|
|
|
nsSVGElement::DidAnimateTransformList(int32_t aModType)
|
2011-09-25 21:04:31 +00:00
|
|
|
{
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(GetTransformListAttrName(),
|
|
|
|
"Animating non-existent transform data?");
|
2011-09-25 21:04:31 +00:00
|
|
|
|
2010-03-02 15:36:31 +00:00
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
2011-09-25 21:04:31 +00:00
|
|
|
|
2010-03-02 15:36:31 +00:00
|
|
|
if (frame) {
|
2013-02-11 23:25:56 +00:00
|
|
|
nsIAtom *transformAttr = GetTransformListAttrName();
|
2010-03-02 15:36:31 +00:00
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
2013-02-11 23:25:56 +00:00
|
|
|
transformAttr,
|
2014-04-07 19:52:12 +00:00
|
|
|
aModType);
|
2013-02-11 23:25:56 +00:00
|
|
|
// When script changes the 'transform' attribute, Element::SetAttrAndNotify
|
|
|
|
// will call nsNodeUtills::AttributeChanged, under which
|
|
|
|
// SVGTransformableElement::GetAttributeChangeHint will be called and an
|
|
|
|
// appropriate change event posted to update our frame's overflow rects.
|
|
|
|
// The SetAttrAndNotify doesn't happen for transform changes caused by
|
|
|
|
// 'animateTransform' though (and sending out the mutation events that
|
|
|
|
// nsNodeUtills::AttributeChanged dispatches would be inappropriate
|
|
|
|
// anyway), so we need to post the change event ourself.
|
2014-04-07 19:52:12 +00:00
|
|
|
nsChangeHint changeHint = GetAttributeChangeHint(transformAttr, aModType);
|
2013-02-11 23:25:56 +00:00
|
|
|
if (changeHint) {
|
|
|
|
nsLayoutUtils::PostRestyleEvent(this, nsRestyleHint(0), changeHint);
|
|
|
|
}
|
2010-03-02 15:36:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-14 09:01:02 +00:00
|
|
|
nsSVGElement::StringAttributesInfo
|
|
|
|
nsSVGElement::GetStringInfo()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return StringAttributesInfo(nullptr, nullptr, 0);
|
2008-06-14 09:01:02 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void nsSVGElement::StringAttributesInfo::Reset(uint8_t aAttrEnum)
|
2008-06-14 09:01:02 +00:00
|
|
|
{
|
|
|
|
mStrings[aAttrEnum].Init(aAttrEnum);
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void nsSVGElement::GetStringBaseValue(uint8_t aAttrEnum, nsAString& aResult) const
|
2008-06-14 09:01:02 +00:00
|
|
|
{
|
2009-01-22 00:56:51 +00:00
|
|
|
nsSVGElement::StringAttributesInfo info = const_cast<nsSVGElement*>(this)->GetStringInfo();
|
|
|
|
|
|
|
|
NS_ASSERTION(info.mStringCount > 0,
|
|
|
|
"GetBaseValue on element with no string attribs");
|
2009-01-19 09:03:31 +00:00
|
|
|
|
2009-01-22 00:56:51 +00:00
|
|
|
NS_ASSERTION(aAttrEnum < info.mStringCount, "aAttrEnum out of range");
|
|
|
|
|
|
|
|
GetAttr(info.mStringInfo[aAttrEnum].mNamespaceID,
|
|
|
|
*info.mStringInfo[aAttrEnum].mName, aResult);
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void nsSVGElement::SetStringBaseValue(uint8_t aAttrEnum, const nsAString& aValue)
|
2009-01-22 00:56:51 +00:00
|
|
|
{
|
|
|
|
nsSVGElement::StringAttributesInfo info = GetStringInfo();
|
2008-06-14 09:01:02 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(info.mStringCount > 0,
|
2009-01-22 00:56:51 +00:00
|
|
|
"SetBaseValue on element with no string attribs");
|
2008-06-14 09:01:02 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(aAttrEnum < info.mStringCount, "aAttrEnum out of range");
|
|
|
|
|
|
|
|
SetAttr(info.mStringInfo[aAttrEnum].mNamespaceID,
|
2011-10-17 14:59:28 +00:00
|
|
|
*info.mStringInfo[aAttrEnum].mName, aValue, true);
|
2008-06-14 09:01:02 +00:00
|
|
|
}
|
|
|
|
|
2010-10-07 19:19:32 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::DidAnimateString(uint8_t aAttrEnum)
|
2010-10-07 19:19:32 +00:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
StringAttributesInfo info = GetStringInfo();
|
|
|
|
frame->AttributeChanged(info.mStringInfo[aAttrEnum].mNamespaceID,
|
|
|
|
*info.mStringInfo[aAttrEnum].mName,
|
|
|
|
nsIDOMMutationEvent::MODIFICATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-31 09:44:03 +00:00
|
|
|
nsSVGElement::StringListAttributesInfo
|
|
|
|
nsSVGElement::GetStringListInfo()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return StringListAttributesInfo(nullptr, nullptr, 0);
|
2011-12-31 09:44:03 +00:00
|
|
|
}
|
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
nsAttrValue
|
|
|
|
nsSVGElement::WillChangeStringList(bool aIsConditionalProcessingAttribute,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t aAttrEnum)
|
2011-12-31 09:44:03 +00:00
|
|
|
{
|
2012-02-15 23:40:46 +00:00
|
|
|
nsIAtom* name;
|
2011-12-31 09:44:03 +00:00
|
|
|
if (aIsConditionalProcessingAttribute) {
|
2013-03-28 01:23:09 +00:00
|
|
|
nsCOMPtr<SVGTests> tests(do_QueryInterface(static_cast<nsIDOMSVGElement*>(this)));
|
2012-02-15 23:40:46 +00:00
|
|
|
name = tests->GetAttrName(aAttrEnum);
|
|
|
|
} else {
|
|
|
|
name = *GetStringListInfo().mStringListInfo[aAttrEnum].mName;
|
2011-12-31 09:44:03 +00:00
|
|
|
}
|
2012-02-15 23:40:46 +00:00
|
|
|
return WillChangeValue(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGElement::DidChangeStringList(bool aIsConditionalProcessingAttribute,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t aAttrEnum,
|
2012-02-15 23:40:46 +00:00
|
|
|
const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
|
|
|
nsIAtom* name;
|
|
|
|
nsAttrValue newValue;
|
2013-03-02 06:08:42 +00:00
|
|
|
nsCOMPtr<SVGTests> tests;
|
2011-12-31 09:44:03 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
if (aIsConditionalProcessingAttribute) {
|
2013-03-28 01:23:09 +00:00
|
|
|
tests = do_QueryObject(this);
|
2012-02-15 23:40:46 +00:00
|
|
|
name = tests->GetAttrName(aAttrEnum);
|
|
|
|
tests->GetAttrValue(aAttrEnum, newValue);
|
|
|
|
} else {
|
|
|
|
StringListAttributesInfo info = GetStringListInfo();
|
2011-12-31 09:44:03 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
NS_ASSERTION(info.mStringListCount > 0,
|
|
|
|
"DidChangeStringList on element with no string list attribs");
|
|
|
|
NS_ASSERTION(aAttrEnum < info.mStringListCount, "aAttrEnum out of range");
|
2011-12-31 09:44:03 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
name = *info.mStringListInfo[aAttrEnum].mName;
|
2012-07-30 14:20:58 +00:00
|
|
|
newValue.SetTo(info.mStringLists[aAttrEnum], nullptr);
|
2012-02-15 23:40:46 +00:00
|
|
|
}
|
2011-12-31 09:44:03 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
DidChangeValue(name, aEmptyOrOldValue, newValue);
|
2011-12-31 09:44:03 +00:00
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
if (aIsConditionalProcessingAttribute) {
|
|
|
|
tests->MaybeInvalidate();
|
|
|
|
}
|
2011-12-31 09:44:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::StringListAttributesInfo::Reset(uint8_t aAttrEnum)
|
2011-12-31 09:44:03 +00:00
|
|
|
{
|
|
|
|
mStringLists[aAttrEnum].Clear();
|
|
|
|
// caller notifies
|
|
|
|
}
|
|
|
|
|
2006-08-08 14:36:43 +00:00
|
|
|
nsresult
|
|
|
|
nsSVGElement::ReportAttributeParseFailure(nsIDocument* aDocument,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue)
|
|
|
|
{
|
|
|
|
const nsAFlatString& attributeValue = PromiseFlatString(aValue);
|
2014-01-04 15:02:17 +00:00
|
|
|
const char16_t *strings[] = { aAttribute->GetUTF16String(),
|
2010-03-08 15:45:00 +00:00
|
|
|
attributeValue.get() };
|
2012-09-22 19:26:05 +00:00
|
|
|
return SVGContentUtils::ReportToConsole(aDocument,
|
|
|
|
"AttributeParseWarning",
|
|
|
|
strings, ArrayLength(strings));
|
2006-08-08 14:36:43 +00:00
|
|
|
}
|
2006-10-07 10:27:45 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGElement::RecompileScriptEventListeners()
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t i, count = mAttrsAndChildren.AttrCount();
|
2007-07-02 09:54:11 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
|
|
|
const nsAttrName *name = mAttrsAndChildren.AttrNameAt(i);
|
2006-10-07 10:27:45 +00:00
|
|
|
|
2007-07-02 09:54:11 +00:00
|
|
|
// Eventlistenener-attributes are always in the null namespace
|
|
|
|
if (!name->IsAtom()) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-10-07 10:27:45 +00:00
|
|
|
|
2007-07-02 09:54:11 +00:00
|
|
|
nsIAtom *attr = name->Atom();
|
2013-01-02 20:24:07 +00:00
|
|
|
if (!IsEventAttributeName(attr)) {
|
2007-07-02 09:54:11 +00:00
|
|
|
continue;
|
2006-10-07 10:27:45 +00:00
|
|
|
}
|
2007-07-02 09:54:11 +00:00
|
|
|
|
|
|
|
nsAutoString value;
|
|
|
|
GetAttr(kNameSpaceID_None, attr, value);
|
2012-08-30 16:25:10 +00:00
|
|
|
SetEventHandler(GetEventNameForAttr(attr), value, true);
|
2007-07-02 09:54:11 +00:00
|
|
|
}
|
2006-10-07 10:27:45 +00:00
|
|
|
}
|
2009-01-15 04:38:07 +00:00
|
|
|
|
|
|
|
nsISMILAttr*
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGElement::GetAnimatedAttr(int32_t aNamespaceID, nsIAtom* aName)
|
2009-01-15 04:38:07 +00:00
|
|
|
{
|
2010-10-07 19:19:32 +00:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
2012-06-16 15:47:40 +00:00
|
|
|
// We check mapped-into-style attributes first so that animations
|
|
|
|
// targeting width/height on outer-<svg> don't appear to be ignored
|
|
|
|
// because we returned a nsISMILAttr for the corresponding
|
|
|
|
// SVGAnimatedLength.
|
|
|
|
|
|
|
|
// Mapped attributes:
|
|
|
|
if (IsAttributeMapped(aName)) {
|
|
|
|
nsCSSProperty prop =
|
2012-07-13 23:59:05 +00:00
|
|
|
nsCSSProps::LookupProperty(nsDependentAtomString(aName),
|
2014-03-07 17:14:23 +00:00
|
|
|
nsCSSProps::eEnabledForAllContent);
|
2012-06-16 15:47:40 +00:00
|
|
|
// Check IsPropertyAnimatable to avoid attributes that...
|
|
|
|
// - map to explicitly unanimatable properties (e.g. 'direction')
|
|
|
|
// - map to unsupported attributes (e.g. 'glyph-orientation-horizontal')
|
|
|
|
if (nsSMILCSSProperty::IsPropertyAnimatable(prop)) {
|
|
|
|
return new nsSMILMappedAttribute(prop, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-07 19:19:32 +00:00
|
|
|
// Transforms:
|
2011-09-25 21:04:31 +00:00
|
|
|
if (GetTransformListAttrName() == aName) {
|
2012-07-30 00:35:26 +00:00
|
|
|
// The transform attribute is being animated, so we must ensure that the
|
|
|
|
// SVGAnimatedTransformList is/has been allocated:
|
|
|
|
return GetAnimatedTransformList(DO_ALLOCATE)->ToSMILAttr(this);
|
2010-10-07 19:19:32 +00:00
|
|
|
}
|
2009-01-19 09:14:16 +00:00
|
|
|
|
2010-10-07 19:19:32 +00:00
|
|
|
// Motion (fake 'attribute' for animateMotion)
|
|
|
|
if (aName == nsGkAtoms::mozAnimateMotionDummyAttr) {
|
|
|
|
return new SVGMotionSMILAttr(this);
|
|
|
|
}
|
2010-04-28 23:00:54 +00:00
|
|
|
|
2010-10-07 19:19:32 +00:00
|
|
|
// Lengths:
|
|
|
|
LengthAttributesInfo info = GetLengthInfo();
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < info.mLengthCount; i++) {
|
2010-10-07 19:19:32 +00:00
|
|
|
if (aName == *info.mLengthInfo[i].mName) {
|
|
|
|
return info.mLengths[i].ToSMILAttr(this);
|
|
|
|
}
|
2009-01-15 04:38:07 +00:00
|
|
|
}
|
|
|
|
|
2010-10-07 19:19:32 +00:00
|
|
|
// Numbers:
|
|
|
|
{
|
|
|
|
NumberAttributesInfo info = GetNumberInfo();
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < info.mNumberCount; i++) {
|
2010-10-07 19:19:32 +00:00
|
|
|
if (aName == *info.mNumberInfo[i].mName) {
|
|
|
|
return info.mNumbers[i].ToSMILAttr(this);
|
|
|
|
}
|
2009-12-29 06:34:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-01 07:19:52 +00:00
|
|
|
// Number Pairs:
|
|
|
|
{
|
|
|
|
NumberPairAttributesInfo info = GetNumberPairInfo();
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < info.mNumberPairCount; i++) {
|
2011-07-01 07:19:52 +00:00
|
|
|
if (aName == *info.mNumberPairInfo[i].mName) {
|
|
|
|
return info.mNumberPairs[i].ToSMILAttr(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-07 19:19:32 +00:00
|
|
|
// Integers:
|
|
|
|
{
|
|
|
|
IntegerAttributesInfo info = GetIntegerInfo();
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < info.mIntegerCount; i++) {
|
2010-10-07 19:19:32 +00:00
|
|
|
if (aName == *info.mIntegerInfo[i].mName) {
|
|
|
|
return info.mIntegers[i].ToSMILAttr(this);
|
|
|
|
}
|
2010-02-18 21:51:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-01 07:19:52 +00:00
|
|
|
// Integer Pairs:
|
|
|
|
{
|
|
|
|
IntegerPairAttributesInfo info = GetIntegerPairInfo();
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < info.mIntegerPairCount; i++) {
|
2011-07-01 07:19:52 +00:00
|
|
|
if (aName == *info.mIntegerPairInfo[i].mName) {
|
|
|
|
return info.mIntegerPairs[i].ToSMILAttr(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-07 19:19:32 +00:00
|
|
|
// Enumerations:
|
|
|
|
{
|
|
|
|
EnumAttributesInfo info = GetEnumInfo();
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < info.mEnumCount; i++) {
|
2010-10-07 19:19:32 +00:00
|
|
|
if (aName == *info.mEnumInfo[i].mName) {
|
|
|
|
return info.mEnums[i].ToSMILAttr(this);
|
|
|
|
}
|
2010-01-23 18:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-07 19:19:32 +00:00
|
|
|
// Booleans:
|
|
|
|
{
|
|
|
|
BooleanAttributesInfo info = GetBooleanInfo();
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < info.mBooleanCount; i++) {
|
2010-10-07 19:19:32 +00:00
|
|
|
if (aName == *info.mBooleanInfo[i].mName) {
|
|
|
|
return info.mBooleans[i].ToSMILAttr(this);
|
|
|
|
}
|
2010-01-24 16:42:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-07 19:19:32 +00:00
|
|
|
// Angles:
|
|
|
|
{
|
|
|
|
AngleAttributesInfo info = GetAngleInfo();
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < info.mAngleCount; i++) {
|
2010-10-07 19:19:32 +00:00
|
|
|
if (aName == *info.mAngleInfo[i].mName) {
|
|
|
|
return info.mAngles[i].ToSMILAttr(this);
|
|
|
|
}
|
2010-02-18 21:50:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-07 19:19:32 +00:00
|
|
|
// viewBox:
|
|
|
|
if (aName == nsGkAtoms::viewBox) {
|
|
|
|
nsSVGViewBox *viewBox = GetViewBox();
|
2012-07-30 14:20:58 +00:00
|
|
|
return viewBox ? viewBox->ToSMILAttr(this) : nullptr;
|
2010-10-07 19:19:32 +00:00
|
|
|
}
|
2010-02-18 21:51:00 +00:00
|
|
|
|
2010-10-07 19:19:32 +00:00
|
|
|
// preserveAspectRatio:
|
|
|
|
if (aName == nsGkAtoms::preserveAspectRatio) {
|
2010-12-20 00:45:29 +00:00
|
|
|
SVGAnimatedPreserveAspectRatio *preserveAspectRatio =
|
|
|
|
GetPreserveAspectRatio();
|
|
|
|
return preserveAspectRatio ?
|
2012-07-30 14:20:58 +00:00
|
|
|
preserveAspectRatio->ToSMILAttr(this) : nullptr;
|
2010-10-07 19:19:32 +00:00
|
|
|
}
|
|
|
|
|
2010-12-03 16:40:23 +00:00
|
|
|
// NumberLists:
|
|
|
|
{
|
|
|
|
NumberListAttributesInfo info = GetNumberListInfo();
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < info.mNumberListCount; i++) {
|
2010-12-03 16:40:23 +00:00
|
|
|
if (aName == *info.mNumberListInfo[i].mName) {
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(i <= UCHAR_MAX, "Too many attributes");
|
2012-08-22 15:56:38 +00:00
|
|
|
return info.mNumberLists[i].ToSMILAttr(this, uint8_t(i));
|
2010-12-03 16:40:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-07 19:19:32 +00:00
|
|
|
// LengthLists:
|
|
|
|
{
|
|
|
|
LengthListAttributesInfo info = GetLengthListInfo();
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < info.mLengthListCount; i++) {
|
2010-10-07 19:19:32 +00:00
|
|
|
if (aName == *info.mLengthListInfo[i].mName) {
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(i <= UCHAR_MAX, "Too many attributes");
|
2010-10-07 19:19:32 +00:00
|
|
|
return info.mLengthLists[i].ToSMILAttr(this,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t(i),
|
2010-10-07 19:19:32 +00:00
|
|
|
info.mLengthListInfo[i].mAxis,
|
|
|
|
info.mLengthListInfo[i].mCouldZeroPadList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-02-08 02:28:01 +00:00
|
|
|
|
2011-01-23 17:08:17 +00:00
|
|
|
// PointLists:
|
|
|
|
{
|
|
|
|
if (GetPointListAttrName() == aName) {
|
|
|
|
SVGAnimatedPointList *pointList = GetAnimatedPointList();
|
|
|
|
if (pointList) {
|
|
|
|
return pointList->ToSMILAttr(this);
|
|
|
|
}
|
2010-07-16 21:42:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-23 17:08:17 +00:00
|
|
|
// PathSegLists:
|
|
|
|
{
|
|
|
|
if (GetPathDataAttrName() == aName) {
|
|
|
|
SVGAnimatedPathSegList *segList = GetAnimPathSegList();
|
|
|
|
if (segList) {
|
|
|
|
return segList->ToSMILAttr(this);
|
|
|
|
}
|
2010-12-08 12:15:53 +00:00
|
|
|
}
|
|
|
|
}
|
2012-12-23 08:22:22 +00:00
|
|
|
|
|
|
|
if (aName == nsGkAtoms::_class) {
|
|
|
|
return mClassAttribute.ToSMILAttr(this);
|
|
|
|
}
|
2010-11-08 15:07:00 +00:00
|
|
|
}
|
|
|
|
|
2011-01-23 17:08:17 +00:00
|
|
|
// Strings
|
|
|
|
{
|
|
|
|
StringAttributesInfo info = GetStringInfo();
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < info.mStringCount; i++) {
|
2011-01-23 17:08:17 +00:00
|
|
|
if (aNamespaceID == info.mStringInfo[i].mNamespaceID &&
|
|
|
|
aName == *info.mStringInfo[i].mName) {
|
|
|
|
return info.mStrings[i].ToSMILAttr(this);
|
|
|
|
}
|
2010-03-16 23:17:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2009-01-15 04:38:07 +00:00
|
|
|
}
|
2009-01-22 01:00:27 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGElement::AnimationNeedsResample()
|
|
|
|
{
|
2014-10-03 12:32:26 +00:00
|
|
|
nsIDocument* doc = GetComposedDoc();
|
2010-03-03 07:09:51 +00:00
|
|
|
if (doc && doc->HasAnimationController()) {
|
|
|
|
doc->GetAnimationController()->SetResampleNeeded();
|
2009-01-22 01:00:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGElement::FlushAnimations()
|
|
|
|
{
|
2014-10-03 12:32:26 +00:00
|
|
|
nsIDocument* doc = GetComposedDoc();
|
2010-03-03 07:09:51 +00:00
|
|
|
if (doc && doc->HasAnimationController()) {
|
|
|
|
doc->GetAnimationController()->FlushResampleRequests();
|
2009-01-22 01:00:27 +00:00
|
|
|
}
|
|
|
|
}
|