Bug 824327: Convert SVGStyleElement to WebIDL r=bz
authorDavid Zbarsky <dzbarsky@gmail.com>
Fri, 04 Jan 2013 20:50:21 -0500
changeset 126808 46e52ba374e04c28b65b6a9f646e56c3cb14e4e6
parent 126807 5b57d2f7af3d077f4a2fcaad923d93e51136a4f5
child 126809 c47eb8f76e9d84cc9a7da43fd4f04e1db2f14aa5
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 SVGStyleElement to WebIDL r=bz
content/svg/content/src/Makefile.in
content/svg/content/src/SVGStyleElement.cpp
content/svg/content/src/SVGStyleElement.h
content/svg/content/src/nsSVGStyleElement.cpp
dom/webidl/SVGStyleElement.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 \
-		nsSVGStyleElement.cpp \
 		nsSVGSwitchElement.cpp \
 		nsSVGSymbolElement.cpp \
 		nsSVGTSpanElement.cpp \
 		nsSVGTextContentElement.cpp \
 		nsSVGTextElement.cpp \
 		nsSVGTextPathElement.cpp \
 		nsSVGTextPositioningElement.cpp \
 		nsSVGUnknownElement.cpp \
@@ -128,16 +127,17 @@ CPPSRCS		= \
 		SVGMotionSMILAnimationFunction.cpp \
 		SVGMotionSMILPathUtils.cpp \
 		SVGNumberListSMILType.cpp \
 		SVGNumberPairSMILType.cpp \
 		SVGOrientSMILType.cpp \
 		SVGPathSegListSMILType.cpp \
 		SVGPointListSMILType.cpp \
 		SVGStopElement.cpp \
+		SVGStyleElement.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
@@ -151,16 +151,17 @@ EXPORTS =  			\
 EXPORTS_NAMESPACES = mozilla/dom
 
 EXPORTS_mozilla/dom = \
 	SVGAngle.h \
 	SVGAnimatedAngle.h \
 	SVGAnimatedBoolean.h \
 	SVGDescElement.h \
 	SVGStopElement.h \
+	SVGStyleElement.h \
 	SVGTitleElement.h \
 	$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 INCLUDES += 	\
 		-I$(srcdir)/../../../xml/content/src \
 		-I$(srcdir)/../../../../dom \
