Bug 824327: Convert SVGStopElement to WebIDL r=bz
authorDavid Zbarsky <dzbarsky@gmail.com>
Fri, 04 Jan 2013 17:28:05 -0500
changeset 126786 00e9c72fa4101efe07b4ae5f9b0047252cc43e14
parent 126785 2a2fdd3161f8eba414362e6daf9899b60542e0b4
child 126787 83dd11d6dc7febf736520d2997cc082da199c43e
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs824327
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 824327: Convert SVGStopElement to WebIDL r=bz
content/svg/content/src/Makefile.in
content/svg/content/src/SVGStopElement.cpp
content/svg/content/src/SVGStopElement.h
content/svg/content/src/nsSVGStopElement.cpp
dom/bindings/Bindings.conf
dom/webidl/SVGStopElement.webidl
dom/webidl/WebIDL.mk
--- a/content/svg/content/src/Makefile.in
+++ b/content/svg/content/src/Makefile.in
@@ -73,17 +73,16 @@ CPPSRCS		= \
 		nsSVGPolyElement.cpp \
 		nsSVGPolygonElement.cpp \
 		nsSVGPolylineElement.cpp \
 		nsSVGScriptElement.cpp \
 		nsSVGString.cpp \
 		nsSVGRect.cpp \
 		nsSVGRectElement.cpp \
 		nsSVGSVGElement.cpp \
-		nsSVGStopElement.cpp \
 		nsSVGStyleElement.cpp \
 		nsSVGSwitchElement.cpp \
 		nsSVGSymbolElement.cpp \
 		nsSVGTSpanElement.cpp \
 		nsSVGTextContentElement.cpp \
 		nsSVGTextElement.cpp \
 		nsSVGTextPathElement.cpp \
 		nsSVGTextPositioningElement.cpp \
@@ -128,16 +127,17 @@ CPPSRCS		= \
 		SVGMotionSMILAttr.cpp \
 		SVGMotionSMILAnimationFunction.cpp \
 		SVGMotionSMILPathUtils.cpp \
 		SVGNumberListSMILType.cpp \
 		SVGNumberPairSMILType.cpp \
 		SVGOrientSMILType.cpp \
 		SVGPathSegListSMILType.cpp \
 		SVGPointListSMILType.cpp \
+		SVGStopElement.cpp \
 		SVGTransformListSMILType.cpp \
 		SVGViewBoxSMILType.cpp \
 		$(NULL)
 
 include $(topsrcdir)/config/config.mk
 
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
@@ -150,16 +150,17 @@ EXPORTS =  			\
 
 EXPORTS_NAMESPACES = mozilla/dom
 
 EXPORTS_mozilla/dom = \
 	SVGAngle.h \
 	SVGAnimatedAngle.h \
 	SVGAnimatedBoolean.h \
 	SVGDescElement.h \
+	SVGStopElement.h \
 	SVGTitleElement.h \
 	$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 INCLUDES += 	\
 		-I$(srcdir)/../../../xml/content/src \
 		-I$(srcdir)/../../../../dom \
rename from content/svg/content/src/nsSVGStopElement.cpp
rename to content/svg/content/src/SVGStopElement.cpp
--- a/content/svg/content/src/nsSVGStopElement.cpp
+++ b/content/svg/content/src/SVGStopElement.cpp
@@ -1,118 +1,93 @@
 /* -*- 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 "nsSVGElement.h"
-#include "nsIDOMSVGStopElement.h"
-#include "nsSVGNumber2.h"
-#include "nsGenericHTMLElement.h"
-
-using namespace mozilla;
-
-typedef nsSVGElement nsSVGStopElementBase;
+#include "mozilla/dom/SVGStopElement.h"
+#include "mozilla/dom/SVGStopElementBinding.h"
 
-class nsSVGStopElement : public nsSVGStopElementBase,
-                         public nsIDOMSVGStopElement
-{
-protected:
-  friend nsresult NS_NewSVGStopElement(nsIContent **aResult,
-                                       already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGStopElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+DOMCI_NODE_DATA(SVGStopElement, mozilla::dom::SVGStopElement)
 
-public:
-  // interfaces:
-
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMSVGSTOPELEMENT
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Stop)
 
-  // 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(nsSVGStopElementBase::)
-
-  // nsIContent interface
-  NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
-
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
-
-  virtual nsXPCClassInfo* GetClassInfo();
+namespace mozilla {
+namespace dom {
 
-  virtual nsIDOMNode* AsDOMNode() { return this; }
-protected:
+JSObject*
+SVGStopElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return SVGStopElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
 
-  virtual NumberAttributesInfo GetNumberInfo();
-  // nsIDOMSVGStopElement properties:
-  nsSVGNumber2 mOffset;
-  static NumberInfo sNumberInfo;
-};
-
-nsSVGElement::NumberInfo nsSVGStopElement::sNumberInfo =
+nsSVGElement::NumberInfo SVGStopElement::sNumberInfo =
 { &nsGkAtoms::offset, 0, true };
 
-NS_IMPL_NS_NEW_SVG_ELEMENT(Stop)
-
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGStopElement,nsSVGStopElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGStopElement,nsSVGStopElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGStopElement, SVGStopElementBase)
+NS_IMPL_RELEASE_INHERITED(SVGStopElement, SVGStopElementBase)
 
-DOMCI_NODE_DATA(SVGStopElement, nsSVGStopElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGStopElement)
-  NS_NODE_INTERFACE_TABLE4(nsSVGStopElement, nsIDOMNode, nsIDOMElement,
+NS_INTERFACE_TABLE_HEAD(SVGStopElement)
+  NS_NODE_INTERFACE_TABLE4(SVGStopElement, nsIDOMNode, nsIDOMElement,
                            nsIDOMSVGElement, nsIDOMSVGStopElement)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStopElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGStopElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGStopElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGStopElement::nsSVGStopElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGStopElementBase(aNodeInfo)
+SVGStopElement::SVGStopElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGStopElementBase(aNodeInfo)
 {
-
+  SetIsDOMBinding();
 }
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGStopElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGStopElement)
 
 //----------------------------------------------------------------------
 // nsIDOMSVGStopElement methods
 
 /* readonly attribute nsIDOMSVGAnimatedNumber offset; */
