From 866a8a4d20b584eab9fc3c48f8f2751273a43284 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Sun, 6 Jan 2013 01:25:54 -0500 Subject: [PATCH] Bug 825147: Convert SVGDefsElement to WebIDL r=bz --HG-- rename : content/svg/content/src/nsSVGDefsElement.cpp => content/svg/content/src/SVGDefsElement.cpp rename : content/svg/content/src/nsSVGDefsElement.cpp => content/svg/content/src/SVGDefsElement.h --- content/svg/content/src/Makefile.in | 3 +- content/svg/content/src/SVGDefsElement.cpp | 74 ++++++++++++++ content/svg/content/src/SVGDefsElement.h | 52 ++++++++++ content/svg/content/src/nsSVGDefsElement.cpp | 101 ------------------- dom/webidl/SVGDefsElement.webidl | 15 +++ dom/webidl/WebIDL.mk | 1 + 6 files changed, 144 insertions(+), 102 deletions(-) create mode 100644 content/svg/content/src/SVGDefsElement.cpp create mode 100644 content/svg/content/src/SVGDefsElement.h delete mode 100644 content/svg/content/src/nsSVGDefsElement.cpp create mode 100644 dom/webidl/SVGDefsElement.webidl diff --git a/content/svg/content/src/Makefile.in b/content/svg/content/src/Makefile.in index f2269cecc411..1a89a01e1d26 100644 --- a/content/svg/content/src/Makefile.in +++ b/content/svg/content/src/Makefile.in @@ -44,7 +44,6 @@ CPPSRCS = \ nsSVGClass.cpp \ nsSVGClipPathElement.cpp \ nsSVGDataParser.cpp \ - nsSVGDefsElement.cpp \ nsSVGElement.cpp \ nsSVGElementFactory.cpp \ nsSVGEllipseElement.cpp \ @@ -116,6 +115,7 @@ CPPSRCS = \ nsSVGSetElement.cpp \ SVGAttrValueWrapper.cpp \ SVGContentUtils.cpp \ + SVGDefsElement.cpp \ SVGDescElement.cpp \ SVGIntegerPairSMILType.cpp \ SVGLengthListSMILType.cpp \ @@ -156,6 +156,7 @@ EXPORTS_mozilla/dom = \ SVGAngle.h \ SVGAnimatedAngle.h \ SVGAnimatedBoolean.h \ + SVGDefsElement.h \ SVGDescElement.h \ SVGGraphicsElement.h \ SVGLocatableElement.h \ diff --git a/content/svg/content/src/SVGDefsElement.cpp b/content/svg/content/src/SVGDefsElement.cpp new file mode 100644 index 000000000000..6d8226ae0a2a --- /dev/null +++ b/content/svg/content/src/SVGDefsElement.cpp @@ -0,0 +1,74 @@ +/* -*- 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/SVGDefsElement.h" +#include "mozilla/dom/SVGDefsElementBinding.h" + +DOMCI_NODE_DATA(SVGDefsElement, mozilla::dom::SVGDefsElement) + +NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Defs) + +namespace mozilla { +namespace dom { + +JSObject* +SVGDefsElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) +{ + return SVGDefsElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(SVGDefsElement, SVGGraphicsElement) +NS_IMPL_RELEASE_INHERITED(SVGDefsElement, SVGGraphicsElement) + +NS_INTERFACE_TABLE_HEAD(SVGDefsElement) + NS_NODE_INTERFACE_TABLE4(SVGDefsElement, nsIDOMNode, nsIDOMElement, + nsIDOMSVGElement, + nsIDOMSVGDefsElement) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGDefsElement) +NS_INTERFACE_MAP_END_INHERITING(SVGGraphicsElement) + +//---------------------------------------------------------------------- +// Implementation + +SVGDefsElement::SVGDefsElement(already_AddRefed aNodeInfo) + : SVGGraphicsElement(aNodeInfo) +{ + SetIsDOMBinding(); +} + +//---------------------------------------------------------------------- +// nsIDOMNode methods + + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGDefsElement) + + +//---------------------------------------------------------------------- +// nsIContent methods + +NS_IMETHODIMP_(bool) +SVGDefsElement::IsAttributeMapped(const nsIAtom* name) const +{ + static const MappedAttributeEntry* const map[] = { + sFEFloodMap, + sFiltersMap, + sFontSpecificationMap, + sGradientStopMap, + sLightingEffectsMap, + sMarkersMap, + sTextContentElementsMap, + sViewportsMap + }; + + return FindAttributeDependence(name, map) || + SVGGraphicsElement::IsAttributeMapped(name); +} + +} // namespace dom +} // namespace mozilla + diff --git a/content/svg/content/src/SVGDefsElement.h b/content/svg/content/src/SVGDefsElement.h new file mode 100644 index 000000000000..b373431d603a --- /dev/null +++ b/content/svg/content/src/SVGDefsElement.h @@ -0,0 +1,52 @@ +/* -*- 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_SVGDefsElement_h +#define mozilla_dom_SVGDefsElement_h + +#include "mozilla/Util.h" +#include "SVGGraphicsElement.h" +#include "nsIDOMSVGDefsElement.h" + +nsresult NS_NewSVGDefsElement(nsIContent **aResult, + already_AddRefed aNodeInfo); + +namespace mozilla { +namespace dom { + +class SVGDefsElement MOZ_FINAL : public SVGGraphicsElement, + public nsIDOMSVGDefsElement +{ +protected: + friend nsresult (::NS_NewSVGDefsElement(nsIContent **aResult, + already_AddRefed aNodeInfo)); + SVGDefsElement(already_AddRefed aNodeInfo); + virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE; + +public: + // interfaces: + + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMSVGDEFSELEMENT + + // xxx I wish we could use virtual inheritance + NS_FORWARD_NSIDOMNODE_TO_NSINODE + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + NS_FORWARD_NSIDOMSVGELEMENT(SVGGraphicsElement::) + + // nsIContent + NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_SVGDefsElement_h diff --git a/content/svg/content/src/nsSVGDefsElement.cpp b/content/svg/content/src/nsSVGDefsElement.cpp deleted file mode 100644 index 8370ceca7d0d..000000000000 --- a/content/svg/content/src/nsSVGDefsElement.cpp +++ /dev/null @@ -1,101 +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 "SVGGraphicsElement.h" -#include "nsIDOMSVGDefsElement.h" - -using namespace mozilla; - -typedef mozilla::dom::SVGGraphicsElement nsSVGDefsElementBase; - -class nsSVGDefsElement : public nsSVGDefsElementBase, - public nsIDOMSVGDefsElement -{ -protected: - friend nsresult NS_NewSVGDefsElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - nsSVGDefsElement(already_AddRefed aNodeInfo); - -public: - // interfaces: - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIDOMSVGDEFSELEMENT - - // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_TO_NSINODE - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(nsSVGDefsElementBase::) - - // nsIContent - NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -}; - -//////////////////////////////////////////////////////////////////////// -// implementation - - -NS_IMPL_NS_NEW_SVG_ELEMENT(Defs) - - -//---------------------------------------------------------------------- -// nsISupports methods - -NS_IMPL_ADDREF_INHERITED(nsSVGDefsElement,nsSVGDefsElementBase) -NS_IMPL_RELEASE_INHERITED(nsSVGDefsElement,nsSVGDefsElementBase) - -DOMCI_NODE_DATA(SVGDefsElement, nsSVGDefsElement) - -NS_INTERFACE_TABLE_HEAD(nsSVGDefsElement) - NS_NODE_INTERFACE_TABLE4(nsSVGDefsElement, nsIDOMNode, nsIDOMElement, - nsIDOMSVGElement, - nsIDOMSVGDefsElement) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGDefsElement) -NS_INTERFACE_MAP_END_INHERITING(nsSVGDefsElementBase) - -//---------------------------------------------------------------------- -// Implementation - -nsSVGDefsElement::nsSVGDefsElement(already_AddRefed aNodeInfo) - : nsSVGDefsElementBase(aNodeInfo) -{ - -} - -//---------------------------------------------------------------------- -// nsIDOMNode methods - - -NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGDefsElement) - - -//---------------------------------------------------------------------- -// nsIContent methods - -NS_IMETHODIMP_(bool) -nsSVGDefsElement::IsAttributeMapped(const nsIAtom* name) const -{ - static const MappedAttributeEntry* const map[] = { - sFEFloodMap, - sFiltersMap, - sFontSpecificationMap, - sGradientStopMap, - sLightingEffectsMap, - sMarkersMap, - sTextContentElementsMap, - sViewportsMap - }; - - return FindAttributeDependence(name, map) || - nsSVGDefsElementBase::IsAttributeMapped(name); -} diff --git a/dom/webidl/SVGDefsElement.webidl b/dom/webidl/SVGDefsElement.webidl new file mode 100644 index 000000000000..0b37978b47bc --- /dev/null +++ b/dom/webidl/SVGDefsElement.webidl @@ -0,0 +1,15 @@ +/* -*- 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 SVGDefsElement : SVGGraphicsElement { +}; + diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 3451923edcdd..b6df02c1342a 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -103,6 +103,7 @@ webidl_files = \ SVGAnimatedNumberList.webidl \ SVGAnimatedPreserveAspectRatio.webidl \ SVGAnimatedTransformList.webidl \ + SVGDefsElement.webidl \ SVGDescElement.webidl \ SVGElement.webidl \ SVGGraphicsElement.webidl \