rename from content/svg/content/src/nsSVGStyleElement.cpp
rename to content/svg/content/src/SVGStyleElement.cpp
--- a/content/svg/content/src/nsSVGStyleElement.cpp
+++ b/content/svg/content/src/SVGStyleElement.cpp
@@ -1,345 +1,285 @@
 /* -*- 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 "nsGkAtoms.h"
-#include "nsIDOMSVGStyleElement.h"
-#include "nsUnicharUtils.h"
-#include "nsIDocument.h"
-#include "nsStyleLinkElement.h"
+#include "mozilla/dom/SVGStyleElement.h"
 #include "nsContentUtils.h"
 #include "nsStubMutationObserver.h"
-
-using namespace mozilla;
-
-typedef nsSVGElement nsSVGStyleElementBase;
+#include "mozilla/dom/SVGStyleElementBinding.h"
 
-class nsSVGStyleElement : public nsSVGStyleElementBase,
-                          public nsIDOMSVGStyleElement,
-                          public nsStyleLinkElement,
-                          public nsStubMutationObserver
-{
-protected:
-  friend nsresult NS_NewSVGStyleElement(nsIContent **aResult,
-                                        already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGStyleElement(already_AddRefed<nsINodeInfo> aNodeInfo);
-  
-public:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMSVGSTYLEELEMENT
+DOMCI_NODE_DATA(SVGStyleElement, mozilla::dom::SVGStyleElement)
 
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsSVGStyleElement,
-                                           nsSVGStyleElementBase)
-
-  // xxx I wish we could use virtual inheritance
-  NS_FORWARD_NSIDOMNODE_TO_NSINODE
-  NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGStyleElementBase::)
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Style)
 
-  // nsIContent
-  virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
-                              nsIContent* aBindingParent,
-                              bool aCompileEventHandlers);
-  virtual void UnbindFromTree(bool aDeep = true,
-                              bool aNullParent = true);
-  nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
-                   const nsAString& aValue, bool aNotify)
-  {
-    return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify);
-  }
-  virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
-                           nsIAtom* aPrefix, const nsAString& aValue,
-                           bool aNotify);
-  virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
-                             bool aNotify);
-  virtual bool ParseAttribute(int32_t aNamespaceID,
-                              nsIAtom* aAttribute,
-                              const nsAString& aValue,
-                              nsAttrValue& aResult);
-
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
-
-  // nsIMutationObserver
-  NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
-  NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
-  NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
-  NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
-
-  virtual nsXPCClassInfo* GetClassInfo();
+namespace mozilla {
+namespace dom {
 
-  virtual nsIDOMNode* AsDOMNode() { return this; }
-protected:
-  // Dummy init method to make the NS_IMPL_NS_NEW_SVG_ELEMENT and
-  // NS_IMPL_ELEMENT_CLONE_WITH_INIT usable with this class. This should be
-  // completely optimized away.
-  inline nsresult Init()
-  {
-    return NS_OK;
-  }
-
-  // nsStyleLinkElement overrides
-  already_AddRefed<nsIURI> GetStyleSheetURL(bool* aIsInline);
-
-  void GetStyleSheetInfo(nsAString& aTitle,
-                         nsAString& aType,
-                         nsAString& aMedia,
-                         bool* aIsAlternate);
-  virtual CORSMode GetCORSMode() const;
-
-  /**
-   * Common method to call from the various mutation observer methods.
-   * aContent is a content node that's either the one that changed or its
-   * parent; we should only respond to the change if aContent is non-anonymous.
-   */
-  void ContentChanged(nsIContent* aContent);
-};
-
-
-NS_IMPL_NS_NEW_SVG_ELEMENT(Style)
-
+JSObject*
+SVGStyleElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return SVGStyleElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGStyleElement,nsSVGStyleElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGStyleElement,nsSVGStyleElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGStyleElement, SVGStyleElementBase)
+NS_IMPL_RELEASE_INHERITED(SVGStyleElement, SVGStyleElementBase)
 
-DOMCI_NODE_DATA(SVGStyleElement, nsSVGStyleElement)
-
-NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsSVGStyleElement)
-  NS_NODE_INTERFACE_TABLE7(nsSVGStyleElement, nsIDOMNode, nsIDOMElement,
+NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(SVGStyleElement)
+  NS_NODE_INTERFACE_TABLE7(SVGStyleElement, nsIDOMNode, nsIDOMElement,
                            nsIDOMSVGElement, nsIDOMSVGStyleElement,
                            nsIDOMLinkStyle, nsIStyleSheetLinkingElement,
                            nsIMutationObserver)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStyleElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGStyleElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGStyleElementBase)
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsSVGStyleElement)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsSVGStyleElement,
-                                                  nsSVGStyleElementBase)
+NS_IMPL_CYCLE_COLLECTION_CLASS(SVGStyleElement)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SVGStyleElement,
+                                                  SVGStyleElementBase)
   tmp->nsStyleLinkElement::Traverse(cb);
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsSVGStyleElement,
-                                                nsSVGStyleElementBase)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SVGStyleElement,
+                                                SVGStyleElementBase)
   tmp->nsStyleLinkElement::Unlink();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGStyleElement::nsSVGStyleElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGStyleElementBase(aNodeInfo)
+SVGStyleElement::SVGStyleElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGStyleElementBase(aNodeInfo)
 {
+  SetIsDOMBinding();
   AddMutationObserver(this);
 }
 
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGStyleElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGStyleElement)
 
 
 //----------------------------------------------------------------------
 // nsIContent methods
 
 nsresult
-nsSVGStyleElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
-                              nsIContent* aBindingParent,
-                              bool aCompileEventHandlers)
+SVGStyleElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
+                            nsIContent* aBindingParent,
+                            bool aCompileEventHandlers)
 {
-  nsresult rv = nsSVGStyleElementBase::BindToTree(aDocument, aParent,
-                                                  aBindingParent,
-                                                  aCompileEventHandlers);
+  nsresult rv = SVGStyleElementBase::BindToTree(aDocument, aParent,
+                                                aBindingParent,
+                                                aCompileEventHandlers);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  void (nsSVGStyleElement::*update)() = &nsSVGStyleElement::UpdateStyleSheetInternal;
+  void (SVGStyleElement::*update)() = &SVGStyleElement::UpdateStyleSheetInternal;
   nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update));
 
-  return rv;  
+  return rv;
 }
 
 void
-nsSVGStyleElement::UnbindFromTree(bool aDeep, bool aNullParent)
+SVGStyleElement::UnbindFromTree(bool aDeep, bool aNullParent)
 {
   nsCOMPtr<nsIDocument> oldDoc = GetCurrentDoc();
 
-  nsSVGStyleElementBase::UnbindFromTree(aDeep, aNullParent);
+  SVGStyleElementBase::UnbindFromTree(aDeep, aNullParent);
   UpdateStyleSheetInternal(oldDoc);
 }
 
 nsresult
-nsSVGStyleElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
-                           nsIAtom* aPrefix, const nsAString& aValue,
-                           bool aNotify)
+SVGStyleElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
+                         nsIAtom* aPrefix, const nsAString& aValue,
+                         bool aNotify)
 {
-  nsresult rv = nsSVGStyleElementBase::SetAttr(aNameSpaceID, aName, aPrefix,
-                                               aValue, aNotify);
+  nsresult rv = SVGStyleElementBase::SetAttr(aNameSpaceID, aName, aPrefix,
+                                             aValue, aNotify);
   if (NS_SUCCEEDED(rv)) {
     UpdateStyleSheetInternal(nullptr,
                              aNameSpaceID == kNameSpaceID_None &&
                              (aName == nsGkAtoms::title ||
                               aName == nsGkAtoms::media ||
                               aName == nsGkAtoms::type));
   }
 
   return rv;
 }
 
 nsresult
-nsSVGStyleElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
-                              bool aNotify)
+SVGStyleElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
+                           bool aNotify)
 {
-  nsresult rv = nsSVGStyleElementBase::UnsetAttr(aNameSpaceID, aAttribute,
-                                                 aNotify);
+  nsresult rv = SVGStyleElementBase::UnsetAttr(aNameSpaceID, aAttribute,
+                                               aNotify);
   if (NS_SUCCEEDED(rv)) {
     UpdateStyleSheetInternal(nullptr,
                              aNameSpaceID == kNameSpaceID_None &&
                              (aAttribute == nsGkAtoms::title ||
                               aAttribute == nsGkAtoms::media ||
                               aAttribute == nsGkAtoms::type));
   }
 
   return rv;
 }
 
 bool
-nsSVGStyleElement::ParseAttribute(int32_t aNamespaceID,
-                                  nsIAtom* aAttribute,
-                                  const nsAString& aValue,
-                                  nsAttrValue& aResult)
+SVGStyleElement::ParseAttribute(int32_t aNamespaceID,
+                                nsIAtom* aAttribute,
+                                const nsAString& aValue,
+                                nsAttrValue& aResult)
 {
   if (aNamespaceID == kNameSpaceID_None &&
       aAttribute == nsGkAtoms::crossorigin) {
     ParseCORSValue(aValue, aResult);
     return true;
   }
 
-  return nsSVGStyleElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue,
-                                               aResult);
+  return SVGStyleElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue,
+                                             aResult);
 }
 
 //----------------------------------------------------------------------
 // nsIMutationObserver methods
 
 void
