Bug 847120: Convert SVGFETileElement to WebIDL r=Ms2ger

This commit is contained in:
David Zbarsky 2013-03-11 03:27:08 -04:00
parent bc2a13320a
commit b82e6139d5
9 changed files with 75 additions and 70 deletions

View File

@ -15,4 +15,4 @@
# #
# Note: The description below will be part of the error message shown to users. # Note: The description below will be part of the error message shown to users.
# #
Bug 848395 resulted in Windows test failures when landed without clobber Bug 847120 needs a clobber

View File

@ -4,15 +4,22 @@
* 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/SVGFETileElement.h" #include "mozilla/dom/SVGFETileElement.h"
#include "mozilla/dom/SVGFETileElementBinding.h"
DOMCI_NODE_DATA(SVGFETileElement, nsSVGFETileElement) #include "nsSVGFilterInstance.h"
#include "gfxUtils.h"
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FETile) NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FETile)
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
nsSVGElement::StringInfo nsSVGFETileElement::sStringInfo[2] = JSObject*
SVGFETileElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return SVGFETileElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
nsSVGElement::StringInfo SVGFETileElement::sStringInfo[2] =
{ {
{ &nsGkAtoms::result, kNameSpaceID_None, true }, { &nsGkAtoms::result, kNameSpaceID_None, true },
{ &nsGkAtoms::in, kNameSpaceID_None, true } { &nsGkAtoms::in, kNameSpaceID_None, true }
@ -21,66 +28,53 @@ nsSVGElement::StringInfo nsSVGFETileElement::sStringInfo[2] =
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsISupports methods // nsISupports methods
NS_IMPL_ADDREF_INHERITED(nsSVGFETileElement,nsSVGFETileElementBase) NS_IMPL_ADDREF_INHERITED(SVGFETileElement,SVGFETileElementBase)
NS_IMPL_RELEASE_INHERITED(nsSVGFETileElement,nsSVGFETileElementBase) NS_IMPL_RELEASE_INHERITED(SVGFETileElement,SVGFETileElementBase)
NS_INTERFACE_TABLE_HEAD(nsSVGFETileElement) NS_INTERFACE_TABLE_HEAD(SVGFETileElement)
NS_NODE_INTERFACE_TABLE5(nsSVGFETileElement, nsIDOMNode, nsIDOMElement, NS_NODE_INTERFACE_TABLE3(SVGFETileElement, nsIDOMNode, nsIDOMElement,
nsIDOMSVGElement, nsIDOMSVGElement)
nsIDOMSVGFilterPrimitiveStandardAttributes, NS_INTERFACE_MAP_END_INHERITING(SVGFETileElementBase)
nsIDOMSVGFETileElement)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGFETileElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGFETileElementBase)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsIDOMNode methods // nsIDOMNode methods
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFETileElement) NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFETileElement)
already_AddRefed<nsIDOMSVGAnimatedString>
//---------------------------------------------------------------------- SVGFETileElement::In1()
// nsSVGFETileElement methods
/* readonly attribute nsIDOMSVGAnimatedString in1; */
NS_IMETHODIMP nsSVGFETileElement::GetIn1(nsIDOMSVGAnimatedString * *aIn)
{ {
return mStringAttributes[IN1].ToDOMAnimatedString(aIn, this); return mStringAttributes[IN1].ToDOMAnimatedString(this);
} }
void void
nsSVGFETileElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources) SVGFETileElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{ {
aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this)); aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this));
} }
nsIntRect nsIntRect
nsSVGFETileElement::ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes, SVGFETileElement::ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance) const nsSVGFilterInstance& aInstance)
{ {
return GetMaxRect(); return GetMaxRect();
} }
void void
nsSVGFETileElement::ComputeNeededSourceBBoxes(const nsIntRect& aTargetBBox, SVGFETileElement::ComputeNeededSourceBBoxes(const nsIntRect& aTargetBBox,
nsTArray<nsIntRect>& aSourceBBoxes, const nsSVGFilterInstance& aInstance) nsTArray<nsIntRect>& aSourceBBoxes, const nsSVGFilterInstance& aInstance)
{ {
// Just assume we need the entire source bounding box, so do nothing. // Just assume we need the entire source bounding box, so do nothing.
} }
nsIntRect nsIntRect
nsSVGFETileElement::ComputeChangeBBox(const nsTArray<nsIntRect>& aSourceChangeBoxes, SVGFETileElement::ComputeChangeBBox(const nsTArray<nsIntRect>& aSourceChangeBoxes,
const nsSVGFilterInstance& aInstance) const nsSVGFilterInstance& aInstance)
{ {
return GetMaxRect(); return GetMaxRect();
} }
static int32_t WrapInterval(int32_t aVal, int32_t aMax)
{
aVal = aVal % aMax;
return aVal < 0 ? aMax + aVal : aVal;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsSVGElement methods // nsSVGElement methods
@ -230,10 +224,10 @@ TilePixels(uint8_t *aTargetData,
} }
nsresult nsresult
nsSVGFETileElement::Filter(nsSVGFilterInstance *instance, SVGFETileElement::Filter(nsSVGFilterInstance *instance,
const nsTArray<const Image*>& aSources, const nsTArray<const Image*>& aSources,
const Image* aTarget, const Image* aTarget,
const nsIntRect& rect) const nsIntRect& rect)
{ {
// XXX This code depends on the surface rect containing the filter // XXX This code depends on the surface rect containing the filter
// primitive subregion. ComputeTargetBBox, ComputeNeededSourceBBoxes // primitive subregion. ComputeTargetBBox, ComputeNeededSourceBBoxes
@ -425,11 +419,11 @@ nsSVGFETileElement::Filter(nsSVGFilterInstance *instance,
} }
bool bool
nsSVGFETileElement::AttributeAffectsRendering(int32_t aNameSpaceID, SVGFETileElement::AttributeAffectsRendering(int32_t aNameSpaceID,
nsIAtom* aAttribute) const nsIAtom* aAttribute) const
{ {
return nsSVGFETileElementBase::AttributeAffectsRendering(aNameSpaceID, return SVGFETileElementBase::AttributeAffectsRendering(aNameSpaceID,
aAttribute) || aAttribute) ||
(aNameSpaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::in); (aNameSpaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::in);
} }
@ -437,7 +431,7 @@ nsSVGFETileElement::AttributeAffectsRendering(int32_t aNameSpaceID,
// nsSVGElement methods // nsSVGElement methods
nsSVGElement::StringAttributesInfo nsSVGElement::StringAttributesInfo
nsSVGFETileElement::GetStringInfo() SVGFETileElement::GetStringInfo()
{ {
return StringAttributesInfo(mStringAttributes, sStringInfo, return StringAttributesInfo(mStringAttributes, sStringInfo,
ArrayLength(sStringInfo)); ArrayLength(sStringInfo));

View File

@ -14,16 +14,20 @@ nsresult NS_NewSVGFETileElement(nsIContent **aResult,
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
typedef nsSVGFE nsSVGFETileElementBase; typedef nsSVGFE SVGFETileElementBase;
class nsSVGFETileElement : public nsSVGFETileElementBase, class SVGFETileElement : public SVGFETileElementBase,
public nsIDOMSVGFETileElement public nsIDOMSVGElement
{ {
friend nsresult (::NS_NewSVGFETileElement(nsIContent **aResult, friend nsresult (::NS_NewSVGFETileElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo)); already_AddRefed<nsINodeInfo> aNodeInfo));
protected: protected:
nsSVGFETileElement(already_AddRefed<nsINodeInfo> aNodeInfo) SVGFETileElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsSVGFETileElementBase(aNodeInfo) {} : SVGFETileElementBase(aNodeInfo)
{
SetIsDOMBinding();
}
virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE;
public: public:
virtual bool SubregionIsUnionOfRegions() { return false; } virtual bool SubregionIsUnionOfRegions() { return false; }
@ -31,9 +35,6 @@ public:
// interfaces: // interfaces:
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
// FE Base
NS_FORWARD_NSIDOMSVGFILTERPRIMITIVESTANDARDATTRIBUTES(nsSVGFETileElementBase::)
virtual nsresult Filter(nsSVGFilterInstance* aInstance, virtual nsresult Filter(nsSVGFilterInstance* aInstance,
const nsTArray<const Image*>& aSources, const nsTArray<const Image*>& aSources,
const Image* aTarget, const Image* aTarget,
@ -49,19 +50,18 @@ public:
virtual nsIntRect ComputeChangeBBox(const nsTArray<nsIntRect>& aSourceChangeBoxes, virtual nsIntRect ComputeChangeBBox(const nsTArray<nsIntRect>& aSourceChangeBoxes,
const nsSVGFilterInstance& aInstance); const nsSVGFilterInstance& aInstance);
// Tile NS_FORWARD_NSIDOMSVGELEMENT(SVGFETileElementBase::)
NS_DECL_NSIDOMSVGFETILEELEMENT
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFETileElementBase::)
NS_FORWARD_NSIDOMNODE_TO_NSINODE NS_FORWARD_NSIDOMNODE_TO_NSINODE
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
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();
protected: protected:
virtual StringAttributesInfo GetStringInfo(); virtual StringAttributesInfo GetStringInfo();

View File

@ -3336,6 +3336,12 @@ static int32_t BoundInterval(int32_t aVal, int32_t aMax)
return std::min(aVal, aMax - 1); return std::min(aVal, aMax - 1);
} }
static int32_t WrapInterval(int32_t aVal, int32_t aMax)
{
aVal = aVal % aMax;
return aVal < 0 ? aMax + aVal : aVal;
}
static void static void
ConvolvePixel(const uint8_t *aSourceData, ConvolvePixel(const uint8_t *aSourceData,
uint8_t *aTargetData, uint8_t *aTargetData,

View File

@ -842,8 +842,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
ELEMENT_SCRIPTABLE_FLAGS) ELEMENT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGFESpotLightElement, nsElementSH, NS_DEFINE_CLASSINFO_DATA(SVGFESpotLightElement, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS) ELEMENT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGFETileElement, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGFETurbulenceElement, nsElementSH, NS_DEFINE_CLASSINFO_DATA(SVGFETurbulenceElement, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS) ELEMENT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA_WITH_NAME(SVGUnknownElement, SVGElement, nsElementSH, NS_DEFINE_CLASSINFO_DATA_WITH_NAME(SVGUnknownElement, SVGElement, nsElementSH,
@ -2334,12 +2332,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(SVGFETileElement, nsIDOMSVGFETileElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFETileElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(SVGFETurbulenceElement, nsIDOMSVGFETurbulenceElement) DOM_CLASSINFO_MAP_BEGIN(SVGFETurbulenceElement, nsIDOMSVGFETurbulenceElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFETurbulenceElement) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFETurbulenceElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)

View File

@ -134,7 +134,6 @@ DOMCI_CLASS(SVGFEOffsetElement)
DOMCI_CLASS(SVGFEPointLightElement) DOMCI_CLASS(SVGFEPointLightElement)
DOMCI_CLASS(SVGFESpecularLightingElement) DOMCI_CLASS(SVGFESpecularLightingElement)
DOMCI_CLASS(SVGFESpotLightElement) DOMCI_CLASS(SVGFESpotLightElement)
DOMCI_CLASS(SVGFETileElement)
DOMCI_CLASS(SVGFETurbulenceElement) DOMCI_CLASS(SVGFETurbulenceElement)
DOMCI_CLASS(SVGUnknownElement) DOMCI_CLASS(SVGUnknownElement)

View File

@ -125,12 +125,6 @@ interface nsIDOMSVGFEOffsetElement : nsIDOMSVGFilterPrimitiveStandardAttributes
readonly attribute nsIDOMSVGAnimatedNumber dy; readonly attribute nsIDOMSVGAnimatedNumber dy;
}; };
[scriptable, uuid(5c7c7ad9-1829-43c4-87b3-1e64c4f51f7a)]
interface nsIDOMSVGFETileElement : nsIDOMSVGFilterPrimitiveStandardAttributes
{
readonly attribute nsIDOMSVGAnimatedString in1;
};
[scriptable, uuid(d60f68fc-179f-430d-ab0d-ff868db7d548)] [scriptable, uuid(d60f68fc-179f-430d-ab0d-ff868db7d548)]
interface nsIDOMSVGFETurbulenceElement : nsIDOMSVGFilterPrimitiveStandardAttributes interface nsIDOMSVGFETurbulenceElement : nsIDOMSVGFilterPrimitiveStandardAttributes
{ {

View File

@ -0,0 +1,19 @@
/* -*- 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 SVGAnimatedString;
interface SVGFETileElement : SVGElement {
readonly attribute SVGAnimatedString in1;
};
SVGFETileElement implements SVGFilterPrimitiveStandardAttributes;

View File

@ -171,6 +171,7 @@ webidl_files = \
SVGFEImageElement.webidl \ SVGFEImageElement.webidl \
SVGFEMergeElement.webidl \ SVGFEMergeElement.webidl \
SVGFEMergeNodeElement.webidl \ SVGFEMergeNodeElement.webidl \
SVGFETileElement.webidl \
SVGFitToViewBox.webidl \ SVGFitToViewBox.webidl \
SVGForeignObjectElement.webidl \ SVGForeignObjectElement.webidl \
SVGGElement.webidl \ SVGGElement.webidl \