Bug 824327: Convert SVGTitleElement to WebIDL r=bz
authorDavid Zbarsky <dzbarsky@gmail.com>
Fri, 04 Jan 2013 17:28:05 -0500
changeset 126785 2a2fdd3161f8eba414362e6daf9899b60542e0b4
parent 126784 60c936f77dce372d976ac429bc54aa75d57a2860
child 126786 00e9c72fa4101efe07b4ae5f9b0047252cc43e14
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 SVGTitleElement to WebIDL r=bz
content/svg/content/src/Makefile.in
content/svg/content/src/SVGTitleElement.cpp
content/svg/content/src/SVGTitleElement.h
content/svg/content/src/nsSVGTitleElement.cpp
dom/bindings/Bindings.conf
dom/webidl/SVGTitleElement.webidl
dom/webidl/WebIDL.mk
--- a/content/svg/content/src/Makefile.in
+++ b/content/svg/content/src/Makefile.in
@@ -82,17 +82,16 @@ CPPSRCS		= \
 		nsSVGStyleElement.cpp \
 		nsSVGSwitchElement.cpp \
 		nsSVGSymbolElement.cpp \
 		nsSVGTSpanElement.cpp \
 		nsSVGTextContentElement.cpp \
 		nsSVGTextElement.cpp \
 		nsSVGTextPathElement.cpp \
 		nsSVGTextPositioningElement.cpp \
-		nsSVGTitleElement.cpp \
 		nsSVGUnknownElement.cpp \
 		nsSVGUseElement.cpp \
 		nsSVGViewBox.cpp \
 		nsSVGViewElement.cpp \
 		SVGAngle.cpp \
 		SVGAnimatedAngle.cpp \
 		SVGAnimatedBoolean.cpp \
 		SVGAnimatedLengthList.cpp \
@@ -105,16 +104,17 @@ CPPSRCS		= \
 		SVGLength.cpp \
 		SVGLengthList.cpp \
 		SVGNumberList.cpp \
 		SVGPathData.cpp \
 		SVGPathSegUtils.cpp \
 		SVGPointList.cpp \
 		SVGPreserveAspectRatio.cpp \
 		SVGStringList.cpp \
+		SVGTitleElement.cpp \
 		SVGTransform.cpp \
 		SVGTransformList.cpp \
 		SVGTransformListParser.cpp \
 		nsSVGAnimateElement.cpp \
 		nsSVGAnimateTransformElement.cpp \
 		nsSVGAnimateMotionElement.cpp \
 		nsSVGAnimationElement.cpp \
 		nsSVGMpathElement.cpp \
@@ -150,16 +150,17 @@ EXPORTS =  			\
 
 EXPORTS_NAMESPACES = mozilla/dom
 
 EXPORTS_mozilla/dom = \
 	SVGAngle.h \
 	SVGAnimatedAngle.h \
 	SVGAnimatedBoolean.h \
 	SVGDescElement.h \
+	SVGTitleElement.h \
 	$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 INCLUDES += 	\
 		-I$(srcdir)/../../../xml/content/src \
 		-I$(srcdir)/../../../../dom \
 		-I$(srcdir)/../../../base/src \