-nsSVGStyleElement::CharacterDataChanged(nsIDocument* aDocument,
-                                        nsIContent* aContent,
-                                        CharacterDataChangeInfo* aInfo)
+SVGStyleElement::CharacterDataChanged(nsIDocument* aDocument,
+                                      nsIContent* aContent,
+                                      CharacterDataChangeInfo* aInfo)
 {
   ContentChanged(aContent);
 }
 
 void
-nsSVGStyleElement::ContentAppended(nsIDocument* aDocument,
-                                   nsIContent* aContainer,
-                                   nsIContent* aFirstNewContent,
-                                   int32_t aNewIndexInContainer)
+SVGStyleElement::ContentAppended(nsIDocument* aDocument,
+                                 nsIContent* aContainer,
+                                 nsIContent* aFirstNewContent,
+                                 int32_t aNewIndexInContainer)
 {
   ContentChanged(aContainer);
 }
- 
+
 void
-nsSVGStyleElement::ContentInserted(nsIDocument* aDocument,
-                                   nsIContent* aContainer,
-                                   nsIContent* aChild,
-                                   int32_t aIndexInContainer)
-{
-  ContentChanged(aChild);
-}
- 
-void
-nsSVGStyleElement::ContentRemoved(nsIDocument* aDocument,
-                                  nsIContent* aContainer,
-                                  nsIContent* aChild,
-                                  int32_t aIndexInContainer,
-                                  nsIContent* aPreviousSibling)
+SVGStyleElement::ContentInserted(nsIDocument* aDocument,
+                                 nsIContent* aContainer,
+                                 nsIContent* aChild,
+                                 int32_t aIndexInContainer)
 {
   ContentChanged(aChild);
 }
 
 void
-nsSVGStyleElement::ContentChanged(nsIContent* aContent)
+SVGStyleElement::ContentRemoved(nsIDocument* aDocument,
+                                nsIContent* aContainer,
+                                nsIContent* aChild,
+                                int32_t aIndexInContainer,
+                                nsIContent* aPreviousSibling)
+{
+  ContentChanged(aChild);
+}
+
+void
+SVGStyleElement::ContentChanged(nsIContent* aContent)
 {
   if (nsContentUtils::IsInSameAnonymousTree(this, aContent)) {
     UpdateStyleSheetInternal(nullptr);
   }
 }
 
 //----------------------------------------------------------------------
 // nsIDOMSVGStyleElement methods
 
 /* attribute DOMString xmlspace; */
-NS_IMETHODIMP nsSVGStyleElement::GetXmlspace(nsAString & aXmlspace)
+NS_IMETHODIMP SVGStyleElement::GetXmlspace(nsAString & aXmlspace)
 {
   GetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace);
 
   return NS_OK;
 }
-NS_IMETHODIMP nsSVGStyleElement::SetXmlspace(const nsAString & aXmlspace)
+NS_IMETHODIMP SVGStyleElement::SetXmlspace(const nsAString & aXmlspace)
 {
   return SetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace, true);
 }
+void
+SVGStyleElement::SetXmlspace(const nsAString & aXmlspace, ErrorResult& rv)
+{
+  rv = SetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace, true);
+}
 
 /* attribute DOMString type; */
-NS_IMETHODIMP nsSVGStyleElement::GetType(nsAString & aType)
+NS_IMETHODIMP SVGStyleElement::GetType(nsAString & aType)
 {
   GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType);
 
   return NS_OK;
 }
-NS_IMETHODIMP nsSVGStyleElement::SetType(const nsAString & aType)
+NS_IMETHODIMP SVGStyleElement::SetType(const nsAString & aType)
 {
   return SetAttr(kNameSpaceID_None, nsGkAtoms::type, aType, true);
 }
+void
+SVGStyleElement::SetType(const nsAString & aType, ErrorResult& rv)
+{
+  rv = SetAttr(kNameSpaceID_None, nsGkAtoms::type, aType, true);
+}
 
 /* attribute DOMString media; */
