Bug 847120: Convert SVGFEDiffuseLightingElement to WebIDL r=Ms2ger

This commit is contained in:
David Zbarsky 2013-03-23 17:00:35 -04:00
parent ad7a714703
commit 0170c10fc4
8 changed files with 87 additions and 74 deletions

View File

@ -4,77 +4,75 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/SVGFEDiffuseLightingElement.h" #include "mozilla/dom/SVGFEDiffuseLightingElement.h"
#include "mozilla/dom/SVGFEDiffuseLightingElementBinding.h"
#include "nsSVGUtils.h"
NS_IMPL_NS_NEW_SVG_ELEMENT(FEDiffuseLighting) NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEDiffuseLighting)
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
JSObject*
SVGFEDiffuseLightingElement::WrapNode(JSContext* aCx, JSObject* aScope)
{
return SVGFEDiffuseLightingElementBinding::Wrap(aCx, aScope, this);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsISupports methods // nsISupports methods
NS_IMPL_ADDREF_INHERITED(nsSVGFEDiffuseLightingElement,nsSVGFEDiffuseLightingElementBase) NS_IMPL_ADDREF_INHERITED(SVGFEDiffuseLightingElement,SVGFEDiffuseLightingElementBase)
NS_IMPL_RELEASE_INHERITED(nsSVGFEDiffuseLightingElement,nsSVGFEDiffuseLightingElementBase) NS_IMPL_RELEASE_INHERITED(SVGFEDiffuseLightingElement,SVGFEDiffuseLightingElementBase)
DOMCI_NODE_DATA(SVGFEDiffuseLightingElement, nsSVGFEDiffuseLightingElement) NS_INTERFACE_TABLE_HEAD(SVGFEDiffuseLightingElement)
NS_NODE_INTERFACE_TABLE3(SVGFEDiffuseLightingElement, nsIDOMNode,
NS_INTERFACE_TABLE_HEAD(nsSVGFEDiffuseLightingElement) nsIDOMElement, nsIDOMSVGElement)
NS_NODE_INTERFACE_TABLE5(nsSVGFEDiffuseLightingElement, nsIDOMNode, NS_INTERFACE_MAP_END_INHERITING(SVGFEDiffuseLightingElementBase)
nsIDOMElement, nsIDOMSVGElement,
nsIDOMSVGFilterPrimitiveStandardAttributes,
nsIDOMSVGFEDiffuseLightingElement)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGFEDiffuseLightingElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGFEDiffuseLightingElementBase)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsIDOMNode methods // nsIDOMNode methods
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEDiffuseLightingElement) NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEDiffuseLightingElement)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsSVGFEDiffuseLightingElement methods
NS_IMETHODIMP already_AddRefed<nsIDOMSVGAnimatedString>
nsSVGFEDiffuseLightingElement::GetIn1(nsIDOMSVGAnimatedString * *aIn) SVGFEDiffuseLightingElement::In1()
{ {
return mStringAttributes[IN1].ToDOMAnimatedString(aIn, this); return mStringAttributes[IN1].ToDOMAnimatedString(this);
} }
NS_IMETHODIMP already_AddRefed<nsIDOMSVGAnimatedNumber>
nsSVGFEDiffuseLightingElement::GetSurfaceScale(nsIDOMSVGAnimatedNumber **aScale) SVGFEDiffuseLightingElement::SurfaceScale()
{ {
return mNumberAttributes[SURFACE_SCALE].ToDOMAnimatedNumber(aScale, return mNumberAttributes[SURFACE_SCALE].ToDOMAnimatedNumber(this);
this);
} }
NS_IMETHODIMP already_AddRefed<nsIDOMSVGAnimatedNumber>
nsSVGFEDiffuseLightingElement::GetDiffuseConstant(nsIDOMSVGAnimatedNumber **aConstant) SVGFEDiffuseLightingElement::DiffuseConstant()
{ {
return mNumberAttributes[DIFFUSE_CONSTANT].ToDOMAnimatedNumber(aConstant, return mNumberAttributes[DIFFUSE_CONSTANT].ToDOMAnimatedNumber(this);
this);
} }
NS_IMETHODIMP already_AddRefed<nsIDOMSVGAnimatedNumber>
nsSVGFEDiffuseLightingElement::GetKernelUnitLengthX(nsIDOMSVGAnimatedNumber **aKernelX) SVGFEDiffuseLightingElement::KernelUnitLengthX()
{ {
return mNumberPairAttributes[KERNEL_UNIT_LENGTH].ToDOMAnimatedNumber(aKernelX, return mNumberPairAttributes[KERNEL_UNIT_LENGTH].ToDOMAnimatedNumber(
nsSVGNumberPair::eFirst, nsSVGNumberPair::eFirst, this);
this);
} }
NS_IMETHODIMP already_AddRefed<nsIDOMSVGAnimatedNumber>
nsSVGFEDiffuseLightingElement::GetKernelUnitLengthY(nsIDOMSVGAnimatedNumber **aKernelY) SVGFEDiffuseLightingElement::KernelUnitLengthY()
{ {
return mNumberPairAttributes[KERNEL_UNIT_LENGTH].ToDOMAnimatedNumber(aKernelY, return mNumberPairAttributes[KERNEL_UNIT_LENGTH].ToDOMAnimatedNumber(
nsSVGNumberPair::eSecond, nsSVGNumberPair::eSecond, this);
this);
} }
bool bool
nsSVGFEDiffuseLightingElement::AttributeAffectsRendering(int32_t aNameSpaceID, SVGFEDiffuseLightingElement::AttributeAffectsRendering(int32_t aNameSpaceID,
nsIAtom* aAttribute) const nsIAtom* aAttribute) const
{ {
return nsSVGFEDiffuseLightingElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) || return SVGFEDiffuseLightingElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
(aNameSpaceID == kNameSpaceID_None && (aNameSpaceID == kNameSpaceID_None &&
aAttribute == nsGkAtoms::diffuseConstant); aAttribute == nsGkAtoms::diffuseConstant);
} }
@ -83,8 +81,8 @@ nsSVGFEDiffuseLightingElement::AttributeAffectsRendering(int32_t aNameSpaceID,
// nsSVGElement methods // nsSVGElement methods
void void
nsSVGFEDiffuseLightingElement::LightPixel(const float *N, const float *L, SVGFEDiffuseLightingElement::LightPixel(const float *N, const float *L,
nscolor color, uint8_t *targetData) nscolor color, uint8_t *targetData)
{ {
float diffuseNL = float diffuseNL =
mNumberAttributes[DIFFUSE_CONSTANT].GetAnimValue() * DOT(N, L); mNumberAttributes[DIFFUSE_CONSTANT].GetAnimValue() * DOT(N, L);

View File

@ -8,29 +8,32 @@
#include "nsSVGFilters.h" #include "nsSVGFilters.h"
nsresult NS_NewSVGFEDiffuseLightingElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
typedef nsSVGFELightingElement nsSVGFEDiffuseLightingElementBase; typedef nsSVGFELightingElement SVGFEDiffuseLightingElementBase;
class nsSVGFEDiffuseLightingElement : public nsSVGFEDiffuseLightingElementBase, class SVGFEDiffuseLightingElement : public SVGFEDiffuseLightingElementBase,
public nsIDOMSVGFEDiffuseLightingElement public nsIDOMSVGElement
{ {
friend nsresult NS_NewSVGFEDiffuseLightingElement(nsIContent **aResult, friend nsresult (::NS_NewSVGFEDiffuseLightingElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo); already_AddRefed<nsINodeInfo> aNodeInfo));
protected: protected:
nsSVGFEDiffuseLightingElement(already_AddRefed<nsINodeInfo> aNodeInfo) SVGFEDiffuseLightingElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsSVGFEDiffuseLightingElementBase(aNodeInfo) {} : SVGFEDiffuseLightingElementBase(aNodeInfo)
{
SetIsDOMBinding();
}
virtual JSObject* WrapNode(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
public: public:
// interfaces: // interfaces:
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
// DiffuseLighting NS_FORWARD_NSIDOMSVGELEMENT(SVGFEDiffuseLightingElementBase::)
NS_DECL_NSIDOMSVGFEDIFFUSELIGHTINGELEMENT
NS_FORWARD_NSIDOMSVGFILTERPRIMITIVESTANDARDATTRIBUTES(nsSVGFEDiffuseLightingElementBase::)
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFEDiffuseLightingElementBase::)
NS_FORWARD_NSIDOMNODE_TO_NSINODE NS_FORWARD_NSIDOMNODE_TO_NSINODE
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
@ -39,9 +42,15 @@ public:
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; } virtual nsIDOMNode* AsDOMNode() { return this; }
// WebIDL
already_AddRefed<nsIDOMSVGAnimatedString> In1();
already_AddRefed<nsIDOMSVGAnimatedNumber> SurfaceScale();
already_AddRefed<nsIDOMSVGAnimatedNumber> DiffuseConstant();
already_AddRefed<nsIDOMSVGAnimatedNumber> KernelUnitLengthX();
already_AddRefed<nsIDOMSVGAnimatedNumber> KernelUnitLengthY();
protected: protected:
virtual void LightPixel(const float *N, const float *L, virtual void LightPixel(const float *N, const float *L,
nscolor color, uint8_t *targetData); nscolor color, uint8_t *targetData);

View File

@ -22,7 +22,7 @@ class nsSVGFilterInstance;
class nsSVGFilterResource; class nsSVGFilterResource;
class nsSVGNumberPair; class nsSVGNumberPair;
inline float DOT(float* a, float* b) { inline float DOT(const float* a, const float* b) {
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
} }

View File

@ -814,8 +814,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS) DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGFEConvolveMatrixElement, nsElementSH, NS_DEFINE_CLASSINFO_DATA(SVGFEConvolveMatrixElement, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS) ELEMENT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGFEDiffuseLightingElement, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGFEDisplacementMapElement, nsElementSH, NS_DEFINE_CLASSINFO_DATA(SVGFEDisplacementMapElement, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS) ELEMENT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGFEMorphologyElement, nsElementSH, NS_DEFINE_CLASSINFO_DATA(SVGFEMorphologyElement, nsElementSH,
@ -2237,12 +2235,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(SVGFEDiffuseLightingElement, nsIDOMSVGFEDiffuseLightingElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEDiffuseLightingElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(SVGFEDisplacementMapElement, nsIDOMSVGFEDisplacementMapElement) DOM_CLASSINFO_MAP_BEGIN(SVGFEDisplacementMapElement, nsIDOMSVGFEDisplacementMapElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEDisplacementMapElement) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEDisplacementMapElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)

View File

@ -123,7 +123,6 @@ DOMCI_CLASS(SVGDocument)
// SVG element classes // SVG element classes
DOMCI_CLASS(TimeEvent) DOMCI_CLASS(TimeEvent)
DOMCI_CLASS(SVGFEConvolveMatrixElement) DOMCI_CLASS(SVGFEConvolveMatrixElement)
DOMCI_CLASS(SVGFEDiffuseLightingElement)
DOMCI_CLASS(SVGFEDisplacementMapElement) DOMCI_CLASS(SVGFEDisplacementMapElement)
DOMCI_CLASS(SVGFEMorphologyElement) DOMCI_CLASS(SVGFEMorphologyElement)
DOMCI_CLASS(SVGFETurbulenceElement) DOMCI_CLASS(SVGFETurbulenceElement)

View File

@ -81,16 +81,6 @@ interface nsIDOMSVGFEConvolveMatrixElement : nsIDOMSVGFilterPrimitiveStandardAtt
readonly attribute nsISupports preserveAlpha; readonly attribute nsISupports preserveAlpha;
}; };
[scriptable, uuid(309be736-d55a-40fe-a2f2-088aea14f0fa)]
interface nsIDOMSVGFEDiffuseLightingElement : nsIDOMSVGFilterPrimitiveStandardAttributes
{
readonly attribute nsIDOMSVGAnimatedString in1;
readonly attribute nsIDOMSVGAnimatedNumber surfaceScale;
readonly attribute nsIDOMSVGAnimatedNumber diffuseConstant;
readonly attribute nsIDOMSVGAnimatedNumber kernelUnitLengthX;
readonly attribute nsIDOMSVGAnimatedNumber kernelUnitLengthY;
};
[scriptable, uuid(5ab43048-d59a-4e3c-ad2f-6a5d8593f6d0)] [scriptable, uuid(5ab43048-d59a-4e3c-ad2f-6a5d8593f6d0)]
interface nsIDOMSVGFEDisplacementMapElement : nsIDOMSVGFilterPrimitiveStandardAttributes interface nsIDOMSVGFEDisplacementMapElement : nsIDOMSVGFilterPrimitiveStandardAttributes
{ {

View File

@ -0,0 +1,24 @@
/* -*- 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 SVGAnimatedNumber;
interface SVGAnimatedString;
interface SVGFEDiffuseLightingElement : SVGElement {
readonly attribute SVGAnimatedString in1;
readonly attribute SVGAnimatedNumber surfaceScale;
readonly attribute SVGAnimatedNumber diffuseConstant;
readonly attribute SVGAnimatedNumber kernelUnitLengthX;
readonly attribute SVGAnimatedNumber kernelUnitLengthY;
};
SVGFEDiffuseLightingElement implements SVGFilterPrimitiveStandardAttributes;

View File

@ -190,6 +190,7 @@ webidl_files = \
SVGFEColorMatrixElement.webidl \ SVGFEColorMatrixElement.webidl \
SVGFEComponentTransferElement.webidl \ SVGFEComponentTransferElement.webidl \
SVGFECompositeElement.webidl \ SVGFECompositeElement.webidl \
SVGFEDiffuseLightingElement.webidl \
SVGFEDistantLightElement.webidl \ SVGFEDistantLightElement.webidl \
SVGFEFloodElement.webidl \ SVGFEFloodElement.webidl \
SVGFEFuncAElement.webidl \ SVGFEFuncAElement.webidl \