Merge the last PGO-green inbound changeset to m-c
authorEhsan Akhgari <ehsan@mozilla.com>
Sun, 06 Jan 2013 13:33:16 -0500
changeset 126903 6503c6bee6f84f26ba6b79cac1fccfca4e69f1f1
parent 126862 c4abfca219e5c438a69f65533dcb364ba9604c55 (current diff)
parent 126902 6104f18f25276d9026b7140d312738ef988a1761 (diff)
child 126922 579c679f24f2eccaf985b6a85f2b8c3d0516fb43
child 126926 c706b690654979ce9dc87dc8f22e0138122c0526
child 126965 2ee91743312d6d2c48341f1d751edf4b915d1723
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)
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
Merge the last PGO-green inbound changeset to m-c
browser/themes/gnomestripe/downloads/download-notification.png
browser/themes/pinstripe/downloads/download-notification.png
browser/themes/winstripe/downloads/download-notification.png
content/svg/content/src/nsSVGAnimateElement.cpp
content/svg/content/src/nsSVGAnimateMotionElement.cpp
content/svg/content/src/nsSVGAnimateMotionElement.h
content/svg/content/src/nsSVGAnimateTransformElement.cpp
content/svg/content/src/nsSVGAnimationElement.cpp
content/svg/content/src/nsSVGAnimationElement.h
content/svg/content/src/nsSVGCircleElement.cpp
content/svg/content/src/nsSVGDefsElement.cpp
content/svg/content/src/nsSVGEllipseElement.cpp
content/svg/content/src/nsSVGForeignObjectElement.cpp
content/svg/content/src/nsSVGForeignObjectElement.h
content/svg/content/src/nsSVGGElement.cpp
content/svg/content/src/nsSVGGraphicElement.cpp
content/svg/content/src/nsSVGGraphicElement.h
content/svg/content/src/nsSVGImageElement.cpp
content/svg/content/src/nsSVGImageElement.h
content/svg/content/src/nsSVGLineElement.cpp
content/svg/content/src/nsSVGPolygonElement.cpp
content/svg/content/src/nsSVGPolylineElement.cpp
content/svg/content/src/nsSVGRectElement.cpp
content/svg/content/src/nsSVGSetElement.cpp
content/svg/content/src/nsSVGSwitchElement.cpp
content/svg/content/src/nsSVGSwitchElement.h
--- a/b2g/components/ContentPermissionPrompt.js
+++ b/b2g/components/ContentPermissionPrompt.js
@@ -30,28 +30,35 @@ Cu.import("resource://gre/modules/Permis
 var permissionManager = Cc["@mozilla.org/permissionmanager;1"].getService(Ci.nsIPermissionManager);
 var secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
 
 XPCOMUtils.defineLazyServiceGetter(this,
                                    "PermSettings",
                                    "@mozilla.org/permissionSettings;1",
                                    "nsIDOMPermissionSettings");
 
-function rememberPermission(aPermission, aPrincipal)
+function rememberPermission(aPermission, aPrincipal, aSession)
 {
   function convertPermToAllow(aPerm, aPrincipal)
   {
     let type =
       permissionManager.testExactPermissionFromPrincipal(aPrincipal, aPerm);
     if (type == Ci.nsIPermissionManager.PROMPT_ACTION ||
         (type == Ci.nsIPermissionManager.UNKNOWN_ACTION &&
         PROMPT_FOR_UNKNOWN.indexOf(aPermission) >= 0)) {
-      permissionManager.addFromPrincipal(aPrincipal,
-                                         aPerm,
-                                         Ci.nsIPermissionManager.ALLOW_ACTION);
+      if (!aSession) {
+        permissionManager.addFromPrincipal(aPrincipal,
+                                           aPerm,
+                                           Ci.nsIPermissionManager.ALLOW_ACTION);
+      } else {
+        permissionManager.addFromPrincipal(aPrincipal,
+                                           aPerm,
+                                           Ci.nsIPermissionManager.ALLOW_ACTION,
+                                           Ci.nsIPermissionManager.EXPIRE_SESSION, 0);
+      }
     }
   }
 
   // Expand the permission to see if we have multiple access properties to convert
   let access = PermissionsTable[aPermission].access;
   if (access) {
     for (let idx in access) {
       convertPermToAllow(aPermission + "-" + access[idx], aPrincipal);
@@ -97,27 +104,28 @@ ContentPermissionPrompt.prototype = {
 
     let requestId = this._id++;
     content.addEventListener("mozContentEvent", function contentEvent(evt) {
       if (evt.detail.id != requestId)
         return;
       evt.target.removeEventListener(evt.type, contentEvent);
 
       if (evt.detail.type == "permission-allow") {
-        if (evt.detail.remember) {
-          rememberPermission(request.type, request.principal);
-        }
-
+        rememberPermission(request.type, request.principal, !evt.detail.remember);
         request.allow();
         return;
       }
 
       if (evt.detail.remember) {
         Services.perms.addFromPrincipal(request.principal, access,
                                         Ci.nsIPermissionManager.DENY_ACTION);
+      } else {
+        Services.perms.addFromPrincipal(request.principal, access,
+                                        Ci.nsIPermissionManager.DENY_ACTION,
+                                        Ci.nsIPermissionManager.EXPIRE_SESSION, 0);
       }
 
       request.cancel();
     });
 
     let principal = request.principal;
     let isApp = principal.appStatus != Ci.nsIPrincipal.APP_STATUS_NOT_INSTALLED;
     let remember = principal.appStatus == Ci.nsIPrincipal.APP_STATUS_PRIVILEGED
--- a/browser/components/downloads/content/indicator.js
+++ b/browser/components/downloads/content/indicator.js
@@ -344,34 +344,37 @@ const DownloadsIndicatorView = {
   /**
    * Set while we are waiting for a notification to fade out.
    */
   _notificationTimeout: null,
 
   /**
    * If the status indicator is visible in its assigned position, shows for a
    * brief time a visual notification of a relevant event, like a new download.
+   *
+   * @param aType
+   *        Set to "start" for new downloads, "finish" for completed downloads.
    */
-  showEventNotification: function DIV_showEventNotification()
+  showEventNotification: function DIV_showEventNotification(aType)
   {
     if (!this._initialized) {
       return;
     }
 
     function DIV_SEN_callback() {
       if (this._notificationTimeout) {
         clearTimeout(this._notificationTimeout);
       }
 
       // Now that the overlay is loaded, place the indicator in its final
       // position.
       DownloadsButton.updatePosition();
 
       let indicator = this.indicator;
-      indicator.setAttribute("notification", "true");
+      indicator.setAttribute("notification", aType);
       this._notificationTimeout = setTimeout(
         function () indicator.removeAttribute("notification"), 1000);
     }
 
     this._ensureOperational(DIV_SEN_callback.bind(this));
   },
 
   //////////////////////////////////////////////////////////////////////////////
@@ -481,17 +484,17 @@ const DownloadsIndicatorView = {
   {
     if (!this._operational) {
       return this._attention;
     }
 
     if (this._attention != aValue) {
       this._attention = aValue;
       if (aValue) {
-        this.indicator.setAttribute("attention", "true")
+        this.indicator.setAttribute("attention", "true");
       } else {
         this.indicator.removeAttribute("attention");
       }
     }
     return aValue;
   },
   _attention: false,
 
--- a/browser/components/downloads/src/DownloadsCommon.jsm
+++ b/browser/components/downloads/src/DownloadsCommon.jsm
@@ -980,17 +980,22 @@ DownloadsDataCtor.prototype = {
     }
 
     this._views.forEach(
       function (view) view.getViewItem(dataItem).onStateChange()
     );
 
     if (isNew && !dataItem.newDownloadNotified) {
       dataItem.newDownloadNotified = true;
-      this._notifyNewDownload();
+      this._notifyDownloadEvent("start");
+    }
+
+    // This is a final state of which we are only notified once.
+    if (dataItem.done) {
+      this._notifyDownloadEvent("finish");
     }
   },
 
   onProgressChange: function DD_onProgressChange(aWebProgress, aRequest,
                                                   aCurSelfProgress,
                                                   aMaxSelfProgress,
                                                   aCurTotalProgress,
                                                   aMaxTotalProgress, aDownload)
@@ -1037,36 +1042,39 @@ DownloadsDataCtor.prototype = {
   },
 
   set panelHasShownBefore(aValue) {
     Services.prefs.setBoolPref("browser.download.panel.shown", aValue);
     return aValue;
   },
 
   /**
-   * Displays a new download notification in the most recent browser window, if
-   * one is currently available.
+   * Displays a new or finished download notification in the most recent browser
+   * window, if one is currently available with the required privacy type.
+   *
+   * @param aType
+   *        Set to "start" for new downloads, "finish" for completed downloads.
    */
-  _notifyNewDownload: function DD_notifyNewDownload()
+  _notifyDownloadEvent: function DD_notifyDownloadEvent(aType)
   {
     if (DownloadsCommon.useToolkitUI) {
       return;
     }
 
     // Show the panel in the most recent browser window, if present.
     let browserWin = RecentWindow.getMostRecentBrowserWindow({ private: this._isPrivate });
     if (!browserWin) {
       return;
     }
 
     if (this.panelHasShownBefore) {
       // For new downloads after the first one, don't show the panel
       // automatically, but provide a visible notification in the topmost
       // browser window, if the status indicator is already visible.
-      browserWin.DownloadsIndicatorView.showEventNotification();
+      browserWin.DownloadsIndicatorView.showEventNotification(aType);
       return;
     }
     this.panelHasShownBefore = true;
     browserWin.DownloadsPanel.showPanel();
   }
 };
 
 XPCOMUtils.defineLazyGetter(this, "PrivateDownloadsData", function() {
--- a/browser/components/downloads/test/browser/browser_first_download_panel.js
+++ b/browser/components/downloads/test/browser/browser_first_download_panel.js
@@ -14,29 +14,29 @@ function gen_test()
     // Ensure that state is reset in case previous tests didn't finish.
     for (let yy in gen_resetState(DownloadsCommon.getData(window))) yield;
 
     // With this set to false, we should automatically open the panel
     // the first time a download is started.
     DownloadsCommon.getData(window).panelHasShownBefore = false;
 
     prepareForPanelOpen();
-    DownloadsCommon.getData(window)._notifyNewDownload();
+    DownloadsCommon.getData(window)._notifyDownloadEvent("start");
     yield;
 
     // If we got here, that means the panel opened.
     DownloadsPanel.hidePanel();
 
     ok(DownloadsCommon.getData(window).panelHasShownBefore,
        "Should have recorded that the panel was opened on a download.")
 
     // Next, make sure that if we start another download, we don't open
     // the panel automatically.
     panelShouldNotOpen();
-    DownloadsCommon.getData(window)._notifyNewDownload();
+    DownloadsCommon.getData(window)._notifyDownloadEvent("start");
     yield waitFor(2);
   } catch(e) {
     ok(false, e);
   } finally {
     // Clean up when the test finishes.
     for (let yy in gen_resetState(DownloadsCommon.getData(window))) yield;
   }
 }
--- a/browser/devtools/debugger/test/browser_dbg_propertyview-filter-05.js
+++ b/browser/devtools/debugger/test/browser_dbg_propertyview-filter-05.js
@@ -40,18 +40,18 @@ function testVariablesFiltering()
     is(innerScope.querySelectorAll(".variable:not([non-match])").length, 1,
       "There should be 1 variable displayed in the inner scope");
     is(mathScope.querySelectorAll(".variable:not([non-match])").length, 0,
       "There should be 0 variables displayed in the math scope");
     is(testScope.querySelectorAll(".variable:not([non-match])").length, 0,
       "There should be 0 variables displayed in the test scope");
     is(loadScope.querySelectorAll(".variable:not([non-match])").length, 1,
       "There should be 1 variable displayed in the load scope");
-    is(globalScope.querySelectorAll(".variable:not([non-match])").length, 5,
-      "There should be 5 variables displayed in the global scope");
+    is(globalScope.querySelectorAll(".variable:not([non-match])").length, 8,
+      "There should be 8 variables displayed in the global scope");
 
     is(innerScope.querySelectorAll(".property:not([non-match])").length, 0,
       "There should be 0 properties displayed in the inner scope");
     is(mathScope.querySelectorAll(".property:not([non-match])").length, 0,
       "There should be 0 properties displayed in the math scope");
     is(testScope.querySelectorAll(".property:not([non-match])").length, 0,
       "There should be 0 properties displayed in the test scope");
     is(loadScope.querySelectorAll(".property:not([non-match])").length, 0,
new file mode 100755
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..7bcc7f569999b5e24184f8745d7618ed5cd7cd91
GIT binary patch
literal 3626
zc$_s?c{tSF7yr&Qma!X^HI%U=%S1`<V3Z|;EM*yM^dc{1GQ?moMz&-vTe6f&Z`LAY
zlo=CcYf;w9jCHbP#+H%6Z~T7G?~i-Vz2~0K=X}n6?(^K|ra9Q16BUvZ0suf1ZDoFe
z=ZSkmke_F1CceEqCmU{o3BQO92#@r|`2%PCu$TRn(bs&h_+Rk%^@|Ga_BY~z`_SfR
zobY46N}@1MGjbH+{dbFe9q-<-G?f(W|7CK+S#N#z!ciU7Vv<~5aEPFGG<nJG-d4yH
z!4~1sAonFA@utUY?qn{Gd{jkftn(+C9)q{<pZP3fsNY9mmolSvSE8nknHyU}`pg)m
znA<w7KOd&=nckkd!D`x+jDgYB<MVEY(?(aPxv6)fDBl?Snx{S!&zUJ|io8rZyR#*F
zTpii>IoTYcjrSn5h#8$Q^2E2S1oqG}QpiaiqG8uN@1H1CN%NU>p#w@Ge=8~)g&T44
zoK-=F<a?E;{3;SEKp2~L-w1I|bk-K8Az_*<{-a8&$)HSj6BG->#pbFX8uThHd=N`X
zbTeG)<SlOA5AX~cmBzjGEI~w~!AIQJhp_22f{Ksc4QyRYoD7R?vVH$4U)4L!FJ`R*
z6W#3>u@-l~^T?{V0@BkcC$>h33ac|e{$6_r)9@>u)$~u&>jbIsMD2C3Gj=;-B(D|3
zZPD@?S_#|6Sav(jO;qkT?#<uNU!T<MjyaJp&2RI{)K0dO_2K|i08tujFn!xNfuEHW
zouJvc6Kz;TTK=lOQ~1$^Smw53V52jCIrL}Ntw#?fN~e%lH%H?{a9tDS$H#4q=lO0+
zn}%#FB5LidhV%XR+rJFr;7l_=Ntu2yRA(c8@>u~Y<X!%j>Vf6_yZ7;@&(2@2IrK&W
zamuPssc$ljkQ;h~LE12<5hcMRlZ&!LLvd1i;hQmQDx<RxLplV3Fw&2t3Xag3NXdfK
zTD*Oe`G_INsf9X;+DUCX@fx0~tt|qxBp&$VGB8hMdXu&w=a)-)B_U5!#DxPsfu^$X
zt2#GcAlSPK{4km6%wmfWy#0D=eJJ>8Xw}K<Twm;iu3Z#g>XmHdl1%HAaSq_TUpW=>
zbP9Z13PTK?0Yh>CYltDd9!RkQU_^+6Cb575#`A)F_^I+1u;~&UfSQ6eU<@J!te_0q
zFN|>U0d?g9Pb4T8eLzNNpcA|(jUjHsiI+iLf?5<A7zF}e<Z;LT54fM<As))dcy$L5
z;*-&?2P)A2D?>R27G{e=%P~YpurT5l1d#y5{OCMDWZLmCK94Bi+i;MrGDR_gZ^R6o
z4Zw+dAWOn8wQ3+6$)n8%Zb3$PY~;QAZ94Tp-5o$pf>HHkQiu|!4&t?9ng-Ox9<BX<
zx-|s9E*#27{JsY`A&DWX?FlyFDgU?^c`Kx4ss;4{gG|B>xB{g}Xt@K?)r2>FUjk9)
z(OG~OVHl#<9wwO;r1f7F<xWI<$U%k_%=9@xgB<k1T$3n2TVqlz_jFL;-81AWds5O!
z>%0$W01hH8d*2roLKih8Kgd7_$+&2Yx|F3DD@HB(%(};Zz_;irG>k`J+*K0z0wLhW
z&X`bIjQ$l-GXX!ptiG#N&M*6bxY$OQ48H7gE?P=|cz(4*fM2_k_Q`3lqX|W}H<vx$
z=SHiC>fz1?h-N=nhB*;+3$6x}y3IuIALM`er_ZrYSH|OfiaXp?psmtJe;9E!;dWbg
zk!R}%JXGYCLAUC+?^nE_fhb(vH^Q6eImRbymir4!GJ5d!g(p_ueP1l?5CUEeztzvh
zTvwy;%YcsgBpWB*p?;@nfTnY=eM&l!(L3;4skOmzf^^4tG?PTVN-xRLni_v3SMyO|
zu*F;oz}0qNf!GrJGf5i!)kN8PT99f`h0X8-;J2ag@~l*m@Ph6et?e9p)^Gpd^<Om)
zy_Gt51rQ(uiXaB0?;{|R^ElQSLe#1F+*V8l(IO3IUb3HjGCO!paI%kh2m#5rbk)}1
zPdwL9cqn6SD@5HYul^_XmLx@}5QOx>90E-rHkIFc72K0MwS80TyVDg9R2fmnWV~!|
zcknPH)YE|SmU?Y0OZzViY~)evo~(m71MdySDmpAqWM2S9Y(wDd`>#L!%RSp9HNAt>
z{qXO^M&~{6MNb{brQF&#@@O2Nw|6KtbPFAKx4eGkC>5(Dd7(Fd|Bh)piLVNC3j(2i
zYS>?dF3TdoE)<c`f2T9bpM~&!n{0VNeffx97`wz08J~1&n(A`MrSvdZZO89}<Ua)7
zqLKwf^%`rIwg5NqIj(qd)@eqL#LLb(YSY4TctRe99v7=IW!q!Pij0?%IehG05G_6x
zA}XRP6GKta32L}Fmmh3q1s0~!e_s@t(o$rH#N+rlUD#chi60atSX=0)Fv3^0%7OE)
z6}&7eJzD!7Xy3T9dJ$ioDlLKDLMyGPFhK6y!>Q)NpZao&qiE^hr!jy1E`Nt_=s0zj
zB<WbJz*3({$$^}N#7kkX=N!%4oq5g1Btpwpj<?Iftf~^BbKcKANik^!{5g<-<T8RP
zDRL{bJrg;7`kCc~Ym@o3yg02TuXCl?3>*;6k&n{tEnAKi+r5!asWS)D(~8DF=N!F9
zUeFPNLv2NrqFr~cva(Q<vgzz%O?PIo4GHZw_CD3`{O7UNeO6#8DxDJJykl#_aX^08
zWVouG@ys;PIx_0mKI@5^<3IQ#2#u(M?oOrag1DE(Q2fo2HT!lhSpi!gO_tw<>sr81
zkGtP6aB7wObHH(MqHZe`NVgjJUQ#$={8n><$JP<q|0hK~IHZ>QAS>L=MmSNhHitdz
z{qtkTov#*mUbLyy$nBWHv*R5!(d+>4hBp)Fdu0V>QI4(8XOgIpS9%=g)^m1-oY*CK
z9SFAvj$gR>QJA1`4D)+ictHH1%TEu<MIq2CoY?-y^AfQxt9M9D5C1rLo4tD$?8@;P
z`&LPaSuSP#$^G(L73#9^4TcvfR046GnSbi*&HHP*Pq!v;5>hbiV|RRdWZM-9p5!Ku
zlWs1sZ`J~cpBa^Q8?jvP=XiR>@8bkb@J@&NRf*fWEdRPKHNFjiRex@-YGC`C!28qV
z@Cl;UPP@765}igc0eP6$JC)457dZp-bie*E1r8#7a&Vo{MXnlAc26I!b1QS_+m(bp
zbpZcpRN5|^xKkpmq^MiKP}!!>ix3JSHocRqnAPK#yeR73ABU|u@rOZ#j_TqZx*l8$
z9TpKc9+nGP2the7Ow@fvxxG0a(JI}@UBH&C%_S*eTZXJT2jKPpYEb)nwUH|mjJ`Hj
z>tHn0XF!-OUAENCf6ZZg?ZZFx(i`A7RahXCyPp%zv0U#K$B~EKp?;inyLEu$T1jAS
zd6tlNC7|>2*6i^NN@Yjx*C-Y<e*?0BMR^4?Xx8VV^`qxc6XT0?Q^<p8P97SuK|gb-
z!ypL9oDHuz38M%JFmw$!#SH>q&kvwJ8nA+ZOU_IN>MU4*OL9iC3e?Az`yW<s;7ar0
zBiG3l9JYOUVt)McC1!DCLX>?;%B3{O_$rpKc}j}5c6xLM20wTMCT5})4BAO~M}A%~
zT=ij9{G^#g+}|YZO^9$va|kVlWY*BoDyW_y5^qAGm;Z&_&fTRkzI~12sjFw(EesKE
z)MI};hQf&lL?~qi8(NKAeL`J@3bn2j!gg!en4DDiSZ+>@x#FLUc@0TsZ{B3BRab%R
zr3f=Hy!O`1YuE8F{#4<hY92HH`s#7TS6WS*<1ha{34Jrfdvi#2wj^~<mbFQ7k#8)F
zf;+%yFWV9c---&W6)>@2pI1*HTu2+fH4t$|^60%2Zs1_U7VBixsZ$UJ^MkhFJdrIg
zNzk{de^DK)T;Q{HdrczWTQA|-(fN>24(req8|C63&n{CRlchu|bDrEOSF{Eyy`pNl
zHL<|1Uc~C{wGWF9%b2EZyDYgBae1eB%B8v<IOn7mC@Vjw_|PdkCQN~G?$ML+Ij_Ij
zzN%n0b2^-#Gsi`AMc|L9Q|tbLayB7K_NalPU&o^JVsXv(8Pu|pFKN2#3Szn~Kc0zF
zn;Rh>3a<83u*Fx#wtpRKR%5I_9#2TJsPT{@^x80}w0O2l<>N16DfM;hpBK|769N)Z
z$H*#eBb)gQj|UL5rqkN@A~bHsx&@AfrTcO88+OHzgqVW6jZjOD4up<7GUB9h^)OoE
z^^Yj;c5^ZvMV1YL@ouC(u){wXGLrZ9mI8!str{r#`b(6ZMuE@pd4J}?ZVM$iCv9HW
z=Tt7kqaEU)_SnMqS#RGb(Fp&4QSDCJ(CH50FAZ=GS(AdbV%J<E&6<7je3D$-u%$g0
zw8@<7YD3>ejS#!1*VgQ~kz3D7>X&aG6C+_eVMdFlHuT{);fEw!yS!1lb;pn$&6yyb
zY8d03Jlj!?kSB~9`yN_Zu!d##L=A3^SF_y7bj}Lya0)BSEM1=}eGW`Z)C}idY_v<n
z+bofLYQqBpuH@tVCB9uW^o%aZ?oQW^^;nbp7N<hmB~&5Pe?0NuhYBj(>^dX9DeQGB
zaV2<N@Qn=YeP!O$&=N82k&Ry$O+K<+ws$C53Sud>jk-S@`j$XhbTiixx?KGeU!C~w
z#$+YJsJQ+3T89!gNW_i~=aA6K?db5gk*iCbjxOnRt){o^cVC*r4Ts2=t0EEHWi_g_
zJva&%m~tfWx>kV=!=N+Urna?QOKc?3p{mZ}h|x2_h|Y(-5y=c_+%MQfXyVFzlQ@)Q
jC+!vf*@9;V(-z_#x?8b_3wMw3K7Rn(!p^+*tPklw3@XZv
rename from browser/themes/gnomestripe/downloads/download-notification.png
rename to browser/themes/gnomestripe/downloads/download-notification-start.png
--- a/browser/themes/gnomestripe/downloads/downloads.css
+++ b/browser/themes/gnomestripe/downloads/downloads.css
@@ -225,44 +225,57 @@ toolbar[iconsize="large"] > #downloads-i
                               0, 16, 16, 0) center no-repeat;
   background-size: 12px;
 }
 
 #downloads-indicator:not([counter])[attention] > #downloads-indicator-anchor > #downloads-indicator-progress-area > #downloads-indicator-counter {
   background-image: url("chrome://browser/skin/downloads/download-glow.png");
 }
 
-/*** Event notification ***/
+/*** Download notifications ***/
 
 #downloads-indicator-notification {
   opacity: 0;
-  background: url("chrome://browser/skin/downloads/download-notification.png")
-              center no-repeat;
   background-size: 16px;
+  background-position: center;
+  background-repeat: no-repeat;
 }
 
-@keyframes downloadsIndicatorNotificationRight {
+@keyframes downloadsIndicatorNotificationStartRight {
   from { opacity: 0; transform: translate(-128px, 128px) scale(8); }
   20%  { opacity: .85; animation-timing-function: ease-out; }
   to   { opacity: 0; transform: translate(0) scale(1); }
 }
 
-@keyframes downloadsIndicatorNotificationLeft {
+@keyframes downloadsIndicatorNotificationStartLeft {
   from { opacity: 0; transform: translate(128px, 128px) scale(8); }
   20%  { opacity: .85; animation-timing-function: ease-out; }
   to   { opacity: 0; transform: translate(0) scale(1); }
 }
 
-#downloads-indicator[notification] > #downloads-indicator-anchor > #downloads-indicator-notification {
-  animation-name: downloadsIndicatorNotificationRight;
+#downloads-indicator[notification="start"] > #downloads-indicator-anchor > #downloads-indicator-notification {
+  background-image: url("chrome://browser/skin/downloads/download-notification-start.png");
+  animation-name: downloadsIndicatorNotificationStartRight;
   animation-duration: 1s;
 }
 
-#downloads-indicator[notification]:-moz-locale-dir(rtl) > #downloads-indicator-anchor > #downloads-indicator-notification {
-  animation-name: downloadsIndicatorNotificationLeft;
+#downloads-indicator[notification="start"]:-moz-locale-dir(rtl) > #downloads-indicator-anchor > #downloads-indicator-notification {
+  animation-name: downloadsIndicatorNotificationStartLeft;
+}
+
+@keyframes downloadsIndicatorNotificationFinish {
+  from { opacity: 0; transform: scale(1); }
+  20%  { opacity: .65; animation-timing-function: ease-in; }
+  to   { opacity: 0; transform: scale(8); }
+}
+
+#downloads-indicator[notification="finish"] > #downloads-indicator-anchor > #downloads-indicator-notification {
+  background-image: url("chrome://browser/skin/downloads/download-notification-finish.png");
+  animation-name: downloadsIndicatorNotificationFinish;
+  animation-duration: 1s;
 }
 
 /*** Progress bar and text ***/
 
 #downloads-indicator-counter {
   height: 10px;
   margin: 0;
   color: hsl(0,0%,30%);
--- a/browser/themes/gnomestripe/jar.mn
+++ b/browser/themes/gnomestripe/jar.mn
@@ -44,17 +44,18 @@ browser.jar:
   skin/classic/browser/Toolbar.png
   skin/classic/browser/Toolbar-small.png
   skin/classic/browser/urlbar-arrow.png
   skin/classic/browser/webRTC-shareDevice-16.png
   skin/classic/browser/webRTC-shareDevice-64.png
   skin/classic/browser/downloads/buttons.png          (downloads/buttons.png)
   skin/classic/browser/downloads/download-glow.png    (downloads/download-glow.png)
   skin/classic/browser/downloads/download-glow-small.png (downloads/download-glow-small.png)
-  skin/classic/browser/downloads/download-notification.png (downloads/download-notification.png)
+  skin/classic/browser/downloads/download-notification-finish.png (downloads/download-notification-finish.png)
+  skin/classic/browser/downloads/download-notification-start.png (downloads/download-notification-start.png)
   skin/classic/browser/downloads/download-summary.png (downloads/download-summary.png)
   skin/classic/browser/downloads/downloads.css        (downloads/downloads.css)
   skin/classic/browser/downloads/allDownloadsViewOverlay.css   (downloads/allDownloadsViewOverlay.css)
   skin/classic/browser/downloads/contentAreaDownloadsView.css  (downloads/contentAreaDownloadsView.css)
   skin/classic/browser/feeds/feedIcon.png             (feeds/feedIcon.png)
   skin/classic/browser/feeds/feedIcon16.png           (feeds/feedIcon16.png)
   skin/classic/browser/feeds/videoFeedIcon.png        (feeds/feedIcon.png)
   skin/classic/browser/feeds/videoFeedIcon16.png      (feeds/feedIcon16.png)
new file mode 100755
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..139bf0b539e3d978b05396f78269043275223b2f
GIT binary patch
literal 4066
zc$__#dpy(MAIG<u%glYU_=aMQD3XvwENsiIawi!HA^W<8xy{^D3?-Lxja*`+xnCof
zBIHh(2+3u9i_zjY-^=fh&pGFDKCk!t{d~XQ=Z|yZt{J0wxy85v001u*qkDrj6AwQw
z4%XPN<?w+uiTdhU`I_RLef=H0?*Me1@Q!zmWA8b*+_`bb!70$I=guVnfIkwet78^0
zx%S-O%xp{~rhP#81uu`$J5XAlBeqiaQS*<YN`!u8hv(_XKw;?zM6uIx(;X5<CZ_`f
zx37xi430atr8TCFS8_Duw65+<E!3vUL$@MDaSE#qqxen9)rOXhRG(<|r6lwM`3j%<
zzeBrCVuE`&$KZ)=%#jXJFTKwKJKhg6OWLeQoG5N@1RYb^@$na=6k^qGK#OCB(I~P$
zX8xS9^v{~_r8Xe5dkQ5Mwt{Wv=xYKp9Rq=9*ke3jxNv&pD_k*krB!U43TEsGM`bH@
zcc0@qXgd0{rhOKh3oI&D9_v(*6MSa2CKaAeFFmn8t@g<@qS|yv!5}mXF0^f}|5L)p
z^Jx9YZZ+TM*ctp|69)cQqq;oBdHI?935RTnZ?754jXG0BoMZ1*N+<P5Lfp90a;bv>
zqhW7);c9HOw3g-yyuMXfxH23i#5a&)nlLmpWSn|?Kc}##<pzcs`X!^bnxj2c@{fxB
z)T9lLs~{~-+Y>g-((LSfj^>P`p}3Z)^l%4vXig1t`6AWY`)QV~b6)j_;$yc_yt~5$
zFJm2}o3^;|izQQd9pu=nbufpYf;U_?8o)%Zz3n$`UW<tg^Lmrz1y#xRiOc$Rf$}UD
zE?)k~eZi*AIrLbOKPXgb7%~w9C&rl01pl%2dSSeAGQu(~qpzOGv1B@R$7y6vtj?l5
z-Q6+~6ng3n{58KKAhFneb1HOb*&NNv=|*NjVC{4=@-5Z7&nVAQVs0>8Ov*y=P-pUL
zcs}>mz`&8Q%)a^}QN~WY3McRHMX~7E-y@g8tH>b%z<~Q@T8Wix=vO^>s;sRK=#5Q4
z4C(FY;+JD@hn<p2|CT&ZiIlM+<yT+NOf(vf#+Qj*b#D~l5Uml)j>u5*g&jufuTuLm
zQB7N36Cj>H3iDbE=5w1Ix9b)$A$DF`6Fc^tR2p|)wA>CdU<EE}1U(c6_6p}5$tZpo
z3rH0>&J8+!(kR*;4%7t*wjKkL20B~@4bLDkU;);SGCP+p%r-CG#xREq2LwJ8z(MYw
zyV-EKw#iAid3d;3$&2e_SrnFY;Z6WWQjpRhD{bOMS4ZXZrt!tnpjdzuF&#9l56jk3
zrlw6w5u?CXx)~1-#aa5w)T4r}DA1)SXE!A&;z@99Bmjy{nVZyOMJ|d$YQ?eksVp#U
z@L5wLF;>{Eo_LrExPk~U8ZbPg|2L!$dy!}s>d{gPvYi?aaOS?oX5<mcGF187kR?4K
znRG~nAx66viu^-V2QuR~$mNhs{?~?<h#W<;Xu<?rgMrL}4jGpBP7`ni8Sob-MG$xz
z(K`RPt(7*w{`{sAE49rdz|+TDxwy_g{f{Uy@86094|EV%>Uox2pGZ@G(Q_D)3s(-9
zadi}6)jc2{un5H+%|eA&9VV-Crj;$|=S1;6lV`*0aL<B9dr3TWOw6FH%iRv3#i<4N
zGcKqL%guD0e_=I|PL0VW;VGfH62%E%sYGdBgFuRwr<K1)-MMymEAEl!dKo-pAD3E}
z@;(-y-#P11G!B-tAiVq7JT4^5;A`v*dFp2d%am04R`cYRcrvP~GOqpX=TWIj9)j=P
zwXrTsUNwbFPxj}<E8|yK4gSZ~+a)ubprdjkNxjjcO7hN~tHU!;zIVym_a+v%IteAy
zcqsLI)rzCXP@4I-k)XcI8#8|Qt9`oCkxOGPH|}<ojae>8hLPOz|M7QCq{$KapQp53
z!ufF#G(ffU*V>uk*S|miuA08s|Neehkc#MA|785?^)1O?8pi8R#V-k;*tyeEji@e%
zJ^M@ju^uH2QstoE`ygFO!?{Sc%v&}Az+5eQWP4R@LjqdG)2V3|^5srR9E>|H3r%&-
z5J<K%H)Qun6RdJ{?oALqXW(pe4EU^a)~+f1JD$(ydqaksVY3d9$vN&8$Kfc4W5J!M
zIz3uw?lx9_yz%A_HJ*tyQ=b)a?lc`C-l)T%-KXQ_0UJ~Bvw!~K=O)mw8;f^Djy!Wf
zVe;bAVh;sYt0B;l@xjtAeL~^bdjnXb^rwwIlR7;W`iGOFlFsjX)5MjXQr}J1ne`pt
z4AK^F)T<8j+pnZFIr1(2GHHW$`X*a>{Rdovt}jPa5hd)#24Um-Z-S=2UB0K<A)&Hs
z(wC%fD<53(UoEUYO=v&QFx@8jXhzZC+in`aX%>|0Xrs`I-UGH|tLx0d1%WCc^BzlG
zY};}>&R@Y&hz`vKDqnp>j}NNJ3=F7pF^ukk3o$k&Qy&MVMaj@=GQC`(%8nMjhLuC<
zzv5^ikj7p3&g@mq?CcPy2rZ=atc$nmt~W5*JD#5w5%q1?Iz~+kFgqnhhc>|IWl<*s
zyw(S)dqr1vwR-%!cS3kHW@NCUT{5EdeB~|sw3N#5^vB%HJVdLEajs%mz^X>bkK9We
z3sVbhkl<QbY<fonV1JGYUvz$To3WCPmp#IW!V(k3{y>o=D8WBI)a(^yZ}Dt6tU@4-
zbr-OwI(0cd`)TI!e{DIxv7{1wA{D|!A?R<<<^#37gTGVR5A1RiFQ&Pqfgy!Dq`Qby
zPXPNtH9c%iiw%nQM3!8Xg|gfbRZq45F*Qb*55K91!O>9HD>{;ulHlvFC2FU(?BMWQ
z{_L}*hI8<9CNv0S<qAnn<FwX(0eZOkW<OS~CmyOlCuGo}o5eHBFqK%ZmftP^0KZk&
zrg#-(sCj?w$7WprkIs;tOENRZDaB-*9JZI6X2OJOt-qe7RnM*g83|uGTDTxtvSi#u
z&sW0yOalQ!Q)ibU!jc{%ke}eKv)NOjgPRn_^$&2dok=+wTq<0GU2Dcg*>9cMQ(Umu
zt*I^n^CU|MEqkGozjWwI!0^cpUiO|b?^?pz60J%j?H_|{VZMa<A?0`|0#k3i*F(l}
zV<qH>m*<dyy6X*HiDu2ECH(ha!S-hnv@qF``P<#-AbjE2EQ9$O)E_HZHJwtP#EGD{
zLay$gLV9=E4T;n3?eA~F`dSrrLHwzJ#E69H=5FSIviFX7O^5peALO%FUNVX_Q+ra0
z+2pTr<}#Is-XO~$7_};*NCXy5!1wP^AI*0E>H7w?SJzoU=dcnygfFRF48b7p`e1Lu
zsTTBRzL^glx_duK1HlyyUTX;R@k({+;IFv}d)<9TJ^S;YUxdJPI~WDty76EK85;KK
zJTr_;qYgZI>Jp&0+W769R{YHq;qqeFirE+nJeQeWtL53x?YcLNn9F7dJ@Yx%3_Xm%
zusf_tsDA4`Cz%%g;R1#(fxr~LPu~Gt1}b*VHB`+qnV*^5oGs)7C0|pa#?RlUUKK}o
zKOZZ7)PPbTx3cpVn*o__^HAFCx9zXH{JVFoL&EbN+gMq)W|4FHTPVic35G2zJdhF{
zlAEhx0T)e!)lt7+WfX<puRHnNya$qqfZ~4tG2~p>c-6Cc1yd?E(3Q`8)eyvFl=2){
z>`)XwTF@g#Q2cx+Zw=_=3k^qs6}Rnzd`Kovdq-Z@#xL+do(&dpr(<^)gtPVb=#rj4
zt-S6cTZAp;7*QD7d!b0r7fZj&>(Xg|q~D*oYsmhDI5%G~29wSiIP&!6yyo)ARS4_+
ztyF-2k4`7-#2Yr4`Sr4UlfcHVH>0>{mg1Rux8^kPKRUQ#(J1D*n|J5nNT6a~<VGcx
zb({NW6?S_vs$>I2f{<}ScQs(Z%j+gvJhNU+ODmUOY651<bZ5tlbA-l=?-*K<s@YVX
zx<<|xI$MZ_WR;*uC9W@!Yz*@+<z&l_1ox(vri)Q%E#{Uy{lJ<8z|cRp8u_Eg9vW*d
zUAUN1qD_)>Eh+>t64>cOl<m$xpQ0~;S{OnPxnr>!^GBhOWbZ+<Px{AS&8Nv*QDijZ
zW9klnn_USAtXGXtosBO(l0tazFl_A|2~KdWFz2L;&%6`U6#N#}+_cyUmRQ`vplMHU
zl13wH7WKwN(+O`^PRbI)1ml%o*tJ!tLZma{!oil|_TCUTZIT7~c!{US<i>XXM=~4Y
zPwn<HIU=5)p(S|tX`pdL4AsqxBODKb%uH(c^Ub763LeYc&J5|j>y2rQDNON0K<H?D
zgrSq&m%4`oMn4q8@z#)lxRe!g&R5!6VFe+7D3ltnj@>4=N&w!g#05IRgTm+RR}<BF
zqA8<aVT=NV4m6ck=|7Y(p_eUd4-pQ&e0wsmHE~{@hbmVaUt&$Oy#|`%M7U}>Y48R~
zDQLE<?(x4is72og+$aPFPmTXY%+Bb6S%O+TPSQ83vodr@{ws;oUgM(-jfqDwV62%c
z7QjqOH=9l)B*?r9_=qZdCqw^$0m+<fQ;w(^B9j@<Iqyj)ULiHy;b_q}Td~e65@LLn
z4`-caF(Dq$XSMDv3R`NgqrlYwb2)4`JJTof)XES~woD1Q`3dH%s|K$}#+#r-g)c1y
z(!lmabpzmF@k@?-J&!Et?j;T-t%@#?;D&oSFDsP0h%b?A69w^%DBpP>4CkLB5ZZTu
zr0FM_K#OD-8TRI%vGg3UiKExTem`PkIu{xN-XtGS>irPVny7V!iZ1-!R+V%~z6WLs
zn%zSbJz(I9-xQK_@PGCEGWB!lGOYJ<#t@UD6!y-Kh(93&4~#Zq!YSgA4BTKxjjf?(
zg}ItkyOZ*^>I5RKo8y|~#ZCX7&Hxe!U9i8$hs+8Pxj}PBlSt-9oVX)pOG^^AUoWh7
z9m^ayaEg%MJ0MABqg8L0r+6|1P3JqN8#wXGyg;V2o4l$^IE5FoPQi5=jQTE9FS?^}
z9($DPcK)R)91mW3vD4l%0JU%L&mkhcE;8|ugmCEU9;=nEn(vZ<Z$6j`pt!!3=4GF?
zpt)Zm{VIJz9~=6PdtJz`&y}lbaSQ8t(F<R1Km4)EynTDRTGZ>pLDC$$TWM80!E%BB
z=}O|SIqjEUT^4UgS6<!^tP%$k%+7S0nbX`&K|w!zx91MpmTcAWdBiyB8Gw)M_D~#6
z*rT@g`JQ9X$VbMp7W0=>cKg0<%j{)!i*bsZd0rie^CamhA*rE--IMLette@$zLh|E
zy7@v0#Y&190$X+Cep8z9-p^uSt#8uT`u`7M*6`{#Lvk5V*X-H9|Ah5u2VnJ#b<0sW
G(*FP&3#p+1
rename from browser/themes/pinstripe/downloads/download-notification.png
rename to browser/themes/pinstripe/downloads/download-notification-start.png
--- a/browser/themes/pinstripe/downloads/downloads.css
+++ b/browser/themes/pinstripe/downloads/downloads.css
@@ -233,44 +233,57 @@ richlistitem[type="download"][state="1"]
   }
 
   #downloads-indicator:not([counter])[attention] > #downloads-indicator-anchor >
   #downloads-indicator-progress-area > #downloads-indicator-counter {
     background-image: url("chrome://browser/skin/downloads/download-glow@2x.png");
   }
 }
 
-/*** Event notification ***/
+/*** Download notifications ***/
 
 #downloads-indicator-notification {
   opacity: 0;
-  background: url("chrome://browser/skin/downloads/download-notification.png")
-              center no-repeat;
   background-size: 16px;
+  background-position: center;
+  background-repeat: no-repeat;
 }
 
-@keyframes downloadsIndicatorNotificationRight {
+@keyframes downloadsIndicatorNotificationStartRight {
   from { opacity: 0; transform: translate(-128px, 128px) scale(8); }
   20%  { opacity: .85; animation-timing-function: ease-out; }
   to   { opacity: 0; transform: translate(0) scale(1); }
 }
 
-@keyframes downloadsIndicatorNotificationLeft {
+@keyframes downloadsIndicatorNotificationStartLeft {
   from { opacity: 0; transform: translate(128px, 128px) scale(8); }
   20%  { opacity: .85; animation-timing-function: ease-out; }
   to   { opacity: 0; transform: translate(0) scale(1); }
 }
 
-#downloads-indicator[notification] > #downloads-indicator-anchor > #downloads-indicator-notification {
-  animation-name: downloadsIndicatorNotificationRight;
+#downloads-indicator[notification="start"] > #downloads-indicator-anchor > #downloads-indicator-notification {
+  background-image: url("chrome://browser/skin/downloads/download-notification-start.png");
+  animation-name: downloadsIndicatorNotificationStartRight;
   animation-duration: 1s;
 }
 
-#downloads-indicator[notification]:-moz-locale-dir(rtl) > #downloads-indicator-anchor > #downloads-indicator-notification {
-  animation-name: downloadsIndicatorNotificationLeft;
+#downloads-indicator[notification="start"]:-moz-locale-dir(rtl) > #downloads-indicator-anchor > #downloads-indicator-notification {
+  animation-name: downloadsIndicatorNotificationStartLeft;
+}
+
+@keyframes downloadsIndicatorNotificationFinish {
+  from { opacity: 0; transform: scale(1); }
+  20%  { opacity: .65; animation-timing-function: ease-in; }
+  to   { opacity: 0; transform: scale(8); }
+}
+
+#downloads-indicator[notification="finish"] > #downloads-indicator-anchor > #downloads-indicator-notification {
+  background-image: url("chrome://browser/skin/downloads/download-notification-finish.png");
+  animation-name: downloadsIndicatorNotificationFinish;
+  animation-duration: 1s;
 }
 
 /*** Progress bar and text ***/
 
 #downloads-indicator-counter {
   height: 9px;
   margin: -3px 0 0;
   color: hsl(0,0%,30%);
--- a/browser/themes/pinstripe/jar.mn
+++ b/browser/themes/pinstripe/jar.mn
@@ -68,17 +68,18 @@ browser.jar:
   skin/classic/browser/urlbar-popup-blocked.png
   skin/classic/browser/urlbar-popup-blocked@2x.png
   skin/classic/browser/webRTC-shareDevice-16.png
   skin/classic/browser/webRTC-shareDevice-16@2x.png
   skin/classic/browser/webRTC-shareDevice-64.png
   skin/classic/browser/downloads/buttons.png                (downloads/buttons.png)
   skin/classic/browser/downloads/download-glow.png          (downloads/download-glow.png)
   skin/classic/browser/downloads/download-glow@2x.png       (downloads/download-glow@2x.png)
-  skin/classic/browser/downloads/download-notification.png  (downloads/download-notification.png)
+  skin/classic/browser/downloads/download-notification-finish.png  (downloads/download-notification-finish.png)
+  skin/classic/browser/downloads/download-notification-start.png  (downloads/download-notification-start.png)
   skin/classic/browser/downloads/download-summary.png       (downloads/download-summary.png)
   skin/classic/browser/downloads/downloads.css              (downloads/downloads.css)
   skin/classic/browser/downloads/allDownloadsViewOverlay.css (downloads/allDownloadsViewOverlay.css)
   skin/classic/browser/downloads/contentAreaDownloadsView.css (downloads/contentAreaDownloadsView.css)
   skin/classic/browser/feeds/subscribe.css                  (feeds/subscribe.css)
   skin/classic/browser/feeds/subscribe-ui.css               (feeds/subscribe-ui.css)
   skin/classic/browser/feeds/feedIcon.png                   (feeds/feedIcon.png)
   skin/classic/browser/feeds/feedIcon16.png                 (feeds/feedIcon16.png)
new file mode 100755
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..5194f5d59a4328f984b99a8d76be18175b793345
GIT binary patch
literal 3755
zc$`&Nc{mhY7oVATkS&=ELxhZd$yh>zF=HJSvacD#h-@i4F{DXFl(i(XWU1^?WEo2e
zY3y4VN+dLv7);|+@B6*a_x*9tdG5LA{C>atoaa9GIkzm#jJY|4H~;_uH`c_!^1u^+
zuS2W{wq4h)=fDXD8QKR~1$YL9x?Ldv&>jJJf*97%?IOXF;N}q?_@1B*031GtH9%X3
zO|0aEUrw7B>8crD&iRmYS<>T&ME2AN&vvMZ*m#(Y(@U#6b!H+#m%b+&Lz8X452@tv
zPexEK4a<$kzY`ZLj!Q@ozH&3=x^O~W-R&2S0W3UWd%sq6A6T-#Tm3qwvD2hF6ZjVO
zZbLiw<DPTlp0=zkgVxT2`p2Z!e$>4K!Wvp9@FT<oO{DIt8@%TuC?}|t8VEwUp2v{o
zdAach94YvY*svp_bH?4QTG4CuI{6Bp4aXDnpPTYOiJ=yYN5EZ&mn)Mmah?qhwQ&_%
zE^YLjdvY}(D`@de_S($&yBF7CyOA}WGtE!lNC&BR2eGFob;}q~?o`)++1t#G-+ryz
zm47p(>d87{r(+#d(J1j*z)<v?zvxxxy^a2Xl=-{;_nCJQu7qg^I=bIEG;+M5?51hs
zMQ1ZYk;-q7K#n}Vfc~+5zxj0NO0WihU$Dr~l<HP|U^BMc(LJ-;H3+NaG^L-Z=r0?Y
zYSr!RmsxVwx-PKgYREaS7kh#~Suvn%g-VPL#@3+bL-T;6<d02VQSe`g)U>8?$@#hr
z({LSK*?pUqwEc-ABqq}>rcl9JO3rEbvy|-i@xgm04+?b9%_W@MAjBa(Rd0!;;-M7*
zCixm=43}|bJG_u#7p2en>nwV_B+=SdPL-PtZ-z@8x|LhQPt34l8A=++3dqu68uT4E
z|KfMXk=}$BEPZb6Dc1<&;5ZRHxA2@LPdym%VXJHZ{ov!*BjWQS>)7zcD+J!O^lt6w
z$Hh6eZ1`IxgvyI20e;Uly-G8G5_j4kO-ZiDp2QIPqABa>aPujJDsvp}cgjk6xL1;2
z)KHLi{h%}wcm>&Xf9?E6W=Z=`e2vU?^5Z5zZRb)!QpToHO<L&KNhEOn@J`WYr9=Md
z1d;Z$tdUzFif&_W$YkO<&mD5Ho}(Oc80~xPB4TU|EK}e&S_05@_zDMh+Y`fB?Dh1C
z<{3|_twihr{6v-nJ7SO;UP;L6F7_huPXzbdiA4h|dDG71R=-!a4*3&=@U{|-deQFP
z2-bg-+<-I|PA$^!9kGK&`3a(_nkzkrWswb7-Jf-Zi?bC}31H`>0Duv1{v6=`W=L=X
z=m;S=lVrOV9f;A8yh-_<N`M03?{xM&eF@Ke#5_!dlfnav7uT~ZRnRB=pEg}!tyf24
zpQVFQ59r@Q1w966C>#EnZ0SJi?)wwKgZK&%I{#%R#)GqXfTy+pD{<goi3bQNSpaiA
zVo35IDhQw6btARB0}V;bEc6+dYu<AcN1I;#I&qcw<9mV6Y}w^wqf=J|h)a6Gyum{6
z_Bd5pjy2)ZGsZ+n=jn25JYU5=ACaFkdh=J5ov8X)??CytZDX+4#yb`3kg~sq4TrqN
zekgBpoU$d$8CP0$DxvwBANIW(T@K}+f4TeDR$r+AI09p5D|~w4bdZn6ENs(>b*Wi5
z!lz`mjK{Usanb|hp79UXjU_dUP#6cl2JbPv!Se*cs-vMNOWae%A_&=trlJlHq`iYx
z)w8XTjqB5X4x!MNq9(uI^TW$=N4@L$P5u%Y{uFqBODnt3_@Ju?c<p($(5xf>AW4w$
zUKVdp00gaYTAD=zE!9^ZZ;kXD+iXKkg&3b48VBUON5?I+_K3#y<Ko}8UlZg3={ZZv
zFh8gp=u}67J+CU>n5(nMX2~9$SJkdIOVP?K+OJ;J`GBb@oSaMBjC8&qjUo!`%{yvg
zp?HjM>pvy82=U%rAlT)Z9Cyp_uSf5lYY<T)DX9t`NV=m8?io{haeI1#kiFi$Q?nU^
z5E=Xtc(tHgv4d+lLA)x_2GCF+5QVk-*?Ge}t<FcoO<U@jqgM5yzoFe*>XjQpdV2!o
zvtgfXkjA4prgP&UG@Y2bd8-oiH@UAyrcr1L*V3=Us-E`*GRiBQ^IiOP%Ju8pxF3B1
zO5hE96GRYv`Vp738;Ro$zsez@cEe{E%5EJ~lUJ0skNZM0PfUO!Btklrr>9!2tBN08
z^j)LVc$k#e5pzcBOd|go?iHYh^aGI8k_<!OAoZwAixe}vrvO5UR~AK@Ml;&&8b-_}
z^1_86%OtR(znKbHVMty<+Sx}+=MVPLWy_<#3@Yv7K)W|{at5QR5uWR(KV0bvTv5sp
z6QmAue!GAS|AnP-?y^OT>Hvck;pq1bvOelPCZOWNsgGhLco^`TVGs%#E`kt*(Tnc^
zay4CM9b8|VHubKjdrH?G7ms~<L)8lyrB3~97)7GqL7-xA)NS$Dkd_`!cBO4?yVsZv
zK6scQM6I#l#AQ~cp|@ePv^kM3&R3)h9pu=UGH|%PXWE=Z*N;s9tcEm67@Up-#FWm<
zFJ1e_QYa8eqvjfcd^MeI8v-XFE0CT{1u~$mxUTb#QIpbzHxEG3)6_OpaITmDB<wkx
ze9OX=^-GgR7{pf}y?qOF6~gm!eoH3m$HrjB`HC|qrzvDq5_pll`TL~vRH1{%4u+e3
zNaj_;gH($WZlG%ujHY20$uY$wNRvmoL>SGIGUDuv>}SVnITdrC)oWP*du_9|0&h(C
zH|h`M+5K!*_Cs*L+{{1kB+bUKl6;2-PIZc;Dy_9x>xe>xtpW(_bEK9eYBoC)BZN;q
z%JhaS2cK<z<@<fJ>!mp+PB8^nQNp*djG+lUXrcL)U&_B=6IGd7NZWS>?P9zSH<P{y
z&mh*2gvnx5nP2sB8#D+Cw^;cc<xcUr#P8VLYB3=rN-s7|IS0XM(nH33RF99SJLp<9
zbwC~=A`58!KGCZ)&QMmy85V|cc<T=*kg?ld{2dU|li^U`x+{C;vL`)kBRSo#^s)Jd
zjF9O(+y0QN009j`!e3QJUHou;mu1A<I(tQdJUZ*1FobJ1*pPaNdVlQT9x_W=^cStG
z5BIo}>XL0vV&Zi2*Cn)uSQnw*kFD$ccHPwi@}F2mr5Y=`(yyJt9UHw67`^lOAxcQd
zSF{Knr>3SiG0iJfh9tY<v~Is&muTl<md+r0;p`lf@_n4E&zdxv$Xjj`PkH5l!-A+|
zgNl_=q@DhDH3xna73N9X%V<5_@PhFMcXj1QB6r>P;Hhznn3-DdA@*VDhL}siywyYD
zL55dY`$4zeC$2BBX6v^gNPa(x{Nlll2A{bWmW`A*zX>VirmbWl%v<a4Tt7avCb}r5
z&rZt;=7eiXhl#0m!RlJF>)f)==+O{gz8zD{P5V(6PL%4D;AECUJW{{~6CiOD+Ox!n
zNu;SsUOc#4r(J<q(P2>>P#K+=PPvxF<*KYQyR8_jbpq|PxY`@BH`%>FdH`;swT~ow
zu^7mUKjcbwre8DByD2kYpD_%c{Jz@FF}V*-Z$)TRTX5}$10y^=+apXSoc>_#7ye?H
zX^PZcgzVd7!HeKYOsMBg5#uz?pP1K!ynY5+qzJ@We{Q!)Hv6^SqI8~f(Spnek}w|j
zr))?}=$H7M0J%|zdD&QE?(w=N^Bxz+HDv}&QU(QUP}Er7Enaspsnj=uP<;+0O3-Es
z2ukhAE^$GHGWEl*F4KY!b0(<~I#5U<CeB*zvLzeMs(`j{H4S;F-{b7~O_@QLEa3<l
zp1MCuWjZaXVwHg8t}ny(0Wlh5kX?1#Q^BBU*7juAIE-+FCbtgx0}J=6oz*BNE>j%%
zcC3&iy7FGbaoWP<^b;L!$C2CZg0Scqlay<%NOcOdA<(*DA$>?4D|H|}R)=e%r`5M5
zV|Kd&9Mth%)5Jn>@vsZ3p?@&7p&P`$44}d$C@Hnma)c2i^IRkh?E0vui^gUWCkrQ!
zu@t%J|5m1={%m@Uf5nAzoTLf;B-7nX+dB^;RDiW!G`}b4yc|vPSr3u1eIVHx(pU&c
zL32~(^J&S-400yU_iO9`mbp5S%XeyLf=^zYe9DB#U4Ul)D$4QPr22bKzyJxl;*d~7
zhcU&lc><8Lo57>bP7IH6VCQZ0eKF9?iTNSqbY7Ai2~`V8j0GQMOsS)kE(m+sYU{K@
zC>Av%C+0~x`w7dI_=4NB(zn3VtAe9h8Q?9MjBHk;xC`{3<)c;7fp>_m@QhNfm;^}}
zH@n<r)vn>MMe|5#j~LlDa=*>h{oZ=pYRh0be8o(K@r8HRgFQ}DI6NcR;c_G18-*34
zF5H}|==X=Om=3(<Yd6<r4|*q~e+K)y*k{*fWFG2d`B){#Bo-_S5VQlJ2<lXgG~vTR
zB!4_z<sM*Rp5>FvFsk}RR^|CB7=$W6CY#k%eDIsX58Lt=v`OlaR~x>23*4XWF^+pz
z`n0^StS9j9^m;ApU=^S5=u_MkdJ;A8gfT~RTamrTX*WmVu^Z60FUP_j!prfh%2DAa
zl*l+i5r?bicbX@(=toM8t0+O*EIxF;D75N2$*Mw69C4vzzrF7`iCeaY90+DpWu%*Z
z>N`#4rkLut+Nu0OaKxUvCU^5>wi%gYmLp1HyWU>Xx93t&^OFm>9kml3`FQNGhpwk@
zZHr4SrDdkRXqVSl^<!J6hR>#=f3apFwu^S~P)rlY3l@>|q4YsXj>VCR4nId!=Z!lW
zmWyqMzVfa&B<xO-7wCi5A3}D$x9rz$J@%wCt$n^MLrZQP3df%qjb!mJJ(SbtCeRqc
z0(z4%vpXx<HhPk5CXlDvVOx&Yvy%+@rh@vPIS#(F;c9>iEbhM>HE=L}0<eZ=2IUxB
G+<yS}K=FG3
rename from browser/themes/winstripe/downloads/download-notification.png
rename to browser/themes/winstripe/downloads/download-notification-start.png
--- a/browser/themes/winstripe/downloads/downloads.css
+++ b/browser/themes/winstripe/downloads/downloads.css
@@ -222,44 +222,57 @@ richlistitem[type="download"][state="1"]
                               0, 108, 18, 90) center no-repeat;
   background-size: 12px;
 }
 
 #downloads-indicator:not([counter])[attention] > #downloads-indicator-anchor > #downloads-indicator-progress-area > #downloads-indicator-counter {
   background-image: url("chrome://browser/skin/downloads/download-glow.png");
 }
 
-/*** Event notification ***/
+/*** Download notifications ***/
 
 #downloads-indicator-notification {
   opacity: 0;
-  background: url("chrome://browser/skin/downloads/download-notification.png")
-              center no-repeat;
   background-size: 16px;
+  background-position: center;
+  background-repeat: no-repeat;
 }
 
-@keyframes downloadsIndicatorNotificationRight {
+@keyframes downloadsIndicatorNotificationStartRight {
   from { opacity: 0; transform: translate(-128px, 128px) scale(8); }
   20%  { opacity: .85; animation-timing-function: ease-out; }
   to   { opacity: 0; transform: translate(0) scale(1); }
 }
 
-@keyframes downloadsIndicatorNotificationLeft {
+@keyframes downloadsIndicatorNotificationStartLeft {
   from { opacity: 0; transform: translate(128px, 128px) scale(8); }
   20%  { opacity: .85; animation-timing-function: ease-out; }
   to   { opacity: 0; transform: translate(0) scale(1); }
 }
 
-#downloads-indicator[notification] > #downloads-indicator-anchor > #downloads-indicator-notification {
-  animation-name: downloadsIndicatorNotificationRight;
+#downloads-indicator[notification="start"] > #downloads-indicator-anchor > #downloads-indicator-notification {
+  background-image: url("chrome://browser/skin/downloads/download-notification-start.png");
+  animation-name: downloadsIndicatorNotificationStartRight;
   animation-duration: 1s;
 }
 
-#downloads-indicator[notification]:-moz-locale-dir(rtl) > #downloads-indicator-anchor > #downloads-indicator-notification {
-  animation-name: downloadsIndicatorNotificationLeft;
+#downloads-indicator[notification="start"]:-moz-locale-dir(rtl) > #downloads-indicator-anchor > #downloads-indicator-notification {
+  animation-name: downloadsIndicatorNotificationStartLeft;
+}
+
+@keyframes downloadsIndicatorNotificationFinish {
+  from { opacity: 0; transform: scale(1); }
+  20%  { opacity: .65; animation-timing-function: ease-in; }
+  to   { opacity: 0; transform: scale(8); }
+}
+
+#downloads-indicator[notification="finish"] > #downloads-indicator-anchor > #downloads-indicator-notification {
+  background-image: url("chrome://browser/skin/downloads/download-notification-finish.png");
+  animation-name: downloadsIndicatorNotificationFinish;
+  animation-duration: 1s;
 }
 
 /*** Progress bar and text ***/
 
 #downloads-indicator-counter {
   height: 9px;
   margin: -3px 0px 0px 0px;
   color: hsl(0,0%,30%);
--- a/browser/themes/winstripe/jar.mn
+++ b/browser/themes/winstripe/jar.mn
@@ -58,17 +58,18 @@ browser.jar:
         skin/classic/browser/urlbar-popup-blocked.png
         skin/classic/browser/urlbar-history-dropmarker.png
         skin/classic/browser/webapps-16.png
         skin/classic/browser/webapps-64.png
         skin/classic/browser/webRTC-shareDevice-16.png
         skin/classic/browser/webRTC-shareDevice-64.png
         skin/classic/browser/downloads/buttons.png                   (downloads/buttons.png)
         skin/classic/browser/downloads/download-glow.png             (downloads/download-glow.png)
-        skin/classic/browser/downloads/download-notification.png     (downloads/download-notification.png)
+        skin/classic/browser/downloads/download-notification-finish.png (downloads/download-notification-finish.png)
+        skin/classic/browser/downloads/download-notification-start.png (downloads/download-notification-start.png)
         skin/classic/browser/downloads/download-summary.png          (downloads/download-summary.png)
 *       skin/classic/browser/downloads/downloads.css                 (downloads/downloads.css)
 *       skin/classic/browser/downloads/allDownloadsViewOverlay.css   (downloads/allDownloadsViewOverlay.css)
         skin/classic/browser/downloads/contentAreaDownloadsView.css  (downloads/contentAreaDownloadsView.css)
         skin/classic/browser/feeds/feedIcon.png                      (feeds/feedIcon.png)
         skin/classic/browser/feeds/feedIcon16.png                    (feeds/feedIcon16.png)
         skin/classic/browser/feeds/audioFeedIcon.png                 (feeds/feedIcon.png)
         skin/classic/browser/feeds/audioFeedIcon16.png               (feeds/feedIcon16.png)
@@ -278,17 +279,18 @@ browser.jar:
         skin/classic/aero/browser/urlbar-popup-blocked.png
         skin/classic/aero/browser/urlbar-history-dropmarker.png
         skin/classic/aero/browser/webapps-16.png
         skin/classic/aero/browser/webapps-64.png
         skin/classic/aero/browser/webRTC-shareDevice-16.png
         skin/classic/aero/browser/webRTC-shareDevice-64.png
         skin/classic/aero/browser/downloads/buttons.png              (downloads/buttons-aero.png)
         skin/classic/aero/browser/downloads/download-glow.png        (downloads/download-glow.png)
-        skin/classic/aero/browser/downloads/download-notification.png (downloads/download-notification.png)
+        skin/classic/aero/browser/downloads/download-notification-finish.png (downloads/download-notification-finish.png)
+        skin/classic/aero/browser/downloads/download-notification-start.png (downloads/download-notification-start.png)
         skin/classic/aero/browser/downloads/download-summary.png     (downloads/download-summary.png)
 *       skin/classic/aero/browser/downloads/downloads.css            (downloads/downloads-aero.css)
 *       skin/classic/aero/browser/downloads/allDownloadsViewOverlay.css (downloads/allDownloadsViewOverlay-aero.css)
         skin/classic/aero/browser/downloads/contentAreaDownloadsView.css (downloads/contentAreaDownloadsView.css)
         skin/classic/aero/browser/feeds/feedIcon.png                 (feeds/feedIcon-aero.png)
         skin/classic/aero/browser/feeds/feedIcon16.png               (feeds/feedIcon16-aero.png)
         skin/classic/aero/browser/feeds/audioFeedIcon.png            (feeds/feedIcon-aero.png)
         skin/classic/aero/browser/feeds/audioFeedIcon16.png          (feeds/feedIcon16-aero.png)
new file mode 100644
--- /dev/null
+++ b/content/base/crashtests/815043.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+<body onload="document.getElementById('x').dir = '';">
+
+<div><bdi><bdi id="x"><span></span></bdi></bdi></div>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/content/base/crashtests/815276.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body onload="((new DOMParser).parseFromString('<x/>', 'text/xml')).adoptNode(document.getElementById('v'));">
+<div id="v"><bdi>x</bdi></div>
+</body>
+</html>
--- a/content/base/crashtests/crashtests.list
+++ b/content/base/crashtests/crashtests.list
@@ -111,13 +111,15 @@ load 715056.html
 load 741163-1.html
 load 766426.html
 load 771639.html
 load 752226-1.html
 load 752226-2.html
 HTTP(..) load xhr_abortinprogress.html
 load 786854.html
 load xhr_empty_datauri.html
+load 815043.html
+load 815276.html
 load 815477.html
 load 815500.html
 load 816253.html
 load 822691.html
 load 822723.html
--- a/content/base/public/DirectionalityUtils.h
+++ b/content/base/public/DirectionalityUtils.h
@@ -74,24 +74,16 @@ void WalkDescendantsSetDirAuto(mozilla::
 /**
  * After unsetting dir=auto on an element, walk its descendants in tree order,
  * skipping any that have dir=auto themselves, and unset the
  * NODE_ANCESTOR_HAS_DIR_AUTO flag
  */
 void WalkDescendantsClearAncestorDirAuto(mozilla::dom::Element* aElement);
 
 /**
- * Walk the parent chain of a text node whose dir attribute has been removed and
- * reset the direction of any of its ancestors which have dir=auto and whose
- * directionality is determined by a text node descendant.
- */
-void WalkAncestorsResetAutoDirection(mozilla::dom::Element* aElement,
-                                     bool aNotify = true);
-
-/**
  * When the contents of a text node have changed, deal with any elements whose
  * directionality needs to change
  */
 void SetDirectionFromChangedTextNode(nsIContent* aTextNode, uint32_t aOffset,
                                      const PRUnichar* aBuffer, uint32_t aLength,
                                      bool aNotify);
 
 /**
@@ -122,11 +114,24 @@ void SetDirectionalityFromValue(mozilla:
  * and in BeforeSetAttr we can't do the walk because this element hasn't had the
  * value set yet so the results will be wrong.
  */
 void OnSetDirAttr(mozilla::dom::Element* aElement,
                   const nsAttrValue* aNewValue,
                   bool hadValidDir,
                   bool aNotify);
 
+/**
+ * Called when binding a new element to the tree, to set the
+ * NodeAncestorHasDirAuto flag and set the direction of the element and its
+ * ancestors if necessary
+ */
+void SetDirOnBind(mozilla::dom::Element* aElement, nsIContent* aParent);
+
+/**
+ * Called when unbinding an element from the tree, to recompute the
+ * directionality of the element if it doesn't have autodirection, and to
+ * clean up any entries in nsTextDirectionalityMap that refer to it.
+ */
+void ResetDir(mozilla::dom::Element* aElement);
 } // end namespace mozilla
 
 #endif /* DirectionalityUtils_h___ */
--- a/content/base/src/DirectionalityUtils.cpp
+++ b/content/base/src/DirectionalityUtils.cpp
@@ -429,16 +429,19 @@ WalkDescendantsSetDirectionFromText(Elem
 }
 
 class nsTextNodeDirectionalityMap
 {
   static void
   nsTextNodeDirectionalityMapDtor(void *aObject, nsIAtom* aPropertyName,
                                   void *aPropertyValue, void* aData)
   {
+    nsINode* textNode = static_cast<nsINode * >(aObject);
+    textNode->ClearHasTextNodeDirectionalityMap();
+
     nsTextNodeDirectionalityMap* map =
       reinterpret_cast<nsTextNodeDirectionalityMap * >(aPropertyValue);
     delete map;
   }
 
 public:
   nsTextNodeDirectionalityMap(nsINode* aTextNode)
   {
@@ -561,23 +564,16 @@ public:
   }
 };
 
 Directionality
 RecomputeDirectionality(Element* aElement, bool aNotify)
 {
   MOZ_ASSERT(!aElement->HasDirAuto(),
              "RecomputeDirectionality called with dir=auto");
-  if (aElement->HasDirAutoSet()) {
-    nsINode* setByNode =
-      static_cast<nsINode*>(aElement->GetProperty(nsGkAtoms::dirAutoSetBy));
-    if (setByNode) {
-      nsTextNodeDirectionalityMap::RemoveElementFromMap(setByNode, aElement);
-    }
-  }
 
   Directionality dir = eDir_LTR;
 
   if (aElement->HasValidDir()) {
     dir = aElement->GetDirectionality();
   } else {
     Element* parent = aElement->GetElementParent();
     if (parent) {
@@ -618,16 +614,21 @@ SetDirectionalityOnDescendants(Element* 
       child = child->GetNextNonChildNode(aElement);
       continue;
     }
     element->SetDirectionality(aDir, aNotify);
     child = child->GetNextNode(aElement);
   }
 }
 
+/**
+ * Walk the parent chain of a text node whose dir attribute has been removed and
+ * reset the direction of any of its ancestors which have dir=auto and whose
+ * directionality is determined by a text node descendant.
+ */
 void
 WalkAncestorsResetAutoDirection(Element* aElement, bool aNotify)
 {
   nsINode* setByNode;
   Element* parent = aElement->GetElementParent();
 
   while (parent && parent->NodeOrAncestorHasDirAuto()) {
     if (parent->HasDirAutoSet()) {
@@ -888,10 +889,48 @@ OnSetDirAttr(Element* aElement, const ns
     WalkDescendantsSetDirAuto(aElement, aNotify);
   } else {
     SetDirectionalityOnDescendants(aElement,
                                    RecomputeDirectionality(aElement, aNotify),
                                    aNotify);
   }
 }
 
+void
+SetDirOnBind(mozilla::dom::Element* aElement, nsIContent* aParent)
+{
+  // Set the AncestorHasDirAuto flag, unless this element shouldn't affect
+  // ancestors that have dir=auto
+  if (!DoesNotParticipateInAutoDirection(aElement) &&
+      !aElement->IsHTML(nsGkAtoms::bdi) &&
+      aParent && aParent->NodeOrAncestorHasDirAuto()) {
+    aElement->SetAncestorHasDirAuto();
+
+    // if we are binding an element to the tree that already has descendants,
+    // and the parent has NodeHasDirAuto or NodeAncestorHasDirAuto, we may
+    // need to reset the direction of an ancestor with dir=auto
+    if (aElement->GetFirstChild()) {
+      WalkAncestorsResetAutoDirection(aElement, true);
+    }
+  }
+
+  if (!aElement->HasDirAuto()) {
+    // if the element doesn't have dir=auto, set its own directionality from
+    // the dir attribute or by inheriting from its ancestors.
+    RecomputeDirectionality(aElement, false);
+  }
+}
+
+void ResetDir(mozilla::dom::Element* aElement)
+{
+  if (aElement->HasDirAutoSet()) {
+    nsINode* setByNode =
+      static_cast<nsINode*>(aElement->GetProperty(nsGkAtoms::dirAutoSetBy));
+    nsTextNodeDirectionalityMap::RemoveElementFromMap(setByNode, aElement);
+  }
+
+  if (!aElement->HasDirAuto()) {
+    RecomputeDirectionality(aElement, false);
+  }
+}
+
 } // end namespace mozilla
 
--- a/content/base/src/Element.cpp
+++ b/content/base/src/Element.cpp
@@ -1155,35 +1155,21 @@ Element::BindToTree(nsIDocument* aDocume
                NODE_NEEDS_FRAME | NODE_DESCENDANTS_NEED_FRAMES |
                // And the restyle bits
                ELEMENT_ALL_RESTYLE_FLAGS);
   } else {
     // If we're not in the doc, update our subtree pointer.
     SetSubtreeRootPointer(aParent->SubtreeRoot());
   }
 
-  // This has to be here, rather than in nsGenericHTMLElement::BindToTree, 
+  // This has to be here, rather than in nsGenericHTMLElement::BindToTree,
   //  because it has to happen after updating the parent pointer, but before
   //  recursively binding the kids.
   if (IsHTML()) {
-    if (aParent && aParent->NodeOrAncestorHasDirAuto()) {
-      SetAncestorHasDirAuto();
-      // if we are binding an element to the tree that already has descendants,
-      // and the parent has NodeHasDirAuto or NodeAncestorHasDirAuto, we may
-      // need to reset the direction of an ancestor with dir=auto
-      if (GetFirstChild()) {
-        WalkAncestorsResetAutoDirection(this);
-      }
-    }
-
-    if (!HasDirAuto()) {
-      // if the element doesn't have dir=auto, set its directionality from
-      // the dir attribute or by inheriting from its ancestors.
-      RecomputeDirectionality(this, false);
-    }
+    SetDirOnBind(this, aParent);
   }
 
   // If NODE_FORCE_XBL_BINDINGS was set we might have anonymous children
   // that also need to be told that they are moving.
   nsresult rv;
   if (hadForceXBL) {
     nsBindingManager* bmgr = OwnerDoc()->BindingManager();
 
@@ -1364,18 +1350,18 @@ Element::UnbindFromTree(bool aDeep, bool
     if (slots) {
       slots->mBindingParent = nullptr;
     }
   }
 
   // This has to be here, rather than in nsGenericHTMLElement::UnbindFromTree, 
   //  because it has to happen after unsetting the parent pointer, but before
   //  recursively unbinding the kids.
-  if (IsHTML() && !HasDirAuto()) {
-    RecomputeDirectionality(this, false);
+  if (IsHTML()) {
+    ResetDir(this);
   }
 
   if (aDeep) {
     // Do the kids. Don't call GetChildCount() here since that'll force
     // XUL to generate template children, which there is no need for since
     // all we're going to do is unbind them anyway.
     uint32_t i, n = mAttrsAndChildren.ChildCount();
 
--- a/content/base/src/nsFrameLoader.cpp
+++ b/content/base/src/nsFrameLoader.cpp
@@ -52,16 +52,17 @@
 #include "nsISHistory.h"
 #include "nsISHistoryInternal.h"
 #include "nsIDocShellHistory.h"
 #include "nsIDOMHTMLDocument.h"
 #include "nsIXULWindow.h"
 #include "nsIEditor.h"
 #include "nsIEditorDocShell.h"
 #include "nsIMozBrowserFrame.h"
+#include "nsIPermissionManager.h"
 
 #include "nsLayoutUtils.h"
 #include "nsView.h"
 #include "nsAsyncDOMEvent.h"
 
 #include "nsIURI.h"
 #include "nsIURL.h"
 #include "nsNetUtil.h"
@@ -277,16 +278,17 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsFrame
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFrameLoader)
   NS_INTERFACE_MAP_ENTRY(nsIFrameLoader)
   NS_INTERFACE_MAP_ENTRY(nsIContentViewManager)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIFrameLoader)
 NS_INTERFACE_MAP_END
 
 nsFrameLoader::nsFrameLoader(Element* aOwner, bool aNetworkCreated)
   : mOwnerContent(aOwner)
+  , mAppIdSentToPermissionManager(nsIScriptSecurityManager::NO_APP_ID)
   , mDetachedSubdocViews(nullptr)
   , mDepthTooGreat(false)
   , mIsTopLevelContent(false)
   , mDestroyCalled(false)
   , mNeedsAsyncDestroy(false)
   , mInSwap(false)
   , mInShow(false)
   , mHideCalled(false)
@@ -298,16 +300,17 @@ nsFrameLoader::nsFrameLoader(Element* aO
   , mClampScrollPosition(true)
   , mRemoteBrowserInitialized(false)
   , mObservingOwnerContent(false)
   , mCurrentRemoteFrame(nullptr)
   , mRemoteBrowser(nullptr)
   , mRenderMode(RENDER_MODE_DEFAULT)
   , mEventMode(EVENT_MODE_NORMAL_DISPATCH)
 {
+  ResetPermissionManagerStatus();
 }
 
 nsFrameLoader*
 nsFrameLoader::Create(Element* aOwner, bool aNetworkCreated)
 {
   NS_ENSURE_TRUE(aOwner, nullptr);
   nsIDocument* doc = aOwner->OwnerDoc();
   NS_ENSURE_TRUE(!doc->GetDisplayDocument() &&
@@ -1399,16 +1402,18 @@ nsFrameLoader::SetOwnerContent(Element* 
   if (mObservingOwnerContent) {
     mObservingOwnerContent = false;
     mOwnerContent->RemoveMutationObserver(this);
   }
   mOwnerContent = aContent;
   if (RenderFrameParent* rfp = GetCurrentRemoteFrame()) {
     rfp->OwnerContentChanged(aContent);
   }
+
+  ResetPermissionManagerStatus();
 }
 
 bool
 nsFrameLoader::OwnerIsBrowserOrAppFrame()
 {
   nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwnerContent);
   return browserFrame ? browserFrame->GetReallyIsBrowserOrApp() : false;
 }
@@ -2536,8 +2541,64 @@ nsFrameLoader::AttributeChanged(nsIDocum
                        nsCaseInsensitiveStringComparator())) {
     bool is_targetable = is_primary ||
       value.LowerCaseEqualsLiteral("content-targetable");
 
     parentTreeOwner->ContentShellAdded(docShellAsItem, is_primary,
                                        is_targetable, value);
   }
 }
+
+void
+nsFrameLoader::ResetPermissionManagerStatus()
+{
+  // Finding the new app Id:
+  // . first we check if the owner is an app frame
+  // . second, we check if the owner is a browser frame
+  // in both cases we populate the appId variable.
+  uint32_t appId = nsIScriptSecurityManager::NO_APP_ID;
+  if (OwnerIsAppFrame()) {
+    // You can't be both an app and a browser frame.
+    MOZ_ASSERT(!OwnerIsBrowserFrame());
+
+    nsCOMPtr<mozIApplication> ownApp = GetOwnApp();
+    MOZ_ASSERT(ownApp);
+    uint32_t ownAppId = nsIScriptSecurityManager::NO_APP_ID;
+    if (ownApp && NS_SUCCEEDED(ownApp->GetLocalId(&ownAppId))) {
+      appId = ownAppId;
+    }
+  }
+
+  if (OwnerIsBrowserFrame()) {
+    // You can't be both a browser and an app frame.
+    MOZ_ASSERT(!OwnerIsAppFrame());
+
+    nsCOMPtr<mozIApplication> containingApp = GetContainingApp();
+    uint32_t containingAppId = nsIScriptSecurityManager::NO_APP_ID;
+    if (containingApp && NS_SUCCEEDED(containingApp->GetLocalId(&containingAppId))) {
+      appId = containingAppId;
+    }
+  }
+
+  // Nothing changed.
+  if (appId == mAppIdSentToPermissionManager) {
+    return;
+  }
+
+  nsCOMPtr<nsIPermissionManager> permMgr = do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
+  if (!permMgr) {
+    NS_ERROR("No PermissionManager available!");
+    return;
+  }
+
+  // If previously we registered an appId, we have to unregister it.
+  if (mAppIdSentToPermissionManager != nsIScriptSecurityManager::NO_APP_ID) {
+    permMgr->ReleaseAppId(mAppIdSentToPermissionManager);
+    mAppIdSentToPermissionManager = nsIScriptSecurityManager::NO_APP_ID;
+  }
+
+  // Register the new AppId.
+  if (appId != nsIScriptSecurityManager::NO_APP_ID) {
+    mAppIdSentToPermissionManager = appId;
+    permMgr->AddrefAppId(mAppIdSentToPermissionManager);
+  }
+}
+
--- a/content/base/src/nsFrameLoader.h
+++ b/content/base/src/nsFrameLoader.h
@@ -376,20 +376,27 @@ private:
                               nsIDocShellTreeOwner* aOwner,
                               int32_t aParentType,
                               nsIDocShellTreeNode* aParentNode);
 
   nsIAtom* TypeAttrName() const {
     return mOwnerContent->IsXUL() ? nsGkAtoms::type : nsGkAtoms::mozframetype;
   }
 
+  // Update the permission manager's app-id refcount based on mOwnerContent's
+  // own-or-containing-app.
+  void ResetPermissionManagerStatus();
+
   nsCOMPtr<nsIDocShell> mDocShell;
   nsCOMPtr<nsIURI> mURIToLoad;
   mozilla::dom::Element* mOwnerContent; // WEAK
 
+  // Note: this variable must be modified only by ResetPermissionManagerStatus()
+  uint32_t mAppIdSentToPermissionManager;
+
 public:
   // public because a callback needs these.
   nsRefPtr<nsFrameMessageManager> mMessageManager;
   nsCOMPtr<nsIInProcessContentFrameMessageManager> mChildMessageManager;
 private:
   // Stores the root view of the subdocument while the subdocument is being
   // reframed. Used to restore the presentation after reframing.
   nsView* mDetachedSubdocViews;
--- a/content/canvas/compiledtest/TestWebGLElementArrayCache.cpp
+++ b/content/canvas/compiledtest/TestWebGLElementArrayCache.cpp
@@ -110,16 +110,23 @@ void CheckSanity()
     data[i] = numElems - i;
   c.BufferData(data, numBytes);
   VERIFY( c.Validate(type, numElems,     0, numElems));
   VERIFY(!c.Validate(type, numElems - 1, 0, numElems));
 
   MOZ_ASSERT(numElems > 10);
   VERIFY( c.Validate(type, numElems - 10, 10, numElems - 10));
   VERIFY(!c.Validate(type, numElems - 11, 10, numElems - 10));
+
+  // bug 825205
+  if (sizeof(T) < sizeof(uint32_t)) {
+    uint32_t bigValWrappingToZero = uint32_t(T(-1)) + 1;
+    VERIFY(c.Validate(type, bigValWrappingToZero,     0, numElems));
+    VERIFY(c.Validate(type, bigValWrappingToZero - 1, 0, numElems));
+  }
 }
 
 int main(int argc, char *argv[])
 {
   srand(0); // do not want a random seed here.
 
   CheckSanity<uint8_t>();
   CheckSanity<uint16_t>();
--- a/content/canvas/src/WebGLElementArrayCache.cpp
+++ b/content/canvas/src/WebGLElementArrayCache.cpp
@@ -5,16 +5,17 @@
 
 #include "WebGLElementArrayCache.h"
 
 #include "nsTArray.h"
 #include "mozilla/Assertions.h"
 
 #include <cstdlib>
 #include <cstring>
+#include <limits>
 
 namespace mozilla {
 
 /*
  * WebGLElementArrayCacheTree contains most of the implementation of WebGLElementArrayCache,
  * which performs WebGL element array buffer validation for drawElements.
  *
  * Attention: Here lie nontrivial data structures, bug-prone algorithms, and non-canonical tweaks!
@@ -470,70 +471,80 @@ void WebGLElementArrayCache::InvalidateT
 {
   if (mUint8Tree)
     mUint8Tree->Invalidate(firstByte, lastByte);
   if (mUint16Tree)
     mUint16Tree->Invalidate(firstByte, lastByte);
 }
 
 template<typename T>
-bool WebGLElementArrayCache::Validate(T maxAllowed, size_t firstElement, size_t countElements) {
+bool WebGLElementArrayCache::Validate(uint32_t maxAllowed, size_t firstElement, size_t countElements) {
+  // if maxAllowed is >= the max T value, then there is no way that a T index could be invalid
+  if (maxAllowed >= std::numeric_limits<T>::max())
+    return true;
+
+  T maxAllowedT(maxAllowed);
+
+  // integer overflow must have been handled earlier, so we assert that maxAllowedT
+  // is exactly the max allowed value.
+  MOZ_ASSERT(uint32_t(maxAllowedT) == maxAllowed);
+
   if (!mByteSize || !countElements)
     return true;
 
   WebGLElementArrayCacheTree<T>*& tree = TreeForType<T>::Run(this);
   if (!tree) {
     tree = new WebGLElementArrayCacheTree<T>(*this);
   }
 
   size_t lastElement = firstElement + countElements - 1;
 
   tree->Update();
 
   // fast exit path when the global maximum for the whole element array buffer
   // falls in the allowed range
-  if (tree->GlobalMaximum() <= maxAllowed)
+  if (tree->GlobalMaximum() <= maxAllowedT)
   {
     return true;
   }
 
   const T* elements = Elements<T>();
 
   // before calling tree->Validate, we have to validate ourselves the boundaries of the elements span,
   // to round them to the nearest multiple of sElementsPerLeaf.
   size_t firstElementAdjustmentEnd = NS_MIN(lastElement,
                                             tree->LastElementUnderSameLeaf(firstElement));
   while (firstElement <= firstElementAdjustmentEnd) {
-    if (elements[firstElement] > maxAllowed)
+    if (elements[firstElement] > maxAllowedT)
       return false;
     firstElement++;
   }
   size_t lastElementAdjustmentEnd = NS_MAX(firstElement,
                                            tree->FirstElementUnderSameLeaf(lastElement));
   while (lastElement >= lastElementAdjustmentEnd) {
-    if (elements[lastElement] > maxAllowed)
+    if (elements[lastElement] > maxAllowedT)
       return false;
     lastElement--;
   }
 
   // at this point, for many tiny validations, we're already done.
   if (firstElement > lastElement)
     return true;
 
   // general case
-  return tree->Validate(maxAllowed,
+  return tree->Validate(maxAllowedT,
                         tree->LeafForElement(firstElement),
                         tree->LeafForElement(lastElement));
 }
 
 bool WebGLElementArrayCache::Validate(GLenum type, uint32_t maxAllowed, size_t firstElement, size_t countElements) {
   if (type == LOCAL_GL_UNSIGNED_BYTE)
-    return Validate<uint8_t>(uint8_t(maxAllowed), firstElement, countElements);
+    return Validate<uint8_t>(maxAllowed, firstElement, countElements);
   if (type == LOCAL_GL_UNSIGNED_SHORT)
-    return Validate<uint16_t>(uint16_t(maxAllowed), firstElement, countElements);
+    return Validate<uint16_t>(maxAllowed, firstElement, countElements);
   return false;
 }
 
 size_t WebGLElementArrayCache::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const {
   size_t uint8TreeSize  = mUint8Tree  ? mUint8Tree->SizeOfIncludingThis(aMallocSizeOf) : 0;
   size_t uint16TreeSize = mUint16Tree ? mUint16Tree->SizeOfIncludingThis(aMallocSizeOf) : 0;
   return aMallocSizeOf(this) +
           mByteSize +
--- a/content/canvas/src/WebGLElementArrayCache.h
+++ b/content/canvas/src/WebGLElementArrayCache.h
@@ -46,17 +46,17 @@ public:
 
   ~WebGLElementArrayCache();
 
   size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
 
 private:
 
   template<typename T>
-  bool Validate(T maxAllowed, size_t first, size_t count);
+  bool Validate(uint32_t maxAllowed, size_t first, size_t count);
 
   size_t ByteSize() const {
     return mByteSize;
   }
 
   template<typename T>
   const T* Elements() const { return static_cast<const T*>(mUntypedData); }
   template<typename T>
--- a/content/smil/Makefile.in
+++ b/content/smil/Makefile.in
@@ -17,23 +17,35 @@ ifndef _MSC_VER
 FAIL_ON_WARNINGS = 1
 endif # !_MSC_VER
 
 EXPORTS	= \
 	nsISMILAnimationElement.h \
 	nsISMILAttr.h \
 	nsISMILType.h \
 	nsSMILAnimationController.h \
+	nsSMILAnimationFunction.h \
 	nsSMILCompositorTable.h \
 	nsSMILCSSProperty.h \
+	nsSMILInstanceTime.h \
+	nsSMILInterval.h \
 	nsSMILKeySpline.h \
 	nsSMILMappedAttribute.h \
 	nsSMILMilestone.h \
+	nsSMILNullType.h \
+	nsSMILRepeatCount.h \
+	nsSMILSetAnimationFunction.h \
+	nsSMILTargetIdentifier.h \
 	nsSMILTimeContainer.h \
+	nsSMILTimedElement.h \
+	nsSMILTimeValue.h \
+	nsSMILTimeValueSpec.h \
+	nsSMILTimeValueSpecParams.h \
 	nsSMILTypes.h \
+	nsSMILValue.h \
 	$(NULL)
 
 CPPSRCS	= \
 	nsDOMTimeEvent.cpp \
 	nsSMILAnimationController.cpp \
 	nsSMILAnimationFunction.cpp \
 	nsSMILCompositor.cpp \
 	nsSMILCSSProperty.cpp \
--- a/content/svg/content/src/DOMSVGTests.cpp
+++ b/content/svg/content/src/DOMSVGTests.cpp
@@ -1,17 +1,17 @@
 /* -*- 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 "DOMSVGTests.h"
 #include "DOMSVGStringList.h"
 #include "nsSVGFeatures.h"
-#include "nsSVGSwitchElement.h"
+#include "mozilla/dom/SVGSwitchElement.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsStyleUtil.h"
 #include "mozilla/Preferences.h"
 
 using namespace mozilla;
 
 NS_IMPL_ISUPPORTS1(DOMSVGTests, nsIDOMSVGTests)
 
@@ -26,51 +26,75 @@ DOMSVGTests::DOMSVGTests()
 {
   mStringListAttributes[LANGUAGE].SetIsCommaSeparated(true);
 }
 
 /* readonly attribute nsIDOMSVGStringList requiredFeatures; */
 NS_IMETHODIMP
 DOMSVGTests::GetRequiredFeatures(nsIDOMSVGStringList * *aRequiredFeatures)
 {
+  *aRequiredFeatures = RequiredFeatures().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGStringList>
+DOMSVGTests::RequiredFeatures()
+{
   nsCOMPtr<nsSVGElement> element = do_QueryInterface(this);
-  *aRequiredFeatures = DOMSVGStringList::GetDOMWrapper(
-                         &mStringListAttributes[FEATURES], element, true, FEATURES).get();
-  return NS_OK;
+  return DOMSVGStringList::GetDOMWrapper(
+           &mStringListAttributes[FEATURES], element, true, FEATURES).get();
 }
 
 /* readonly attribute nsIDOMSVGStringList requiredExtensions; */
 NS_IMETHODIMP
 DOMSVGTests::GetRequiredExtensions(nsIDOMSVGStringList * *aRequiredExtensions)
 {
+  *aRequiredExtensions = RequiredExtensions().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGStringList>
+DOMSVGTests::RequiredExtensions()
+{
   nsCOMPtr<nsSVGElement> element = do_QueryInterface(this);
-  *aRequiredExtensions = DOMSVGStringList::GetDOMWrapper(
-                           &mStringListAttributes[EXTENSIONS], element, true, EXTENSIONS).get();
-  return NS_OK;
+  return DOMSVGStringList::GetDOMWrapper(
+           &mStringListAttributes[EXTENSIONS], element, true, EXTENSIONS).get();
 }
 
 /* readonly attribute nsIDOMSVGStringList systemLanguage; */
 NS_IMETHODIMP
 DOMSVGTests::GetSystemLanguage(nsIDOMSVGStringList * *aSystemLanguage)
 {
+  *aSystemLanguage = SystemLanguage().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGStringList>
+DOMSVGTests::SystemLanguage()
+{
   nsCOMPtr<nsSVGElement> element = do_QueryInterface(this);
-  *aSystemLanguage = DOMSVGStringList::GetDOMWrapper(
-                       &mStringListAttributes[LANGUAGE], element, true, LANGUAGE).get();
-  return NS_OK;
+  return DOMSVGStringList::GetDOMWrapper(
+           &mStringListAttributes[LANGUAGE], element, true, LANGUAGE).get();
 }
 
 /* boolean hasExtension (in DOMString extension); */
 NS_IMETHODIMP
 DOMSVGTests::HasExtension(const nsAString & extension, bool *_retval)
 {
-  *_retval = nsSVGFeatures::HasExtension(extension);
+  *_retval = HasExtension(extension);
   return NS_OK;
 }
 
 bool
+DOMSVGTests::HasExtension(const nsAString& aExtension)
+{
+  return nsSVGFeatures::HasExtension(aExtension);
+}
+
+bool
 DOMSVGTests::IsConditionalProcessingAttribute(const nsIAtom* aAttribute) const
 {
   for (uint32_t i = 0; i < ArrayLength(sStringListNames); i++) {
     if (aAttribute == *sStringListNames[i]) {
       return true;
     }
   }
   return false;
@@ -237,11 +261,11 @@ void
 DOMSVGTests::MaybeInvalidate()
 {
   nsCOMPtr<nsSVGElement> element = do_QueryInterface(this);
 
   nsIContent* parent = element->GetFlattenedTreeParent();
 
   if (parent &&
       parent->NodeInfo()->Equals(nsGkAtoms::svgSwitch, kNameSpaceID_SVG)) {
-    static_cast<nsSVGSwitchElement*>(parent)->MaybeInvalidate();
+    static_cast<dom::SVGSwitchElement*>(parent)->MaybeInvalidate();
   }
 }
--- a/content/svg/content/src/DOMSVGTests.h
+++ b/content/svg/content/src/DOMSVGTests.h
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_DOMSVGTESTS_H__
 #define MOZILLA_DOMSVGTESTS_H__
 
 #include "nsIDOMSVGTests.h"
 #include "nsStringFwd.h"
 #include "SVGStringList.h"
+#include "nsCOMPtr.h"
 
 class nsAttrValue;
 class nsIAtom;
 class nsString;
 
 namespace mozilla {
 class DOMSVGStringList;
 }
@@ -79,15 +80,21 @@ public:
    */
   void UnsetAttr(const nsIAtom* aAttribute);
 
   nsIAtom* GetAttrName(uint8_t aAttrEnum) const;
   void GetAttrValue(uint8_t aAttrEnum, nsAttrValue &aValue) const;
 
   void MaybeInvalidate();
 
+  // WebIDL
+  already_AddRefed<nsIDOMSVGStringList> RequiredFeatures();
+  already_AddRefed<nsIDOMSVGStringList> RequiredExtensions();
+  already_AddRefed<nsIDOMSVGStringList> SystemLanguage();
+  bool HasExtension(const nsAString& aExtension);
+
 private:
   enum { FEATURES, EXTENSIONS, LANGUAGE };
   SVGStringList mStringListAttributes[3];
   static nsIAtom** sStringListNames[3];
 };
 
 #endif // MOZILLA_DOMSVGTESTS_H__
--- a/content/svg/content/src/Makefile.in
+++ b/content/svg/content/src/Makefile.in
@@ -35,53 +35,41 @@ CPPSRCS		= \
 		DOMSVGTransform.cpp \
 		DOMSVGTransformList.cpp \
 		nsDOMSVGZoomEvent.cpp \
 		nsDOMSVGEvent.cpp \
 		nsSVGAElement.cpp \
 		nsSVGAltGlyphElement.cpp \
 		nsSVGAngle.cpp \
 		nsSVGBoolean.cpp \
-		nsSVGCircleElement.cpp \
 		nsSVGClass.cpp \
 		nsSVGClipPathElement.cpp \
 		nsSVGDataParser.cpp \
-		nsSVGDefsElement.cpp \
 		nsSVGElement.cpp \
 		nsSVGElementFactory.cpp \
-		nsSVGEllipseElement.cpp \
 		nsSVGEnum.cpp \
 		nsSVGFeatures.cpp \
 		nsSVGFilterElement.cpp \
 		nsSVGFilters.cpp \
-		nsSVGForeignObjectElement.cpp \
-		nsSVGGElement.cpp \
 		nsSVGGradientElement.cpp \
-		nsSVGGraphicElement.cpp \
-		nsSVGImageElement.cpp \
 		nsSVGInteger.cpp \
 		nsSVGIntegerPair.cpp \
 		nsSVGLength2.cpp \
-		nsSVGLineElement.cpp \
 		nsSVGMarkerElement.cpp \
 		nsSVGMaskElement.cpp \
 		nsSVGNumber2.cpp \
 		nsSVGNumberPair.cpp \
 		nsSVGPathDataParser.cpp \
 		nsSVGPathElement.cpp \
 		nsSVGPathGeometryElement.cpp \
 		nsSVGPatternElement.cpp \
 		nsSVGPolyElement.cpp \
-		nsSVGPolygonElement.cpp \
-		nsSVGPolylineElement.cpp \
 		nsSVGString.cpp \
 		nsSVGRect.cpp \
-		nsSVGRectElement.cpp \
 		nsSVGSVGElement.cpp \
-		nsSVGSwitchElement.cpp \
 		nsSVGSymbolElement.cpp \
 		nsSVGTSpanElement.cpp \
 		nsSVGTextContentElement.cpp \
 		nsSVGTextElement.cpp \
 		nsSVGTextPathElement.cpp \
 		nsSVGTextPositioningElement.cpp \
 		nsSVGUnknownElement.cpp \
 		nsSVGUseElement.cpp \
@@ -91,53 +79,67 @@ CPPSRCS		= \
 		SVGAnimatedAngle.cpp \
 		SVGAnimatedBoolean.cpp \
 		SVGAnimatedLengthList.cpp \
 		SVGAnimatedNumberList.cpp \
 		SVGAnimatedPathSegList.cpp \
 		SVGAnimatedPointList.cpp \
 		SVGAnimatedPreserveAspectRatio.cpp \
 		SVGAnimatedTransformList.cpp \
+		SVGAnimateElement.cpp \
+		SVGAnimateTransformElement.cpp \
+		SVGAnimateMotionElement.cpp \
+		SVGAnimationElement.cpp \
+		SVGAttrValueWrapper.cpp \
+		SVGCircleElement.cpp \
+		SVGContentUtils.cpp \
+		SVGDefsElement.cpp \
+		SVGDescElement.cpp \
+		SVGEllipseElement.cpp \
+		SVGForeignObjectElement.cpp \
 		SVGFragmentIdentifier.cpp \
+		SVGGElement.cpp \
+		SVGGraphicsElement.cpp \
+		SVGImageElement.cpp \
+		SVGIntegerPairSMILType.cpp \
 		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 \
-		nsSVGSetElement.cpp \
-		SVGAttrValueWrapper.cpp \
-		SVGContentUtils.cpp \
-		SVGDescElement.cpp \
-		SVGIntegerPairSMILType.cpp \
 		SVGLengthListSMILType.cpp \
+		SVGLineElement.cpp \
+		SVGLocatableElement.cpp \
 		SVGMetadataElement.cpp \
 		SVGMotionSMILType.cpp \
 		SVGMotionSMILAttr.cpp \
 		SVGMotionSMILAnimationFunction.cpp \
 		SVGMotionSMILPathUtils.cpp \
 		SVGMPathElement.cpp \
+		SVGNumberList.cpp \
 		SVGNumberListSMILType.cpp \
 		SVGNumberPairSMILType.cpp \
 		SVGOrientSMILType.cpp \
+		SVGPathData.cpp \
+		SVGPathSegUtils.cpp \
 		SVGPathSegListSMILType.cpp \
+		SVGPointList.cpp \
 		SVGPointListSMILType.cpp \
+		SVGPolygonElement.cpp \
+		SVGPolylineElement.cpp \
+		SVGPreserveAspectRatio.cpp \
+		SVGRectElement.cpp \
 		SVGScriptElement.cpp \
+		SVGSetElement.cpp \
 		SVGStopElement.cpp \
+		SVGStringList.cpp \
 		SVGStyleElement.cpp \
+		SVGSwitchElement.cpp \
+		SVGTitleElement.cpp \
+		SVGTransform.cpp \
+		SVGTransformableElement.cpp \
+		SVGTransformList.cpp \
+		SVGTransformListParser.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
@@ -149,23 +151,42 @@ EXPORTS =  			\
 	$(NULL)
 
 EXPORTS_NAMESPACES = mozilla/dom
 
 EXPORTS_mozilla/dom = \
 	SVGAngle.h \
 	SVGAnimatedAngle.h \
 	SVGAnimatedBoolean.h \
+	SVGAnimateElement.h \
+	SVGAnimateTransformElement.h \
+	SVGAnimateMotionElement.h \
+	SVGAnimationElement.h \
+	SVGCircleElement.h \
+	SVGDefsElement.h \
 	SVGDescElement.h \
+	SVGEllipseElement.h \
+	SVGForeignObjectElement.h \
+	SVGGElement.h \
+	SVGGraphicsElement.h \
+	SVGImageElement.h \
+	SVGLineElement.h \
+	SVGLocatableElement.h \
 	SVGMetadataElement.h \
 	SVGMPathElement.h \
+	SVGPolygonElement.h \
+	SVGPolylineElement.h \
+	SVGRectElement.h \
 	SVGScriptElement.h \
+	SVGSetElement.h \
 	SVGStopElement.h \
 	SVGStyleElement.h \
+	SVGSwitchElement.h \
 	SVGTitleElement.h \
+	SVGTransformableElement.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/nsSVGAnimateElement.cpp
rename to content/svg/content/src/SVGAnimateElement.cpp
--- a/content/svg/content/src/nsSVGAnimateElement.cpp
+++ b/content/svg/content/src/SVGAnimateElement.cpp
@@ -1,80 +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/. */
 
-#include "nsSVGAnimationElement.h"
-#include "nsIDOMSVGAnimateElement.h"
-#include "nsSMILAnimationFunction.h"
-
-typedef nsSVGAnimationElement nsSVGAnimateElementBase;
+#include "mozilla/dom/SVGAnimateElement.h"
+#include "mozilla/dom/SVGAnimateElementBinding.h"
 
-class nsSVGAnimateElement : public nsSVGAnimateElementBase,
-                            public nsIDOMSVGAnimateElement
-{
-protected:
-  friend nsresult NS_NewSVGAnimateElement(nsIContent **aResult,
-                                          already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGAnimateElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+DOMCI_NODE_DATA(SVGAnimateElement, mozilla::dom::SVGAnimateElement)
 
-  nsSMILAnimationFunction mAnimationFunction;
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Animate)
 
-public:
-  // interfaces:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMSVGANIMATEELEMENT
+namespace mozilla {
+namespace dom {
 
-  NS_FORWARD_NSIDOMNODE_TO_NSINODE
-  NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGAnimateElementBase::)
-  NS_FORWARD_NSIDOMSVGANIMATIONELEMENT(nsSVGAnimateElementBase::)
-  
-  // nsIDOMNode
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
-
-  // nsISMILAnimationElement
-  virtual nsSMILAnimationFunction& AnimationFunction();
-
-  virtual nsXPCClassInfo* GetClassInfo();
-
-  virtual nsIDOMNode* AsDOMNode() { return this; }
-};
-
-NS_IMPL_NS_NEW_SVG_ELEMENT(Animate)
+JSObject*
+SVGAnimateElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return SVGAnimateElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGAnimateElement,nsSVGAnimateElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGAnimateElement,nsSVGAnimateElementBase)
 
-DOMCI_NODE_DATA(SVGAnimateElement, nsSVGAnimateElement)
+NS_IMPL_ADDREF_INHERITED(SVGAnimateElement, SVGAnimationElement)
+NS_IMPL_RELEASE_INHERITED(SVGAnimateElement, SVGAnimationElement)
 
-NS_INTERFACE_TABLE_HEAD(nsSVGAnimateElement)
-  NS_NODE_INTERFACE_TABLE6(nsSVGAnimateElement, nsIDOMNode, nsIDOMElement,
+NS_INTERFACE_TABLE_HEAD(SVGAnimateElement)
+  NS_NODE_INTERFACE_TABLE5(SVGAnimateElement, nsIDOMNode, nsIDOMElement,
                            nsIDOMSVGElement, nsIDOMSVGAnimationElement,
-                           nsIDOMSVGTests, nsIDOMSVGAnimateElement)
+                           nsIDOMSVGAnimateElement)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimateElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGAnimateElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGAnimationElement)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGAnimateElement::nsSVGAnimateElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGAnimateElementBase(aNodeInfo)
+SVGAnimateElement::SVGAnimateElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGAnimationElement(aNodeInfo)
 {
 }
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGAnimateElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGAnimateElement)
 
 //----------------------------------------------------------------------
 // nsISMILAnimationElement methods
 
 nsSMILAnimationFunction&
-nsSVGAnimateElement::AnimationFunction()
+SVGAnimateElement::AnimationFunction()
 {
   return mAnimationFunction;
 }
+
+} // namespace mozilla
+} // namespace dom
+
copy from content/svg/content/src/nsSVGAnimateElement.cpp
copy to content/svg/content/src/SVGAnimateElement.h
--- a/content/svg/content/src/nsSVGAnimateElement.cpp
+++ b/content/svg/content/src/SVGAnimateElement.h
@@ -1,80 +1,56 @@
 /* -*- 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 "nsSVGAnimationElement.h"
+#ifndef mozilla_dom_SVGAnimateElement_h
+#define mozilla_dom_SVGAnimateElement_h
+
+#include "mozilla/dom/SVGAnimationElement.h"
 #include "nsIDOMSVGAnimateElement.h"
 #include "nsSMILAnimationFunction.h"
 
-typedef nsSVGAnimationElement nsSVGAnimateElementBase;
+nsresult NS_NewSVGAnimateElement(nsIContent **aResult,
+                                 already_AddRefed<nsINodeInfo> aNodeInfo);
 
-class nsSVGAnimateElement : public nsSVGAnimateElementBase,
-                            public nsIDOMSVGAnimateElement
+namespace mozilla {
+namespace dom {
+
+class SVGAnimateElement MOZ_FINAL : public SVGAnimationElement,
+                                    public nsIDOMSVGAnimateElement
 {
 protected:
-  friend nsresult NS_NewSVGAnimateElement(nsIContent **aResult,
-                                          already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGAnimateElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  SVGAnimateElement(already_AddRefed<nsINodeInfo> aNodeInfo);
 
   nsSMILAnimationFunction mAnimationFunction;
+  friend nsresult
+    (::NS_NewSVGAnimateElement(nsIContent **aResult,
+                               already_AddRefed<nsINodeInfo> aNodeInfo));
+
+  virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
 
 public:
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMSVGANIMATEELEMENT
 
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGAnimateElementBase::)
-  NS_FORWARD_NSIDOMSVGANIMATIONELEMENT(nsSVGAnimateElementBase::)
-  
+  NS_FORWARD_NSIDOMSVGELEMENT(SVGAnimationElement::)
+  NS_FORWARD_NSIDOMSVGANIMATIONELEMENT(SVGAnimationElement::)
+
   // nsIDOMNode
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   // nsISMILAnimationElement
   virtual nsSMILAnimationFunction& AnimationFunction();
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
 };
 
-NS_IMPL_NS_NEW_SVG_ELEMENT(Animate)
-
-//----------------------------------------------------------------------
-// nsISupports methods
-
-NS_IMPL_ADDREF_INHERITED(nsSVGAnimateElement,nsSVGAnimateElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGAnimateElement,nsSVGAnimateElementBase)
-
-DOMCI_NODE_DATA(SVGAnimateElement, nsSVGAnimateElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGAnimateElement)
-  NS_NODE_INTERFACE_TABLE6(nsSVGAnimateElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGAnimationElement,
-                           nsIDOMSVGTests, nsIDOMSVGAnimateElement)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimateElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGAnimateElementBase)
+} // namespace dom
+} // namespace mozilla
 
-//----------------------------------------------------------------------
-// Implementation
-
-nsSVGAnimateElement::nsSVGAnimateElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGAnimateElementBase(aNodeInfo)
-{
-}
-
-//----------------------------------------------------------------------
-// nsIDOMNode methods
-
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGAnimateElement)
-
-//----------------------------------------------------------------------
-// nsISMILAnimationElement methods
-
-nsSMILAnimationFunction&
-nsSVGAnimateElement::AnimationFunction()
-{
-  return mAnimationFunction;
-}
+#endif // mozilla_dom_SVGAnimateElement_h
rename from content/svg/content/src/nsSVGAnimateMotionElement.cpp
rename to content/svg/content/src/SVGAnimateMotionElement.cpp
--- a/content/svg/content/src/nsSVGAnimateMotionElement.cpp
+++ b/content/svg/content/src/SVGAnimateMotionElement.cpp
@@ -1,67 +1,81 @@
 /* -*- 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 "nsSVGAnimateMotionElement.h"
+#include "mozilla/dom/SVGAnimateMotionElement.h"
+#include "mozilla/dom/SVGAnimateMotionElementBinding.h"
+
+DOMCI_NODE_DATA(SVGAnimateMotionElement, mozilla::dom::SVGAnimateMotionElement)
+
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(AnimateMotion)
 
-NS_IMPL_NS_NEW_SVG_ELEMENT(AnimateMotion)
+namespace mozilla {
+namespace dom {
+
+JSObject*
+SVGAnimateMotionElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return SVGAnimateMotionElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGAnimateMotionElement,nsSVGAnimateMotionElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGAnimateMotionElement,nsSVGAnimateMotionElementBase)
-
-DOMCI_NODE_DATA(SVGAnimateMotionElement, nsSVGAnimateMotionElement)
+NS_IMPL_ADDREF_INHERITED(SVGAnimateMotionElement, SVGAnimationElement)
+NS_IMPL_RELEASE_INHERITED(SVGAnimateMotionElement, SVGAnimationElement)
 
-NS_INTERFACE_TABLE_HEAD(nsSVGAnimateMotionElement)
-  NS_NODE_INTERFACE_TABLE6(nsSVGAnimateMotionElement, nsIDOMNode,
+NS_INTERFACE_TABLE_HEAD(SVGAnimateMotionElement)
+  NS_NODE_INTERFACE_TABLE5(SVGAnimateMotionElement, nsIDOMNode,
                            nsIDOMElement, nsIDOMSVGElement,
-                           nsIDOMSVGAnimationElement, nsIDOMSVGTests,
+                           nsIDOMSVGAnimationElement,
                            nsIDOMSVGAnimateMotionElement)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimateMotionElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGAnimateMotionElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGAnimationElement)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGAnimateMotionElement::nsSVGAnimateMotionElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGAnimateMotionElementBase(aNodeInfo)
+SVGAnimateMotionElement::SVGAnimateMotionElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGAnimationElement(aNodeInfo)
 {
 }
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGAnimateMotionElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGAnimateMotionElement)
 
 //----------------------------------------------------------------------
 // nsISMILAnimationElement methods
 
 nsSMILAnimationFunction&
-nsSVGAnimateMotionElement::AnimationFunction()
+SVGAnimateMotionElement::AnimationFunction()
 {
   return mAnimationFunction;
 }
 
 bool
-nsSVGAnimateMotionElement::GetTargetAttributeName(int32_t *aNamespaceID,
-                                                  nsIAtom **aLocalName) const
+SVGAnimateMotionElement::GetTargetAttributeName(int32_t *aNamespaceID,
+                                                nsIAtom **aLocalName) const
 {
   // <animateMotion> doesn't take an attributeName, since it doesn't target an
   // 'attribute' per se.  We'll use a unique dummy attribute-name so that our
   // nsSMILTargetIdentifier logic (which requires a attribute name) still works.
   *aNamespaceID = kNameSpaceID_None;
   *aLocalName = nsGkAtoms::mozAnimateMotionDummyAttr;
   return true;
 }
 
 nsSMILTargetAttrType
-nsSVGAnimateMotionElement::GetTargetAttributeType() const
+SVGAnimateMotionElement::GetTargetAttributeType() const
 {
   // <animateMotion> doesn't take an attributeType, since it doesn't target an
   // 'attribute' per se.  We'll just return 'XML' for simplicity.  (This just
   // needs to match what we expect in nsSVGElement::GetAnimAttr.)
   return eSMILTargetAttrType_XML;
 }
+
+} // namespace dom
+} // namespace mozilla
+
rename from content/svg/content/src/nsSVGAnimateMotionElement.h
rename to content/svg/content/src/SVGAnimateMotionElement.h
--- a/content/svg/content/src/nsSVGAnimateMotionElement.h
+++ b/content/svg/content/src/SVGAnimateMotionElement.h
@@ -1,42 +1,48 @@
 /* -*- 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 NS_SVGANIMATEMOTIONELEMENT_H_
-#define NS_SVGANIMATEMOTIONELEMENT_H_
+#ifndef mozilla_dom_SVGAnimateMotionElement_h
+#define mozilla_dom_SVGAnimateMotionElement_h
 
+#include "mozilla/dom/SVGAnimationElement.h"
 #include "nsIDOMSVGAnimateMotionElement.h"
-#include "nsSVGAnimationElement.h"
-#include "nsSVGEnum.h"
 #include "SVGMotionSMILAnimationFunction.h"
 
-typedef nsSVGAnimationElement nsSVGAnimateMotionElementBase;
+nsresult NS_NewSVGAnimateMotionElement(nsIContent **aResult,
+                                       already_AddRefed<nsINodeInfo> aNodeInfo);
 
-class nsSVGAnimateMotionElement : public nsSVGAnimateMotionElementBase,
-                                  public nsIDOMSVGAnimateMotionElement
+namespace mozilla {
+namespace dom {
+
+class SVGAnimateMotionElement MOZ_FINAL : public SVGAnimationElement,
+                                          public nsIDOMSVGAnimateMotionElement
 {
 protected:
-  friend nsresult NS_NewSVGAnimateMotionElement(nsIContent **aResult,
-                                                already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGAnimateMotionElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  SVGAnimateMotionElement(already_AddRefed<nsINodeInfo> aNodeInfo);
 
-  mozilla::SVGMotionSMILAnimationFunction mAnimationFunction;
+  SVGMotionSMILAnimationFunction mAnimationFunction;
+  friend nsresult
+    (::NS_NewSVGAnimateMotionElement(nsIContent **aResult,
+                                     already_AddRefed<nsINodeInfo> aNodeInfo));
+
+  virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
 
 public:
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMSVGANIMATEMOTIONELEMENT
 
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGAnimateMotionElementBase::)
-  NS_FORWARD_NSIDOMSVGANIMATIONELEMENT(nsSVGAnimateMotionElementBase::)
+  NS_FORWARD_NSIDOMSVGELEMENT(SVGAnimationElement::)
+  NS_FORWARD_NSIDOMSVGANIMATIONELEMENT(SVGAnimationElement::)
 
   // nsIDOMNode specializations
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   // nsISMILAnimationElement
   virtual nsSMILAnimationFunction& AnimationFunction();
   virtual bool GetTargetAttributeName(int32_t *aNamespaceID,
                                         nsIAtom **aLocalName) const;
@@ -51,9 +57,12 @@ public:
   // so we can make sure our mAnimationFunction is marked as having changed.
   void MpathChanged() { mAnimationFunction.MpathChanged(); }
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
 };
 
-#endif // NS_SVGANIMATEMOTIONELEMENT_H_
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_SVGAnimateMotionElement_h
rename from content/svg/content/src/nsSVGAnimateTransformElement.cpp
rename to content/svg/content/src/SVGAnimateTransformElement.cpp
--- a/content/svg/content/src/nsSVGAnimateTransformElement.cpp
+++ b/content/svg/content/src/SVGAnimateTransformElement.cpp
@@ -1,132 +1,100 @@
 /* -*- 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 "nsSVGAnimationElement.h"
-#include "nsIDOMSVGAnimateTransformElement.h"
-#include "nsSVGEnum.h"
-#include "nsIDOMSVGTransformable.h"
-#include "nsSMILAnimationFunction.h"
-
-typedef nsSVGAnimationElement nsSVGAnimateTransformElementBase;
+#include "mozilla/dom/SVGAnimateTransformElement.h"
+#include "mozilla/dom/SVGAnimateTransformElementBinding.h"
 
-class nsSVGAnimateTransformElement : public nsSVGAnimateTransformElementBase,
-                                     public nsIDOMSVGAnimateTransformElement
-{
-protected:
-  friend nsresult NS_NewSVGAnimateTransformElement(nsIContent **aResult,
-                                                   already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGAnimateTransformElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+DOMCI_NODE_DATA(SVGAnimateTransformElement, mozilla::dom::SVGAnimateTransformElement)
 
-  nsSMILAnimationFunction mAnimationFunction;
-
-public:
-  // interfaces:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMSVGANIMATETRANSFORMELEMENT
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(AnimateTransform)
 
-  NS_FORWARD_NSIDOMNODE_TO_NSINODE
-  NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGAnimateTransformElementBase::)
-  NS_FORWARD_NSIDOMSVGANIMATIONELEMENT(nsSVGAnimateTransformElementBase::)
-
-  // nsIDOMNode specializations
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
+namespace mozilla {
+namespace dom {
 
-  // Element specializations
-  bool ParseAttribute(int32_t aNamespaceID,
-                        nsIAtom* aAttribute,
-                        const nsAString& aValue,
-                        nsAttrValue& aResult);
-
-  // nsISMILAnimationElement
-  virtual nsSMILAnimationFunction& AnimationFunction();
-  virtual bool GetTargetAttributeName(int32_t *aNamespaceID,
-                                      nsIAtom **aLocalName) const;
-
-  virtual nsXPCClassInfo* GetClassInfo();
-
-  virtual nsIDOMNode* AsDOMNode() { return this; }
-};
-
-NS_IMPL_NS_NEW_SVG_ELEMENT(AnimateTransform)
+JSObject*
+SVGAnimateTransformElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return SVGAnimateTransformElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGAnimateTransformElement,nsSVGAnimateTransformElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGAnimateTransformElement,nsSVGAnimateTransformElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGAnimateTransformElement, SVGAnimationElement)
+NS_IMPL_RELEASE_INHERITED(SVGAnimateTransformElement, SVGAnimationElement)
 
-DOMCI_NODE_DATA(SVGAnimateTransformElement, nsSVGAnimateTransformElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGAnimateTransformElement)
-  NS_NODE_INTERFACE_TABLE6(nsSVGAnimateTransformElement, nsIDOMNode,
+NS_INTERFACE_TABLE_HEAD(SVGAnimateTransformElement)
+  NS_NODE_INTERFACE_TABLE5(SVGAnimateTransformElement, nsIDOMNode,
                            nsIDOMElement, nsIDOMSVGElement,
                            nsIDOMSVGAnimationElement,
-                           nsIDOMSVGTests,
                            nsIDOMSVGAnimateTransformElement)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimateTransformElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGAnimateTransformElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGAnimationElement)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGAnimateTransformElement::nsSVGAnimateTransformElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGAnimateTransformElementBase(aNodeInfo)
+SVGAnimateTransformElement::SVGAnimateTransformElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGAnimationElement(aNodeInfo)
 {
 }
 
 bool
-nsSVGAnimateTransformElement::ParseAttribute(int32_t aNamespaceID,
-                                             nsIAtom* aAttribute,
-                                             const nsAString& aValue,
-                                             nsAttrValue& aResult)
+SVGAnimateTransformElement::ParseAttribute(int32_t aNamespaceID,
+                                           nsIAtom* aAttribute,
+                                           const nsAString& aValue,
+                                           nsAttrValue& aResult)
 {
   // 'type' is an <animateTransform>-specific attribute, and we'll handle it
   // specially.
   if (aNamespaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::type) {
     aResult.ParseAtom(aValue);
     nsIAtom* atom = aResult.GetAtomValue();
     if (atom != nsGkAtoms::translate &&
         atom != nsGkAtoms::scale &&
         atom != nsGkAtoms::rotate &&
         atom != nsGkAtoms::skewX &&
         atom != nsGkAtoms::skewY) {
       ReportAttributeParseFailure(OwnerDoc(), aAttribute, aValue);
     }
     return true;
   }
 
-  return nsSVGAnimateTransformElementBase::ParseAttribute(aNamespaceID, 
-                                                          aAttribute, aValue,
-                                                          aResult);
+  return SVGAnimationElement::ParseAttribute(aNamespaceID,
+                                             aAttribute, aValue,
+                                             aResult);
 }
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGAnimateTransformElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGAnimateTransformElement)
 
 //----------------------------------------------------------------------
 // nsISMILAnimationElement methods
 
 nsSMILAnimationFunction&
-nsSVGAnimateTransformElement::AnimationFunction()
+SVGAnimateTransformElement::AnimationFunction()
 {
   return mAnimationFunction;
 }
 
 bool
-nsSVGAnimateTransformElement::GetTargetAttributeName(int32_t *aNamespaceID,
-                                                     nsIAtom **aLocalName) const
+SVGAnimateTransformElement::GetTargetAttributeName(int32_t *aNamespaceID,
+                                                   nsIAtom **aLocalName) const
 {
-  if (nsSVGAnimateTransformElementBase::GetTargetAttributeName(aNamespaceID,
-                                                               aLocalName)) {
+  if (SVGAnimationElement::GetTargetAttributeName(aNamespaceID,
+                                                  aLocalName)) {
     return *aNamespaceID == kNameSpaceID_None &&
            (*aLocalName == nsGkAtoms::transform ||
             *aLocalName == nsGkAtoms::patternTransform ||
             *aLocalName == nsGkAtoms::gradientTransform);
   }
   return false;
 }
+
+} // namespace dom
+} // namespace mozilla
+
copy from content/svg/content/src/nsSVGAnimateTransformElement.cpp
copy to content/svg/content/src/SVGAnimateTransformElement.h
--- a/content/svg/content/src/nsSVGAnimateTransformElement.cpp
+++ b/content/svg/content/src/SVGAnimateTransformElement.h
@@ -1,40 +1,48 @@
 /* -*- 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 "nsSVGAnimationElement.h"
+#ifndef mozilla_dom_SVGAnimateTransformElement_h
+#define mozilla_dom_SVGAnimateTransformElement_h
+
+#include "mozilla/dom/SVGAnimationElement.h"
 #include "nsIDOMSVGAnimateTransformElement.h"
-#include "nsSVGEnum.h"
-#include "nsIDOMSVGTransformable.h"
 #include "nsSMILAnimationFunction.h"
 
-typedef nsSVGAnimationElement nsSVGAnimateTransformElementBase;
+nsresult NS_NewSVGAnimateTransformElement(nsIContent **aResult,
+                                          already_AddRefed<nsINodeInfo> aNodeInfo);
 
-class nsSVGAnimateTransformElement : public nsSVGAnimateTransformElementBase,
-                                     public nsIDOMSVGAnimateTransformElement
+namespace mozilla {
+namespace dom {
+
+class SVGAnimateTransformElement MOZ_FINAL : public SVGAnimationElement,
+                                             public nsIDOMSVGAnimateTransformElement
 {
 protected:
-  friend nsresult NS_NewSVGAnimateTransformElement(nsIContent **aResult,
-                                                   already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGAnimateTransformElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  SVGAnimateTransformElement(already_AddRefed<nsINodeInfo> aNodeInfo);
 
   nsSMILAnimationFunction mAnimationFunction;
+  friend nsresult
+    (::NS_NewSVGAnimateTransformElement(nsIContent **aResult,
+                                        already_AddRefed<nsINodeInfo> aNodeInfo));
+
+  virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
 
 public:
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMSVGANIMATETRANSFORMELEMENT
 
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGAnimateTransformElementBase::)
-  NS_FORWARD_NSIDOMSVGANIMATIONELEMENT(nsSVGAnimateTransformElementBase::)
+  NS_FORWARD_NSIDOMSVGELEMENT(SVGAnimationElement::)
+  NS_FORWARD_NSIDOMSVGANIMATIONELEMENT(SVGAnimationElement::)
 
   // nsIDOMNode specializations
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   // Element specializations
   bool ParseAttribute(int32_t aNamespaceID,
                         nsIAtom* aAttribute,
                         const nsAString& aValue,
@@ -45,88 +53,12 @@ public:
   virtual bool GetTargetAttributeName(int32_t *aNamespaceID,
                                       nsIAtom **aLocalName) const;
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
 };
 
-NS_IMPL_NS_NEW_SVG_ELEMENT(AnimateTransform)
-
-//----------------------------------------------------------------------
-// nsISupports methods
-
-NS_IMPL_ADDREF_INHERITED(nsSVGAnimateTransformElement,nsSVGAnimateTransformElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGAnimateTransformElement,nsSVGAnimateTransformElementBase)
-
-DOMCI_NODE_DATA(SVGAnimateTransformElement, nsSVGAnimateTransformElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGAnimateTransformElement)
-  NS_NODE_INTERFACE_TABLE6(nsSVGAnimateTransformElement, nsIDOMNode,
-                           nsIDOMElement, nsIDOMSVGElement,
-                           nsIDOMSVGAnimationElement,
-                           nsIDOMSVGTests,
-                           nsIDOMSVGAnimateTransformElement)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimateTransformElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGAnimateTransformElementBase)
-
-//----------------------------------------------------------------------
-// Implementation
-
-nsSVGAnimateTransformElement::nsSVGAnimateTransformElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGAnimateTransformElementBase(aNodeInfo)
-{
-}
+} // namespace dom
+} // namespace mozilla
 
-bool
-nsSVGAnimateTransformElement::ParseAttribute(int32_t aNamespaceID,
-                                             nsIAtom* aAttribute,
-                                             const nsAString& aValue,
-                                             nsAttrValue& aResult)
-{
-  // 'type' is an <animateTransform>-specific attribute, and we'll handle it
-  // specially.
-  if (aNamespaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::type) {
-    aResult.ParseAtom(aValue);
-    nsIAtom* atom = aResult.GetAtomValue();
-    if (atom != nsGkAtoms::translate &&
-        atom != nsGkAtoms::scale &&
-        atom != nsGkAtoms::rotate &&
-        atom != nsGkAtoms::skewX &&
-        atom != nsGkAtoms::skewY) {
-      ReportAttributeParseFailure(OwnerDoc(), aAttribute, aValue);
-    }
-    return true;
-  }
-
-  return nsSVGAnimateTransformElementBase::ParseAttribute(aNamespaceID, 
-                                                          aAttribute, aValue,
-                                                          aResult);
-}
-
-//----------------------------------------------------------------------
-// nsIDOMNode methods
-
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGAnimateTransformElement)
-
-//----------------------------------------------------------------------
-// nsISMILAnimationElement methods
-
-nsSMILAnimationFunction&
-nsSVGAnimateTransformElement::AnimationFunction()
-{
-  return mAnimationFunction;
-}
-
-bool
-nsSVGAnimateTransformElement::GetTargetAttributeName(int32_t *aNamespaceID,
-                                                     nsIAtom **aLocalName) const
-{
-  if (nsSVGAnimateTransformElementBase::GetTargetAttributeName(aNamespaceID,
-                                                               aLocalName)) {
-    return *aNamespaceID == kNameSpaceID_None &&
-           (*aLocalName == nsGkAtoms::transform ||
-            *aLocalName == nsGkAtoms::patternTransform ||
-            *aLocalName == nsGkAtoms::gradientTransform);
-  }
-  return false;
-}
+#endif // mozilla_dom_SVGAnimateTransformElement_h
--- a/content/svg/content/src/SVGAnimatedPreserveAspectRatio.cpp
+++ b/content/svg/content/src/SVGAnimatedPreserveAspectRatio.cpp
@@ -278,17 +278,17 @@ SVGAnimatedPreserveAspectRatio::SetAnimV
   mAnimVal.SetAlign(uint16_t((aPackedValue & 0xff00) >> 8));
   mAnimVal.SetMeetOrSlice(uint16_t(aPackedValue & 0xff));
   mIsAnimated = true;
   aSVGElement->DidAnimatePreserveAspectRatio();
 }
 
 nsresult
 SVGAnimatedPreserveAspectRatio::ToDOMAnimatedPreserveAspectRatio(
-  nsISupports **aResult,
+  DOMSVGAnimatedPreserveAspectRatio **aResult,
   nsSVGElement *aSVGElement)
 {
   nsRefPtr<DOMSVGAnimatedPreserveAspectRatio> domAnimatedPAspectRatio =
     sSVGAnimatedPAspectRatioTearoffTable.GetTearoff(this);
   if (!domAnimatedPAspectRatio) {
     domAnimatedPAspectRatio = new DOMSVGAnimatedPreserveAspectRatio(this, aSVGElement);
     sSVGAnimatedPAspectRatioTearoffTable.AddTearoff(this, domAnimatedPAspectRatio);
   }
--- a/content/svg/content/src/SVGAnimatedPreserveAspectRatio.h
+++ b/content/svg/content/src/SVGAnimatedPreserveAspectRatio.h
@@ -13,16 +13,19 @@
 #include "nsSVGElement.h"
 #include "SVGPreserveAspectRatio.h"
 #include "mozilla/Attributes.h"
 
 class nsISMILAnimationElement;
 class nsSMILValue;
 
 namespace mozilla {
+namespace dom {
+class DOMSVGAnimatedPreserveAspectRatio;
+}
 
 class SVGAnimatedPreserveAspectRatio MOZ_FINAL
 {
 public:
   void Init() {
     mBaseVal.mAlign = SVG_PRESERVEASPECTRATIO_XMIDYMID;
     mBaseVal.mMeetOrSlice = SVG_MEETORSLICE_MEET;
     mBaseVal.mDefer = false;
@@ -67,17 +70,17 @@ public:
   const SVGPreserveAspectRatio &GetAnimValue() const
     { return mAnimVal; }
   bool IsAnimated() const
     { return mIsAnimated; }
   bool IsExplicitlySet() const
     { return mIsAnimated || mIsBaseSet; }
 
   nsresult ToDOMAnimatedPreserveAspectRatio(
-    nsISupports **aResult,
+    mozilla::dom::DOMSVGAnimatedPreserveAspectRatio **aResult,
     nsSVGElement* aSVGElement);
   // Returns a new nsISMILAttr object that the caller must delete
   nsISMILAttr* ToSMILAttr(nsSVGElement* aSVGElement);
 
 private:
 
   SVGPreserveAspectRatio mAnimVal;
   SVGPreserveAspectRatio mBaseVal;
rename from content/svg/content/src/nsSVGAnimationElement.cpp
rename to content/svg/content/src/SVGAnimationElement.cpp
--- a/content/svg/content/src/nsSVGAnimationElement.cpp
+++ b/content/svg/content/src/SVGAnimationElement.cpp
@@ -1,256 +1,286 @@
 /* -*- 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 "nsSVGAnimationElement.h"
+#include "mozilla/dom/SVGAnimationElement.h"
 #include "nsSVGSVGElement.h"
 #include "nsSMILTimeContainer.h"
 #include "nsSMILAnimationController.h"
 #include "nsSMILAnimationFunction.h"
 #include "nsISMILAttr.h"
 #include "nsContentUtils.h"
 
-using namespace mozilla::dom;
+namespace mozilla {
+namespace dom {
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGAnimationElement, nsSVGAnimationElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGAnimationElement, nsSVGAnimationElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGAnimationElement, SVGAnimationElementBase)
+NS_IMPL_RELEASE_INHERITED(SVGAnimationElement, SVGAnimationElementBase)
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGAnimationElement)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SVGAnimationElement)
   NS_INTERFACE_MAP_ENTRY(nsISMILAnimationElement)
   NS_INTERFACE_MAP_ENTRY(nsIDOMElementTimeControl)
   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTests)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGAnimationElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGAnimationElementBase)
 
 // Cycle collection magic -- based on nsSVGUseElement
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsSVGAnimationElement)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsSVGAnimationElement,
-                                                nsSVGAnimationElementBase)
+NS_IMPL_CYCLE_COLLECTION_CLASS(SVGAnimationElement)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SVGAnimationElement,
+                                                SVGAnimationElementBase)
   tmp->mHrefTarget.Unlink();
   tmp->mTimedElement.Unlink();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsSVGAnimationElement,
-                                                  nsSVGAnimationElementBase)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SVGAnimationElement,
+                                                  SVGAnimationElementBase)
   tmp->mHrefTarget.Traverse(&cb);
   tmp->mTimedElement.Traverse(&cb);
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 //----------------------------------------------------------------------
 // Implementation
 
 #ifdef _MSC_VER
 // Disable "warning C4355: 'this' : used in base member initializer list".
 // We can ignore that warning because we know that mHrefTarget's constructor 
 // doesn't dereference the pointer passed to it.
 #pragma warning(push)
 #pragma warning(disable:4355)
 #endif
-nsSVGAnimationElement::nsSVGAnimationElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGAnimationElementBase(aNodeInfo),
+SVGAnimationElement::SVGAnimationElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGAnimationElementBase(aNodeInfo),
     mHrefTarget(this)
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
 {
+  SetIsDOMBinding();
 }
 
 nsresult
-nsSVGAnimationElement::Init()
+SVGAnimationElement::Init()
 {
-  nsresult rv = nsSVGAnimationElementBase::Init();
+  nsresult rv = SVGAnimationElementBase::Init();
   NS_ENSURE_SUCCESS(rv, rv);
 
   mTimedElement.SetAnimationElement(this);
   AnimationFunction().SetAnimationElement(this);
   mTimedElement.SetTimeClient(&AnimationFunction());
 
   return NS_OK;
 }
 
 //----------------------------------------------------------------------
 // nsISMILAnimationElement methods
 
 const Element&
-nsSVGAnimationElement::AsElement() const
+SVGAnimationElement::AsElement() const
 {
   return *this;
 }
 
 Element&
-nsSVGAnimationElement::AsElement()
+SVGAnimationElement::AsElement()
 {
   return *this;
 }
 
 bool
-nsSVGAnimationElement::PassesConditionalProcessingTests()
+SVGAnimationElement::PassesConditionalProcessingTests()
 {
-  nsCOMPtr<DOMSVGTests> tests(do_QueryInterface(
-    static_cast<nsSVGElement*>(this)));
-  return tests->PassesConditionalProcessingTests();
+  return DOMSVGTests::PassesConditionalProcessingTests();
 }
 
 const nsAttrValue*
-nsSVGAnimationElement::GetAnimAttr(nsIAtom* aName) const
+SVGAnimationElement::GetAnimAttr(nsIAtom* aName) const
 {
   return mAttrsAndChildren.GetAttr(aName, kNameSpaceID_None);
 }
 
 bool
-nsSVGAnimationElement::GetAnimAttr(nsIAtom* aAttName,
-                                   nsAString& aResult) const
+SVGAnimationElement::GetAnimAttr(nsIAtom* aAttName,
+                                 nsAString& aResult) const
 {
   return GetAttr(kNameSpaceID_None, aAttName, aResult);
 }
 
 bool
-nsSVGAnimationElement::HasAnimAttr(nsIAtom* aAttName) const
+SVGAnimationElement::HasAnimAttr(nsIAtom* aAttName) const
 {
   return HasAttr(kNameSpaceID_None, aAttName);
 }
 
 Element*
-nsSVGAnimationElement::GetTargetElementContent()
+SVGAnimationElement::GetTargetElementContent()
 {
   if (HasAttr(kNameSpaceID_XLink, nsGkAtoms::href)) {
     return mHrefTarget.get();
   }
   NS_ABORT_IF_FALSE(!mHrefTarget.get(),
                     "We shouldn't have an xlink:href target "
                     "if we don't have an xlink:href attribute");
 
   // No "xlink:href" attribute --> I should target my parent.
   nsIContent* parent = GetFlattenedTreeParent();
   return parent && parent->IsElement() ? parent->AsElement() : nullptr;
 }
 
 bool
-nsSVGAnimationElement::GetTargetAttributeName(int32_t *aNamespaceID,
-                                              nsIAtom **aLocalName) const
+SVGAnimationElement::GetTargetAttributeName(int32_t *aNamespaceID,
+                                            nsIAtom **aLocalName) const
 {
   const nsAttrValue* nameAttr
     = mAttrsAndChildren.GetAttr(nsGkAtoms::attributeName);
 
   if (!nameAttr)
     return false;
 
   NS_ASSERTION(nameAttr->Type() == nsAttrValue::eAtom,
     "attributeName should have been parsed as an atom");
 
   return NS_SUCCEEDED(nsContentUtils::SplitQName(
                         this, nsDependentAtomString(nameAttr->GetAtomValue()),
                         aNamespaceID, aLocalName));
 }
 
 nsSMILTargetAttrType
-nsSVGAnimationElement::GetTargetAttributeType() const
+SVGAnimationElement::GetTargetAttributeType() const
 {
   nsIContent::AttrValuesArray typeValues[] = { &nsGkAtoms::css,
                                                &nsGkAtoms::XML,
                                                nullptr};
   nsSMILTargetAttrType smilTypes[] = { eSMILTargetAttrType_CSS,
                                        eSMILTargetAttrType_XML };
   int32_t index = FindAttrValueIn(kNameSpaceID_None,
                                   nsGkAtoms::attributeType,
                                   typeValues,
                                   eCaseMatters);
   return (index >= 0) ? smilTypes[index] : eSMILTargetAttrType_auto;
 }
 
 nsSMILTimedElement&
-nsSVGAnimationElement::TimedElement()
+SVGAnimationElement::TimedElement()
 {
   return mTimedElement;
 }
 
 //----------------------------------------------------------------------
 // nsIDOMSVGAnimationElement methods
 
 /* readonly attribute SVGElement targetElement; */
 NS_IMETHODIMP
-nsSVGAnimationElement::GetTargetElement(nsIDOMSVGElement** aTarget)
+SVGAnimationElement::GetTargetElement(nsIDOMSVGElement** aTarget)
+{
+  // We'll just call the other GetTargetElement method, and QI to the right type
+  nsSVGElement* target = GetTargetElement();
+
+  nsCOMPtr<nsIDOMSVGElement> targetSVG = do_QueryInterface(target);
+  targetSVG.forget(aTarget);
+
+  return NS_OK;
+}
+
+nsSVGElement*
+SVGAnimationElement::GetTargetElement()
 {
   FlushAnimations();
 
   // We'll just call the other GetTargetElement method, and QI to the right type
-  nsIContent* targetContent = GetTargetElementContent();
+  nsIContent* target = GetTargetElementContent();
 
-  nsCOMPtr<nsIDOMSVGElement> targetSVG = do_QueryInterface(targetContent);
-  NS_IF_ADDREF(*aTarget = targetSVG);
-
-  return NS_OK;
+  return (target && target->IsSVG()) ? static_cast<nsSVGElement*>(target) : nullptr;
 }
 
 /* float getStartTime() raises( DOMException ); */
 NS_IMETHODIMP
-nsSVGAnimationElement::GetStartTime(float* retval)
+SVGAnimationElement::GetStartTime(float* retval)
+{
+  ErrorResult rv;
+  *retval = GetStartTime(rv);
+  return rv.ErrorCode();
+}
+
+float
+SVGAnimationElement::GetStartTime(ErrorResult& rv)
 {
   FlushAnimations();
 
   nsSMILTimeValue startTime = mTimedElement.GetStartTime();
-  if (!startTime.IsDefinite())
-    return NS_ERROR_DOM_INVALID_STATE_ERR;
+  if (!startTime.IsDefinite()) {
+    rv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
+    return 0.f;
+  }
 
-  *retval = float(double(startTime.GetMillis()) / PR_MSEC_PER_SEC);
-
-  return NS_OK;
+  return float(double(startTime.GetMillis()) / PR_MSEC_PER_SEC);
 }
 
 /* float getCurrentTime(); */
 NS_IMETHODIMP
-nsSVGAnimationElement::GetCurrentTime(float* retval)
+SVGAnimationElement::GetCurrentTime(float* retval)
+{
+  *retval = GetCurrentTime();
+  return NS_OK;
+}
+
+float
+SVGAnimationElement::GetCurrentTime()
 {
   // Not necessary to call FlushAnimations() for this
 
   nsSMILTimeContainer* root = GetTimeContainer();
   if (root) {
-    *retval = float(double(root->GetCurrentTime()) / PR_MSEC_PER_SEC);
-  } else {
-    *retval = 0.f;
+    return float(double(root->GetCurrentTime()) / PR_MSEC_PER_SEC);
   }
-  return NS_OK;
+
+  return 0.0f;
 }
 
 /* float getSimpleDuration() raises( DOMException ); */
 NS_IMETHODIMP
-nsSVGAnimationElement::GetSimpleDuration(float* retval)
+SVGAnimationElement::GetSimpleDuration(float* retval)
+{
+  ErrorResult rv;
+  *retval = GetSimpleDuration(rv);
+  return rv.ErrorCode();
+}
+
+float
+SVGAnimationElement::GetSimpleDuration(ErrorResult& rv)
 {
   // Not necessary to call FlushAnimations() for this
 
   nsSMILTimeValue simpleDur = mTimedElement.GetSimpleDuration();
   if (!simpleDur.IsDefinite()) {
-    *retval = 0.f;
-    return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
+    rv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
+    return 0.f;
   }
 
-  *retval = float(double(simpleDur.GetMillis()) / PR_MSEC_PER_SEC);
-  return NS_OK;
+  return float(double(simpleDur.GetMillis()) / PR_MSEC_PER_SEC);
 }
 
 //----------------------------------------------------------------------
 // nsIContent methods
 
 nsresult
-nsSVGAnimationElement::BindToTree(nsIDocument* aDocument,
-                                  nsIContent* aParent,
-                                  nsIContent* aBindingParent,
-                                  bool aCompileEventHandlers)
+SVGAnimationElement::BindToTree(nsIDocument* aDocument,
+                                nsIContent* aParent,
+                                nsIContent* aBindingParent,
+                                bool aCompileEventHandlers)
 {
   NS_ABORT_IF_FALSE(!mHrefTarget.get(),
                     "Shouldn't have href-target yet "
                     "(or it should've been cleared)");
-  nsresult rv = nsSVGAnimationElementBase::BindToTree(aDocument, aParent,
-                                                      aBindingParent,
-                                                      aCompileEventHandlers);
+  nsresult rv = SVGAnimationElementBase::BindToTree(aDocument, aParent,
+                                                    aBindingParent,
+                                                    aCompileEventHandlers);
   NS_ENSURE_SUCCESS(rv,rv);
 
   // XXXdholbert is GetCtx (as a check for SVG parent) still needed here?
   if (!GetCtx()) {
     // No use proceeding. We don't have an SVG parent (yet) so we won't be able
     // to register ourselves etc. Maybe next time we'll have more luck.
     // (This sort of situation will arise a lot when trees are being constructed
     // piece by piece via script)
@@ -279,36 +309,36 @@ nsSVGAnimationElement::BindToTree(nsIDoc
   }
 
   AnimationNeedsResample();
 
   return NS_OK;
 }
 
 void
-nsSVGAnimationElement::UnbindFromTree(bool aDeep, bool aNullParent)
+SVGAnimationElement::UnbindFromTree(bool aDeep, bool aNullParent)
 {
   nsSMILAnimationController *controller = OwnerDoc()->GetAnimationController();
   if (controller) {
     controller->UnregisterAnimationElement(this);
   }
 
   mHrefTarget.Unlink();
   mTimedElement.DissolveReferences();
 
   AnimationNeedsResample();
 
-  nsSVGAnimationElementBase::UnbindFromTree(aDeep, aNullParent);
+  SVGAnimationElementBase::UnbindFromTree(aDeep, aNullParent);
 }
 
 bool
-nsSVGAnimationElement::ParseAttribute(int32_t aNamespaceID,
-                                      nsIAtom* aAttribute,
-                                      const nsAString& aValue,
-                                      nsAttrValue& aResult)
+SVGAnimationElement::ParseAttribute(int32_t aNamespaceID,
+                                    nsIAtom* aAttribute,
+                                    const nsAString& aValue,
+                                    nsAttrValue& aResult)
 {
   if (aNamespaceID == kNameSpaceID_None) {
     // Deal with target-related attributes here
     if (aAttribute == nsGkAtoms::attributeName ||
         aAttribute == nsGkAtoms::attributeType) {
       aResult.ParseAtom(aValue);
       AnimationNeedsResample();
       return true;
@@ -332,27 +362,27 @@ nsSVGAnimationElement::ParseAttribute(in
       if (NS_FAILED(rv)) {
         ReportAttributeParseFailure(OwnerDoc(), aAttribute, aValue);
         return false;
       }
       return true;
     }
   }
 
-  return nsSVGAnimationElementBase::ParseAttribute(aNamespaceID, aAttribute,
-                                                   aValue, aResult);
+  return SVGAnimationElementBase::ParseAttribute(aNamespaceID, aAttribute,
+                                                 aValue, aResult);
 }
 
 nsresult
-nsSVGAnimationElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
-                                    const nsAttrValue* aValue, bool aNotify)
+SVGAnimationElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
+                                  const nsAttrValue* aValue, bool aNotify)
 {
   nsresult rv =
-    nsSVGAnimationElementBase::AfterSetAttr(aNamespaceID, aName, aValue,
-                                            aNotify);
+    SVGAnimationElementBase::AfterSetAttr(aNamespaceID, aName, aValue,
+                                          aNotify);
 
   if (aNamespaceID != kNameSpaceID_XLink || aName != nsGkAtoms::href)
     return rv;
 
   if (!aValue) {
     mHrefTarget.Unlink();
     AnimationTargetChanged();
   } else if (IsInDoc()) {
@@ -361,44 +391,44 @@ nsSVGAnimationElement::AfterSetAttr(int3
     UpdateHrefTarget(this, aValue->GetStringValue());
   } // else: we're not yet in a document -- we'll update the target on
     // next BindToTree call.
 
   return rv;
 }
 
 nsresult
-nsSVGAnimationElement::UnsetAttr(int32_t aNamespaceID,
-                                 nsIAtom* aAttribute, bool aNotify)
+SVGAnimationElement::UnsetAttr(int32_t aNamespaceID,
+                               nsIAtom* aAttribute, bool aNotify)
 {
-  nsresult rv = nsSVGAnimationElementBase::UnsetAttr(aNamespaceID, aAttribute,
-                                                     aNotify);
+  nsresult rv = SVGAnimationElementBase::UnsetAttr(aNamespaceID, aAttribute,
+                                                   aNotify);
   NS_ENSURE_SUCCESS(rv,rv);
 
   if (aNamespaceID == kNameSpaceID_None) {
     if (AnimationFunction().UnsetAttr(aAttribute) ||
         mTimedElement.UnsetAttr(aAttribute)) {
       AnimationNeedsResample();
     }
   }
 
   return NS_OK;
 }
 
 bool
-nsSVGAnimationElement::IsNodeOfType(uint32_t aFlags) const
+SVGAnimationElement::IsNodeOfType(uint32_t aFlags) const
 {
   return !(aFlags & ~(eCONTENT | eANIMATION));
 }
 
 //----------------------------------------------------------------------
 // SVG utility methods
 
 void
-nsSVGAnimationElement::ActivateByHyperlink()
+SVGAnimationElement::ActivateByHyperlink()
 {
   FlushAnimations();
 
   // The behavior for when the target is an animation element is defined in
   // SMIL Animation:
   //   http://www.w3.org/TR/smil-animation/#HyperlinkSemantics
   nsSMILTimeValue seekTime = mTimedElement.GetHyperlinkTime();
   if (seekTime.IsDefinite()) {
@@ -416,101 +446,116 @@ nsSVGAnimationElement::ActivateByHyperli
     BeginElement();
   }
 }
 
 //----------------------------------------------------------------------
 // Implementation helpers
 
 nsSMILTimeContainer*
-nsSVGAnimationElement::GetTimeContainer()
+SVGAnimationElement::GetTimeContainer()
 {
   nsSVGSVGElement *element = SVGContentUtils::GetOuterSVGElement(this);
 
   if (element) {
     return element->GetTimedDocumentRoot();
   }
 
   return nullptr;
 }
 
 // nsIDOMElementTimeControl
 /* void beginElement (); */
 NS_IMETHODIMP
-nsSVGAnimationElement::BeginElement(void)
+SVGAnimationElement::BeginElement(void)
 {
   return BeginElementAt(0.f);
 }
 
 /* void beginElementAt (in float offset); */
 NS_IMETHODIMP
-nsSVGAnimationElement::BeginElementAt(float offset)
+SVGAnimationElement::BeginElementAt(float offset)
 {
   NS_ENSURE_FINITE(offset, NS_ERROR_ILLEGAL_VALUE);
 
+  ErrorResult rv;
+  BeginElementAt(offset, rv);
+  return rv.ErrorCode();
+}
+
+void
+SVGAnimationElement::BeginElementAt(float offset, ErrorResult& rv)
+{
   // Make sure the timegraph is up-to-date
   FlushAnimations();
 
   // This will fail if we're not attached to a time container (SVG document
   // fragment).
-  nsresult rv = mTimedElement.BeginElementAt(offset);
-  if (NS_FAILED(rv))
-    return rv;
+  rv = mTimedElement.BeginElementAt(offset);
+  if (rv.Failed())
+    return;
 
   AnimationNeedsResample();
   // Force synchronous sample so that events resulting from this call arrive in
   // the expected order and we get an up-to-date paint.
   FlushAnimations();
-
-  return NS_OK;
 }
 
 /* void endElement (); */
 NS_IMETHODIMP
-nsSVGAnimationElement::EndElement(void)
+SVGAnimationElement::EndElement(void)
 {
   return EndElementAt(0.f);
 }
 
 /* void endElementAt (in float offset); */
 NS_IMETHODIMP
-nsSVGAnimationElement::EndElementAt(float offset)
+SVGAnimationElement::EndElementAt(float offset)
 {
   NS_ENSURE_FINITE(offset, NS_ERROR_ILLEGAL_VALUE);
 
+  ErrorResult rv;
+  EndElementAt(offset, rv);
+  return rv.ErrorCode();
+}
+
+void
+SVGAnimationElement::EndElementAt(float offset, ErrorResult& rv)
+{
   // Make sure the timegraph is up-to-date
   FlushAnimations();
 
-  nsresult rv = mTimedElement.EndElementAt(offset);
-  if (NS_FAILED(rv))
-    return rv;
+  rv = mTimedElement.EndElementAt(offset);
+  if (rv.Failed())
+    return;
 
   AnimationNeedsResample();
   // Force synchronous sample
   FlushAnimations();
- 
-  return NS_OK;
 }
 
 bool
-nsSVGAnimationElement::IsEventAttributeName(nsIAtom* aName)
+SVGAnimationElement::IsEventAttributeName(nsIAtom* aName)
 {
   return nsContentUtils::IsEventAttributeName(aName, EventNameType_SMIL);
 }
 
 void
-nsSVGAnimationElement::UpdateHrefTarget(nsIContent* aNodeForContext,
-                                        const nsAString& aHrefStr)
+SVGAnimationElement::UpdateHrefTarget(nsIContent* aNodeForContext,
+                                      const nsAString& aHrefStr)
 {
   nsCOMPtr<nsIURI> targetURI;
   nsCOMPtr<nsIURI> baseURI = GetBaseURI();
   nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(targetURI),
                                             aHrefStr, OwnerDoc(), baseURI);
   mHrefTarget.Reset(aNodeForContext, targetURI);
   AnimationTargetChanged();
 }
 
 void
-nsSVGAnimationElement::AnimationTargetChanged()
+SVGAnimationElement::AnimationTargetChanged()
 {
   mTimedElement.HandleTargetElementChange(GetTargetElementContent());
   AnimationNeedsResample();
 }
+
+} // namespace dom
+} // namespace mozilla
rename from content/svg/content/src/nsSVGAnimationElement.h
rename to content/svg/content/src/SVGAnimationElement.h
--- a/content/svg/content/src/nsSVGAnimationElement.h
+++ b/content/svg/content/src/SVGAnimationElement.h
@@ -1,41 +1,44 @@
 /* -*- 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 NS_SVGANIMATIONELEMENT_H_
-#define NS_SVGANIMATIONELEMENT_H_
+#ifndef mozilla_dom_SVGAnimationElement_h
+#define mozilla_dom_SVGAnimationElement_h
 
 #include "DOMSVGTests.h"
 #include "nsIDOMElementTimeControl.h"
 #include "nsIDOMSVGAnimationElement.h"
 #include "nsISMILAnimationElement.h"
 #include "nsReferencedElement.h"
 #include "nsSMILTimedElement.h"
 #include "nsSVGElement.h"
 
-typedef nsSVGElement nsSVGAnimationElementBase;
+typedef nsSVGElement SVGAnimationElementBase;
+
+namespace mozilla {
+namespace dom {
 
-class nsSVGAnimationElement : public nsSVGAnimationElementBase,
-                              public DOMSVGTests,
-                              public nsISMILAnimationElement,
-                              public nsIDOMElementTimeControl
+class SVGAnimationElement : public SVGAnimationElementBase,
+                            public DOMSVGTests,
+                            public nsISMILAnimationElement,
+                            public nsIDOMElementTimeControl
 {
 protected:
-  nsSVGAnimationElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  SVGAnimationElement(already_AddRefed<nsINodeInfo> aNodeInfo);
   nsresult Init();
 
 public:
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
 
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsSVGAnimationElement,
-                                           nsSVGAnimationElementBase)
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGAnimationElement,
+                                           SVGAnimationElementBase)
   NS_DECL_NSIDOMSVGANIMATIONELEMENT
   NS_DECL_NSIDOMELEMENTTIMECONTROL
 
   // nsIContent specializations
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers);
   virtual void UnbindFromTree(bool aDeep, bool aNullParent);
@@ -67,40 +70,53 @@ public:
   virtual nsSMILTimedElement& TimedElement();
   virtual nsSMILTimeContainer* GetTimeContainer();
 
   virtual bool IsEventAttributeName(nsIAtom* aName) MOZ_OVERRIDE;
 
   // Utility methods for within SVG
   void ActivateByHyperlink();
 
-protected:
+  // WebIDL
+  nsSVGElement* GetTargetElement();
+  float GetStartTime(ErrorResult& rv);
+  float GetCurrentTime();
+  float GetSimpleDuration(ErrorResult& rv);
+  void BeginElement(ErrorResult& rv) { BeginElementAt(0.f, rv); }
+  void BeginElementAt(float offset, ErrorResult& rv);
+  void EndElement(ErrorResult& rv) { EndElementAt(0.f, rv); }
+  void EndElementAt(float offset, ErrorResult& rv);
+
+ protected:
   // nsSVGElement overrides
 
   void UpdateHrefTarget(nsIContent* aNodeForContext,
                         const nsAString& aHrefStr);
   void AnimationTargetChanged();
 
   class TargetReference : public nsReferencedElement {
   public:
-    TargetReference(nsSVGAnimationElement* aAnimationElement) :
+    TargetReference(SVGAnimationElement* aAnimationElement) :
       mAnimationElement(aAnimationElement) {}
   protected:
     // We need to be notified when target changes, in order to request a
     // sample (which will clear animation effects from old target and apply
     // them to the new target) and update any event registrations.
     virtual void ElementChanged(Element* aFrom, Element* aTo) {
       nsReferencedElement::ElementChanged(aFrom, aTo);
       mAnimationElement->AnimationTargetChanged();
     }
 
     // We need to override IsPersistent to get persistent tracking (beyond the
     // first time the target changes)
     virtual bool IsPersistent() { return true; }
   private:
-    nsSVGAnimationElement* const mAnimationElement;
+    SVGAnimationElement* const mAnimationElement;
   };
 
   TargetReference      mHrefTarget;
   nsSMILTimedElement   mTimedElement;
 };
 
-#endif // NS_SVGANIMATIONELEMENT_H_
+} // namespace mozilla
+} // namespace dom
+
+#endif // mozilla_dom_SVGAnimationElement_h
rename from content/svg/content/src/nsSVGCircleElement.cpp
rename to content/svg/content/src/SVGCircleElement.cpp
--- a/content/svg/content/src/nsSVGCircleElement.cpp
+++ b/content/svg/content/src/SVGCircleElement.cpp
@@ -1,143 +1,132 @@
 /* -*- 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 "nsSVGPathGeometryElement.h"
-#include "nsIDOMSVGCircleElement.h"
-#include "nsSVGLength2.h"
+#include "mozilla/dom/SVGCircleElement.h"
 #include "nsGkAtoms.h"
 #include "gfxContext.h"
-
-using namespace mozilla;
-
-typedef nsSVGPathGeometryElement nsSVGCircleElementBase;
+#include "mozilla/dom/SVGCircleElementBinding.h"
 
-class nsSVGCircleElement : public nsSVGCircleElementBase,
-                           public nsIDOMSVGCircleElement
-{
-protected:
-  friend nsresult NS_NewSVGCircleElement(nsIContent **aResult,
-                                         already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGCircleElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+DOMCI_NODE_DATA(SVGCircleElement, mozilla::dom::SVGCircleElement)
 
-public:
-  // interfaces:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMSVGCIRCLEELEMENT
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Circle)
 
-  // xxx I wish we could use virtual inheritance
-  NS_FORWARD_NSIDOMNODE_TO_NSINODE
-  NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGCircleElementBase::)
-
-  // nsSVGSVGElement methods:
-  virtual bool HasValidDimensions() const;
-
-  // nsSVGPathGeometryElement methods:
-  virtual void ConstructPath(gfxContext *aCtx);
-
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
+namespace mozilla {
+namespace dom {
 
-  virtual nsXPCClassInfo* GetClassInfo();
-
-  virtual nsIDOMNode* AsDOMNode() { return this; }
-protected:
-
-  virtual LengthAttributesInfo GetLengthInfo();
+JSObject*
+SVGCircleElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return SVGCircleElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
 
-  enum { CX, CY, R };
-  nsSVGLength2 mLengthAttributes[3];
-  static LengthInfo sLengthInfo[3];
-};
-
-nsSVGElement::LengthInfo nsSVGCircleElement::sLengthInfo[3] =
+nsSVGElement::LengthInfo SVGCircleElement::sLengthInfo[3] =
 {
   { &nsGkAtoms::cx, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::cy, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
   { &nsGkAtoms::r, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::XY }
 };
 
-NS_IMPL_NS_NEW_SVG_ELEMENT(Circle)
-
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGCircleElement,nsSVGCircleElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGCircleElement,nsSVGCircleElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGCircleElement,SVGCircleElementBase)
+NS_IMPL_RELEASE_INHERITED(SVGCircleElement,SVGCircleElementBase)
 
-DOMCI_NODE_DATA(SVGCircleElement, nsSVGCircleElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGCircleElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGCircleElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
+NS_INTERFACE_TABLE_HEAD(SVGCircleElement)
+  NS_NODE_INTERFACE_TABLE4(SVGCircleElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
                            nsIDOMSVGCircleElement)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGCircleElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGCircleElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGCircleElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGCircleElement::nsSVGCircleElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGCircleElementBase(aNodeInfo)
+SVGCircleElement::SVGCircleElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGCircleElementBase(aNodeInfo)
 {
+  SetIsDOMBinding();
 }
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGCircleElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGCircleElement)
 
 //----------------------------------------------------------------------
 // nsIDOMSVGCircleElement methods
 
 /* readonly attribute nsIDOMSVGAnimatedLength cx; */
-NS_IMETHODIMP nsSVGCircleElement::GetCx(nsIDOMSVGAnimatedLength * *aCx)
+NS_IMETHODIMP SVGCircleElement::GetCx(nsIDOMSVGAnimatedLength * *aCx)
 {
-  return mLengthAttributes[CX].ToDOMAnimatedLength(aCx, this);
+  *aCx = Cx().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGCircleElement::Cx()
+{
+  return mLengthAttributes[ATTR_CX].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength cy; */
-NS_IMETHODIMP nsSVGCircleElement::GetCy(nsIDOMSVGAnimatedLength * *aCy)
+NS_IMETHODIMP SVGCircleElement::GetCy(nsIDOMSVGAnimatedLength * *aCy)
 {
-  return mLengthAttributes[CY].ToDOMAnimatedLength(aCy, this);
+  *aCy = Cy().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGCircleElement::Cy()
+{
+  return mLengthAttributes[ATTR_CY].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength r; */
-NS_IMETHODIMP nsSVGCircleElement::GetR(nsIDOMSVGAnimatedLength * *aR)
+NS_IMETHODIMP SVGCircleElement::GetR(nsIDOMSVGAnimatedLength * *aR)
 {
-  return mLengthAttributes[R].ToDOMAnimatedLength(aR, this);
+  *aR = R().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGCircleElement::R()
+{
+  return mLengthAttributes[ATTR_R].ToDOMAnimatedLength(this);
 }
 
 //----------------------------------------------------------------------
 // nsSVGElement methods
 
 /* virtual */ bool
-nsSVGCircleElement::HasValidDimensions() const
+SVGCircleElement::HasValidDimensions() const
 {
-  return mLengthAttributes[R].IsExplicitlySet() &&
-         mLengthAttributes[R].GetAnimValInSpecifiedUnits() > 0;
+  return mLengthAttributes[ATTR_R].IsExplicitlySet() &&
+         mLengthAttributes[ATTR_R].GetAnimValInSpecifiedUnits() > 0;
 }
 
 nsSVGElement::LengthAttributesInfo
-nsSVGCircleElement::GetLengthInfo()
+SVGCircleElement::GetLengthInfo()
 {
   return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
                               ArrayLength(sLengthInfo));
 }
 
 //----------------------------------------------------------------------
 // nsSVGPathGeometryElement methods
 
 void
-nsSVGCircleElement::ConstructPath(gfxContext *aCtx)
+SVGCircleElement::ConstructPath(gfxContext *aCtx)
 {
   float x, y, r;
 
   GetAnimatedLengthValues(&x, &y, &r, nullptr);
 
   if (r > 0.0f)
     aCtx->Arc(gfxPoint(x, y), r, 0, 2*M_PI);
 }
+
+} // namespace dom
+} // namespace mozilla
copy from content/svg/content/src/nsSVGCircleElement.cpp
copy to content/svg/content/src/SVGCircleElement.h
--- a/content/svg/content/src/nsSVGCircleElement.cpp
+++ b/content/svg/content/src/SVGCircleElement.h
@@ -1,143 +1,69 @@
 /* -*- 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_SVGCircleElement_h
+#define mozilla_dom_SVGCircleElement_h
 
 #include "nsSVGPathGeometryElement.h"
 #include "nsIDOMSVGCircleElement.h"
 #include "nsSVGLength2.h"
-#include "nsGkAtoms.h"
-#include "gfxContext.h"
 
-using namespace mozilla;
+nsresult NS_NewSVGCircleElement(nsIContent **aResult,
+                                already_AddRefed<nsINodeInfo> aNodeInfo);
+
+typedef nsSVGPathGeometryElement SVGCircleElementBase;
 
-typedef nsSVGPathGeometryElement nsSVGCircleElementBase;
+namespace mozilla {
+namespace dom {
 
-class nsSVGCircleElement : public nsSVGCircleElementBase,
-                           public nsIDOMSVGCircleElement
+class SVGCircleElement MOZ_FINAL : public SVGCircleElementBase,
+                                   public nsIDOMSVGCircleElement
 {
 protected:
-  friend nsresult NS_NewSVGCircleElement(nsIContent **aResult,
-                                         already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGCircleElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  SVGCircleElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE;
+  friend nsresult (::NS_NewSVGCircleElement(nsIContent **aResult,
+                                            already_AddRefed<nsINodeInfo> aNodeInfo));
 
 public:
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMSVGCIRCLEELEMENT
 
   // xxx I wish we could use virtual inheritance
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGCircleElementBase::)
+  NS_FORWARD_NSIDOMSVGELEMENT(SVGCircleElementBase::)
 
   // nsSVGSVGElement methods:
   virtual bool HasValidDimensions() const;
 
   // nsSVGPathGeometryElement methods:
   virtual void ConstructPath(gfxContext *aCtx);
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
+
+  // WebIDL
+  already_AddRefed<nsIDOMSVGAnimatedLength> Cx();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Cy();
+  already_AddRefed<nsIDOMSVGAnimatedLength> R();
+
 protected:
 
   virtual LengthAttributesInfo GetLengthInfo();
 
-  enum { CX, CY, R };
+  enum { ATTR_CX, ATTR_CY, ATTR_R };
   nsSVGLength2 mLengthAttributes[3];
   static LengthInfo sLengthInfo[3];
 };
 
-nsSVGElement::LengthInfo nsSVGCircleElement::sLengthInfo[3] =
-{
-  { &nsGkAtoms::cx, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
-  { &nsGkAtoms::cy, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
-  { &nsGkAtoms::r, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::XY }
-};
-
-NS_IMPL_NS_NEW_SVG_ELEMENT(Circle)
-
-//----------------------------------------------------------------------
-// nsISupports methods
-
-NS_IMPL_ADDREF_INHERITED(nsSVGCircleElement,nsSVGCircleElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGCircleElement,nsSVGCircleElementBase)
-
-DOMCI_NODE_DATA(SVGCircleElement, nsSVGCircleElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGCircleElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGCircleElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
-                           nsIDOMSVGCircleElement)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGCircleElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGCircleElementBase)
-
-//----------------------------------------------------------------------
-// Implementation
-
-nsSVGCircleElement::nsSVGCircleElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGCircleElementBase(aNodeInfo)
-{
-}
-
-//----------------------------------------------------------------------
-// nsIDOMNode methods
-
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGCircleElement)
-
-//----------------------------------------------------------------------
-// nsIDOMSVGCircleElement methods
+} // namespace dom
+} // namespace mozilla
 
-/* readonly attribute nsIDOMSVGAnimatedLength cx; */
-NS_IMETHODIMP nsSVGCircleElement::GetCx(nsIDOMSVGAnimatedLength * *aCx)
-{
-  return mLengthAttributes[CX].ToDOMAnimatedLength(aCx, this);
-}
-
-/* readonly attribute nsIDOMSVGAnimatedLength cy; */
-NS_IMETHODIMP nsSVGCircleElement::GetCy(nsIDOMSVGAnimatedLength * *aCy)
-{
-  return mLengthAttributes[CY].ToDOMAnimatedLength(aCy, this);
-}
-
-/* readonly attribute nsIDOMSVGAnimatedLength r; */
-NS_IMETHODIMP nsSVGCircleElement::GetR(nsIDOMSVGAnimatedLength * *aR)
-{
-  return mLengthAttributes[R].ToDOMAnimatedLength(aR, this);
-}
-
-//----------------------------------------------------------------------
-// nsSVGElement methods
-
-/* virtual */ bool
-nsSVGCircleElement::HasValidDimensions() const
-{
-  return mLengthAttributes[R].IsExplicitlySet() &&
-         mLengthAttributes[R].GetAnimValInSpecifiedUnits() > 0;
-}
-
-nsSVGElement::LengthAttributesInfo
-nsSVGCircleElement::GetLengthInfo()
-{
-  return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
-                              ArrayLength(sLengthInfo));
-}
-
-//----------------------------------------------------------------------
-// nsSVGPathGeometryElement methods
-
-void
-nsSVGCircleElement::ConstructPath(gfxContext *aCtx)
-{
-  float x, y, r;
-
-  GetAnimatedLengthValues(&x, &y, &r, nullptr);
-
-  if (r > 0.0f)
-    aCtx->Arc(gfxPoint(x, y), r, 0, 2*M_PI);
-}
+#endif // mozilla_dom_SVGCircleElement_h
--- a/content/svg/content/src/SVGContentUtils.cpp
+++ b/content/svg/content/src/SVGContentUtils.cpp
@@ -7,21 +7,20 @@
 // This is also necessary to ensure our definition of M_SQRT1_2 is picked up
 #include "SVGContentUtils.h"
 
 // Keep others in (case-insensitive) order:
 #include "gfxMatrix.h"
 #include "mozilla/Preferences.h"
 #include "nsComputedDOMStyle.h"
 #include "nsFontMetrics.h"
-#include "nsIDOMSVGElement.h"
 #include "nsIFrame.h"
 #include "nsIScriptError.h"
 #include "nsLayoutUtils.h"
-#include "nsSVGAnimationElement.h"
+#include "SVGAnimationElement.h"
 #include "nsSVGSVGElement.h"
 #include "SVGAnimatedPreserveAspectRatio.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 nsSVGSVGElement*
 SVGContentUtils::GetOuterSVGElement(nsSVGElement *aSVGElement)
@@ -42,17 +41,17 @@ SVGContentUtils::GetOuterSVGElement(nsSV
 }
 
 void
 SVGContentUtils::ActivateByHyperlink(nsIContent *aContent)
 {
   NS_ABORT_IF_FALSE(aContent->IsNodeOfType(nsINode::eANIMATION),
                     "Expecting an animation element");
 
-  static_cast<nsSVGAnimationElement*>(aContent)->ActivateByHyperlink();
+  static_cast<SVGAnimationElement*>(aContent)->ActivateByHyperlink();
 }
 
 float
 SVGContentUtils::GetFontSize(Element *aElement)
 {
   if (!aElement)
     return 1.0f;
 
@@ -155,27 +154,27 @@ SVGContentUtils::EstablishesViewport(nsI
   // viewport, this is really only for the document it references, not
   // for any child content, which is what this function is used for.
   return aContent && aContent->IsSVG() &&
            (aContent->Tag() == nsGkAtoms::svg ||
             aContent->Tag() == nsGkAtoms::foreignObject ||
             aContent->Tag() == nsGkAtoms::symbol);
 }
 
-already_AddRefed<nsIDOMSVGElement>
+nsSVGElement*
 SVGContentUtils::GetNearestViewportElement(nsIContent *aContent)
 {
   nsIContent *element = aContent->GetFlattenedTreeParent();
 
   while (element && element->IsSVG()) {
     if (EstablishesViewport(element)) {
       if (element->Tag() == nsGkAtoms::foreignObject) {
         return nullptr;
       }
-      return nsCOMPtr<nsIDOMSVGElement>(do_QueryInterface(element)).forget();
+      return static_cast<nsSVGElement*>(element);
     }
     element = element->GetFlattenedTreeParent();
   }
   return nullptr;
 }
 
 static gfxMatrix
 GetCTMInternal(nsSVGElement *aElement, bool aScreenCTM, bool aHaveRecursed)
--- a/content/svg/content/src/SVGContentUtils.h
+++ b/content/svg/content/src/SVGContentUtils.h
@@ -10,17 +10,16 @@
 #define _USE_MATH_DEFINES
 #include <math.h>
 
 #include "gfxMatrix.h"
 #include "nsCOMPtr.h"
 
 class nsIContent;
 class nsIDocument;
-class nsIDOMSVGElement;
 class nsIFrame;
 class nsStyleContext;
 class nsSVGElement;
 class nsSVGLength2;
 class nsSVGSVGElement;
 
 namespace mozilla {
 class SVGAnimatedPreserveAspectRatio;
@@ -101,17 +100,17 @@ public:
   static gfxMatrix GetCTM(nsSVGElement *aElement, bool aScreenCTM);
 
   /**
    * Check if this is one of the SVG elements that SVG 1.1 Full says
    * establishes a viewport: svg, symbol, image or foreignObject.
    */
   static bool EstablishesViewport(nsIContent *aContent);
 
-  static already_AddRefed<nsIDOMSVGElement>
+  static nsSVGElement*
   GetNearestViewportElement(nsIContent *aContent);
 
   /* enum for specifying coordinate direction for ObjectSpace/UserSpace */
   enum ctxDirection { X, Y, XY };
 
   /**
    * Computes sqrt((aWidth^2 + aHeight^2)/2);
    */
rename from content/svg/content/src/nsSVGDefsElement.cpp
rename to content/svg/content/src/SVGDefsElement.cpp
--- a/content/svg/content/src/nsSVGDefsElement.cpp
+++ b/content/svg/content/src/SVGDefsElement.cpp
@@ -1,103 +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/Util.h"
+#include "mozilla/dom/SVGDefsElement.h"
+#include "mozilla/dom/SVGDefsElementBinding.h"
 
-#include "nsSVGGraphicElement.h"
-#include "nsIDOMSVGDefsElement.h"
-#include "DOMSVGTests.h"
+DOMCI_NODE_DATA(SVGDefsElement, mozilla::dom::SVGDefsElement)
 
-using namespace mozilla;
-
-typedef nsSVGGraphicElement nsSVGDefsElementBase;
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Defs)
 
-class nsSVGDefsElement : public nsSVGDefsElementBase,
-                         public nsIDOMSVGDefsElement,
-                         public DOMSVGTests
+namespace mozilla {
+namespace dom {
+
+JSObject*
+SVGDefsElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
 {
-protected:
-  friend nsresult NS_NewSVGDefsElement(nsIContent **aResult,
-                                       already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGDefsElement(already_AddRefed<nsINodeInfo> 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)
-
+  return SVGDefsElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGDefsElement,nsSVGDefsElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGDefsElement,nsSVGDefsElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGDefsElement, SVGGraphicsElement)
+NS_IMPL_RELEASE_INHERITED(SVGDefsElement, SVGGraphicsElement)
 
-DOMCI_NODE_DATA(SVGDefsElement, nsSVGDefsElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGDefsElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGDefsElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
+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(nsSVGDefsElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGGraphicsElement)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGDefsElement::nsSVGDefsElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGDefsElementBase(aNodeInfo)
+SVGDefsElement::SVGDefsElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGGraphicsElement(aNodeInfo)
 {
-
+  SetIsDOMBinding();
 }
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGDefsElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGDefsElement)
 
 
 //----------------------------------------------------------------------
 // nsIContent methods
 
 NS_IMETHODIMP_(bool)
-nsSVGDefsElement::IsAttributeMapped(const nsIAtom* name) const
+SVGDefsElement::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);
+    SVGGraphicsElement::IsAttributeMapped(name);
 }
+
+} // namespace dom
+} // namespace mozilla
+
copy from content/svg/content/src/nsSVGDefsElement.cpp
copy to content/svg/content/src/SVGDefsElement.h
--- a/content/svg/content/src/nsSVGDefsElement.cpp
+++ b/content/svg/content/src/SVGDefsElement.h
@@ -1,103 +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/. */
 
-#include "mozilla/Util.h"
+#ifndef mozilla_dom_SVGDefsElement_h
+#define mozilla_dom_SVGDefsElement_h
 
-#include "nsSVGGraphicElement.h"
+#include "mozilla/Util.h"
+#include "SVGGraphicsElement.h"
 #include "nsIDOMSVGDefsElement.h"
-#include "DOMSVGTests.h"
 
-using namespace mozilla;
-
-typedef nsSVGGraphicElement nsSVGDefsElementBase;
+nsresult NS_NewSVGDefsElement(nsIContent **aResult,
+                              already_AddRefed<nsINodeInfo> aNodeInfo);
 
-class nsSVGDefsElement : public nsSVGDefsElementBase,
-                         public nsIDOMSVGDefsElement,
-                         public DOMSVGTests
+namespace mozilla {
+namespace dom {
+
+class SVGDefsElement MOZ_FINAL : public SVGGraphicsElement,
+                                 public nsIDOMSVGDefsElement
 {
 protected:
-  friend nsresult NS_NewSVGDefsElement(nsIContent **aResult,
-                                       already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGDefsElement(already_AddRefed<nsINodeInfo> aNodeInfo);
-  
+  friend nsresult (::NS_NewSVGDefsElement(nsIContent **aResult,
+                                          already_AddRefed<nsINodeInfo> aNodeInfo));
+  SVGDefsElement(already_AddRefed<nsINodeInfo> 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(nsSVGDefsElementBase::)
+  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; }
 };
 
-////////////////////////////////////////////////////////////////////////
-// 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_TABLE5(nsSVGDefsElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
-                           nsIDOMSVGDefsElement)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGDefsElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGDefsElementBase)
-
-//----------------------------------------------------------------------
-// Implementation
-
-nsSVGDefsElement::nsSVGDefsElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGDefsElementBase(aNodeInfo)
-{
+} // namespace dom
+} // namespace mozilla
 
-}
-
-//----------------------------------------------------------------------
-// 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);
-}
+#endif // mozilla_dom_SVGDefsElement_h
rename from content/svg/content/src/nsSVGEllipseElement.cpp
rename to content/svg/content/src/SVGEllipseElement.cpp
--- a/content/svg/content/src/nsSVGEllipseElement.cpp
+++ b/content/svg/content/src/SVGEllipseElement.cpp
@@ -1,157 +1,152 @@
 /* -*- 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 "nsSVGPathGeometryElement.h"
-#include "nsIDOMSVGEllipseElement.h"
-#include "nsSVGLength2.h"
-#include "nsGkAtoms.h"
+#include "mozilla/dom/SVGEllipseElement.h"
+#include "mozilla/dom/SVGEllipseElementBinding.h"
 #include "gfxContext.h"
 
-using namespace mozilla;
-
-typedef nsSVGPathGeometryElement nsSVGEllipseElementBase;
+DOMCI_NODE_DATA(SVGEllipseElement, mozilla::dom::SVGEllipseElement)
 
-class nsSVGEllipseElement : public nsSVGEllipseElementBase,
-                            public nsIDOMSVGEllipseElement
-{
-protected:
-  friend nsresult NS_NewSVGEllipseElement(nsIContent **aResult,
-                                          already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGEllipseElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Ellipse)
 
-public:
-  // interfaces:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMSVGELLIPSEELEMENT
-
-  // xxx I wish we could use virtual inheritance
-  NS_FORWARD_NSIDOMNODE_TO_NSINODE
-  NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGEllipseElementBase::)
+namespace mozilla {
+namespace dom {
 
-  // nsSVGSVGElement methods:
-  virtual bool HasValidDimensions() const;
-
-  // nsSVGPathGeometryElement methods:
-  virtual void ConstructPath(gfxContext *aCtx);
-
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
-
-  virtual nsXPCClassInfo* GetClassInfo();
+JSObject*
+SVGEllipseElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return SVGEllipseElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
 
-  virtual nsIDOMNode* AsDOMNode() { return this; }
-protected:
-
-  virtual LengthAttributesInfo GetLengthInfo();
-
-  enum { CX, CY, RX, RY };
-  nsSVGLength2 mLengthAttributes[4];
-  static LengthInfo sLengthInfo[4];
-};
-
-nsSVGElement::LengthInfo nsSVGEllipseElement::sLengthInfo[4] =
+nsSVGElement::LengthInfo SVGEllipseElement::sLengthInfo[4] =
 {
   { &nsGkAtoms::cx, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::cy, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
   { &nsGkAtoms::rx, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::ry, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
 };
 
-NS_IMPL_NS_NEW_SVG_ELEMENT(Ellipse)
-
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGEllipseElement,nsSVGEllipseElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGEllipseElement,nsSVGEllipseElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGEllipseElement,SVGEllipseElementBase)
+NS_IMPL_RELEASE_INHERITED(SVGEllipseElement,SVGEllipseElementBase)
 
-DOMCI_NODE_DATA(SVGEllipseElement, nsSVGEllipseElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGEllipseElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGEllipseElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
+NS_INTERFACE_TABLE_HEAD(SVGEllipseElement)
+  NS_NODE_INTERFACE_TABLE4(SVGEllipseElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
                            nsIDOMSVGEllipseElement)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGEllipseElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGEllipseElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGEllipseElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGEllipseElement::nsSVGEllipseElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGEllipseElementBase(aNodeInfo)
+SVGEllipseElement::SVGEllipseElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGEllipseElementBase(aNodeInfo)
 {
+  SetIsDOMBinding();
 }
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGEllipseElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGEllipseElement)
 
 //----------------------------------------------------------------------
 // nsIDOMSVGEllipseElement methods
 
 /* readonly attribute nsIDOMSVGAnimatedLength cx; */
-NS_IMETHODIMP nsSVGEllipseElement::GetCx(nsIDOMSVGAnimatedLength * *aCx)
+NS_IMETHODIMP SVGEllipseElement::GetCx(nsIDOMSVGAnimatedLength * *aCx)
 {
-  return mLengthAttributes[CX].ToDOMAnimatedLength(aCx, this);
+  *aCx = Cx().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGEllipseElement::Cx()
+{
+  return mLengthAttributes[CX].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength cy; */
-NS_IMETHODIMP nsSVGEllipseElement::GetCy(nsIDOMSVGAnimatedLength * *aCy)
+NS_IMETHODIMP SVGEllipseElement::GetCy(nsIDOMSVGAnimatedLength * *aCy)
 {
-  return mLengthAttributes[CY].ToDOMAnimatedLength(aCy, this);
+  *aCy = Cy().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGEllipseElement::Cy()
+{
+  return mLengthAttributes[CY].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength rx; */
-NS_IMETHODIMP nsSVGEllipseElement::GetRx(nsIDOMSVGAnimatedLength * *aRx)
+NS_IMETHODIMP SVGEllipseElement::GetRx(nsIDOMSVGAnimatedLength * *aRx)
 {
-  return mLengthAttributes[RX].ToDOMAnimatedLength(aRx, this);
+  *aRx = Rx().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGEllipseElement::Rx()
+{
+  return mLengthAttributes[RX].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength ry; */
-NS_IMETHODIMP nsSVGEllipseElement::GetRy(nsIDOMSVGAnimatedLength * *aRy)
+NS_IMETHODIMP SVGEllipseElement::GetRy(nsIDOMSVGAnimatedLength * *aRy)
 {
-  return mLengthAttributes[RY].ToDOMAnimatedLength(aRy, this);
+  *aRy = Ry().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGEllipseElement::Ry()
+{
+  return mLengthAttributes[RY].ToDOMAnimatedLength(this);
 }
 
 //----------------------------------------------------------------------
 // nsSVGElement methods
 
 /* virtual */ bool
-nsSVGEllipseElement::HasValidDimensions() const
+SVGEllipseElement::HasValidDimensions() const
 {
   return mLengthAttributes[RX].IsExplicitlySet() &&
          mLengthAttributes[RX].GetAnimValInSpecifiedUnits() > 0 &&
          mLengthAttributes[RY].IsExplicitlySet() &&
          mLengthAttributes[RY].GetAnimValInSpecifiedUnits() > 0;
 }
 
 nsSVGElement::LengthAttributesInfo
-nsSVGEllipseElement::GetLengthInfo()
+SVGEllipseElement::GetLengthInfo()
 {
   return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
                               ArrayLength(sLengthInfo));
 }
 
 //----------------------------------------------------------------------
 // nsSVGPathGeometryElement methods
 
 void
-nsSVGEllipseElement::ConstructPath(gfxContext *aCtx)
+SVGEllipseElement::ConstructPath(gfxContext *aCtx)
 {
   float x, y, rx, ry;
 
   GetAnimatedLengthValues(&x, &y, &rx, &ry, nullptr);
 
   if (rx > 0.0f && ry > 0.0f) {
     aCtx->Save();
     aCtx->Translate(gfxPoint(x, y));
     aCtx->Scale(rx, ry);
     aCtx->Arc(gfxPoint(0, 0), 1, 0, 2 * M_PI);
     aCtx->Restore();
   }
 }
+
+} // namespace dom
+} // namespace mozilla
copy from content/svg/content/src/nsSVGEllipseElement.cpp
copy to content/svg/content/src/SVGEllipseElement.h
--- a/content/svg/content/src/nsSVGEllipseElement.cpp
+++ b/content/svg/content/src/SVGEllipseElement.h
@@ -1,157 +1,70 @@
 /* -*- 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_SVGEllipseElement_h
+#define mozilla_dom_SVGEllipseElement_h
 
 #include "nsSVGPathGeometryElement.h"
 #include "nsIDOMSVGEllipseElement.h"
 #include "nsSVGLength2.h"
-#include "nsGkAtoms.h"
-#include "gfxContext.h"
 
-using namespace mozilla;
+nsresult NS_NewSVGEllipseElement(nsIContent **aResult,
+                                 already_AddRefed<nsINodeInfo> aNodeInfo);
 
-typedef nsSVGPathGeometryElement nsSVGEllipseElementBase;
+namespace mozilla {
+namespace dom {
 
-class nsSVGEllipseElement : public nsSVGEllipseElementBase,
-                            public nsIDOMSVGEllipseElement
+typedef nsSVGPathGeometryElement SVGEllipseElementBase;
+
+class SVGEllipseElement MOZ_FINAL : public SVGEllipseElementBase,
+                                    public nsIDOMSVGEllipseElement
 {
 protected:
-  friend nsresult NS_NewSVGEllipseElement(nsIContent **aResult,
-                                          already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGEllipseElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  SVGEllipseElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE;
+  friend nsresult (::NS_NewSVGEllipseElement(nsIContent **aResult,
+                                             already_AddRefed<nsINodeInfo> aNodeInfo));
 
 public:
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMSVGELLIPSEELEMENT
 
   // xxx I wish we could use virtual inheritance
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGEllipseElementBase::)
+  NS_FORWARD_NSIDOMSVGELEMENT(SVGEllipseElementBase::)
 
   // nsSVGSVGElement methods:
   virtual bool HasValidDimensions() const;
 
   // nsSVGPathGeometryElement methods:
   virtual void ConstructPath(gfxContext *aCtx);
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
+
+  // WebIDL
+  already_AddRefed<nsIDOMSVGAnimatedLength> Cx();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Cy();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Rx();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Ry();
+
 protected:
 
   virtual LengthAttributesInfo GetLengthInfo();
 
   enum { CX, CY, RX, RY };
   nsSVGLength2 mLengthAttributes[4];
   static LengthInfo sLengthInfo[4];
 };
 
-nsSVGElement::LengthInfo nsSVGEllipseElement::sLengthInfo[4] =
-{
-  { &nsGkAtoms::cx, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
-  { &nsGkAtoms::cy, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
-  { &nsGkAtoms::rx, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
-  { &nsGkAtoms::ry, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
-};
-
-NS_IMPL_NS_NEW_SVG_ELEMENT(Ellipse)
-
-//----------------------------------------------------------------------
-// nsISupports methods
-
-NS_IMPL_ADDREF_INHERITED(nsSVGEllipseElement,nsSVGEllipseElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGEllipseElement,nsSVGEllipseElementBase)
-
-DOMCI_NODE_DATA(SVGEllipseElement, nsSVGEllipseElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGEllipseElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGEllipseElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
-                           nsIDOMSVGEllipseElement)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGEllipseElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGEllipseElementBase)
-
-//----------------------------------------------------------------------
-// Implementation
-
-nsSVGEllipseElement::nsSVGEllipseElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGEllipseElementBase(aNodeInfo)
-{
-}
-
-//----------------------------------------------------------------------
-// nsIDOMNode methods
-
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGEllipseElement)
-
-//----------------------------------------------------------------------
-// nsIDOMSVGEllipseElement methods
-
-/* readonly attribute nsIDOMSVGAnimatedLength cx; */
-NS_IMETHODIMP nsSVGEllipseElement::GetCx(nsIDOMSVGAnimatedLength * *aCx)
-{
-  return mLengthAttributes[CX].ToDOMAnimatedLength(aCx, this);
-}
+} // namespace dom
+} // namespace mozilla
 
-/* readonly attribute nsIDOMSVGAnimatedLength cy; */
-NS_IMETHODIMP nsSVGEllipseElement::GetCy(nsIDOMSVGAnimatedLength * *aCy)
-{
-  return mLengthAttributes[CY].ToDOMAnimatedLength(aCy, this);
-}
-
-/* readonly attribute nsIDOMSVGAnimatedLength rx; */
-NS_IMETHODIMP nsSVGEllipseElement::GetRx(nsIDOMSVGAnimatedLength * *aRx)
-{
-  return mLengthAttributes[RX].ToDOMAnimatedLength(aRx, this);
-}
-
-/* readonly attribute nsIDOMSVGAnimatedLength ry; */
-NS_IMETHODIMP nsSVGEllipseElement::GetRy(nsIDOMSVGAnimatedLength * *aRy)
-{
-  return mLengthAttributes[RY].ToDOMAnimatedLength(aRy, this);
-}
-
-//----------------------------------------------------------------------
-// nsSVGElement methods
-
-/* virtual */ bool
-nsSVGEllipseElement::HasValidDimensions() const
-{
-  return mLengthAttributes[RX].IsExplicitlySet() &&
-         mLengthAttributes[RX].GetAnimValInSpecifiedUnits() > 0 &&
-         mLengthAttributes[RY].IsExplicitlySet() &&
-         mLengthAttributes[RY].GetAnimValInSpecifiedUnits() > 0;
-}
-
-nsSVGElement::LengthAttributesInfo
-nsSVGEllipseElement::GetLengthInfo()
-{
-  return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
-                              ArrayLength(sLengthInfo));
-}
-
-//----------------------------------------------------------------------
-// nsSVGPathGeometryElement methods
-
-void
-nsSVGEllipseElement::ConstructPath(gfxContext *aCtx)
-{
-  float x, y, rx, ry;
-
-  GetAnimatedLengthValues(&x, &y, &rx, &ry, nullptr);
-
-  if (rx > 0.0f && ry > 0.0f) {
-    aCtx->Save();
-    aCtx->Translate(gfxPoint(x, y));
-    aCtx->Scale(rx, ry);
-    aCtx->Arc(gfxPoint(0, 0), 1, 0, 2 * M_PI);
-    aCtx->Restore();
-  }
-}
+#endif // mozilla_dom_SVGEllipseElement_h
rename from content/svg/content/src/nsSVGForeignObjectElement.cpp
rename to content/svg/content/src/SVGForeignObjectElement.cpp
--- a/content/svg/content/src/nsSVGForeignObjectElement.cpp
+++ b/content/svg/content/src/SVGForeignObjectElement.cpp
@@ -1,144 +1,187 @@
 /* -*- 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 "nsCOMPtr.h"
-#include "nsSVGForeignObjectElement.h"
+#include "mozilla/dom/SVGForeignObjectElement.h"
+#include "mozilla/dom/SVGForeignObjectElementBinding.h"
+
+DOMCI_NODE_DATA(SVGForeignObjectElement, mozilla::dom::SVGForeignObjectElement)
+
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(ForeignObject)
 
-using namespace mozilla;
+namespace mozilla {
+namespace dom {
 
-nsSVGElement::LengthInfo nsSVGForeignObjectElement::sLengthInfo[4] =
+JSObject*
+SVGForeignObjectElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return SVGForeignObjectElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
+
+nsSVGElement::LengthInfo SVGForeignObjectElement::sLengthInfo[4] =
 {
   { &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
   { &nsGkAtoms::width, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::height, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
 };
 
-NS_IMPL_NS_NEW_SVG_ELEMENT(ForeignObject)
-
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGForeignObjectElement,nsSVGForeignObjectElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGForeignObjectElement,nsSVGForeignObjectElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGForeignObjectElement, SVGGraphicsElement)
+NS_IMPL_RELEASE_INHERITED(SVGForeignObjectElement, SVGGraphicsElement)
 
-DOMCI_NODE_DATA(SVGForeignObjectElement, nsSVGForeignObjectElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGForeignObjectElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGForeignObjectElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
+NS_INTERFACE_TABLE_HEAD(SVGForeignObjectElement)
+  NS_NODE_INTERFACE_TABLE4(SVGForeignObjectElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
                            nsIDOMSVGForeignObjectElement)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGForeignObjectElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGForeignObjectElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGGraphicsElement)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGForeignObjectElement::nsSVGForeignObjectElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGForeignObjectElementBase(aNodeInfo)
+SVGForeignObjectElement::SVGForeignObjectElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGGraphicsElement(aNodeInfo)
 {
+  SetIsDOMBinding();
 }
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGForeignObjectElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGForeignObjectElement)
 
 //----------------------------------------------------------------------
 // nsIDOMSVGForeignObjectElement methods:
 
 /* readonly attribute nsIDOMSVGAnimatedLength x; */
-NS_IMETHODIMP nsSVGForeignObjectElement::GetX(nsIDOMSVGAnimatedLength * *aX)
+NS_IMETHODIMP SVGForeignObjectElement::GetX(nsIDOMSVGAnimatedLength * *aX)
 {
-  return mLengthAttributes[X].ToDOMAnimatedLength(aX, this);
+  *aX = X().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGForeignObjectElement::X()
+{
+  return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength y; */
-NS_IMETHODIMP nsSVGForeignObjectElement::GetY(nsIDOMSVGAnimatedLength * *aY)
+NS_IMETHODIMP SVGForeignObjectElement::GetY(nsIDOMSVGAnimatedLength * *aY)
 {
-  return mLengthAttributes[Y].ToDOMAnimatedLength(aY, this);
+  *aY = Y().get();
+  return NS_OK;
 }
 
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGForeignObjectElement::Y()
+{
+  return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
+}
+
+
 /* readonly attribute nsIDOMSVGAnimatedLength width; */
-NS_IMETHODIMP nsSVGForeignObjectElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
+NS_IMETHODIMP SVGForeignObjectElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
 {
-  return mLengthAttributes[WIDTH].ToDOMAnimatedLength(aWidth, this);
+  *aWidth = Width().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGForeignObjectElement::Width()
+{
+  return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
 }
 
+
 /* readonly attribute nsIDOMSVGAnimatedLength height; */
-NS_IMETHODIMP nsSVGForeignObjectElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
+NS_IMETHODIMP SVGForeignObjectElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
 {
-  return mLengthAttributes[HEIGHT].ToDOMAnimatedLength(aHeight, this);
+  *aHeight = Height().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGForeignObjectElement::Height()
+{
+  return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
 }
 
 //----------------------------------------------------------------------
 // nsSVGElement methods
 
 /* virtual */ gfxMatrix
-nsSVGForeignObjectElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
-                                                    TransformTypes aWhich) const
+SVGForeignObjectElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
+                                                  TransformTypes aWhich) const
 {
   NS_ABORT_IF_FALSE(aWhich != eChildToUserSpace || aMatrix.IsIdentity(),
                     "Skipping eUserSpaceToParent transforms makes no sense");
 
   // 'transform' attribute:
   gfxMatrix fromUserSpace =
-    nsSVGForeignObjectElementBase::PrependLocalTransformsTo(aMatrix, aWhich);
+    SVGGraphicsElement::PrependLocalTransformsTo(aMatrix, aWhich);
   if (aWhich == eUserSpaceToParent) {
     return fromUserSpace;
   }
   // our 'x' and 'y' attributes:
   float x, y;
-  const_cast<nsSVGForeignObjectElement*>(this)->
+  const_cast<SVGForeignObjectElement*>(this)->
     GetAnimatedLengthValues(&x, &y, nullptr);
   gfxMatrix toUserSpace = gfxMatrix().Translate(gfxPoint(x, y));
   if (aWhich == eChildToUserSpace) {
     return toUserSpace;
   }
   NS_ABORT_IF_FALSE(aWhich == eAllTransforms, "Unknown TransformTypes");
   return toUserSpace * fromUserSpace;
 }
 
 /* virtual */ bool
-nsSVGForeignObjectElement::HasValidDimensions() const
+SVGForeignObjectElement::HasValidDimensions() const
 {
-  return mLengthAttributes[WIDTH].IsExplicitlySet() &&
-         mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
-         mLengthAttributes[HEIGHT].IsExplicitlySet() &&
-         mLengthAttributes[HEIGHT].GetAnimValInSpecifiedUnits() > 0;
+  return mLengthAttributes[ATTR_WIDTH].IsExplicitlySet() &&
+         mLengthAttributes[ATTR_WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
+         mLengthAttributes[ATTR_HEIGHT].IsExplicitlySet() &&
+         mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0;
 }
 
 //----------------------------------------------------------------------
 // nsIContent methods
 
 NS_IMETHODIMP_(bool)
-nsSVGForeignObjectElement::IsAttributeMapped(const nsIAtom* name) const
+SVGForeignObjectElement::IsAttributeMapped(const nsIAtom* name) const
 {
   static const MappedAttributeEntry* const map[] = {
     sFEFloodMap,
     sFiltersMap,
     sFontSpecificationMap,
     sGradientStopMap,
     sLightingEffectsMap,
     sMarkersMap,
     sTextContentElementsMap,
     sViewportsMap
   };
 
   return FindAttributeDependence(name, map) ||
-    nsSVGForeignObjectElementBase::IsAttributeMapped(name);
+    SVGGraphicsElement::IsAttributeMapped(name);
 }
 
 //----------------------------------------------------------------------
 // nsSVGElement methods
 
 nsSVGElement::LengthAttributesInfo
-nsSVGForeignObjectElement::GetLengthInfo()
+SVGForeignObjectElement::GetLengthInfo()
 {
   return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
                               ArrayLength(sLengthInfo));
 }
+
+} // namespace dom
+} // namespace mozilla
+
new file mode 100644
--- /dev/null
+++ b/content/svg/content/src/SVGForeignObjectElement.h
@@ -0,0 +1,76 @@
+/* -*- 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_SVGForeignObjectElement_h
+#define mozilla_dom_SVGForeignObjectElement_h
+
+#include "mozilla/dom/SVGGraphicsElement.h"
+#include "nsIDOMSVGForeignObjectElem.h"
+#include "nsSVGLength2.h"
+
+nsresult NS_NewSVGForeignObjectElement(nsIContent **aResult,
+                                       already_AddRefed<nsINodeInfo> aNodeInfo);
+
+class nsSVGForeignObjectFrame;
+
+namespace mozilla {
+namespace dom {
+
+class SVGForeignObjectElement MOZ_FINAL : public SVGGraphicsElement,
+                                          public nsIDOMSVGForeignObjectElement
+{
+  friend class ::nsSVGForeignObjectFrame;
+
+protected:
+  friend nsresult (::NS_NewSVGForeignObjectElement(nsIContent **aResult,
+                                                   already_AddRefed<nsINodeInfo> aNodeInfo));
+  SVGForeignObjectElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE;
+
+public:
+  // interfaces:
+
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_NSIDOMSVGFOREIGNOBJECTELEMENT
+
+  // xxx I wish we could use virtual inheritance
+  NS_FORWARD_NSIDOMNODE_TO_NSINODE
+  NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMSVGELEMENT(SVGGraphicsElement::)
+
+  // nsSVGElement specializations:
+  virtual gfxMatrix PrependLocalTransformsTo(const gfxMatrix &aMatrix,
+                      TransformTypes aWhich = eAllTransforms) const;
+  virtual bool HasValidDimensions() const;
+
+  // nsIContent interface
+  NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const;
+
+  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
+
+  virtual nsXPCClassInfo* GetClassInfo();
+
+  virtual nsIDOMNode* AsDOMNode() { return this; }
+
+  // WebIDL
+  already_AddRefed<nsIDOMSVGAnimatedLength> X();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Y();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Width();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Height();
+
+protected:
+
+  virtual LengthAttributesInfo GetLengthInfo();
+
+  enum { ATTR_X, ATTR_Y, ATTR_WIDTH, ATTR_HEIGHT };
+  nsSVGLength2 mLengthAttributes[4];
+  static LengthInfo sLengthInfo[4];
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_SVGForeignObjectElement_h
+
rename from content/svg/content/src/nsSVGGElement.cpp
rename to content/svg/content/src/SVGGElement.cpp
--- a/content/svg/content/src/nsSVGGElement.cpp
+++ b/content/svg/content/src/SVGGElement.cpp
@@ -1,104 +1,75 @@
 /* -*- 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 "mozilla/dom/SVGGElement.h"
+#include "mozilla/dom/SVGGElementBinding.h"
 
-#include "nsSVGGraphicElement.h"
-#include "nsIDOMSVGGElement.h"
-#include "DOMSVGTests.h"
+DOMCI_NODE_DATA(SVGGElement, mozilla::dom::SVGGElement)
 
-using namespace mozilla;
-
-typedef nsSVGGraphicElement nsSVGGElementBase;
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(G)
 
-class nsSVGGElement : public nsSVGGElementBase,
-                      public nsIDOMSVGGElement,
-                      public DOMSVGTests
+namespace mozilla {
+namespace dom {
+
+JSObject*
+SVGGElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
 {
-protected:
-  friend nsresult NS_NewSVGGElement(nsIContent **aResult,
-                                    already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGGElement(already_AddRefed<nsINodeInfo> aNodeInfo);
-  
-public:
-  // interfaces:
-  
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMSVGGELEMENT
-
-  // xxx I wish we could use virtual inheritance
-  NS_FORWARD_NSIDOMNODE_TO_NSINODE
-  NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGGElementBase::)
-
-  // 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(G)
-
+  return SVGGElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGGElement,nsSVGGElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGGElement,nsSVGGElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGGElement, SVGGraphicsElement)
+NS_IMPL_RELEASE_INHERITED(SVGGElement, SVGGraphicsElement)
 
-DOMCI_NODE_DATA(SVGGElement, nsSVGGElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGGElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGGElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
+NS_INTERFACE_TABLE_HEAD(SVGGElement)
+  NS_NODE_INTERFACE_TABLE4(SVGGElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
                            nsIDOMSVGGElement)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGGElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGGElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGGraphicsElement)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGGElement::nsSVGGElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGGElementBase(aNodeInfo)
+SVGGElement::SVGGElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGGraphicsElement(aNodeInfo)
 {
-
+  SetIsDOMBinding();
 }
 
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGGElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGGElement)
 
 
 //----------------------------------------------------------------------
 // nsIContent methods
 
 NS_IMETHODIMP_(bool)
-nsSVGGElement::IsAttributeMapped(const nsIAtom* name) const
+SVGGElement::IsAttributeMapped(const nsIAtom* name) const
 {
   static const MappedAttributeEntry* const map[] = {
     sFEFloodMap,
     sFiltersMap,
     sFontSpecificationMap,
     sGradientStopMap,
     sLightingEffectsMap,
     sMarkersMap,
     sTextContentElementsMap,
     sViewportsMap
   };
-  
+
   return FindAttributeDependence(name, map) ||
-    nsSVGGElementBase::IsAttributeMapped(name);
+    SVGGraphicsElement::IsAttributeMapped(name);
 }
+
+} // namespace dom
+} // namespace mozilla
+
copy from content/svg/content/src/nsSVGGElement.cpp
copy to content/svg/content/src/SVGGElement.h
--- a/content/svg/content/src/nsSVGGElement.cpp
+++ b/content/svg/content/src/SVGGElement.h
@@ -1,104 +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/. */
 
-#include "mozilla/Util.h"
+#ifndef mozilla_dom_SVGGElement_h
+#define mozilla_dom_SVGGElement_h
 
-#include "nsSVGGraphicElement.h"
+#include "mozilla/Util.h"
+#include "mozilla/dom/SVGGraphicsElement.h"
 #include "nsIDOMSVGGElement.h"
-#include "DOMSVGTests.h"
 
-using namespace mozilla;
-
-typedef nsSVGGraphicElement nsSVGGElementBase;
+nsresult NS_NewSVGGElement(nsIContent **aResult,
+                           already_AddRefed<nsINodeInfo> aNodeInfo);
 
-class nsSVGGElement : public nsSVGGElementBase,
-                      public nsIDOMSVGGElement,
-                      public DOMSVGTests
+namespace mozilla {
+namespace dom {
+
+class SVGGElement MOZ_FINAL : public SVGGraphicsElement,
+                              public nsIDOMSVGGElement
 {
 protected:
-  friend nsresult NS_NewSVGGElement(nsIContent **aResult,
-                                    already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGGElement(already_AddRefed<nsINodeInfo> aNodeInfo);
-  
+  SVGGElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE;
+  friend nsresult (::NS_NewSVGGElement(nsIContent **aResult,
+                                       already_AddRefed<nsINodeInfo> aNodeInfo));
+
 public:
   // interfaces:
-  
+
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMSVGGELEMENT
 
   // xxx I wish we could use virtual inheritance
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGGElementBase::)
+  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; }
 };
 
-////////////////////////////////////////////////////////////////////////
-// implementation
-
-
-NS_IMPL_NS_NEW_SVG_ELEMENT(G)
-
-
-//----------------------------------------------------------------------
-// nsISupports methods
-
-NS_IMPL_ADDREF_INHERITED(nsSVGGElement,nsSVGGElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGGElement,nsSVGGElementBase)
-
-DOMCI_NODE_DATA(SVGGElement, nsSVGGElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGGElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGGElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
-                           nsIDOMSVGGElement)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGGElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGGElementBase)
-
-//----------------------------------------------------------------------
-// Implementation
-
-nsSVGGElement::nsSVGGElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGGElementBase(aNodeInfo)
-{
+} // namespace dom
+} // namespace mozilla
 
-}
-
-
-//----------------------------------------------------------------------
-// nsIDOMNode methods
-
-
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGGElement)
-
-
-//----------------------------------------------------------------------
-// nsIContent methods
-
-NS_IMETHODIMP_(bool)
-nsSVGGElement::IsAttributeMapped(const nsIAtom* name) const
-{
-  static const MappedAttributeEntry* const map[] = {
-    sFEFloodMap,
-    sFiltersMap,
-    sFontSpecificationMap,
-    sGradientStopMap,
-    sLightingEffectsMap,
-    sMarkersMap,
-    sTextContentElementsMap,
-    sViewportsMap
-  };
-  
-  return FindAttributeDependence(name, map) ||
-    nsSVGGElementBase::IsAttributeMapped(name);
-}
+#endif // mozilla_dom_SVGGElement_h
rename from content/svg/content/src/nsSVGGraphicElement.cpp
rename to content/svg/content/src/SVGGraphicsElement.cpp
--- a/content/svg/content/src/nsSVGGraphicElement.cpp
+++ b/content/svg/content/src/SVGGraphicsElement.cpp
@@ -1,246 +1,37 @@
 /* -*- 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 "mozilla/dom/SVGGraphicsElement.h"
+#include "mozilla/dom/SVGGraphicsElementBinding.h"
+
+namespace mozilla {
+namespace dom {
 
-#include "nsSVGGraphicElement.h"
-#include "nsSVGSVGElement.h"
-#include "DOMSVGAnimatedTransformList.h"
-#include "DOMSVGMatrix.h"
-#include "nsGkAtoms.h"
-#include "nsIDOMEventTarget.h"
-#include "nsIDOMMutationEvent.h"
-#include "nsIFrame.h"
-#include "nsISVGChildFrame.h"
-#include "nsSVGUtils.h"
-#include "nsError.h"
-#include "nsSVGRect.h"
-#include "nsContentUtils.h"
-
-using namespace mozilla;
+JSObject*
+SVGGraphicsElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return SVGGraphicsElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGGraphicElement, nsSVGGraphicElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGGraphicElement, nsSVGGraphicElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGGraphicsElement, SVGGraphicsElementBase)
+NS_IMPL_RELEASE_INHERITED(SVGGraphicsElement, SVGGraphicsElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGGraphicElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGLocatable)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTransformable)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGGraphicElementBase)
+NS_INTERFACE_MAP_BEGIN(SVGGraphicsElement)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTests)
+NS_INTERFACE_MAP_END_INHERITING(SVGGraphicsElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGGraphicElement::nsSVGGraphicElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGGraphicElementBase(aNodeInfo)
+SVGGraphicsElement::SVGGraphicsElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGGraphicsElementBase(aNodeInfo)
 {
 }
 
-//----------------------------------------------------------------------
-// nsIDOMSVGLocatable methods
-
-/* readonly attribute nsIDOMSVGElement nearestViewportElement; */
-NS_IMETHODIMP nsSVGGraphicElement::GetNearestViewportElement(nsIDOMSVGElement * *aNearestViewportElement)
-{
-  *aNearestViewportElement = SVGContentUtils::GetNearestViewportElement(this).get();
-  return NS_OK;
-}
-
-/* readonly attribute nsIDOMSVGElement farthestViewportElement; */
-NS_IMETHODIMP nsSVGGraphicElement::GetFarthestViewportElement(nsIDOMSVGElement * *aFarthestViewportElement)
-{
-  NS_IF_ADDREF(*aFarthestViewportElement = SVGContentUtils::GetOuterSVGElement(this));
-  return NS_OK;
-}
-
-/* nsIDOMSVGRect getBBox (); */
-NS_IMETHODIMP nsSVGGraphicElement::GetBBox(nsIDOMSVGRect **_retval)
-{
-  *_retval = nullptr;
-
-  nsIFrame* frame = GetPrimaryFrame(Flush_Layout);
-
-  if (!frame || (frame->GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD))
-    return NS_ERROR_FAILURE;
-
-  nsISVGChildFrame* svgframe = do_QueryFrame(frame);
-  if (svgframe) {
-    return NS_NewSVGRect(_retval, nsSVGUtils::GetBBox(frame));
-  }
-  return NS_ERROR_FAILURE;
-}
-
-/* DOMSVGMatrix getCTM (); */
-NS_IMETHODIMP nsSVGGraphicElement::GetCTM(nsISupports * *aCTM)
-{
-  gfxMatrix m = SVGContentUtils::GetCTM(this, false);
-  *aCTM = m.IsSingular() ? nullptr : new DOMSVGMatrix(m);
-  NS_IF_ADDREF(*aCTM);
-  return NS_OK;
-}
-
-/* DOMSVGMatrix getScreenCTM (); */
-NS_IMETHODIMP nsSVGGraphicElement::GetScreenCTM(nsISupports * *aCTM)
-{
-  gfxMatrix m = SVGContentUtils::GetCTM(this, true);
-  *aCTM = m.IsSingular() ? nullptr : new DOMSVGMatrix(m);
-  NS_IF_ADDREF(*aCTM);
-  return NS_OK;
-}
-
-/* DOMSVGMatrix getTransformToElement (in nsIDOMSVGElement element); */
-NS_IMETHODIMP nsSVGGraphicElement::GetTransformToElement(nsIDOMSVGElement *element, nsISupports **_retval)
-{
-  if (!element)
-    return NS_ERROR_DOM_SVG_WRONG_TYPE_ERR;
-
-  nsresult rv;
-  *_retval = nullptr;
-  nsCOMPtr<DOMSVGMatrix> ourScreenCTM;
-  nsCOMPtr<DOMSVGMatrix> targetScreenCTM;
-  nsCOMPtr<nsIDOMSVGLocatable> target = do_QueryInterface(element, &rv);
-  if (NS_FAILED(rv)) return rv;
-
-  // the easiest way to do this (if likely to increase rounding error):
-  GetScreenCTM(getter_AddRefs(ourScreenCTM));
-  if (!ourScreenCTM) return NS_ERROR_DOM_SVG_MATRIX_NOT_INVERTABLE;
-  target->GetScreenCTM(getter_AddRefs(targetScreenCTM));
-  if (!targetScreenCTM) return NS_ERROR_DOM_SVG_MATRIX_NOT_INVERTABLE;
-  ErrorResult result;
-  nsCOMPtr<DOMSVGMatrix> tmp = targetScreenCTM->Inverse(result);
-  if (result.Failed()) return result.ErrorCode();
-  *_retval = tmp->Multiply(*ourScreenCTM).get(); // addrefs, so we don't
-  return NS_OK;
-}
-
-//----------------------------------------------------------------------
-// nsIDOMSVGTransformable methods
-/* readonly attribute nsISupports transform; */
-
-NS_IMETHODIMP nsSVGGraphicElement::GetTransform(nsISupports **aTransform)
-{
-  // We're creating a DOM wrapper, so we must tell GetAnimatedTransformList
-  // to allocate the SVGAnimatedTransformList if it hasn't already done so:
-  *aTransform = DOMSVGAnimatedTransformList::GetDOMWrapper(
-                  GetAnimatedTransformList(DO_ALLOCATE), this).get();
-  return NS_OK;
-}
-
-//----------------------------------------------------------------------
-// nsIContent methods
-
-NS_IMETHODIMP_(bool)
-nsSVGGraphicElement::IsAttributeMapped(const nsIAtom* name) const
-{
-  static const MappedAttributeEntry* const map[] = {
-    sColorMap,
-    sFillStrokeMap,
-    sGraphicsMap
-  };
-  
-  return FindAttributeDependence(name, map) ||
-    nsSVGGraphicElementBase::IsAttributeMapped(name);
-}
-
-nsChangeHint
-nsSVGGraphicElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
-                                            int32_t aModType) const
-{
-  nsChangeHint retval =
-    nsSVGGraphicElementBase::GetAttributeChangeHint(aAttribute, aModType);
-  if (aAttribute == nsGkAtoms::transform ||
-      aAttribute == nsGkAtoms::mozAnimateMotionDummyAttr) {
-    // We add nsChangeHint_UpdateOverflow so that nsFrame::UpdateOverflow()
-    // will be called on us and our ancestors.
-    nsIFrame* frame =
-      const_cast<nsSVGGraphicElement*>(this)->GetPrimaryFrame();
-    if (!frame || (frame->GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD)) {
-      return retval; // no change
-    }
-    if (aModType == nsIDOMMutationEvent::ADDITION ||
-        aModType == nsIDOMMutationEvent::REMOVAL) {
-      // Reconstruct the frame tree to handle stacking context changes:
-      NS_UpdateHint(retval, nsChangeHint_ReconstructFrame);
-    } else {
-      NS_ABORT_IF_FALSE(aModType == nsIDOMMutationEvent::MODIFICATION,
-                        "Unknown modification type.");
-      // We just assume the old and new transforms are different.
-      NS_UpdateHint(retval, NS_CombineHint(nsChangeHint_UpdateOverflow,
-                                           nsChangeHint_UpdateTransformLayer));
-    }
-  }
-  return retval;
-}
-
-bool
-nsSVGGraphicElement::IsEventAttributeName(nsIAtom* aName)
-{
-  return nsContentUtils::IsEventAttributeName(aName, EventNameType_SVGGraphic);
-}
-
-//----------------------------------------------------------------------
-// nsSVGElement overrides
-
-gfxMatrix
-nsSVGGraphicElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
-                                              TransformTypes aWhich) const
-{
-  NS_ABORT_IF_FALSE(aWhich != eChildToUserSpace || aMatrix.IsIdentity(),
-                    "Skipping eUserSpaceToParent transforms makes no sense");
-
-  gfxMatrix result(aMatrix);
-
-  if (aWhich == eChildToUserSpace) {
-    // We don't have anything to prepend.
-    // eChildToUserSpace is not the common case, which is why we return
-    // 'result' to benefit from NRVO rather than returning aMatrix before
-    // creating 'result'.
-    return result;
-  }
-
-  NS_ABORT_IF_FALSE(aWhich == eAllTransforms || aWhich == eUserSpaceToParent,
-                    "Unknown TransformTypes");
-
-  // animateMotion's resulting transform is supposed to apply *on top of*
-  // any transformations from the |transform| attribute. So since we're
-  // PRE-multiplying, we need to apply the animateMotion transform *first*.
-  if (mAnimateMotionTransform) {
-    result.PreMultiply(*mAnimateMotionTransform);
-  }
-
-  if (mTransforms) {
-    result.PreMultiply(mTransforms->GetAnimValue().GetConsolidationMatrix());
-  }
-
-  return result;
-}
-
-const gfxMatrix*
-nsSVGGraphicElement::GetAnimateMotionTransform() const
-{
-  return mAnimateMotionTransform.get();
-}
-
-void
-nsSVGGraphicElement::SetAnimateMotionTransform(const gfxMatrix* aMatrix)
-{
-  if ((!aMatrix && !mAnimateMotionTransform) ||
-      (aMatrix && mAnimateMotionTransform && *aMatrix == *mAnimateMotionTransform)) {
-    return;
-  }
-  mAnimateMotionTransform = aMatrix ? new gfxMatrix(*aMatrix) : nullptr;
-  DidAnimateTransformList();
-}
-
-SVGAnimatedTransformList*
-nsSVGGraphicElement::GetAnimatedTransformList(uint32_t aFlags)
-{
-  if (!mTransforms && (aFlags & DO_ALLOCATE)) {
-    mTransforms = new SVGAnimatedTransformList();
-  }
-  return mTransforms;
-}
+} // namespace dom
+} // namespace mozilla
rename from content/svg/content/src/nsSVGGraphicElement.h
rename to content/svg/content/src/SVGGraphicsElement.h
--- a/content/svg/content/src/nsSVGGraphicElement.h
+++ b/content/svg/content/src/SVGGraphicsElement.h
@@ -1,59 +1,45 @@
 /* -*- 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 __NS_SVGGRAPHICELEMENT_H__
-#define __NS_SVGGRAPHICELEMENT_H__
+#ifndef mozilla_dom_SVGGraphicsElement_h
+#define mozilla_dom_SVGGraphicsElement_h
+
+#include "mozilla/dom/SVGTransformableElement.h"
+#include "DOMSVGTests.h"
 
-#include "gfxMatrix.h"
-#include "nsIDOMSVGLocatable.h"
-#include "nsIDOMSVGTransformable.h"
-#include "nsSVGElement.h"
-#include "SVGAnimatedTransformList.h"
+#define MOZILLA_SVGGRAPHICSELEMENT_IID \
+  { 0xe57b8fe5, 0x9088, 0x446e, \
+    {0xa1, 0x87, 0xd1, 0xdb, 0xbb, 0x58, 0xce, 0xdc}}
 
-typedef nsSVGElement nsSVGGraphicElementBase;
+namespace mozilla {
+namespace dom {
 
-class nsSVGGraphicElement : public nsSVGGraphicElementBase,
-                            public nsIDOMSVGTransformable // : nsIDOMSVGLocatable
+typedef SVGTransformableElement SVGGraphicsElementBase;
+
+class SVGGraphicsElement : public SVGGraphicsElementBase,
+                           public DOMSVGTests
 {
 protected:
-  nsSVGGraphicElement(already_AddRefed<nsINodeInfo> aNodeInfo);
-  
-public:
-  // interfaces:  
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMSVGLOCATABLE
-  NS_DECL_NSIDOMSVGTRANSFORMABLE
-
-  // nsIContent interface
-  NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
-
-  nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
-                                      int32_t aModType) const;
+  SVGGraphicsElement(already_AddRefed<nsINodeInfo> aNodeInfo);
 
-
-  virtual bool IsEventAttributeName(nsIAtom* aName) MOZ_OVERRIDE;
-
-
-  virtual gfxMatrix PrependLocalTransformsTo(const gfxMatrix &aMatrix,
-                      TransformTypes aWhich = eAllTransforms) const;
-  virtual const gfxMatrix* GetAnimateMotionTransform() const;
-  virtual void SetAnimateMotionTransform(const gfxMatrix* aMatrix);
-
-  virtual mozilla::SVGAnimatedTransformList*
-    GetAnimatedTransformList(uint32_t aFlags = 0);
-  virtual nsIAtom* GetTransformListAttrName() const {
-    return nsGkAtoms::transform;
-  }
+public:
+  // interfaces:
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_SVGGRAPHICSELEMENT_IID)
+  NS_FORWARD_NSIDOMSVGLOCATABLE(SVGLocatableElement::)
+  NS_FORWARD_NSIDOMSVGTRANSFORMABLE(SVGTransformableElement::)
 
 protected:
-  // nsSVGElement overrides
+  virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE;
 
-  nsAutoPtr<mozilla::SVGAnimatedTransformList> mTransforms;
-
-  // XXX maybe move this to property table, to save space on un-animated elems?
-  nsAutoPtr<gfxMatrix> mAnimateMotionTransform;
 };
 
-#endif // __NS_SVGGRAPHICELEMENT_H__
+NS_DEFINE_STATIC_IID_ACCESSOR(SVGGraphicsElement,
+                              MOZILLA_SVGGRAPHICSELEMENT_IID)
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_SVGGraphicsElement_h
rename from content/svg/content/src/nsSVGImageElement.cpp
rename to content/svg/content/src/SVGImageElement.cpp
--- a/content/svg/content/src/nsSVGImageElement.cpp
+++ b/content/svg/content/src/SVGImageElement.cpp
@@ -1,129 +1,183 @@
 /* -*- 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 "nsSVGImageElement.h"
+#include "mozilla/dom/SVGImageElement.h"
 #include "nsCOMPtr.h"
 #include "nsIURI.h"
 #include "nsNetUtil.h"
 #include "imgIContainer.h"
 #include "imgINotificationObserver.h"
 #include "gfxContext.h"
+#include "mozilla/dom/SVGImageElementBinding.h"
 
-using namespace mozilla;
-using namespace mozilla::dom;
+DOMCI_NODE_DATA(SVGImageElement, mozilla::dom::SVGImageElement)
+
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Image)
+
+namespace mozilla {
+namespace dom {
 
-nsSVGElement::LengthInfo nsSVGImageElement::sLengthInfo[4] =
+JSObject*
+SVGImageElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return SVGImageElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
+
+nsSVGElement::LengthInfo SVGImageElement::sLengthInfo[4] =
 {
   { &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
   { &nsGkAtoms::width, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::height, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
 };
 
-nsSVGElement::StringInfo nsSVGImageElement::sStringInfo[1] =
+nsSVGElement::StringInfo SVGImageElement::sStringInfo[1] =
 {
   { &nsGkAtoms::href, kNameSpaceID_XLink, true }
 };
 
-NS_IMPL_NS_NEW_SVG_ELEMENT(Image)
-
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGImageElement,nsSVGImageElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGImageElement,nsSVGImageElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGImageElement,SVGImageElementBase)
+NS_IMPL_RELEASE_INHERITED(SVGImageElement,SVGImageElementBase)
 
-DOMCI_NODE_DATA(SVGImageElement, nsSVGImageElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGImageElement)
-  NS_NODE_INTERFACE_TABLE9(nsSVGImageElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
+NS_INTERFACE_TABLE_HEAD(SVGImageElement)
+  NS_NODE_INTERFACE_TABLE8(SVGImageElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
                            nsIDOMSVGImageElement,
                            nsIDOMSVGURIReference, imgINotificationObserver,
                            nsIImageLoadingContent, imgIOnloadBlocker)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGImageElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGImageElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGImageElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGImageElement::nsSVGImageElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGImageElementBase(aNodeInfo)
+SVGImageElement::SVGImageElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGImageElementBase(aNodeInfo)
 {
+  SetIsDOMBinding();
   // We start out broken
   AddStatesSilently(NS_EVENT_STATE_BROKEN);
 }
 
-nsSVGImageElement::~nsSVGImageElement()
+SVGImageElement::~SVGImageElement()
 {
   DestroyImageLoadingContent();
 }
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGImageElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGImageElement)
 
 
 //----------------------------------------------------------------------
 // nsIDOMSVGImageElement methods:
 
 /* readonly attribute nsIDOMSVGAnimatedLength x; */
-NS_IMETHODIMP nsSVGImageElement::GetX(nsIDOMSVGAnimatedLength * *aX)
+NS_IMETHODIMP SVGImageElement::GetX(nsIDOMSVGAnimatedLength * *aX)
 {
-  return mLengthAttributes[X].ToDOMAnimatedLength(aX, this);
+  *aX = X().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGImageElement::X()
+{
+  return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength y; */
-NS_IMETHODIMP nsSVGImageElement::GetY(nsIDOMSVGAnimatedLength * *aY)
+NS_IMETHODIMP SVGImageElement::GetY(nsIDOMSVGAnimatedLength * *aY)
 {
-  return mLengthAttributes[Y].ToDOMAnimatedLength(aY, this);
+  *aY = Y().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGImageElement::Y()
+{
+  return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength width; */
-NS_IMETHODIMP nsSVGImageElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
+NS_IMETHODIMP SVGImageElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
 {
-  return mLengthAttributes[WIDTH].ToDOMAnimatedLength(aWidth, this);
+  *aWidth = Width().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGImageElement::Width()
+{
+  return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength height; */
-NS_IMETHODIMP nsSVGImageElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
+NS_IMETHODIMP SVGImageElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
 {
-  return mLengthAttributes[HEIGHT].ToDOMAnimatedLength(aHeight, this);
+  *aHeight = Height().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGImageElement::Height()
+{
+  return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute SVGPreserveAspectRatio preserveAspectRatio; */
 NS_IMETHODIMP
-nsSVGImageElement::GetPreserveAspectRatio(nsISupports
-                                          **aPreserveAspectRatio)
+SVGImageElement::GetPreserveAspectRatio(nsISupports
+                                        **aPreserveAspectRatio)
 {
-  return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(aPreserveAspectRatio, this);
+  *aPreserveAspectRatio = PreserveAspectRatio().get();
+  return NS_OK;
+}
+
+already_AddRefed<DOMSVGAnimatedPreserveAspectRatio>
+SVGImageElement::PreserveAspectRatio()
+{
+  nsRefPtr<DOMSVGAnimatedPreserveAspectRatio> ratio;
+  mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this);
+  return ratio.forget();
 }
 
 //----------------------------------------------------------------------
 // nsIDOMSVGURIReference methods:
 
 /* readonly attribute nsIDOMSVGAnimatedString href; */
 NS_IMETHODIMP
-nsSVGImageElement::GetHref(nsIDOMSVGAnimatedString * *aHref)
+SVGImageElement::GetHref(nsIDOMSVGAnimatedString * *aHref)
 {
-  return mStringAttributes[HREF].ToDOMAnimatedString(aHref, this);
+  *aHref = Href().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedString>
+SVGImageElement::Href()
+{
+  nsCOMPtr<nsIDOMSVGAnimatedString> href;
+  mStringAttributes[HREF].ToDOMAnimatedString(getter_AddRefs(href), this);
+  return href.forget();;
 }
 
 //----------------------------------------------------------------------
 
 nsresult
-nsSVGImageElement::LoadSVGImage(bool aForce, bool aNotify)
+SVGImageElement::LoadSVGImage(bool aForce, bool aNotify)
 {
   // resolve href attribute
   nsCOMPtr<nsIURI> baseURI = GetBaseURI();
 
   nsAutoString href;
   mStringAttributes[HREF].GetAnimValue(href, this);
   href.Trim(" \t\n\r");
 
@@ -132,18 +186,18 @@ nsSVGImageElement::LoadSVGImage(bool aFo
 
   return LoadImage(href, aForce, aNotify);
 }
 
 //----------------------------------------------------------------------
 // nsIContent methods:
 
 nsresult
-nsSVGImageElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
-                                const nsAttrValue* aValue, bool aNotify)
+SVGImageElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
+                              const nsAttrValue* aValue, bool aNotify)
 {
   if (aNamespaceID == kNameSpaceID_XLink && aName == nsGkAtoms::href) {
 
     // If there isn't a frame we still need to load the image in case
     // the frame is created later e.g. by attaching to a document.
     // If there is a frame then it should deal with loading as the image
     // url may be animated
     if (!GetPrimaryFrame()) {
@@ -155,130 +209,134 @@ nsSVGImageElement::AfterSetAttr(int32_t 
 
       if (aValue) {
         LoadSVGImage(true, aNotify);
       } else {
         CancelImageRequests(aNotify);
       }
     }
   }
-  return nsSVGImageElementBase::AfterSetAttr(aNamespaceID, aName,
-                                             aValue, aNotify);
+  return SVGImageElementBase::AfterSetAttr(aNamespaceID, aName,
+                                           aValue, aNotify);
 }
 
 void
-nsSVGImageElement::MaybeLoadSVGImage()
+SVGImageElement::MaybeLoadSVGImage()
 {
   if (mStringAttributes[HREF].IsExplicitlySet() &&
       (NS_FAILED(LoadSVGImage(false, true)) ||
        !LoadingEnabled())) {
     CancelImageRequests(true);
   }
 }
 
 nsresult
-nsSVGImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
-                              nsIContent* aBindingParent,
-                              bool aCompileEventHandlers)
+SVGImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
+                            nsIContent* aBindingParent,
+                            bool aCompileEventHandlers)
 {
-  nsresult rv = nsSVGImageElementBase::BindToTree(aDocument, aParent,
-                                                  aBindingParent,
-                                                  aCompileEventHandlers);
+  nsresult rv = SVGImageElementBase::BindToTree(aDocument, aParent,
+                                                aBindingParent,
+                                                aCompileEventHandlers);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsImageLoadingContent::BindToTree(aDocument, aParent, aBindingParent,
                                     aCompileEventHandlers);
 
   if (mStringAttributes[HREF].IsExplicitlySet()) {
     // FIXME: Bug 660963 it would be nice if we could just have
     // ClearBrokenState update our state and do it fast...
     ClearBrokenState();
     RemoveStatesSilently(NS_EVENT_STATE_BROKEN);
     nsContentUtils::AddScriptRunner(
-      NS_NewRunnableMethod(this, &nsSVGImageElement::MaybeLoadSVGImage));
+      NS_NewRunnableMethod(this, &SVGImageElement::MaybeLoadSVGImage));
   }
 
   return rv;
 }
 
 void
-nsSVGImageElement::UnbindFromTree(bool aDeep, bool aNullParent)
+SVGImageElement::UnbindFromTree(bool aDeep, bool aNullParent)
 {
   nsImageLoadingContent::UnbindFromTree(aDeep, aNullParent);
-  nsSVGImageElementBase::UnbindFromTree(aDeep, aNullParent);
+  SVGImageElementBase::UnbindFromTree(aDeep, aNullParent);
 }
 
 nsEventStates
-nsSVGImageElement::IntrinsicState() const
+SVGImageElement::IntrinsicState() const
 {
-  return nsSVGImageElementBase::IntrinsicState() |
+  return SVGImageElementBase::IntrinsicState() |
     nsImageLoadingContent::ImageState();
 }
 
 NS_IMETHODIMP_(bool)
-nsSVGImageElement::IsAttributeMapped(const nsIAtom* name) const
+SVGImageElement::IsAttributeMapped(const nsIAtom* name) const
 {
   static const MappedAttributeEntry* const map[] = {
     sViewportsMap,
   };
-  
+
   return FindAttributeDependence(name, map) ||
-    nsSVGImageElementBase::IsAttributeMapped(name);
+    SVGImageElementBase::IsAttributeMapped(name);
 }
 
 //----------------------------------------------------------------------
 // nsSVGPathGeometryElement methods
 
 /* For the purposes of the update/invalidation logic pretend to
    be a rectangle. */
 void
-nsSVGImageElement::ConstructPath(gfxContext *aCtx)
+SVGImageElement::ConstructPath(gfxContext *aCtx)
 {
   float x, y, width, height;
 
   GetAnimatedLengthValues(&x, &y, &width, &height, nullptr);
 
   if (width <= 0 || height <= 0)
     return;
 
   aCtx->Rectangle(gfxRect(x, y, width, height));
 }
 
 //----------------------------------------------------------------------
 // nsSVGElement methods
 
 /* virtual */ bool
-nsSVGImageElement::HasValidDimensions() const
+SVGImageElement::HasValidDimensions() const
 {
-  return mLengthAttributes[WIDTH].IsExplicitlySet() &&
-         mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
-         mLengthAttributes[HEIGHT].IsExplicitlySet() &&
-         mLengthAttributes[HEIGHT].GetAnimValInSpecifiedUnits() > 0;
+  return mLengthAttributes[ATTR_WIDTH].IsExplicitlySet() &&
+         mLengthAttributes[ATTR_WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
+         mLengthAttributes[ATTR_HEIGHT].IsExplicitlySet() &&
+         mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0;
 }
 
 nsSVGElement::LengthAttributesInfo
-nsSVGImageElement::GetLengthInfo()
+SVGImageElement::GetLengthInfo()
 {
   return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
                               ArrayLength(sLengthInfo));
 }
 
 SVGAnimatedPreserveAspectRatio *
-nsSVGImageElement::GetPreserveAspectRatio()
+SVGImageElement::GetPreserveAspectRatio()
 {
   return &mPreserveAspectRatio;
 }
 
 nsSVGElement::StringAttributesInfo
-nsSVGImageElement::GetStringInfo()
+SVGImageElement::GetStringInfo()
 {
   return StringAttributesInfo(mStringAttributes, sStringInfo,
                               ArrayLength(sStringInfo));
 }
 
 nsresult
-nsSVGImageElement::CopyInnerTo(Element* aDest)
+SVGImageElement::CopyInnerTo(Element* aDest)
 {
   if (aDest->OwnerDoc()->IsStaticDocument()) {
-    CreateStaticImageClone(static_cast<nsSVGImageElement*>(aDest));
+    CreateStaticImageClone(static_cast<SVGImageElement*>(aDest));
   }
-  return nsSVGImageElementBase::CopyInnerTo(aDest);
+  return SVGImageElementBase::CopyInnerTo(aDest);
 }
+
+} // namespace dom
+} // namespace mozilla
+
rename from content/svg/content/src/nsSVGImageElement.h
rename to content/svg/content/src/SVGImageElement.h
--- a/content/svg/content/src/nsSVGImageElement.h
+++ b/content/svg/content/src/SVGImageElement.h
@@ -1,52 +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 __NS_SVGIMAGEELEMENT_H__
-#define __NS_SVGIMAGEELEMENT_H__
+#ifndef mozilla_dom_SVGImageElement_h
+#define mozilla_dom_SVGImageElement_h
 
 #include "nsIDOMSVGImageElement.h"
 #include "nsIDOMSVGURIReference.h"
 #include "nsImageLoadingContent.h"
 #include "nsSVGLength2.h"
 #include "nsSVGPathGeometryElement.h"
 #include "nsSVGString.h"
 #include "SVGAnimatedPreserveAspectRatio.h"
 
-typedef nsSVGPathGeometryElement nsSVGImageElementBase;
+nsresult NS_NewSVGImageElement(nsIContent **aResult,
+                               already_AddRefed<nsINodeInfo> aNodeInfo);
+
+typedef nsSVGPathGeometryElement SVGImageElementBase;
+
+class nsSVGImageFrame;
 
-class nsSVGImageElement : public nsSVGImageElementBase,
-                          public nsIDOMSVGImageElement,
-                          public nsIDOMSVGURIReference,
-                          public nsImageLoadingContent
+namespace mozilla {
+namespace dom {
+class DOMSVGAnimatedPreserveAspectRatio;
+
+class SVGImageElement : public SVGImageElementBase,
+                        public nsIDOMSVGImageElement,
+                        public nsIDOMSVGURIReference,
+                        public nsImageLoadingContent
 {
-  friend class nsSVGImageFrame;
+  friend class ::nsSVGImageFrame;
 
 protected:
-  friend nsresult NS_NewSVGImageElement(nsIContent **aResult,
-                                        already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGImageElement(already_AddRefed<nsINodeInfo> aNodeInfo);
-  virtual ~nsSVGImageElement();
+  SVGImageElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  virtual ~SVGImageElement();
+  virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
+  friend nsresult (::NS_NewSVGImageElement(nsIContent **aResult,
+                                           already_AddRefed<nsINodeInfo> aNodeInfo));
 
 public:
-  typedef mozilla::SVGAnimatedPreserveAspectRatio SVGAnimatedPreserveAspectRatio;
+  // interfaces:
 
-  // interfaces:
-  
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMSVGIMAGEELEMENT
   NS_DECL_NSIDOMSVGURIREFERENCE
 
   // xxx I wish we could use virtual inheritance
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGImageElementBase::)
+  NS_FORWARD_NSIDOMSVGELEMENT(SVGImageElementBase::)
 
   // nsIContent interface
   virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
                                 const nsAttrValue* aValue, bool aNotify);
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers);
   virtual void UnbindFromTree(bool aDeep, bool aNullParent);
@@ -67,27 +75,39 @@ public:
 
   void MaybeLoadSVGImage();
 
   bool IsImageSrcSetDisabled() const;
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
+
+  // WebIDL
+  already_AddRefed<nsIDOMSVGAnimatedLength> X();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Y();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Width();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Height();
+  already_AddRefed<DOMSVGAnimatedPreserveAspectRatio> PreserveAspectRatio();
+  already_AddRefed<nsIDOMSVGAnimatedString> Href();
+
 protected:
   nsresult LoadSVGImage(bool aForce, bool aNotify);
 
   virtual LengthAttributesInfo GetLengthInfo();
   virtual SVGAnimatedPreserveAspectRatio *GetPreserveAspectRatio();
   virtual StringAttributesInfo GetStringInfo();
 
-  enum { X, Y, WIDTH, HEIGHT };
+  enum { ATTR_X, ATTR_Y, ATTR_WIDTH, ATTR_HEIGHT };
   nsSVGLength2 mLengthAttributes[4];
   static LengthInfo sLengthInfo[4];
 
   SVGAnimatedPreserveAspectRatio mPreserveAspectRatio;
 
   enum { HREF };
   nsSVGString mStringAttributes[1];
   static StringInfo sStringInfo[1];
 };
 
-#endif
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_SVGImageElement_h
rename from content/svg/content/src/nsSVGLineElement.cpp
rename to content/svg/content/src/SVGLineElement.cpp
--- a/content/svg/content/src/nsSVGLineElement.cpp
+++ b/content/svg/content/src/SVGLineElement.cpp
@@ -1,171 +1,165 @@
 /* -*- 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 "nsSVGPathGeometryElement.h"
-#include "nsIDOMSVGLineElement.h"
-#include "nsSVGLength2.h"
-#include "nsGkAtoms.h"
+#include "mozilla/dom/SVGLineElement.h"
+#include "mozilla/dom/SVGLineElementBinding.h"
 #include "gfxContext.h"
 
-using namespace mozilla;
-
-typedef nsSVGPathGeometryElement nsSVGLineElementBase;
+DOMCI_NODE_DATA(SVGLineElement, mozilla::dom::SVGLineElement)
 
-class nsSVGLineElement : public nsSVGLineElementBase,
-                         public nsIDOMSVGLineElement
-{
-protected:
-  friend nsresult NS_NewSVGLineElement(nsIContent **aResult,
-                                       already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGLineElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Line)
 
-public:
-  // interfaces:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMSVGLINEELEMENT
-
-  // xxx I wish we could use virtual inheritance
-  NS_FORWARD_NSIDOMNODE_TO_NSINODE
-  NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGLineElementBase::)
+namespace mozilla {
+namespace dom {
 
-  // nsIContent interface
-  NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const;
-
-  // nsSVGPathGeometryElement methods:
-  virtual bool IsMarkable() { return true; }
-  virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks);
-  virtual void ConstructPath(gfxContext *aCtx);
-
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
-
-  virtual nsXPCClassInfo* GetClassInfo();
+JSObject*
+SVGLineElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return SVGLineElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
 
-  virtual nsIDOMNode* AsDOMNode() { return this; }
-protected:
-
-  virtual LengthAttributesInfo GetLengthInfo();
-
-  enum { X1, Y1, X2, Y2 };
-  nsSVGLength2 mLengthAttributes[4];
-  static LengthInfo sLengthInfo[4];
-};
-
-nsSVGElement::LengthInfo nsSVGLineElement::sLengthInfo[4] =
+nsSVGElement::LengthInfo SVGLineElement::sLengthInfo[4] =
 {
   { &nsGkAtoms::x1, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::y1, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
   { &nsGkAtoms::x2, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::y2, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
 };
 
-NS_IMPL_NS_NEW_SVG_ELEMENT(Line)
-
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGLineElement,nsSVGLineElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGLineElement,nsSVGLineElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGLineElement,SVGLineElementBase)
+NS_IMPL_RELEASE_INHERITED(SVGLineElement,SVGLineElementBase)
 
-DOMCI_NODE_DATA(SVGLineElement, nsSVGLineElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGLineElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGLineElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
+NS_INTERFACE_TABLE_HEAD(SVGLineElement)
+  NS_NODE_INTERFACE_TABLE4(SVGLineElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
                            nsIDOMSVGLineElement)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGLineElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGLineElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGLineElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGLineElement::nsSVGLineElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGLineElementBase(aNodeInfo)
+SVGLineElement::SVGLineElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGLineElementBase(aNodeInfo)
 {
+  SetIsDOMBinding();
 }
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGLineElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGLineElement)
 
 //----------------------------------------------------------------------
 // nsIDOMSVGLineElement methods
 
 /* readonly attribute nsIDOMSVGAnimatedLength cx; */
-NS_IMETHODIMP nsSVGLineElement::GetX1(nsIDOMSVGAnimatedLength * *aX1)
+NS_IMETHODIMP SVGLineElement::GetX1(nsIDOMSVGAnimatedLength * *aX1)
 {
-  return mLengthAttributes[X1].ToDOMAnimatedLength(aX1, this);
+  *aX1 = X1().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGLineElement::X1()
+{
+  return mLengthAttributes[ATTR_X1].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength cy; */
-NS_IMETHODIMP nsSVGLineElement::GetY1(nsIDOMSVGAnimatedLength * *aY1)
+NS_IMETHODIMP SVGLineElement::GetY1(nsIDOMSVGAnimatedLength * *aY1)
 {
-  return mLengthAttributes[Y1].ToDOMAnimatedLength(aY1, this);
+  *aY1 = Y1().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGLineElement::Y1()
+{
+  return mLengthAttributes[ATTR_Y1].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength rx; */
-NS_IMETHODIMP nsSVGLineElement::GetX2(nsIDOMSVGAnimatedLength * *aX2)
+NS_IMETHODIMP SVGLineElement::GetX2(nsIDOMSVGAnimatedLength * *aX2)
 {
-  return mLengthAttributes[X2].ToDOMAnimatedLength(aX2, this);
+  *aX2 = X2().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGLineElement::X2()
+{
+  return mLengthAttributes[ATTR_X2].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength ry; */
-NS_IMETHODIMP nsSVGLineElement::GetY2(nsIDOMSVGAnimatedLength * *aY2)
+NS_IMETHODIMP SVGLineElement::GetY2(nsIDOMSVGAnimatedLength * *aY2)
 {
-  return mLengthAttributes[Y2].ToDOMAnimatedLength(aY2, this);
+  *aY2 = Y2().get();
+  return NS_OK;
 }
 
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGLineElement::Y2()
+{
+  return mLengthAttributes[ATTR_Y2].ToDOMAnimatedLength(this);
+}
+
+
 //----------------------------------------------------------------------
 // nsIContent methods
 
 NS_IMETHODIMP_(bool)
-nsSVGLineElement::IsAttributeMapped(const nsIAtom* name) const
+SVGLineElement::IsAttributeMapped(const nsIAtom* name) const
 {
   static const MappedAttributeEntry* const map[] = {
     sMarkersMap
   };
-  
+
   return FindAttributeDependence(name, map) ||
-    nsSVGLineElementBase::IsAttributeMapped(name);
+    SVGLineElementBase::IsAttributeMapped(name);
 }
 
 //----------------------------------------------------------------------
 // nsSVGElement methods
 
 nsSVGElement::LengthAttributesInfo
-nsSVGLineElement::GetLengthInfo()
+SVGLineElement::GetLengthInfo()
 {
   return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
                               ArrayLength(sLengthInfo));
 }
 
 //----------------------------------------------------------------------
 // nsSVGPathGeometryElement methods
 
 void
-nsSVGLineElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks) {
+SVGLineElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks) {
   float x1, y1, x2, y2;
 
   GetAnimatedLengthValues(&x1, &y1, &x2, &y2, nullptr);
 
   float angle = atan2(y2 - y1, x2 - x1);
 
   aMarks->AppendElement(nsSVGMark(x1, y1, angle));
   aMarks->AppendElement(nsSVGMark(x2, y2, angle));
 }
 
 void
-nsSVGLineElement::ConstructPath(gfxContext *aCtx)
+SVGLineElement::ConstructPath(gfxContext *aCtx)
 {
   float x1, y1, x2, y2;
 
   GetAnimatedLengthValues(&x1, &y1, &x2, &y2, nullptr);
 
   aCtx->MoveTo(gfxPoint(x1, y1));
   aCtx->LineTo(gfxPoint(x2, y2));
 }
+
+} // namespace dom
+} // namespace mozilla
copy from content/svg/content/src/nsSVGLineElement.cpp
copy to content/svg/content/src/SVGLineElement.h
--- a/content/svg/content/src/nsSVGLineElement.cpp
+++ b/content/svg/content/src/SVGLineElement.h
@@ -1,171 +1,72 @@
 /* -*- 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_SVGLineElement_h
+#define mozilla_dom_SVGLineElement_h
 
 #include "nsSVGPathGeometryElement.h"
 #include "nsIDOMSVGLineElement.h"
 #include "nsSVGLength2.h"
-#include "nsGkAtoms.h"
-#include "gfxContext.h"
 
-using namespace mozilla;
+nsresult NS_NewSVGLineElement(nsIContent **aResult,
+                              already_AddRefed<nsINodeInfo> aNodeInfo);
 
-typedef nsSVGPathGeometryElement nsSVGLineElementBase;
+namespace mozilla {
+namespace dom {
 
-class nsSVGLineElement : public nsSVGLineElementBase,
-                         public nsIDOMSVGLineElement
+typedef nsSVGPathGeometryElement SVGLineElementBase;
+
+class SVGLineElement MOZ_FINAL : public SVGLineElementBase,
+                                 public nsIDOMSVGLineElement
 {
 protected:
-  friend nsresult NS_NewSVGLineElement(nsIContent **aResult,
-                                       already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGLineElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  SVGLineElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE;
+  friend nsresult (::NS_NewSVGLineElement(nsIContent **aResult,
+                                          already_AddRefed<nsINodeInfo> aNodeInfo));
 
 public:
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMSVGLINEELEMENT
 
   // xxx I wish we could use virtual inheritance
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGLineElementBase::)
+  NS_FORWARD_NSIDOMSVGELEMENT(SVGLineElementBase::)
 
   // nsIContent interface
   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const;
 
   // nsSVGPathGeometryElement methods:
   virtual bool IsMarkable() { return true; }
   virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks);
   virtual void ConstructPath(gfxContext *aCtx);
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
+
+  // WebIDL
+  already_AddRefed<nsIDOMSVGAnimatedLength> X1();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Y1();
+  already_AddRefed<nsIDOMSVGAnimatedLength> X2();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Y2();
+
 protected:
 
   virtual LengthAttributesInfo GetLengthInfo();
 
-  enum { X1, Y1, X2, Y2 };
+  enum { ATTR_X1, ATTR_Y1, ATTR_X2, ATTR_Y2 };
   nsSVGLength2 mLengthAttributes[4];
   static LengthInfo sLengthInfo[4];
 };
 
-nsSVGElement::LengthInfo nsSVGLineElement::sLengthInfo[4] =
-{
-  { &nsGkAtoms::x1, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
-  { &nsGkAtoms::y1, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
-  { &nsGkAtoms::x2, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
-  { &nsGkAtoms::y2, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
-};
-
-NS_IMPL_NS_NEW_SVG_ELEMENT(Line)
-
-//----------------------------------------------------------------------
-// nsISupports methods
-
-NS_IMPL_ADDREF_INHERITED(nsSVGLineElement,nsSVGLineElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGLineElement,nsSVGLineElementBase)
-
-DOMCI_NODE_DATA(SVGLineElement, nsSVGLineElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGLineElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGLineElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
-                           nsIDOMSVGLineElement)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGLineElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGLineElementBase)
-
-//----------------------------------------------------------------------
-// Implementation
-
-nsSVGLineElement::nsSVGLineElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGLineElementBase(aNodeInfo)
-{
-}
-
-//----------------------------------------------------------------------
-// nsIDOMNode methods
-
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGLineElement)
-
-//----------------------------------------------------------------------
-// nsIDOMSVGLineElement methods
-
-/* readonly attribute nsIDOMSVGAnimatedLength cx; */
-NS_IMETHODIMP nsSVGLineElement::GetX1(nsIDOMSVGAnimatedLength * *aX1)
-{
-  return mLengthAttributes[X1].ToDOMAnimatedLength(aX1, this);
-}
-
-/* readonly attribute nsIDOMSVGAnimatedLength cy; */
-NS_IMETHODIMP nsSVGLineElement::GetY1(nsIDOMSVGAnimatedLength * *aY1)
-{
-  return mLengthAttributes[Y1].ToDOMAnimatedLength(aY1, this);
-}
+} // namespace dom
+} // namespace mozilla
 
-/* readonly attribute nsIDOMSVGAnimatedLength rx; */
-NS_IMETHODIMP nsSVGLineElement::GetX2(nsIDOMSVGAnimatedLength * *aX2)
-{
-  return mLengthAttributes[X2].ToDOMAnimatedLength(aX2, this);
-}
-
-/* readonly attribute nsIDOMSVGAnimatedLength ry; */
-NS_IMETHODIMP nsSVGLineElement::GetY2(nsIDOMSVGAnimatedLength * *aY2)
-{
-  return mLengthAttributes[Y2].ToDOMAnimatedLength(aY2, this);
-}
-
-//----------------------------------------------------------------------
-// nsIContent methods
-
-NS_IMETHODIMP_(bool)
-nsSVGLineElement::IsAttributeMapped(const nsIAtom* name) const
-{
-  static const MappedAttributeEntry* const map[] = {
-    sMarkersMap
-  };
-  
-  return FindAttributeDependence(name, map) ||
-    nsSVGLineElementBase::IsAttributeMapped(name);
-}
-
-//----------------------------------------------------------------------
-// nsSVGElement methods
-
-nsSVGElement::LengthAttributesInfo
-nsSVGLineElement::GetLengthInfo()
-{
-  return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
-                              ArrayLength(sLengthInfo));
-}
-
-//----------------------------------------------------------------------
-// nsSVGPathGeometryElement methods
-
-void
-nsSVGLineElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks) {
-  float x1, y1, x2, y2;
-
-  GetAnimatedLengthValues(&x1, &y1, &x2, &y2, nullptr);
-
-  float angle = atan2(y2 - y1, x2 - x1);
-
-  aMarks->AppendElement(nsSVGMark(x1, y1, angle));
-  aMarks->AppendElement(nsSVGMark(x2, y2, angle));
-}
-
-void
-nsSVGLineElement::ConstructPath(gfxContext *aCtx)
-{
-  float x1, y1, x2, y2;
-
-  GetAnimatedLengthValues(&x1, &y1, &x2, &y2, nullptr);
-
-  aCtx->MoveTo(gfxPoint(x1, y1));
-  aCtx->LineTo(gfxPoint(x2, y2));
-}
+#endif // mozilla_dom_SVGLineElement_h
new file mode 100644
--- /dev/null
+++ b/content/svg/content/src/SVGLocatableElement.cpp
@@ -0,0 +1,162 @@
+/* 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 "SVGLocatableElement.h"
+#include "DOMSVGMatrix.h"
+#include "nsIFrame.h"
+#include "nsISVGChildFrame.h"
+#include "nsSVGRect.h"
+#include "nsSVGSVGElement.h"
+#include "nsSVGUtils.h"
+#include "SVGContentUtils.h"
+
+namespace mozilla {
+namespace dom {
+
+//----------------------------------------------------------------------
+// nsISupports methods
+
+NS_IMPL_ADDREF_INHERITED(SVGLocatableElement, nsSVGElement)
+NS_IMPL_RELEASE_INHERITED(SVGLocatableElement, nsSVGElement)
+
+NS_INTERFACE_MAP_BEGIN(SVGLocatableElement)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGLocatable)
+NS_INTERFACE_MAP_END_INHERITING(nsSVGElement)
+
+
+//----------------------------------------------------------------------
+// nsIDOMSVGLocatable methods
+
+/* readonly attribute nsIDOMSVGElement nearestViewportElement; */
+NS_IMETHODIMP
+SVGLocatableElement::GetNearestViewportElement(nsIDOMSVGElement * *aNearestViewportElement)
+{
+  nsCOMPtr<nsIDOMSVGElement> domElem = do_QueryInterface(GetNearestViewportElement());
+  domElem.forget(aNearestViewportElement);
+  return NS_OK;
+}
+
+nsSVGElement*
+SVGLocatableElement::GetNearestViewportElement()
+{
+  return SVGContentUtils::GetNearestViewportElement(this);
+}
+
+/* readonly attribute nsIDOMSVGElement farthestViewportElement; */
+NS_IMETHODIMP
+SVGLocatableElement::GetFarthestViewportElement(nsIDOMSVGElement * *aFarthestViewportElement)
+{
+  NS_IF_ADDREF(*aFarthestViewportElement = SVGContentUtils::GetOuterSVGElement(this));
+  return NS_OK;
+}
+
+nsSVGElement*
+SVGLocatableElement::GetFarthestViewportElement()
+{
+  return SVGContentUtils::GetOuterSVGElement(this);
+}
+
+/* nsIDOMSVGRect getBBox (); */
+NS_IMETHODIMP
+SVGLocatableElement::GetBBox(nsIDOMSVGRect **_retval)
+{
+  ErrorResult rv;
+  *_retval = GetBBox(rv).get();
+  return rv.ErrorCode();
+}
+
+already_AddRefed<nsIDOMSVGRect>
+SVGLocatableElement::GetBBox(ErrorResult& rv)
+{
+  nsIFrame* frame = GetPrimaryFrame(Flush_Layout);
+
+  if (!frame || (frame->GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD)) {
+    rv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
+  }
+
+  nsISVGChildFrame* svgframe = do_QueryFrame(frame);
+  if (!svgframe) {
+    rv.Throw(NS_ERROR_NOT_IMPLEMENTED); // XXX: outer svg
+    return nullptr;
+  }
+
+  nsCOMPtr<nsIDOMSVGRect> rect;
+  rv = NS_NewSVGRect(getter_AddRefs(rect), nsSVGUtils::GetBBox(frame));
+  return rect.forget();
+}
+
+/* DOMSVGMatrix getCTM (); */
+NS_IMETHODIMP
+SVGLocatableElement::GetCTM(nsISupports * *aCTM)
+{
+  *aCTM = GetCTM().get();
+  return NS_OK;
+}
+
+already_AddRefed<DOMSVGMatrix>
+SVGLocatableElement::GetCTM()
+{
+  gfxMatrix m = SVGContentUtils::GetCTM(this, false);
+  nsCOMPtr<DOMSVGMatrix> mat = m.IsSingular() ? nullptr : new DOMSVGMatrix(m);
+  return mat.forget();
+}
+
+/* DOMSVGMatrix getScreenCTM (); */
+NS_IMETHODIMP
+SVGLocatableElement::GetScreenCTM(nsISupports * *aCTM)
+{
+  *aCTM = GetScreenCTM().get();
+  return NS_OK;
+}
+
+already_AddRefed<DOMSVGMatrix>
+SVGLocatableElement::GetScreenCTM()
+{
+  gfxMatrix m = SVGContentUtils::GetCTM(this, true);
+  nsCOMPtr<DOMSVGMatrix> mat = m.IsSingular() ? nullptr : new DOMSVGMatrix(m);
+  return mat.forget();
+}
+
+/* DOMSVGMatrix getTransformToElement (in nsIDOMSVGElement element); */
+NS_IMETHODIMP
+SVGLocatableElement::GetTransformToElement(nsIDOMSVGElement *element,
+                                           nsISupports **_retval)
+{
+  nsCOMPtr<nsSVGElement> elem = do_QueryInterface(element);
+  if (!elem)
+    return NS_ERROR_DOM_SVG_WRONG_TYPE_ERR;
+  ErrorResult rv;
+  *_retval = GetTransformToElement(*elem, rv).get();
+  return rv.ErrorCode();
+}
+
+already_AddRefed<DOMSVGMatrix>
+SVGLocatableElement::GetTransformToElement(nsSVGElement& aElement,
+                                           ErrorResult& rv)
+{
+  nsCOMPtr<nsIDOMSVGLocatable> target = do_QueryInterface(&aElement);
+  if (!target) {
+    rv.Throw(NS_NOINTERFACE);
+    return nullptr;
+  }
+
+  // the easiest way to do this (if likely to increase rounding error):
+  nsCOMPtr<DOMSVGMatrix> ourScreenCTM = GetScreenCTM();
+  nsCOMPtr<DOMSVGMatrix> targetScreenCTM;
+  target->GetScreenCTM(getter_AddRefs(targetScreenCTM));
+  if (!ourScreenCTM || !targetScreenCTM) {
+    rv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
+    return nullptr;
+  }
+  nsCOMPtr<DOMSVGMatrix> tmp = targetScreenCTM->Inverse(rv);
+  if (rv.Failed()) return nullptr;
+
+  nsCOMPtr<DOMSVGMatrix> mat = tmp->Multiply(*ourScreenCTM).get();
+  return mat.forget();
+}
+
+} // namespace dom
+} // namespace mozilla
+
new file mode 100644
--- /dev/null
+++ b/content/svg/content/src/SVGLocatableElement.h
@@ -0,0 +1,49 @@
+/* -*- 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 SVGLocatableElement_h
+#define SVGLocatableElement_h
+
+#include "nsSVGElement.h"
+#include "nsIDOMSVGLocatable.h"
+
+#define MOZILLA_SVGLOCATABLEELEMENT_IID \
+  { 0xe20176ba, 0xc48d, 0x4704, \
+    {0x89, 0xec, 0xe6, 0x69, 0x6c, 0xb7, 0xb8, 0xb3} }
+
+namespace mozilla {
+class DOMSVGMatrix;
+
+namespace dom {
+class SVGLocatableElement : public nsSVGElement,
+                            public nsIDOMSVGLocatable
+{
+public:
+  SVGLocatableElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+    : nsSVGElement(aNodeInfo) {}
+  virtual ~SVGLocatableElement() {}
+
+  NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_SVGLOCATABLEELEMENT_IID)
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_NSIDOMSVGLOCATABLE
+
+  // WebIDL
+  nsSVGElement* GetNearestViewportElement();
+  nsSVGElement* GetFarthestViewportElement();
+  already_AddRefed<nsIDOMSVGRect> GetBBox(ErrorResult& rv);
+  already_AddRefed<DOMSVGMatrix> GetCTM();
+  already_AddRefed<DOMSVGMatrix> GetScreenCTM();
+  already_AddRefed<DOMSVGMatrix> GetTransformToElement(nsSVGElement& aElement,
+                                                       ErrorResult& rv);
+};
+
+NS_DEFINE_STATIC_IID_ACCESSOR(SVGLocatableElement,
+                              MOZILLA_SVGLOCATABLEELEMENT_IID)
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // SVGLocatableElement_h
+
--- a/content/svg/content/src/SVGMPathElement.cpp
+++ b/content/svg/content/src/SVGMPathElement.cpp
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Util.h"
 
 #include "mozilla/dom/SVGMPathElement.h"
 #include "nsAutoPtr.h"
 #include "nsDebug.h"
 #include "nsSVGPathElement.h"
-#include "nsSVGAnimateMotionElement.h"
+#include "mozilla/dom/SVGAnimateMotionElement.h"
 #include "nsContentUtils.h"
 #include "mozilla/dom/SVGMPathElementBinding.h"
 
 DOMCI_NODE_DATA(SVGMpathElement, mozilla::dom::SVGMPathElement)
 
 NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(MPath)
 
 namespace mozilla {
@@ -270,18 +270,18 @@ SVGMPathElement::UnlinkHrefTarget(bool a
   }
 }
 
 void
 SVGMPathElement::NotifyParentOfMpathChange(nsIContent* aParent)
 {
   if (aParent && aParent->IsSVG(nsGkAtoms::animateMotion)) {
 
-    nsSVGAnimateMotionElement* animateMotionParent =
-      static_cast<nsSVGAnimateMotionElement*>(aParent);
+    SVGAnimateMotionElement* animateMotionParent =
+      static_cast<SVGAnimateMotionElement*>(aParent);
 
     animateMotionParent->MpathChanged();
     AnimationNeedsResample();
   }
 }
 
 } // namespace dom
 } // namespace mozilla
rename from content/svg/content/src/nsSVGPolygonElement.cpp
rename to content/svg/content/src/SVGPolygonElement.cpp
--- a/content/svg/content/src/nsSVGPolygonElement.cpp
+++ b/content/svg/content/src/SVGPolygonElement.cpp
@@ -1,86 +1,63 @@
 /* -*- 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 "nsSVGPolyElement.h"
-#include "nsIDOMSVGPolygonElement.h"
+#include "mozilla/dom/SVGPolygonElement.h"
+#include "mozilla/dom/SVGPolygonElementBinding.h"
 #include "gfxContext.h"
 #include "SVGContentUtils.h"
 
-typedef nsSVGPolyElement nsSVGPolygonElementBase;
+DOMCI_NODE_DATA(SVGPolygonElement, mozilla::dom::SVGPolygonElement)
 
-class nsSVGPolygonElement : public nsSVGPolygonElementBase,
-                            public nsIDOMSVGPolygonElement
-{
-protected:
-  friend nsresult NS_NewSVGPolygonElement(nsIContent **aResult,
-                                          already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGPolygonElement(already_AddRefed<nsINodeInfo> aNodeInfo);
-
-public:
-  // interfaces:
-
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMSVGPOLYGONELEMENT
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Polygon)
 
-  // xxx I wish we could use virtual inheritance
-  NS_FORWARD_NSIDOMNODE_TO_NSINODE
-  NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGPolygonElementBase::)
-
-  // nsSVGPathGeometryElement methods:
-  virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks);
-  virtual void ConstructPath(gfxContext *aCtx);
+namespace mozilla {
+namespace dom {
 
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
-
-  virtual nsXPCClassInfo* GetClassInfo();
-
-  virtual nsIDOMNode* AsDOMNode() { return this; }
-};
-
-NS_IMPL_NS_NEW_SVG_ELEMENT(Polygon)
+JSObject*
+SVGPolygonElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return SVGPolygonElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGPolygonElement,nsSVGPolygonElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGPolygonElement,nsSVGPolygonElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGPolygonElement,SVGPolygonElementBase)
+NS_IMPL_RELEASE_INHERITED(SVGPolygonElement,SVGPolygonElementBase)
 
-DOMCI_NODE_DATA(SVGPolygonElement, nsSVGPolygonElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGPolygonElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGPolygonElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
+NS_INTERFACE_TABLE_HEAD(SVGPolygonElement)
+  NS_NODE_INTERFACE_TABLE4(SVGPolygonElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
                            nsIDOMSVGPolygonElement)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGPolygonElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGPolygonElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGPolygonElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGPolygonElement::nsSVGPolygonElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGPolygonElementBase(aNodeInfo)
+SVGPolygonElement::SVGPolygonElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGPolygonElementBase(aNodeInfo)
 {
 
 }
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGPolygonElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGPolygonElement)
 
 //----------------------------------------------------------------------
 // nsSVGPathGeometryElement methods
 
 void
-nsSVGPolygonElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
+SVGPolygonElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
 {
   nsSVGPolyElement::GetMarkPoints(aMarks);
   if (aMarks->Length() > 0) {
     nsSVGMark *endMark = &aMarks->ElementAt(aMarks->Length()-1);
     nsSVGMark *startMark = &aMarks->ElementAt(0);
     float angle = atan2(startMark->y - endMark->y, startMark->x - endMark->x);
 
     endMark->angle = SVGContentUtils::AngleBisect(angle, endMark->angle);
@@ -88,17 +65,18 @@ nsSVGPolygonElement::GetMarkPoints(nsTAr
     // for a polygon (as opposed to a polyline) there's an implicit extra point
     // co-located with the start point that nsSVGPolyElement::GetMarkPoints
     // doesn't return
     aMarks->AppendElement(nsSVGMark(startMark->x, startMark->y, startMark->angle));
   }
 }
 
 void
-nsSVGPolygonElement::ConstructPath(gfxContext *aCtx)
+SVGPolygonElement::ConstructPath(gfxContext *aCtx)
 {
-  nsSVGPolygonElementBase::ConstructPath(aCtx);
+  SVGPolygonElementBase::ConstructPath(aCtx);
   // the difference between a polyline and a polygon is that the
   // polygon is closed:
   aCtx->ClosePath();
 }
 
-
+} // namespace dom
+} // namespace mozilla
copy from content/svg/content/src/nsSVGPolygonElement.cpp
copy to content/svg/content/src/SVGPolygonElement.h
--- a/content/svg/content/src/nsSVGPolygonElement.cpp
+++ b/content/svg/content/src/SVGPolygonElement.h
@@ -1,104 +1,54 @@
 /* -*- 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_SVGPolygonElement_h
+#define mozilla_dom_SVGPolygonElement_h
+
 #include "nsSVGPolyElement.h"
 #include "nsIDOMSVGPolygonElement.h"
-#include "gfxContext.h"
-#include "SVGContentUtils.h"
+
+nsresult NS_NewSVGPolygonElement(nsIContent **aResult,
+                                 already_AddRefed<nsINodeInfo> aNodeInfo);
+
+typedef nsSVGPolyElement SVGPolygonElementBase;
 
-typedef nsSVGPolyElement nsSVGPolygonElementBase;
+namespace mozilla {
+namespace dom {
 
-class nsSVGPolygonElement : public nsSVGPolygonElementBase,
-                            public nsIDOMSVGPolygonElement
+class SVGPolygonElement MOZ_FINAL : public SVGPolygonElementBase,
+                                    public nsIDOMSVGPolygonElement
 {
 protected:
-  friend nsresult NS_NewSVGPolygonElement(nsIContent **aResult,
-                                          already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGPolygonElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  SVGPolygonElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE;
+  friend nsresult (::NS_NewSVGPolygonElement(nsIContent **aResult,
+                                             already_AddRefed<nsINodeInfo> aNodeInfo));
 
 public:
   // interfaces:
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMSVGPOLYGONELEMENT
 
   // xxx I wish we could use virtual inheritance
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGPolygonElementBase::)
+  NS_FORWARD_NSIDOMSVGELEMENT(SVGPolygonElementBase::)
 
   // nsSVGPathGeometryElement methods:
   virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks);
   virtual void ConstructPath(gfxContext *aCtx);
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
 };
 
-NS_IMPL_NS_NEW_SVG_ELEMENT(Polygon)
-
-//----------------------------------------------------------------------
-// nsISupports methods
-
-NS_IMPL_ADDREF_INHERITED(nsSVGPolygonElement,nsSVGPolygonElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGPolygonElement,nsSVGPolygonElementBase)
-
-DOMCI_NODE_DATA(SVGPolygonElement, nsSVGPolygonElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGPolygonElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGPolygonElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
-                           nsIDOMSVGPolygonElement)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGPolygonElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGPolygonElementBase)
-
-//----------------------------------------------------------------------
-// Implementation
-
-nsSVGPolygonElement::nsSVGPolygonElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGPolygonElementBase(aNodeInfo)
-{
-
-}
-
-//----------------------------------------------------------------------
-// nsIDOMNode methods
-
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGPolygonElement)
+} // namespace dom
+} // namespace mozilla
 
-//----------------------------------------------------------------------
-// nsSVGPathGeometryElement methods
-
-void
-nsSVGPolygonElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
-{
-  nsSVGPolyElement::GetMarkPoints(aMarks);
-  if (aMarks->Length() > 0) {
-    nsSVGMark *endMark = &aMarks->ElementAt(aMarks->Length()-1);
-    nsSVGMark *startMark = &aMarks->ElementAt(0);
-    float angle = atan2(startMark->y - endMark->y, startMark->x - endMark->x);
-
-    endMark->angle = SVGContentUtils::AngleBisect(angle, endMark->angle);
-    startMark->angle = SVGContentUtils::AngleBisect(angle, startMark->angle);
-    // for a polygon (as opposed to a polyline) there's an implicit extra point
-    // co-located with the start point that nsSVGPolyElement::GetMarkPoints
-    // doesn't return
-    aMarks->AppendElement(nsSVGMark(startMark->x, startMark->y, startMark->angle));
-  }
-}
-
-void
-nsSVGPolygonElement::ConstructPath(gfxContext *aCtx)
-{
-  nsSVGPolygonElementBase::ConstructPath(aCtx);
-  // the difference between a polyline and a polygon is that the
-  // polygon is closed:
-  aCtx->ClosePath();
-}
-
-
+#endif // mozilla_dom_SVGPolygonElement_h
rename from content/svg/content/src/nsSVGPolylineElement.cpp
rename to content/svg/content/src/SVGPolylineElement.cpp
--- a/content/svg/content/src/nsSVGPolylineElement.cpp
+++ b/content/svg/content/src/SVGPolylineElement.cpp
@@ -1,65 +1,50 @@
 /* -*- 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 "nsSVGPolyElement.h"
-#include "nsIDOMSVGPolylineElement.h"
-
-typedef nsSVGPolyElement nsSVGPolylineElementBase;
+#include "mozilla/dom/SVGPolylineElement.h"
+#include "mozilla/dom/SVGPolylineElementBinding.h"
 
-class nsSVGPolylineElement : public nsSVGPolylineElementBase,
-                             public nsIDOMSVGPolylineElement
-{
-protected:
-  friend nsresult NS_NewSVGPolylineElement(nsIContent **aResult,
-                                           already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGPolylineElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+DOMCI_NODE_DATA(SVGPolylineElement, mozilla::dom::SVGPolylineElement)
 
-public:
-  // interfaces:
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Polyline)
 
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMSVGPOLYLINEELEMENT
-
-  // xxx I wish we could use virtual inheritance
-  NS_FORWARD_NSIDOMNODE_TO_NSINODE
-  NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGPolylineElementBase::)
+namespace mozilla {
+namespace dom {
 
-  // nsIContent interface
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
-  virtual nsXPCClassInfo* GetClassInfo();
-  virtual nsIDOMNode* AsDOMNode() { return this; }
-};
-
-NS_IMPL_NS_NEW_SVG_ELEMENT(Polyline)
+JSObject*
+SVGPolylineElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return SVGPolylineElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGPolylineElement,nsSVGPolylineElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGPolylineElement,nsSVGPolylineElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGPolylineElement,SVGPolylineElementBase)
+NS_IMPL_RELEASE_INHERITED(SVGPolylineElement,SVGPolylineElementBase)
 
-DOMCI_NODE_DATA(SVGPolylineElement, nsSVGPolylineElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGPolylineElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGPolylineElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
+NS_INTERFACE_TABLE_HEAD(SVGPolylineElement)
+  NS_NODE_INTERFACE_TABLE4(SVGPolylineElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
                            nsIDOMSVGPolylineElement)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGPolylineElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGPolylineElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGPolylineElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGPolylineElement::nsSVGPolylineElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGPolylineElementBase(aNodeInfo)
+SVGPolylineElement::SVGPolylineElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGPolylineElementBase(aNodeInfo)
 {
 
 }
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGPolylineElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGPolylineElement)
+
+} // namespace dom
+} // namespace mozilla
copy from content/svg/content/src/nsSVGPolylineElement.cpp
copy to content/svg/content/src/SVGPolylineElement.h
--- a/content/svg/content/src/nsSVGPolylineElement.cpp
+++ b/content/svg/content/src/SVGPolylineElement.h
@@ -1,65 +1,49 @@
 /* -*- 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_SVGPolylineElement_h
+#define mozilla_dom_SVGPolylineElement_h
+
 #include "nsSVGPolyElement.h"
 #include "nsIDOMSVGPolylineElement.h"
 
-typedef nsSVGPolyElement nsSVGPolylineElementBase;
+nsresult NS_NewSVGPolylineElement(nsIContent **aResult,
+                                  already_AddRefed<nsINodeInfo> aNodeInfo);
+
+typedef nsSVGPolyElement SVGPolylineElementBase;
 
-class nsSVGPolylineElement : public nsSVGPolylineElementBase,
-                             public nsIDOMSVGPolylineElement
+namespace mozilla {
+namespace dom {
+
+class SVGPolylineElement MOZ_FINAL : public SVGPolylineElementBase,
+                                     public nsIDOMSVGPolylineElement
 {
 protected:
-  friend nsresult NS_NewSVGPolylineElement(nsIContent **aResult,
-                                           already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGPolylineElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  SVGPolylineElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE;
+  friend nsresult (::NS_NewSVGPolylineElement(nsIContent **aResult,
+                                              already_AddRefed<nsINodeInfo> aNodeInfo));
 
 public:
   // interfaces:
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMSVGPOLYLINEELEMENT
 
   // xxx I wish we could use virtual inheritance
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGPolylineElementBase::)
+  NS_FORWARD_NSIDOMSVGELEMENT(SVGPolylineElementBase::)
 
   // nsIContent interface
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
   virtual nsXPCClassInfo* GetClassInfo();
   virtual nsIDOMNode* AsDOMNode() { return this; }
 };
 
-NS_IMPL_NS_NEW_SVG_ELEMENT(Polyline)
-
-//----------------------------------------------------------------------
-// nsISupports methods
-
-NS_IMPL_ADDREF_INHERITED(nsSVGPolylineElement,nsSVGPolylineElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGPolylineElement,nsSVGPolylineElementBase)
-
-DOMCI_NODE_DATA(SVGPolylineElement, nsSVGPolylineElement)
+} // namespace mozilla
+} // namespace dom
 
-NS_INTERFACE_TABLE_HEAD(nsSVGPolylineElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGPolylineElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
-                           nsIDOMSVGPolylineElement)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGPolylineElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGPolylineElementBase)
-
-//----------------------------------------------------------------------
-// Implementation
-
-nsSVGPolylineElement::nsSVGPolylineElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGPolylineElementBase(aNodeInfo)
-{
-
-}
-
-//----------------------------------------------------------------------
-// nsIDOMNode methods
-
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGPolylineElement)
+#endif // mozilla_dom_SVGPolylineElement_h
rename from content/svg/content/src/nsSVGRectElement.cpp
rename to content/svg/content/src/SVGRectElement.cpp
--- a/content/svg/content/src/nsSVGRectElement.cpp
+++ b/content/svg/content/src/SVGRectElement.cpp
@@ -1,166 +1,173 @@
 /* -*- 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 "nsSVGPathGeometryElement.h"
-#include "nsIDOMSVGRectElement.h"
-#include "nsSVGLength2.h"
+#include "mozilla/dom/SVGRectElement.h"
 #include "nsGkAtoms.h"
 #include "gfxContext.h"
-
-using namespace mozilla;
-
-typedef nsSVGPathGeometryElement nsSVGRectElementBase;
+#include "mozilla/dom/SVGRectElementBinding.h"
 
-class nsSVGRectElement : public nsSVGRectElementBase,
-                         public nsIDOMSVGRectElement
-{
-protected:
-  friend nsresult NS_NewSVGRectElement(nsIContent **aResult,
-                                       already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGRectElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+DOMCI_NODE_DATA(SVGRectElement, mozilla::dom::SVGRectElement)
 
-public:
-  // interfaces:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMSVGRECTELEMENT
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Rect)
 
-  // xxx I wish we could use virtual inheritance
-  NS_FORWARD_NSIDOMNODE_TO_NSINODE
-  NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGRectElementBase::)
-
-  // nsSVGSVGElement methods:
-  virtual bool HasValidDimensions() const;
-
-  // nsSVGPathGeometryElement methods:
-  virtual void ConstructPath(gfxContext *aCtx);
-
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
+namespace mozilla {
+namespace dom {
 
-  virtual nsXPCClassInfo* GetClassInfo();
-
-  virtual nsIDOMNode* AsDOMNode() { return this; }
-protected:
+JSObject*
+SVGRectElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return SVGRectElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
 
-  virtual LengthAttributesInfo GetLengthInfo();
- 
-  enum { X, Y, WIDTH, HEIGHT, RX, RY };
-  nsSVGLength2 mLengthAttributes[6];
-  static LengthInfo sLengthInfo[6];
-};
-
-nsSVGElement::LengthInfo nsSVGRectElement::sLengthInfo[6] =
+nsSVGElement::LengthInfo SVGRectElement::sLengthInfo[6] =
 {
   { &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
   { &nsGkAtoms::width, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::height, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
   { &nsGkAtoms::rx, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::ry, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }
 };
 
-NS_IMPL_NS_NEW_SVG_ELEMENT(Rect)
-
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGRectElement,nsSVGRectElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGRectElement,nsSVGRectElementBase)
+NS_IMPL_ADDREF_INHERITED(SVGRectElement,SVGRectElementBase)
+NS_IMPL_RELEASE_INHERITED(SVGRectElement,SVGRectElementBase)
 
-DOMCI_NODE_DATA(SVGRectElement, nsSVGRectElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGRectElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGRectElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
+NS_INTERFACE_TABLE_HEAD(SVGRectElement)
+  NS_NODE_INTERFACE_TABLE4(SVGRectElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
                            nsIDOMSVGRectElement)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGRectElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGRectElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGRectElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGRectElement::nsSVGRectElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGRectElementBase(aNodeInfo)
+SVGRectElement::SVGRectElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGRectElementBase(aNodeInfo)
 {
+  SetIsDOMBinding();
 }
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGRectElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGRectElement)
 
 //----------------------------------------------------------------------
 // nsIDOMSVGRectElement methods
 
 /* readonly attribute nsIDOMSVGAnimatedLength x; */
-NS_IMETHODIMP nsSVGRectElement::GetX(nsIDOMSVGAnimatedLength * *aX)
+NS_IMETHODIMP SVGRectElement::GetX(nsIDOMSVGAnimatedLength * *aX)
 {
-  return mLengthAttributes[X].ToDOMAnimatedLength(aX, this);
+  *aX = X().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGRectElement::X()
+{
+  return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength y; */
-NS_IMETHODIMP nsSVGRectElement::GetY(nsIDOMSVGAnimatedLength * *aY)
+NS_IMETHODIMP SVGRectElement::GetY(nsIDOMSVGAnimatedLength * *aY)
 {
-  return mLengthAttributes[Y].ToDOMAnimatedLength(aY, this);
+  *aY = Y().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGRectElement::Y()
+{
+  return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength width; */
-NS_IMETHODIMP nsSVGRectElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
+NS_IMETHODIMP SVGRectElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
 {
-  return mLengthAttributes[WIDTH].ToDOMAnimatedLength(aWidth, this);
+  *aWidth = Width().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGRectElement::Width()
+{
+  return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength height; */
-NS_IMETHODIMP nsSVGRectElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
+NS_IMETHODIMP SVGRectElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
 {
-  return mLengthAttributes[HEIGHT].ToDOMAnimatedLength(aHeight, this);
+  *aHeight = Height().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGRectElement::Height()
+{
+  return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength rx; */
-NS_IMETHODIMP nsSVGRectElement::GetRx(nsIDOMSVGAnimatedLength * *aRx)
+NS_IMETHODIMP SVGRectElement::GetRx(nsIDOMSVGAnimatedLength * *aRx)
 {
-  return mLengthAttributes[RX].ToDOMAnimatedLength(aRx, this);
+  *aRx = Rx().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGRectElement::Rx()
+{
+  return mLengthAttributes[ATTR_RX].ToDOMAnimatedLength(this);
 }
 
 /* readonly attribute nsIDOMSVGAnimatedLength ry; */
-NS_IMETHODIMP nsSVGRectElement::GetRy(nsIDOMSVGAnimatedLength * *aRy)
+NS_IMETHODIMP SVGRectElement::GetRy(nsIDOMSVGAnimatedLength * *aRy)
 {
-  return mLengthAttributes[RY].ToDOMAnimatedLength(aRy, this);
+  *aRy = Ry().get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+SVGRectElement::Ry()
+{
+  return mLengthAttributes[ATTR_RY].ToDOMAnimatedLength(this);
 }
 
 //----------------------------------------------------------------------
 // nsSVGElement methods
 
 /* virtual */ bool
-nsSVGRectElement::HasValidDimensions() const
+SVGRectElement::HasValidDimensions() const
 {
-  return mLengthAttributes[WIDTH].IsExplicitlySet() &&
-         mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
-         mLengthAttributes[HEIGHT].IsExplicitlySet() &&
-         mLengthAttributes[HEIGHT].GetAnimValInSpecifiedUnits() > 0;
+  return mLengthAttributes[ATTR_WIDTH].IsExplicitlySet() &&
+         mLengthAttributes[ATTR_WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
+         mLengthAttributes[ATTR_HEIGHT].IsExplicitlySet() &&
+         mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0;
 }
 
 nsSVGElement::LengthAttributesInfo
-nsSVGRectElement::GetLengthInfo()
+SVGRectElement::GetLengthInfo()
 {
   return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
                               ArrayLength(sLengthInfo));
 }
 
 //----------------------------------------------------------------------
 // nsSVGPathGeometryElement methods
 
 void
-nsSVGRectElement::ConstructPath(gfxContext *aCtx)
+SVGRectElement::ConstructPath(gfxContext *aCtx)
 {
   float x, y, width, height, rx, ry;
 
   GetAnimatedLengthValues(&x, &y, &width, &height, &rx, &ry, nullptr);
 
   /* In a perfect world, this would be handled by the DOM, and
      return a DOM exception. */
   if (width <= 0 || height <= 0)
@@ -172,18 +179,18 @@ nsSVGRectElement::ConstructPath(gfxConte
   /* optimize the no rounded corners case */
   if (rx == 0 && ry == 0) {
     aCtx->Rectangle(gfxRect(x, y, width, height));
     return;
   }
 
   /* If either the 'rx' or the 'ry' attribute isn't set, then we
      have to set it to the value of the other. */
-  bool hasRx = mLengthAttributes[RX].IsExplicitlySet();
-  bool hasRy = mLengthAttributes[RY].IsExplicitlySet();
+  bool hasRx = mLengthAttributes[ATTR_RX].IsExplicitlySet();
+  bool hasRy = mLengthAttributes[ATTR_RY].IsExplicitlySet();
   if (hasRx && !hasRy)
     ry = rx;
   else if (hasRy && !hasRx)
     rx = ry;
 
   /* Clamp rx and ry to half the rect's width and height respectively. */
   float halfWidth  = width/2;
   float halfHeight = height/2;
@@ -191,8 +198,11 @@ nsSVGRectElement::ConstructPath(gfxConte
     rx = halfWidth;
   if (ry > halfHeight)
     ry = halfHeight;
 
   gfxSize corner(rx, ry);
   aCtx->RoundedRectangle(gfxRect(x, y, width, height),
                          gfxCornerSizes(corner, corner, corner, corner));
 }
+
+} // namespace dom
+} // namespace mozilla
copy from content/svg/content/src/nsSVGRectElement.cpp
copy to content/svg/content/src/SVGRectElement.h
--- a/content/svg/content/src/nsSVGRectElement.cpp
+++ b/content/svg/content/src/SVGRectElement.h
@@ -1,198 +1,72 @@
 /* -*- 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_SVGRectElement_h
+#define mozilla_dom_SVGRectElement_h
 
 #include "nsSVGPathGeometryElement.h"
 #include "nsIDOMSVGRectElement.h"
 #include "nsSVGLength2.h"
-#include "nsGkAtoms.h"
-#include "gfxContext.h"
 
-using namespace mozilla;
+nsresult NS_NewSVGRectElement(nsIContent **aResult,
+                              already_AddRefed<nsINodeInfo> aNodeInfo);
+
+typedef nsSVGPathGeometryElement SVGRectElementBase;
 
-typedef nsSVGPathGeometryElement nsSVGRectElementBase;
+namespace mozilla {
+namespace dom {
 
-class nsSVGRectElement : public nsSVGRectElementBase,
-                         public nsIDOMSVGRectElement
+class SVGRectElement MOZ_FINAL : public SVGRectElementBase,
+                                 public nsIDOMSVGRectElement
 {
 protected:
-  friend nsresult NS_NewSVGRectElement(nsIContent **aResult,
-                                       already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGRectElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  SVGRectElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap) MOZ_OVERRIDE;
+  friend nsresult (::NS_NewSVGRectElement(nsIContent **aResult,
+                                          already_AddRefed<nsINodeInfo> aNodeInfo));
 
 public:
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMSVGRECTELEMENT
 
   // xxx I wish we could use virtual inheritance
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGRectElementBase::)
+  NS_FORWARD_NSIDOMSVGELEMENT(SVGRectElementBase::)
 
   // nsSVGSVGElement methods:
   virtual bool HasValidDimensions() const;
 
   // nsSVGPathGeometryElement methods:
   virtual void ConstructPath(gfxContext *aCtx);
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
+
+  // WebIDL
+  already_AddRefed<nsIDOMSVGAnimatedLength> X();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Y();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Height();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Width();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Rx();
+  already_AddRefed<nsIDOMSVGAnimatedLength> Ry();
+
 protected:
 
   virtual LengthAttributesInfo GetLengthInfo();
- 
-  enum { X, Y, WIDTH, HEIGHT, RX, RY };
+
+  enum { ATTR_X, ATTR_Y, ATTR_WIDTH, ATTR_HEIGHT, ATTR_RX, ATTR_RY };
   nsSVGLength2 mLengthAttributes[6];
   static LengthInfo sLengthInfo[6];
 };
 
-nsSVGElement::LengthInfo nsSVGRectElement::sLengthInfo[6] =
-{
-  { &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
-  { &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
-  { &nsGkAtoms::width, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
-  { &nsGkAtoms::height, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
-  { &nsGkAtoms::rx, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
-  { &nsGkAtoms::ry, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }
-};
-
-NS_IMPL_NS_NEW_SVG_ELEMENT(Rect)
-
-//----------------------------------------------------------------------
-// nsISupports methods
-
-NS_IMPL_ADDREF_INHERITED(nsSVGRectElement,nsSVGRectElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGRectElement,nsSVGRectElementBase)
-
-DOMCI_NODE_DATA(SVGRectElement, nsSVGRectElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGRectElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGRectElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
-                           nsIDOMSVGRectElement)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGRectElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGRectElementBase)
-
-//----------------------------------------------------------------------
-// Implementation
-
-nsSVGRectElement::nsSVGRectElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGRectElementBase(aNodeInfo)
-{
-}
-
-//----------------------------------------------------------------------
-// nsIDOMNode methods
-
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGRectElement)
-
-//----------------------------------------------------------------------
-// nsIDOMSVGRectElement methods
-
-/* readonly attribute nsIDOMSVGAnimatedLength x; */
-NS_IMETHODIMP nsSVGRectElement::GetX(nsIDOMSVGAnimatedLength * *aX)
-{
-  return mLengthAttributes[X].ToDOMAnimatedLength(aX, this);
-}
-
-/* readonly attribute nsIDOMSVGAnimatedLength y; */
-NS_IMETHODIMP nsSVGRectElement::GetY(nsIDOMSVGAnimatedLength * *aY)
-{
-  return mLengthAttributes[Y].ToDOMAnimatedLength(aY, this);
-}
-
-/* readonly attribute nsIDOMSVGAnimatedLength width; */
-NS_IMETHODIMP nsSVGRectElement::GetWidth(nsIDOMSVGAnimatedLength * *aWidth)
-{
-  return mLengthAttributes[WIDTH].ToDOMAnimatedLength(aWidth, this);
-}
-
-/* readonly attribute nsIDOMSVGAnimatedLength height; */
-NS_IMETHODIMP nsSVGRectElement::GetHeight(nsIDOMSVGAnimatedLength * *aHeight)
-{
-  return mLengthAttributes[HEIGHT].ToDOMAnimatedLength(aHeight, this);
-}
+} // namespace dom
+} // namespace mozilla
 
-/* readonly attribute nsIDOMSVGAnimatedLength rx; */
-NS_IMETHODIMP nsSVGRectElement::GetRx(nsIDOMSVGAnimatedLength * *aRx)
-{
-  return mLengthAttributes[RX].ToDOMAnimatedLength(aRx, this);
-}
-
-/* readonly attribute nsIDOMSVGAnimatedLength ry; */
-NS_IMETHODIMP nsSVGRectElement::GetRy(nsIDOMSVGAnimatedLength * *aRy)
-{
-  return mLengthAttributes[RY].ToDOMAnimatedLength(aRy, this);
-}
-
-//----------------------------------------------------------------------
-// nsSVGElement methods
-
-/* virtual */ bool
-nsSVGRectElement::HasValidDimensions() const
-{
-  return mLengthAttributes[WIDTH].IsExplicitlySet() &&
-         mLengthAttributes[WIDTH].GetAnimValInSpecifiedUnits() > 0 &&
-         mLengthAttributes[HEIGHT].IsExplicitlySet() &&
-         mLengthAttributes[HEIGHT].GetAnimValInSpecifiedUnits() > 0;
-}
-
-nsSVGElement::LengthAttributesInfo
-nsSVGRectElement::GetLengthInfo()
-{
-  return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
-                              ArrayLength(sLengthInfo));
-}
-
-//----------------------------------------------------------------------
-// nsSVGPathGeometryElement methods
-
-void
-nsSVGRectElement::ConstructPath(gfxContext *aCtx)
-{
-  float x, y, width, height, rx, ry;
-
-  GetAnimatedLengthValues(&x, &y, &width, &height, &rx, &ry, nullptr);
-
-  /* In a perfect world, this would be handled by the DOM, and
-     return a DOM exception. */
-  if (width <= 0 || height <= 0)
-    return;
-
-  rx = NS_MAX(rx, 0.0f);
-  ry = NS_MAX(ry, 0.0f);
-
-  /* optimize the no rounded corners case */
-  if (rx == 0 && ry == 0) {
-    aCtx->Rectangle(gfxRect(x, y, width, height));
-    return;
-  }
-
-  /* If either the 'rx' or the 'ry' attribute isn't set, then we
-     have to set it to the value of the other. */
-  bool hasRx = mLengthAttributes[RX].IsExplicitlySet();
-  bool hasRy = mLengthAttributes[RY].IsExplicitlySet();
-  if (hasRx && !hasRy)
-    ry = rx;
-  else if (hasRy && !hasRx)
-    rx = ry;
-
-  /* Clamp rx and ry to half the rect's width and height respectively. */
-  float halfWidth  = width/2;
-  float halfHeight = height/2;
-  if (rx > halfWidth)
-    rx = halfWidth;
-  if (ry > halfHeight)
-    ry = halfHeight;
-
-  gfxSize corner(rx, ry);
-  aCtx->RoundedRectangle(gfxRect(x, y, width, height),
-                         gfxCornerSizes(corner, corner, corner, corner));
-}
+#endif // mozilla_dom_SVGRectElement_h
rename from content/svg/content/src/nsSVGSetElement.cpp
rename to content/svg/content/src/SVGSetElement.cpp
--- a/content/svg/content/src/nsSVGSetElement.cpp
+++ b/content/svg/content/src/SVGSetElement.cpp
@@ -1,80 +1,59 @@
 /* -*- 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 "nsSVGAnimationElement.h"
-#include "nsIDOMSVGSetElement.h"
-#include "nsSMILSetAnimationFunction.h"
-
-typedef nsSVGAnimationElement nsSVGSetElementBase;
+#include "mozilla/dom/SVGSetElement.h"
+#include "mozilla/dom/SVGSetElementBinding.h"
 
-class nsSVGSetElement : public nsSVGSetElementBase,
-                        public nsIDOMSVGSetElement
-{
-protected:
-  friend nsresult NS_NewSVGSetElement(nsIContent **aResult,
-                                      already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGSetElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+DOMCI_NODE_DATA(SVGSetElement, mozilla::dom::SVGSetElement)
 
-  nsSMILSetAnimationFunction mAnimationFunction;
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Set)
 
-public:
-  // interfaces:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMSVGSETELEMENT
+namespace mozilla {
+namespace dom {
 
-  NS_FORWARD_NSIDOMNODE_TO_NSINODE
-  NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGSetElementBase::)
-  NS_FORWARD_NSIDOMSVGANIMATIONELEMENT(nsSVGSetElementBase::)
-  
-  // nsIDOMNode
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
-
-  // nsISMILAnimationElement
-  virtual nsSMILAnimationFunction& AnimationFunction();
-
-  virtual nsXPCClassInfo* GetClassInfo();
-
-  virtual nsIDOMNode* AsDOMNode() { return this; }
-};
-
-NS_IMPL_NS_NEW_SVG_ELEMENT(Set)
+JSObject*
+SVGSetElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return SVGSetElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_ADDREF_INHERITED(nsSVGSetElement,nsSVGSetElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGSetElement,nsSVGSetElementBase)
-
-DOMCI_NODE_DATA(SVGSetElement, nsSVGSetElement)
+NS_IMPL_ADDREF_INHERITED(SVGSetElement, SVGAnimationElement)
+NS_IMPL_RELEASE_INHERITED(SVGSetElement, SVGAnimationElement)
 
-NS_INTERFACE_TABLE_HEAD(nsSVGSetElement)
-  NS_NODE_INTERFACE_TABLE6(nsSVGSetElement, nsIDOMNode, nsIDOMElement,
+NS_INTERFACE_TABLE_HEAD(SVGSetElement)
+  NS_NODE_INTERFACE_TABLE5(SVGSetElement, nsIDOMNode, nsIDOMElement,
                            nsIDOMSVGElement, nsIDOMSVGAnimationElement,
-                           nsIDOMSVGTests, nsIDOMSVGSetElement)
+                           nsIDOMSVGSetElement)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGSetElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGSetElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGAnimationElement)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGSetElement::nsSVGSetElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGSetElementBase(aNodeInfo)
+SVGSetElement::SVGSetElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGAnimationElement(aNodeInfo)
 {
 }
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGSetElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGSetElement)
 
 //----------------------------------------------------------------------
 // nsISMILAnimationElement methods
 
 nsSMILAnimationFunction&
-nsSVGSetElement::AnimationFunction()
+SVGSetElement::AnimationFunction()
 {
   return mAnimationFunction;
 }
+
+} // namespace dom
+} // namespace mozilla
+
copy from content/svg/content/src/nsSVGSetElement.cpp
copy to content/svg/content/src/SVGSetElement.h
--- a/content/svg/content/src/nsSVGSetElement.cpp
+++ b/content/svg/content/src/SVGSetElement.h
@@ -1,80 +1,56 @@
 /* -*- 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 "nsSVGAnimationElement.h"
+#ifndef mozilla_dom_SVGSetElement_h
+#define mozilla_dom_SVGSetElement_h
+
+#include "mozilla/dom/SVGAnimationElement.h"
 #include "nsIDOMSVGSetElement.h"
 #include "nsSMILSetAnimationFunction.h"
 
-typedef nsSVGAnimationElement nsSVGSetElementBase;
+nsresult NS_NewSVGSetElement(nsIContent **aResult,
+                             already_AddRefed<nsINodeInfo> aNodeInfo);
 
-class nsSVGSetElement : public nsSVGSetElementBase,
-                        public nsIDOMSVGSetElement
+namespace mozilla {
+namespace dom {
+
+class SVGSetElement MOZ_FINAL : public SVGAnimationElement,
+                                public nsIDOMSVGSetElement
 {
 protected:
-  friend nsresult NS_NewSVGSetElement(nsIContent **aResult,
-                                      already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGSetElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  SVGSetElement(already_AddRefed<nsINodeInfo> aNodeInfo);
 
   nsSMILSetAnimationFunction mAnimationFunction;
 
+  friend nsresult (::NS_NewSVGSetElement(nsIContent **aResult,
+                                         already_AddRefed<nsINodeInfo> aNodeInfo));
+
+  virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
+
 public:
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMSVGSETELEMENT
 
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGSetElementBase::)
-  NS_FORWARD_NSIDOMSVGANIMATIONELEMENT(nsSVGSetElementBase::)
-  
+  NS_FORWARD_NSIDOMSVGELEMENT(SVGAnimationElement::)
+  NS_FORWARD_NSIDOMSVGANIMATIONELEMENT(SVGAnimationElement::)
+
   // nsIDOMNode
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   // nsISMILAnimationElement
   virtual nsSMILAnimationFunction& AnimationFunction();
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
 };
 
-NS_IMPL_NS_NEW_SVG_ELEMENT(Set)
-
-//----------------------------------------------------------------------
-// nsISupports methods
-
-NS_IMPL_ADDREF_INHERITED(nsSVGSetElement,nsSVGSetElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGSetElement,nsSVGSetElementBase)
-
-DOMCI_NODE_DATA(SVGSetElement, nsSVGSetElement)
-
-NS_INTERFACE_TABLE_HEAD(nsSVGSetElement)
-  NS_NODE_INTERFACE_TABLE6(nsSVGSetElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGAnimationElement,
-                           nsIDOMSVGTests, nsIDOMSVGSetElement)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGSetElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGSetElementBase)
+} // namespace dom
+} // namespace mozilla
 
-//----------------------------------------------------------------------
-// Implementation
-
-nsSVGSetElement::nsSVGSetElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGSetElementBase(aNodeInfo)
-{
-}
-
-//----------------------------------------------------------------------
-// nsIDOMNode methods
-
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGSetElement)
-
-//----------------------------------------------------------------------
-// nsISMILAnimationElement methods
-
-nsSMILAnimationFunction&
-nsSVGSetElement::AnimationFunction()
-{
-  return mAnimationFunction;
-}
+#endif // mozilla_dom_SVGSetElement_h
rename from content/svg/content/src/nsSVGSwitchElement.cpp
rename to content/svg/content/src/SVGSwitchElement.cpp
--- a/content/svg/content/src/nsSVGSwitchElement.cpp
+++ b/content/svg/content/src/SVGSwitchElement.cpp
@@ -1,65 +1,68 @@
 /* -*- 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 "nsSVGSwitchElement.h"
+#include "mozilla/dom/SVGSwitchElement.h"
 #include "DOMSVGTests.h"
 #include "nsIFrame.h"
 #include "nsSVGUtils.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/dom/SVGSwitchElementBinding.h"
 
-using namespace mozilla;
+DOMCI_NODE_DATA(SVGSwitchElement, mozilla::dom::SVGSwitchElement)
+
+NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Switch)
 
-////////////////////////////////////////////////////////////////////////
-// implementation
+namespace mozilla {
+namespace dom {
 
-
-NS_IMPL_NS_NEW_SVG_ELEMENT(Switch)
-
+JSObject*
+SVGSwitchElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return SVGSwitchElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsSVGSwitchElement)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsSVGSwitchElement,
-                                                  nsSVGSwitchElementBase)
+NS_IMPL_CYCLE_COLLECTION_CLASS(SVGSwitchElement)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SVGSwitchElement,
+                                                  SVGSwitchElementBase)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mActiveChild)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsSVGSwitchElement,
-                                                nsSVGSwitchElementBase)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SVGSwitchElement,
+                                                SVGSwitchElementBase)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mActiveChild)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
-NS_IMPL_ADDREF_INHERITED(nsSVGSwitchElement,nsSVGSwitchElementBase)
-NS_IMPL_RELEASE_INHERITED(nsSVGSwitchElement,nsSVGSwitchElementBase)
-
-DOMCI_NODE_DATA(SVGSwitchElement, nsSVGSwitchElement)
+NS_IMPL_ADDREF_INHERITED(SVGSwitchElement,SVGSwitchElementBase)
+NS_IMPL_RELEASE_INHERITED(SVGSwitchElement,SVGSwitchElementBase)
 
-NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsSVGSwitchElement)
-  NS_NODE_INTERFACE_TABLE5(nsSVGSwitchElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGSwitchElement,
-                           nsIDOMSVGTests)
+NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(SVGSwitchElement)
+  NS_NODE_INTERFACE_TABLE4(SVGSwitchElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGSwitchElement)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGSwitchElement)
-NS_INTERFACE_MAP_END_INHERITING(nsSVGSwitchElementBase)
+NS_INTERFACE_MAP_END_INHERITING(SVGSwitchElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
-nsSVGSwitchElement::nsSVGSwitchElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsSVGSwitchElementBase(aNodeInfo)
+SVGSwitchElement::SVGSwitchElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : SVGSwitchElementBase(aNodeInfo)
 {
+  SetIsDOMBinding();
 }
 
 void
-nsSVGSwitchElement::MaybeInvalidate()
+SVGSwitchElement::MaybeInvalidate()
 {
   // We must not change mActiveChild until after
   // InvalidateAndScheduleBoundsUpdate has been called, otherwise
   // it will not correctly invalidate the old mActiveChild area.
 
   nsIContent *newActiveChild = FindActiveChild();
 
   if (newActiveChild == mActiveChild) {
@@ -74,66 +77,66 @@ nsSVGSwitchElement::MaybeInvalidate()
 
   mActiveChild = newActiveChild;
 }
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 
-NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGSwitchElement)
+NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGSwitchElement)
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 nsresult
-nsSVGSwitchElement::InsertChildAt(nsIContent* aKid,
-                                  uint32_t aIndex,
-                                  bool aNotify)
+SVGSwitchElement::InsertChildAt(nsIContent* aKid,
+                                uint32_t aIndex,
+                                bool aNotify)
 {
-  nsresult rv = nsSVGSwitchElementBase::InsertChildAt(aKid, aIndex, aNotify);
+  nsresult rv = SVGSwitchElementBase::InsertChildAt(aKid, aIndex, aNotify);
   if (NS_SUCCEEDED(rv)) {
     MaybeInvalidate();
   }
   return rv;
 }
 
 void
-nsSVGSwitchElement::RemoveChildAt(uint32_t aIndex, bool aNotify)
+SVGSwitchElement::RemoveChildAt(uint32_t aIndex, bool aNotify)
 {
-  nsSVGSwitchElementBase::RemoveChildAt(aIndex, aNotify);
+  SVGSwitchElementBase::RemoveChildAt(aIndex, aNotify);
   MaybeInvalidate();
 }
- 
+
 //----------------------------------------------------------------------
 // nsIContent methods
 
 NS_IMETHODIMP_(bool)
-nsSVGSwitchElement::IsAttributeMapped(const nsIAtom* name) const
+SVGSwitchElement::IsAttributeMapped(const nsIAtom* name) const
 {
   static const MappedAttributeEntry* const map[] = {
     sFEFloodMap,
     sFiltersMap,
     sFontSpecificationMap,
     sGradientStopMap,
     sLightingEffectsMap,
     sMarkersMap,
     sTextContentElementsMap,
     sViewportsMap
   };
 
   return FindAttributeDependence(name, map) ||
-    nsSVGSwitchElementBase::IsAttributeMapped(name);
+    SVGSwitchElementBase::IsAttributeMapped(name);
 }
 
 //----------------------------------------------------------------------
 // Implementation Helpers:
 
 nsIContent *
-nsSVGSwitchElement::FindActiveChild() const
+SVGSwitchElement::FindActiveChild() const
 {
   bool allowReorder = AttrValueIs(kNameSpaceID_None,
                                     nsGkAtoms::allowReorder,
                                     nsGkAtoms::yes, eCaseMatters);
 
   const nsAdoptingString& acceptLangs =
     Preferences::GetLocalizedString("intl.accept_languages");
 
@@ -184,8 +187,12 @@ nsSVGSwitchElement::FindActiveChild() co
     }
     nsCOMPtr<DOMSVGTests> tests(do_QueryInterface(child));
     if (!tests || tests->PassesConditionalProcessingTests(&acceptLangs)) {
       return child;
     }
   }
   return nullptr;
 }
+
+} // namespace dom
+} // namespace mozilla
+
rename from content/svg/content/src/nsSVGSwitchElement.h
rename to content/svg/content/src/SVGSwitchElement.h
--- a/content/svg/content/src/nsSVGSwitchElement.h
+++ b/content/svg/content/src/SVGSwitchElement.h
@@ -1,48 +1,53 @@
 /* -*- 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 __NS_SVGSWITCHELEMENT_H__
-#define __NS_SVGSWITCHELEMENT_H__
+#ifndef mozilla_dom_SVGSwitchElement_h
+#define mozilla_dom_SVGSwitchElement_h
 
-#include "DOMSVGTests.h"
 #include "nsIDOMSVGSwitchElement.h"
-#include "nsSVGGraphicElement.h"
+#include "SVGGraphicsElement.h"
 
-typedef nsSVGGraphicElement nsSVGSwitchElementBase;
+nsresult NS_NewSVGSwitchElement(nsIContent **aResult,
+                                already_AddRefed<nsINodeInfo> aNodeInfo);
 
-class nsSVGSwitchElement : public nsSVGSwitchElementBase,
-                           public nsIDOMSVGSwitchElement,
-                           public DOMSVGTests
+namespace mozilla {
+namespace dom {
+
+typedef SVGGraphicsElement SVGSwitchElementBase;
+
+class SVGSwitchElement MOZ_FINAL : public SVGSwitchElementBase,
+                                   public nsIDOMSVGSwitchElement
 {
   friend class nsSVGSwitchFrame;
 protected:
-  friend nsresult NS_NewSVGSwitchElement(nsIContent **aResult,
-                                         already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGSwitchElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  friend nsresult (::NS_NewSVGSwitchElement(nsIContent **aResult,
+                                            already_AddRefed<nsINodeInfo> aNodeInfo));
+  SVGSwitchElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE;
 
 public:
   nsIContent * GetActiveChild() const
   { return mActiveChild; }
   void MaybeInvalidate();
-    
+
   // interfaces:
 
   NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsSVGSwitchElement,
-                                           nsSVGSwitchElementBase)
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGSwitchElement,
+                                           SVGSwitchElementBase)
   NS_DECL_NSIDOMSVGSWITCHELEMENT
 
   // xxx I wish we could use virtual inheritance
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGSwitchElementBase::)
+  NS_FORWARD_NSIDOMSVGELEMENT(SVGSwitchElementBase::)
 
   // nsINode
   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
                                  bool aNotify);
   virtual void RemoveChildAt(uint32_t aIndex, bool aNotify);
 
   // nsIContent
   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
@@ -56,9 +61,12 @@ private:
   void UpdateActiveChild()
   { mActiveChild = FindActiveChild(); }
   nsIContent* FindActiveChild() const;
 
   // only this child will be displayed
   nsCOMPtr<nsIContent> mActiveChild;
 };
 
-#endif // __NS_SVGSWITCHELEMENT_H__
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_SVGSwitchElement_h
new file mode 100644
--- /dev/null
+++ b/content/svg/content/src/SVGTransformableElement.cpp
@@ -0,0 +1,165 @@
+/* -*- 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/SVGTransformableElement.h"
+#include "DOMSVGAnimatedTransformList.h"
+#include "nsIDOMMutationEvent.h"
+#include "nsIFrame.h"
+#include "nsSVGUtils.h"
+#include "nsContentUtils.h"
+
+namespace mozilla {
+namespace dom {
+
+//----------------------------------------------------------------------
+// nsISupports methods
+
+NS_IMPL_ADDREF_INHERITED(SVGTransformableElement, SVGLocatableElement)
+NS_IMPL_RELEASE_INHERITED(SVGTransformableElement, SVGLocatableElement)
+
+NS_INTERFACE_MAP_BEGIN(SVGTransformableElement)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTransformable)
+NS_INTERFACE_MAP_END_INHERITING(SVGLocatableElement)
+
+
+//----------------------------------------------------------------------
+// nsIDOMSVGTransformable methods
+/* readonly attribute nsISupports transform; */
+
+NS_IMETHODIMP
+SVGTransformableElement::GetTransform(nsISupports **aTransform)
+{
+  *aTransform = Transform().get();
+  return NS_OK;
+}
+
+already_AddRefed<DOMSVGAnimatedTransformList>
+SVGTransformableElement::Transform()
+{
+  // We're creating a DOM wrapper, so we must tell GetAnimatedTransformList
+  // to allocate the SVGAnimatedTransformList if it hasn't already done so:
+  return DOMSVGAnimatedTransformList::GetDOMWrapper(
+           GetAnimatedTransformList(DO_ALLOCATE), this).get();
+
+}
+
+//----------------------------------------------------------------------
+// nsIContent methods
+
+NS_IMETHODIMP_(bool)
+SVGTransformableElement::IsAttributeMapped(const nsIAtom* name) const
+{
+  static const MappedAttributeEntry* const map[] = {
+    sColorMap,
+    sFillStrokeMap,
+    sGraphicsMap
+  };
+
+  return FindAttributeDependence(name, map) ||
+    SVGLocatableElement::IsAttributeMapped(name);
+}
+
+nsChangeHint
+SVGTransformableElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
+                                                int32_t aModType) const
+{
+  nsChangeHint retval =
+    SVGLocatableElement::GetAttributeChangeHint(aAttribute, aModType);
+  if (aAttribute == nsGkAtoms::transform ||
+      aAttribute == nsGkAtoms::mozAnimateMotionDummyAttr) {
+    // We add nsChangeHint_UpdateOverflow so that nsFrame::UpdateOverflow()
+    // will be called on us and our ancestors.
+    nsIFrame* frame =
+      const_cast<SVGTransformableElement*>(this)->GetPrimaryFrame();
+    if (!frame || (frame->GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD)) {
+      return retval; // no change
+    }
+    if (aModType == nsIDOMMutationEvent::ADDITION ||
+        aModType == nsIDOMMutationEvent::REMOVAL) {
+      // Reconstruct the frame tree to handle stacking context changes:
+      NS_UpdateHint(retval, nsChangeHint_ReconstructFrame);
+    } else {
+      NS_ABORT_IF_FALSE(aModType == nsIDOMMutationEvent::MODIFICATION,
+                        "Unknown modification type.");
+      // We just assume the old and new transforms are different.
+      NS_UpdateHint(retval, NS_CombineHint(nsChangeHint_UpdateOverflow,
+                                           nsChangeHint_UpdateTransformLayer));
+    }
+  }
+  return retval;
+}
+
+bool
+SVGTransformableElement::IsEventAttributeName(nsIAtom* aName)
+{
+  return nsContentUtils::IsEventAttributeName(aName, EventNameType_SVGGraphic);
+}
+
+//----------------------------------------------------------------------
+// nsSVGElement overrides
+
+gfxMatrix
+SVGTransformableElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
+                                                  TransformTypes aWhich) const
+{
+  NS_ABORT_IF_FALSE(aWhich != eChildToUserSpace || aMatrix.IsIdentity(),
+                    "Skipping eUserSpaceToParent transforms makes no sense");
+
+  gfxMatrix result(aMatrix);
+
+  if (aWhich == eChildToUserSpace) {
+    // We don't have anything to prepend.
+    // eChildToUserSpace is not the common case, which is why we return
+    // 'result' to benefit from NRVO rather than returning aMatrix before
+    // creating 'result'.
+    return result;
+  }
+
+  NS_ABORT_IF_FALSE(aWhich == eAllTransforms || aWhich == eUserSpaceToParent,
+                    "Unknown TransformTypes");
+
+  // animateMotion's resulting transform is supposed to apply *on top of*
+  // any transformations from the |transform| attribute. So since we're
+  // PRE-multiplying, we need to apply the animateMotion transform *first*.
+  if (mAnimateMotionTransform) {
+    result.PreMultiply(*mAnimateMotionTransform);
+  }
+
+  if (mTransforms) {
+    result.PreMultiply(mTransforms->GetAnimValue().GetConsolidationMatrix());
+  }
+
+  return result;
+}
+
+const gfxMatrix*
+SVGTransformableElement::GetAnimateMotionTransform() const
+{
+  return mAnimateMotionTransform.get();
+}
+
+void
+SVGTransformableElement::SetAnimateMotionTransform(const gfxMatrix* aMatrix)
+{
+  if ((!aMatrix && !mAnimateMotionTransform) ||
+      (aMatrix && mAnimateMotionTransform && *aMatrix == *mAnimateMotionTransform)) {
+    return;
+  }
+  mAnimateMotionTransform = aMatrix ? new gfxMatrix(*aMatrix) : nullptr;
+  DidAnimateTransformList();
+}
+
+SVGAnimatedTransformList*
+SVGTransformableElement::GetAnimatedTransformList(uint32_t aFlags)
+{
+  if (!mTransforms && (aFlags & DO_ALLOCATE)) {
+    mTransforms = new SVGAnimatedTransformList();
+  }
+  return mTransforms;
+}
+
+} // namespace dom
+} // namespace mozilla
+
new file mode 100644
--- /dev/null
+++ b/content/svg/content/src/SVGTransformableElement.h
@@ -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/. */
+
+#ifndef SVGTransformableElement_h
+#define SVGTransformableElement_h
+
+#include "mozilla/dom/SVGLocatableElement.h"
+#include "nsIDOMSVGTransformable.h"
+#include "gfxMatrix.h"
+#include "SVGAnimatedTransformList.h"
+
+#define MOZILLA_SVGTRANSFORMABLEELEMENT_IID \
+  { 0x77888cba, 0x0b43, 0x4654, \
+    {0x96, 0x3c, 0xf5, 0x50, 0xfc, 0xb5, 0x5e, 0x32}}
+
+namespace mozilla {
+class DOMSVGAnimatedTransformList;
+
+namespace dom {
+class SVGTransformableElement : public SVGLocatableElement,
+                                public nsIDOMSVGTransformable
+{
+public:
+  SVGTransformableElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+    : SVGLocatableElement(aNodeInfo) {}
+  virtual ~SVGTransformableElement() {}
+
+  NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_SVGTRANSFORMABLEELEMENT_IID)
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_NSIDOMSVGTRANSFORMABLE
+
+  // WebIDL
+  already_AddRefed<DOMSVGAnimatedTransformList> Transform();
+
+  // nsIContent interface
+  NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
+
+  nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
+                                      int32_t aModType) const;
+
+
+  virtual bool IsEventAttributeName(nsIAtom* aName) MOZ_OVERRIDE;
+
+
+  virtual gfxMatrix PrependLocalTransformsTo(const gfxMatrix &aMatrix,
+                      TransformTypes aWhich = eAllTransforms) const;
+  virtual const gfxMatrix* GetAnimateMotionTransform() const;
+  virtual void SetAnimateMotionTransform(const gfxMatrix* aMatrix);
+
+  virtual SVGAnimatedTransformList*
+    GetAnimatedTransformList(uint32_t aFlags = 0);
+  virtual nsIAtom* GetTransformListAttrName() const {
+    return nsGkAtoms::transform;
+  }
+
+protected:
+  // nsSVGElement overrides
+
+  nsAutoPtr<SVGAnimatedTransformList> mTransforms;
+
+  // XXX maybe move this to property table, to save space on un-animated elems?
+  nsAutoPtr<gfxMatrix> mAnimateMotionTransform;
+};
+
+NS_DEFINE_STATIC_IID_ACCESSOR(SVGTransformableElement,
+                              MOZILLA_SVGTRANSFORMABLEELEMENT_IID)
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // SVGTransformableElement_h
+
--- a/content/svg/content/src/nsSVGAElement.cpp
+++ b/content/svg/content/src/nsSVGAElement.cpp
@@ -1,17 +1,16 @@
 /* -*- 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 "nsSVGAElement.h"
-#include "nsSVGGraphicElement.h"
 #include "nsIDOMSVGAElement.h"
 #include "nsIDOMSVGURIReference.h"
 #include "nsILink.h"
 #include "nsSVGString.h"
 #include "nsCOMPtr.h"
 #include "nsGkAtoms.h"
 #include "nsContentUtils.h"
 
@@ -31,22 +30,21 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(A)
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGAElement, nsSVGAElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGAElement, nsSVGAElementBase)
 
 DOMCI_NODE_DATA(SVGAElement, nsSVGAElement)
 
 NS_INTERFACE_TABLE_HEAD(nsSVGAElement)
-  NS_NODE_INTERFACE_TABLE8(nsSVGAElement,
+  NS_NODE_INTERFACE_TABLE7(nsSVGAElement,
                            nsIDOMNode,
                            nsIDOMElement,
                            nsIDOMSVGElement,
                            nsIDOMSVGAElement,
-                           nsIDOMSVGTests,
                            nsIDOMSVGURIReference,
                            nsILink,
                            Link)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGAElementBase)
 
 
 //----------------------------------------------------------------------
@@ -287,17 +285,17 @@ nsSVGAElement::SetAttr(int32_t aNameSpac
 
   return rv;
 }
 
 nsresult
 nsSVGAElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttr,
                          bool aNotify)
 {
-  nsresult rv = nsSVGAElementBase::UnsetAttr(aNameSpaceID, aAttr, aNotify);
+  nsresult rv = nsSVGElement::UnsetAttr(aNameSpaceID, aAttr, aNotify);
 
   // The ordering of the parent class's UnsetAttr call and Link::ResetLinkState
   // is important here!  The attribute is not unset until UnsetAttr returns, and
   // we will need the updated attribute value because notifying the document
   // that content states have changed will call IntrinsicState, which will try
   // to get updated information about the visitedness from Link.
   if (aAttr == nsGkAtoms::href && aNameSpaceID == kNameSpaceID_XLink) {
     Link::ResetLinkState(!!aNotify, false);
--- a/content/svg/content/src/nsSVGAElement.h
+++ b/content/svg/content/src/nsSVGAElement.h
@@ -1,29 +1,27 @@
 /* -*- 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 NS_SVGAELEMENT_H_
 #define NS_SVGAELEMENT_H_
 
-#include "DOMSVGTests.h"
 #include "Link.h"
 #include "nsIDOMSVGAElement.h"
 #include "nsIDOMSVGURIReference.h"
 #include "nsILink.h"
-#include "nsSVGGraphicElement.h"
 #include "nsSVGString.h"
+#include "SVGGraphicsElement.h"
 
-typedef nsSVGGraphicElement nsSVGAElementBase;
+typedef mozilla::dom::SVGGraphicsElement nsSVGAElementBase;
 
 class nsSVGAElement : public nsSVGAElementBase,
                       public nsIDOMSVGAElement,
-                      public DOMSVGTests,
                       public nsIDOMSVGURIReference,
                       public nsILink,
                       public mozilla::dom::Link
 {
 protected:
   friend nsresult NS_NewSVGAElement(nsIContent **aResult,
                                     already_AddRefed<nsINodeInfo> aNodeInfo);
   nsSVGAElement(already_AddRefed<nsINodeInfo> aNodeInfo);
--- a/content/svg/content/src/nsSVGAltGlyphElement.cpp
+++ b/content/svg/content/src/nsSVGAltGlyphElement.cpp
@@ -74,20 +74,19 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(AltGlyph)
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGAltGlyphElement,nsSVGAltGlyphElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGAltGlyphElement,nsSVGAltGlyphElementBase)
 
 DOMCI_NODE_DATA(SVGAltGlyphElement, nsSVGAltGlyphElement)
 
 NS_INTERFACE_TABLE_HEAD(nsSVGAltGlyphElement)
-  NS_NODE_INTERFACE_TABLE8(nsSVGAltGlyphElement, nsIDOMNode, nsIDOMElement,
+  NS_NODE_INTERFACE_TABLE7(nsSVGAltGlyphElement, nsIDOMNode, nsIDOMElement,
                            nsIDOMSVGElement, nsIDOMSVGAltGlyphElement,
                            nsIDOMSVGTextPositioningElement, nsIDOMSVGTextContentElement,
-                           nsIDOMSVGTests,
                            nsIDOMSVGURIReference)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAltGlyphElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGAltGlyphElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGAltGlyphElement::nsSVGAltGlyphElement(already_AddRefed<nsINodeInfo> aNodeInfo)
--- a/content/svg/content/src/nsSVGClipPathElement.cpp
+++ b/content/svg/content/src/nsSVGClipPathElement.cpp
@@ -24,18 +24,18 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(ClipPath)
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGClipPathElement,nsSVGClipPathElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGClipPathElement,nsSVGClipPathElementBase)
 
 DOMCI_NODE_DATA(SVGClipPathElement, nsSVGClipPathElement)
 
 NS_INTERFACE_TABLE_HEAD(nsSVGClipPathElement)
-  NS_NODE_INTERFACE_TABLE6(nsSVGClipPathElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
+  NS_NODE_INTERFACE_TABLE5(nsSVGClipPathElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
                            nsIDOMSVGClipPathElement,
                            nsIDOMSVGUnitTypes)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGClipPathElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGClipPathElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
--- a/content/svg/content/src/nsSVGClipPathElement.h
+++ b/content/svg/content/src/nsSVGClipPathElement.h
@@ -1,27 +1,25 @@
 /* -*- 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 __NS_SVGCLIPPATHELEMENT_H__
 #define __NS_SVGCLIPPATHELEMENT_H__
 
-#include "DOMSVGTests.h"
 #include "nsIDOMSVGClipPathElement.h"
 #include "nsIDOMSVGUnitTypes.h"
 #include "nsSVGEnum.h"
-#include "nsSVGGraphicElement.h"
+#include "mozilla/dom/SVGTransformableElement.h"
 
-typedef nsSVGGraphicElement nsSVGClipPathElementBase;
+typedef mozilla::dom::SVGTransformableElement nsSVGClipPathElementBase;
 
 class nsSVGClipPathElement : public nsSVGClipPathElementBase,
                              public nsIDOMSVGClipPathElement,
-                             public DOMSVGTests,
                              public nsIDOMSVGUnitTypes
 {
   friend class nsSVGClipPathFrame;
 
 protected:
   friend nsresult NS_NewSVGClipPathElement(nsIContent **aResult,
                                            already_AddRefed<nsINodeInfo> aNodeInfo);
   nsSVGClipPathElement(already_AddRefed<nsINodeInfo> aNodeInfo);
@@ -31,16 +29,18 @@ public:
   
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMSVGCLIPPATHELEMENT
 
   // xxx I wish we could use virtual inheritance
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
   NS_FORWARD_NSIDOMSVGELEMENT(nsSVGClipPathElementBase::)
+  NS_FORWARD_NSIDOMSVGLOCATABLE(mozilla::dom::SVGLocatableElement::)
+  NS_FORWARD_NSIDOMSVGTRANSFORMABLE(mozilla::dom::SVGTransformableElement::)
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
 protected:
 
--- a/content/svg/content/src/nsSVGElement.cpp
+++ b/content/svg/content/src/nsSVGElement.cpp
@@ -1169,29 +1169,26 @@ nsSVGElement::GetOwnerSVGElement(ErrorRe
 
   return ownerSVGElement;
 }
 
 /* readonly attribute nsIDOMSVGElement viewportElement; */
 NS_IMETHODIMP
 nsSVGElement::GetViewportElement(nsIDOMSVGElement * *aViewportElement)
 {
-  nsCOMPtr<nsSVGElement> elem = GetViewportElement();
+  nsSVGElement* elem = GetViewportElement();
   nsCOMPtr<nsIDOMSVGElement> svgElem = do_QueryInterface(elem);
   svgElem.forget(aViewportElement);
   return NS_OK;
 }
 
-already_AddRefed<nsSVGElement>
+nsSVGElement*
 nsSVGElement::GetViewportElement()
 {
-  nsCOMPtr<nsIDOMSVGElement> elem =
-    SVGContentUtils::GetNearestViewportElement(this);
-  nsCOMPtr<nsSVGElement> svgElem = do_QueryInterface(elem);
-  return svgElem.forget();
+  return SVGContentUtils::GetNearestViewportElement(this);
 }
 
 already_AddRefed<nsIDOMSVGAnimatedString>
 nsSVGElement::ClassName()
 {
   nsCOMPtr<nsIDOMSVGAnimatedString> className;
   mClassAttribute.ToDOMAnimatedString(getter_AddRefs(className), this);
   return className.forget();
--- a/content/svg/content/src/nsSVGElement.h
+++ b/content/svg/content/src/nsSVGElement.h
@@ -295,17 +295,17 @@ public:
     return nullptr;
   }
   virtual nsIAtom* GetTransformListAttrName() const {
     return nullptr;
   }
 
   // WebIDL
   nsSVGSVGElement* GetOwnerSVGElement(mozilla::ErrorResult& rv);
-  already_AddRefed<nsSVGElement> GetViewportElement();
+  nsSVGElement* GetViewportElement();
   already_AddRefed<nsIDOMSVGAnimatedString> ClassName();
   nsICSSDeclaration* GetStyle(mozilla::ErrorResult& rv);
   already_AddRefed<mozilla::dom::CSSValue> GetPresentationAttribute(const nsAString& aName, mozilla::ErrorResult& rv);
 protected:
   virtual JSObject* WrapNode(JSContext *cx, JSObject *scope, bool *triedToWrap);
 
 #ifdef DEBUG
   // We define BeforeSetAttr here and mark it MOZ_FINAL to ensure it is NOT used
--- a/content/svg/content/src/nsSVGFilterElement.cpp
+++ b/content/svg/content/src/nsSVGFilterElement.cpp
@@ -48,18 +48,18 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(Filter)
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFilterElement,nsSVGFilterElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFilterElement,nsSVGFilterElementBase)
 
 DOMCI_NODE_DATA(SVGFilterElement, nsSVGFilterElement)
 
 NS_INTERFACE_TABLE_HEAD(nsSVGFilterElement)
-  NS_NODE_INTERFACE_TABLE6(nsSVGFilterElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
+  NS_NODE_INTERFACE_TABLE5(nsSVGFilterElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
                            nsIDOMSVGFilterElement,
                            nsIDOMSVGURIReference)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGFilterElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFilterElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
@@ -161,17 +161,17 @@ nsSVGFilterElement::IsAttributeMapped(co
     sFontSpecificationMap,
     sGradientStopMap,
     sLightingEffectsMap,
     sMarkersMap,
     sTextContentElementsMap,
     sViewportsMap
   };
   return FindAttributeDependence(name, map) ||
-    nsSVGGraphicElementBase::IsAttributeMapped(name);
+    nsSVGFilterElementBase::IsAttributeMapped(name);
 }
 
 void
 nsSVGFilterElement::Invalidate()
 {
   nsTObserverArray<nsIMutationObserver*> *observers = GetMutationObservers();
 
   if (observers && !observers->IsEmpty()) {
--- a/content/svg/content/src/nsSVGFilterElement.h
+++ b/content/svg/content/src/nsSVGFilterElement.h
@@ -1,31 +1,29 @@
 /* -*- 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 __NS_SVGFILTERELEMENT_H__
 #define __NS_SVGFILTERELEMENT_H__
 
-#include "DOMSVGTests.h"
 #include "nsIDOMSVGFilterElement.h"
 #include "nsIDOMSVGUnitTypes.h"
 #include "nsIDOMSVGURIReference.h"
 #include "nsSVGEnum.h"
-#include "nsSVGGraphicElement.h"
+#include "nsSVGElement.h"
 #include "nsSVGIntegerPair.h"
 #include "nsSVGLength2.h"
 #include "nsSVGString.h"
 
-typedef nsSVGGraphicElement nsSVGFilterElementBase;
+typedef nsSVGElement nsSVGFilterElementBase;
 
 class nsSVGFilterElement : public nsSVGFilterElementBase,
                            public nsIDOMSVGFilterElement,
-                           public DOMSVGTests,
                            public nsIDOMSVGURIReference,
                            public nsIDOMSVGUnitTypes
 {
   friend class nsSVGFilterFrame;
   friend class nsAutoFilterInstance;
 
 protected:
   friend nsresult NS_NewSVGFilterElement(nsIContent **aResult,
deleted file mode 100644
--- a/content/svg/content/src/nsSVGForeignObjectElement.h
+++ /dev/null
@@ -1,60 +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/. */
-
-#ifndef __NS_SVGFOREIGNOBJECTELEMENT_H__
-#define __NS_SVGFOREIGNOBJECTELEMENT_H__
-
-#include "DOMSVGTests.h"
-#include "nsIDOMSVGForeignObjectElem.h"
-#include "nsSVGGraphicElement.h"
-#include "nsSVGLength2.h"
-
-typedef nsSVGGraphicElement nsSVGForeignObjectElementBase;
-
-class nsSVGForeignObjectElement : public nsSVGForeignObjectElementBase,
-                                  public nsIDOMSVGForeignObjectElement,
-                                  public DOMSVGTests
-{
-  friend class nsSVGForeignObjectFrame;
-
-protected:
-  friend nsresult NS_NewSVGForeignObjectElement(nsIContent **aResult,
-                                                already_AddRefed<nsINodeInfo> aNodeInfo);
-  nsSVGForeignObjectElement(already_AddRefed<nsINodeInfo> aNodeInfo);
-
-public:
-  // interfaces:
-  
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMSVGFOREIGNOBJECTELEMENT
-
-  // xxx I wish we could use virtual inheritance
-  NS_FORWARD_NSIDOMNODE_TO_NSINODE
-  NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-  NS_FORWARD_NSIDOMSVGELEMENT(nsSVGForeignObjectElementBase::)
-
-  // nsSVGElement specializations:
-  virtual gfxMatrix PrependLocalTransformsTo(const gfxMatrix &aMatrix,
-                      TransformTypes aWhich = eAllTransforms) const;
-  virtual bool HasValidDimensions() const;
-
-  // nsIContent interface
-  NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const;
-
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
-
-  virtual nsXPCClassInfo* GetClassInfo();
-
-  virtual nsIDOMNode* AsDOMNode() { return this; }
-protected:
-
-  virtual LengthAttributesInfo GetLengthInfo();
-  
-  enum { X, Y, WIDTH, HEIGHT };
-  nsSVGLength2 mLengthAttributes[4];
-  static LengthInfo sLengthInfo[4];
-};
-
-#endif
--- a/content/svg/content/src/nsSVGLength2.cpp
+++ b/content/svg/content/src/nsSVGLength2.cpp
@@ -481,25 +481,31 @@ nsSVGLength2::SetAnimValue(float aValue,
                                                            mSpecifiedUnitType),
                                aSVGElement);
 }
 
 nsresult
 nsSVGLength2::ToDOMAnimatedLength(nsIDOMSVGAnimatedLength **aResult,
                                   nsSVGElement *aSVGElement)
 {
+  *aResult = ToDOMAnimatedLength(aSVGElement).get();
+  return NS_OK;
+}
+
+already_AddRefed<nsIDOMSVGAnimatedLength>
+nsSVGLength2::ToDOMAnimatedLength(nsSVGElement* aSVGElement)
+{
   nsRefPtr<DOMAnimatedLength> domAnimatedLength =
     sSVGAnimatedLengthTearoffTable.GetTearoff(this);
   if (!domAnimatedLength) {
     domAnimatedLength = new DOMAnimatedLength(this, aSVGElement);
     sSVGAnimatedLengthTearoffTable.AddTearoff(this, domAnimatedLength);
   }
 
-  domAnimatedLength.forget(aResult);
-  return NS_OK;
+  return domAnimatedLength.forget();
 }
 
 nsSVGLength2::DOMAnimatedLength::~DOMAnimatedLength()
 {
   sSVGAnimatedLengthTearoffTable.RemoveTearoff(mVal);
 }
 
 nsISMILAttr*
--- a/content/svg/content/src/nsSVGLength2.h
+++ b/content/svg/content/src/nsSVGLength2.h
@@ -80,16 +80,20 @@ public:
   // explicitly set by markup or a DOM call), false otherwise.
   // If this returns false, the animated value is still valid, that is,
   // useable, and represents the default base value of the attribute.
   bool IsExplicitlySet() const
     { return mIsAnimated || mIsBaseSet; }
   
   nsresult ToDOMAnimatedLength(nsIDOMSVGAnimatedLength **aResult,
                                nsSVGElement* aSVGElement);
+
+  already_AddRefed<nsIDOMSVGAnimatedLength>
+  ToDOMAnimatedLength(nsSVGElement* aSVGElement);
+
   // Returns a new nsISMILAttr object that the caller must delete
   nsISMILAttr* ToSMILAttr(nsSVGElement* aSVGElement);
 
 private:
   
   float mAnimVal;
   float mBaseVal;
   uint8_t mSpecifiedUnitType;
--- a/content/svg/content/src/nsSVGMarkerElement.cpp
+++ b/content/svg/content/src/nsSVGMarkerElement.cpp
@@ -11,16 +11,17 @@
 #include "nsError.h"
 #include "nsSVGMarkerElement.h"
 #include "gfxMatrix.h"
 #include "nsContentUtils.h" // NS_ENSURE_FINITE
 #include "SVGContentUtils.h"
 #include "SVGAngle.h"
 
 using namespace mozilla;
+using namespace mozilla::dom;
 
 nsSVGElement::LengthInfo nsSVGMarkerElement::sLengthInfo[4] =
 {
   { &nsGkAtoms::refX, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::refY, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
   { &nsGkAtoms::markerWidth, 3, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::markerHeight, 3, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
 };
@@ -123,17 +124,20 @@ NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGMar
   return mViewBox.ToDOMAnimatedRect(aViewBox, this);
 }
 
 /* readonly attribute SVGPreserveAspectRatio preserveAspectRatio; */
 NS_IMETHODIMP
 nsSVGMarkerElement::GetPreserveAspectRatio(nsISupports
                                            **aPreserveAspectRatio)
 {
-  return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(aPreserveAspectRatio, this);
+  nsRefPtr<DOMSVGAnimatedPreserveAspectRatio> ratio;
+  mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this);
+  ratio.forget(aPreserveAspectRatio);
+  return NS_OK;
 }
 
 //----------------------------------------------------------------------
 // nsIDOMSVGMarkerElement methods
 
 /* readonly attribute nsIDOMSVGAnimatedLength refX; */
 NS_IMETHODIMP nsSVGMarkerElement::GetRefX(nsIDOMSVGAnimatedLength * *aRefX)
 {
@@ -257,17 +261,17 @@ nsSVGMarkerElement::UnsetAttr(int32_t aN
                               bool aNotify)
 {
   if (aNamespaceID == kNameSpaceID_None) {
     if (aName == nsGkAtoms::orient) {
       mOrientType.SetBaseValue(SVG_MARKER_ORIENT_ANGLE);
     }
   }
 
-  return nsSVGMarkerElementBase::UnsetAttr(aNamespaceID, aName, aNotify);
+  return nsSVGElement::UnsetAttr(aNamespaceID, aName, aNotify);
 }
 
 //----------------------------------------------------------------------
 // nsSVGElement methods
 
 void 
 nsSVGMarkerElement::SetParentCoordCtxProvider(nsSVGSVGElement *aContext)
 {
--- a/content/svg/content/src/nsSVGMarkerElement.h
+++ b/content/svg/content/src/nsSVGMarkerElement.h
@@ -6,20 +6,20 @@
 #ifndef __NS_SVGMARKERELEMENT_H__
 #define __NS_SVGMARKERELEMENT_H__
 
 #include "gfxMatrix.h"
 #include "nsIDOMSVGFitToViewBox.h"
 #include "nsIDOMSVGMarkerElement.h"
 #include "nsSVGAngle.h"
 #include "nsSVGEnum.h"
-#include "nsSVGGraphicElement.h"
 #include "nsSVGLength2.h"
 #include "nsSVGViewBox.h"
 #include "SVGAnimatedPreserveAspectRatio.h"
+#include "SVGGraphicsElement.h"
 #include "mozilla/Attributes.h"
 
 class nsSVGOrientType
 {
 public:
   nsSVGOrientType()
    : mAnimVal(nsIDOMSVGMarkerElement::SVG_MARKER_ORIENT_ANGLE),
      mBaseVal(nsIDOMSVGMarkerElement::SVG_MARKER_ORIENT_ANGLE) {}
@@ -63,17 +63,17 @@ private:
       { *aResult = mVal->GetBaseValue(); return NS_OK; }
     NS_IMETHOD SetBaseVal(uint16_t aValue)
       { return mVal->SetBaseValue(aValue, mSVGElement); }
     NS_IMETHOD GetAnimVal(uint16_t* aResult)
       { *aResult = mVal->GetAnimValue(); return NS_OK; }
   };
 };
 
-typedef nsSVGGraphicElement nsSVGMarkerElementBase;
+typedef mozilla::dom::SVGGraphicsElement nsSVGMarkerElementBase;
 
 class nsSVGMarkerElement : public nsSVGMarkerElementBase,
                            public nsIDOMSVGMarkerElement,
                            public nsIDOMSVGFitToViewBox
 {
   friend class nsSVGMarkerFrame;
 
 protected:
--- a/content/svg/content/src/nsSVGMaskElement.cpp
+++ b/content/svg/content/src/nsSVGMaskElement.cpp
@@ -39,18 +39,18 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(Mask)
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGMaskElement,nsSVGMaskElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGMaskElement,nsSVGMaskElementBase)
 
 DOMCI_NODE_DATA(SVGMaskElement, nsSVGMaskElement)
 
 NS_INTERFACE_TABLE_HEAD(nsSVGMaskElement)
-  NS_NODE_INTERFACE_TABLE6(nsSVGMaskElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
+  NS_NODE_INTERFACE_TABLE5(nsSVGMaskElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
                            nsIDOMSVGMaskElement, nsIDOMSVGUnitTypes)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGMaskElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGMaskElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGMaskElement::nsSVGMaskElement(already_AddRefed<nsINodeInfo> aNodeInfo)
--- a/content/svg/content/src/nsSVGMaskElement.h
+++ b/content/svg/content/src/nsSVGMaskElement.h
@@ -1,30 +1,28 @@
 /* -*- 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 __NS_SVGMASKELEMENT_H__
 #define __NS_SVGMASKELEMENT_H__
 
-#include "DOMSVGTests.h"
 #include "nsIDOMSVGMaskElement.h"
 #include "nsIDOMSVGUnitTypes.h"
 #include "nsSVGEnum.h"
 #include "nsSVGLength2.h"
 #include "nsSVGElement.h"
 
 //--------------------- Masks ------------------------
 
 typedef nsSVGElement nsSVGMaskElementBase;
 
 class nsSVGMaskElement : public nsSVGMaskElementBase,
                          public nsIDOMSVGMaskElement,
-                         public DOMSVGTests,
                          public nsIDOMSVGUnitTypes
 {
   friend class nsSVGMaskFrame;
 
 protected:
   friend nsresult NS_NewSVGMaskElement(nsIContent **aResult,
                                        already_AddRefed<nsINodeInfo> aNodeInfo);
   nsSVGMaskElement(already_AddRefed<nsINodeInfo> aNodeInfo);
--- a/content/svg/content/src/nsSVGPathElement.cpp
+++ b/content/svg/content/src/nsSVGPathElement.cpp
@@ -25,18 +25,18 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(Path)
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGPathElement,nsSVGPathElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGPathElement,nsSVGPathElementBase)
 
 DOMCI_NODE_DATA(SVGPathElement, nsSVGPathElement)
 
 NS_INTERFACE_TABLE_HEAD(nsSVGPathElement)
-  NS_NODE_INTERFACE_TABLE6(nsSVGPathElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
+  NS_NODE_INTERFACE_TABLE5(nsSVGPathElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
                            nsIDOMSVGPathElement, nsIDOMSVGAnimatedPathData)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGPathElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGPathElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGPathElement::nsSVGPathElement(already_AddRefed<nsINodeInfo> aNodeInfo)
--- a/content/svg/content/src/nsSVGPathGeometryElement.cpp
+++ b/content/svg/content/src/nsSVGPathGeometryElement.cpp
@@ -7,17 +7,16 @@
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGPathGeometryElement, nsSVGPathGeometryElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGPathGeometryElement, nsSVGPathGeometryElementBase)
 
 NS_INTERFACE_MAP_BEGIN(nsSVGPathGeometryElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTests)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGPathGeometryElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGPathGeometryElement::nsSVGPathGeometryElement(already_AddRefed<nsINodeInfo> aNodeInfo)
   : nsSVGPathGeometryElementBase(aNodeInfo)
 {
--- a/content/svg/content/src/nsSVGPathGeometryElement.h
+++ b/content/svg/content/src/nsSVGPathGeometryElement.h
@@ -1,33 +1,31 @@
 /* -*- 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 __NS_SVGPATHGEOMETRYELEMENT_H__
 #define __NS_SVGPATHGEOMETRYELEMENT_H__
 
-#include "DOMSVGTests.h"
 #include "gfxMatrix.h"
-#include "nsSVGGraphicElement.h"
+#include "SVGGraphicsElement.h"
 #include "nsTArray.h"
 
 struct nsSVGMark {
   float x, y, angle;
   nsSVGMark(float aX, float aY, float aAngle) :
     x(aX), y(aY), angle(aAngle) {}
 };
 
 class gfxContext;
 
-typedef nsSVGGraphicElement nsSVGPathGeometryElementBase;
+typedef mozilla::dom::SVGGraphicsElement nsSVGPathGeometryElementBase;
 
-class nsSVGPathGeometryElement : public nsSVGPathGeometryElementBase,
-                                 public DOMSVGTests
+class nsSVGPathGeometryElement : public nsSVGPathGeometryElementBase
 {
 public:
   nsSVGPathGeometryElement(already_AddRefed<nsINodeInfo> aNodeInfo);
 
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
 
   virtual bool AttributeDefinesGeometry(const nsIAtom *aName);
--- a/content/svg/content/src/nsSVGPatternElement.cpp
+++ b/content/svg/content/src/nsSVGPatternElement.cpp
@@ -7,16 +7,17 @@
 
 #include "DOMSVGAnimatedTransformList.h"
 #include "nsIDOMMutationEvent.h"
 #include "nsCOMPtr.h"
 #include "nsGkAtoms.h"
 #include "nsSVGPatternElement.h"
 
 using namespace mozilla;
+using namespace mozilla::dom;
 
 //--------------------- Patterns ------------------------
 
 nsSVGElement::LengthInfo nsSVGPatternElement::sLengthInfo[4] =
 {
   { &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X },
   { &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y },
   { &nsGkAtoms::width, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X },
@@ -46,18 +47,18 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(Pattern)
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGPatternElement,nsSVGPatternElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGPatternElement,nsSVGPatternElementBase)
 
 DOMCI_NODE_DATA(SVGPatternElement, nsSVGPatternElement)
 
 NS_INTERFACE_TABLE_HEAD(nsSVGPatternElement)
-  NS_NODE_INTERFACE_TABLE8(nsSVGPatternElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
+  NS_NODE_INTERFACE_TABLE7(nsSVGPatternElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
                            nsIDOMSVGFitToViewBox, nsIDOMSVGURIReference,
                            nsIDOMSVGPatternElement, nsIDOMSVGUnitTypes)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGPatternElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGPatternElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
@@ -80,17 +81,20 @@ NS_IMETHODIMP nsSVGPatternElement::GetVi
   return mViewBox.ToDOMAnimatedRect(aViewBox, this);
 }
 
 /* readonly attribute SVGPreserveAspectRatio preserveAspectRatio; */
 NS_IMETHODIMP
 nsSVGPatternElement::GetPreserveAspectRatio(nsISupports
                                             **aPreserveAspectRatio)
 {
-  return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(aPreserveAspectRatio, this);
+  nsRefPtr<DOMSVGAnimatedPreserveAspectRatio> ratio;
+  mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this);
+  ratio.forget(aPreserveAspectRatio);
+  return NS_OK;
 }
 
 //----------------------------------------------------------------------
 // nsIDOMSVGPatternElement methods
 
 /* readonly attribute nsIDOMSVGAnimatedEnumeration patternUnits; */
 NS_IMETHODIMP nsSVGPatternElement::GetPatternUnits(nsIDOMSVGAnimatedEnumeration * *aPatternUnits)
 {
--- a/content/svg/content/src/nsSVGPatternElement.h
+++ b/content/svg/content/src/nsSVGPatternElement.h
@@ -1,17 +1,16 @@
 /* -*- 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 __NS_SVGPATTERNELEMENT_H__
 #define __NS_SVGPATTERNELEMENT_H__
 
-#include "DOMSVGTests.h"
 #include "nsIDOMSVGFitToViewBox.h"
 #include "nsIDOMSVGPatternElement.h"
 #include "nsIDOMSVGUnitTypes.h"
 #include "nsIDOMSVGURIReference.h"
 #include "nsSVGEnum.h"
 #include "nsSVGLength2.h"
 #include "nsSVGString.h"
 #include "nsSVGElement.h"
@@ -20,17 +19,16 @@
 #include "SVGAnimatedTransformList.h"
 
 //--------------------- Patterns ------------------------
 
 typedef nsSVGElement nsSVGPatternElementBase;
 
 class nsSVGPatternElement : public nsSVGPatternElementBase,
                             public nsIDOMSVGPatternElement,
-                            public DOMSVGTests,
                             public nsIDOMSVGURIReference,
                             public nsIDOMSVGFitToViewBox,
                             public nsIDOMSVGUnitTypes
 {
   friend class nsSVGPatternFrame;
 
 protected:
   friend nsresult NS_NewSVGPatternElement(nsIContent **aResult,
--- a/content/svg/content/src/nsSVGPolyElement.cpp
+++ b/content/svg/content/src/nsSVGPolyElement.cpp
@@ -23,40 +23,55 @@ NS_INTERFACE_MAP_BEGIN(nsSVGPolyElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGPolyElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGPolyElement::nsSVGPolyElement(already_AddRefed<nsINodeInfo> aNodeInfo)
   : nsSVGPolyElementBase(aNodeInfo)
 {
-
+  SetIsDOMBinding();
 }
 
 //----------------------------------------------------------------------
 // nsIDOMSGAnimatedPoints methods:
 
 /* readonly attribute DOMSVGPointList points; */
-NS_IMETHODIMP 
+NS_IMETHODIMP
 nsSVGPolyElement::GetPoints(nsISupports * *aPoints)
 {
-  void *key = mPoints.GetBaseValKey();
-  *aPoints = DOMSVGPointList::GetDOMWrapper(key, this, false).get();
+  *aPoints = Points().get();
   return NS_OK;
 }
 
+already_AddRefed<DOMSVGPointList>
+nsSVGPolyElement::Points()
+{
+  void *key = mPoints.GetBaseValKey();
+  nsRefPtr<DOMSVGPointList> points = DOMSVGPointList::GetDOMWrapper(key, this, false);
+  return points.forget();
+}
+
 /* readonly attribute DOMSVGPointList animatedPoints; */
-NS_IMETHODIMP 
+NS_IMETHODIMP
 nsSVGPolyElement::GetAnimatedPoints(nsISupports * *aAnimatedPoints)
 {
-  void *key = mPoints.GetAnimValKey();
-  *aAnimatedPoints = DOMSVGPointList::GetDOMWrapper(key, this, true).get();
+  *aAnimatedPoints = AnimatedPoints().get();
   return NS_OK;
 }
 
+already_AddRefed<DOMSVGPointList>
+nsSVGPolyElement::AnimatedPoints()
+{
+  void *key = mPoints.GetAnimValKey();
+  nsRefPtr<DOMSVGPointList> points = DOMSVGPointList::GetDOMWrapper(key, this, true);
+  return points.forget();
+}
+
+
 //----------------------------------------------------------------------
 // nsIContent methods
 
 NS_IMETHODIMP_(bool)
 nsSVGPolyElement::IsAttributeMapped(const nsIAtom* name) const
 {
   static const MappedAttributeEntry* const map[] = {
     sMarkersMap
--- a/content/svg/content/src/nsSVGPolyElement.h
+++ b/content/svg/content/src/nsSVGPolyElement.h
@@ -9,16 +9,20 @@
 #include "nsIDOMSVGAnimatedPoints.h"
 #include "nsSVGPathGeometryElement.h"
 #include "SVGAnimatedPointList.h"
 
 typedef nsSVGPathGeometryElement nsSVGPolyElementBase;
 
 class gfxContext;
 
+namespace mozilla {
+class DOMSVGPointList;
+}
+
 class nsSVGPolyElement : public nsSVGPolyElementBase,
                          public nsIDOMSVGAnimatedPoints
 {
 protected:
   nsSVGPolyElement(already_AddRefed<nsINodeInfo> aNodeInfo);
 
 public:
   //interfaces
@@ -37,13 +41,17 @@ public:
   }
 
   // nsSVGPathGeometryElement methods:
   virtual bool AttributeDefinesGeometry(const nsIAtom *aName);
   virtual bool IsMarkable() { return true; }
   virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks);
   virtual void ConstructPath(gfxContext *aCtx);
 
+  // WebIDL
+  already_AddRefed<mozilla::DOMSVGPointList> Points();
+  already_AddRefed<mozilla::DOMSVGPointList> AnimatedPoints();
+
 protected:
   SVGAnimatedPointList mPoints;
 };
 
 #endif //NS_SVGPOLYELEMENT_H_
--- a/content/svg/content/src/nsSVGSVGElement.cpp
+++ b/content/svg/content/src/nsSVGSVGElement.cpp
@@ -133,20 +133,20 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_ADDREF_INHERITED(nsSVGSVGElement,nsSVGSVGElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGSVGElement,nsSVGSVGElementBase)
 
 DOMCI_NODE_DATA(SVGSVGElement, nsSVGSVGElement)
 
 NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsSVGSVGElement)
-  NS_NODE_INTERFACE_TABLE8(nsSVGSVGElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
+  NS_NODE_INTERFACE_TABLE6(nsSVGSVGElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
                            nsIDOMSVGSVGElement,
-                           nsIDOMSVGFitToViewBox, nsIDOMSVGLocatable,
+                           nsIDOMSVGFitToViewBox,
                            nsIDOMSVGZoomAndPan)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGSVGElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGSVGElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGSVGElement::nsSVGSVGElement(already_AddRefed<nsINodeInfo> aNodeInfo,
@@ -590,101 +590,19 @@ nsSVGSVGElement::GetViewBox(nsIDOMSVGAni
   return mViewBox.ToDOMAnimatedRect(aViewBox, this);
 }
 
 /* readonly attribute SVGPreserveAspectRatio preserveAspectRatio; */
 NS_IMETHODIMP
 nsSVGSVGElement::GetPreserveAspectRatio(nsISupports
                                         **aPreserveAspectRatio)
 {
-  return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(aPreserveAspectRatio, this);
-}
-
-//----------------------------------------------------------------------
-// nsIDOMSVGLocatable methods
-
-/* readonly attribute nsIDOMSVGElement nearestViewportElement; */
-NS_IMETHODIMP
-nsSVGSVGElement::GetNearestViewportElement(nsIDOMSVGElement * *aNearestViewportElement)
-{
-  *aNearestViewportElement = SVGContentUtils::GetNearestViewportElement(this).get();
-  return NS_OK;
-}
-
-/* readonly attribute nsIDOMSVGElement farthestViewportElement; */
-NS_IMETHODIMP
-nsSVGSVGElement::GetFarthestViewportElement(nsIDOMSVGElement * *aFarthestViewportElement)
-{
-  NS_IF_ADDREF(*aFarthestViewportElement = SVGContentUtils::GetOuterSVGElement(this));
-  return NS_OK;
-}
-
-/* nsIDOMSVGRect getBBox (); */
-NS_IMETHODIMP
-nsSVGSVGElement::GetBBox(nsIDOMSVGRect **_retval)
-{
-  *_retval = nullptr;
-
-  nsIFrame* frame = GetPrimaryFrame(Flush_Layout);
-
-  if (!frame || (frame->GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD))
-    return NS_ERROR_FAILURE;
-
-  nsISVGChildFrame* svgframe = do_QueryFrame(frame);
-  if (svgframe) {
-    return NS_NewSVGRect(_retval, nsSVGUtils::GetBBox(frame));
-  }
-  return NS_ERROR_NOT_IMPLEMENTED; // XXX: outer svg
-}
-
-/* DOMSVGMatrix getCTM (); */
-NS_IMETHODIMP
-nsSVGSVGElement::GetCTM(nsISupports * *aCTM)
-{
-  gfxMatrix m = SVGContentUtils::GetCTM(this, false);
-  *aCTM = m.IsSingular() ? nullptr : new DOMSVGMatrix(m);
-  NS_IF_ADDREF(*aCTM);
-  return NS_OK;
-}
-
-/* DOMSVGMatrix getScreenCTM (); */
-NS_IMETHODIMP
-nsSVGSVGElement::GetScreenCTM(nsISupports **aCTM)
-{
-  gfxMatrix m = SVGContentUtils::GetCTM(this, true);
-  *aCTM = m.IsSingular() ? nullptr : new DOMSVGMatrix(m);
-  NS_IF_ADDREF(*aCTM);
-  return NS_OK;
-}
-
-/* DOMSVGMatrix getTransformToElement (in nsIDOMSVGElement element); */
-NS_IMETHODIMP
-nsSVGSVGElement::GetTransformToElement(nsIDOMSVGElement *element,
-                                       nsISupports **_retval)
-{
-  if (!element)
-    return NS_ERROR_DOM_SVG_WRONG_TYPE_ERR;
-
-  nsresult rv;
-  *_retval = nullptr;
-  nsCOMPtr<DOMSVGMatrix> ourScreenCTM;
-  nsCOMPtr<DOMSVGMatrix> targetScreenCTM;
-  nsCOMPtr<nsIDOMSVGLocatable> target = do_QueryInterface(element, &rv);
-  if (NS_FAILED(rv)) return rv;
-
-  // the easiest way to do this (if likely to increase rounding error):
-  GetScreenCTM(getter_AddRefs(ourScreenCTM));
-  if (!ourScreenCTM) return NS_ERROR_DOM_SVG_MATRIX_NOT_INVERTABLE;
-  target->GetScreenCTM(getter_AddRefs(targetScreenCTM));
-  if (!targetScreenCTM) return NS_ERROR_DOM_SVG_MATRIX_NOT_INVERTABLE;
-  ErrorResult result;
-  nsCOMPtr<DOMSVGMatrix> tmp = targetScreenCTM->Inverse(result);
-  if (result.Failed()) return result.ErrorCode();
-  if (NS_FAILED(rv)) return rv;
-  *_retval = tmp->Multiply(*ourScreenCTM).get();  // addrefs, so we don't
+  nsRefPtr<DOMSVGAnimatedPreserveAspectRatio> ratio;
+  mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this);
+  ratio.forget(aPreserveAspectRatio);
   return NS_OK;
 }
 
 //----------------------------------------------------------------------
 // nsIDOMSVGZoomAndPan methods
 
 /* attribute unsigned short zoomAndPan; */
 NS_IMETHODIMP
--- a/content/svg/content/src/nsSVGSVGElement.h
+++ b/content/svg/content/src/nsSVGSVGElement.h
@@ -1,39 +1,38 @@
 /* -*- 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 __NS_SVGSVGELEMENT_H__
 #define __NS_SVGSVGELEMENT_H__
 
-#include "DOMSVGTests.h"
 #include "mozilla/dom/FromParser.h"
 #include "nsIDOMSVGFitToViewBox.h"
 #include "nsIDOMSVGLocatable.h"
 #include "nsISVGPoint.h"
 #include "nsIDOMSVGSVGElement.h"
 #include "nsIDOMSVGZoomAndPan.h"
 #include "nsSVGEnum.h"
 #include "nsSVGLength2.h"
-#include "nsSVGElement.h"
+#include "SVGGraphicsElement.h"
 #include "nsSVGViewBox.h"
 #include "SVGPreserveAspectRatio.h"
 #include "SVGAnimatedPreserveAspectRatio.h"
 #include "mozilla/Attributes.h"
 
 class nsSMILTimeContainer;
 class nsSVGViewElement;
 namespace mozilla {
   class DOMSVGMatrix;
   class SVGFragmentIdentifier;
 }
 
-typedef nsSVGElement nsSVGSVGElementBase;
+typedef mozilla::dom::SVGGraphicsElement nsSVGSVGElementBase;
 
 class nsSVGSVGElement;
 
 class nsSVGTranslatePoint {
 public:
   nsSVGTranslatePoint()
     : mX(0.0f)
     , mY(0.0f)
@@ -95,19 +94,17 @@ public:
     return width != rhs.width || height != rhs.height;
   }
   float width;
   float height;
 };
 
 class nsSVGSVGElement : public nsSVGSVGElementBase,
                         public nsIDOMSVGSVGElement,
-                        public DOMSVGTests,
                         public nsIDOMSVGFitToViewBox,
-                        public nsIDOMSVGLocatable,
                         public nsIDOMSVGZoomAndPan
 {
   friend class nsSVGOuterSVGFrame;
   friend class nsSVGInnerSVGFrame;
   friend class nsSVGImageFrame;
   friend class mozilla::SVGFragmentIdentifier;
 
   friend nsresult NS_NewSVGSVGElement(nsIContent **aResult,
@@ -120,17 +117,16 @@ public:
   typedef mozilla::SVGAnimatedPreserveAspectRatio SVGAnimatedPreserveAspectRatio;
   typedef mozilla::SVGPreserveAspectRatio SVGPreserveAspectRatio;
 
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsSVGSVGElement, nsSVGSVGElementBase)
   NS_DECL_NSIDOMSVGSVGELEMENT
   NS_DECL_NSIDOMSVGFITTOVIEWBOX
-  NS_DECL_NSIDOMSVGLOCATABLE
   NS_DECL_NSIDOMSVGZOOMANDPAN
   
   // xxx I wish we could use virtual inheritance
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
   NS_FORWARD_NSIDOMSVGELEMENT(nsSVGSVGElementBase::)
 
   /**
--- a/content/svg/content/src/nsSVGSymbolElement.cpp
+++ b/content/svg/content/src/nsSVGSymbolElement.cpp
@@ -9,16 +9,18 @@
 #include "DOMSVGTests.h"
 #include "nsSVGElement.h"
 #include "nsSVGViewBox.h"
 #include "SVGAnimatedPreserveAspectRatio.h"
 #include "nsIDOMSVGFitToViewBox.h"
 #include "nsGkAtoms.h"
 
 using namespace mozilla;
+using namespace mozilla::dom;
+
 typedef nsSVGElement nsSVGSymbolElementBase;
 
 class nsSVGSymbolElement : public nsSVGSymbolElementBase,
                            public nsIDOMSVGSymbolElement,
                            public DOMSVGTests,
                            public nsIDOMSVGFitToViewBox
 {
 protected:
@@ -94,17 +96,20 @@ NS_IMETHODIMP nsSVGSymbolElement::GetVie
   return mViewBox.ToDOMAnimatedRect(aViewBox, this);
 }
 
 /* readonly attribute SVGPreserveAspectRatio preserveAspectRatio; */
 NS_IMETHODIMP
 nsSVGSymbolElement::GetPreserveAspectRatio(nsISupports
                                            **aPreserveAspectRatio)
 {
-  return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(aPreserveAspectRatio, this);
+  nsRefPtr<DOMSVGAnimatedPreserveAspectRatio> ratio;
+  mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this);
+  ratio.forget(aPreserveAspectRatio);
+  return NS_OK;
 }
 
 //----------------------------------------------------------------------
 // nsIContent methods
 
 NS_IMETHODIMP_(bool)
 nsSVGSymbolElement::IsAttributeMapped(const nsIAtom* name) const
 {
--- a/content/svg/content/src/nsSVGTSpanElement.cpp
+++ b/content/svg/content/src/nsSVGTSpanElement.cpp
@@ -57,21 +57,20 @@ 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_TABLE7(nsSVGTSpanElement, nsIDOMNode, nsIDOMElement,
+  NS_NODE_INTERFACE_TABLE6(nsSVGTSpanElement, nsIDOMNode, nsIDOMElement,
                            nsIDOMSVGElement, nsIDOMSVGTSpanElement,
                            nsIDOMSVGTextPositioningElement,
-                           nsIDOMSVGTextContentElement,
-                           nsIDOMSVGTests)
+                           nsIDOMSVGTextContentElement)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGTSpanElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGTSpanElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGTSpanElement::nsSVGTSpanElement(already_AddRefed<nsINodeInfo> aNodeInfo)
   : nsSVGTSpanElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGTextContentElement.cpp
+++ b/content/svg/content/src/nsSVGTextContentElement.cpp
@@ -11,17 +11,16 @@ using namespace mozilla;
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGTextContentElement, nsSVGTextContentElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGTextContentElement, nsSVGTextContentElementBase)
 
 NS_INTERFACE_MAP_BEGIN(nsSVGTextContentElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTests)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGTextContentElementBase)
 
 /* readonly attribute nsIDOMSVGAnimatedLength textLength; */
 NS_IMETHODIMP nsSVGTextContentElement::GetTextLength(nsIDOMSVGAnimatedLength * *aTextLength)
 {
   NS_NOTYETIMPLEMENTED("nsSVGTextContentElement::GetTextLength");
   return NS_ERROR_NOT_IMPLEMENTED;
 }
--- a/content/svg/content/src/nsSVGTextContentElement.h
+++ b/content/svg/content/src/nsSVGTextContentElement.h
@@ -1,31 +1,29 @@
 /* -*- 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 __NS_SVGTEXTCONTENTELEMENTBASE_H__
 #define __NS_SVGTEXTCONTENTELEMENTBASE_H__
 
-#include "DOMSVGTests.h"
 #include "nsIDOMSVGTextContentElement.h"
 #include "nsSVGElement.h"
 #include "nsSVGTextContainerFrame.h"
 
 typedef nsSVGElement nsSVGTextContentElementBase;
 
 /**
  * Note that nsSVGTextElement does not inherit nsSVGTextPositioningElement, or
  * this class - it reimplements us instead (see its documenting comment). The
  * upshot is that any changes to this class also need to be made in
  * nsSVGTextElement.
  */
-class nsSVGTextContentElement : public nsSVGTextContentElementBase,
-                                public DOMSVGTests
+class nsSVGTextContentElement : public nsSVGTextContentElementBase
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMSVGTEXTCONTENTELEMENT
 
 protected:
 
   nsSVGTextContentElement(already_AddRefed<nsINodeInfo> aNodeInfo)
--- a/content/svg/content/src/nsSVGTextElement.cpp
+++ b/content/svg/content/src/nsSVGTextElement.cpp
@@ -1,50 +1,48 @@
 /* -*- 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 "nsSVGGraphicElement.h"
+#include "SVGGraphicsElement.h"
 #include "nsGkAtoms.h"
 #include "nsIDOMSVGTextElement.h"
 #include "nsCOMPtr.h"
 #include "nsSVGSVGElement.h"
 #include "nsSVGTextPositioningElement.h"
 #include "nsError.h"
 #include "SVGAnimatedLengthList.h"
 #include "DOMSVGAnimatedLengthList.h"
 #include "SVGLengthList.h"
 #include "SVGNumberList.h"
 #include "SVGAnimatedNumberList.h"
 #include "DOMSVGAnimatedNumberList.h"
 #include "DOMSVGPoint.h"
-#include "DOMSVGTests.h"
 
 using namespace mozilla;
 
-typedef nsSVGGraphicElement nsSVGTextElementBase;
+typedef dom::SVGGraphicsElement nsSVGTextElementBase;
 
 /**
  * This class does not inherit nsSVGTextPositioningElement - it reimplements it
  * instead.
  *
  * Ideally this class would inherit nsSVGTextPositioningElement in addition to
  * nsSVGGraphicElement, but we don't want two instances of nsSVGStylableElement
  * and all the classes it inherits. Instead we choose to inherit one of the
  * classes (nsSVGGraphicElement) and reimplement the missing pieces from the
  * other (nsSVGTextPositioningElement (and thus nsSVGTextContentElement)). Care
  * must be taken when making changes to the reimplemented pieces to keep
  * nsSVGTextPositioningElement in sync (and vice versa).
  */
 class nsSVGTextElement : public nsSVGTextElementBase,
-                         public nsIDOMSVGTextElement, // nsIDOMSVGTextPositioningElement
-                         public DOMSVGTests
+                         public nsIDOMSVGTextElement // nsIDOMSVGTextPositioningElement
 {
 protected:
   friend nsresult NS_NewSVGTextElement(nsIContent **aResult,
                                        already_AddRefed<nsINodeInfo> aNodeInfo);
   nsSVGTextElement(already_AddRefed<nsINodeInfo> aNodeInfo);
   
 public:
   // interfaces:
@@ -95,21 +93,20 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(Text)
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGTextElement,nsSVGTextElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGTextElement,nsSVGTextElementBase)
 
 DOMCI_NODE_DATA(SVGTextElement, nsSVGTextElement)
 
 NS_INTERFACE_TABLE_HEAD(nsSVGTextElement)
-  NS_NODE_INTERFACE_TABLE7(nsSVGTextElement, nsIDOMNode, nsIDOMElement,
+  NS_NODE_INTERFACE_TABLE6(nsSVGTextElement, nsIDOMNode, nsIDOMElement,
                            nsIDOMSVGElement, nsIDOMSVGTextElement,
                            nsIDOMSVGTextPositioningElement,
-                           nsIDOMSVGTextContentElement,
-                           nsIDOMSVGTests)
+                           nsIDOMSVGTextContentElement)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGTextElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGTextElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGTextElement::nsSVGTextElement(already_AddRefed<nsINodeInfo> aNodeInfo)
   : nsSVGTextElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGTextPathElement.cpp
+++ b/content/svg/content/src/nsSVGTextPathElement.cpp
@@ -56,19 +56,19 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(TextPath)
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGTextPathElement,nsSVGTextPathElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGTextPathElement,nsSVGTextPathElementBase)
 
 DOMCI_NODE_DATA(SVGTextPathElement, nsSVGTextPathElement)
 
 NS_INTERFACE_TABLE_HEAD(nsSVGTextPathElement)
-  NS_NODE_INTERFACE_TABLE7(nsSVGTextPathElement, nsIDOMNode, nsIDOMElement,
+  NS_NODE_INTERFACE_TABLE6(nsSVGTextPathElement, nsIDOMNode, nsIDOMElement,
                            nsIDOMSVGElement, nsIDOMSVGTextPathElement,
-                           nsIDOMSVGTextContentElement, nsIDOMSVGTests,
+                           nsIDOMSVGTextContentElement,
                            nsIDOMSVGURIReference)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGTextPathElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGTextPathElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGTextPathElement::nsSVGTextPathElement(already_AddRefed<nsINodeInfo> aNodeInfo)
--- a/content/svg/content/src/nsSVGUseElement.cpp
+++ b/content/svg/content/src/nsSVGUseElement.cpp
@@ -55,18 +55,18 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_ADDREF_INHERITED(nsSVGUseElement,nsSVGUseElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGUseElement,nsSVGUseElementBase)
 
 DOMCI_NODE_DATA(SVGUseElement, nsSVGUseElement)
 
 NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsSVGUseElement)
-  NS_NODE_INTERFACE_TABLE7(nsSVGUseElement, nsIDOMNode, nsIDOMElement,
-                           nsIDOMSVGElement, nsIDOMSVGTests,
+  NS_NODE_INTERFACE_TABLE6(nsSVGUseElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
                            nsIDOMSVGURIReference,
                            nsIDOMSVGUseElement, nsIMutationObserver)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGUseElement)
   if (aIID.Equals(NS_GET_IID(nsSVGUseElement)))
     foundInterface = reinterpret_cast<nsISupports*>(this);
   else
 NS_INTERFACE_MAP_END_INHERITING(nsSVGUseElementBase)
 
--- a/content/svg/content/src/nsSVGUseElement.h
+++ b/content/svg/content/src/nsSVGUseElement.h
@@ -1,44 +1,42 @@
 /* -*- 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 __NS_SVGUSEELEMENT_H__
 #define __NS_SVGUSEELEMENT_H__
 
-#include "DOMSVGTests.h"
 #include "mozilla/dom/FromParser.h"
 #include "nsIDOMSVGURIReference.h"
 #include "nsIDOMSVGUseElement.h"
 #include "nsReferencedElement.h"
 #include "nsStubMutationObserver.h"
-#include "nsSVGGraphicElement.h"
+#include "SVGGraphicsElement.h"
 #include "nsSVGLength2.h"
 #include "nsSVGString.h"
 #include "nsTArray.h"
 
 class nsIContent;
 class nsINodeInfo;
 
 #define NS_SVG_USE_ELEMENT_IMPL_CID \
 { 0x55fb86fe, 0xd81f, 0x4ae4, \
   { 0x80, 0x3f, 0xeb, 0x90, 0xfe, 0xe0, 0x7a, 0xe9 } }
 
 nsresult
 NS_NewSVGSVGElement(nsIContent **aResult,
                     already_AddRefed<nsINodeInfo> aNodeInfo,
                     mozilla::dom::FromParser aFromParser);
 
-typedef nsSVGGraphicElement nsSVGUseElementBase;
+typedef mozilla::dom::SVGGraphicsElement nsSVGUseElementBase;
 
 class nsSVGUseElement : public nsSVGUseElementBase,
                         public nsIDOMSVGUseElement,
-                        public DOMSVGTests,
                         public nsIDOMSVGURIReference,
                         public nsStubMutationObserver
 {
   friend class nsSVGUseFrame;
 protected:
   friend nsresult NS_NewSVGUseElement(nsIContent **aResult,
                                       already_AddRefed<nsINodeInfo> aNodeInfo);
   nsSVGUseElement(already_AddRefed<nsINodeInfo> aNodeInfo);
--- a/content/svg/content/src/nsSVGViewElement.cpp
+++ b/content/svg/content/src/nsSVGViewElement.cpp
@@ -2,16 +2,17 @@
 /* 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 "nsSVGViewElement.h"
 #include "DOMSVGStringList.h"
 
 using namespace mozilla;
+using namespace mozilla::dom;
 
 nsSVGElement::StringListInfo nsSVGViewElement::sStringListInfo[1] =
 {
   { &nsGkAtoms::viewTarget }
 };
 
 nsSVGEnumMapping nsSVGViewElement::sZoomAndPanMap[] = {
   {&nsGkAtoms::disable, nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_DISABLE},
@@ -91,17 +92,20 @@ nsSVGViewElement::GetViewBox(nsIDOMSVGAn
   return mViewBox.ToDOMAnimatedRect(aViewBox, this);
 }
 
 /* readonly attribute SVGPreserveAspectRatio preserveAspectRatio; */
 NS_IMETHODIMP
 nsSVGViewElement::GetPreserveAspectRatio(nsISupports
                                          **aPreserveAspectRatio)
 {
-  return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(aPreserveAspectRatio, this);
+  nsRefPtr<DOMSVGAnimatedPreserveAspectRatio> ratio;
+  mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(getter_AddRefs(ratio), this);
+  ratio.forget(aPreserveAspectRatio);
+  return NS_OK;
 }
 
 //----------------------------------------------------------------------
 // nsIDOMSVGViewElement methods
 
 /* readonly attribute nsIDOMSVGStringList viewTarget; */
 NS_IMETHODIMP nsSVGViewElement::GetViewTarget(nsIDOMSVGStringList * *aViewTarget)
 {
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -3002,22 +3002,22 @@ nsDOMClassInfo::Init()
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGElement)                           \
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)                         \
     DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers)                     \
     DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver,          \
                                         nsDOMTouchEvent::PrefEnabled())
 
 #define DOM_CLASSINFO_SVG_TEXT_CONTENT_ELEMENT_MAP_ENTRIES \
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextContentElement)   \
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)                \
     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
 
 #define DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES \
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLocatable)       \
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTransformable)   \
+    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)           \
     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
 
   // XXX - the proto chain stuff is sort of hackish, because of the MI in
   // the SVG interfaces. I doubt that extending the proto on one interface
   // works properly on an element which inherits off multiple interfaces.
   // Tough luck. - bbaetz
 
   // The SVG document
@@ -3029,17 +3029,16 @@ nsDOMClassInfo::Init()
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGDocument)
     DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   // SVG element classes
 
   DOM_CLASSINFO_MAP_BEGIN(SVGAElement, nsIDOMSVGAElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAElement)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGAltGlyphElement, nsIDOMSVGAltGlyphElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextPositioningElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
     DOM_CLASSINFO_SVG_TEXT_CONTENT_ELEMENT_MAP_ENTRIES
@@ -3087,41 +3086,37 @@ nsDOMClassInfo::Init()
 
   DOM_CLASSINFO_MAP_BEGIN(TimeEvent, nsIDOMTimeEvent)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMTimeEvent)
     DOM_CLASSINFO_EVENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGCircleElement, nsIDOMSVGCircleElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGCircleElement)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGClipPathElement, nsIDOMSVGClipPathElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGClipPathElement)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGDefsElement, nsIDOMSVGDefsElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGDefsElement)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGDescElement, nsIDOMSVGDescElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGDescElement)
     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGEllipseElement, nsIDOMSVGEllipseElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGEllipseElement)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGFEBlendElement, nsIDOMSVGFEBlendElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEBlendElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
@@ -3254,116 +3249,106 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_BEGIN(SVGFETurbulenceElement, nsIDOMSVGFETurbulenceElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFETurbulenceElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGFilterElement, nsIDOMSVGFilterElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterElement)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGForeignObjectElement, nsIDOMSVGForeignObjectElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGForeignObjectElement)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGGElement, nsIDOMSVGGElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGGElement)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGImageElement, nsIDOMSVGImageElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGImageElement)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
+    DOM_CLASSINFO_MAP_ENTRY(nsIImageLoadingContent)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGLinearGradientElement, nsIDOMSVGLinearGradientElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGGradientElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLinearGradientElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGLineElement, nsIDOMSVGLineElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLineElement)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGMarkerElement, nsIDOMSVGMarkerElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGMarkerElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFitToViewBox)
     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGMaskElement, nsIDOMSVGMaskElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGMaskElement)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGMetadataElement, nsIDOMSVGMetadataElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGMetadataElement)
     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGPathElement, nsIDOMSVGPathElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathElement)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedPathData)
     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGPatternElement, nsIDOMSVGPatternElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPatternElement)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFitToViewBox)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGPolygonElement, nsIDOMSVGPolygonElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPolygonElement)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedPoints)
     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGPolylineElement, nsIDOMSVGPolylineElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPolylineElement)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedPoints)
     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGRadialGradientElement, nsIDOMSVGRadialGradientElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGGradientElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGRadialGradientElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGRectElement, nsIDOMSVGRectElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGRectElement)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGScriptElement, nsIDOMSVGScriptElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGScriptElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
@@ -3378,39 +3363,36 @@ nsDOMClassInfo::Init()
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMLinkStyle)
     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGSVGElement, nsIDOMSVGSVGElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGSVGElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFitToViewBox)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLocatable)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGZoomAndPan)
-    DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
+    DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGSwitchElement, nsIDOMSVGSwitchElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGSwitchElement)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGSymbolElement, nsIDOMSVGSymbolElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGSymbolElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFitToViewBox)
     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGTextElement, nsIDOMSVGTextElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextPositioningElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextContentElement)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGTextPathElement, nsIDOMSVGTextPathElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
     DOM_CLASSINFO_SVG_TEXT_CONTENT_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
@@ -3425,17 +3407,16 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGUnknownElement, nsIDOMSVGElement)
     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGUseElement, nsIDOMSVGUseElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUseElement)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SVGViewElement, nsIDOMSVGViewElement)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFitToViewBox)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGZoomAndPan)
     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -597,21 +597,40 @@ DOMInterfaces = {
     'headerFile': 'SVGAnimatedPreserveAspectRatio.h'
 },
 
 'SVGAnimatedTransformList': {
     'nativeType': 'mozilla::DOMSVGAnimatedTransformList',
     'headerFile': 'DOMSVGAnimatedTransformList.h'
 },
 
+'SVGAnimationElement': {
+    'resultNotAddRefed': ['targetElement'],
+    'concrete': False
+},
+
 'SVGElement': {
     'nativeType': 'nsSVGElement',
     'hasXPConnectImpls': True,
     'hasInstanceInterface': 'nsIDOMSVGElement',
-    'resultNotAddRefed': ['ownerSVGElement', 'style']
+    'resultNotAddRefed': ['ownerSVGElement', 'viewportElement', 'style']
+},
+
+'SVGGraphicsElement': {
+    'hasXPConnectImpls': True,
+},
+
+'SVGImageElement': {
+  'hasInstanceInterface': 'nsIDOMSVGImageElement',
+},
+
+'SVGLocatableElement': {
+    'hasXPConnectImpls': True,
+    'concrete': False,
+    'resultNotAddRefed': ['nearestViewportElement', 'farthestViewportElement']
 },
 
 'SVGLengthList': {
     'nativeType': 'mozilla::DOMSVGLengthList',
     'headerFile': 'DOMSVGLengthList.h',
     'resultNotAddRefed': [ 'getItem' ]
 },
 
@@ -753,16 +772,21 @@ DOMInterfaces = {
   'hasInstanceInterface': 'nsIDOMSVGTitleElement',
 },
 
 'SVGTransform': {
     'nativeType': 'mozilla::DOMSVGTransform',
     'headerFile': 'DOMSVGTransform.h'
 },
 
+'SVGTransformableElement': {
+    'hasXPConnectImpls': True,
+    'concrete': False
+},
+
 'SVGTransformList': {
     'nativeType': 'mozilla::DOMSVGTransformList',
     'headerFile': 'DOMSVGTransformList.h',
     'resultNotAddRefed': [ 'getItem' ]
 },
 
 'Text': {
     'nativeType': 'nsTextNode',
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -24,16 +24,17 @@
 #include "nsIHttpChannel.h"
 #include "nsIHttpChannelInternal.h"
 #include "nsIUploadChannel.h"
 #include "nsIByteRangeRequest.h"
 #include "nsIStreamListener.h"
 #include "nsIInputStream.h"
 #include "nsIOutputStream.h"
 #include "nsIURL.h"
+#include "nsTArray.h"
 #include "nsXPIDLString.h"
 #include "nsReadableUtils.h"
 #include "nsIProtocolProxyService2.h"
 #include "nsIStreamConverterService.h"
 #include "nsIFile.h"
 #if defined(XP_MACOSX)
 #include "nsILocalFileMac.h"
 #endif
@@ -105,17 +106,16 @@
 #include "nsPluginManifestLineReader.h"
 
 #include "nsIWeakReferenceUtils.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMHTMLObjectElement.h"
 #include "nsIDOMHTMLEmbedElement.h"
 #include "nsIPresShell.h"
 #include "nsIWebNavigation.h"
-#include "nsISupportsArray.h"
 #include "nsIDocShell.h"
 #include "nsPluginNativeWindow.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIContentPolicy.h"
 #include "nsContentPolicyUtils.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Telemetry.h"
 #include "nsIImageLoadingContent.h"
@@ -274,33 +274,30 @@ bool ReadSectionHeader(nsPluginManifestL
   return false;
 }
 
 // Little helper struct to asynchronously reframe any presentations (embedded)
 // or reload any documents (full-page), that contained plugins
 // which were shutdown as a result of a plugins.refresh(1)
 class nsPluginDocReframeEvent: public nsRunnable {
 public:
-  nsPluginDocReframeEvent(nsISupportsArray* aDocs) { mDocs = aDocs; }
+  nsPluginDocReframeEvent(nsTArray<nsCOMPtr<nsIDocument> >& aDocs) { mDocs.SwapElements(aDocs); }
 
   NS_DECL_NSIRUNNABLE
 
-  nsCOMPtr<nsISupportsArray> mDocs;
+  nsTArray<nsCOMPtr<nsIDocument> > mDocs;
 };
 
 NS_IMETHODIMP nsPluginDocReframeEvent::Run() {
-  NS_ENSURE_TRUE(mDocs, NS_ERROR_FAILURE);
-
-  uint32_t c;
-  mDocs->Count(&c);
+  uint32_t c = mDocs.Length();
 
   // for each document (which previously had a running instance), tell
   // the frame constructor to rebuild
   for (uint32_t i = 0; i < c; i++) {
-    nsCOMPtr<nsIDocument> doc (do_QueryElementAt(mDocs, i));
+    nsIDocument* doc = mDocs[i];
     if (doc) {
       nsIPresShell *shell = doc->GetShell();
 
       // if this document has a presentation shell, then it has frames and can be reframed
       if (shell) {
         /* A reframe will cause a fresh object frame, instance owner, and instance
          * to be created. Reframing of the entire document is necessary as we may have
          * recently found new plugins and we want a shot at trying to use them instead
@@ -314,17 +311,18 @@ NS_IMETHODIMP nsPluginDocReframeEvent::R
       } else {  // no pres shell --> full-page plugin
 
         NS_NOTREACHED("all plugins should have a pres shell!");
 
       }
     }
   }
 
-  return mDocs->Clear();
+  mDocs.Clear();
+  return NS_OK;
 }
 
 static bool UnloadPluginsASAP()
 {
   return Preferences::GetBool("dom.ipc.plugins.unloadASAP", false);
 }
 
 nsPluginHost::nsPluginHost()
@@ -435,23 +433,22 @@ nsresult nsPluginHost::ReloadPlugins(boo
   // look for possible changes
   bool pluginschanged = true;
   FindPlugins(false, &pluginschanged);
 
   // if no changed detected, return an appropriate error code
   if (!pluginschanged)
     return NS_ERROR_PLUGINS_PLUGINSNOTCHANGED;
 
-  nsCOMPtr<nsISupportsArray> instsToReload;
+  nsTArray<nsCOMPtr<nsIDocument> > instsToReload;
   if (reloadPages) {
-    NS_NewISupportsArray(getter_AddRefs(instsToReload));
 
     // Then stop any running plugin instances but hold on to the documents in the array
     // We are going to need to restart the instances in these documents later
-    DestroyRunningInstances(instsToReload, nullptr);
+    DestroyRunningInstances(&instsToReload, nullptr);
   }
 
   // shutdown plugins and kill the list if there are no running plugins
   nsRefPtr<nsPluginTag> prev;
   nsRefPtr<nsPluginTag> next;
 
   for (nsRefPtr<nsPluginTag> p = mPlugins; p != nullptr;) {
     next = p->mNext;
@@ -480,21 +477,17 @@ nsresult nsPluginHost::ReloadPlugins(boo
   mPluginsLoaded = false;
 
   // load them again
   rv = LoadPlugins();
 
   // If we have shut down any plugin instances, we've now got to restart them.
   // Post an event to do the rest as we are going to be destroying the frame tree and we also want
   // any posted unload events to finish
-  uint32_t c;
-  if (reloadPages &&
-      instsToReload &&
-      NS_SUCCEEDED(instsToReload->Count(&c)) &&
-      c > 0) {
+  if (reloadPages && !instsToReload.IsEmpty()){
     nsCOMPtr<nsIRunnable> ev = new nsPluginDocReframeEvent(instsToReload);
     if (ev)
       NS_DispatchToCurrentThread(ev);
   }
 
   PLUGIN_LOG(PLUGIN_LOG_NORMAL,
   ("nsPluginHost::ReloadPlugins End active_instance_count=%d\n",
   mInstances.Length()));
@@ -2388,22 +2381,20 @@ nsPluginHost::UpdatePluginInfo(nsPluginT
   if (obsService)
     obsService->NotifyObservers(nullptr, "plugin-info-updated", nullptr);
 
   // Reload instances if needed
   if (aPluginTag->IsEnabled()) {
     return NS_OK;
   }
 
-  nsCOMPtr<nsISupportsArray> instsToReload;
-  NS_NewISupportsArray(getter_AddRefs(instsToReload));
-  DestroyRunningInstances(instsToReload, aPluginTag);
+  nsTArray<nsCOMPtr<nsIDocument> > instsToReload;
+  DestroyRunningInstances(&instsToReload, aPluginTag);
   
-  uint32_t c;
-  if (instsToReload && NS_SUCCEEDED(instsToReload->Count(&c)) && c > 0) {
+  if (!instsToReload.IsEmpty()) {
     nsCOMPtr<nsIRunnable> ev = new nsPluginDocReframeEvent(instsToReload);
     if (ev)
       NS_DispatchToCurrentThread(ev);
   }
 
   return NS_OK;
 }
 
@@ -3820,34 +3811,35 @@ nsPluginHost::StoppedInstanceCount()
 }
 
 nsTArray< nsRefPtr<nsNPAPIPluginInstance> >*
 nsPluginHost::InstanceArray()
 {
   return &mInstances;
 }
 
-void
-nsPluginHost::DestroyRunningInstances(nsISupportsArray* aReloadDocs, nsPluginTag* aPluginTag)
+void 
+nsPluginHost::DestroyRunningInstances(nsTArray<nsCOMPtr<nsIDocument> >* aReloadDocs,
+                                      nsPluginTag* aPluginTag)
 {
   for (int32_t i = mInstances.Length(); i > 0; i--) {
     nsNPAPIPluginInstance *instance = mInstances[i - 1];
     if (instance->IsRunning() && (!aPluginTag || aPluginTag == TagForPlugin(instance->GetPlugin()))) {
       instance->SetWindow(nullptr);
       instance->Stop();
 
       // If we've been passed an array to return, lets collect all our documents,
       // removing duplicates. These will be reframed (embedded) or reloaded (full-page) later
       // to kickstart our instances.
       if (aReloadDocs) {
         nsRefPtr<nsPluginInstanceOwner> owner = instance->GetOwner();
         if (owner) {
           nsCOMPtr<nsIDocument> doc;
           owner->GetDocument(getter_AddRefs(doc));
-          if (doc && aReloadDocs->IndexOf(doc) == -1)  // don't allow for duplicates
+          if (doc && !aReloadDocs->Contains(doc))  // don't allow for duplicates
             aReloadDocs->AppendElement(doc);
         }
       }
 
       // Get rid of all the instances without the possibility of caching.
       nsPluginTag* pluginTag = TagForPlugin(instance->GetPlugin());
       instance->SetWindow(nullptr);
       instance->Destroy();
--- a/dom/plugins/base/nsPluginHost.h
+++ b/dom/plugins/base/nsPluginHost.h
@@ -14,17 +14,16 @@
 #include "npapi.h"
 #include "nsNPAPIPluginInstance.h"
 #include "nsIPluginTag.h"
 #include "nsPluginsDir.h"
 #include "nsPluginDirServiceProvider.h"
 #include "nsAutoPtr.h"
 #include "nsWeakPtr.h"
 #include "nsIPrompt.h"
-#include "nsISupportsArray.h"
 #include "nsWeakReference.h"
 #include "nsThreadUtils.h"
 #include "nsTArray.h"
 #include "nsTObserverArray.h"
 #include "nsITimer.h"
 #include "nsPluginTags.h"
 #include "nsIEffectiveTLDService.h"
 #include "nsIIDNService.h"
@@ -172,17 +171,17 @@ public:
                      const nsAString& browserDumpID);
 
   nsNPAPIPluginInstance *FindInstance(const char *mimetype);
   nsNPAPIPluginInstance *FindOldestStoppedInstance();
   uint32_t StoppedInstanceCount();
 
   nsTArray< nsRefPtr<nsNPAPIPluginInstance> > *InstanceArray();
 
-  void DestroyRunningInstances(nsISupportsArray* aReloadDocs, nsPluginTag* aPluginTag);
+  void DestroyRunningInstances(nsTArray<nsCOMPtr<nsIDocument> >* aReloadDocs, nsPluginTag* aPluginTag);
 
   // Return the tag for |aLibrary| if found, nullptr if not.
   nsPluginTag* FindTagForLibrary(PRLibrary* aLibrary);
 
   // The last argument should be false if we already have an in-flight stream
   // and don't need to set up a new stream.
   nsresult InstantiatePluginInstance(const char *aMimeType, nsIURI* aURL,
                                      nsObjectLoadingContent *aContent,
--- a/dom/plugins/base/nsPluginTags.h
+++ b/dom/plugins/base/nsPluginTags.h
@@ -7,17 +7,16 @@
 #define nsPluginTags_h_
 
 #include "nscore.h"
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsCOMArray.h"
 #include "nsIPluginTag.h"
 #include "nsNPAPIPluginInstance.h"
-#include "nsISupportsArray.h"
 #include "nsITimer.h"
 #include "nsIDOMMimeType.h"
 
 class nsPluginHost;
 struct PRLibrary;
 struct nsPluginInfo;
 
 // Remember that flags are written out to pluginreg.dat, be careful
new file mode 100644
--- /dev/null
+++ b/dom/webidl/SVGAnimateElement.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 SVGAnimateElement : SVGAnimationElement {
+};
+
new file mode 100644
--- /dev/null
+++ b/dom/webidl/SVGAnimateMotionElement.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 SVGAnimateMotionElement : SVGAnimationElement {
+};
+
new file mode 100644
--- /dev/null
+++ b/dom/webidl/SVGAnimateTransformElement.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 SVGAnimateTransformElement : SVGAnimationElement {
+};
+
new file mode 100644
--- /dev/null
+++ b/dom/webidl/SVGAnimatedPoints.webidl
@@ -0,0 +1,20 @@
+/* -*- 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.
+ */
+
+[NoInterfaceObject]
+interface SVGAnimatedPoints {
+  [Constant]
+  readonly attribute SVGPointList points;
+  [Constant]
+  readonly attribute SVGPointList animatedPoints;
+};
+
new file mode 100644
--- /dev/null
+++ b/dom/webidl/SVGAnimationElement.webidl
@@ -0,0 +1,34 @@
+/* -*- 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 SVGAnimationElement : SVGElement {
+
+  readonly attribute SVGElement? targetElement;
+
+  [Throws]
+  float getStartTime();
+  float getCurrentTime();
+  [Throws]
+  float getSimpleDuration();
+
+  [Throws]
+  void beginElement();
+  [Throws]
+  void beginElementAt(float offset);
+  [Throws]
+  void endElement();
+  [Throws]
+  void endElementAt(float offset);
+};
+
+SVGAnimationElement implements SVGTests;
+
new file mode 100644
--- /dev/null
+++ b/dom/webidl/SVGCircleElement.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 SVGAnimatedLength;
+
+interface SVGCircleElement : SVGGraphicsElement {
+  [Constant]
+  readonly attribute SVGAnimatedLength cx;
+  [Constant]
+  readonly attribute SVGAnimatedLength cy;
+  [Constant]
+  readonly attribute SVGAnimatedLength r;
+};
+
new file mode 100644
--- /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 {
+};
+
new file mode 100644
--- /dev/null
+++ b/dom/webidl/SVGEllipseElement.webidl
@@ -0,0 +1,25 @@
+/* -*- 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 SVGAnimatedLength;
+
+interface SVGEllipseElement : SVGGraphicsElement {
+  [Constant]
+  readonly attribute SVGAnimatedLength cx;
+  [Constant]
+  readonly attribute SVGAnimatedLength cy;
+  [Constant]
+  readonly attribute SVGAnimatedLength rx;
+  [Constant]
+  readonly attribute SVGAnimatedLength ry;
+};
+
new file mode 100644
--- /dev/null
+++ b/dom/webidl/SVGForeignObjectElement.webidl
@@ -0,0 +1,25 @@
+/* -*- 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 SVGAnimatedLength;
+
+interface SVGForeignObjectElement : SVGGraphicsElement {
+  [Constant]
+  readonly attribute SVGAnimatedLength x;
+  [Constant]