diff --git a/content/svg/content/src/Makefile.in b/content/svg/content/src/Makefile.in index 585c99878d4..bf8a2916254 100644 --- a/content/svg/content/src/Makefile.in +++ b/content/svg/content/src/Makefile.in @@ -59,7 +59,6 @@ CPPSRCS = \ nsSVGPolyElement.cpp \ nsSVGString.cpp \ nsSVGRect.cpp \ - nsSVGSymbolElement.cpp \ nsSVGUnknownElement.cpp \ nsSVGViewBox.cpp \ SVGAElement.cpp \ @@ -121,6 +120,7 @@ CPPSRCS = \ SVGStopElement.cpp \ SVGStringList.cpp \ SVGStyleElement.cpp \ + SVGSymbolElement.cpp \ SVGSVGElement.cpp \ SVGSwitchElement.cpp \ SVGTextContentElement.cpp \ @@ -184,6 +184,7 @@ EXPORTS_mozilla/dom = \ SVGSetElement.h \ SVGStopElement.h \ SVGStyleElement.h \ + SVGSymbolElement.h \ SVGSVGElement.h \ SVGSwitchElement.h \ SVGTextContentElement.h \ diff --git a/content/svg/content/src/SVGSymbolElement.cpp b/content/svg/content/src/SVGSymbolElement.cpp new file mode 100644 index 00000000000..05bf430095b --- /dev/null +++ b/content/svg/content/src/SVGSymbolElement.cpp @@ -0,0 +1,102 @@ +/* -*- Mode: C++; 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/. */ + +#include "mozilla/dom/SVGSymbolElement.h" + +NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Symbol) + +DOMCI_NODE_DATA(SVGSymbolElement, mozilla::dom::SVGSymbolElement) + +namespace mozilla { +namespace dom { + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(SVGSymbolElement,SVGSymbolElementBase) +NS_IMPL_RELEASE_INHERITED(SVGSymbolElement,SVGSymbolElementBase) + +NS_INTERFACE_TABLE_HEAD(SVGSymbolElement) + NS_NODE_INTERFACE_TABLE5(SVGSymbolElement, nsIDOMNode, nsIDOMElement, + nsIDOMSVGElement, nsIDOMSVGFitToViewBox, + nsIDOMSVGSymbolElement) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGSymbolElement) +NS_INTERFACE_MAP_END_INHERITING(SVGSymbolElementBase) + +//---------------------------------------------------------------------- +// Implementation + +SVGSymbolElement::SVGSymbolElement(already_AddRefed aNodeInfo) + : SVGSymbolElementBase(aNodeInfo) +{ +} + + +//---------------------------------------------------------------------- +// nsIDOMNode methods + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGSymbolElement) + +//---------------------------------------------------------------------- +// nsIDOMSVGFitToViewBox methods + +/* readonly attribute nsIDOMSVGAnimatedRect viewBox; */ +NS_IMETHODIMP SVGSymbolElement::GetViewBox(nsIDOMSVGAnimatedRect * *aViewBox) +{ + return mViewBox.ToDOMAnimatedRect(aViewBox, this); +} + +/* readonly attribute SVGPreserveAspectRatio preserveAspectRatio; */ +NS_IMETHODIMP +SVGSymbolElement::GetPreserveAspectRatio(nsISupports + **aPreserveAspectRatio) +{ + nsRefPtr ratio; + mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this); + ratio.forget(aPreserveAspectRatio); + return NS_OK; +} + +//---------------------------------------------------------------------- +// nsIContent methods + +NS_IMETHODIMP_(bool) +SVGSymbolElement::IsAttributeMapped(const nsIAtom* name) const +{ + static const MappedAttributeEntry* const map[] = { + sColorMap, + sFEFloodMap, + sFillStrokeMap, + sFiltersMap, + sFontSpecificationMap, + sGradientStopMap, + sGraphicsMap, + sLightingEffectsMap, + sMarkersMap, + sTextContentElementsMap, + sViewportsMap + }; + + return FindAttributeDependence(name, map) || + SVGSymbolElementBase::IsAttributeMapped(name); +} + +//---------------------------------------------------------------------- +// nsSVGElement methods + +nsSVGViewBox * +SVGSymbolElement::GetViewBox() +{ + return &mViewBox; +} + +SVGAnimatedPreserveAspectRatio * +SVGSymbolElement::GetPreserveAspectRatio() +{ + return &mPreserveAspectRatio; +} + +} // namespace dom +} // namespace mozilla diff --git a/content/svg/content/src/SVGSymbolElement.h b/content/svg/content/src/SVGSymbolElement.h new file mode 100644 index 00000000000..b4ab8ac1467 --- /dev/null +++ b/content/svg/content/src/SVGSymbolElement.h @@ -0,0 +1,66 @@ +/* -*- Mode: C++; 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/. */ + +#ifndef mozilla_dom_SVGSymbolElement_h +#define mozilla_dom_SVGSymbolElement_h + +#include "nsIDOMSVGSymbolElement.h" +#include "DOMSVGTests.h" +#include "nsSVGElement.h" +#include "nsSVGViewBox.h" +#include "SVGAnimatedPreserveAspectRatio.h" +#include "nsIDOMSVGFitToViewBox.h" +#include "nsGkAtoms.h" + +nsresult NS_NewSVGSymbolElement(nsIContent **aResult, + already_AddRefed aNodeInfo); + +namespace mozilla { +namespace dom { + +typedef nsSVGElement SVGSymbolElementBase; + +class SVGSymbolElement MOZ_FINAL : public SVGSymbolElementBase, + public nsIDOMSVGSymbolElement, + public DOMSVGTests, + public nsIDOMSVGFitToViewBox +{ +protected: + friend nsresult (::NS_NewSVGSymbolElement(nsIContent **aResult, + already_AddRefed aNodeInfo)); + SVGSymbolElement(already_AddRefed aNodeInfo); + +public: + // interfaces: + + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMSVGSYMBOLELEMENT + NS_DECL_NSIDOMSVGFITTOVIEWBOX + + // xxx I wish we could use virtual inheritance + NS_FORWARD_NSIDOMNODE_TO_NSINODE + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + NS_FORWARD_NSIDOMSVGELEMENT(nsSVGElement::) + + // nsIContent interface + NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const; + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +protected: + virtual nsSVGViewBox *GetViewBox(); + virtual SVGAnimatedPreserveAspectRatio *GetPreserveAspectRatio(); + + nsSVGViewBox mViewBox; + SVGAnimatedPreserveAspectRatio mPreserveAspectRatio; +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_SVGSymbolElement_h diff --git a/content/svg/content/src/nsSVGSymbolElement.cpp b/content/svg/content/src/nsSVGSymbolElement.cpp deleted file mode 100644 index de2fcfe8c9d..00000000000 --- a/content/svg/content/src/nsSVGSymbolElement.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- Mode: C++; 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/. */ - -#include "mozilla/Util.h" - -#include "nsIDOMSVGSymbolElement.h" -#include "DOMSVGTests.h" -#include "nsSVGElement.h" -#include "nsSVGViewBox.h" -#include "SVGAnimatedPreserveAspectRatio.h" -#include "nsIDOMSVGFitToViewBox.h" -#include "nsGkAtoms.h" - -using namespace mozilla; -using namespace mozilla::dom; - -typedef nsSVGElement nsSVGSymbolElementBase; - -class nsSVGSymbolElement : public nsSVGSymbolElementBase, - public nsIDOMSVGSymbolElement, - public DOMSVGTests, - public nsIDOMSVGFitToViewBox -{ -protected: - friend nsresult NS_NewSVGSymbolElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - nsSVGSymbolElement(already_AddRefed aNodeInfo); - -public: - // interfaces: - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIDOMSVGSYMBOLELEMENT - NS_DECL_NSIDOMSVGFITTOVIEWBOX - - // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_TO_NSINODE - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(nsSVGElement::) - - // nsIContent interface - NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const; - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -protected: - virtual nsSVGViewBox *GetViewBox(); - virtual SVGAnimatedPreserveAspectRatio *GetPreserveAspectRatio(); - - nsSVGViewBox mViewBox; - SVGAnimatedPreserveAspectRatio mPreserveAspectRatio; -}; - -NS_IMPL_NS_NEW_SVG_ELEMENT(Symbol) - -//---------------------------------------------------------------------- -// nsISupports methods - -NS_IMPL_ADDREF_INHERITED(nsSVGSymbolElement,nsSVGSymbolElementBase) -NS_IMPL_RELEASE_INHERITED(nsSVGSymbolElement,nsSVGSymbolElementBase) - -DOMCI_NODE_DATA(SVGSymbolElement, nsSVGSymbolElement) - -NS_INTERFACE_TABLE_HEAD(nsSVGSymbolElement) - NS_NODE_INTERFACE_TABLE5(nsSVGSymbolElement, nsIDOMNode, nsIDOMElement, - nsIDOMSVGElement, nsIDOMSVGFitToViewBox, - nsIDOMSVGSymbolElement) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGSymbolElement) -NS_INTERFACE_MAP_END_INHERITING(nsSVGSymbolElementBase) - -//---------------------------------------------------------------------- -// Implementation - -nsSVGSymbolElement::nsSVGSymbolElement(already_AddRefed aNodeInfo) - : nsSVGSymbolElementBase(aNodeInfo) -{ -} - - -//---------------------------------------------------------------------- -// nsIDOMNode methods - -NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGSymbolElement) - -//---------------------------------------------------------------------- -// nsIDOMSVGFitToViewBox methods - -/* readonly attribute nsIDOMSVGAnimatedRect viewBox; */ -NS_IMETHODIMP nsSVGSymbolElement::GetViewBox(nsIDOMSVGAnimatedRect * *aViewBox) -{ - return mViewBox.ToDOMAnimatedRect(aViewBox, this); -} - -/* readonly attribute SVGPreserveAspectRatio preserveAspectRatio; */ -NS_IMETHODIMP -nsSVGSymbolElement::GetPreserveAspectRatio(nsISupports - **aPreserveAspectRatio) -{ - nsRefPtr ratio; - mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this); - ratio.forget(aPreserveAspectRatio); - return NS_OK; -} - -//---------------------------------------------------------------------- -// nsIContent methods - -NS_IMETHODIMP_(bool) -nsSVGSymbolElement::IsAttributeMapped(const nsIAtom* name) const -{ - static const MappedAttributeEntry* const map[] = { - sColorMap, - sFEFloodMap, - sFillStrokeMap, - sFiltersMap, - sFontSpecificationMap, - sGradientStopMap, - sGraphicsMap, - sLightingEffectsMap, - sMarkersMap, - sTextContentElementsMap, - sViewportsMap - }; - - return FindAttributeDependence(name, map) || - nsSVGSymbolElementBase::IsAttributeMapped(name); -} - -//---------------------------------------------------------------------- -// nsSVGElement methods - -nsSVGViewBox * -nsSVGSymbolElement::GetViewBox() -{ - return &mViewBox; -} - -SVGAnimatedPreserveAspectRatio * -nsSVGSymbolElement::GetPreserveAspectRatio() -{ - return &mPreserveAspectRatio; -}