From 8bad5d1a748ca5e7349795c0cd4cbd57b933c0f7 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Wed, 23 Jan 2013 15:59:06 -0500 Subject: [PATCH] Bug 832153: Move SVGMaskElement to mozilla::dom r=bz --HG-- rename : content/svg/content/src/nsSVGMaskElement.cpp => content/svg/content/src/SVGMaskElement.cpp rename : content/svg/content/src/nsSVGMaskElement.h => content/svg/content/src/SVGMaskElement.h --- content/svg/content/src/Makefile.in | 3 +- ...sSVGMaskElement.cpp => SVGMaskElement.cpp} | 58 ++++++++++--------- .../{nsSVGMaskElement.h => SVGMaskElement.h} | 33 +++++++---- layout/svg/nsSVGMaskFrame.cpp | 14 +++-- 4 files changed, 63 insertions(+), 45 deletions(-) rename content/svg/content/src/{nsSVGMaskElement.cpp => SVGMaskElement.cpp} (70%) rename content/svg/content/src/{nsSVGMaskElement.h => SVGMaskElement.h} (63%) diff --git a/content/svg/content/src/Makefile.in b/content/svg/content/src/Makefile.in index 7e0d2d23de46..04fd7cf15847 100644 --- a/content/svg/content/src/Makefile.in +++ b/content/svg/content/src/Makefile.in @@ -50,7 +50,6 @@ CPPSRCS = \ nsSVGIntegerPair.cpp \ nsSVGLength2.cpp \ nsSVGMarkerElement.cpp \ - nsSVGMaskElement.cpp \ nsSVGNumber2.cpp \ nsSVGNumberPair.cpp \ nsSVGPathDataParser.cpp \ @@ -95,6 +94,7 @@ CPPSRCS = \ SVGLengthListSMILType.cpp \ SVGLineElement.cpp \ SVGLocatableElement.cpp \ + SVGMaskElement.cpp \ SVGMatrix.cpp \ SVGMetadataElement.cpp \ SVGMotionSMILType.cpp \ @@ -177,6 +177,7 @@ EXPORTS_mozilla/dom = \ SVGImageElement.h \ SVGLineElement.h \ SVGLocatableElement.h \ + SVGMaskElement.h \ SVGMatrix.h \ SVGMetadataElement.h \ SVGMPathElement.h \ diff --git a/content/svg/content/src/nsSVGMaskElement.cpp b/content/svg/content/src/SVGMaskElement.cpp similarity index 70% rename from content/svg/content/src/nsSVGMaskElement.cpp rename to content/svg/content/src/SVGMaskElement.cpp index 21b5107dafd8..ee942c3db886 100644 --- a/content/svg/content/src/nsSVGMaskElement.cpp +++ b/content/svg/content/src/SVGMaskElement.cpp @@ -7,13 +7,18 @@ #include "nsCOMPtr.h" #include "nsGkAtoms.h" -#include "nsSVGMaskElement.h" +#include "mozilla/dom/SVGMaskElement.h" -using namespace mozilla; +DOMCI_NODE_DATA(SVGMaskElement, mozilla::dom::SVGMaskElement) + +NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Mask) + +namespace mozilla { +namespace dom { //--------------------- Masks ------------------------ -nsSVGElement::LengthInfo nsSVGMaskElement::sLengthInfo[4] = +nsSVGElement::LengthInfo SVGMaskElement::sLengthInfo[4] = { { &nsGkAtoms::x, -10, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X }, { &nsGkAtoms::y, -10, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, @@ -21,7 +26,7 @@ nsSVGElement::LengthInfo nsSVGMaskElement::sLengthInfo[4] = { &nsGkAtoms::height, 120, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y }, }; -nsSVGElement::EnumInfo nsSVGMaskElement::sEnumInfo[2] = +nsSVGElement::EnumInfo SVGMaskElement::sEnumInfo[2] = { { &nsGkAtoms::maskUnits, sSVGUnitTypesMap, @@ -33,71 +38,67 @@ nsSVGElement::EnumInfo nsSVGMaskElement::sEnumInfo[2] = } }; -NS_IMPL_NS_NEW_SVG_ELEMENT(Mask) - //---------------------------------------------------------------------- // nsISupports methods -NS_IMPL_ADDREF_INHERITED(nsSVGMaskElement,nsSVGMaskElementBase) -NS_IMPL_RELEASE_INHERITED(nsSVGMaskElement,nsSVGMaskElementBase) +NS_IMPL_ADDREF_INHERITED(SVGMaskElement,SVGMaskElementBase) +NS_IMPL_RELEASE_INHERITED(SVGMaskElement,SVGMaskElementBase) -DOMCI_NODE_DATA(SVGMaskElement, nsSVGMaskElement) - -NS_INTERFACE_TABLE_HEAD(nsSVGMaskElement) - NS_NODE_INTERFACE_TABLE5(nsSVGMaskElement, nsIDOMNode, nsIDOMElement, +NS_INTERFACE_TABLE_HEAD(SVGMaskElement) + NS_NODE_INTERFACE_TABLE5(SVGMaskElement, nsIDOMNode, nsIDOMElement, nsIDOMSVGElement, nsIDOMSVGMaskElement, nsIDOMSVGUnitTypes) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGMaskElement) -NS_INTERFACE_MAP_END_INHERITING(nsSVGMaskElementBase) +NS_INTERFACE_MAP_END_INHERITING(SVGMaskElementBase) //---------------------------------------------------------------------- // Implementation -nsSVGMaskElement::nsSVGMaskElement(already_AddRefed aNodeInfo) - : nsSVGMaskElementBase(aNodeInfo) +SVGMaskElement::SVGMaskElement(already_AddRefed aNodeInfo) + : SVGMaskElementBase(aNodeInfo) { } //---------------------------------------------------------------------- // nsIDOMNode method -NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGMaskElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGMaskElement) //---------------------------------------------------------------------- // nsIDOMSVGMaskElement methods /* readonly attribute nsIDOMSVGAnimatedEnumeration maskUnits; */ -NS_IMETHODIMP nsSVGMaskElement::GetMaskUnits(nsIDOMSVGAnimatedEnumeration * *aMaskUnits) +NS_IMETHODIMP SVGMaskElement::GetMaskUnits(nsIDOMSVGAnimatedEnumeration * *aMaskUnits) { return mEnumAttributes[MASKUNITS].ToDOMAnimatedEnum(aMaskUnits, this); } /* readonly attribute nsIDOMSVGAnimatedEnumeration maskContentUnits; */ -NS_IMETHODIMP nsSVGMaskElement::GetMaskContentUnits(nsIDOMSVGAnimatedEnumeration * *aMaskUnits) +NS_IMETHODIMP SVGMaskElement::GetMaskContentUnits(nsIDOMSVGAnimatedEnumeration * *aMaskUnits) { return mEnumAttributes[MASKCONTENTUNITS].ToDOMAnimatedEnum(aMaskUnits, this); } /* readonly attribute nsIDOMSVGAnimatedLength x; */ -NS_IMETHODIMP nsSVGMaskElement::GetX(nsIDOMSVGAnimatedLength * *aX) +NS_IMETHODIMP SVGMaskElement::GetX(nsIDOMSVGAnimatedLength * *aX) { return mLengthAttributes[X].ToDOMAnimatedLength(aX, this); } /* readonly attribute nsIDOMSVGAnimatedLength y; */ -NS_IMETHODIMP nsSVGMaskElement::GetY(nsIDOMSVGAnimatedLength * *aY) +NS_IMETHODIMP SVGMaskElement::GetY(nsIDOMSVGAnimatedLength * *aY) { return mLengthAttributes[Y].ToDOMAnimatedLength(aY, this); } /* readonly attribute nsIDOMSVGAnimatedLength width; */ -NS_IMETHODIMP nsSVGMaskElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth) +NS_IMETHODIMP SVGMaskElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth) { return mLengthAttributes[WIDTH].ToDOMAnimatedLength(aWidth, this); } /* readonly attribute nsIDOMSVGAnimatedLength height; */ -NS_IMETHODIMP nsSVGMaskElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight) +NS_IMETHODIMP SVGMaskElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight) { return mLengthAttributes[HEIGHT].ToDOMAnimatedLength(aHeight, this); } @@ -106,7 +107,7 @@ NS_IMETHODIMP nsSVGMaskElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight) // nsSVGElement methods /* virtual */ bool -nsSVGMaskElement::HasValidDimensions() const +SVGMaskElement::HasValidDimensions() const { return (!mLengthAttributes[WIDTH].IsExplicitlySet() || mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() > 0) && @@ -115,14 +116,14 @@ nsSVGMaskElement::HasValidDimensions() const } nsSVGElement::LengthAttributesInfo -nsSVGMaskElement::GetLengthInfo() +SVGMaskElement::GetLengthInfo() { return LengthAttributesInfo(mLengthAttributes, sLengthInfo, ArrayLength(sLengthInfo)); } nsSVGElement::EnumAttributesInfo -nsSVGMaskElement::GetEnumInfo() +SVGMaskElement::GetEnumInfo() { return EnumAttributesInfo(mEnumAttributes, sEnumInfo, ArrayLength(sEnumInfo)); @@ -132,7 +133,7 @@ nsSVGMaskElement::GetEnumInfo() // nsIContent methods NS_IMETHODIMP_(bool) -nsSVGMaskElement::IsAttributeMapped(const nsIAtom* name) const +SVGMaskElement::IsAttributeMapped(const nsIAtom* name) const { static const MappedAttributeEntry* const map[] = { sFEFloodMap, @@ -147,5 +148,8 @@ nsSVGMaskElement::IsAttributeMapped(const nsIAtom* name) const }; return FindAttributeDependence(name, map) || - nsSVGMaskElementBase::IsAttributeMapped(name); + SVGMaskElementBase::IsAttributeMapped(name); } + +} // namespace dom +} // namespace mozilla diff --git a/content/svg/content/src/nsSVGMaskElement.h b/content/svg/content/src/SVGMaskElement.h similarity index 63% rename from content/svg/content/src/nsSVGMaskElement.h rename to content/svg/content/src/SVGMaskElement.h index ed3641fd16ae..f27fa16771ec 100644 --- a/content/svg/content/src/nsSVGMaskElement.h +++ b/content/svg/content/src/SVGMaskElement.h @@ -3,8 +3,8 @@ * 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/. */ -#ifndef __NS_SVGMASKELEMENT_H__ -#define __NS_SVGMASKELEMENT_H__ +#ifndef mozilla_dom_SVGMaskElement_h +#define mozilla_dom_SVGMaskElement_h #include "nsIDOMSVGMaskElement.h" #include "nsIDOMSVGUnitTypes.h" @@ -12,20 +12,28 @@ #include "nsSVGLength2.h" #include "nsSVGElement.h" +class nsSVGMaskFrame; + +nsresult NS_NewSVGMaskElement(nsIContent **aResult, + already_AddRefed aNodeInfo); + +namespace mozilla { +namespace dom { + //--------------------- Masks ------------------------ -typedef nsSVGElement nsSVGMaskElementBase; +typedef nsSVGElement SVGMaskElementBase; -class nsSVGMaskElement : public nsSVGMaskElementBase, - public nsIDOMSVGMaskElement, - public nsIDOMSVGUnitTypes +class SVGMaskElement MOZ_FINAL : public SVGMaskElementBase, + public nsIDOMSVGMaskElement, + public nsIDOMSVGUnitTypes { - friend class nsSVGMaskFrame; + friend class ::nsSVGMaskFrame; protected: - friend nsresult NS_NewSVGMaskElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - nsSVGMaskElement(already_AddRefed aNodeInfo); + friend nsresult (::NS_NewSVGMaskElement(nsIContent **aResult, + already_AddRefed aNodeInfo)); + SVGMaskElement(already_AddRefed aNodeInfo); public: // interfaces: @@ -63,4 +71,7 @@ protected: static EnumInfo sEnumInfo[2]; }; -#endif +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_SVGMaskElement_h diff --git a/layout/svg/nsSVGMaskFrame.cpp b/layout/svg/nsSVGMaskFrame.cpp index 05dd0cc636dc..940e702832a0 100644 --- a/layout/svg/nsSVGMaskFrame.cpp +++ b/layout/svg/nsSVGMaskFrame.cpp @@ -11,7 +11,9 @@ #include "gfxImageSurface.h" #include "nsRenderingContext.h" #include "nsSVGEffects.h" -#include "nsSVGMaskElement.h" +#include "mozilla/dom/SVGMaskElement.h" + +using namespace mozilla::dom; //---------------------------------------------------------------------- // Implementation @@ -39,17 +41,17 @@ nsSVGMaskFrame::ComputeMaskAlpha(nsRenderingContext *aContext, } AutoMaskReferencer maskRef(this); - nsSVGMaskElement *mask = static_cast(mContent); + SVGMaskElement *mask = static_cast(mContent); uint16_t units = - mask->mEnumAttributes[nsSVGMaskElement::MASKUNITS].GetAnimValue(); + mask->mEnumAttributes[SVGMaskElement::MASKUNITS].GetAnimValue(); gfxRect bbox; if (units == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { bbox = nsSVGUtils::GetBBox(aParent); } gfxRect maskArea = nsSVGUtils::GetRelativeRect(units, - &mask->mLengthAttributes[nsSVGMaskElement::X], bbox, aParent); + &mask->mLengthAttributes[SVGMaskElement::X], bbox, aParent); gfxContext *gfx = aContext->ThebesContext(); @@ -201,11 +203,11 @@ nsSVGMaskFrame::GetCanvasTM(uint32_t aFor) { NS_ASSERTION(mMaskParentMatrix, "null parent matrix"); - nsSVGMaskElement *mask = static_cast(mContent); + SVGMaskElement *mask = static_cast(mContent); return nsSVGUtils::AdjustMatrixForUnits( mMaskParentMatrix ? *mMaskParentMatrix : gfxMatrix(), - &mask->mEnumAttributes[nsSVGMaskElement::MASKCONTENTUNITS], + &mask->mEnumAttributes[SVGMaskElement::MASKCONTENTUNITS], mMaskParent); }