-NS_IMETHODIMP nsSVGStyleElement::GetMedia(nsAString & aMedia)
+NS_IMETHODIMP SVGStyleElement::GetMedia(nsAString & aMedia)
 {
   GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia);
 
   return NS_OK;
 }
-NS_IMETHODIMP nsSVGStyleElement::SetMedia(const nsAString & aMedia)
+NS_IMETHODIMP SVGStyleElement::SetMedia(const nsAString & aMedia)
 {
   return SetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia, true);
 }
+void
+SVGStyleElement::SetMedia(const nsAString & aMedia, ErrorResult& rv)
+{
+  rv = SetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia, true);
+}
 
 /* attribute DOMString title; */
-NS_IMETHODIMP nsSVGStyleElement::GetTitle(nsAString & aTitle)
+NS_IMETHODIMP SVGStyleElement::GetTitle(nsAString & aTitle)
 {
   GetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle);
 
   return NS_OK;
 }
-NS_IMETHODIMP nsSVGStyleElement::SetTitle(const nsAString & aTitle)
+NS_IMETHODIMP SVGStyleElement::SetTitle(const nsAString & aTitle)
 {
   return SetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle, true);
 }
+void
+SVGStyleElement::SetTitle(const nsAString & aTitle, ErrorResult& rv)
+{
+  rv = SetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle, true);
+}
 
 //----------------------------------------------------------------------
 // nsStyleLinkElement methods
 
 already_AddRefed<nsIURI>
-nsSVGStyleElement::GetStyleSheetURL(bool* aIsInline)
+SVGStyleElement::GetStyleSheetURL(bool* aIsInline)
 {
   *aIsInline = true;
   return nullptr;
 }
 
 void
-nsSVGStyleElement::GetStyleSheetInfo(nsAString& aTitle,
-                                     nsAString& aType,
-                                     nsAString& aMedia,
-                                     bool* aIsAlternate)
+SVGStyleElement::GetStyleSheetInfo(nsAString& aTitle,
+                                   nsAString& aType,
+                                   nsAString& aMedia,
+                                   bool* aIsAlternate)
 {
   *aIsAlternate = false;
 
   nsAutoString title;
   GetAttr(kNameSpaceID_None, nsGkAtoms::title, title);
   title.CompressWhitespace();
   aTitle.Assign(title);
 
@@ -352,12 +292,16 @@ nsSVGStyleElement::GetStyleSheetInfo(nsA
   if (aType.IsEmpty()) {
     aType.AssignLiteral("text/css");
   }
 
   return;
 }
 
 CORSMode
-nsSVGStyleElement::GetCORSMode() const
+SVGStyleElement::GetCORSMode() const
 {
   return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin));
 }
+
+} // namespace dom
+} // namespace mozilla
+
copy from content/svg/content/src/nsSVGStyleElement.cpp
copy to content/svg/content/src/SVGStyleElement.h
--- a/content/svg/content/src/nsSVGStyleElement.cpp
+++ b/content/svg/content/src/SVGStyleElement.h
@@ -1,47 +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_SVGStyleElement_h
+#define mozilla_dom_SVGStyleElement_h
+
 #include "nsSVGElement.h"
-#include "nsGkAtoms.h"
 #include "nsIDOMSVGStyleElement.h"
-#include "nsUnicharUtils.h"
-#include "nsIDocument.h"
 #include "nsStyleLinkElement.h"
-#include "nsContentUtils.h"
 #include "nsStubMutationObserver.h"
 
-using namespace mozilla;
+nsresult NS_NewSVGStyleElement(nsIContent **aResult,
+                               already_AddRefed<nsINodeInfo> aNodeInfo);
 
-typedef nsSVGElement nsSVGStyleElementBase;
+typedef nsSVGElement SVGStyleElementBase;
 
