Bug 824898: Convert SVG animation classes to WebIDL r=bz

This commit is contained in:
David Zbarsky 2013-01-06 04:32:03 -05:00
Родитель 5fdcfc99f1
Коммит 062f6deba3
19 изменённых файлов: 236 добавлений и 32 удалений

Просмотреть файл

@ -45,8 +45,8 @@ function testVariablesFiltering()
"There should be 0 variables displayed in the test scope");
is(loadScope.querySelectorAll(".variable:not([non-match])").length, 1,
"There should be 1 variable displayed in the load scope");
is(globalScope.querySelectorAll(".variable:not([non-match])").length, 6,
"There should be 6 variables displayed in the global scope");
is(globalScope.querySelectorAll(".variable:not([non-match])").length, 8,
"There should be 8 variables displayed in the global scope");
is(innerScope.querySelectorAll(".property:not([non-match])").length, 0,
"There should be 0 properties displayed in the inner scope");

Просмотреть файл

@ -22,13 +22,25 @@ EXPORTS = \
nsISMILAttr.h \
nsISMILType.h \
nsSMILAnimationController.h \
nsSMILAnimationFunction.h \
nsSMILCompositorTable.h \
nsSMILCSSProperty.h \
nsSMILInstanceTime.h \
nsSMILInterval.h \
nsSMILKeySpline.h \
nsSMILMappedAttribute.h \
nsSMILMilestone.h \
nsSMILNullType.h \
nsSMILRepeatCount.h \
nsSMILSetAnimationFunction.h \
nsSMILTargetIdentifier.h \
nsSMILTimeContainer.h \
nsSMILTimedElement.h \
nsSMILTimeValue.h \
nsSMILTimeValueSpec.h \
nsSMILTimeValueSpecParams.h \
nsSMILTypes.h \
nsSMILValue.h \
$(NULL)
CPPSRCS = \

