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

View File

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

View File

@ -22,7 +22,7 @@ class nsSVGFilterInstance;
class nsSVGFilterResource;
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];
}

View File

@ -814,8 +814,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGFEConvolveMatrixElement, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGFEDiffuseLightingElement, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGFEDisplacementMapElement, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGFEMorphologyElement, nsElementSH,
@ -2237,12 +2235,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
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_ENTRY(nsIDOMSVGFEDisplacementMapElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)

View File

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

View File

@ -81,16 +81,6 @@ interface nsIDOMSVGFEConvolveMatrixElement : nsIDOMSVGFilterPrimitiveStandardAtt
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)]
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 \
SVGFEComponentTransferElement.webidl \
SVGFECompositeElement.webidl \
SVGFEDiffuseLightingElement.webidl \
SVGFEDistantLightElement.webidl \
SVGFEFloodElement.webidl \
SVGFEFuncAElement.webidl \