-class nsSVGStyleElement : public nsSVGStyleElementBase,
-                          public nsIDOMSVGStyleElement,
-                          public nsStyleLinkElement,
-                          public nsStubMutationObserver
+namespace mozilla {
+namespace dom {
+
+class SVGStyleElement MOZ_FINAL : public SVGStyleElementBase,
+                                  public nsIDOMSVGStyleElement,
+                                  public nsStyleLinkElement,
+                                  public nsStubMutationObserver
 {
 protected:
-  friend nsresult NS_NewSVGStyleElement(nsIContent **aResult,
-                                        already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGStyleElement(already_AddRefed<nsINodeInfo> aNodeInfo);
-  
+  friend nsresult (::NS_NewSVGStyleElement(nsIContent **aResult,
+                                           already_AddRefed<nsINodeInfo> aNodeInfo));
+  SVGStyleElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+
+  virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
+
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMSVGSTYLEELEMENT
 
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsSVGStyleElement,
-                                           nsSVGStyleElementBase)
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGStyleElement,
+                                           SVGStyleElementBase)
 
   // xxx I wish we could use virtual inheritance
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGStyleElementBase::)
+  NS_FORWARD_NSIDOMSVGELEMENT(SVGStyleElementBase::)
 
   // nsIContent
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers);
   virtual void UnbindFromTree(bool aDeep = true,
                               bool aNullParent = true);
   nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
@@ -65,16 +70,23 @@ public:
   NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
+
+  // WebIDL
+  void SetXmlspace(const nsAString & aXmlspace, ErrorResult& rv);
+  void SetType(const nsAString & aType, ErrorResult& rv);
+  void SetMedia(const nsAString & aMedia, ErrorResult& rv);
+  void SetTitle(const nsAString & aTitle, ErrorResult& rv);
+
 protected:
   // Dummy init method to make the NS_IMPL_NS_NEW_SVG_ELEMENT and
   // NS_IMPL_ELEMENT_CLONE_WITH_INIT usable with this class. This should be
   // completely optimized away.
   inline nsresult Init()
   {
     return NS_OK;
   }
@@ -91,273 +103,12 @@ protected:
   /**
    * Common method to call from the various mutation observer methods.
    * aContent is a content node that's either the one that changed or its
    * parent; we should only respond to the change if aContent is non-anonymous.
    */
   void ContentChanged(nsIContent* aContent);
 };
 