-NS_IMETHODIMP nsSVGStopElement::GetOffset(nsIDOMSVGAnimatedNumber * *aOffset)
+NS_IMETHODIMP SVGStopElement::GetOffset(nsIDOMSVGAnimatedNumber * *aOffset)
 {
   return mOffset.ToDOMAnimatedNumber(aOffset,this);
 }
 
+already_AddRefed<nsIDOMSVGAnimatedNumber>
+SVGStopElement::Offset()
+{
+  nsCOMPtr<nsIDOMSVGAnimatedNumber> offset;
+  mOffset.ToDOMAnimatedNumber(getter_AddRefs(offset), this);
+  return offset.forget();
+}
+
 //----------------------------------------------------------------------
-// nsSVGElement methods
+// sSVGElement methods
 
 nsSVGElement::NumberAttributesInfo
-nsSVGStopElement::GetNumberInfo()
+SVGStopElement::GetNumberInfo()
 {
   return NumberAttributesInfo(&mOffset, &sNumberInfo, 1);
 }
 
 //----------------------------------------------------------------------
 // nsIContent methods
 
 NS_IMETHODIMP_(bool)
-nsSVGStopElement::IsAttributeMapped(const nsIAtom* name) const
+SVGStopElement::IsAttributeMapped(const nsIAtom* name) const
 {
   static const MappedAttributeEntry* const map[] = {
     sGradientStopMap
   };
-  
+
   return FindAttributeDependence(name, map) ||
-    nsSVGStopElementBase::IsAttributeMapped(name);
+    SVGStopElementBase::IsAttributeMapped(name);
 }
 
+} // namespace dom
+} // namespace mozilla
 