Просмотреть файл

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/SVGAnimateElement.h"
#include "mozilla/dom/SVGAnimateElementBinding.h"
DOMCI_NODE_DATA(SVGAnimateElement, mozilla::dom::SVGAnimateElement)
@ -12,6 +13,12 @@ NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Animate)
namespace mozilla {
namespace dom {
JSObject*
SVGAnimateElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return SVGAnimateElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
//----------------------------------------------------------------------
// nsISupports methods

Просмотреть файл

@ -27,6 +27,8 @@ protected:
(::NS_NewSVGAnimateElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo));
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
public:
// interfaces:
NS_DECL_ISUPPORTS_INHERITED

Просмотреть файл

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/SVGAnimateMotionElement.h"
#include "mozilla/dom/SVGAnimateMotionElementBinding.h"
DOMCI_NODE_DATA(SVGAnimateMotionElement, mozilla::dom::SVGAnimateMotionElement)
@ -12,6 +13,12 @@ NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(AnimateMotion)
namespace mozilla {
namespace dom {
JSObject*
SVGAnimateMotionElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return SVGAnimateMotionElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
//----------------------------------------------------------------------
// nsISupports methods

Просмотреть файл

@ -27,6 +27,8 @@ protected:
(::NS_NewSVGAnimateMotionElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo));
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
public:
// interfaces:
NS_DECL_ISUPPORTS_INHERITED

Просмотреть файл

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/SVGAnimateTransformElement.h"
#include "mozilla/dom/SVGAnimateTransformElementBinding.h"
DOMCI_NODE_DATA(SVGAnimateTransformElement, mozilla::dom::SVGAnimateTransformElement)
@ -12,6 +13,12 @@ NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(AnimateTransform)
namespace mozilla {
namespace dom {
JSObject*
SVGAnimateTransformElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return SVGAnimateTransformElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
//----------------------------------------------------------------------
// nsISupports methods

Просмотреть файл

@ -27,6 +27,8 @@ protected:
(::NS_NewSVGAnimateTransformElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo));
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
public:
// interfaces:
NS_DECL_ISUPPORTS_INHERITED

Просмотреть файл

@ -57,6 +57,7 @@ SVGAnimationElement::SVGAnimationElement(already_AddRefed<nsINodeInfo> aNodeInfo
#pragma warning(pop)
#endif
{
SetIsDOMBinding();
}
nsresult
@ -172,62 +173,92 @@ SVGAnimationElement::TimedElement()
/* readonly attribute SVGElement targetElement; */
NS_IMETHODIMP
SVGAnimationElement::GetTargetElement(nsIDOMSVGElement** aTarget)
{
// We'll just call the other GetTargetElement method, and QI to the right type
nsSVGElement* target = GetTargetElement();
nsCOMPtr<nsIDOMSVGElement> targetSVG = do_QueryInterface(target);
targetSVG.forget(aTarget);
return NS_OK;
}
nsSVGElement*
SVGAnimationElement::GetTargetElement()
{
FlushAnimations();
// We'll just call the other GetTargetElement method, and QI to the right type
nsIContent* targetContent = GetTargetElementContent();
nsIContent* target = GetTargetElementContent();
nsCOMPtr<nsIDOMSVGElement> targetSVG = do_QueryInterface(targetContent);
NS_IF_ADDREF(*aTarget = targetSVG);
return NS_OK;
return (target && target->IsSVG()) ? static_cast<nsSVGElement*>(target) : nullptr;
}
/* float getStartTime() raises( DOMException ); */
NS_IMETHODIMP
SVGAnimationElement::GetStartTime(float* retval)
{
ErrorResult rv;
*retval = GetStartTime(rv);
return rv.ErrorCode();
}
float
SVGAnimationElement::GetStartTime(ErrorResult& rv)
{
FlushAnimations();
nsSMILTimeValue startTime = mTimedElement.GetStartTime();
if (!startTime.IsDefinite())
return NS_ERROR_DOM_INVALID_STATE_ERR;
if (!startTime.IsDefinite()) {
rv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return 0.f;
}
*retval = float(double(startTime.GetMillis()) / PR_MSEC_PER_SEC);
return NS_OK;
return float(double(startTime.GetMillis()) / PR_MSEC_PER_SEC);
}
/* float getCurrentTime(); */
NS_IMETHODIMP
SVGAnimationElement::GetCurrentTime(float* retval)
{
*retval = GetCurrentTime();
return NS_OK;
}
float
SVGAnimationElement::GetCurrentTime()
{
// Not necessary to call FlushAnimations() for this
nsSMILTimeContainer* root = GetTimeContainer();
if (root) {
*retval = float(double(root->GetCurrentTime()) / PR_MSEC_PER_SEC);
} else {
*retval = 0.f;
return float(double(root->GetCurrentTime()) / PR_MSEC_PER_SEC);
}
return NS_OK;
return 0.0f;
}
/* float getSimpleDuration() raises( DOMException ); */
NS_IMETHODIMP
SVGAnimationElement::GetSimpleDuration(float* retval)
{
ErrorResult rv;
*retval = GetSimpleDuration(rv);
return rv.ErrorCode();
}
float
SVGAnimationElement::GetSimpleDuration(ErrorResult& rv)
{
// Not necessary to call FlushAnimations() for this
nsSMILTimeValue simpleDur = mTimedElement.GetSimpleDuration();
if (!simpleDur.IsDefinite()) {
*retval = 0.f;
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
rv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return 0.f;
}
*retval = float(double(simpleDur.GetMillis()) / PR_MSEC_PER_SEC);
return NS_OK;
return float(double(simpleDur.GetMillis()) / PR_MSEC_PER_SEC);
}
//----------------------------------------------------------------------
@ -445,21 +476,27 @@ SVGAnimationElement::BeginElementAt(float offset)
{
NS_ENSURE_FINITE(offset, NS_ERROR_ILLEGAL_VALUE);
ErrorResult rv;
BeginElementAt(offset, rv);
return rv.ErrorCode();
}
void
SVGAnimationElement::BeginElementAt(float offset, ErrorResult& rv)
{
// Make sure the timegraph is up-to-date
FlushAnimations();
// This will fail if we're not attached to a time container (SVG document
// fragment).
nsresult rv = mTimedElement.BeginElementAt(offset);
if (NS_FAILED(rv))
return rv;
rv = mTimedElement.BeginElementAt(offset);
if (rv.Failed())
return;
AnimationNeedsResample();
// Force synchronous sample so that events resulting from this call arrive in
// the expected order and we get an up-to-date paint.
FlushAnimations();
return NS_OK;
}
/* void endElement (); */
@ -475,18 +512,24 @@ SVGAnimationElement::EndElementAt(float offset)
{
NS_ENSURE_FINITE(offset, NS_ERROR_ILLEGAL_VALUE);
ErrorResult rv;
EndElementAt(offset, rv);
return rv.ErrorCode();
}
void
SVGAnimationElement::EndElementAt(float offset, ErrorResult& rv)
{
// Make sure the timegraph is up-to-date
FlushAnimations();
nsresult rv = mTimedElement.EndElementAt(offset);
if (NS_FAILED(rv))
return rv;
rv = mTimedElement.EndElementAt(offset);
if (rv.Failed())
return;
AnimationNeedsResample();
// Force synchronous sample
FlushAnimations();
return NS_OK;
}
bool

Просмотреть файл

@ -75,7 +75,17 @@ public:
// Utility methods for within SVG
void ActivateByHyperlink();
protected:
// WebIDL
nsSVGElement* GetTargetElement();
float GetStartTime(ErrorResult& rv);
float GetCurrentTime();
float GetSimpleDuration(ErrorResult& rv);
void BeginElement(ErrorResult& rv) { BeginElementAt(0.f, rv); }
void BeginElementAt(float offset, ErrorResult& rv);
void EndElement(ErrorResult& rv) { EndElementAt(0.f, rv); }
void EndElementAt(float offset, ErrorResult& rv);
protected:
// nsSVGElement overrides
void UpdateHrefTarget(nsIContent* aNodeForContext,

Просмотреть файл

@ -4,7 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/SVGSetElement.h"
#include "nsSMILSetAnimationFunction.h"
#include "mozilla/dom/SVGSetElementBinding.h"
DOMCI_NODE_DATA(SVGSetElement, mozilla::dom::SVGSetElement)
@ -13,6 +13,12 @@ NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Set)
namespace mozilla {
namespace dom {
JSObject*
SVGSetElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return SVGSetElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
//----------------------------------------------------------------------
// nsISupports methods

Просмотреть файл

@ -27,6 +27,8 @@ protected:
friend nsresult (::NS_NewSVGSetElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo));
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
public:
// interfaces:
NS_DECL_ISUPPORTS_INHERITED

Просмотреть файл

@ -602,6 +602,11 @@ DOMInterfaces = {
'headerFile': 'DOMSVGAnimatedTransformList.h'
},
'SVGAnimationElement': {
'resultNotAddRefed': ['targetElement'],
'concrete': False
},
'SVGElement': {
'nativeType': 'nsSVGElement',
'hasXPConnectImpls': True,

Просмотреть файл

@ -0,0 +1,15 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* http://www.w3.org/TR/SVG2/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
interface SVGAnimateElement : SVGAnimationElement {
};

Просмотреть файл

@ -0,0 +1,15 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* http://www.w3.org/TR/SVG2/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
interface SVGAnimateMotionElement : SVGAnimationElement {
};

Просмотреть файл

@ -0,0 +1,15 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* http://www.w3.org/TR/SVG2/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
interface SVGAnimateTransformElement : SVGAnimationElement {
};

Просмотреть файл

@ -0,0 +1,34 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* http://www.w3.org/TR/SVG2/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
interface SVGAnimationElement : SVGElement {
readonly attribute SVGElement? targetElement;
[Throws]
float getStartTime();
float getCurrentTime();
[Throws]
float getSimpleDuration();
[Throws]
void beginElement();
[Throws]
void beginElementAt(float offset);
[Throws]
void endElement();
[Throws]
void endElementAt(float offset);
};
SVGAnimationElement implements SVGTests;

Просмотреть файл

@ -0,0 +1,15 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* http://www.w3.org/TR/SVG2/
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
interface SVGSetElement : SVGAnimationElement {
};

Просмотреть файл

@ -104,6 +104,10 @@ webidl_files = \
SVGAnimatedPoints.webidl \
SVGAnimatedPreserveAspectRatio.webidl \
SVGAnimatedTransformList.webidl \
SVGAnimateElement.webidl \
SVGAnimateMotionElement.webidl \
SVGAnimateTransformElement.webidl \
SVGAnimationElement.webidl \
SVGCircleElement.webidl \
SVGDefsElement.webidl \
SVGDescElement.webidl \
@ -129,6 +133,7 @@ webidl_files = \
SVGPreserveAspectRatio.webidl \
SVGRectElement.webidl \
SVGScriptElement.webidl \
SVGSetElement.webidl \
SVGStopElement.webidl \
SVGStyleElement.webidl \
SVGSwitchElement.webidl \