-
-NS_IMPL_NS_NEW_SVG_ELEMENT(Style)
-
-
-//----------------------------------------------------------------------
-// nsISupports methods
-
-NS_IMPL_ADDREF_INHERITED(nsSVGStyleElement,nsSVGStyleElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGStyleElement,nsSVGStyleElementBase)
-
-DOMCI_NODE_DATA(SVGStyleElement, nsSVGStyleElement)
-
-NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsSVGStyleElement)
-  NS_NODE_INTERFACE_TABLE7(nsSVGStyleElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGStyleElement,
-                           nsIDOMLinkStyle, nsIStyleSheetLinkingElement,
-                           nsIMutationObserver)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStyleElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGStyleElementBase)
-
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsSVGStyleElement)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsSVGStyleElement,
-                                                  nsSVGStyleElementBase)
-  tmp->nsStyleLinkElement::Traverse(cb);
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsSVGStyleElement,
-                                                nsSVGStyleElementBase)
-  tmp->nsStyleLinkElement::Unlink();
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-
-//----------------------------------------------------------------------
-// Implementation
-
-nsSVGStyleElement::nsSVGStyleElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGStyleElementBase(aNodeInfo)
-{
-  AddMutationObserver(this);
-}
-
-
-//----------------------------------------------------------------------
-// nsIDOMNode methods
-
-
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGStyleElement)
-
-
-//----------------------------------------------------------------------
-// nsIContent methods
-
-nsresult
-nsSVGStyleElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
-                              nsIContent* aBindingParent,
-                              bool aCompileEventHandlers)
-{
-  nsresult rv = nsSVGStyleElementBase::BindToTree(aDocument, aParent,
-                                                  aBindingParent,
-                                                  aCompileEventHandlers);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  void (nsSVGStyleElement::*update)() = &nsSVGStyleElement::UpdateStyleSheetInternal;
-  nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update));
-
-  return rv;  
-}
-
-void
-nsSVGStyleElement::UnbindFromTree(bool aDeep, bool aNullParent)
-{
-  nsCOMPtr<nsIDocument> oldDoc = GetCurrentDoc();
-
-  nsSVGStyleElementBase::UnbindFromTree(aDeep, aNullParent);
-  UpdateStyleSheetInternal(oldDoc);
-}
-
-nsresult
-nsSVGStyleElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
-                           nsIAtom* aPrefix, const nsAString& aValue,
-                           bool aNotify)
-{
-  nsresult rv = nsSVGStyleElementBase::SetAttr(aNameSpaceID, aName, aPrefix,
-                                               aValue, aNotify);
-  if (NS_SUCCEEDED(rv)) {
-    UpdateStyleSheetInternal(nullptr,
-                             aNameSpaceID == kNameSpaceID_None &&
-                             (aName == nsGkAtoms::title ||
-                              aName == nsGkAtoms::media ||
-                              aName == nsGkAtoms::type));
-  }
-
-  return rv;
-}
-
-nsresult
-nsSVGStyleElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
-                              bool aNotify)
-{
-  nsresult rv = nsSVGStyleElementBase::UnsetAttr(aNameSpaceID, aAttribute,
-                                                 aNotify);
-  if (NS_SUCCEEDED(rv)) {
-    UpdateStyleSheetInternal(nullptr,
-                             aNameSpaceID == kNameSpaceID_None &&
-                             (aAttribute == nsGkAtoms::title ||
-                              aAttribute == nsGkAtoms::media ||
-                              aAttribute == nsGkAtoms::type));
-  }
-
-  return rv;
-}
-
-bool
-nsSVGStyleElement::ParseAttribute(int32_t aNamespaceID,
-                                  nsIAtom* aAttribute,
-                                  const nsAString& aValue,
-                                  nsAttrValue& aResult)
-{
-  if (aNamespaceID == kNameSpaceID_None &&
-      aAttribute == nsGkAtoms::crossorigin) {
-    ParseCORSValue(aValue, aResult);
-    return true;
-  }
-
-  return nsSVGStyleElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue,
-                                               aResult);
-}
-
-//----------------------------------------------------------------------
-// nsIMutationObserver methods
+} // namespace dom
+} // namespace mozilla
 