copy from content/svg/content/src/nsSVGStopElement.cpp
copy to content/svg/content/src/SVGStopElement.h
--- a/content/svg/content/src/nsSVGStopElement.cpp
+++ b/content/svg/content/src/SVGStopElement.h
@@ -1,118 +1,65 @@
 /* -*- 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"
+#ifndef mozilla_dom_SVGStopElement_h
+#define mozilla_dom_SVGStopElement_h
 
 #include "nsSVGElement.h"
+#include "nsSVGNumber2.h"
 #include "nsIDOMSVGStopElement.h"
-#include "nsSVGNumber2.h"
-#include "nsGenericHTMLElement.h"
+
+nsresult NS_NewSVGStopElement(nsIContent **aResult,
+                              already_AddRefed<nsINodeInfo> aNodeInfo);
 
-using namespace mozilla;
+typedef nsSVGElement SVGStopElementBase;
 
-typedef nsSVGElement nsSVGStopElementBase;
+namespace mozilla {
+namespace dom {
 
-class nsSVGStopElement : public nsSVGStopElementBase,
-                         public nsIDOMSVGStopElement
+class SVGStopElement MOZ_FINAL : public SVGStopElementBase,
+                                 public nsIDOMSVGStopElement
 {
 protected:
-  friend nsresult NS_NewSVGStopElement(nsIContent **aResult,
-                                       already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGStopElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  friend nsresult (::NS_NewSVGStopElement(nsIContent **aResult,
+                                          already_AddRefed<nsINodeInfo> aNodeInfo));
+  SVGStopElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
 
 public:
   // interfaces:
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMSVGSTOPELEMENT
 
   // 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(nsSVGStopElementBase::)
+  NS_FORWARD_NSIDOMSVGELEMENT(SVGStopElementBase::)
 
   // 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; }
+
+  // WebIDL
+  already_AddRefed<nsIDOMSVGAnimatedNumber> Offset();
+
 protected:
 
   virtual NumberAttributesInfo GetNumberInfo();
   // nsIDOMSVGStopElement properties:
   nsSVGNumber2 mOffset;
   static NumberInfo sNumberInfo;
 };
 
-nsSVGElement::NumberInfo nsSVGStopElement::sNumberInfo =
-{ &nsGkAtoms::offset, 0, true };
-
-NS_IMPL_NS_NEW_SVG_ELEMENT(Stop)
-
-//----------------------------------------------------------------------
-// nsISupports methods
-
-NS_IMPL_ADDREF_INHERITED(nsSVGStopElement,nsSVGStopElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGStopElement,nsSVGStopElementBase)
-
-DOMCI_NODE_DATA(SVGStopElement, nsSVGStopElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGStopElement)
-  NS_NODE_INTERFACE_TABLE4(nsSVGStopElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGStopElement)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStopElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGStopElementBase)
-
-//----------------------------------------------------------------------
-// Implementation
-
-nsSVGStopElement::nsSVGStopElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGStopElementBase(aNodeInfo)
-{
-
-}
-
-//----------------------------------------------------------------------
-// nsIDOMNode methods
-
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGStopElement)
+} // namespace dom
+} // namespace mozilla
 
-//----------------------------------------------------------------------
-// nsIDOMSVGStopElement methods
-
-/* readonly attribute nsIDOMSVGAnimatedNumber offset; */
-NS_IMETHODIMP nsSVGStopElement::GetOffset(nsIDOMSVGAnimatedNumber * *aOffset)
-{
-  return mOffset.ToDOMAnimatedNumber(aOffset,this);
-}
-
-//----------------------------------------------------------------------
-// nsSVGElement methods
-
-nsSVGElement::NumberAttributesInfo
-nsSVGStopElement::GetNumberInfo()
-{
-  return NumberAttributesInfo(&mOffset, &sNumberInfo, 1);
-}
-
-//----------------------------------------------------------------------
-// nsIContent methods
-
-NS_IMETHODIMP_(bool)
-nsSVGStopElement::IsAttributeMapped(const nsIAtom* name) const
-{
-  static const MappedAttributeEntry* const map[] = {
-    sGradientStopMap
-  };
-  
-  return FindAttributeDependence(name, map) ||
-    nsSVGStopElementBase::IsAttributeMapped(name);
-}
-
-
+#endif // mozilla_dom_SVGStopElement_h
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1117,16 +1117,17 @@ addExternalIface('nsISupports', nativeTy
 addExternalIface('OutputStream', nativeType='nsIOutputStream',
                  notflattened=True)
 addExternalIface('Principal', nativeType='nsIPrincipal',
                  headerFile='nsIPrincipal.h', notflattened=True)
 addExternalIface('ProcessingInstruction', nativeType='nsXMLProcessingInstruction')
 addExternalIface('Range', nativeType='nsRange')
 addExternalIface('Selection', nativeType='nsISelection')
 addExternalIface('StyleSheetList')
+addExternalIface('SVGAnimatedNumber')
 addExternalIface('SVGAnimatedString')
 addExternalIface('SVGLength')
 addExternalIface('SVGNumber')
 addExternalIface('SVGSVGElement', nativeType='nsSVGSVGElement')
 addExternalIface('TextMetrics', headerFile='nsIDOMCanvasRenderingContext2D.h')
 addExternalIface('TreeWalker')
 addExternalIface('Touch', headerFile='nsIDOMTouchEvent.h')
 addExternalIface('TouchList', headerFile='nsIDOMTouchEvent.h')
new file mode 100644
--- /dev/null
+++ b/dom/webidl/SVGStopElement.webidl
@@ -0,0 +1,18 @@
+/* -*- 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 SVGAnimatedNumber;
+
+interface SVGStopElement : SVGElement {
+  readonly attribute SVGAnimatedNumber offset;
+};
+
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -101,16 +101,17 @@ webidl_files = \
   SVGLengthList.webidl \
   SVGMatrix.webidl \
   SVGNumberList.webidl \
   SVGPathSeg.webidl \
   SVGPathSegList.webidl \
   SVGPoint.webidl \
   SVGPointList.webidl \
   SVGPreserveAspectRatio.webidl \
+  SVGStopElement.webidl \
   SVGTitleElement.webidl \
   SVGTransform.webidl \
   SVGTransformList.webidl \
   Text.webidl \
   TextDecoder.webidl \
   TextEncoder.webidl \
   URL.webidl \
   WebSocket.webidl \