rename from content/svg/content/src/nsSVGTitleElement.cpp
rename to content/svg/content/src/SVGTitleElement.cpp
--- a/content/svg/content/src/nsSVGTitleElement.cpp
+++ b/content/svg/content/src/SVGTitleElement.cpp
@@ -1,173 +1,131 @@
 /* -*- 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 "nsSVGElement.h"
-#include "nsIDOMSVGTitleElement.h"
-#include "nsStubMutationObserver.h"
-
-typedef nsSVGElement nsSVGTitleElementBase;
+#include "mozilla/dom/SVGTitleElement.h"
+#include "mozilla/dom/SVGTitleElementBinding.h"
 
-class nsSVGTitleElement : public nsSVGTitleElementBase,
-                          public nsIDOMSVGTitleElement,
-                          public nsStubMutationObserver
-{
-protected:
-  friend nsresult NS_NewSVGTitleElement(nsIContent **aResult,
-                                        already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGTitleElement(already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsresult Init();
+DOMCI_NODE_DATA(SVGTitleElement, mozilla::dom::SVGTitleElement)
 
-public:
-  // interfaces:
-
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMSVGTITLEELEMENT
-
-  // xxx I wish we could use virtual inheritance
-  NS_FORWARD_NSIDOMNODE_TO_NSINODE
-  NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGTitleElementBase::)
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Title)
 
-  // nsIMutationObserver
-  NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
-  NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
-  NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
-  NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
-
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
-
-  virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent,
-                              nsIContent *aBindingParent,
-                              bool aCompileEventHandlers);
+namespace mozilla {
+namespace dom {
 
-  virtual void UnbindFromTree(bool aDeep = true,
-                              bool aNullParent = true);
-
-  virtual void DoneAddingChildren(bool aHaveNotified);
-
-  virtual nsXPCClassInfo* GetClassInfo();
-
-  virtual nsIDOMNode* AsDOMNode() { return this; }
-private:
-  void SendTitleChangeEvent(bool aBound);
-};
-
-NS_IMPL_NS_NEW_SVG_ELEMENT(Title)
-
+JSObject*
+SVGTitleElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return SVGTitleElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGTitleElement, nsSVGTitleElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGTitleElement, nsSVGTitleElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGTitleElement, SVGTitleElementBase)
+NS_IMPL_RELEASE_INHERITED(SVGTitleElement, SVGTitleElementBase)
 
-DOMCI_NODE_DATA(SVGTitleElement, nsSVGTitleElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGTitleElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGTitleElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTitleElement,
+NS_INTERFACE_TABLE_HEAD(SVGTitleElement)
+  NS_NODE_INTERFACE_TABLE4(SVGTitleElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
                            nsIMutationObserver)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGTitleElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGTitleElementBase)
-
+NS_INTERFACE_MAP_END_INHERITING(SVGTitleElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGTitleElement::nsSVGTitleElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGTitleElementBase(aNodeInfo)
+SVGTitleElement::SVGTitleElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGTitleElementBase(aNodeInfo)
 {
+  SetIsDOMBinding();
   AddMutationObserver(this);
 }
 
-nsresult
-nsSVGTitleElement::Init()
-{
-  return nsSVGTitleElementBase::Init();
-}
-
 void
-nsSVGTitleElement::CharacterDataChanged(nsIDocument *aDocument,
-                                        nsIContent *aContent,
-                                        CharacterDataChangeInfo *aInfo)
+SVGTitleElement::CharacterDataChanged(nsIDocument *aDocument,
+                                      nsIContent *aContent,
+                                      CharacterDataChangeInfo *aInfo)
 {
   SendTitleChangeEvent(false);
 }
 
 void
-nsSVGTitleElement::ContentAppended(nsIDocument *aDocument,
-                                   nsIContent *aContainer,
-                                   nsIContent *aFirstNewContent,
-                                   int32_t aNewIndexInContainer)
+SVGTitleElement::ContentAppended(nsIDocument *aDocument,
+                                 nsIContent *aContainer,
+                                 nsIContent *aFirstNewContent,
+                                 int32_t aNewIndexInContainer)
 {
   SendTitleChangeEvent(false);
 }
 
 void
-nsSVGTitleElement::ContentInserted(nsIDocument *aDocument,
-                                   nsIContent *aContainer,
-                                   nsIContent *aChild,
-                                   int32_t aIndexInContainer)
+SVGTitleElement::ContentInserted(nsIDocument *aDocument,
+                                 nsIContent *aContainer,
+                                 nsIContent *aChild,
+                                 int32_t aIndexInContainer)
 {
   SendTitleChangeEvent(false);
 }
 
 void
-nsSVGTitleElement::ContentRemoved(nsIDocument *aDocument,
-                                  nsIContent *aContainer,
-                                  nsIContent *aChild,
-                                  int32_t aIndexInContainer,
-                                  nsIContent *aPreviousSibling)
+SVGTitleElement::ContentRemoved(nsIDocument *aDocument,
+                                nsIContent *aContainer,
+                                nsIContent *aChild,
+                                int32_t aIndexInContainer,
+                                nsIContent *aPreviousSibling)
 {
   SendTitleChangeEvent(false);
 }
 
 nsresult
-nsSVGTitleElement::BindToTree(nsIDocument *aDocument,
-                               nsIContent *aParent,
-                               nsIContent *aBindingParent,
-                               bool aCompileEventHandlers)
+SVGTitleElement::BindToTree(nsIDocument *aDocument,
+                             nsIContent *aParent,
+                             nsIContent *aBindingParent,
+                             bool aCompileEventHandlers)
 {
   // Let this fall through.
-  nsresult rv = nsSVGTitleElementBase::BindToTree(aDocument, aParent,
-                                                  aBindingParent,
-                                                  aCompileEventHandlers);
+  nsresult rv = SVGTitleElementBase::BindToTree(aDocument, aParent,
+                                                aBindingParent,
+                                                aCompileEventHandlers);
   NS_ENSURE_SUCCESS(rv, rv);
 
   SendTitleChangeEvent(true);
 
   return NS_OK;
 }
 
 void
-nsSVGTitleElement::UnbindFromTree(bool aDeep, bool aNullParent)
+SVGTitleElement::UnbindFromTree(bool aDeep, bool aNullParent)
 {
   SendTitleChangeEvent(false);
 
   // Let this fall through.
-  nsSVGTitleElementBase::UnbindFromTree(aDeep, aNullParent);
+  SVGTitleElementBase::UnbindFromTree(aDeep, aNullParent);
 }
 
 void
-nsSVGTitleElement::DoneAddingChildren(bool aHaveNotified)
+SVGTitleElement::DoneAddingChildren(bool aHaveNotified)
 {
   if (!aHaveNotified) {
     SendTitleChangeEvent(false);
   }
 }
 
 void
-nsSVGTitleElement::SendTitleChangeEvent(bool aBound)
+SVGTitleElement::SendTitleChangeEvent(bool aBound)
 {
   nsIDocument* doc = GetCurrentDoc();
   if (doc) {
     doc->NotifyPossibleTitleChange(aBound);
   }
 }
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGTitleElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGTitleElement)
+
+} // namespace dom
+} // namespace mozilla
+
copy from content/svg/content/src/nsSVGTitleElement.cpp
copy to content/svg/content/src/SVGTitleElement.h
--- a/content/svg/content/src/nsSVGTitleElement.cpp
+++ b/content/svg/content/src/SVGTitleElement.h
@@ -1,39 +1,47 @@
 /* -*- 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_SVGTitleElement_h
+#define mozilla_dom_SVGTitleElement_h
+
 #include "nsSVGElement.h"
 #include "nsIDOMSVGTitleElement.h"
 #include "nsStubMutationObserver.h"
 
-typedef nsSVGElement nsSVGTitleElementBase;
+typedef nsSVGElement SVGTitleElementBase;
 
-class nsSVGTitleElement : public nsSVGTitleElementBase,
-                          public nsIDOMSVGTitleElement,
-                          public nsStubMutationObserver
+nsresult NS_NewSVGTitleElement(nsIContent **aResult,
+                               already_AddRefed<nsINodeInfo> aNodeInfo);
+namespace mozilla {
+namespace dom {
+
+class SVGTitleElement MOZ_FINAL : public SVGTitleElementBase,
+                                  public nsStubMutationObserver,
+                                  public nsIDOMSVGTitleElement
 {
 protected:
-  friend nsresult NS_NewSVGTitleElement(nsIContent **aResult,
-                                        already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGTitleElement(already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsresult Init();
+  friend nsresult (::NS_NewSVGTitleElement(nsIContent **aResult,
+                                           already_AddRefed<nsINodeInfo> aNodeInfo));
+  SVGTitleElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+
+  virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
 
 public:
   // interfaces:
 
   NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMSVGTITLEELEMENT
 
   // xxx I wish we could use virtual inheritance
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGTitleElementBase::)
+  NS_FORWARD_NSIDOMSVGELEMENT(SVGTitleElementBase::)
 
   // nsIMutationObserver
   NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
@@ -49,125 +57,13 @@ public:
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
 private:
   void SendTitleChangeEvent(bool aBound);
 };
 
-NS_IMPL_NS_NEW_SVG_ELEMENT(Title)
-
-
-//----------------------------------------------------------------------
-// nsISupports methods
-
-NS_IMPL_ADDREF_INHERITED(nsSVGTitleElement, nsSVGTitleElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGTitleElement, nsSVGTitleElementBase)
-
-DOMCI_NODE_DATA(SVGTitleElement, nsSVGTitleElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGTitleElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGTitleElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTitleElement,
-                           nsIMutationObserver)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGTitleElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGTitleElementBase)
-
-
-//----------------------------------------------------------------------
-// Implementation
-
-nsSVGTitleElement::nsSVGTitleElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGTitleElementBase(aNodeInfo)
-{
-  AddMutationObserver(this);
-}
-
-nsresult
-nsSVGTitleElement::Init()
-{
-  return nsSVGTitleElementBase::Init();
-}
-
-void
-nsSVGTitleElement::CharacterDataChanged(nsIDocument *aDocument,
-                                        nsIContent *aContent,
-                                        CharacterDataChangeInfo *aInfo)
-{
-  SendTitleChangeEvent(false);
-}
-
-void
-nsSVGTitleElement::ContentAppended(nsIDocument *aDocument,
-                                   nsIContent *aContainer,
-                                   nsIContent *aFirstNewContent,
-                                   int32_t aNewIndexInContainer)
-{
-  SendTitleChangeEvent(false);
-}
+} // namespace dom
+} // namespace mozilla
 
-void
-nsSVGTitleElement::ContentInserted(nsIDocument *aDocument,
-                                   nsIContent *aContainer,
-                                   nsIContent *aChild,
-                                   int32_t aIndexInContainer)
-{
-  SendTitleChangeEvent(false);
-}
-
-void
-nsSVGTitleElement::ContentRemoved(nsIDocument *aDocument,
-                                  nsIContent *aContainer,
-                                  nsIContent *aChild,
-                                  int32_t aIndexInContainer,
-                                  nsIContent *aPreviousSibling)
-{
-  SendTitleChangeEvent(false);
-}
-
-nsresult
-nsSVGTitleElement::BindToTree(nsIDocument *aDocument,
-                               nsIContent *aParent,
-                               nsIContent *aBindingParent,
-                               bool aCompileEventHandlers)
-{
-  // Let this fall through.
-  nsresult rv = nsSVGTitleElementBase::BindToTree(aDocument, aParent,
-                                                  aBindingParent,
-                                                  aCompileEventHandlers);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  SendTitleChangeEvent(true);
+#endif // mozilla_dom_SVGTitleElement_h
 
-  return NS_OK;
-}
-
-void
-nsSVGTitleElement::UnbindFromTree(bool aDeep, bool aNullParent)
-{
-  SendTitleChangeEvent(false);
-
-  // Let this fall through.
-  nsSVGTitleElementBase::UnbindFromTree(aDeep, aNullParent);
-}
-
-void
-nsSVGTitleElement::DoneAddingChildren(bool aHaveNotified)
-{
-  if (!aHaveNotified) {
-    SendTitleChangeEvent(false);
-  }
-}
-
-void
-nsSVGTitleElement::SendTitleChangeEvent(bool aBound)
-{
-  nsIDocument* doc = GetCurrentDoc();
-  if (doc) {
-    doc->NotifyPossibleTitleChange(aBound);
-  }
-}
-
-//----------------------------------------------------------------------
-// nsIDOMNode methods
-
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGTitleElement)
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -711,16 +711,20 @@ DOMInterfaces = {
     'resultNotAddRefed': [ 'getItem' ]
 },
 
 'SVGPreserveAspectRatio': {
     'nativeType': 'mozilla::dom::DOMSVGPreserveAspectRatio',
     'headerFile': 'SVGPreserveAspectRatio.h'
 },
 
+'SVGTitleElement': {
+  'hasInstanceInterface': 'nsIDOMSVGTitleElement',
+},
+
 'SVGTransform': {
     'nativeType': 'mozilla::DOMSVGTransform',
     'headerFile': 'DOMSVGTransform.h'
 },
 
 'SVGTransformList': {
     'nativeType': 'mozilla::DOMSVGTransformList',
     'headerFile': 'DOMSVGTransformList.h',
new file mode 100644
--- /dev/null
+++ b/dom/webidl/SVGTitleElement.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 SVGTitleElement : SVGElement {
+};
+
--- 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 \
+  SVGTitleElement.webidl \
   SVGTransform.webidl \
   SVGTransformList.webidl \
   Text.webidl \
   TextDecoder.webidl \
   TextEncoder.webidl \
   URL.webidl \
   WebSocket.webidl \
   UndoManager.webidl \