-void
-nsSVGStyleElement::CharacterDataChanged(nsIDocument* aDocument,
-                                        nsIContent* aContent,
-                                        CharacterDataChangeInfo* aInfo)
-{
-  ContentChanged(aContent);
-}
-
-void
-nsSVGStyleElement::ContentAppended(nsIDocument* aDocument,
-                                   nsIContent* aContainer,
-                                   nsIContent* aFirstNewContent,
-                                   int32_t aNewIndexInContainer)
-{
-  ContentChanged(aContainer);
-}
- 
-void
-nsSVGStyleElement::ContentInserted(nsIDocument* aDocument,
-                                   nsIContent* aContainer,
-                                   nsIContent* aChild,
-                                   int32_t aIndexInContainer)
-{
-  ContentChanged(aChild);
-}
- 
-void
-nsSVGStyleElement::ContentRemoved(nsIDocument* aDocument,
-                                  nsIContent* aContainer,
-                                  nsIContent* aChild,
-                                  int32_t aIndexInContainer,
-                                  nsIContent* aPreviousSibling)
-{
-  ContentChanged(aChild);
-}
-
-void
-nsSVGStyleElement::ContentChanged(nsIContent* aContent)
-{
-  if (nsContentUtils::IsInSameAnonymousTree(this, aContent)) {
-    UpdateStyleSheetInternal(nullptr);
-  }
-}
-
-//----------------------------------------------------------------------
-// nsIDOMSVGStyleElement methods
-
-/* attribute DOMString xmlspace; */
-NS_IMETHODIMP nsSVGStyleElement::GetXmlspace(nsAString & aXmlspace)
-{
-  GetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace);
-
-  return NS_OK;
-}
-NS_IMETHODIMP nsSVGStyleElement::SetXmlspace(const nsAString & aXmlspace)
-{
-  return SetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace, true);
-}
-
-/* attribute DOMString type; */
-NS_IMETHODIMP nsSVGStyleElement::GetType(nsAString & aType)
-{
-  GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType);
-
-  return NS_OK;
-}
-NS_IMETHODIMP nsSVGStyleElement::SetType(const nsAString & aType)
-{
-  return SetAttr(kNameSpaceID_None, nsGkAtoms::type, aType, true);
-}
-
-/* attribute DOMString media; */
-NS_IMETHODIMP nsSVGStyleElement::GetMedia(nsAString & aMedia)
-{
-  GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia);
-
-  return NS_OK;
-}
-NS_IMETHODIMP nsSVGStyleElement::SetMedia(const nsAString & aMedia)
-{
-  return SetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia, true);
-}
-
-/* attribute DOMString title; */
-NS_IMETHODIMP nsSVGStyleElement::GetTitle(nsAString & aTitle)
-{
-  GetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle);
-
-  return NS_OK;
-}
-NS_IMETHODIMP nsSVGStyleElement::SetTitle(const nsAString & aTitle)
-{
-  return SetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle, true);
-}
-
-//----------------------------------------------------------------------
-// nsStyleLinkElement methods
-
-already_AddRefed<nsIURI>
-nsSVGStyleElement::GetStyleSheetURL(bool* aIsInline)
-{
-  *aIsInline = true;
-  return nullptr;
-}
-
-void
-nsSVGStyleElement::GetStyleSheetInfo(nsAString& aTitle,
-                                     nsAString& aType,
-                                     nsAString& aMedia,
-                                     bool* aIsAlternate)
-{
-  *aIsAlternate = false;
-
-  nsAutoString title;
-  GetAttr(kNameSpaceID_None, nsGkAtoms::title, title);
-  title.CompressWhitespace();
-  aTitle.Assign(title);
-
-  GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia);
-  // The SVG spec is formulated in terms of the CSS2 spec,
-  // which specifies that media queries are case insensitive.
-  nsContentUtils::ASCIIToLower(aMedia);
-
-  GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType);
-  if (aType.IsEmpty()) {
-    aType.AssignLiteral("text/css");
-  }
-
-  return;
-}
-
-CORSMode
-nsSVGStyleElement::GetCORSMode() const
-{
-  return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin));
-}
+#endif // mozilla_dom_SVGStyleElement_h
new file mode 100644
--- /dev/null
+++ b/dom/webidl/SVGStyleElement.webidl
@@ -0,0 +1,23 @@
+/* -*- 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 SVGStyleElement : SVGElement {
+  [SetterThrows]
+  attribute DOMString xmlspace; // Spec claims this should be on SVGElement
+  [SetterThrows]
+  attribute DOMString type;
+  [SetterThrows]
+  attribute DOMString media;
+  [SetterThrows]
+  attribute DOMString title;
+};
+
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -102,16 +102,17 @@ webidl_files = \
   SVGMatrix.webidl \
   SVGNumberList.webidl \
   SVGPathSeg.webidl \
   SVGPathSegList.webidl \
   SVGPoint.webidl \
   SVGPointList.webidl \
   SVGPreserveAspectRatio.webidl \
   SVGStopElement.webidl \
+  SVGStyleElement.webidl \
   SVGTitleElement.webidl \
   SVGTransform.webidl \
   SVGTransformList.webidl \
   Text.webidl \
   TextDecoder.webidl \
   TextEncoder.webidl \
   URL.webidl \
   WebSocket.webidl \