From cb9307ea4a60c33d4b9dcd4c320e617cddae74ff Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Sun, 6 Jan 2013 09:14:44 -0500 Subject: [PATCH] Bug 825732: Convert SVGTSpanElement to WebIDL r=bz --HG-- rename : content/svg/content/src/nsSVGTSpanElement.cpp => content/svg/content/src/SVGTSpanElement.cpp rename : content/svg/content/src/nsSVGTSpanElement.cpp => content/svg/content/src/SVGTSpanElement.h --- content/svg/content/src/Makefile.in | 3 +- content/svg/content/src/SVGTSpanElement.cpp | 87 +++++++++++++ content/svg/content/src/SVGTSpanElement.h | 60 +++++++++ content/svg/content/src/nsSVGTSpanElement.cpp | 122 ------------------ dom/webidl/SVGTSpanElement.webidl | 15 +++ dom/webidl/WebIDL.mk | 1 + 6 files changed, 165 insertions(+), 123 deletions(-) create mode 100644 content/svg/content/src/SVGTSpanElement.cpp create mode 100644 content/svg/content/src/SVGTSpanElement.h delete mode 100644 content/svg/content/src/nsSVGTSpanElement.cpp create mode 100644 dom/webidl/SVGTSpanElement.webidl diff --git a/content/svg/content/src/Makefile.in b/content/svg/content/src/Makefile.in index 6a03139caa58..8c5f84fe530b 100644 --- a/content/svg/content/src/Makefile.in +++ b/content/svg/content/src/Makefile.in @@ -66,7 +66,6 @@ CPPSRCS = \ nsSVGRect.cpp \ nsSVGSVGElement.cpp \ nsSVGSymbolElement.cpp \ - nsSVGTSpanElement.cpp \ nsSVGUnknownElement.cpp \ nsSVGUseElement.cpp \ nsSVGViewBox.cpp \ @@ -136,6 +135,7 @@ CPPSRCS = \ SVGTransformList.cpp \ SVGTransformListParser.cpp \ SVGTransformListSMILType.cpp \ + SVGTSpanElement.cpp \ SVGViewBoxSMILType.cpp \ $(NULL) @@ -186,6 +186,7 @@ EXPORTS_mozilla/dom = \ SVGTextPositioningElement.h \ SVGTitleElement.h \ SVGTransformableElement.h \ + SVGTSpanElement.h \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/content/svg/content/src/SVGTSpanElement.cpp b/content/svg/content/src/SVGTSpanElement.cpp new file mode 100644 index 000000000000..0ced855e5edc --- /dev/null +++ b/content/svg/content/src/SVGTSpanElement.cpp @@ -0,0 +1,87 @@ +/* -*- 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/SVGTSpanElement.h" +#include "mozilla/dom/SVGTSpanElementBinding.h" + +DOMCI_NODE_DATA(SVGTSpanElement, mozilla::dom::SVGTSpanElement) + +NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(TSpan) + +namespace mozilla { +namespace dom { + +JSObject* +SVGTSpanElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) +{ + return SVGTSpanElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(SVGTSpanElement,SVGTSpanElementBase) +NS_IMPL_RELEASE_INHERITED(SVGTSpanElement,SVGTSpanElementBase) + +NS_INTERFACE_TABLE_HEAD(SVGTSpanElement) + NS_NODE_INTERFACE_TABLE6(SVGTSpanElement, nsIDOMNode, nsIDOMElement, + nsIDOMSVGElement, nsIDOMSVGTSpanElement, + nsIDOMSVGTextPositioningElement, + nsIDOMSVGTextContentElement) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGTSpanElement) +NS_INTERFACE_MAP_END_INHERITING(SVGTSpanElementBase) + +//---------------------------------------------------------------------- +// Implementation + +SVGTSpanElement::SVGTSpanElement(already_AddRefed aNodeInfo) + : SVGTSpanElementBase(aNodeInfo) +{ + SetIsDOMBinding(); +} + + +//---------------------------------------------------------------------- +// nsIDOMNode methods + + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGTSpanElement) + + +//---------------------------------------------------------------------- +// nsIDOMSVGTSpanElement methods + +// - no methods - + +//---------------------------------------------------------------------- +// nsIContent methods + +NS_IMETHODIMP_(bool) +SVGTSpanElement::IsAttributeMapped(const nsIAtom* name) const +{ + static const MappedAttributeEntry* const map[] = { + sColorMap, + sFillStrokeMap, + sFontSpecificationMap, + sGraphicsMap, + sTextContentElementsMap + }; + + return FindAttributeDependence(name, map) || + SVGTSpanElementBase::IsAttributeMapped(name); +} + +//---------------------------------------------------------------------- +// nsSVGElement overrides + +bool +SVGTSpanElement::IsEventName(nsIAtom* aName) +{ + return nsContentUtils::IsEventAttributeName(aName, EventNameType_SVGGraphic); +} + +} // namespace dom +} // namespace mozilla diff --git a/content/svg/content/src/SVGTSpanElement.h b/content/svg/content/src/SVGTSpanElement.h new file mode 100644 index 000000000000..0284c1fcc80f --- /dev/null +++ b/content/svg/content/src/SVGTSpanElement.h @@ -0,0 +1,60 @@ +/* -*- 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_SVGTSpanElement_h +#define mozilla_dom_SVGTSpanElement_h + +#include "mozilla/dom/SVGTextPositioningElement.h" +#include "nsIDOMSVGTSpanElement.h" + +nsresult NS_NewSVGTSpanElement(nsIContent **aResult, + already_AddRefed aNodeInfo); + +namespace mozilla { +namespace dom { + +typedef SVGTextPositioningElement SVGTSpanElementBase; + +class SVGTSpanElement MOZ_FINAL : public SVGTSpanElementBase, // = nsIDOMSVGTextPositioningElement + public nsIDOMSVGTSpanElement +{ +protected: + friend nsresult (::NS_NewSVGTSpanElement(nsIContent **aResult, + already_AddRefed aNodeInfo)); + SVGTSpanElement(already_AddRefed aNodeInfo); + virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE; + +public: + // interfaces: + + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMSVGTSPANELEMENT + + // xxx If xpcom allowed virtual inheritance we wouldn't need to + // forward here :-( + NS_FORWARD_NSIDOMNODE_TO_NSINODE + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + NS_FORWARD_NSIDOMSVGELEMENT(SVGTSpanElementBase::) + NS_FORWARD_NSIDOMSVGTEXTCONTENTELEMENT(SVGTSpanElementBase::) + NS_FORWARD_NSIDOMSVGTEXTPOSITIONINGELEMENT(SVGTSpanElementBase::) + + // nsIContent interface + NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +protected: + + // nsSVGElement overrides + virtual bool IsEventName(nsIAtom* aName); +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_SVGTSpanElement_h diff --git a/content/svg/content/src/nsSVGTSpanElement.cpp b/content/svg/content/src/nsSVGTSpanElement.cpp deleted file mode 100644 index 808d140fe10d..000000000000 --- a/content/svg/content/src/nsSVGTSpanElement.cpp +++ /dev/null @@ -1,122 +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 "nsGkAtoms.h" -#include "nsIDOMSVGTSpanElement.h" -#include "nsSVGSVGElement.h" -#include "SVGTextPositioningElement.h" -#include "nsContentUtils.h" - -using namespace mozilla; - -typedef dom::SVGTextPositioningElement nsSVGTSpanElementBase; - -class nsSVGTSpanElement : public nsSVGTSpanElementBase, // = nsIDOMSVGTextPositioningElement - public nsIDOMSVGTSpanElement -{ -protected: - friend nsresult NS_NewSVGTSpanElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - nsSVGTSpanElement(already_AddRefed aNodeInfo); - -public: - // interfaces: - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIDOMSVGTSPANELEMENT - - // xxx If xpcom allowed virtual inheritance we wouldn't need to - // forward here :-( - NS_FORWARD_NSIDOMNODE_TO_NSINODE - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(nsSVGTSpanElementBase::) - NS_FORWARD_NSIDOMSVGTEXTCONTENTELEMENT(nsSVGTSpanElementBase::) - NS_FORWARD_NSIDOMSVGTEXTPOSITIONINGELEMENT(nsSVGTSpanElementBase::) - - // nsIContent interface - NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } - - virtual bool IsEventAttributeName(nsIAtom* aName) MOZ_OVERRIDE; -}; - - -NS_IMPL_NS_NEW_SVG_ELEMENT(TSpan) - - -//---------------------------------------------------------------------- -// nsISupports methods - -NS_IMPL_ADDREF_INHERITED(nsSVGTSpanElement,nsSVGTSpanElementBase) -NS_IMPL_RELEASE_INHERITED(nsSVGTSpanElement,nsSVGTSpanElementBase) - -DOMCI_NODE_DATA(SVGTSpanElement, nsSVGTSpanElement) - -NS_INTERFACE_TABLE_HEAD(nsSVGTSpanElement) - NS_NODE_INTERFACE_TABLE6(nsSVGTSpanElement, nsIDOMNode, nsIDOMElement, - nsIDOMSVGElement, nsIDOMSVGTSpanElement, - nsIDOMSVGTextPositioningElement, - nsIDOMSVGTextContentElement) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGTSpanElement) -NS_INTERFACE_MAP_END_INHERITING(nsSVGTSpanElementBase) - -//---------------------------------------------------------------------- -// Implementation - -nsSVGTSpanElement::nsSVGTSpanElement(already_AddRefed aNodeInfo) - : nsSVGTSpanElementBase(aNodeInfo) -{ - -} - - -//---------------------------------------------------------------------- -// nsIDOMNode methods - - -NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGTSpanElement) - - -//---------------------------------------------------------------------- -// nsIDOMSVGTSpanElement methods - -// - no methods - - -//---------------------------------------------------------------------- -// nsIContent methods - -NS_IMETHODIMP_(bool) -nsSVGTSpanElement::IsAttributeMapped(const nsIAtom* name) const -{ - static const MappedAttributeEntry* const map[] = { - sColorMap, - sFillStrokeMap, - sFontSpecificationMap, - sGraphicsMap, - sTextContentElementsMap - }; - - return FindAttributeDependence(name, map) || - nsSVGTSpanElementBase::IsAttributeMapped(name); -} - - -bool -nsSVGTSpanElement::IsEventAttributeName(nsIAtom* aName) -{ - return nsContentUtils::IsEventAttributeName(aName, EventNameType_SVGGraphic); -} - -//---------------------------------------------------------------------- -// nsSVGElement overrides - -// - no methods - diff --git a/dom/webidl/SVGTSpanElement.webidl b/dom/webidl/SVGTSpanElement.webidl new file mode 100644 index 000000000000..a6d944450cbc --- /dev/null +++ b/dom/webidl/SVGTSpanElement.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 SVGTSpanElement : SVGTextPositioningElement { +}; + diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index ed53b1a8bbbf..926ad859522d 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -146,6 +146,7 @@ webidl_files = \ SVGTransform.webidl \ SVGTransformableElement.webidl \ SVGTransformList.webidl \ + SVGTSpanElement.webidl \ SVGURIReference.webidl \ Text.webidl \ TextDecoder.webidl \