diff --git a/content/svg/content/src/SVGFETileElement.cpp b/content/svg/content/src/SVGFETileElement.cpp index 156ae7734ac..47cd2ad63c9 100644 --- a/content/svg/content/src/SVGFETileElement.cpp +++ b/content/svg/content/src/SVGFETileElement.cpp @@ -4,15 +4,22 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/SVGFETileElement.h" - -DOMCI_NODE_DATA(SVGFETileElement, nsSVGFETileElement) +#include "mozilla/dom/SVGFETileElementBinding.h" +#include "nsSVGFilterInstance.h" +#include "gfxUtils.h" NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FETile) namespace mozilla { 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::in, kNameSpaceID_None, true } @@ -21,66 +28,53 @@ nsSVGElement::StringInfo nsSVGFETileElement::sStringInfo[2] = //---------------------------------------------------------------------- // nsISupports methods -NS_IMPL_ADDREF_INHERITED(nsSVGFETileElement,nsSVGFETileElementBase) -NS_IMPL_RELEASE_INHERITED(nsSVGFETileElement,nsSVGFETileElementBase) +NS_IMPL_ADDREF_INHERITED(SVGFETileElement,SVGFETileElementBase) +NS_IMPL_RELEASE_INHERITED(SVGFETileElement,SVGFETileElementBase) -NS_INTERFACE_TABLE_HEAD(nsSVGFETileElement) - NS_NODE_INTERFACE_TABLE5(nsSVGFETileElement, nsIDOMNode, nsIDOMElement, - nsIDOMSVGElement, - nsIDOMSVGFilterPrimitiveStandardAttributes, - nsIDOMSVGFETileElement) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGFETileElement) -NS_INTERFACE_MAP_END_INHERITING(nsSVGFETileElementBase) +NS_INTERFACE_TABLE_HEAD(SVGFETileElement) + NS_NODE_INTERFACE_TABLE3(SVGFETileElement, nsIDOMNode, nsIDOMElement, + nsIDOMSVGElement) +NS_INTERFACE_MAP_END_INHERITING(SVGFETileElementBase) //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFETileElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFETileElement) - -//---------------------------------------------------------------------- -// nsSVGFETileElement methods - -/* readonly attribute nsIDOMSVGAnimatedString in1; */ -NS_IMETHODIMP nsSVGFETileElement::GetIn1(nsIDOMSVGAnimatedString * *aIn) +already_AddRefed +SVGFETileElement::In1() { - return mStringAttributes[IN1].ToDOMAnimatedString(aIn, this); + return mStringAttributes[IN1].ToDOMAnimatedString(this); } void -nsSVGFETileElement::GetSourceImageNames(nsTArray& aSources) +SVGFETileElement::GetSourceImageNames(nsTArray& aSources) { aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this)); } nsIntRect -nsSVGFETileElement::ComputeTargetBBox(const nsTArray& aSourceBBoxes, +SVGFETileElement::ComputeTargetBBox(const nsTArray& aSourceBBoxes, const nsSVGFilterInstance& aInstance) { return GetMaxRect(); } void -nsSVGFETileElement::ComputeNeededSourceBBoxes(const nsIntRect& aTargetBBox, +SVGFETileElement::ComputeNeededSourceBBoxes(const nsIntRect& aTargetBBox, nsTArray& aSourceBBoxes, const nsSVGFilterInstance& aInstance) { // Just assume we need the entire source bounding box, so do nothing. } nsIntRect -nsSVGFETileElement::ComputeChangeBBox(const nsTArray& aSourceChangeBoxes, - const nsSVGFilterInstance& aInstance) +SVGFETileElement::ComputeChangeBBox(const nsTArray& aSourceChangeBoxes, + const nsSVGFilterInstance& aInstance) { return GetMaxRect(); } -static int32_t WrapInterval(int32_t aVal, int32_t aMax) -{ - aVal = aVal % aMax; - return aVal < 0 ? aMax + aVal : aVal; -} - //---------------------------------------------------------------------- // nsSVGElement methods @@ -230,10 +224,10 @@ TilePixels(uint8_t *aTargetData, } nsresult -nsSVGFETileElement::Filter(nsSVGFilterInstance *instance, - const nsTArray& aSources, - const Image* aTarget, - const nsIntRect& rect) +SVGFETileElement::Filter(nsSVGFilterInstance *instance, + const nsTArray& aSources, + const Image* aTarget, + const nsIntRect& rect) { // XXX This code depends on the surface rect containing the filter // primitive subregion. ComputeTargetBBox, ComputeNeededSourceBBoxes @@ -425,11 +419,11 @@ nsSVGFETileElement::Filter(nsSVGFilterInstance *instance, } bool -nsSVGFETileElement::AttributeAffectsRendering(int32_t aNameSpaceID, - nsIAtom* aAttribute) const +SVGFETileElement::AttributeAffectsRendering(int32_t aNameSpaceID, + nsIAtom* aAttribute) const { - return nsSVGFETileElementBase::AttributeAffectsRendering(aNameSpaceID, - aAttribute) || + return SVGFETileElementBase::AttributeAffectsRendering(aNameSpaceID, + aAttribute) || (aNameSpaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::in); } @@ -437,7 +431,7 @@ nsSVGFETileElement::AttributeAffectsRendering(int32_t aNameSpaceID, // nsSVGElement methods nsSVGElement::StringAttributesInfo -nsSVGFETileElement::GetStringInfo() +SVGFETileElement::GetStringInfo() { return StringAttributesInfo(mStringAttributes, sStringInfo, ArrayLength(sStringInfo)); diff --git a/content/svg/content/src/SVGFETileElement.h b/content/svg/content/src/SVGFETileElement.h index 064da304800..4779111deee 100644 --- a/content/svg/content/src/SVGFETileElement.h +++ b/content/svg/content/src/SVGFETileElement.h @@ -14,16 +14,20 @@ nsresult NS_NewSVGFETileElement(nsIContent **aResult, namespace mozilla { namespace dom { -typedef nsSVGFE nsSVGFETileElementBase; +typedef nsSVGFE SVGFETileElementBase; -class nsSVGFETileElement : public nsSVGFETileElementBase, - public nsIDOMSVGFETileElement +class SVGFETileElement : public SVGFETileElementBase, + public nsIDOMSVGElement { friend nsresult (::NS_NewSVGFETileElement(nsIContent **aResult, already_AddRefed aNodeInfo)); protected: - nsSVGFETileElement(already_AddRefed aNodeInfo) - : nsSVGFETileElementBase(aNodeInfo) {} + SVGFETileElement(already_AddRefed aNodeInfo) + : SVGFETileElementBase(aNodeInfo) + { + SetIsDOMBinding(); + } + virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE; public: virtual bool SubregionIsUnionOfRegions() { return false; } @@ -31,9 +35,6 @@ public: // interfaces: NS_DECL_ISUPPORTS_INHERITED - // FE Base - NS_FORWARD_NSIDOMSVGFILTERPRIMITIVESTANDARDATTRIBUTES(nsSVGFETileElementBase::) - virtual nsresult Filter(nsSVGFilterInstance* aInstance, const nsTArray& aSources, const Image* aTarget, @@ -49,19 +50,18 @@ public: virtual nsIntRect ComputeChangeBBox(const nsTArray& aSourceChangeBoxes, const nsSVGFilterInstance& aInstance); - // Tile - NS_DECL_NSIDOMSVGFETILEELEMENT - - NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFETileElementBase::) + NS_FORWARD_NSIDOMSVGELEMENT(SVGFETileElementBase::) NS_FORWARD_NSIDOMNODE_TO_NSINODE NS_FORWARD_NSIDOMELEMENT_TO_GENERIC virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - virtual nsXPCClassInfo* GetClassInfo(); - virtual nsIDOMNode* AsDOMNode() { return this; } + + // WebIDL + already_AddRefed In1(); + protected: virtual StringAttributesInfo GetStringInfo(); diff --git a/content/svg/content/src/nsSVGFilters.cpp b/content/svg/content/src/nsSVGFilters.cpp index 42d3f291302..b7480543cd7 100644 --- a/content/svg/content/src/nsSVGFilters.cpp +++ b/content/svg/content/src/nsSVGFilters.cpp @@ -3336,6 +3336,12 @@ static int32_t BoundInterval(int32_t aVal, int32_t aMax) 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 ConvolvePixel(const uint8_t *aSourceData, uint8_t *aTargetData, diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index a5ae99ab6ba..7c75bc3c056 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -842,8 +842,6 @@ static nsDOMClassInfoData sClassInfoData[] = { ELEMENT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(SVGFESpotLightElement, nsElementSH, ELEMENT_SCRIPTABLE_FLAGS) - NS_DEFINE_CLASSINFO_DATA(SVGFETileElement, nsElementSH, - ELEMENT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(SVGFETurbulenceElement, nsElementSH, ELEMENT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA_WITH_NAME(SVGUnknownElement, SVGElement, nsElementSH, @@ -2334,12 +2332,6 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES 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_ENTRY(nsIDOMSVGFETurbulenceElement) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes) diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index 0b1fb3a7bc0..168b1704359 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -134,7 +134,6 @@ DOMCI_CLASS(SVGFEOffsetElement) DOMCI_CLASS(SVGFEPointLightElement) DOMCI_CLASS(SVGFESpecularLightingElement) DOMCI_CLASS(SVGFESpotLightElement) -DOMCI_CLASS(SVGFETileElement) DOMCI_CLASS(SVGFETurbulenceElement) DOMCI_CLASS(SVGUnknownElement) diff --git a/dom/interfaces/svg/nsIDOMSVGFilters.idl b/dom/interfaces/svg/nsIDOMSVGFilters.idl index b5094f4595e..43be87bf772 100644 --- a/dom/interfaces/svg/nsIDOMSVGFilters.idl +++ b/dom/interfaces/svg/nsIDOMSVGFilters.idl @@ -125,12 +125,6 @@ interface nsIDOMSVGFEOffsetElement : nsIDOMSVGFilterPrimitiveStandardAttributes 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)] interface nsIDOMSVGFETurbulenceElement : nsIDOMSVGFilterPrimitiveStandardAttributes { diff --git a/dom/webidl/SVGFETileElement.webidl b/dom/webidl/SVGFETileElement.webidl new file mode 100644 index 00000000000..511fce6ed78 --- /dev/null +++ b/dom/webidl/SVGFETileElement.webidl @@ -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; diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 411b800baf1..5a92ae3eb51 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -171,6 +171,7 @@ webidl_files = \ SVGFEImageElement.webidl \ SVGFEMergeElement.webidl \ SVGFEMergeNodeElement.webidl \ + SVGFETileElement.webidl \ SVGFitToViewBox.webidl \ SVGForeignObjectElement.webidl \ SVGGElement.webidl \