2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-12-12 10:59:31 +03:00
|
|
|
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2012-12-15 03:58:45 +04:00
|
|
|
#include "mozilla/DebugOnly.h"
|
2016-08-23 07:09:32 +03:00
|
|
|
#include "mozilla/Unused.h"
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2012-12-15 03:58:45 +04:00
|
|
|
#include "nsSVGElement.h"
|
|
|
|
|
2013-01-10 03:02:45 +04:00
|
|
|
#include "mozilla/dom/SVGSVGElement.h"
|
2013-03-02 10:08:42 +04:00
|
|
|
#include "mozilla/dom/SVGTests.h"
|
2013-09-10 21:03:28 +04:00
|
|
|
#include "nsContentUtils.h"
|
2013-03-12 02:05:58 +04:00
|
|
|
#include "nsICSSDeclaration.h"
|
2017-07-04 23:54:30 +03:00
|
|
|
#include "nsIContentInlines.h"
|
2001-12-12 10:59:31 +03:00
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIDOMMutationEvent.h"
|
2014-02-27 14:51:15 +04:00
|
|
|
#include "mozilla/InternalMutationEvent.h"
|
2017-04-01 05:54:41 +03:00
|
|
|
#include "mozAutoDocUpdate.h"
|
2012-07-27 18:03:27 +04:00
|
|
|
#include "nsError.h"
|
2001-12-12 10:59:31 +03:00
|
|
|
#include "nsIPresShell.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2001-12-12 10:59:31 +03:00
|
|
|
#include "nsRuleWalker.h"
|
2010-06-29 02:49:35 +04:00
|
|
|
#include "mozilla/css/Declaration.h"
|
2004-06-08 05:32:29 +04:00
|
|
|
#include "nsCSSProps.h"
|
2010-03-02 23:59:32 +03:00
|
|
|
#include "nsCSSParser.h"
|
2014-03-17 10:56:53 +04:00
|
|
|
#include "mozilla/EventListenerManager.h"
|
2013-02-12 03:25:56 +04:00
|
|
|
#include "nsLayoutUtils.h"
|
2013-04-15 02:56:34 +04:00
|
|
|
#include "nsSVGAnimatedTransformList.h"
|
2006-04-14 19:09:39 +04:00
|
|
|
#include "nsSVGLength2.h"
|
2006-07-28 22:10:48 +04:00
|
|
|
#include "nsSVGNumber2.h"
|
2011-07-01 11:19:52 +04:00
|
|
|
#include "nsSVGNumberPair.h"
|
2007-09-18 16:09:26 +04:00
|
|
|
#include "nsSVGInteger.h"
|
2011-07-01 11:19:52 +04:00
|
|
|
#include "nsSVGIntegerPair.h"
|
2007-10-10 14:07:59 +04:00
|
|
|
#include "nsSVGAngle.h"
|
2007-09-26 13:22:08 +04:00
|
|
|
#include "nsSVGBoolean.h"
|
2007-08-28 03:11:14 +04:00
|
|
|
#include "nsSVGEnum.h"
|
2009-02-03 17:42:24 +03:00
|
|
|
#include "nsSVGViewBox.h"
|
2008-06-14 13:01:02 +04:00
|
|
|
#include "nsSVGString.h"
|
2013-07-07 11:27:51 +04:00
|
|
|
#include "mozilla/dom/SVGAnimatedEnumeration.h"
|
2010-12-03 19:40:23 +03:00
|
|
|
#include "SVGAnimatedNumberList.h"
|
2010-07-17 01:42:12 +04:00
|
|
|
#include "SVGAnimatedLengthList.h"
|
2010-12-08 15:15:53 +03:00
|
|
|
#include "SVGAnimatedPointList.h"
|
2010-11-08 18:07:00 +03:00
|
|
|
#include "SVGAnimatedPathSegList.h"
|
2012-09-22 23:26:05 +04:00
|
|
|
#include "SVGContentUtils.h"
|
2016-12-18 14:11:47 +03:00
|
|
|
#include "SVGGeometryElement.h"
|
2009-01-15 07:38:07 +03:00
|
|
|
#include "nsIFrame.h"
|
2015-04-15 19:47:03 +03:00
|
|
|
#include "nsQueryObject.h"
|
2006-04-14 19:09:39 +04:00
|
|
|
#include <stdarg.h>
|
2010-04-29 03:00:54 +04:00
|
|
|
#include "SVGMotionSMILAttr.h"
|
2012-02-16 03:40:45 +04:00
|
|
|
#include "nsAttrValueOrString.h"
|
2012-08-06 16:02:08 +04:00
|
|
|
#include "nsSMILAnimationController.h"
|
2012-12-23 12:22:58 +04:00
|
|
|
#include "mozilla/dom/SVGElementBinding.h"
|
2016-12-31 12:10:45 +03:00
|
|
|
#include "mozilla/DeclarationBlock.h"
|
|
|
|
#include "mozilla/DeclarationBlockInlines.h"
|
2016-08-23 07:09:32 +03:00
|
|
|
#include "mozilla/Unused.h"
|
2017-02-13 06:21:33 +03:00
|
|
|
#include "mozilla/RestyleManager.h"
|
|
|
|
#include "mozilla/RestyleManagerInlines.h"
|
2001-12-12 10:59:31 +03:00
|
|
|
|
2010-07-26 04:25:38 +04:00
|
|
|
using namespace mozilla;
|
2012-11-15 02:10:08 +04:00
|
|
|
using namespace mozilla::dom;
|
2010-07-26 04:25:38 +04:00
|
|
|
|
2010-04-12 19:53:59 +04: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 12:03:59 +04:00
|
|
|
static_assert(sizeof(void*) == sizeof(nullptr),
|
|
|
|
"nullptr should be the correct size");
|
2010-04-12 19:53:59 +04:00
|
|
|
|
2013-03-28 05:23:10 +04:00
|
|
|
nsresult
|
2014-06-20 06:01:40 +04:00
|
|
|
NS_NewSVGElement(Element **aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
2013-03-28 05:23:10 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsSVGElement> it = new nsSVGElement(aNodeInfo);
|
2013-03-28 05:23:10 +04:00
|
|
|
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 19:53:59 +04:00
|
|
|
|
2007-08-28 03:11:14 +04:00
|
|
|
nsSVGEnumMapping nsSVGElement::sSVGUnitTypesMap[] = {
|
2013-02-18 06:14:02 +04:00
|
|
|
{&nsGkAtoms::userSpaceOnUse, SVG_UNIT_TYPE_USERSPACEONUSE},
|
|
|
|
{&nsGkAtoms::objectBoundingBox, SVG_UNIT_TYPE_OBJECTBOUNDINGBOX},
|
2012-07-30 18:20:58 +04:00
|
|
|
{nullptr, 0}
|
2007-08-28 03:11:14 +04:00
|
|
|
};
|
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
nsSVGElement::nsSVGElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2011-09-30 13:25:34 +04:00
|
|
|
: nsSVGElementBase(aNodeInfo)
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2006-04-14 19:09:39 +04:00
|
|
|
}
|
|
|
|
|
2016-12-31 12:10:45 +03:00
|
|
|
nsSVGElement::~nsSVGElement()
|
|
|
|
{
|
2017-02-23 04:19:04 +03:00
|
|
|
OwnerDoc()->UnscheduleSVGForPresAttrEvaluation(this);
|
2016-12-31 12:10:45 +03:00
|
|
|
}
|
|
|
|
|
2012-12-23 12:22:58 +04: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 17:13:33 +03:00
|
|
|
nsSVGElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2012-12-23 12:22:58 +04: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 17:13:33 +03:00
|
|
|
return SVGElementBinding::Wrap(aCx, this, aGivenProto);
|
2012-12-23 12:22:58 +04:00
|
|
|
}
|
|
|
|
|
2012-12-23 12:22:22 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-05-30 11:36:53 +04:00
|
|
|
nsSVGElement::GetSVGClassName(nsISupports** aClassName)
|
2012-12-23 12:22:22 +04:00
|
|
|
{
|
2014-03-15 23:00:15 +04:00
|
|
|
*aClassName = ClassName().take();
|
2012-12-23 12:22:58 +04:00
|
|
|
return NS_OK;
|
2012-12-23 12:22:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGElement::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
|
|
|
|
{
|
2013-01-11 12:42:59 +04:00
|
|
|
NS_ADDREF(*aStyle = Style());
|
|
|
|
return NS_OK;
|
2012-12-23 12:22:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGElement::DidAnimateClass()
|
|
|
|
{
|
2017-06-27 20:55:03 +03:00
|
|
|
// For Servo, snapshot the element before we change it.
|
|
|
|
nsIPresShell* shell = OwnerDoc()->GetShell();
|
|
|
|
if (shell) {
|
|
|
|
nsPresContext* presContext = shell->GetPresContext();
|
|
|
|
if (presContext && presContext->RestyleManager()->IsServo()) {
|
|
|
|
presContext->RestyleManager()
|
|
|
|
->AsServo()
|
|
|
|
->ClassAttributeWillBeChangedBySMIL(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-23 12:22:22 +04:00
|
|
|
nsAutoString src;
|
|
|
|
mClassAttribute.GetAnimValue(src, this);
|
|
|
|
if (!mClassAnimAttr) {
|
|
|
|
mClassAnimAttr = new nsAttrValue();
|
|
|
|
}
|
|
|
|
mClassAnimAttr->ParseAtomArray(src);
|
|
|
|
|
|
|
|
if (shell) {
|
|
|
|
shell->RestyleForAnimation(this, eRestyle_Self);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-14 19:09:39 +04: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 22:10:48 +04:00
|
|
|
LengthAttributesInfo lengthInfo = GetLengthInfo();
|
2006-04-14 19:09:39 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t i;
|
2006-07-29 01:03:00 +04:00
|
|
|
for (i = 0; i < lengthInfo.mLengthCount; i++) {
|
2007-11-22 11:54:31 +03:00
|
|
|
lengthInfo.Reset(i);
|
2006-07-28 22:10:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NumberAttributesInfo numberInfo = GetNumberInfo();
|
|
|
|
|
2006-07-29 01:03:00 +04:00
|
|
|
for (i = 0; i < numberInfo.mNumberCount; i++) {
|
2007-11-22 11:54:31 +03:00
|
|
|
numberInfo.Reset(i);
|
2006-04-14 19:09:39 +04:00
|
|
|
}
|
2004-05-19 00:58:12 +04:00
|
|
|
|
2011-07-01 11:19:52 +04:00
|
|
|
NumberPairAttributesInfo numberPairInfo = GetNumberPairInfo();
|
|
|
|
|
|
|
|
for (i = 0; i < numberPairInfo.mNumberPairCount; i++) {
|
|
|
|
numberPairInfo.Reset(i);
|
|
|
|
}
|
|
|
|
|
2007-09-18 16:09:26 +04:00
|
|
|
IntegerAttributesInfo integerInfo = GetIntegerInfo();
|
|
|
|
|
|
|
|
for (i = 0; i < integerInfo.mIntegerCount; i++) {
|
2007-11-22 11:54:31 +03:00
|
|
|
integerInfo.Reset(i);
|
2007-09-18 16:09:26 +04:00
|
|
|
}
|
|
|
|
|
2011-07-01 11:19:52 +04:00
|
|
|
IntegerPairAttributesInfo integerPairInfo = GetIntegerPairInfo();
|
|
|
|
|
|
|
|
for (i = 0; i < integerPairInfo.mIntegerPairCount; i++) {
|
|
|
|
integerPairInfo.Reset(i);
|
|
|
|
}
|
|
|
|
|
2007-10-10 14:07:59 +04:00
|
|
|
AngleAttributesInfo angleInfo = GetAngleInfo();
|
|
|
|
|
|
|
|
for (i = 0; i < angleInfo.mAngleCount; i++) {
|
2007-11-22 11:54:31 +03:00
|
|
|
angleInfo.Reset(i);
|
2007-10-10 14:07:59 +04:00
|
|
|
}
|
|
|
|
|
2007-09-26 13:22:08 +04:00
|
|
|
BooleanAttributesInfo booleanInfo = GetBooleanInfo();
|
|
|
|
|
|
|
|
for (i = 0; i < booleanInfo.mBooleanCount; i++) {
|
2007-11-22 11:54:31 +03:00
|
|
|
booleanInfo.Reset(i);
|
2007-09-26 13:22:08 +04:00
|
|
|
}
|
|
|
|
|
2007-08-28 03:11:14 +04:00
|
|
|
EnumAttributesInfo enumInfo = GetEnumInfo();
|
|
|
|
|
|
|
|
for (i = 0; i < enumInfo.mEnumCount; i++) {
|
2007-11-22 11:54:31 +03:00
|
|
|
enumInfo.Reset(i);
|
2007-08-28 03:11:14 +04:00
|
|
|
}
|
|
|
|
|
2009-02-03 17:42:24 +03:00
|
|
|
nsSVGViewBox *viewBox = GetViewBox();
|
|
|
|
|
|
|
|
if (viewBox) {
|
|
|
|
viewBox->Init();
|
|
|
|
}
|
|
|
|
|
2010-12-20 03:45:29 +03:00
|
|
|
SVGAnimatedPreserveAspectRatio *preserveAspectRatio =
|
2009-01-05 04:19:38 +03:00
|
|
|
GetPreserveAspectRatio();
|
|
|
|
|
|
|
|
if (preserveAspectRatio) {
|
|
|
|
preserveAspectRatio->Init();
|
|
|
|
}
|
|
|
|
|
2010-07-17 01:42:12 +04:00
|
|
|
LengthListAttributesInfo lengthListInfo = GetLengthListInfo();
|
|
|
|
|
|
|
|
for (i = 0; i < lengthListInfo.mLengthListCount; i++) {
|
|
|
|
lengthListInfo.Reset(i);
|
|
|
|
}
|
|
|
|
|
2010-12-03 19:40:23 +03:00
|
|
|
NumberListAttributesInfo numberListInfo = GetNumberListInfo();
|
|
|
|
|
|
|
|
for (i = 0; i < numberListInfo.mNumberListCount; i++) {
|
|
|
|
numberListInfo.Reset(i);
|
|
|
|
}
|
|
|
|
|
2010-12-08 15:15:53 +03: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 18:07:00 +03:00
|
|
|
// (an empty list).
|
|
|
|
|
2008-06-14 13:01:02 +04:00
|
|
|
StringAttributesInfo stringInfo = GetStringInfo();
|
|
|
|
|
|
|
|
for (i = 0; i < stringInfo.mStringCount; i++) {
|
|
|
|
stringInfo.Reset(i);
|
|
|
|
}
|
|
|
|
|
2006-04-14 19:09:39 +04:00
|
|
|
return NS_OK;
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(nsSVGElement, nsSVGElementBase,
|
|
|
|
nsIDOMNode, nsIDOMElement,
|
|
|
|
nsIDOMSVGElement)
|
2001-12-12 10:59:31 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
2013-03-28 05:23:10 +04:00
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods
|
|
|
|
|
2008-01-01 13:51:40 +03:00
|
|
|
nsresult
|
|
|
|
nsSVGElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
2008-07-13 15:30:48 +04:00
|
|
|
nsIContent* aBindingParent,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aCompileEventHandlers)
|
2008-01-01 13:51:40 +03:00
|
|
|
{
|
|
|
|
nsresult rv = nsSVGElementBase::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2011-04-08 06:29:50 +04:00
|
|
|
if (!MayHaveStyle()) {
|
2008-01-01 13:51:40 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
const nsAttrValue* oldVal = mAttrsAndChildren.GetAttr(nsGkAtoms::style);
|
|
|
|
|
2016-10-18 07:29:03 +03:00
|
|
|
if (oldVal && oldVal->Type() == nsAttrValue::eCSSDeclaration) {
|
2008-01-01 13:51:40 +03:00
|
|
|
// we need to force a reparse because the baseURI of the document
|
2010-02-24 07:37:46 +03: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 13:51:40 +03:00
|
|
|
nsAttrValue attrValue;
|
|
|
|
nsAutoString stringValue;
|
|
|
|
oldVal->ToString(stringValue);
|
2008-02-19 20:52:00 +03:00
|
|
|
// Force in data doc, since we already have a style rule
|
2011-10-17 18:59:28 +04:00
|
|
|
ParseStyleAttribute(stringValue, attrValue, true);
|
2015-11-09 10:57:16 +03:00
|
|
|
// Don't bother going through SetInlineStyleDeclaration; we don't
|
|
|
|
// want to fire off mutation events or document notifications anyway
|
2017-05-19 00:09:01 +03:00
|
|
|
bool oldValueSet;
|
|
|
|
rv = mAttrsAndChildren.SetAndSwapAttr(nsGkAtoms::style, attrValue,
|
|
|
|
&oldValueSet);
|
2008-01-01 13:51:40 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-01-10 02:54:21 +03:00
|
|
|
nsresult
|
2017-10-03 01:05:19 +03:00
|
|
|
nsSVGElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
|
2017-05-19 00:09:01 +03:00
|
|
|
const nsAttrValue* aValue,
|
|
|
|
const nsAttrValue* aOldValue, bool aNotify)
|
2012-02-14 06:00:56 +04:00
|
|
|
{
|
2012-02-16 03:40:45 +04: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-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!mAttrsAndChildren.HasMappedAttrs(),
|
|
|
|
"Unexpected use of nsMappedAttributes within SVG");
|
2012-02-16 03:40:45 +04:00
|
|
|
|
2004-03-09 11:44:53 +03:00
|
|
|
// If this is an svg presentation attribute we need to map it into
|
2016-12-31 12:10:45 +03:00
|
|
|
// the content declaration block.
|
2004-03-09 11:44:53 +03:00
|
|
|
// XXX For some reason incremental mapping doesn't work, so for now
|
2016-12-31 12:10:45 +03:00
|
|
|
// just delete the style rule and lazily reconstruct it as needed).
|
2005-10-28 06:59:38 +04:00
|
|
|
if (aNamespaceID == kNameSpaceID_None && IsAttributeMapped(aName)) {
|
2016-12-31 12:10:45 +03:00
|
|
|
mContentDeclarationBlock = nullptr;
|
2017-02-23 04:19:04 +03:00
|
|
|
if (OwnerDoc()->GetStyleBackendType() == StyleBackendType::Servo) {
|
2017-02-23 04:19:04 +03:00
|
|
|
OwnerDoc()->ScheduleSVGForPresAttrEvaluation(this);
|
2017-02-23 04:19:04 +03:00
|
|
|
}
|
2005-10-28 06:59:38 +04:00
|
|
|
}
|
|
|
|
|
2013-01-03 00:24:07 +04:00
|
|
|
if (IsEventAttributeName(aName) && aValue) {
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(aValue->Type() == nsAttrValue::eString,
|
|
|
|
"Expected string value for script body");
|
2012-08-30 20:25:10 +04:00
|
|
|
nsresult rv = SetEventHandler(GetEventNameForAttr(aName),
|
|
|
|
aValue->GetStringValue());
|
2005-10-28 06:59:38 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
2017-05-19 00:09:01 +03:00
|
|
|
return nsSVGElementBase::AfterSetAttr(aNamespaceID, aName, aValue, aOldValue,
|
|
|
|
aNotify);
|
2005-10-28 06:59:38 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::ParseAttribute(int32_t aNamespaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute,
|
2005-10-28 06:59:38 +04:00
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
|
|
|
{
|
2008-12-28 01:52:30 +03:00
|
|
|
nsresult rv = NS_OK;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool foundMatch = false;
|
2012-02-16 03:40:44 +04:00
|
|
|
bool didSetResult = false;
|
|
|
|
|
2006-04-14 19:09:39 +04:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
|
|
|
// Check for nsSVGLength2 attribute
|
2006-07-28 22:10:48 +04:00
|
|
|
LengthAttributesInfo lengthInfo = GetLengthInfo();
|
2007-10-10 14:07:59 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t i;
|
2008-06-14 13:01:02 +04:00
|
|
|
for (i = 0; i < lengthInfo.mLengthCount; i++) {
|
2006-07-28 22:10:48 +04:00
|
|
|
if (aAttribute == *lengthInfo.mLengthInfo[i].mName) {
|
2011-10-17 18:59:28 +04:00
|
|
|
rv = lengthInfo.mLengths[i].SetBaseValueString(aValue, this, false);
|
2007-11-22 11:54:31 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
lengthInfo.Reset(i);
|
2012-02-16 03:40:45 +04:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(lengthInfo.mLengths[i], &aValue);
|
|
|
|
didSetResult = true;
|
2007-11-22 11:54:31 +03:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
foundMatch = true;
|
2008-06-14 13:01:02 +04:00
|
|
|
break;
|
2006-07-28 22:10:48 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-17 01:42:12 +04: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-16 03:40:45 +04:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(lengthListInfo.mLengthLists[i].GetBaseValue(),
|
|
|
|
&aValue);
|
|
|
|
didSetResult = true;
|
2010-07-17 01:42:12 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
foundMatch = true;
|
2010-07-17 01:42:12 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-03 19:40:23 +03: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-16 03:40:46 +04:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(numberListInfo.mNumberLists[i].GetBaseValue(),
|
|
|
|
&aValue);
|
|
|
|
didSetResult = true;
|
2010-12-03 19:40:23 +03:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
foundMatch = true;
|
2010-12-03 19:40:23 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-08 15:15:53 +03:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for SVGAnimatedPointList attribute
|
|
|
|
if (GetPointListAttrName() == aAttribute) {
|
|
|
|
SVGAnimatedPointList* pointList = GetAnimatedPointList();
|
|
|
|
if (pointList) {
|
2012-02-16 03:40:46 +04: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 18:59:28 +04:00
|
|
|
foundMatch = true;
|
2010-12-08 15:15:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-08 18:07:00 +03:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for SVGAnimatedPathSegList attribute
|
|
|
|
if (GetPathDataAttrName() == aAttribute) {
|
|
|
|
SVGAnimatedPathSegList* segList = GetAnimPathSegList();
|
|
|
|
if (segList) {
|
2012-02-16 03:40:46 +04: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 18:59:28 +04:00
|
|
|
foundMatch = true;
|
2010-11-08 18:07:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-14 13:01:02 +04: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 19:25:07 +04:00
|
|
|
rv = numberInfo.mNumbers[i].SetBaseValueString(aValue, this);
|
2008-06-14 13:01:02 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
numberInfo.Reset(i);
|
2012-02-16 03:40:45 +04:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(numberInfo.mNumbers[i].GetBaseValue(), &aValue);
|
|
|
|
didSetResult = true;
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
foundMatch = true;
|
2008-06-14 13:01:02 +04:00
|
|
|
break;
|
2007-11-22 11:54:31 +03:00
|
|
|
}
|
2006-04-14 19:09:39 +04:00
|
|
|
}
|
|
|
|
}
|
2007-08-28 03:11:14 +04:00
|
|
|
|
2011-07-01 11:19:52 +04: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 19:25:07 +04:00
|
|
|
rv = numberPairInfo.mNumberPairs[i].SetBaseValueString(aValue, this);
|
2011-07-01 11:19:52 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
numberPairInfo.Reset(i);
|
2012-02-16 03:40:45 +04:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(numberPairInfo.mNumberPairs[i], &aValue);
|
|
|
|
didSetResult = true;
|
2011-07-01 11:19:52 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
foundMatch = true;
|
2011-07-01 11:19:52 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-14 13:01:02 +04: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 19:25:07 +04:00
|
|
|
rv = integerInfo.mIntegers[i].SetBaseValueString(aValue, this);
|
2008-06-14 13:01:02 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
integerInfo.Reset(i);
|
2012-02-16 03:40:45 +04:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(integerInfo.mIntegers[i].GetBaseValue(), &aValue);
|
|
|
|
didSetResult = true;
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
foundMatch = true;
|
2008-06-14 13:01:02 +04:00
|
|
|
break;
|
2007-11-22 11:54:31 +03:00
|
|
|
}
|
2007-09-18 16:09:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-01 11:19:52 +04: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-16 03:40:45 +04:00
|
|
|
rv =
|
|
|
|
integerPairInfo.mIntegerPairs[i].SetBaseValueString(aValue, this);
|
2011-07-01 11:19:52 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
integerPairInfo.Reset(i);
|
2012-02-16 03:40:45 +04:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(integerPairInfo.mIntegerPairs[i], &aValue);
|
|
|
|
didSetResult = true;
|
2011-07-01 11:19:52 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
foundMatch = true;
|
2011-07-01 11:19:52 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-14 13:01:02 +04: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 18:59:28 +04:00
|
|
|
rv = angleInfo.mAngles[i].SetBaseValueString(aValue, this, false);
|
2008-06-14 13:01:02 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
angleInfo.Reset(i);
|
2012-02-16 03:40:45 +04:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(angleInfo.mAngles[i], &aValue);
|
|
|
|
didSetResult = true;
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
foundMatch = true;
|
2008-06-14 13:01:02 +04:00
|
|
|
break;
|
2007-11-22 11:54:31 +03:00
|
|
|
}
|
2007-10-10 14:07:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-14 13:01:02 +04:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for nsSVGBoolean attribute
|
|
|
|
BooleanAttributesInfo booleanInfo = GetBooleanInfo();
|
|
|
|
for (i = 0; i < booleanInfo.mBooleanCount; i++) {
|
|
|
|
if (aAttribute == *booleanInfo.mBooleanInfo[i].mName) {
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom *valAtom = NS_GetStaticAtom(aValue);
|
2012-08-24 11:29:09 +04:00
|
|
|
rv = valAtom ? booleanInfo.mBooleans[i].SetBaseValueAtom(valAtom, this) :
|
|
|
|
NS_ERROR_DOM_SYNTAX_ERR;
|
2008-06-14 13:01:02 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
booleanInfo.Reset(i);
|
2012-02-16 03:40:45 +04:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(valAtom);
|
|
|
|
didSetResult = true;
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
foundMatch = true;
|
2008-06-14 13:01:02 +04:00
|
|
|
break;
|
2007-11-22 11:54:31 +03:00
|
|
|
}
|
2007-09-26 13:22:08 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-14 13:01:02 +04:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for nsSVGEnum attribute
|
|
|
|
EnumAttributesInfo enumInfo = GetEnumInfo();
|
|
|
|
for (i = 0; i < enumInfo.mEnumCount; i++) {
|
|
|
|
if (aAttribute == *enumInfo.mEnumInfo[i].mName) {
|
2017-10-03 01:05:19 +03:00
|
|
|
RefPtr<nsAtom> valAtom = NS_Atomize(aValue);
|
2012-02-16 03:40:44 +04:00
|
|
|
rv = enumInfo.mEnums[i].SetBaseValueAtom(valAtom, this);
|
2008-06-14 13:01:02 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
enumInfo.Reset(i);
|
2012-02-16 03:40:44 +04:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(valAtom);
|
|
|
|
didSetResult = true;
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
foundMatch = true;
|
2008-06-14 13:01:02 +04:00
|
|
|
break;
|
2007-11-22 11:54:31 +03:00
|
|
|
}
|
2007-08-28 03:11:14 +04:00
|
|
|
}
|
|
|
|
}
|
2009-01-05 04:19:38 +03:00
|
|
|
|
2011-12-31 13:44:03 +04:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for conditional processing attributes
|
2013-03-28 05:23:09 +04:00
|
|
|
nsCOMPtr<SVGTests> tests = do_QueryObject(this);
|
2011-12-31 13:44:03 +04: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-16 03:40:46 +04:00
|
|
|
rv = stringListInfo.mStringLists[i].SetValue(aValue);
|
2011-12-31 13:44:03 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
stringListInfo.Reset(i);
|
2012-02-16 03:40:46 +04:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(stringListInfo.mStringLists[i], &aValue);
|
|
|
|
didSetResult = true;
|
2011-12-31 13:44:03 +04:00
|
|
|
}
|
|
|
|
foundMatch = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-03 17:42:24 +03:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for nsSVGViewBox attribute
|
|
|
|
if (aAttribute == nsGkAtoms::viewBox) {
|
|
|
|
nsSVGViewBox* viewBox = GetViewBox();
|
|
|
|
if (viewBox) {
|
2012-08-25 21:02:34 +04:00
|
|
|
rv = viewBox->SetBaseValueString(aValue, this, false);
|
2009-02-03 17:42:24 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
viewBox->Init();
|
2012-02-16 03:40:46 +04:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(*viewBox, &aValue);
|
|
|
|
didSetResult = true;
|
2009-02-03 17:42:24 +03:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
foundMatch = true;
|
2009-02-03 17:42:24 +03:00
|
|
|
}
|
2010-12-20 03:45:29 +03:00
|
|
|
// Check for SVGAnimatedPreserveAspectRatio attribute
|
2009-02-03 17:42:24 +03:00
|
|
|
} else if (aAttribute == nsGkAtoms::preserveAspectRatio) {
|
2010-12-20 03:45:29 +03:00
|
|
|
SVGAnimatedPreserveAspectRatio *preserveAspectRatio =
|
2009-02-03 17:42:24 +03:00
|
|
|
GetPreserveAspectRatio();
|
|
|
|
if (preserveAspectRatio) {
|
2012-08-25 21:02:34 +04:00
|
|
|
rv = preserveAspectRatio->SetBaseValueString(aValue, this, false);
|
2009-02-03 17:42:24 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
preserveAspectRatio->Init();
|
2012-02-16 03:40:46 +04:00
|
|
|
} else {
|
|
|
|
aResult.SetTo(*preserveAspectRatio, &aValue);
|
|
|
|
didSetResult = true;
|
2009-02-03 17:42:24 +03:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
foundMatch = true;
|
2009-01-05 04:19:38 +03:00
|
|
|
}
|
2011-09-26 01:04:31 +04:00
|
|
|
// Check for SVGAnimatedTransformList attribute
|
|
|
|
} else if (GetTransformListAttrName() == aAttribute) {
|
2012-07-30 04:35:26 +04:00
|
|
|
// The transform attribute is being set, so we must ensure that the
|
2013-04-15 02:56:34 +04:00
|
|
|
// nsSVGAnimatedTransformList is/has been allocated:
|
|
|
|
nsSVGAnimatedTransformList *transformList =
|
2012-07-30 04:35:26 +04:00
|
|
|
GetAnimatedTransformList(DO_ALLOCATE);
|
|
|
|
rv = transformList->SetBaseValueString(aValue);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
transformList->ClearBaseValue();
|
|
|
|
} else {
|
|
|
|
aResult.SetTo(transformList->GetBaseValue(), &aValue);
|
|
|
|
didSetResult = true;
|
2011-09-26 01:04:31 +04:00
|
|
|
}
|
2012-07-30 04:35:26 +04:00
|
|
|
foundMatch = true;
|
2016-05-24 07:22:17 +03:00
|
|
|
} else if (aAttribute == nsGkAtoms::tabindex) {
|
|
|
|
didSetResult = aResult.ParseIntValue(aValue);
|
|
|
|
foundMatch = true;
|
2009-01-05 04:19:38 +03:00
|
|
|
}
|
|
|
|
}
|
2012-12-23 12:22:22 +04:00
|
|
|
|
|
|
|
if (aAttribute == nsGkAtoms::_class) {
|
|
|
|
mClassAttribute.SetBaseValue(aValue, this, false);
|
|
|
|
aResult.ParseAtomArray(aValue);
|
|
|
|
return true;
|
|
|
|
}
|
2004-07-22 20:38:05 +04:00
|
|
|
}
|
2005-10-28 06:59:38 +04:00
|
|
|
|
2008-06-14 13:01:02 +04:00
|
|
|
if (!foundMatch) {
|
|
|
|
// Check for nsSVGString attribute
|
|
|
|
StringAttributesInfo stringInfo = GetStringInfo();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < stringInfo.mStringCount; i++) {
|
2008-06-14 13:01:02 +04:00
|
|
|
if (aNamespaceID == stringInfo.mStringInfo[i].mNamespaceID &&
|
|
|
|
aAttribute == *stringInfo.mStringInfo[i].mName) {
|
2011-10-17 18:59:28 +04:00
|
|
|
stringInfo.mStrings[i].SetBaseValue(aValue, this, false);
|
|
|
|
foundMatch = true;
|
2008-06-14 13:01:02 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-28 01:52:30 +03:00
|
|
|
if (foundMatch) {
|
|
|
|
if (NS_FAILED(rv)) {
|
2011-10-18 14:53:36 +04:00
|
|
|
ReportAttributeParseFailure(OwnerDoc(), aAttribute, aValue);
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2008-12-28 01:52:30 +03:00
|
|
|
}
|
2012-02-16 03:40:44 +04:00
|
|
|
if (!didSetResult) {
|
|
|
|
aResult.SetTo(aValue);
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2008-12-28 01:52:30 +03:00
|
|
|
}
|
|
|
|
|
2007-08-06 19:27:19 +04:00
|
|
|
return nsSVGElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
2005-11-29 19:37:15 +03:00
|
|
|
aResult);
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2011-10-08 10:32:44 +04:00
|
|
|
void
|
2017-10-03 01:05:19 +03:00
|
|
|
nsSVGElement::UnsetAttrInternal(int32_t aNamespaceID, nsAtom* aName,
|
2011-10-08 10:32:44 +04:00
|
|
|
bool aNotify)
|
2004-07-22 20:38:05 +04:00
|
|
|
{
|
2010-02-24 07:37:47 +03:00
|
|
|
// XXXbz there's a bunch of redundancy here with AfterSetAttr.
|
|
|
|
// Maybe consolidate?
|
|
|
|
|
2006-04-14 19:09:39 +04:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
2016-12-31 12:10:45 +03:00
|
|
|
// If this is an svg presentation attribute, remove declaration block to
|
|
|
|
// force an update
|
|
|
|
if (IsAttributeMapped(aName)) {
|
|
|
|
mContentDeclarationBlock = nullptr;
|
|
|
|
}
|
2006-04-14 19:09:39 +04:00
|
|
|
|
2013-01-03 00:24:07 +04:00
|
|
|
if (IsEventAttributeName(aName)) {
|
2014-03-17 10:56:53 +04:00
|
|
|
EventListenerManager* manager = GetExistingListenerManager();
|
2006-04-14 19:09:39 +04:00
|
|
|
if (manager) {
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* eventName = GetEventNameForAttr(aName);
|
2013-08-16 14:06:24 +04:00
|
|
|
manager->RemoveEventHandler(eventName, EmptyString());
|
2006-04-14 19:09:39 +04:00
|
|
|
}
|
2011-10-08 10:32:44 +04:00
|
|
|
return;
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2011-01-23 20:08:17 +03:00
|
|
|
// Check if this is a length attribute going away
|
|
|
|
LengthAttributesInfo lenInfo = GetLengthInfo();
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < lenInfo.mLengthCount; i++) {
|
2011-01-23 20:08:17 +03:00
|
|
|
if (aName == *lenInfo.mLengthInfo[i].mName) {
|
2012-02-16 03:40:45 +04:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-01-23 20:08:17 +03:00
|
|
|
lenInfo.Reset(i);
|
2011-10-08 10:32:44 +04:00
|
|
|
return;
|
2006-04-14 19:09:39 +04:00
|
|
|
}
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
|
|
|
|
2011-01-23 20:08:17 +03:00
|
|
|
// Check if this is a length list attribute going away
|
|
|
|
LengthListAttributesInfo lengthListInfo = GetLengthListInfo();
|
2010-07-17 01:42:12 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < lengthListInfo.mLengthListCount; i++) {
|
2011-01-23 20:08:17 +03:00
|
|
|
if (aName == *lengthListInfo.mLengthListInfo[i].mName) {
|
2012-02-16 03:40:45 +04:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-01-23 20:08:17 +03:00
|
|
|
lengthListInfo.Reset(i);
|
2011-10-08 10:32:44 +04:00
|
|
|
return;
|
2010-07-17 01:42:12 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-23 20:08:17 +03:00
|
|
|
// Check if this is a number list attribute going away
|
|
|
|
NumberListAttributesInfo numberListInfo = GetNumberListInfo();
|
2010-12-03 19:40:23 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < numberListInfo.mNumberListCount; i++) {
|
2011-01-23 20:08:17 +03:00
|
|
|
if (aName == *numberListInfo.mNumberListInfo[i].mName) {
|
2012-02-16 03:40:46 +04:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-01-23 20:08:17 +03:00
|
|
|
numberListInfo.Reset(i);
|
2011-10-08 10:32:44 +04:00
|
|
|
return;
|
2010-12-03 19:40:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-23 20:08:17 +03:00
|
|
|
// Check if this is a point list attribute going away
|
|
|
|
if (GetPointListAttrName() == aName) {
|
|
|
|
SVGAnimatedPointList *pointList = GetAnimatedPointList();
|
|
|
|
if (pointList) {
|
2012-02-16 03:40:46 +04:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-01-23 20:08:17 +03:00
|
|
|
pointList->ClearBaseValue();
|
2011-10-08 10:32:44 +04:00
|
|
|
return;
|
2010-12-08 15:15:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-23 20:08:17 +03:00
|
|
|
// Check if this is a path segment list attribute going away
|
|
|
|
if (GetPathDataAttrName() == aName) {
|
|
|
|
SVGAnimatedPathSegList *segList = GetAnimPathSegList();
|
|
|
|
if (segList) {
|
2012-02-16 03:40:46 +04:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-01-23 20:08:17 +03:00
|
|
|
segList->ClearBaseValue();
|
2011-10-08 10:32:44 +04:00
|
|
|
return;
|
2010-11-08 18:07:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-23 20:08:17 +03:00
|
|
|
// Check if this is a number attribute going away
|
|
|
|
NumberAttributesInfo numInfo = GetNumberInfo();
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < numInfo.mNumberCount; i++) {
|
2011-01-23 20:08:17 +03:00
|
|
|
if (aName == *numInfo.mNumberInfo[i].mName) {
|
|
|
|
numInfo.Reset(i);
|
2011-10-08 10:32:44 +04:00
|
|
|
return;
|
2006-07-28 22:10:48 +04:00
|
|
|
}
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
2007-08-28 03:11:14 +04:00
|
|
|
|
2011-07-01 11:19:52 +04:00
|
|
|
// Check if this is a number pair attribute going away
|
|
|
|
NumberPairAttributesInfo numPairInfo = GetNumberPairInfo();
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < numPairInfo.mNumberPairCount; i++) {
|
2011-07-01 11:19:52 +04:00
|
|
|
if (aName == *numPairInfo.mNumberPairInfo[i].mName) {
|
2012-02-16 03:40:45 +04:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-07-01 11:19:52 +04:00
|
|
|
numPairInfo.Reset(i);
|
2011-10-08 10:32:44 +04:00
|
|
|
return;
|
2011-07-01 11:19:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-23 20:08:17 +03:00
|
|
|
// Check if this is an integer attribute going away
|
|
|
|
IntegerAttributesInfo intInfo = GetIntegerInfo();
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < intInfo.mIntegerCount; i++) {
|
2011-01-23 20:08:17 +03:00
|
|
|
if (aName == *intInfo.mIntegerInfo[i].mName) {
|
|
|
|
intInfo.Reset(i);
|
2011-10-08 10:32:44 +04:00
|
|
|
return;
|
2007-09-18 16:09:26 +04:00
|
|
|
}
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
2007-09-18 16:09:26 +04:00
|
|
|
|
2011-07-01 11:19:52 +04:00
|
|
|
// Check if this is an integer pair attribute going away
|
|
|
|
IntegerPairAttributesInfo intPairInfo = GetIntegerPairInfo();
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < intPairInfo.mIntegerPairCount; i++) {
|
2011-07-01 11:19:52 +04:00
|
|
|
if (aName == *intPairInfo.mIntegerPairInfo[i].mName) {
|
2012-02-16 03:40:45 +04:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-07-01 11:19:52 +04:00
|
|
|
intPairInfo.Reset(i);
|
2011-10-08 10:32:44 +04:00
|
|
|
return;
|
2011-07-01 11:19:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-23 20:08:17 +03:00
|
|
|
// Check if this is an angle attribute going away
|
|
|
|
AngleAttributesInfo angleInfo = GetAngleInfo();
|
2007-10-10 14:07:59 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < angleInfo.mAngleCount; i++) {
|
2011-01-23 20:08:17 +03:00
|
|
|
if (aName == *angleInfo.mAngleInfo[i].mName) {
|
2012-02-16 03:40:45 +04:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-01-23 20:08:17 +03:00
|
|
|
angleInfo.Reset(i);
|
2011-10-08 10:32:44 +04:00
|
|
|
return;
|
2007-10-10 14:07:59 +04:00
|
|
|
}
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
2007-10-10 14:07:59 +04:00
|
|
|
|
2011-01-23 20:08:17 +03:00
|
|
|
// Check if this is a boolean attribute going away
|
|
|
|
BooleanAttributesInfo boolInfo = GetBooleanInfo();
|
2007-09-26 13:22:08 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < boolInfo.mBooleanCount; i++) {
|
2011-01-23 20:08:17 +03:00
|
|
|
if (aName == *boolInfo.mBooleanInfo[i].mName) {
|
|
|
|
boolInfo.Reset(i);
|
2011-10-08 10:32:44 +04:00
|
|
|
return;
|
2007-09-26 13:22:08 +04:00
|
|
|
}
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
2007-09-26 13:22:08 +04:00
|
|
|
|
2011-01-23 20:08:17 +03:00
|
|
|
// Check if this is an enum attribute going away
|
|
|
|
EnumAttributesInfo enumInfo = GetEnumInfo();
|
2007-08-28 03:11:14 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < enumInfo.mEnumCount; i++) {
|
2011-01-23 20:08:17 +03:00
|
|
|
if (aName == *enumInfo.mEnumInfo[i].mName) {
|
|
|
|
enumInfo.Reset(i);
|
2011-10-08 10:32:44 +04:00
|
|
|
return;
|
2007-08-28 03:11:14 +04:00
|
|
|
}
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
2009-01-05 04:19:38 +03:00
|
|
|
|
2011-01-23 20:08:17 +03:00
|
|
|
// Check if this is a nsViewBox attribute going away
|
|
|
|
if (aName == nsGkAtoms::viewBox) {
|
|
|
|
nsSVGViewBox* viewBox = GetViewBox();
|
|
|
|
if (viewBox) {
|
2012-02-16 03:40:46 +04:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-01-23 20:08:17 +03:00
|
|
|
viewBox->Init();
|
2011-10-08 10:32:44 +04:00
|
|
|
return;
|
2009-01-05 04:19:38 +03:00
|
|
|
}
|
|
|
|
}
|
2011-10-08 10:32:44 +04:00
|
|
|
|
2011-01-23 20:08:17 +03:00
|
|
|
// Check if this is a preserveAspectRatio attribute going away
|
|
|
|
if (aName == nsGkAtoms::preserveAspectRatio) {
|
|
|
|
SVGAnimatedPreserveAspectRatio *preserveAspectRatio =
|
|
|
|
GetPreserveAspectRatio();
|
|
|
|
if (preserveAspectRatio) {
|
2012-02-16 03:40:46 +04:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-01-23 20:08:17 +03:00
|
|
|
preserveAspectRatio->Init();
|
2011-10-08 10:32:44 +04:00
|
|
|
return;
|
2011-01-23 20:08:17 +03:00
|
|
|
}
|
|
|
|
}
|
2011-09-26 01:04:31 +04:00
|
|
|
|
|
|
|
// Check if this is a transform list attribute going away
|
|
|
|
if (GetTransformListAttrName() == aName) {
|
2013-04-15 02:56:34 +04:00
|
|
|
nsSVGAnimatedTransformList *transformList = GetAnimatedTransformList();
|
2011-09-26 01:04:31 +04:00
|
|
|
if (transformList) {
|
2012-02-16 03:40:46 +04:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-09-26 01:04:31 +04:00
|
|
|
transformList->ClearBaseValue();
|
2011-10-08 10:32:44 +04:00
|
|
|
return;
|
2011-09-26 01:04:31 +04:00
|
|
|
}
|
|
|
|
}
|
2011-12-31 13:44:03 +04:00
|
|
|
|
|
|
|
// Check for conditional processing attributes
|
2013-03-28 05:23:09 +04:00
|
|
|
nsCOMPtr<SVGTests> tests = do_QueryObject(this);
|
2011-12-31 13:44:03 +04:00
|
|
|
if (tests && tests->IsConditionalProcessingAttribute(aName)) {
|
2012-02-16 03:40:46 +04:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-12-31 13:44:03 +04:00
|
|
|
tests->UnsetAttr(aName);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if this is a string list attribute going away
|
|
|
|
StringListAttributesInfo stringListInfo = GetStringListInfo();
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < stringListInfo.mStringListCount; i++) {
|
2011-12-31 13:44:03 +04:00
|
|
|
if (aName == *stringListInfo.mStringListInfo[i].mName) {
|
2012-02-16 03:40:46 +04:00
|
|
|
MaybeSerializeAttrBeforeRemoval(aName, aNotify);
|
2011-12-31 13:44:03 +04:00
|
|
|
stringListInfo.Reset(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-12-23 12:22:22 +04:00
|
|
|
|
|
|
|
if (aName == nsGkAtoms::_class) {
|
|
|
|
mClassAttribute.Init();
|
|
|
|
return;
|
|
|
|
}
|
2004-07-22 20:38:05 +04:00
|
|
|
}
|
|
|
|
|
2011-01-23 20:08:17 +03:00
|
|
|
// Check if this is a string attribute going away
|
|
|
|
StringAttributesInfo stringInfo = GetStringInfo();
|
2008-06-14 13:01:02 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < stringInfo.mStringCount; i++) {
|
2011-01-23 20:08:17 +03:00
|
|
|
if (aNamespaceID == stringInfo.mStringInfo[i].mNamespaceID &&
|
|
|
|
aName == *stringInfo.mStringInfo[i].mName) {
|
|
|
|
stringInfo.Reset(i);
|
2011-10-08 10:32:44 +04:00
|
|
|
return;
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
|
|
|
}
|
2011-10-08 10:32:44 +04:00
|
|
|
}
|
2008-06-14 13:01:02 +04:00
|
|
|
|
2011-10-08 10:32:44 +04:00
|
|
|
nsresult
|
2017-10-03 01:05:19 +03:00
|
|
|
nsSVGElement::UnsetAttr(int32_t aNamespaceID, nsAtom* aName,
|
2011-10-08 10:32:44 +04:00
|
|
|
bool aNotify)
|
|
|
|
{
|
|
|
|
UnsetAttrInternal(aNamespaceID, aName, aNotify);
|
|
|
|
return nsSVGElementBase::UnsetAttr(aNamespaceID, aName, aNotify);
|
2004-07-22 20:38:05 +04:00
|
|
|
}
|
|
|
|
|
2008-08-05 16:01:47 +04:00
|
|
|
nsChangeHint
|
2017-10-03 01:05:19 +03:00
|
|
|
nsSVGElement::GetAttributeChangeHint(const nsAtom* aAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aModType) const
|
2008-08-05 16:01:47 +04:00
|
|
|
{
|
|
|
|
nsChangeHint retval =
|
|
|
|
nsSVGElementBase::GetAttributeChangeHint(aAttribute, aModType);
|
|
|
|
|
2013-03-28 05:23:09 +04:00
|
|
|
nsCOMPtr<SVGTests> tests = do_QueryObject(const_cast<nsSVGElement*>(this));
|
2011-12-31 13:44:03 +04:00
|
|
|
if (tests && tests->IsConditionalProcessingAttribute(aAttribute)) {
|
2008-08-05 16:01:47 +04:00
|
|
|
// It would be nice to only reconstruct the frame if the value returned by
|
2013-03-02 10:08:42 +04:00
|
|
|
// SVGTests::PassesConditionalProcessingTests has changed, but we don't
|
2011-12-31 13:44:03 +04:00
|
|
|
// know that
|
2016-05-23 06:26:03 +03:00
|
|
|
retval |= nsChangeHint_ReconstructFrame;
|
2008-08-05 16:01:47 +04:00
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::IsNodeOfType(uint32_t aFlags) const
|
2004-07-07 02:52:03 +04:00
|
|
|
{
|
2011-12-08 10:32:11 +04:00
|
|
|
return !(aFlags & ~eCONTENT);
|
2004-07-07 02:52:03 +04:00
|
|
|
}
|
|
|
|
|
2017-02-23 04:19:04 +03:00
|
|
|
void
|
|
|
|
nsSVGElement::NodeInfoChanged(nsIDocument* aOldDoc)
|
|
|
|
{
|
2017-03-25 01:28:19 +03:00
|
|
|
nsSVGElementBase::NodeInfoChanged(aOldDoc);
|
2017-02-23 04:19:04 +03:00
|
|
|
aOldDoc->UnscheduleSVGForPresAttrEvaluation(this);
|
|
|
|
mContentDeclarationBlock = nullptr;
|
|
|
|
OwnerDoc()->ScheduleSVGForPresAttrEvaluation(this);
|
|
|
|
}
|
|
|
|
|
2001-12-12 10:59:31 +03: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 15:39:26 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
// printf("nsSVGElement(%p)::WalkContentStyleRules()\n", this);
|
|
|
|
#endif
|
2016-12-31 12:10:45 +03:00
|
|
|
if (!mContentDeclarationBlock) {
|
2017-02-23 04:19:04 +03:00
|
|
|
UpdateContentDeclarationBlock(StyleBackendType::Gecko);
|
2016-12-31 12:10:45 +03:00
|
|
|
}
|
2004-03-09 11:44:53 +03:00
|
|
|
|
2016-12-31 12:10:45 +03:00
|
|
|
if (mContentDeclarationBlock) {
|
|
|
|
css::Declaration* declaration = mContentDeclarationBlock->AsGecko();
|
2015-11-05 11:44:10 +03:00
|
|
|
declaration->SetImmutable();
|
|
|
|
aRuleWalker->Forward(declaration);
|
2009-12-11 19:13:19 +03:00
|
|
|
}
|
2004-03-09 11:44:53 +03:00
|
|
|
|
2014-09-13 17:17:35 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-02-20 00:49:34 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2017-10-03 01:05:19 +03:00
|
|
|
nsSVGElement::IsAttributeMapped(const nsAtom* name) const
|
2012-02-20 00:49:34 +04:00
|
|
|
{
|
|
|
|
if (name == nsGkAtoms::lang) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return nsSVGElementBase::IsAttributeMapped(name);
|
|
|
|
}
|
|
|
|
|
2004-02-09 23:48:20 +03:00
|
|
|
// PresentationAttributes-FillStroke
|
2012-11-15 02:10:08 +04:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2004-02-09 23:48:20 +03:00
|
|
|
nsSVGElement::sFillStrokeMap[] = {
|
2006-12-26 20:47:52 +03:00
|
|
|
{ &nsGkAtoms::fill },
|
|
|
|
{ &nsGkAtoms::fill_opacity },
|
|
|
|
{ &nsGkAtoms::fill_rule },
|
2013-01-13 03:27:53 +04:00
|
|
|
{ &nsGkAtoms::paint_order },
|
2006-12-26 20:47:52 +03: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 12:34:25 +04:00
|
|
|
{ &nsGkAtoms::vector_effect },
|
2012-07-30 18:20:58 +04:00
|
|
|
{ nullptr }
|
2004-02-09 23:48:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// PresentationAttributes-Graphics
|
2012-11-15 02:10:08 +04:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2004-02-09 23:48:20 +03:00
|
|
|
nsSVGElement::sGraphicsMap[] = {
|
2006-12-26 20:47:52 +03:00
|
|
|
{ &nsGkAtoms::clip_path },
|
|
|
|
{ &nsGkAtoms::clip_rule },
|
2007-01-30 16:19:55 +03:00
|
|
|
{ &nsGkAtoms::colorInterpolation },
|
2006-12-26 20:47:52 +03: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 18:20:58 +04:00
|
|
|
{ nullptr }
|
2004-02-09 23:48:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// PresentationAttributes-TextContentElements
|
2012-11-15 02:10:08 +04:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2004-02-09 23:48:20 +03:00
|
|
|
nsSVGElement::sTextContentElementsMap[] = {
|
2012-07-09 05:09:49 +04:00
|
|
|
// Properties that we don't support are commented out.
|
|
|
|
// { &nsGkAtoms::alignment_baseline },
|
|
|
|
// { &nsGkAtoms::baseline_shift },
|
2006-12-26 20:47:52 +03:00
|
|
|
{ &nsGkAtoms::direction },
|
|
|
|
{ &nsGkAtoms::dominant_baseline },
|
|
|
|
{ &nsGkAtoms::letter_spacing },
|
|
|
|
{ &nsGkAtoms::text_anchor },
|
|
|
|
{ &nsGkAtoms::text_decoration },
|
|
|
|
{ &nsGkAtoms::unicode_bidi },
|
|
|
|
{ &nsGkAtoms::word_spacing },
|
2016-04-02 00:08:04 +03:00
|
|
|
{ &nsGkAtoms::writing_mode },
|
2012-07-30 18:20:58 +04:00
|
|
|
{ nullptr }
|
2004-02-09 23:48:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// PresentationAttributes-FontSpecification
|
2012-11-15 02:10:08 +04:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2004-02-09 23:48:20 +03:00
|
|
|
nsSVGElement::sFontSpecificationMap[] = {
|
2006-12-26 20:47:52 +03:00
|
|
|
{ &nsGkAtoms::font_family },
|
|
|
|
{ &nsGkAtoms::font_size },
|
|
|
|
{ &nsGkAtoms::font_size_adjust },
|
|
|
|
{ &nsGkAtoms::font_stretch },
|
|
|
|
{ &nsGkAtoms::font_style },
|
|
|
|
{ &nsGkAtoms::font_variant },
|
2017-07-06 15:00:35 +03:00
|
|
|
{ &nsGkAtoms::fontWeight },
|
2012-07-30 18:20:58 +04:00
|
|
|
{ nullptr }
|
2004-02-09 23:48:20 +03:00
|
|
|
};
|
|
|
|
|
2004-10-15 03:02:53 +04:00
|
|
|
// PresentationAttributes-GradientStop
|
2012-11-15 02:10:08 +04:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2004-10-15 03:02:53 +04:00
|
|
|
nsSVGElement::sGradientStopMap[] = {
|
2006-12-26 20:47:52 +03:00
|
|
|
{ &nsGkAtoms::stop_color },
|
|
|
|
{ &nsGkAtoms::stop_opacity },
|
2012-07-30 18:20:58 +04:00
|
|
|
{ nullptr }
|
2004-10-15 03:02:53 +04:00
|
|
|
};
|
|
|
|
|
2004-10-27 04:25:08 +04:00
|
|
|
// PresentationAttributes-Viewports
|
2012-11-15 02:10:08 +04:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2004-10-27 04:25:08 +04:00
|
|
|
nsSVGElement::sViewportsMap[] = {
|
2006-12-26 20:47:52 +03:00
|
|
|
{ &nsGkAtoms::overflow },
|
|
|
|
{ &nsGkAtoms::clip },
|
2012-07-30 18:20:58 +04:00
|
|
|
{ nullptr }
|
2004-10-27 04:25:08 +04:00
|
|
|
};
|
|
|
|
|
2004-12-09 06:16:15 +03:00
|
|
|
// PresentationAttributes-Makers
|
2012-11-15 02:10:08 +04:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2004-12-09 06:16:15 +03:00
|
|
|
nsSVGElement::sMarkersMap[] = {
|
2006-12-26 20:47:52 +03:00
|
|
|
{ &nsGkAtoms::marker_end },
|
|
|
|
{ &nsGkAtoms::marker_mid },
|
|
|
|
{ &nsGkAtoms::marker_start },
|
2012-07-30 18:20:58 +04:00
|
|
|
{ nullptr }
|
2004-12-09 06:16:15 +03:00
|
|
|
};
|
|
|
|
|
2004-12-10 02:51:25 +03:00
|
|
|
// PresentationAttributes-Color
|
2012-11-15 02:10:08 +04:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2004-12-10 02:51:25 +03:00
|
|
|
nsSVGElement::sColorMap[] = {
|
2006-12-26 20:47:52 +03:00
|
|
|
{ &nsGkAtoms::color },
|
2012-07-30 18:20:58 +04:00
|
|
|
{ nullptr }
|
2004-12-10 02:51:25 +03:00
|
|
|
};
|
|
|
|
|
2007-01-30 16:19:55 +03:00
|
|
|
// PresentationAttributes-Filters
|
2012-11-15 02:10:08 +04:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2007-01-30 16:19:55 +03:00
|
|
|
nsSVGElement::sFiltersMap[] = {
|
|
|
|
{ &nsGkAtoms::colorInterpolationFilters },
|
2012-07-30 18:20:58 +04:00
|
|
|
{ nullptr }
|
2007-01-30 16:19:55 +03:00
|
|
|
};
|
|
|
|
|
2007-01-08 19:48:56 +03:00
|
|
|
// PresentationAttributes-feFlood
|
2012-11-15 02:10:08 +04:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2007-01-08 19:48:56 +03:00
|
|
|
nsSVGElement::sFEFloodMap[] = {
|
|
|
|
{ &nsGkAtoms::flood_color },
|
|
|
|
{ &nsGkAtoms::flood_opacity },
|
2012-07-30 18:20:58 +04:00
|
|
|
{ nullptr }
|
2007-01-08 19:48:56 +03:00
|
|
|
};
|
2004-12-10 02:51:25 +03:00
|
|
|
|
2007-07-26 10:57:42 +04:00
|
|
|
// PresentationAttributes-LightingEffects
|
2012-11-15 02:10:08 +04:00
|
|
|
/* static */ const Element::MappedAttributeEntry
|
2007-07-26 10:57:42 +04:00
|
|
|
nsSVGElement::sLightingEffectsMap[] = {
|
|
|
|
{ &nsGkAtoms::lighting_color },
|
2012-07-30 18:20:58 +04:00
|
|
|
{ nullptr }
|
2007-07-26 10:57:42 +04:00
|
|
|
};
|
|
|
|
|
2012-12-21 04:15:22 +04:00
|
|
|
// PresentationAttributes-mask
|
|
|
|
/* static */ const Element::MappedAttributeEntry
|
|
|
|
nsSVGElement::sMaskMap[] = {
|
|
|
|
{ &nsGkAtoms::mask_type },
|
|
|
|
{ nullptr }
|
|
|
|
};
|
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMElement methods
|
|
|
|
|
2012-11-15 02:10:08 +04:00
|
|
|
// forwarded to Element implementations
|
2001-12-12 10:59:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMSVGElement methods
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2013-02-08 23:55:07 +04:00
|
|
|
nsSVGElement::GetOwnerSVGElement(nsIDOMSVGElement * *aOwnerSVGElement)
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2013-08-07 21:40:52 +04:00
|
|
|
NS_IF_ADDREF(*aOwnerSVGElement = GetOwnerSVGElement());
|
|
|
|
return NS_OK;
|
2012-12-23 12:22:58 +04:00
|
|
|
}
|
2012-12-23 12:22:58 +04:00
|
|
|
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement*
|
2013-08-07 21:40:52 +04:00
|
|
|
nsSVGElement::GetOwnerSVGElement()
|
2012-12-23 12:22:58 +04:00
|
|
|
{
|
2013-08-07 21:40:52 +04:00
|
|
|
return GetCtx(); // this may return nullptr
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGElement::GetViewportElement(nsIDOMSVGElement * *aViewportElement)
|
|
|
|
{
|
2013-01-06 10:25:55 +04:00
|
|
|
nsSVGElement* elem = GetViewportElement();
|
2013-03-28 05:23:09 +04:00
|
|
|
NS_ADDREF(*aViewportElement = elem);
|
2009-07-23 12:35:59 +04:00
|
|
|
return NS_OK;
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2013-01-06 10:25:55 +04:00
|
|
|
nsSVGElement*
|
2012-12-23 12:22:58 +04:00
|
|
|
nsSVGElement::GetViewportElement()
|
|
|
|
{
|
2013-01-06 10:25:55 +04:00
|
|
|
return SVGContentUtils::GetNearestViewportElement(this);
|
2012-12-23 12:22:58 +04:00
|
|
|
}
|
|
|
|
|
2013-06-15 02:37:27 +04:00
|
|
|
already_AddRefed<SVGAnimatedString>
|
2012-12-23 12:22:58 +04:00
|
|
|
nsSVGElement::ClassName()
|
|
|
|
{
|
2013-02-07 12:08:56 +04:00
|
|
|
return mClassAttribute.ToDOMAnimatedString(this);
|
2012-12-23 12:22:58 +04:00
|
|
|
}
|
|
|
|
|
2016-05-24 07:22:17 +03:00
|
|
|
bool
|
2016-09-28 15:05:28 +03:00
|
|
|
nsSVGElement::IsSVGFocusable(bool* aIsFocusable, int32_t* aTabIndex)
|
2016-05-24 07:22:17 +03:00
|
|
|
{
|
2016-09-28 15:05:28 +03:00
|
|
|
nsIDocument* doc = GetComposedDoc();
|
|
|
|
if (!doc || doc->HasFlag(NODE_IS_EDITABLE)) {
|
|
|
|
// In designMode documents we only allow focusing the document.
|
|
|
|
if (aTabIndex) {
|
|
|
|
*aTabIndex = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aIsFocusable = false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t tabIndex = TabIndex();
|
2016-05-24 07:22:17 +03:00
|
|
|
|
2016-09-28 15:05:28 +03:00
|
|
|
if (aTabIndex) {
|
|
|
|
*aTabIndex = tabIndex;
|
2016-05-24 07:22:17 +03:00
|
|
|
}
|
|
|
|
|
2016-09-28 15:05:28 +03:00
|
|
|
// If a tabindex is specified at all, or the default tabindex is 0, we're focusable
|
|
|
|
*aIsFocusable =
|
|
|
|
tabIndex >= 0 || HasAttr(kNameSpaceID_None, nsGkAtoms::tabindex);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsSVGElement::IsFocusableInternal(int32_t* aTabIndex, bool aWithMouse)
|
|
|
|
{
|
|
|
|
bool isFocusable = false;
|
|
|
|
IsSVGFocusable(&isFocusable, aTabIndex);
|
|
|
|
return isFocusable;
|
2016-05-24 07:22:17 +03:00
|
|
|
}
|
|
|
|
|
2010-03-17 02:17:32 +03:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Helper class: MappedAttrParser, for parsing values of mapped attributes
|
2010-06-29 02:49:35 +04:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2013-04-12 07:20:09 +04:00
|
|
|
class MOZ_STACK_CLASS MappedAttrParser {
|
2010-03-17 02:17:32 +03:00
|
|
|
public:
|
2010-06-29 02:49:35 +04:00
|
|
|
MappedAttrParser(css::Loader* aLoader,
|
2010-03-17 02:17:32 +03:00
|
|
|
nsIURI* aDocURI,
|
|
|
|
already_AddRefed<nsIURI> aBaseURI,
|
2017-02-23 04:19:04 +03:00
|
|
|
nsSVGElement* aElement,
|
|
|
|
StyleBackendType aBackend);
|
2010-03-17 02:17:32 +03:00
|
|
|
~MappedAttrParser();
|
|
|
|
|
|
|
|
// Parses a mapped attribute value.
|
2017-10-03 01:05:19 +03:00
|
|
|
void ParseMappedAttrValue(nsAtom* aMappedAttrName,
|
2012-06-11 03:44:50 +04:00
|
|
|
const nsAString& aMappedAttrValue);
|
2010-03-17 02:17:32 +03:00
|
|
|
|
2016-12-31 12:10:45 +03:00
|
|
|
// If we've parsed any values for mapped attributes, this method returns the
|
|
|
|
// already_AddRefed css::Declaration that incorporates the parsed
|
2010-06-29 02:49:35 +04:00
|
|
|
// values. Otherwise, this method returns null.
|
2017-02-23 04:19:04 +03:00
|
|
|
already_AddRefed<DeclarationBlock> GetDeclarationBlock();
|
2016-12-31 12:10:45 +03:00
|
|
|
|
2010-03-17 02:17:32 +03:00
|
|
|
private:
|
|
|
|
// MEMBER DATA
|
|
|
|
// -----------
|
|
|
|
nsCSSParser mParser;
|
2017-07-11 00:52:00 +03:00
|
|
|
css::Loader* mLoader;
|
2010-03-17 02:17:32 +03:00
|
|
|
|
|
|
|
// Arguments for nsCSSParser::ParseProperty
|
|
|
|
nsIURI* mDocURI;
|
|
|
|
nsCOMPtr<nsIURI> mBaseURI;
|
|
|
|
|
|
|
|
// Declaration for storing parsed values (lazily initialized)
|
2017-02-23 04:19:04 +03:00
|
|
|
RefPtr<DeclarationBlock> mDecl;
|
2015-02-05 20:32:14 +03:00
|
|
|
|
|
|
|
// For reporting use counters
|
|
|
|
nsSVGElement* mElement;
|
2017-02-23 04:19:04 +03:00
|
|
|
|
|
|
|
StyleBackendType mBackend;
|
2010-03-17 02:17:32 +03:00
|
|
|
};
|
|
|
|
|
2010-06-29 02:49:35 +04:00
|
|
|
MappedAttrParser::MappedAttrParser(css::Loader* aLoader,
|
2010-03-17 02:17:32 +03:00
|
|
|
nsIURI* aDocURI,
|
|
|
|
already_AddRefed<nsIURI> aBaseURI,
|
2017-02-23 04:19:04 +03:00
|
|
|
nsSVGElement* aElement,
|
|
|
|
StyleBackendType aBackend)
|
2017-07-11 00:52:00 +03:00
|
|
|
: mParser(aLoader), mLoader(aLoader), mDocURI(aDocURI), mBaseURI(aBaseURI),
|
2017-02-23 04:19:04 +03:00
|
|
|
mElement(aElement), mBackend(aBackend)
|
2010-03-17 02:17:32 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
MappedAttrParser::~MappedAttrParser()
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!mDecl,
|
2016-12-31 12:10:45 +03:00
|
|
|
"If mDecl was initialized, it should have been returned via "
|
|
|
|
"GetDeclarationBlock (and had its pointer cleared)");
|
2010-03-17 02:17:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-10-03 01:05:19 +03:00
|
|
|
MappedAttrParser::ParseMappedAttrValue(nsAtom* aMappedAttrName,
|
2012-06-11 03:44:50 +04:00
|
|
|
const nsAString& aMappedAttrValue)
|
2010-03-17 02:17:32 +03:00
|
|
|
{
|
|
|
|
if (!mDecl) {
|
2017-02-23 04:19:04 +03:00
|
|
|
if (mBackend == StyleBackendType::Gecko) {
|
|
|
|
mDecl = new css::Declaration();
|
|
|
|
mDecl->AsGecko()->InitializeEmpty();
|
|
|
|
} else {
|
|
|
|
mDecl = new ServoDeclarationBlock();
|
|
|
|
}
|
2010-03-17 02:17:32 +03:00
|
|
|
}
|
|
|
|
|
2016-08-10 02:28:19 +03:00
|
|
|
// Get the nsCSSPropertyID ID for our mapped attribute.
|
|
|
|
nsCSSPropertyID propertyID =
|
2012-07-14 03:59:05 +04:00
|
|
|
nsCSSProps::LookupProperty(nsDependentAtomString(aMappedAttrName),
|
2016-05-10 11:44:05 +03:00
|
|
|
CSSEnabledState::eForAllContent);
|
2012-02-20 00:49:34 +04:00
|
|
|
if (propertyID != eCSSProperty_UNKNOWN) {
|
2015-06-03 22:21:24 +03:00
|
|
|
bool changed = false; // outparam for ParseProperty.
|
2017-02-23 04:19:04 +03:00
|
|
|
if (mBackend == StyleBackendType::Gecko) {
|
|
|
|
mParser.ParseProperty(propertyID, aMappedAttrValue, mDocURI, mBaseURI,
|
|
|
|
mElement->NodePrincipal(), mDecl->AsGecko(), &changed, false, true);
|
|
|
|
} else {
|
|
|
|
NS_ConvertUTF16toUTF8 value(aMappedAttrValue);
|
|
|
|
// FIXME (bug 1343964): Figure out a better solution for sending the base uri to servo
|
2017-04-04 03:04:13 +03:00
|
|
|
RefPtr<URLExtraData> data = new URLExtraData(mBaseURI, mDocURI,
|
|
|
|
mElement->NodePrincipal());
|
2017-04-14 06:55:44 +03:00
|
|
|
changed = Servo_DeclarationBlock_SetPropertyById(
|
|
|
|
mDecl->AsServo()->Raw(), propertyID, &value, false, data,
|
2017-07-11 00:52:00 +03:00
|
|
|
ParsingMode::AllowUnitlessLength, mElement->OwnerDoc()->GetCompatibilityMode(), mLoader);
|
2017-02-23 04:19:04 +03:00
|
|
|
}
|
|
|
|
|
2015-06-03 22:21:24 +03:00
|
|
|
if (changed) {
|
|
|
|
// The normal reporting of use counters by the nsCSSParser won't happen
|
|
|
|
// since it doesn't have a sheet.
|
2015-08-11 07:24:27 +03:00
|
|
|
if (nsCSSProps::IsShorthand(propertyID)) {
|
|
|
|
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(subprop, propertyID,
|
2016-05-10 11:44:05 +03:00
|
|
|
CSSEnabledState::eForAllContent) {
|
2015-08-11 07:24:27 +03:00
|
|
|
UseCounter useCounter = nsCSSProps::UseCounterFor(*subprop);
|
|
|
|
if (useCounter != eUseCounter_UNKNOWN) {
|
|
|
|
mElement->OwnerDoc()->SetDocumentAndPageUseCounter(useCounter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
UseCounter useCounter = nsCSSProps::UseCounterFor(propertyID);
|
|
|
|
if (useCounter != eUseCounter_UNKNOWN) {
|
|
|
|
mElement->OwnerDoc()->SetDocumentAndPageUseCounter(useCounter);
|
|
|
|
}
|
2015-06-03 22:21:24 +03:00
|
|
|
}
|
|
|
|
}
|
2012-02-20 00:49:34 +04:00
|
|
|
return;
|
|
|
|
}
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(aMappedAttrName == nsGkAtoms::lang,
|
|
|
|
"Only 'lang' should be unrecognized!");
|
2012-02-20 00:49:34 +04:00
|
|
|
// nsCSSParser doesn't know about 'lang', so we need to handle it specially.
|
|
|
|
if (aMappedAttrName == nsGkAtoms::lang) {
|
|
|
|
propertyID = eCSSProperty__x_lang;
|
2017-02-23 04:19:04 +03:00
|
|
|
if (mBackend == StyleBackendType::Gecko) {
|
|
|
|
nsCSSExpandedDataBlock block;
|
|
|
|
mDecl->AsGecko()->ExpandTo(&block);
|
|
|
|
nsCSSValue cssValue(PromiseFlatString(aMappedAttrValue), eCSSUnit_Ident);
|
|
|
|
block.AddLonghandProperty(propertyID, cssValue);
|
|
|
|
mDecl->AsGecko()->ValueAppended(propertyID);
|
|
|
|
mDecl->AsGecko()->CompressFrom(&block);
|
|
|
|
} else {
|
2017-10-03 01:05:19 +03:00
|
|
|
RefPtr<nsAtom> atom = NS_Atomize(aMappedAttrValue);
|
2017-02-23 04:19:04 +03:00
|
|
|
Servo_DeclarationBlock_SetIdentStringValue(mDecl->AsServo()->Raw(), propertyID, atom);
|
|
|
|
}
|
2012-02-20 00:49:34 +04:00
|
|
|
}
|
2010-03-17 02:17:32 +03:00
|
|
|
}
|
|
|
|
|
2017-02-23 04:19:04 +03:00
|
|
|
already_AddRefed<DeclarationBlock>
|
2016-12-31 12:10:45 +03:00
|
|
|
MappedAttrParser::GetDeclarationBlock()
|
|
|
|
{
|
|
|
|
return mDecl.forget();
|
|
|
|
}
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace
|
2010-06-29 02:49:35 +04:00
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation Helpers:
|
|
|
|
|
2004-03-09 11:44:53 +03:00
|
|
|
void
|
2017-02-23 04:19:04 +03:00
|
|
|
nsSVGElement::UpdateContentDeclarationBlock(mozilla::StyleBackendType aBackend)
|
2004-03-09 11:44:53 +03:00
|
|
|
{
|
2016-12-31 12:10:45 +03:00
|
|
|
NS_ASSERTION(!mContentDeclarationBlock,
|
|
|
|
"we already have a content declaration block");
|
2010-03-02 23:59:32 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t attrCount = mAttrsAndChildren.AttrCount();
|
2010-03-02 23:59:32 +03:00
|
|
|
if (!attrCount) {
|
|
|
|
// nothing to do
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-18 14:53:36 +04:00
|
|
|
nsIDocument* doc = OwnerDoc();
|
2010-03-17 02:17:32 +03:00
|
|
|
MappedAttrParser mappedAttrParser(doc->CSSLoader(), doc->GetDocumentURI(),
|
2017-02-23 04:19:04 +03:00
|
|
|
GetBaseURI(), this, aBackend);
|
2004-08-10 04:02:47 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < attrCount; ++i) {
|
2005-12-30 23:12:35 +03:00
|
|
|
const nsAttrName* attrName = mAttrsAndChildren.AttrNameAt(i);
|
2004-03-09 11:44:53 +03:00
|
|
|
if (!attrName->IsAtom() || !IsAttributeMapped(attrName->Atom()))
|
|
|
|
continue;
|
|
|
|
|
2012-02-20 00:49:34 +04: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 14:09:00 +03:00
|
|
|
if (IsSVGElement(nsGkAtoms::svg)) {
|
2011-12-27 14:27:42 +04: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-10 03:02:45 +04:00
|
|
|
// this by checking the attribute value in SVGSVGElement::
|
2011-12-27 14:27:42 +04: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 11:44:53 +03:00
|
|
|
nsAutoString value;
|
|
|
|
mAttrsAndChildren.AttrAt(i)->ToString(value);
|
2010-03-17 02:17:32 +03:00
|
|
|
mappedAttrParser.ParseMappedAttrValue(attrName->Atom(), value);
|
2004-12-18 15:14:32 +03:00
|
|
|
}
|
2016-12-31 12:10:45 +03:00
|
|
|
mContentDeclarationBlock = mappedAttrParser.GetDeclarationBlock();
|
2004-03-09 11:44:53 +03:00
|
|
|
}
|
|
|
|
|
2017-02-23 04:19:04 +03:00
|
|
|
const DeclarationBlock*
|
|
|
|
nsSVGElement::GetContentDeclarationBlock() const
|
|
|
|
{
|
|
|
|
return mContentDeclarationBlock;
|
|
|
|
}
|
|
|
|
|
2012-02-16 03:40:45 +04: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
|
2017-10-03 01:05:19 +03:00
|
|
|
nsSVGElement::WillChangeValue(nsAtom* aName)
|
2012-02-16 03:40:45 +04:00
|
|
|
{
|
|
|
|
// We need an empty attr value:
|
2012-07-30 18:20:58 +04:00
|
|
|
// a) to pass to BeforeSetAttr when GetParsedAttr returns nullptr
|
2012-02-16 03:40:45 +04:00
|
|
|
// b) to store the old value in the case we have mutation listeners
|
2017-03-16 21:50:41 +03:00
|
|
|
//
|
|
|
|
// We can use the same value for both purposes, because if GetParsedAttr
|
|
|
|
// returns non-null its return value is what will get passed to BeforeSetAttr,
|
|
|
|
// not matter what our mutation listener situation is.
|
|
|
|
//
|
2012-02-16 03:40:45 +04:00
|
|
|
// Also, we should be careful to always return this value to benefit from
|
|
|
|
// return value optimization.
|
|
|
|
nsAttrValue emptyOrOldAttrValue;
|
|
|
|
const nsAttrValue* attrValue = GetParsedAttr(aName);
|
|
|
|
|
|
|
|
// 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 19:56:38 +04:00
|
|
|
uint8_t modType = attrValue
|
|
|
|
? static_cast<uint8_t>(nsIDOMMutationEvent::MODIFICATION)
|
|
|
|
: static_cast<uint8_t>(nsIDOMMutationEvent::ADDITION);
|
2015-07-25 09:05:19 +03:00
|
|
|
nsNodeUtils::AttributeWillChange(this, kNameSpaceID_None, aName, modType,
|
|
|
|
nullptr);
|
2012-02-16 03:40:45 +04:00
|
|
|
|
2017-03-16 21:50:41 +03:00
|
|
|
// 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.
|
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv), "Unexpected failure from BeforeSetAttr");
|
|
|
|
|
2012-02-16 03:40:45 +04:00
|
|
|
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.
|
2015-07-22 05:09:41 +03:00
|
|
|
*
|
|
|
|
* aNewValue is replaced with the old value.
|
2012-02-16 03:40:45 +04:00
|
|
|
*/
|
|
|
|
void
|
2017-10-03 01:05:19 +03:00
|
|
|
nsSVGElement::DidChangeValue(nsAtom* aName,
|
2012-02-16 03:40:45 +04:00
|
|
|
const nsAttrValue& aEmptyOrOldValue,
|
|
|
|
nsAttrValue& aNewValue)
|
|
|
|
{
|
|
|
|
bool hasListeners =
|
|
|
|
nsContentUtils::HasMutationListeners(this,
|
|
|
|
NS_EVENT_BITS_MUTATION_ATTRMODIFIED,
|
|
|
|
this);
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t modType = HasAttr(kNameSpaceID_None, aName)
|
|
|
|
? static_cast<uint8_t>(nsIDOMMutationEvent::MODIFICATION)
|
|
|
|
: static_cast<uint8_t>(nsIDOMMutationEvent::ADDITION);
|
2017-04-01 05:54:41 +03:00
|
|
|
|
|
|
|
nsIDocument* document = GetComposedDoc();
|
|
|
|
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL,
|
|
|
|
kNotifyDocumentObservers);
|
2017-05-19 00:09:01 +03:00
|
|
|
// XXX Really, the fourth argument to SetAttrAndNotify should be null if
|
|
|
|
// aEmptyOrOldValue does not represent the actual previous value of the
|
|
|
|
// attribute, but currently SVG elements do not even use the old attribute
|
|
|
|
// value in |AfterSetAttr|, so this should be ok.
|
|
|
|
SetAttrAndNotify(kNameSpaceID_None, aName, nullptr, &aEmptyOrOldValue,
|
2012-02-16 03:40:45 +04:00
|
|
|
aNewValue, modType, hasListeners, kNotifyDocumentObservers,
|
2017-04-01 05:54:41 +03:00
|
|
|
kCallAfterSetAttr, document, updateBatch);
|
2012-02-16 03:40:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-10-03 01:05:19 +03:00
|
|
|
nsSVGElement::MaybeSerializeAttrBeforeRemoval(nsAtom* aName, bool aNotify)
|
2012-02-16 03:40:45 +04:00
|
|
|
{
|
|
|
|
if (!aNotify ||
|
|
|
|
!nsContentUtils::HasMutationListeners(this,
|
|
|
|
NS_EVENT_BITS_MUTATION_ATTRMODIFIED,
|
|
|
|
this)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-05 03:38:03 +04:00
|
|
|
const nsAttrValue* attrValue = mAttrsAndChildren.GetAttr(aName);
|
|
|
|
if (!attrValue)
|
|
|
|
return;
|
|
|
|
|
2012-02-16 03:40:45 +04:00
|
|
|
nsAutoString serializedValue;
|
2012-03-05 03:38:03 +04:00
|
|
|
attrValue->ToString(serializedValue);
|
|
|
|
nsAttrValue oldAttrValue(serializedValue);
|
2017-05-19 00:09:01 +03:00
|
|
|
bool oldValueSet;
|
|
|
|
mAttrsAndChildren.SetAndSwapAttr(aName, oldAttrValue, &oldValueSet);
|
2012-02-16 03:40:45 +04:00
|
|
|
}
|
|
|
|
|
2005-08-26 01:31:09 +04:00
|
|
|
/* static */
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* nsSVGElement::GetEventNameForAttr(nsAtom* aAttr)
|
2005-08-26 01:31:09 +04:00
|
|
|
{
|
2006-12-26 20:47:52 +03: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 11:02:52 +04:00
|
|
|
if (aAttr == nsGkAtoms::onbegin)
|
|
|
|
return nsGkAtoms::onbeginEvent;
|
|
|
|
if (aAttr == nsGkAtoms::onrepeat)
|
|
|
|
return nsGkAtoms::onrepeatEvent;
|
|
|
|
if (aAttr == nsGkAtoms::onend)
|
|
|
|
return nsGkAtoms::onendEvent;
|
2005-08-26 01:31:09 +04:00
|
|
|
|
|
|
|
return aAttr;
|
|
|
|
}
|
2006-04-14 19:09:39 +04:00
|
|
|
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement *
|
2011-06-16 14:53:13 +04:00
|
|
|
nsSVGElement::GetCtx() const
|
2006-04-14 19:09:39 +04:00
|
|
|
{
|
2011-04-08 09:27:57 +04:00
|
|
|
nsIContent* ancestor = GetFlattenedTreeParent();
|
2011-02-26 13:21:11 +03:00
|
|
|
|
2015-03-03 14:08:59 +03:00
|
|
|
while (ancestor && ancestor->IsSVGElement()) {
|
2015-03-03 14:09:00 +03:00
|
|
|
if (ancestor->IsSVGElement(nsGkAtoms::foreignObject)) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2011-02-26 13:21:11 +03:00
|
|
|
}
|
2015-03-03 14:09:00 +03:00
|
|
|
if (ancestor->IsSVGElement(nsGkAtoms::svg)) {
|
2013-01-10 03:02:45 +04:00
|
|
|
return static_cast<SVGSVGElement*>(ancestor);
|
2011-02-26 13:21:11 +03:00
|
|
|
}
|
2011-04-08 09:27:57 +04:00
|
|
|
ancestor = ancestor->GetFlattenedTreeParent();
|
2011-02-26 13:21:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// we don't have an ancestor <svg> element...
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2006-04-14 19:09:39 +04:00
|
|
|
}
|
|
|
|
|
2013-12-27 00:13:57 +04:00
|
|
|
/* virtual */ gfxMatrix
|
2015-12-03 01:36:23 +03:00
|
|
|
nsSVGElement::PrependLocalTransformsTo(
|
|
|
|
const gfxMatrix &aMatrix, SVGTransformTypes aWhich) const
|
2009-04-29 08:31:34 +04:00
|
|
|
{
|
|
|
|
return aMatrix;
|
|
|
|
}
|
|
|
|
|
2006-04-14 19:09:39 +04:00
|
|
|
nsSVGElement::LengthAttributesInfo
|
|
|
|
nsSVGElement::GetLengthInfo()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return LengthAttributesInfo(nullptr, nullptr, 0);
|
2006-04-14 19:09:39 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsSVGElement::LengthAttributesInfo::Reset(uint8_t aAttrEnum)
|
2007-11-22 11:54:31 +03:00
|
|
|
{
|
|
|
|
mLengths[aAttrEnum].Init(mLengthInfo[aAttrEnum].mCtxType,
|
|
|
|
aAttrEnum,
|
|
|
|
mLengthInfo[aAttrEnum].mDefaultValue,
|
|
|
|
mLengthInfo[aAttrEnum].mDefaultUnitType);
|
|
|
|
}
|
|
|
|
|
2011-06-21 00:15:42 +04:00
|
|
|
void
|
2017-10-03 01:05:19 +03:00
|
|
|
nsSVGElement::SetLength(nsAtom* aName, const nsSVGLength2 &aLength)
|
2011-06-21 00:15:42 +04:00
|
|
|
{
|
|
|
|
LengthAttributesInfo lengthInfo = GetLengthInfo();
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < lengthInfo.mLengthCount; i++) {
|
2011-06-21 00:15:42 +04:00
|
|
|
if (aName == *lengthInfo.mLengthInfo[i].mName) {
|
|
|
|
lengthInfo.mLengths[i] = aLength;
|
2011-10-08 10:32:44 +04:00
|
|
|
DidAnimateLength(i);
|
2011-06-21 00:15:42 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(false, "no length found to set");
|
2011-06-21 00:15:42 +04:00
|
|
|
}
|
|
|
|
|
2012-02-16 03:40:45 +04:00
|
|
|
nsAttrValue
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::WillChangeLength(uint8_t aAttrEnum)
|
2006-04-14 19:09:39 +04:00
|
|
|
{
|
2012-02-16 03:40:45 +04:00
|
|
|
return WillChangeValue(*GetLengthInfo().mLengthInfo[aAttrEnum].mName);
|
|
|
|
}
|
2006-04-14 19:09:39 +04:00
|
|
|
|
2012-02-16 03:40:45 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidChangeLength(uint8_t aAttrEnum,
|
2012-02-16 03:40:45 +04:00
|
|
|
const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2006-04-14 19:09:39 +04: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-16 03:40:45 +04:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 18:20:58 +04:00
|
|
|
newValue.SetTo(info.mLengths[aAttrEnum], nullptr);
|
2006-04-14 19:09:39 +04:00
|
|
|
|
2012-02-16 03:40:45 +04:00
|
|
|
DidChangeValue(*info.mLengthInfo[aAttrEnum].mName, aEmptyOrOldValue,
|
|
|
|
newValue);
|
2006-04-14 19:09:39 +04:00
|
|
|
}
|
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidAnimateLength(uint8_t aAttrEnum)
|
2009-01-15 07:38:07 +03:00
|
|
|
{
|
2014-10-04 15:13:30 +04:00
|
|
|
ClearAnyCachedPath();
|
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
LengthAttributesInfo info = GetLengthInfo();
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mLengthInfo[aAttrEnum].mName,
|
2017-05-06 22:32:14 +03:00
|
|
|
nsIDOMMutationEvent::SMIL);
|
2009-01-15 07:38:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-27 14:27:42 +04:00
|
|
|
nsSVGLength2*
|
2017-10-03 01:05:19 +03:00
|
|
|
nsSVGElement::GetAnimatedLength(const nsAtom *aAttrName)
|
2011-12-27 14:27:42 +04:00
|
|
|
{
|
|
|
|
LengthAttributesInfo lengthInfo = GetLengthInfo();
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < lengthInfo.mLengthCount; i++) {
|
2011-12-27 14:27:42 +04:00
|
|
|
if (aAttrName == *lengthInfo.mLengthInfo[i].mName) {
|
|
|
|
return &lengthInfo.mLengths[i];
|
|
|
|
}
|
|
|
|
}
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(false, "no matching length found");
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2011-12-27 14:27:42 +04:00
|
|
|
}
|
|
|
|
|
2006-04-14 19:09:39 +04:00
|
|
|
void
|
|
|
|
nsSVGElement::GetAnimatedLengthValues(float *aFirst, ...)
|
|
|
|
{
|
|
|
|
LengthAttributesInfo info = GetLengthInfo();
|
|
|
|
|
|
|
|
NS_ASSERTION(info.mLengthCount > 0,
|
|
|
|
"GetAnimatedLengthValues on element with no length attribs");
|
|
|
|
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement *ctx = nullptr;
|
2006-04-14 19:09:39 +04:00
|
|
|
|
|
|
|
float *f = aFirst;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t i = 0;
|
2006-04-14 19:09:39 +04:00
|
|
|
|
|
|
|
va_list args;
|
|
|
|
va_start(args, aFirst);
|
|
|
|
|
|
|
|
while (f && i < info.mLengthCount) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t type = info.mLengths[i].GetSpecifiedUnitType();
|
2006-04-14 19:09:39 +04:00
|
|
|
if (!ctx) {
|
|
|
|
if (type != nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER &&
|
|
|
|
type != nsIDOMSVGLength::SVG_LENGTHTYPE_PX)
|
2007-03-09 19:27:01 +03:00
|
|
|
ctx = GetCtx();
|
2006-04-14 19:09:39 +04:00
|
|
|
}
|
2007-06-25 20:12:35 +04: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 19:09:39 +04:00
|
|
|
f = va_arg(args, float*);
|
|
|
|
}
|
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
}
|
2006-07-28 22:10:48 +04:00
|
|
|
|
2010-07-17 01:42:12 +04:00
|
|
|
nsSVGElement::LengthListAttributesInfo
|
|
|
|
nsSVGElement::GetLengthListInfo()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return LengthListAttributesInfo(nullptr, nullptr, 0);
|
2010-07-17 01:42:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::LengthListAttributesInfo::Reset(uint8_t aAttrEnum)
|
2010-07-17 01:42:12 +04:00
|
|
|
{
|
|
|
|
mLengthLists[aAttrEnum].ClearBaseValue(aAttrEnum);
|
|
|
|
// caller notifies
|
|
|
|
}
|
|
|
|
|
2012-02-16 03:40:45 +04:00
|
|
|
nsAttrValue
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::WillChangeLengthList(uint8_t aAttrEnum)
|
2010-07-17 01:42:12 +04:00
|
|
|
{
|
2012-02-16 03:40:45 +04:00
|
|
|
return WillChangeValue(*GetLengthListInfo().mLengthListInfo[aAttrEnum].mName);
|
|
|
|
}
|
2010-07-17 01:42:12 +04:00
|
|
|
|
2012-02-16 03:40:45 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidChangeLengthList(uint8_t aAttrEnum,
|
2012-02-16 03:40:45 +04:00
|
|
|
const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2010-07-17 01:42:12 +04: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-16 03:40:45 +04:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 18:20:58 +04:00
|
|
|
newValue.SetTo(info.mLengthLists[aAttrEnum].GetBaseValue(), nullptr);
|
2010-07-17 01:42:12 +04:00
|
|
|
|
2012-02-16 03:40:45 +04:00
|
|
|
DidChangeValue(*info.mLengthListInfo[aAttrEnum].mName, aEmptyOrOldValue,
|
|
|
|
newValue);
|
2010-07-17 01:42:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidAnimateLengthList(uint8_t aAttrEnum)
|
2010-07-17 01:42:12 +04:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
LengthListAttributesInfo info = GetLengthListInfo();
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mLengthListInfo[aAttrEnum].mName,
|
2017-05-06 22:32:14 +03:00
|
|
|
nsIDOMMutationEvent::SMIL);
|
2010-07-17 01:42:12 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 19:56:38 +04:00
|
|
|
uint32_t i = 0;
|
2010-07-17 01:42:12 +04: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 19:56:38 +04:00
|
|
|
nsSVGElement::GetAnimatedLengthList(uint8_t aAttrEnum)
|
2010-07-17 01:42:12 +04:00
|
|
|
{
|
|
|
|
LengthListAttributesInfo info = GetLengthListInfo();
|
|
|
|
if (aAttrEnum < info.mLengthListCount) {
|
|
|
|
return &(info.mLengthLists[aAttrEnum]);
|
|
|
|
}
|
|
|
|
NS_NOTREACHED("Bad attrEnum");
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-07-17 01:42:12 +04:00
|
|
|
}
|
|
|
|
|
2010-11-08 18:07:00 +03:00
|
|
|
|
2010-12-03 19:40:23 +03:00
|
|
|
nsSVGElement::NumberListAttributesInfo
|
|
|
|
nsSVGElement::GetNumberListInfo()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return NumberListAttributesInfo(nullptr, nullptr, 0);
|
2010-12-03 19:40:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::NumberListAttributesInfo::Reset(uint8_t aAttrEnum)
|
2010-12-03 19:40:23 +03:00
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(aAttrEnum < mNumberListCount, "Bad attr enum");
|
2010-12-03 19:40:23 +03:00
|
|
|
mNumberLists[aAttrEnum].ClearBaseValue(aAttrEnum);
|
|
|
|
// caller notifies
|
|
|
|
}
|
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
nsAttrValue
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::WillChangeNumberList(uint8_t aAttrEnum)
|
2010-12-03 19:40:23 +03:00
|
|
|
{
|
2012-02-16 03:40:46 +04:00
|
|
|
return WillChangeValue(*GetNumberListInfo().mNumberListInfo[aAttrEnum].mName);
|
|
|
|
}
|
2010-12-03 19:40:23 +03:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidChangeNumberList(uint8_t aAttrEnum,
|
2012-02-16 03:40:46 +04:00
|
|
|
const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2010-12-03 19:40:23 +03:00
|
|
|
NumberListAttributesInfo info = GetNumberListInfo();
|
|
|
|
|
2015-02-10 01:34:50 +03: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 19:40:23 +03:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 18:20:58 +04:00
|
|
|
newValue.SetTo(info.mNumberLists[aAttrEnum].GetBaseValue(), nullptr);
|
2010-12-03 19:40:23 +03:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
DidChangeValue(*info.mNumberListInfo[aAttrEnum].mName, aEmptyOrOldValue,
|
|
|
|
newValue);
|
2010-12-03 19:40:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidAnimateNumberList(uint8_t aAttrEnum)
|
2010-12-03 19:40:23 +03:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
NumberListAttributesInfo info = GetNumberListInfo();
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(aAttrEnum < info.mNumberListCount, "aAttrEnum out of range");
|
2010-12-03 19:40:23 +03:00
|
|
|
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mNumberListInfo[aAttrEnum].mName,
|
2017-05-06 22:32:14 +03:00
|
|
|
nsIDOMMutationEvent::SMIL);
|
2010-12-03 19:40:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SVGAnimatedNumberList*
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::GetAnimatedNumberList(uint8_t aAttrEnum)
|
2010-12-03 19:40:23 +03:00
|
|
|
{
|
|
|
|
NumberListAttributesInfo info = GetNumberListInfo();
|
|
|
|
if (aAttrEnum < info.mNumberListCount) {
|
|
|
|
return &(info.mNumberLists[aAttrEnum]);
|
|
|
|
}
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(false, "Bad attrEnum");
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-12-03 19:40:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
SVGAnimatedNumberList*
|
2017-10-03 01:05:19 +03:00
|
|
|
nsSVGElement::GetAnimatedNumberList(nsAtom *aAttrName)
|
2010-12-03 19:40:23 +03:00
|
|
|
{
|
|
|
|
NumberListAttributesInfo info = GetNumberListInfo();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < info.mNumberListCount; i++) {
|
2010-12-03 19:40:23 +03:00
|
|
|
if (aAttrName == *info.mNumberListInfo[i].mName) {
|
|
|
|
return &info.mNumberLists[i];
|
|
|
|
}
|
|
|
|
}
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(false, "Bad caller");
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-12-03 19:40:23 +03:00
|
|
|
}
|
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
nsAttrValue
|
|
|
|
nsSVGElement::WillChangePointList()
|
2010-12-08 15:15:53 +03:00
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(GetPointListAttrName(),
|
|
|
|
"Changing non-existent point list?");
|
2012-02-16 03:40:46 +04:00
|
|
|
return WillChangeValue(GetPointListAttrName());
|
|
|
|
}
|
2010-12-08 15:15:53 +03:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
void
|
|
|
|
nsSVGElement::DidChangePointList(const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(GetPointListAttrName(),
|
|
|
|
"Changing non-existent point list?");
|
2010-12-08 15:15:53 +03:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 18:20:58 +04:00
|
|
|
newValue.SetTo(GetAnimatedPointList()->GetBaseValue(), nullptr);
|
2010-12-08 15:15:53 +03:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
DidChangeValue(GetPointListAttrName(), aEmptyOrOldValue, newValue);
|
2010-12-08 15:15:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGElement::DidAnimatePointList()
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(GetPointListAttrName(),
|
|
|
|
"Animating non-existent path data?");
|
2010-12-08 15:15:53 +03:00
|
|
|
|
2014-10-04 15:13:30 +04:00
|
|
|
ClearAnyCachedPath();
|
|
|
|
|
2010-12-08 15:15:53 +03:00
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
GetPointListAttrName(),
|
2017-05-06 22:32:14 +03:00
|
|
|
nsIDOMMutationEvent::SMIL);
|
2010-12-08 15:15:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
nsAttrValue
|
|
|
|
nsSVGElement::WillChangePathSegList()
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(GetPathDataAttrName(),
|
|
|
|
"Changing non-existent path seg list?");
|
2012-02-16 03:40:46 +04:00
|
|
|
return WillChangeValue(GetPathDataAttrName());
|
|
|
|
}
|
|
|
|
|
2010-11-08 18:07:00 +03:00
|
|
|
void
|
2012-02-16 03:40:46 +04:00
|
|
|
nsSVGElement::DidChangePathSegList(const nsAttrValue& aEmptyOrOldValue)
|
2010-11-08 18:07:00 +03:00
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(GetPathDataAttrName(),
|
|
|
|
"Changing non-existent path seg list?");
|
2010-11-08 18:07:00 +03:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 18:20:58 +04:00
|
|
|
newValue.SetTo(GetAnimPathSegList()->GetBaseValue(), nullptr);
|
2010-11-08 18:07:00 +03:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
DidChangeValue(GetPathDataAttrName(), aEmptyOrOldValue, newValue);
|
2010-11-08 18:07:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGElement::DidAnimatePathSegList()
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(GetPathDataAttrName(),
|
|
|
|
"Animating non-existent path data?");
|
2010-11-08 18:07:00 +03:00
|
|
|
|
2014-10-04 15:13:30 +04:00
|
|
|
ClearAnyCachedPath();
|
|
|
|
|
2010-11-08 18:07:00 +03:00
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
GetPathDataAttrName(),
|
2017-05-06 22:32:14 +03:00
|
|
|
nsIDOMMutationEvent::SMIL);
|
2010-11-08 18:07:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-28 22:10:48 +04:00
|
|
|
nsSVGElement::NumberAttributesInfo
|
|
|
|
nsSVGElement::GetNumberInfo()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return NumberAttributesInfo(nullptr, nullptr, 0);
|
2006-07-28 22:10:48 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsSVGElement::NumberAttributesInfo::Reset(uint8_t aAttrEnum)
|
2007-11-22 11:54:31 +03:00
|
|
|
{
|
|
|
|
mNumbers[aAttrEnum].Init(aAttrEnum,
|
|
|
|
mNumberInfo[aAttrEnum].mDefaultValue);
|
|
|
|
}
|
|
|
|
|
2006-07-28 22:10:48 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidChangeNumber(uint8_t aAttrEnum)
|
2006-07-28 22:10:48 +04: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-16 03:40:45 +04:00
|
|
|
nsAttrValue attrValue;
|
2012-07-30 18:20:58 +04:00
|
|
|
attrValue.SetTo(info.mNumbers[aAttrEnum].GetBaseValue(), nullptr);
|
2006-07-28 22:10:48 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
SetParsedAttr(kNameSpaceID_None, *info.mNumberInfo[aAttrEnum].mName, nullptr,
|
2011-10-17 18:59:28 +04:00
|
|
|
attrValue, true);
|
2006-07-28 22:10:48 +04:00
|
|
|
}
|
|
|
|
|
2009-12-29 09:34:27 +03:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidAnimateNumber(uint8_t aAttrEnum)
|
2009-12-29 09:34:27 +03:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
NumberAttributesInfo info = GetNumberInfo();
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mNumberInfo[aAttrEnum].mName,
|
2017-05-06 22:32:14 +03:00
|
|
|
nsIDOMMutationEvent::SMIL);
|
2009-12-29 09:34:27 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-28 22:10:48 +04: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 19:56:38 +04:00
|
|
|
uint32_t i = 0;
|
2006-07-28 22:10:48 +04:00
|
|
|
|
|
|
|
va_list args;
|
|
|
|
va_start(args, aFirst);
|
|
|
|
|
|
|
|
while (f && i < info.mNumberCount) {
|
2010-02-25 21:20:43 +03:00
|
|
|
*f = info.mNumbers[i++].GetAnimValue();
|
2006-07-28 22:10:48 +04:00
|
|
|
f = va_arg(args, float*);
|
|
|
|
}
|
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
|
2011-07-01 11:19:52 +04:00
|
|
|
nsSVGElement::NumberPairAttributesInfo
|
|
|
|
nsSVGElement::GetNumberPairInfo()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return NumberPairAttributesInfo(nullptr, nullptr, 0);
|
2011-07-01 11:19:52 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsSVGElement::NumberPairAttributesInfo::Reset(uint8_t aAttrEnum)
|
2011-07-01 11:19:52 +04:00
|
|
|
{
|
|
|
|
mNumberPairs[aAttrEnum].Init(aAttrEnum,
|
|
|
|
mNumberPairInfo[aAttrEnum].mDefaultValue1,
|
|
|
|
mNumberPairInfo[aAttrEnum].mDefaultValue2);
|
|
|
|
}
|
|
|
|
|
2012-02-16 03:40:45 +04:00
|
|
|
nsAttrValue
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::WillChangeNumberPair(uint8_t aAttrEnum)
|
2011-07-01 11:19:52 +04:00
|
|
|
{
|
2012-02-16 03:40:45 +04:00
|
|
|
return WillChangeValue(*GetNumberPairInfo().mNumberPairInfo[aAttrEnum].mName);
|
|
|
|
}
|
2011-07-01 11:19:52 +04:00
|
|
|
|
2012-02-16 03:40:45 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidChangeNumberPair(uint8_t aAttrEnum,
|
2012-02-16 03:40:45 +04:00
|
|
|
const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2011-07-01 11:19:52 +04: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-16 03:40:45 +04:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 18:20:58 +04:00
|
|
|
newValue.SetTo(info.mNumberPairs[aAttrEnum], nullptr);
|
2011-07-01 11:19:52 +04:00
|
|
|
|
2012-02-16 03:40:45 +04:00
|
|
|
DidChangeValue(*info.mNumberPairInfo[aAttrEnum].mName, aEmptyOrOldValue,
|
|
|
|
newValue);
|
2011-07-01 11:19:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidAnimateNumberPair(uint8_t aAttrEnum)
|
2011-07-01 11:19:52 +04:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
NumberPairAttributesInfo info = GetNumberPairInfo();
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mNumberPairInfo[aAttrEnum].mName,
|
2017-05-06 22:32:14 +03:00
|
|
|
nsIDOMMutationEvent::SMIL);
|
2011-07-01 11:19:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-18 16:09:26 +04:00
|
|
|
nsSVGElement::IntegerAttributesInfo
|
|
|
|
nsSVGElement::GetIntegerInfo()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return IntegerAttributesInfo(nullptr, nullptr, 0);
|
2007-09-18 16:09:26 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsSVGElement::IntegerAttributesInfo::Reset(uint8_t aAttrEnum)
|
2007-11-22 11:54:31 +03:00
|
|
|
{
|
|
|
|
mIntegers[aAttrEnum].Init(aAttrEnum,
|
|
|
|
mIntegerInfo[aAttrEnum].mDefaultValue);
|
|
|
|
}
|
|
|
|
|
2007-09-18 16:09:26 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidChangeInteger(uint8_t aAttrEnum)
|
2007-09-18 16:09:26 +04: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-16 03:40:45 +04:00
|
|
|
nsAttrValue attrValue;
|
2012-07-30 18:20:58 +04:00
|
|
|
attrValue.SetTo(info.mIntegers[aAttrEnum].GetBaseValue(), nullptr);
|
2007-09-18 16:09:26 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
SetParsedAttr(kNameSpaceID_None, *info.mIntegerInfo[aAttrEnum].mName, nullptr,
|
2011-10-17 18:59:28 +04:00
|
|
|
attrValue, true);
|
2007-09-18 16:09:26 +04:00
|
|
|
}
|
|
|
|
|
2010-02-19 00:51:00 +03:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidAnimateInteger(uint8_t aAttrEnum)
|
2010-02-19 00:51:00 +03:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2010-02-19 00:51:00 +03:00
|
|
|
if (frame) {
|
|
|
|
IntegerAttributesInfo info = GetIntegerInfo();
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mIntegerInfo[aAttrEnum].mName,
|
2017-05-06 22:32:14 +03:00
|
|
|
nsIDOMMutationEvent::SMIL);
|
2010-02-19 00:51:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-18 16:09:26 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::GetAnimatedIntegerValues(int32_t *aFirst, ...)
|
2007-09-18 16:09:26 +04:00
|
|
|
{
|
|
|
|
IntegerAttributesInfo info = GetIntegerInfo();
|
|
|
|
|
|
|
|
NS_ASSERTION(info.mIntegerCount > 0,
|
|
|
|
"GetAnimatedIntegerValues on element with no integer attribs");
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t *n = aFirst;
|
|
|
|
uint32_t i = 0;
|
2007-09-18 16:09:26 +04:00
|
|
|
|
|
|
|
va_list args;
|
|
|
|
va_start(args, aFirst);
|
|
|
|
|
|
|
|
while (n && i < info.mIntegerCount) {
|
2010-02-25 21:20:43 +03:00
|
|
|
*n = info.mIntegers[i++].GetAnimValue();
|
2012-08-22 19:56:38 +04:00
|
|
|
n = va_arg(args, int32_t*);
|
2007-09-18 16:09:26 +04:00
|
|
|
}
|
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
|
2011-07-01 11:19:52 +04:00
|
|
|
nsSVGElement::IntegerPairAttributesInfo
|
|
|
|
nsSVGElement::GetIntegerPairInfo()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return IntegerPairAttributesInfo(nullptr, nullptr, 0);
|
2011-07-01 11:19:52 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsSVGElement::IntegerPairAttributesInfo::Reset(uint8_t aAttrEnum)
|
2011-07-01 11:19:52 +04:00
|
|
|
{
|
|
|
|
mIntegerPairs[aAttrEnum].Init(aAttrEnum,
|
|
|
|
mIntegerPairInfo[aAttrEnum].mDefaultValue1,
|
|
|
|
mIntegerPairInfo[aAttrEnum].mDefaultValue2);
|
|
|
|
}
|
|
|
|
|
2012-02-16 03:40:45 +04:00
|
|
|
nsAttrValue
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::WillChangeIntegerPair(uint8_t aAttrEnum)
|
2011-07-01 11:19:52 +04:00
|
|
|
{
|
2012-02-16 03:40:45 +04:00
|
|
|
return WillChangeValue(
|
|
|
|
*GetIntegerPairInfo().mIntegerPairInfo[aAttrEnum].mName);
|
|
|
|
}
|
2011-07-01 11:19:52 +04:00
|
|
|
|
2012-02-16 03:40:45 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidChangeIntegerPair(uint8_t aAttrEnum,
|
2012-02-16 03:40:45 +04:00
|
|
|
const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2011-07-01 11:19:52 +04: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-16 03:40:45 +04:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 18:20:58 +04:00
|
|
|
newValue.SetTo(info.mIntegerPairs[aAttrEnum], nullptr);
|
2011-07-01 11:19:52 +04:00
|
|
|
|
2012-02-16 03:40:45 +04:00
|
|
|
DidChangeValue(*info.mIntegerPairInfo[aAttrEnum].mName, aEmptyOrOldValue,
|
|
|
|
newValue);
|
2011-07-01 11:19:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidAnimateIntegerPair(uint8_t aAttrEnum)
|
2011-07-01 11:19:52 +04:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2011-07-01 11:19:52 +04:00
|
|
|
if (frame) {
|
|
|
|
IntegerPairAttributesInfo info = GetIntegerPairInfo();
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mIntegerPairInfo[aAttrEnum].mName,
|
2017-05-06 22:32:14 +03:00
|
|
|
nsIDOMMutationEvent::SMIL);
|
2011-07-01 11:19:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-10 14:07:59 +04:00
|
|
|
nsSVGElement::AngleAttributesInfo
|
|
|
|
nsSVGElement::GetAngleInfo()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return AngleAttributesInfo(nullptr, nullptr, 0);
|
2007-10-10 14:07:59 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsSVGElement::AngleAttributesInfo::Reset(uint8_t aAttrEnum)
|
2007-11-22 11:54:31 +03:00
|
|
|
{
|
2017-07-06 15:00:35 +03:00
|
|
|
mAngles[aAttrEnum].Init(aAttrEnum,
|
2007-11-22 11:54:31 +03:00
|
|
|
mAngleInfo[aAttrEnum].mDefaultValue,
|
|
|
|
mAngleInfo[aAttrEnum].mDefaultUnitType);
|
|
|
|
}
|
|
|
|
|
2012-02-16 03:40:45 +04:00
|
|
|
nsAttrValue
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::WillChangeAngle(uint8_t aAttrEnum)
|
2007-10-10 14:07:59 +04:00
|
|
|
{
|
2012-02-16 03:40:45 +04:00
|
|
|
return WillChangeValue(*GetAngleInfo().mAngleInfo[aAttrEnum].mName);
|
|
|
|
}
|
2007-10-10 14:07:59 +04:00
|
|
|
|
2012-02-16 03:40:45 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidChangeAngle(uint8_t aAttrEnum,
|
2012-02-16 03:40:45 +04:00
|
|
|
const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2007-10-10 14:07:59 +04: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-16 03:40:45 +04:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 18:20:58 +04:00
|
|
|
newValue.SetTo(info.mAngles[aAttrEnum], nullptr);
|
2007-10-10 14:07:59 +04:00
|
|
|
|
2012-02-16 03:40:45 +04:00
|
|
|
DidChangeValue(*info.mAngleInfo[aAttrEnum].mName, aEmptyOrOldValue, newValue);
|
2007-10-10 14:07:59 +04:00
|
|
|
}
|
|
|
|
|
2010-02-19 00:50:59 +03:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidAnimateAngle(uint8_t aAttrEnum)
|
2010-02-19 00:50:59 +03:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
AngleAttributesInfo info = GetAngleInfo();
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mAngleInfo[aAttrEnum].mName,
|
2017-05-06 22:32:14 +03:00
|
|
|
nsIDOMMutationEvent::SMIL);
|
2010-02-19 00:50:59 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-26 13:22:08 +04:00
|
|
|
nsSVGElement::BooleanAttributesInfo
|
|
|
|
nsSVGElement::GetBooleanInfo()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return BooleanAttributesInfo(nullptr, nullptr, 0);
|
2007-09-26 13:22:08 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsSVGElement::BooleanAttributesInfo::Reset(uint8_t aAttrEnum)
|
2007-11-22 11:54:31 +03:00
|
|
|
{
|
|
|
|
mBooleans[aAttrEnum].Init(aAttrEnum,
|
|
|
|
mBooleanInfo[aAttrEnum].mDefaultValue);
|
|
|
|
}
|
|
|
|
|
2007-09-26 13:22:08 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidChangeBoolean(uint8_t aAttrEnum)
|
2007-09-26 13:22:08 +04:00
|
|
|
{
|
|
|
|
BooleanAttributesInfo info = GetBooleanInfo();
|
|
|
|
|
|
|
|
NS_ASSERTION(info.mBooleanCount > 0,
|
2007-10-10 14:07:59 +04:00
|
|
|
"DidChangeBoolean on element with no boolean attribs");
|
2007-09-26 13:22:08 +04:00
|
|
|
NS_ASSERTION(aAttrEnum < info.mBooleanCount, "aAttrEnum out of range");
|
|
|
|
|
2012-02-16 03:40:45 +04:00
|
|
|
nsAttrValue attrValue(info.mBooleans[aAttrEnum].GetBaseValueAtom());
|
2012-07-30 18:20:58 +04:00
|
|
|
SetParsedAttr(kNameSpaceID_None, *info.mBooleanInfo[aAttrEnum].mName, nullptr,
|
2011-10-17 18:59:28 +04:00
|
|
|
attrValue, true);
|
2007-09-26 13:22:08 +04:00
|
|
|
}
|
|
|
|
|
2010-01-24 19:42:08 +03:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidAnimateBoolean(uint8_t aAttrEnum)
|
2010-01-24 19:42:08 +03:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2010-01-24 19:42:08 +03:00
|
|
|
if (frame) {
|
|
|
|
BooleanAttributesInfo info = GetBooleanInfo();
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mBooleanInfo[aAttrEnum].mName,
|
2017-05-06 22:32:14 +03:00
|
|
|
nsIDOMMutationEvent::SMIL);
|
2010-01-24 19:42:08 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-28 03:11:14 +04:00
|
|
|
nsSVGElement::EnumAttributesInfo
|
|
|
|
nsSVGElement::GetEnumInfo()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return EnumAttributesInfo(nullptr, nullptr, 0);
|
2007-08-28 03:11:14 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsSVGElement::EnumAttributesInfo::Reset(uint8_t aAttrEnum)
|
2007-11-22 11:54:31 +03:00
|
|
|
{
|
|
|
|
mEnums[aAttrEnum].Init(aAttrEnum,
|
|
|
|
mEnumInfo[aAttrEnum].mDefaultValue);
|
|
|
|
}
|
|
|
|
|
2007-08-28 03:11:14 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidChangeEnum(uint8_t aAttrEnum)
|
2007-08-28 03:11:14 +04:00
|
|
|
{
|
|
|
|
EnumAttributesInfo info = GetEnumInfo();
|
|
|
|
|
|
|
|
NS_ASSERTION(info.mEnumCount > 0,
|
2007-09-18 16:09:26 +04:00
|
|
|
"DidChangeEnum on element with no enum attribs");
|
2007-08-28 03:11:14 +04:00
|
|
|
NS_ASSERTION(aAttrEnum < info.mEnumCount, "aAttrEnum out of range");
|
|
|
|
|
2012-02-16 03:40:44 +04:00
|
|
|
nsAttrValue attrValue(info.mEnums[aAttrEnum].GetBaseValueAtom(this));
|
2012-07-30 18:20:58 +04:00
|
|
|
SetParsedAttr(kNameSpaceID_None, *info.mEnumInfo[aAttrEnum].mName, nullptr,
|
2011-10-17 18:59:28 +04:00
|
|
|
attrValue, true);
|
2007-08-28 03:11:14 +04:00
|
|
|
}
|
|
|
|
|
2010-01-23 21:59:03 +03:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidAnimateEnum(uint8_t aAttrEnum)
|
2010-01-23 21:59:03 +03:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
EnumAttributesInfo info = GetEnumInfo();
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
*info.mEnumInfo[aAttrEnum].mName,
|
2017-05-06 22:32:14 +03:00
|
|
|
nsIDOMMutationEvent::SMIL);
|
2010-01-23 21:59:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-03 17:42:24 +03:00
|
|
|
nsSVGViewBox *
|
|
|
|
nsSVGElement::GetViewBox()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2009-02-03 17:42:24 +03:00
|
|
|
}
|
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
nsAttrValue
|
|
|
|
nsSVGElement::WillChangeViewBox()
|
2009-02-03 17:42:24 +03:00
|
|
|
{
|
2012-02-16 03:40:46 +04:00
|
|
|
return WillChangeValue(nsGkAtoms::viewBox);
|
|
|
|
}
|
2009-02-03 17:42:24 +03:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
void
|
|
|
|
nsSVGElement::DidChangeViewBox(const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2009-02-03 17:42:24 +03:00
|
|
|
nsSVGViewBox *viewBox = GetViewBox();
|
|
|
|
|
|
|
|
NS_ASSERTION(viewBox, "DidChangeViewBox on element with no viewBox attrib");
|
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 18:20:58 +04:00
|
|
|
newValue.SetTo(*viewBox, nullptr);
|
2009-02-03 17:42:24 +03:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
DidChangeValue(nsGkAtoms::viewBox, aEmptyOrOldValue, newValue);
|
2009-02-03 17:42:24 +03:00
|
|
|
}
|
|
|
|
|
2010-02-19 00:51:00 +03:00
|
|
|
void
|
|
|
|
nsSVGElement::DidAnimateViewBox()
|
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2010-02-19 00:51:00 +03:00
|
|
|
if (frame) {
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
nsGkAtoms::viewBox,
|
2017-05-06 22:32:14 +03:00
|
|
|
nsIDOMMutationEvent::SMIL);
|
2010-02-19 00:51:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-20 03:45:29 +03:00
|
|
|
SVGAnimatedPreserveAspectRatio *
|
2009-01-05 04:19:38 +03:00
|
|
|
nsSVGElement::GetPreserveAspectRatio()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2009-01-05 04:19:38 +03:00
|
|
|
}
|
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
nsAttrValue
|
|
|
|
nsSVGElement::WillChangePreserveAspectRatio()
|
2009-01-05 04:19:38 +03:00
|
|
|
{
|
2012-02-16 03:40:46 +04:00
|
|
|
return WillChangeValue(nsGkAtoms::preserveAspectRatio);
|
|
|
|
}
|
2009-01-05 04:19:38 +03:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
void
|
|
|
|
nsSVGElement::DidChangePreserveAspectRatio(const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2010-12-20 03:45:29 +03:00
|
|
|
SVGAnimatedPreserveAspectRatio *preserveAspectRatio =
|
|
|
|
GetPreserveAspectRatio();
|
2009-01-05 04:19:38 +03:00
|
|
|
|
|
|
|
NS_ASSERTION(preserveAspectRatio,
|
2012-02-16 03:40:46 +04:00
|
|
|
"DidChangePreserveAspectRatio on element with no "
|
|
|
|
"preserveAspectRatio attrib");
|
2009-01-05 04:19:38 +03:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 18:20:58 +04:00
|
|
|
newValue.SetTo(*preserveAspectRatio, nullptr);
|
2009-01-05 04:19:38 +03:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
DidChangeValue(nsGkAtoms::preserveAspectRatio, aEmptyOrOldValue, newValue);
|
2009-01-05 04:19:38 +03:00
|
|
|
}
|
|
|
|
|
2010-02-08 05:28:01 +03:00
|
|
|
void
|
|
|
|
nsSVGElement::DidAnimatePreserveAspectRatio()
|
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2010-02-08 05:28:01 +03:00
|
|
|
if (frame) {
|
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
|
|
|
nsGkAtoms::preserveAspectRatio,
|
2017-05-06 22:32:14 +03:00
|
|
|
nsIDOMMutationEvent::SMIL);
|
2010-02-08 05:28:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
nsAttrValue
|
|
|
|
nsSVGElement::WillChangeTransformList()
|
2010-03-02 18:36:31 +03:00
|
|
|
{
|
2012-02-16 03:40:46 +04:00
|
|
|
return WillChangeValue(GetTransformListAttrName());
|
|
|
|
}
|
2011-09-26 01:04:31 +04:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
void
|
|
|
|
nsSVGElement::DidChangeTransformList(const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(GetTransformListAttrName(),
|
|
|
|
"Changing non-existent transform list?");
|
2011-09-26 01:04:31 +04:00
|
|
|
|
2012-07-30 04:35:26 +04:00
|
|
|
// The transform attribute is being set, so we must ensure that the
|
|
|
|
// SVGAnimatedTransformList is/has been allocated:
|
2012-02-16 03:40:46 +04:00
|
|
|
nsAttrValue newValue;
|
2012-07-30 18:20:58 +04:00
|
|
|
newValue.SetTo(GetAnimatedTransformList(DO_ALLOCATE)->GetBaseValue(), nullptr);
|
2011-09-26 01:04:31 +04:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
DidChangeValue(GetTransformListAttrName(), aEmptyOrOldValue, newValue);
|
2011-09-26 01:04:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-04-07 23:52:12 +04:00
|
|
|
nsSVGElement::DidAnimateTransformList(int32_t aModType)
|
2011-09-26 01:04:31 +04:00
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(GetTransformListAttrName(),
|
|
|
|
"Animating non-existent transform data?");
|
2011-09-26 01:04:31 +04:00
|
|
|
|
2010-03-02 18:36:31 +03:00
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
2011-09-26 01:04:31 +04:00
|
|
|
|
2010-03-02 18:36:31 +03:00
|
|
|
if (frame) {
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom *transformAttr = GetTransformListAttrName();
|
2010-03-02 18:36:31 +03:00
|
|
|
frame->AttributeChanged(kNameSpaceID_None,
|
2013-02-12 03:25:56 +04:00
|
|
|
transformAttr,
|
2014-04-07 23:52:12 +04:00
|
|
|
aModType);
|
2013-02-12 03:25:56 +04: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 23:52:12 +04:00
|
|
|
nsChangeHint changeHint = GetAttributeChangeHint(transformAttr, aModType);
|
2013-02-12 03:25:56 +04:00
|
|
|
if (changeHint) {
|
|
|
|
nsLayoutUtils::PostRestyleEvent(this, nsRestyleHint(0), changeHint);
|
|
|
|
}
|
2010-03-02 18:36:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-14 13:01:02 +04:00
|
|
|
nsSVGElement::StringAttributesInfo
|
|
|
|
nsSVGElement::GetStringInfo()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return StringAttributesInfo(nullptr, nullptr, 0);
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsSVGElement::StringAttributesInfo::Reset(uint8_t aAttrEnum)
|
2008-06-14 13:01:02 +04:00
|
|
|
{
|
|
|
|
mStrings[aAttrEnum].Init(aAttrEnum);
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsSVGElement::GetStringBaseValue(uint8_t aAttrEnum, nsAString& aResult) const
|
2008-06-14 13:01:02 +04:00
|
|
|
{
|
2009-01-22 03:56:51 +03:00
|
|
|
nsSVGElement::StringAttributesInfo info = const_cast<nsSVGElement*>(this)->GetStringInfo();
|
|
|
|
|
|
|
|
NS_ASSERTION(info.mStringCount > 0,
|
|
|
|
"GetBaseValue on element with no string attribs");
|
2009-01-19 12:03:31 +03:00
|
|
|
|
2009-01-22 03:56:51 +03:00
|
|
|
NS_ASSERTION(aAttrEnum < info.mStringCount, "aAttrEnum out of range");
|
|
|
|
|
|
|
|
GetAttr(info.mStringInfo[aAttrEnum].mNamespaceID,
|
|
|
|
*info.mStringInfo[aAttrEnum].mName, aResult);
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsSVGElement::SetStringBaseValue(uint8_t aAttrEnum, const nsAString& aValue)
|
2009-01-22 03:56:51 +03:00
|
|
|
{
|
|
|
|
nsSVGElement::StringAttributesInfo info = GetStringInfo();
|
2008-06-14 13:01:02 +04:00
|
|
|
|
|
|
|
NS_ASSERTION(info.mStringCount > 0,
|
2009-01-22 03:56:51 +03:00
|
|
|
"SetBaseValue on element with no string attribs");
|
2008-06-14 13:01:02 +04:00
|
|
|
|
|
|
|
NS_ASSERTION(aAttrEnum < info.mStringCount, "aAttrEnum out of range");
|
|
|
|
|
|
|
|
SetAttr(info.mStringInfo[aAttrEnum].mNamespaceID,
|
2011-10-17 18:59:28 +04:00
|
|
|
*info.mStringInfo[aAttrEnum].mName, aValue, true);
|
2008-06-14 13:01:02 +04:00
|
|
|
}
|
|
|
|
|
2010-10-07 23:19:32 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::DidAnimateString(uint8_t aAttrEnum)
|
2010-10-07 23:19:32 +04:00
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
StringAttributesInfo info = GetStringInfo();
|
|
|
|
frame->AttributeChanged(info.mStringInfo[aAttrEnum].mNamespaceID,
|
|
|
|
*info.mStringInfo[aAttrEnum].mName,
|
2017-05-06 22:32:14 +03:00
|
|
|
nsIDOMMutationEvent::SMIL);
|
2010-10-07 23:19:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-31 13:44:03 +04:00
|
|
|
nsSVGElement::StringListAttributesInfo
|
|
|
|
nsSVGElement::GetStringListInfo()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return StringListAttributesInfo(nullptr, nullptr, 0);
|
2011-12-31 13:44:03 +04:00
|
|
|
}
|
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
nsAttrValue
|
|
|
|
nsSVGElement::WillChangeStringList(bool aIsConditionalProcessingAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t aAttrEnum)
|
2011-12-31 13:44:03 +04:00
|
|
|
{
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* name;
|
2011-12-31 13:44:03 +04:00
|
|
|
if (aIsConditionalProcessingAttribute) {
|
2013-03-28 05:23:09 +04:00
|
|
|
nsCOMPtr<SVGTests> tests(do_QueryInterface(static_cast<nsIDOMSVGElement*>(this)));
|
2012-02-16 03:40:46 +04:00
|
|
|
name = tests->GetAttrName(aAttrEnum);
|
|
|
|
} else {
|
|
|
|
name = *GetStringListInfo().mStringListInfo[aAttrEnum].mName;
|
2011-12-31 13:44:03 +04:00
|
|
|
}
|
2012-02-16 03:40:46 +04:00
|
|
|
return WillChangeValue(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGElement::DidChangeStringList(bool aIsConditionalProcessingAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t aAttrEnum,
|
2012-02-16 03:40:46 +04:00
|
|
|
const nsAttrValue& aEmptyOrOldValue)
|
|
|
|
{
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* name;
|
2012-02-16 03:40:46 +04:00
|
|
|
nsAttrValue newValue;
|
2013-03-02 10:08:42 +04:00
|
|
|
nsCOMPtr<SVGTests> tests;
|
2011-12-31 13:44:03 +04:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
if (aIsConditionalProcessingAttribute) {
|
2013-03-28 05:23:09 +04:00
|
|
|
tests = do_QueryObject(this);
|
2012-02-16 03:40:46 +04:00
|
|
|
name = tests->GetAttrName(aAttrEnum);
|
|
|
|
tests->GetAttrValue(aAttrEnum, newValue);
|
|
|
|
} else {
|
|
|
|
StringListAttributesInfo info = GetStringListInfo();
|
2011-12-31 13:44:03 +04:00
|
|
|
|
2012-02-16 03:40:46 +04: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 13:44:03 +04:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
name = *info.mStringListInfo[aAttrEnum].mName;
|
2012-07-30 18:20:58 +04:00
|
|
|
newValue.SetTo(info.mStringLists[aAttrEnum], nullptr);
|
2012-02-16 03:40:46 +04:00
|
|
|
}
|
2011-12-31 13:44:03 +04:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
DidChangeValue(name, aEmptyOrOldValue, newValue);
|
2011-12-31 13:44:03 +04:00
|
|
|
|
2012-02-16 03:40:46 +04:00
|
|
|
if (aIsConditionalProcessingAttribute) {
|
|
|
|
tests->MaybeInvalidate();
|
|
|
|
}
|
2011-12-31 13:44:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGElement::StringListAttributesInfo::Reset(uint8_t aAttrEnum)
|
2011-12-31 13:44:03 +04:00
|
|
|
{
|
|
|
|
mStringLists[aAttrEnum].Clear();
|
|
|
|
// caller notifies
|
|
|
|
}
|
|
|
|
|
2006-08-08 18:36:43 +04:00
|
|
|
nsresult
|
|
|
|
nsSVGElement::ReportAttributeParseFailure(nsIDocument* aDocument,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute,
|
2006-08-08 18:36:43 +04:00
|
|
|
const nsAString& aValue)
|
|
|
|
{
|
2017-06-20 12:19:05 +03:00
|
|
|
const nsString& attributeValue = PromiseFlatString(aValue);
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t *strings[] = { aAttribute->GetUTF16String(),
|
2010-03-08 18:45:00 +03:00
|
|
|
attributeValue.get() };
|
2012-09-22 23:26:05 +04:00
|
|
|
return SVGContentUtils::ReportToConsole(aDocument,
|
|
|
|
"AttributeParseWarning",
|
|
|
|
strings, ArrayLength(strings));
|
2006-08-08 18:36:43 +04:00
|
|
|
}
|
2006-10-07 14:27:45 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGElement::RecompileScriptEventListeners()
|
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t i, count = mAttrsAndChildren.AttrCount();
|
2007-07-02 13:54:11 +04:00
|
|
|
for (i = 0; i < count; ++i) {
|
|
|
|
const nsAttrName *name = mAttrsAndChildren.AttrNameAt(i);
|
2006-10-07 14:27:45 +04:00
|
|
|
|
2007-07-02 13:54:11 +04:00
|
|
|
// Eventlistenener-attributes are always in the null namespace
|
|
|
|
if (!name->IsAtom()) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-10-07 14:27:45 +04:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom *attr = name->Atom();
|
2013-01-03 00:24:07 +04:00
|
|
|
if (!IsEventAttributeName(attr)) {
|
2007-07-02 13:54:11 +04:00
|
|
|
continue;
|
2006-10-07 14:27:45 +04:00
|
|
|
}
|
2007-07-02 13:54:11 +04:00
|
|
|
|
|
|
|
nsAutoString value;
|
|
|
|
GetAttr(kNameSpaceID_None, attr, value);
|
2012-08-30 20:25:10 +04:00
|
|
|
SetEventHandler(GetEventNameForAttr(attr), value, true);
|
2007-07-02 13:54:11 +04:00
|
|
|
}
|
2006-10-07 14:27:45 +04:00
|
|
|
}
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2017-03-30 07:10:07 +03:00
|
|
|
UniquePtr<nsISMILAttr>
|
2017-10-03 01:05:19 +03:00
|
|
|
nsSVGElement::GetAnimatedAttr(int32_t aNamespaceID, nsAtom* aName)
|
2009-01-15 07:38:07 +03:00
|
|
|
{
|
2010-10-07 23:19:32 +04:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
|
|
|
// Transforms:
|
2011-09-26 01:04:31 +04:00
|
|
|
if (GetTransformListAttrName() == aName) {
|
2012-07-30 04:35:26 +04: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 23:19:32 +04:00
|
|
|
}
|
2009-01-19 12:14:16 +03:00
|
|
|
|
2010-10-07 23:19:32 +04:00
|
|
|
// Motion (fake 'attribute' for animateMotion)
|
|
|
|
if (aName == nsGkAtoms::mozAnimateMotionDummyAttr) {
|
2017-03-30 07:10:07 +03:00
|
|
|
return MakeUnique<SVGMotionSMILAttr>(this);
|
2010-10-07 23:19:32 +04:00
|
|
|
}
|
2010-04-29 03:00:54 +04:00
|
|
|
|
2010-10-07 23:19:32 +04:00
|
|
|
// Lengths:
|
|
|
|
LengthAttributesInfo info = GetLengthInfo();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < info.mLengthCount; i++) {
|
2010-10-07 23:19:32 +04:00
|
|
|
if (aName == *info.mLengthInfo[i].mName) {
|
|
|
|
return info.mLengths[i].ToSMILAttr(this);
|
|
|
|
}
|
2009-01-15 07:38:07 +03:00
|
|
|
}
|
|
|
|
|
2010-10-07 23:19:32 +04:00
|
|
|
// Numbers:
|
|
|
|
{
|
|
|
|
NumberAttributesInfo info = GetNumberInfo();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < info.mNumberCount; i++) {
|
2010-10-07 23:19:32 +04:00
|
|
|
if (aName == *info.mNumberInfo[i].mName) {
|
|
|
|
return info.mNumbers[i].ToSMILAttr(this);
|
|
|
|
}
|
2009-12-29 09:34:27 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-01 11:19:52 +04:00
|
|
|
// Number Pairs:
|
|
|
|
{
|
|
|
|
NumberPairAttributesInfo info = GetNumberPairInfo();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < info.mNumberPairCount; i++) {
|
2011-07-01 11:19:52 +04:00
|
|
|
if (aName == *info.mNumberPairInfo[i].mName) {
|
|
|
|
return info.mNumberPairs[i].ToSMILAttr(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-07 23:19:32 +04:00
|
|
|
// Integers:
|
|
|
|
{
|
|
|
|
IntegerAttributesInfo info = GetIntegerInfo();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < info.mIntegerCount; i++) {
|
2010-10-07 23:19:32 +04:00
|
|
|
if (aName == *info.mIntegerInfo[i].mName) {
|
|
|
|
return info.mIntegers[i].ToSMILAttr(this);
|
|
|
|
}
|
2010-02-19 00:51:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-01 11:19:52 +04:00
|
|
|
// Integer Pairs:
|
|
|
|
{
|
|
|
|
IntegerPairAttributesInfo info = GetIntegerPairInfo();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < info.mIntegerPairCount; i++) {
|
2011-07-01 11:19:52 +04:00
|
|
|
if (aName == *info.mIntegerPairInfo[i].mName) {
|
|
|
|
return info.mIntegerPairs[i].ToSMILAttr(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-07 23:19:32 +04:00
|
|
|
// Enumerations:
|
|
|
|
{
|
|
|
|
EnumAttributesInfo info = GetEnumInfo();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < info.mEnumCount; i++) {
|
2010-10-07 23:19:32 +04:00
|
|
|
if (aName == *info.mEnumInfo[i].mName) {
|
|
|
|
return info.mEnums[i].ToSMILAttr(this);
|
|
|
|
}
|
2010-01-23 21:59:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-07 23:19:32 +04:00
|
|
|
// Booleans:
|
|
|
|
{
|
|
|
|
BooleanAttributesInfo info = GetBooleanInfo();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < info.mBooleanCount; i++) {
|
2010-10-07 23:19:32 +04:00
|
|
|
if (aName == *info.mBooleanInfo[i].mName) {
|
|
|
|
return info.mBooleans[i].ToSMILAttr(this);
|
|
|
|
}
|
2010-01-24 19:42:08 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-07 23:19:32 +04:00
|
|
|
// Angles:
|
|
|
|
{
|
|
|
|
AngleAttributesInfo info = GetAngleInfo();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < info.mAngleCount; i++) {
|
2010-10-07 23:19:32 +04:00
|
|
|
if (aName == *info.mAngleInfo[i].mName) {
|
|
|
|
return info.mAngles[i].ToSMILAttr(this);
|
|
|
|
}
|
2010-02-19 00:50:59 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-07 23:19:32 +04:00
|
|
|
// viewBox:
|
|
|
|
if (aName == nsGkAtoms::viewBox) {
|
|
|
|
nsSVGViewBox *viewBox = GetViewBox();
|
2012-07-30 18:20:58 +04:00
|
|
|
return viewBox ? viewBox->ToSMILAttr(this) : nullptr;
|
2010-10-07 23:19:32 +04:00
|
|
|
}
|
2010-02-19 00:51:00 +03:00
|
|
|
|
2010-10-07 23:19:32 +04:00
|
|
|
// preserveAspectRatio:
|
|
|
|
if (aName == nsGkAtoms::preserveAspectRatio) {
|
2010-12-20 03:45:29 +03:00
|
|
|
SVGAnimatedPreserveAspectRatio *preserveAspectRatio =
|
|
|
|
GetPreserveAspectRatio();
|
|
|
|
return preserveAspectRatio ?
|
2012-07-30 18:20:58 +04:00
|
|
|
preserveAspectRatio->ToSMILAttr(this) : nullptr;
|
2010-10-07 23:19:32 +04:00
|
|
|
}
|
|
|
|
|
2010-12-03 19:40:23 +03:00
|
|
|
// NumberLists:
|
|
|
|
{
|
|
|
|
NumberListAttributesInfo info = GetNumberListInfo();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < info.mNumberListCount; i++) {
|
2010-12-03 19:40:23 +03:00
|
|
|
if (aName == *info.mNumberListInfo[i].mName) {
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(i <= UCHAR_MAX, "Too many attributes");
|
2012-08-22 19:56:38 +04:00
|
|
|
return info.mNumberLists[i].ToSMILAttr(this, uint8_t(i));
|
2010-12-03 19:40:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-07 23:19:32 +04:00
|
|
|
// LengthLists:
|
|
|
|
{
|
|
|
|
LengthListAttributesInfo info = GetLengthListInfo();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < info.mLengthListCount; i++) {
|
2010-10-07 23:19:32 +04:00
|
|
|
if (aName == *info.mLengthListInfo[i].mName) {
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(i <= UCHAR_MAX, "Too many attributes");
|
2010-10-07 23:19:32 +04:00
|
|
|
return info.mLengthLists[i].ToSMILAttr(this,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t(i),
|
2010-10-07 23:19:32 +04:00
|
|
|
info.mLengthListInfo[i].mAxis,
|
|
|
|
info.mLengthListInfo[i].mCouldZeroPadList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-02-08 05:28:01 +03:00
|
|
|
|
2011-01-23 20:08:17 +03:00
|
|
|
// PointLists:
|
|
|
|
{
|
|
|
|
if (GetPointListAttrName() == aName) {
|
|
|
|
SVGAnimatedPointList *pointList = GetAnimatedPointList();
|
|
|
|
if (pointList) {
|
|
|
|
return pointList->ToSMILAttr(this);
|
|
|
|
}
|
2010-07-17 01:42:12 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-23 20:08:17 +03:00
|
|
|
// PathSegLists:
|
|
|
|
{
|
|
|
|
if (GetPathDataAttrName() == aName) {
|
|
|
|
SVGAnimatedPathSegList *segList = GetAnimPathSegList();
|
|
|
|
if (segList) {
|
|
|
|
return segList->ToSMILAttr(this);
|
|
|
|
}
|
2010-12-08 15:15:53 +03:00
|
|
|
}
|
|
|
|
}
|
2012-12-23 12:22:22 +04:00
|
|
|
|
|
|
|
if (aName == nsGkAtoms::_class) {
|
|
|
|
return mClassAttribute.ToSMILAttr(this);
|
|
|
|
}
|
2010-11-08 18:07:00 +03:00
|
|
|
}
|
|
|
|
|
2011-01-23 20:08:17 +03:00
|
|
|
// Strings
|
|
|
|
{
|
|
|
|
StringAttributesInfo info = GetStringInfo();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < info.mStringCount; i++) {
|
2011-01-23 20:08:17 +03:00
|
|
|
if (aNamespaceID == info.mStringInfo[i].mNamespaceID &&
|
|
|
|
aName == *info.mStringInfo[i].mName) {
|
|
|
|
return info.mStrings[i].ToSMILAttr(this);
|
|
|
|
}
|
2010-03-17 02:17:33 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2009-01-15 07:38:07 +03:00
|
|
|
}
|
2009-01-22 04:00:27 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGElement::AnimationNeedsResample()
|
|
|
|
{
|
2014-10-03 16:32:26 +04:00
|
|
|
nsIDocument* doc = GetComposedDoc();
|
2010-03-03 10:09:51 +03:00
|
|
|
if (doc && doc->HasAnimationController()) {
|
|
|
|
doc->GetAnimationController()->SetResampleNeeded();
|
2009-01-22 04:00:27 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGElement::FlushAnimations()
|
|
|
|
{
|
2014-10-03 16:32:26 +04:00
|
|
|
nsIDocument* doc = GetComposedDoc();
|
2010-03-03 10:09:51 +03:00
|
|
|
if (doc && doc->HasAnimationController()) {
|
|
|
|
doc->GetAnimationController()->FlushResampleRequests();
|
2009-01-22 04:00:27 +03:00
|
|
|
}
|
|
|
|
}
|