Bug 826602 - Rename nsHTMLCanvasElement to mozilla::dom::HTMLCanvasElement; r=bzbarsky
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 04 Jan 2013 00:16:14 -0500
changeset 126717 a6ddfcf593bd52dba322d0e562172ba544205c59
parent 126716 9e04488032822b6143bd817a2eb1e6aa48c558f2
child 126718 99e4076687ca63894a35b692c33ed0cca91aae4e
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)
reviewersbzbarsky
bugs826602
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 826602 - Rename nsHTMLCanvasElement to mozilla::dom::HTMLCanvasElement; r=bzbarsky
content/canvas/public/nsICanvasElementExternal.h
content/canvas/public/nsICanvasRenderingContextInternal.h
content/canvas/src/CanvasImageCache.cpp
content/canvas/src/CanvasImageCache.h
content/canvas/src/CanvasRenderingContext2D.cpp
content/canvas/src/CanvasRenderingContext2D.h
content/canvas/src/CanvasUtils.cpp
content/canvas/src/CanvasUtils.h
content/canvas/src/WebGLContext.cpp
content/canvas/src/WebGLContext.h
content/html/content/public/HTMLCanvasElement.h
content/html/content/public/Makefile.in
content/html/content/public/nsHTMLCanvasElement.h
content/html/content/src/HTMLCanvasElement.cpp
content/html/content/src/Makefile.in
content/html/content/src/nsHTMLCanvasElement.cpp
dom/bindings/Bindings.conf
js/xpconnect/src/nsDOMQS.h
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/generic/nsHTMLCanvasFrame.cpp
layout/generic/nsSimplePageSequence.cpp
layout/generic/nsSimplePageSequence.h
layout/printing/nsPrintEngine.h
--- a/content/canvas/public/nsICanvasElementExternal.h
+++ b/content/canvas/public/nsICanvasElementExternal.h
@@ -19,17 +19,17 @@ struct gfxRect;
 class nsRenderingContext;
 class nsICanvasRenderingContextInternal;
 
 struct _cairo_surface;
 
 /*
  * This interface contains methods that are needed outside of the content/layout
  * modules, specifically widget.  It should eventually go away when we support
- * libxul builds, and nsHTMLCanvasElement be used directly.
+ * libxul builds, and HTMLCanvasElement be used directly.
  *
  * Code internal to content/layout should /never/ use this interface; if the
  * same functionality is needed in both places, two separate methods should be
  * used.
  */
 
 class nsICanvasElementExternal : public nsISupports {
 public:
--- a/content/canvas/public/nsICanvasRenderingContextInternal.h
+++ b/content/canvas/public/nsICanvasRenderingContextInternal.h
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsICanvasRenderingContextInternal_h___
 #define nsICanvasRenderingContextInternal_h___
 
 #include "nsISupports.h"
 #include "nsIInputStream.h"
 #include "nsIDocShell.h"
-#include "nsHTMLCanvasElement.h"
+#include "mozilla/dom/HTMLCanvasElement.h"
 #include "gfxPattern.h"
 #include "mozilla/RefPtr.h"
 
 #define NS_ICANVASRENDERINGCONTEXTINTERNAL_IID \
 { 0x8b8da863, 0xd151, 0x4014, \
   { 0x8b, 0xdc, 0x62, 0xb5, 0x0d, 0xc0, 0x2b, 0x62 } }
 
 class gfxContext;
@@ -41,21 +41,21 @@ public:
   typedef mozilla::layers::LayerManager LayerManager;
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICANVASRENDERINGCONTEXTINTERNAL_IID)
 
   enum {
     RenderFlagPremultAlpha = 0x1
   };
 
-  void SetCanvasElement(nsHTMLCanvasElement* aParentCanvas)
+  void SetCanvasElement(mozilla::dom::HTMLCanvasElement* aParentCanvas)
   {
     mCanvasElement = aParentCanvas;
   }
-  nsHTMLCanvasElement* GetParentObject() const
+  mozilla::dom::HTMLCanvasElement* GetParentObject() const
   {
     return mCanvasElement;
   }
 
   // Sets the dimensions of the canvas, in pixels.  Called
   // whenever the size of the element changes.
   NS_IMETHOD SetDimensions(int32_t width, int32_t height) = 0;
 
@@ -120,17 +120,17 @@ public:
 
   // If this context can be set to use Mozilla's Shmem segments as its backing
   // store, this will set it to that state. Note that if you have drawn
   // anything into this canvas before changing the shmem state, it will be
   // lost.
   NS_IMETHOD SetIsIPC(bool isIPC) = 0;
 
 protected:
-  nsRefPtr<nsHTMLCanvasElement> mCanvasElement;
+  nsRefPtr<mozilla::dom::HTMLCanvasElement> mCanvasElement;
 };
 
 namespace mozilla {
 namespace dom {
 
 }
 }
 
--- a/content/canvas/src/CanvasImageCache.cpp
+++ b/content/canvas/src/CanvasImageCache.cpp
@@ -6,28 +6,28 @@
 #include "CanvasImageCache.h"
 #include "nsIImageLoadingContent.h"
 #include "nsExpirationTracker.h"
 #include "imgIRequest.h"
 #include "gfxASurface.h"
 #include "gfxPoint.h"
 #include "mozilla/dom/Element.h"
 #include "nsTHashtable.h"
-#include "nsHTMLCanvasElement.h"
+#include "mozilla/dom/HTMLCanvasElement.h"
 #include "nsContentUtils.h"
 
 namespace mozilla {
 
 using namespace dom;
 
 struct ImageCacheKey {
-  ImageCacheKey(Element* aImage, nsHTMLCanvasElement* aCanvas)
+  ImageCacheKey(Element* aImage, HTMLCanvasElement* aCanvas)
     : mImage(aImage), mCanvas(aCanvas) {}
   Element* mImage;
-  nsHTMLCanvasElement* mCanvas;
+  HTMLCanvasElement* mCanvas;
 };
 
 struct ImageCacheEntryData {
   ImageCacheEntryData(const ImageCacheEntryData& aOther)
     : mImage(aOther.mImage)
     , mILC(aOther.mILC)
     , mCanvas(aOther.mCanvas)
     , mRequest(aOther.mRequest)
@@ -40,17 +40,17 @@ struct ImageCacheEntryData {
     , mCanvas(aKey.mCanvas)
   {}
 
   nsExpirationState* GetExpirationState() { return &mState; }
 
   // Key
   nsRefPtr<Element> mImage;
   nsIImageLoadingContent* mILC;
-  nsRefPtr<nsHTMLCanvasElement> mCanvas;
+  nsRefPtr<HTMLCanvasElement> mCanvas;
   // Value
   nsCOMPtr<imgIRequest> mRequest;
   nsRefPtr<gfxASurface> mSurface;
   gfxIntSize mSize;
   nsExpirationState mState;
 };
 
 class ImageCacheEntry : public PLDHashEntryHdr {
@@ -108,17 +108,17 @@ class CanvasImageCacheShutdownObserver M
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
 };
 
 void
 CanvasImageCache::NotifyDrawImage(Element* aImage,
-                                  nsHTMLCanvasElement* aCanvas,
+                                  HTMLCanvasElement* aCanvas,
                                   imgIRequest* aRequest,
                                   gfxASurface* aSurface,
                                   const gfxIntSize& aSize)
 {
   if (!gImageCache) {
     gImageCache = new ImageCache();
     nsContentUtils::RegisterShutdownObserver(new CanvasImageCacheShutdownObserver());
   }
@@ -139,17 +139,17 @@ CanvasImageCache::NotifyDrawImage(Elemen
     entry->mData->mILC = ilc;
     entry->mData->mSurface = aSurface;
     entry->mData->mSize = aSize;
   }
 }
 
 gfxASurface*
 CanvasImageCache::Lookup(Element* aImage,
-                         nsHTMLCanvasElement* aCanvas,
+                         HTMLCanvasElement* aCanvas,
                          gfxIntSize* aSize)
 {
   if (!gImageCache)
     return nullptr;
 
   ImageCacheEntry* entry = gImageCache->mCache.GetEntry(ImageCacheKey(aImage, aCanvas));
   if (!entry || !entry->mData->mILC)
     return nullptr;
--- a/content/canvas/src/CanvasImageCache.h
+++ b/content/canvas/src/CanvasImageCache.h
@@ -4,45 +4,45 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef CANVASIMAGECACHE_H_
 #define CANVASIMAGECACHE_H_
 
 namespace mozilla {
 namespace dom {
 class Element;
+class HTMLCanvasElement;
 } // namespace dom
 } // namespace mozilla
-class nsHTMLCanvasElement;
 class imgIRequest;
 class gfxASurface;
 
 #include "gfxPoint.h"
 
 namespace mozilla {
 
 class CanvasImageCache {
 public:
   /**
    * Notify that image element aImage was (or is about to be) drawn to aCanvas
    * using the first frame of aRequest's image. The data for the surface is
    * in aSurface, and the image size is in aSize.
    */
   static void NotifyDrawImage(dom::Element* aImage,
-                              nsHTMLCanvasElement* aCanvas,
+                              dom::HTMLCanvasElement* aCanvas,
                               imgIRequest* aRequest,
                               gfxASurface* aSurface,
                               const gfxIntSize& aSize);
 
   /**
    * Check whether aImage has recently been drawn into aCanvas. If we return
    * a non-null surface, then the image was recently drawn into the canvas
    * (with the same image request) and the returned surface contains the image
    * data, and the image size will be returned in aSize.
    */
   static gfxASurface* Lookup(dom::Element* aImage,
-                             nsHTMLCanvasElement* aCanvas,
+                             dom::HTMLCanvasElement* aCanvas,
                              gfxIntSize* aSize);
 };
 
 }
 
 #endif /* CANVASIMAGECACHE_H_ */
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -11,17 +11,17 @@
 #include "prenv.h"
 
 #include "nsIServiceManager.h"
 #include "nsMathUtils.h"
 
 #include "nsContentUtils.h"
 
 #include "nsIDocument.h"
-#include "nsHTMLCanvasElement.h"
+#include "mozilla/dom/HTMLCanvasElement.h"
 #include "nsSVGEffects.h"
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsIVariant.h"
 
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIFrame.h"
 #include "nsError.h"
@@ -616,17 +616,17 @@ CanvasRenderingContext2D::Reset()
   mThebesSurface = nullptr;
   mIsEntireFrameInvalid = false;
   mPredictManyRedrawCalls = false;
 
   return NS_OK;
 }
 
 static void
-WarnAboutUnexpectedStyle(nsHTMLCanvasElement* canvasElement)
+WarnAboutUnexpectedStyle(HTMLCanvasElement* canvasElement)
 {
   nsContentUtils::ReportToConsole(
     nsIScriptError::warningFlag,
     "Canvas",
     canvasElement ? canvasElement->OwnerDoc() : nullptr,
     nsContentUtils::eDOM_PROPERTIES,
     "UnexpectedCanvasVariantStyle");
 }
@@ -1395,17 +1395,17 @@ CanvasRenderingContext2D::CreatePattern(
     repeatMode = CanvasPattern::NOREPEAT;
   } else {
     error.Throw(NS_ERROR_DOM_SYNTAX_ERR);
     return NULL;
   }
 
   Element* htmlElement;
   if (element.IsHTMLCanvasElement()) {
-    nsHTMLCanvasElement* canvas = element.GetAsHTMLCanvasElement();
+    HTMLCanvasElement* canvas = element.GetAsHTMLCanvasElement();
     htmlElement = canvas;
 
     nsIntSize size = canvas->GetSize();
     if (size.width == 0 || size.height == 0) {
       error.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
       return NULL;
     }
 
@@ -2908,17 +2908,17 @@ CanvasRenderingContext2D::DrawImage(cons
 
   RefPtr<SourceSurface> srcSurf;
   gfxIntSize imgSize;
 
   Element* element;
 
   EnsureTarget();
   if (image.IsHTMLCanvasElement()) {
-    nsHTMLCanvasElement* canvas = image.GetAsHTMLCanvasElement();
+    HTMLCanvasElement* canvas = image.GetAsHTMLCanvasElement();
     element = canvas;
     nsIntSize size = canvas->GetSize();
     if (size.width == 0 || size.height == 0) {
       error.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
       return;
     }
 
     // Special case for Canvas, which could be an Azure canvas!
--- a/content/canvas/src/CanvasRenderingContext2D.h
+++ b/content/canvas/src/CanvasRenderingContext2D.h
@@ -5,17 +5,17 @@
 #ifndef CanvasRenderingContext2D_h
 #define CanvasRenderingContext2D_h
 
 #include <vector>
 #include "nsIDOMCanvasRenderingContext2D.h"
 #include "nsICanvasRenderingContextInternal.h"
 #include "mozilla/RefPtr.h"
 #include "nsColor.h"
-#include "nsHTMLCanvasElement.h"
+#include "mozilla/dom/HTMLCanvasElement.h"
 #include "nsHTMLVideoElement.h"
 #include "CanvasUtils.h"
 #include "gfxFont.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/ImageData.h"
 #include "mozilla/dom/UnionTypes.h"
 
 #define NS_CANVASGRADIENTAZURE_PRIVATE_IID \
@@ -136,17 +136,17 @@ typedef mozilla::dom::HTMLImageElementOr
 
 public:
   CanvasRenderingContext2D();
   virtual ~CanvasRenderingContext2D();
 
   virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
                                bool *triedToWrap);
 
-  nsHTMLCanvasElement* GetCanvas() const
+  HTMLCanvasElement* GetCanvas() const
   {
     // corresponds to changes to the old bindings made in bug 745025
     return mCanvasElement->GetOriginalCanvas();
   }
 
   void Save();
   void Restore();
   void Scale(double x, double y, mozilla::ErrorResult& error);
--- a/content/canvas/src/CanvasUtils.cpp
+++ b/content/canvas/src/CanvasUtils.cpp
@@ -9,33 +9,33 @@
 #include "prprf.h"
 
 #include "nsIServiceManager.h"
 
 #include "nsIConsoleService.h"
 #include "nsIDOMCanvasRenderingContext2D.h"
 #include "nsICanvasRenderingContextInternal.h"
 #include "nsIHTMLCollection.h"
-#include "nsHTMLCanvasElement.h"
+#include "mozilla/dom/HTMLCanvasElement.h"
 #include "nsIPrincipal.h"
 
 #include "nsGfxCIID.h"
 
 #include "nsTArray.h"
 
 #include "CanvasUtils.h"
 #include "mozilla/gfx/Matrix.h"
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace CanvasUtils {
 
 void
-DoDrawImageSecurityCheck(nsHTMLCanvasElement *aCanvasElement,
+DoDrawImageSecurityCheck(dom::HTMLCanvasElement *aCanvasElement,
                          nsIPrincipal *aPrincipal,
                          bool forceWriteOnly,
                          bool CORSUsed)
 {
     NS_PRECONDITION(aPrincipal, "Must have a principal here");
 
     // Callers should ensure that mCanvasElement is non-null before calling this
     if (!aCanvasElement) {
--- a/content/canvas/src/CanvasUtils.h
+++ b/content/canvas/src/CanvasUtils.h
@@ -5,25 +5,28 @@
 
 #ifndef _CANVASUTILS_H_
 #define _CANVASUTILS_H_
 
 #include "prtypes.h"
 
 #include "mozilla/CheckedInt.h"
 
-class nsHTMLCanvasElement;
 class nsIPrincipal;
 
 namespace mozilla {
 
 namespace gfx {
 class Matrix;
 }
 
+namespace dom {
+class HTMLCanvasElement;
+}
+
 namespace CanvasUtils {
 
 
 // Check that the rectangle [x,y,w,h] is a subrectangle of [0,0,realWidth,realHeight]
 
 inline bool CheckSaneSubrectSize(int32_t x, int32_t y, int32_t w, int32_t h,
                             int32_t realWidth, int32_t realHeight) {
     CheckedInt32 checked_xmost  = CheckedInt32(x) + w;
@@ -34,17 +37,17 @@ inline bool CheckSaneSubrectSize(int32_t
         checked_xmost.value() <= realWidth &&
         checked_ymost.isValid() &&
         checked_ymost.value() <= realHeight;
 }
 
 // Flag aCanvasElement as write-only if drawing an image with aPrincipal
 // onto it would make it such.
 
-void DoDrawImageSecurityCheck(nsHTMLCanvasElement *aCanvasElement,
+void DoDrawImageSecurityCheck(dom::HTMLCanvasElement *aCanvasElement,
                               nsIPrincipal *aPrincipal,
                               bool forceWriteOnly,
                               bool CORSUsed);
 
 // Make a double out of |v|, treating undefined values as 0.0 (for
 // the sake of sparse arrays).  Return true iff coercion
 // succeeded.
 bool CoerceDouble(jsval v, double* d);
--- a/content/canvas/src/WebGLContext.cpp
+++ b/content/canvas/src/WebGLContext.cpp
@@ -797,36 +797,36 @@ void WebGLContext::UpdateLastUseIndex()
 }
 
 static uint8_t gWebGLLayerUserData;
 
 namespace mozilla {
 
 class WebGLContextUserData : public LayerUserData {
 public:
-    WebGLContextUserData(nsHTMLCanvasElement *aContent)
+    WebGLContextUserData(HTMLCanvasElement *aContent)
     : mContent(aContent) {}
 
   /** DidTransactionCallback gets called by the Layers code everytime the WebGL canvas gets composite,
     * so it really is the right place to put actions that have to be performed upon compositing
     */
   static void DidTransactionCallback(void* aData)
   {
     WebGLContextUserData *userdata = static_cast<WebGLContextUserData*>(aData);
-    nsHTMLCanvasElement *canvas = userdata->mContent;
+    HTMLCanvasElement *canvas = userdata->mContent;
     WebGLContext *context = static_cast<WebGLContext*>(canvas->GetContextAtIndex(0));
 
     context->mBackbufferClearingStatus = BackbufferClearingStatus::NotClearedSinceLastPresented;
     canvas->MarkContextClean();
 
     context->UpdateLastUseIndex();
   }
 
 private:
-  nsRefPtr<nsHTMLCanvasElement> mContent;
+  nsRefPtr<HTMLCanvasElement> mContent;
 };
 
 } // end namespace mozilla
 
 already_AddRefed<layers::CanvasLayer>
 WebGLContext::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
                              CanvasLayer *aOldLayer,
                              LayerManager *aManager)
--- a/content/canvas/src/WebGLContext.h
+++ b/content/canvas/src/WebGLContext.h
@@ -23,17 +23,17 @@
 #include "nsDataHashtable.h"
 #include "nsHashKeys.h"
 #include "nsCycleCollectionNoteChild.h"
 
 #include "nsIDocShell.h"
 
 #include "nsIDOMWebGLRenderingContext.h"
 #include "nsICanvasRenderingContextInternal.h"
-#include "nsHTMLCanvasElement.h"
+#include "mozilla/dom/HTMLCanvasElement.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsIMemoryReporter.h"
 #include "nsIJSNativeInitializer.h"
 #include "nsWrapperCache.h"
 #include "nsIObserver.h"
 
 #include "GLContextProvider.h"
 
@@ -327,17 +327,17 @@ public:
     void TerminateContextLossTimer() {
         if (mContextLossTimerRunning) {
             mContextRestorer->Cancel();
             mContextLossTimerRunning = false;
         }
     }
 
     // WebIDL WebGLRenderingContext API
-    nsHTMLCanvasElement* GetCanvas() const {
+    dom::HTMLCanvasElement* GetCanvas() const {
         return mCanvasElement;
     }
     WebGLsizei DrawingBufferWidth() const {
         if (!IsContextStable())
             return 0;
         return mWidth;
     }
     WebGLsizei DrawingBufferHeight() const {
rename from content/html/content/public/nsHTMLCanvasElement.h
rename to content/html/content/public/HTMLCanvasElement.h
--- a/content/html/content/public/nsHTMLCanvasElement.h
+++ b/content/html/content/public/HTMLCanvasElement.h
@@ -1,57 +1,58 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* 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/. */
-#if !defined(nsHTMLCanvasElement_h__)
-#define nsHTMLCanvasElement_h__
+#if !defined(mozilla_dom_HTMLCanvasElement_h)
+#define mozilla_dom_HTMLCanvasElement_h
 
 #include "nsIDOMHTMLCanvasElement.h"
 #include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsSize.h"
 #include "nsError.h"
 #include "nsNodeInfoManager.h"
 
 #include "nsICanvasElementExternal.h"
 #include "nsLayoutUtils.h"
 
 class nsICanvasRenderingContextInternal;
 class nsIDOMFile;
-class nsHTMLCanvasPrintState;
 class nsITimerCallback;
 class nsIPropertyBag;
 
 namespace mozilla {
 
 namespace layers {
 class CanvasLayer;
 class LayerManager;
 }
 
 namespace gfx {
 struct Rect;
 }
 
-}
+namespace dom {
+
+class HTMLCanvasPrintState;
 
-class nsHTMLCanvasElement : public nsGenericHTMLElement,
-                            public nsICanvasElementExternal,
-                            public nsIDOMHTMLCanvasElement
+class HTMLCanvasElement MOZ_FINAL : public nsGenericHTMLElement,
+                                    public nsICanvasElementExternal,
+                                    public nsIDOMHTMLCanvasElement
 {
-  typedef mozilla::layers::CanvasLayer CanvasLayer;
-  typedef mozilla::layers::LayerManager LayerManager;
+  typedef layers::CanvasLayer CanvasLayer;
+  typedef layers::LayerManager LayerManager;
 
 public:
-  nsHTMLCanvasElement(already_AddRefed<nsINodeInfo> aNodeInfo);
-  virtual ~nsHTMLCanvasElement();
+  HTMLCanvasElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  virtual ~HTMLCanvasElement();
 
-  NS_IMPL_FROMCONTENT_HTML_WITH_TAG(nsHTMLCanvasElement, canvas)
+  NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLCanvasElement, canvas)
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
@@ -59,17 +60,17 @@ public:
 
   // nsIDOMHTMLElement
   NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
 
   // nsIDOMHTMLCanvasElement
   NS_DECL_NSIDOMHTMLCANVASELEMENT
 
   // CC
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLCanvasElement,
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLCanvasElement,
                                            nsGenericHTMLElement)
 
   /**
    * Get the size in pixels of this canvas element
    */
   nsIntSize GetSize();
 
   /**
@@ -168,38 +169,41 @@ protected:
   nsresult MozGetAsFileImpl(const nsAString& aName,
                             const nsAString& aType,
                             nsIDOMFile** aResult);
   nsresult GetContextHelper(const nsAString& aContextId,
                             nsICanvasRenderingContextInternal **aContext);
   void CallPrintCallback();
 
   nsString mCurrentContextId;
-  nsRefPtr<nsHTMLCanvasElement> mOriginalCanvas;
+  nsRefPtr<HTMLCanvasElement> mOriginalCanvas;
   nsCOMPtr<nsIPrintCallback> mPrintCallback;
   nsCOMPtr<nsICanvasRenderingContextInternal> mCurrentContext;
-  nsCOMPtr<nsHTMLCanvasPrintState> mPrintState;
+  nsCOMPtr<HTMLCanvasPrintState> mPrintState;
   
 public:
   // Record whether this canvas should be write-only or not.
   // We set this when script paints an image from a different origin.
   // We also transitively set it when script paints a canvas which
   // is itself write-only.
   bool                     mWriteOnly;
 
   bool IsPrintCallbackDone();
 
   void HandlePrintCallback(nsPresContext::nsPresContextType aType);
 
   nsresult DispatchPrintCallback(nsITimerCallback* aCallback);
 
   void ResetPrintCallback();
 
-  nsHTMLCanvasElement* GetOriginalCanvas();
+  HTMLCanvasElement* GetOriginalCanvas();
 };
 
 inline nsISupports*
-GetISupports(nsHTMLCanvasElement* p)
+GetISupports(HTMLCanvasElement* p)
 {
-  return static_cast<mozilla::dom::Element*>(p);
+  return static_cast<Element*>(p);
 }
 
-#endif /* nsHTMLCanvasElement_h__ */
+} // namespace dom
+} // namespace mozilla
+
+#endif /* mozilla_dom_HTMLCanvasElement_h */
--- a/content/html/content/public/Makefile.in
+++ b/content/html/content/public/Makefile.in
@@ -26,15 +26,20 @@ EXPORTS = \
 		nsIForm.h \
 		nsIFormProcessor.h \
 		nsILink.h \
 		nsIRadioVisitor.h \
 		nsIRadioGroupContainer.h \
 		nsITextControlElement.h \
 		nsFormSubmission.h \
 		nsHTMLAudioElement.h \
-		nsHTMLCanvasElement.h \
 		nsHTMLMediaElement.h \
 		nsHTMLVideoElement.h \
 		nsIHTMLCollection.h \
 		$(NULL)
 
+EXPORTS_NAMESPACES = mozilla/dom
+
+EXPORTS_mozilla/dom = \
+		HTMLCanvasElement.h \
+		$(NULL)
+
 include $(topsrcdir)/config/rules.mk
rename from content/html/content/src/nsHTMLCanvasElement.cpp
rename to content/html/content/src/HTMLCanvasElement.cpp
--- a/content/html/content/src/nsHTMLCanvasElement.cpp
+++ b/content/html/content/src/HTMLCanvasElement.cpp
@@ -1,14 +1,14 @@
 /* -*- 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 "nsHTMLCanvasElement.h"
+#include "mozilla/dom/HTMLCanvasElement.h"
 #include "nsAttrValueInlines.h"
 
 #include "mozilla/Base64.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/gfx/Rect.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Telemetry.h"
 #include "nsNetUtil.h"
@@ -31,20 +31,25 @@
 #include "nsITimer.h"
 #include "nsAsyncDOMEvent.h"
 
 #include "nsIWritablePropertyBag2.h"
 
 #define DEFAULT_CANVAS_WIDTH 300
 #define DEFAULT_CANVAS_HEIGHT 150
 
-using namespace mozilla;
-using namespace mozilla::dom;
 using namespace mozilla::layers;
 
+nsGenericHTMLElement*
+NS_NewHTMLCanvasElement(already_AddRefed<nsINodeInfo> aNodeInfo,
+                        mozilla::dom::FromParser aFromParser)
+{
+  return new mozilla::dom::HTMLCanvasElement(aNodeInfo);
+}
+
 namespace {
 
 typedef mozilla::dom::HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement
 HTMLImageOrCanvasOrVideoElement;
 
 class ToBlobRunnable : public nsRunnable
 {
 public:
@@ -64,22 +69,25 @@ public:
   }
 private:
   nsCOMPtr<nsIFileCallback> mCallback;
   nsCOMPtr<nsIDOMBlob> mBlob;
 };
 
 } // anonymous namespace
 
-class nsHTMLCanvasPrintState : public nsIDOMMozCanvasPrintState
+namespace mozilla {
+namespace dom {
+
+class HTMLCanvasPrintState : public nsIDOMMozCanvasPrintState
 {
 public:
-  nsHTMLCanvasPrintState(nsHTMLCanvasElement* aCanvas,
-                         nsICanvasRenderingContextInternal* aContext,
-                         nsITimerCallback* aCallback)
+  HTMLCanvasPrintState(HTMLCanvasElement* aCanvas,
+                       nsICanvasRenderingContextInternal* aContext,
+                       nsITimerCallback* aCallback)
     : mIsDone(false), mPendingNotify(false), mCanvas(aCanvas),
       mContext(aContext), mCallback(aCallback)
   {
   }
 
   NS_IMETHOD GetContext(nsISupports** aContext)
   {
     NS_ADDREF(*aContext = mContext);
@@ -89,18 +97,18 @@ public:
   NS_IMETHOD Done()
   {
     if (!mPendingNotify && !mIsDone) {
       // The canvas needs to be invalidated for printing reftests on linux to
       // work.
       if (mCanvas) {
         mCanvas->InvalidateCanvas();
       }
-      nsRefPtr<nsRunnableMethod<nsHTMLCanvasPrintState> > doneEvent =
-        NS_NewRunnableMethod(this, &nsHTMLCanvasPrintState::NotifyDone);
+      nsRefPtr<nsRunnableMethod<HTMLCanvasPrintState> > doneEvent =
+        NS_NewRunnableMethod(this, &HTMLCanvasPrintState::NotifyDone);
       if (NS_SUCCEEDED(NS_DispatchToCurrentThread(doneEvent))) {
         mPendingNotify = true;
       }
     }
     return NS_OK;
   }
 
   void NotifyDone()
@@ -111,106 +119,95 @@ public:
       mCallback->Notify(nullptr);
     }
   }
 
   bool mIsDone;
 
   // CC
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_CLASS(nsHTMLCanvasPrintState)
+  NS_DECL_CYCLE_COLLECTION_CLASS(HTMLCanvasPrintState)
 private:
-  virtual ~nsHTMLCanvasPrintState()
+  virtual ~HTMLCanvasPrintState()
   {
   }
   bool mPendingNotify;
 
 protected:
-  nsRefPtr<nsHTMLCanvasElement> mCanvas;
+  nsRefPtr<HTMLCanvasElement> mCanvas;
   nsCOMPtr<nsICanvasRenderingContextInternal> mContext;
   nsCOMPtr<nsITimerCallback> mCallback;
 };
 
-NS_IMPL_CYCLE_COLLECTING_ADDREF(nsHTMLCanvasPrintState)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(nsHTMLCanvasPrintState)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(HTMLCanvasPrintState)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(HTMLCanvasPrintState)
 
-DOMCI_DATA(MozCanvasPrintState, nsHTMLCanvasPrintState)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsHTMLCanvasPrintState)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(HTMLCanvasPrintState)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
   NS_INTERFACE_MAP_ENTRY(nsIDOMMozCanvasPrintState)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozCanvasPrintState)
 NS_INTERFACE_MAP_END
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsHTMLCanvasPrintState)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsHTMLCanvasPrintState)
+NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLCanvasPrintState)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(HTMLCanvasPrintState)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCanvas)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mContext)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCallback)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsHTMLCanvasPrintState)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(HTMLCanvasPrintState)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mCanvas)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mContext)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mCallback)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 // ---------------------------------------------------------------------------
 
-nsGenericHTMLElement*
-NS_NewHTMLCanvasElement(already_AddRefed<nsINodeInfo> aNodeInfo,
-                        FromParser aFromParser)
-{
-  return new nsHTMLCanvasElement(aNodeInfo);
-}
-
-nsHTMLCanvasElement::nsHTMLCanvasElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+HTMLCanvasElement::HTMLCanvasElement(already_AddRefed<nsINodeInfo> aNodeInfo)
   : nsGenericHTMLElement(aNodeInfo), 
     mWriteOnly(false)
 {
 }
 
-nsHTMLCanvasElement::~nsHTMLCanvasElement()
+HTMLCanvasElement::~HTMLCanvasElement()
 {
   ResetPrintCallback();
 }
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsHTMLCanvasElement)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLCanvasElement,
+NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLCanvasElement)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLCanvasElement,
                                                   nsGenericHTMLElement)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCurrentContext)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPrintCallback)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPrintState)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOriginalCanvas)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsHTMLCanvasElement,
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLCanvasElement,
                                                 nsGenericHTMLElement)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mCurrentContext)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mPrintCallback)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mPrintState)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mOriginalCanvas)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
-NS_IMPL_ADDREF_INHERITED(nsHTMLCanvasElement, Element)
-NS_IMPL_RELEASE_INHERITED(nsHTMLCanvasElement, Element)
+NS_IMPL_ADDREF_INHERITED(HTMLCanvasElement, Element)
+NS_IMPL_RELEASE_INHERITED(HTMLCanvasElement, Element)
 
-DOMCI_NODE_DATA(HTMLCanvasElement, nsHTMLCanvasElement)
-
-NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLCanvasElement)
-  NS_HTML_CONTENT_INTERFACE_TABLE2(nsHTMLCanvasElement,
+NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLCanvasElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE2(HTMLCanvasElement,
                                    nsIDOMHTMLCanvasElement,
                                    nsICanvasElementExternal)
-  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLCanvasElement,
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(HTMLCanvasElement,
                                                nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLCanvasElement)
 
-NS_IMPL_ELEMENT_CLONE(nsHTMLCanvasElement)
+NS_IMPL_ELEMENT_CLONE(HTMLCanvasElement)
 
 nsIntSize
-nsHTMLCanvasElement::GetWidthHeight()
+HTMLCanvasElement::GetWidthHeight()
 {
   nsIntSize size(DEFAULT_CANVAS_WIDTH, DEFAULT_CANVAS_HEIGHT);
   const nsAttrValue* value;
 
   if ((value = GetParsedAttr(nsGkAtoms::width)) &&
       value->Type() == nsAttrValue::eInteger)
   {
       size.width = value->GetIntegerValue();
@@ -220,182 +217,182 @@ nsHTMLCanvasElement::GetWidthHeight()
       value->Type() == nsAttrValue::eInteger)
   {
       size.height = value->GetIntegerValue();
   }
 
   return size;
 }
 
-NS_IMPL_UINT_ATTR_DEFAULT_VALUE(nsHTMLCanvasElement, Width, width, DEFAULT_CANVAS_WIDTH)
-NS_IMPL_UINT_ATTR_DEFAULT_VALUE(nsHTMLCanvasElement, Height, height, DEFAULT_CANVAS_HEIGHT)
-NS_IMPL_BOOL_ATTR(nsHTMLCanvasElement, MozOpaque, moz_opaque)
+NS_IMPL_UINT_ATTR_DEFAULT_VALUE(HTMLCanvasElement, Width, width, DEFAULT_CANVAS_WIDTH)
+NS_IMPL_UINT_ATTR_DEFAULT_VALUE(HTMLCanvasElement, Height, height, DEFAULT_CANVAS_HEIGHT)
+NS_IMPL_BOOL_ATTR(HTMLCanvasElement, MozOpaque, moz_opaque)
 
 nsresult
-nsHTMLCanvasElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
-                             nsIAtom* aPrefix, const nsAString& aValue,
-                             bool aNotify)
+HTMLCanvasElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
+                           nsIAtom* aPrefix, const nsAString& aValue,
+                           bool aNotify)
 {
   nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix, aValue,
                                               aNotify);
   if (NS_SUCCEEDED(rv) && mCurrentContext &&
       (aName == nsGkAtoms::width || aName == nsGkAtoms::height || aName == nsGkAtoms::moz_opaque))
   {
     rv = UpdateContext();
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return rv;
 }
 
 void
-nsHTMLCanvasElement::HandlePrintCallback(nsPresContext::nsPresContextType aType)
+HTMLCanvasElement::HandlePrintCallback(nsPresContext::nsPresContextType aType)
 {
   // Only call the print callback here if 1) we're in a print testing mode or
   // print preview mode, 2) the canvas has a print callback and 3) the callback
   // hasn't already been called. For real printing the callback is handled in
   // nsSimplePageSequenceFrame::PrePrintNextPage.
   nsCOMPtr<nsIPrintCallback> printCallback;
   if ((aType == nsPresContext::eContext_PageLayout ||
        aType == nsPresContext::eContext_PrintPreview) &&
       !mPrintState &&
       NS_SUCCEEDED(GetMozPrintCallback(getter_AddRefs(printCallback))) && printCallback) {
     DispatchPrintCallback(nullptr);
   }
 }
 
 nsresult
-nsHTMLCanvasElement::DispatchPrintCallback(nsITimerCallback* aCallback)
+HTMLCanvasElement::DispatchPrintCallback(nsITimerCallback* aCallback)
 {
   // For print reftests the context may not be initialized yet, so get a context
   // so mCurrentContext is set.
   if (!mCurrentContext) {
     nsresult rv;
     nsCOMPtr<nsISupports> context;
     rv = GetContext(NS_LITERAL_STRING("2d"), JSVAL_VOID,
                     getter_AddRefs(context));
     NS_ENSURE_SUCCESS(rv, rv);
   }
-  mPrintState = new nsHTMLCanvasPrintState(this, mCurrentContext, aCallback);
+  mPrintState = new HTMLCanvasPrintState(this, mCurrentContext, aCallback);
 
-  nsRefPtr<nsRunnableMethod<nsHTMLCanvasElement> > renderEvent =
-        NS_NewRunnableMethod(this, &nsHTMLCanvasElement::CallPrintCallback);
+  nsRefPtr<nsRunnableMethod<HTMLCanvasElement> > renderEvent =
+        NS_NewRunnableMethod(this, &HTMLCanvasElement::CallPrintCallback);
   return NS_DispatchToCurrentThread(renderEvent);
 }
 
 void
-nsHTMLCanvasElement::CallPrintCallback()
+HTMLCanvasElement::CallPrintCallback()
 {
   nsCOMPtr<nsIPrintCallback> printCallback;
   GetMozPrintCallback(getter_AddRefs(printCallback));
   printCallback->Render(mPrintState);
 }
 
 void
-nsHTMLCanvasElement::ResetPrintCallback()
+HTMLCanvasElement::ResetPrintCallback()
 {
   if (mPrintState) {
     mPrintState = nullptr;
   }
 }
 
 bool
-nsHTMLCanvasElement::IsPrintCallbackDone()
+HTMLCanvasElement::IsPrintCallbackDone()
 {
   if (mPrintState == nullptr) {
     return true;
   }
 
   return mPrintState->mIsDone;
 }
 
-nsHTMLCanvasElement*
-nsHTMLCanvasElement::GetOriginalCanvas()
+HTMLCanvasElement*
+HTMLCanvasElement::GetOriginalCanvas()
 {
   return mOriginalCanvas ? mOriginalCanvas.get() : this;
 }
 
 nsresult
-nsHTMLCanvasElement::CopyInnerTo(Element* aDest)
+HTMLCanvasElement::CopyInnerTo(Element* aDest)
 {
   nsresult rv = nsGenericHTMLElement::CopyInnerTo(aDest);
   NS_ENSURE_SUCCESS(rv, rv);
   if (aDest->OwnerDoc()->IsStaticDocument()) {
-    nsHTMLCanvasElement* dest = static_cast<nsHTMLCanvasElement*>(aDest);
-    nsHTMLCanvasElement* self = const_cast<nsHTMLCanvasElement*>(this);
+    HTMLCanvasElement* dest = static_cast<HTMLCanvasElement*>(aDest);
+    HTMLCanvasElement* self = const_cast<HTMLCanvasElement*>(this);
     dest->mOriginalCanvas = self;
 
     nsCOMPtr<nsISupports> cxt;
     dest->GetContext(NS_LITERAL_STRING("2d"), JSVAL_VOID, getter_AddRefs(cxt));
     nsRefPtr<CanvasRenderingContext2D> context2d =
       static_cast<CanvasRenderingContext2D*>(cxt.get());
     if (context2d && !self->mPrintCallback) {
-      HTMLImageOrCanvasOrVideoElement element;
-      element.SetAsHTMLCanvasElement() = this;
+      HTMLImageOrCanvasOrVideoElement element;
+      element.SetAsHTMLCanvasElement() = this;
       ErrorResult err;
       context2d->DrawImage(element,
                            0.0, 0.0, err);
       rv = err.ErrorCode();
     }
   }
   return rv;
 }
 
 nsChangeHint
-nsHTMLCanvasElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
-                                            int32_t aModType) const
+HTMLCanvasElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
+                                          int32_t aModType) const
 {
   nsChangeHint retval =
     nsGenericHTMLElement::GetAttributeChangeHint(aAttribute, aModType);
   if (aAttribute == nsGkAtoms::width ||
       aAttribute == nsGkAtoms::height)
   {
     NS_UpdateHint(retval, NS_STYLE_HINT_REFLOW);
   } else if (aAttribute == nsGkAtoms::moz_opaque)
   {
     NS_UpdateHint(retval, NS_STYLE_HINT_VISUAL);
   }
   return retval;
 }
 
 bool
-nsHTMLCanvasElement::ParseAttribute(int32_t aNamespaceID,
-                                    nsIAtom* aAttribute,
-                                    const nsAString& aValue,
-                                    nsAttrValue& aResult)
+HTMLCanvasElement::ParseAttribute(int32_t aNamespaceID,
+                                  nsIAtom* aAttribute,
+                                  const nsAString& aValue,
+                                  nsAttrValue& aResult)
 {
   if (aNamespaceID == kNameSpaceID_None &&
       (aAttribute == nsGkAtoms::width || aAttribute == nsGkAtoms::height)) {
     return aResult.ParseNonNegativeIntValue(aValue);
   }
 
   return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
                                               aResult);
 }
 
 
-// nsHTMLCanvasElement::toDataURL
+// HTMLCanvasElement::toDataURL
 
 NS_IMETHODIMP
-nsHTMLCanvasElement::ToDataURL(const nsAString& aType, nsIVariant* aParams,
-                               uint8_t optional_argc, nsAString& aDataURL)
+HTMLCanvasElement::ToDataURL(const nsAString& aType, nsIVariant* aParams,
+                             uint8_t optional_argc, nsAString& aDataURL)
 {
   // do a trust check if this is a write-only canvas
   if (mWriteOnly && !nsContentUtils::IsCallerChrome()) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   return ToDataURLImpl(aType, aParams, aDataURL);
 }
 
-// nsHTMLCanvasElement::mozFetchAsStream
+// HTMLCanvasElement::mozFetchAsStream
 
 NS_IMETHODIMP
-nsHTMLCanvasElement::MozFetchAsStream(nsIInputStreamCallback *aCallback,
-                                      const nsAString& aType)
+HTMLCanvasElement::MozFetchAsStream(nsIInputStreamCallback *aCallback,
+                                    const nsAString& aType)
 {
   if (!nsContentUtils::IsCallerChrome())
     return NS_ERROR_FAILURE;
 
   nsresult rv;
   bool fellBackToPNG = false;
   nsCOMPtr<nsIInputStream> inputData;
 
@@ -412,38 +409,38 @@ nsHTMLCanvasElement::MozFetchAsStream(ns
   nsCOMPtr<nsIInputStreamCallback> asyncCallback;
   rv = NS_NewInputStreamReadyEvent(getter_AddRefs(asyncCallback), aCallback, mainThread);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return asyncCallback->OnInputStreamReady(asyncData);
 }
 
 NS_IMETHODIMP
-nsHTMLCanvasElement::SetMozPrintCallback(nsIPrintCallback *aCallback)
+HTMLCanvasElement::SetMozPrintCallback(nsIPrintCallback *aCallback)
 {
   mPrintCallback = aCallback;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLCanvasElement::GetMozPrintCallback(nsIPrintCallback** aCallback)
+HTMLCanvasElement::GetMozPrintCallback(nsIPrintCallback** aCallback)
 {
   if (mOriginalCanvas) {
     mOriginalCanvas->GetMozPrintCallback(aCallback);
     return NS_OK;
   }
   NS_IF_ADDREF(*aCallback = mPrintCallback);
   return NS_OK;
 }
 
 nsresult
-nsHTMLCanvasElement::ExtractData(const nsAString& aType,
-                                 const nsAString& aOptions,
-                                 nsIInputStream** aStream,
-                                 bool& aFellBackToPNG)
+HTMLCanvasElement::ExtractData(const nsAString& aType,
+                               const nsAString& aOptions,
+                               nsIInputStream** aStream,
+                               bool& aFellBackToPNG)
 {
   // note that if we don't have a current context, the spec says we're
   // supposed to just return transparent black pixels of the canvas
   // dimensions.
   nsRefPtr<gfxImageSurface> emptyCanvas;
   nsIntSize size = GetWidthHeight();
   if (!mCurrentContext) {
     emptyCanvas = new gfxImageSurface(gfxIntSize(size.width, size.height), gfxASurface::ImageFormatARGB32);
@@ -495,19 +492,19 @@ nsHTMLCanvasElement::ExtractData(const n
 
   NS_ENSURE_SUCCESS(rv, rv);
 
   imgStream.forget(aStream);
   return NS_OK;
 }
 
 nsresult
-nsHTMLCanvasElement::ToDataURLImpl(const nsAString& aMimeType,
-                                   nsIVariant* aEncoderOptions,
-                                   nsAString& aDataURL)
+HTMLCanvasElement::ToDataURLImpl(const nsAString& aMimeType,
+                                 nsIVariant* aEncoderOptions,
+                                 nsAString& aDataURL)
 {
   bool fallbackToPNG = false;
 
   nsIntSize size = GetWidthHeight();
   if (size.height == 0 || size.width == 0) {
     aDataURL = NS_LITERAL_STRING("data:,");
     return NS_OK;
   }
@@ -580,20 +577,20 @@ nsHTMLCanvasElement::ToDataURLImpl(const
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(count <= UINT32_MAX, NS_ERROR_FILE_TOO_BIG);
 
   return Base64EncodeInputStream(stream, aDataURL, (uint32_t)count, aDataURL.Length());
 }
 
 // XXXkhuey the encoding should be off the main thread, but we're lazy.
 NS_IMETHODIMP
-nsHTMLCanvasElement::ToBlob(nsIFileCallback* aCallback,
-                            const nsAString& aType,
-                            nsIVariant* aParams,
-                            uint8_t optional_argc)
+HTMLCanvasElement::ToBlob(nsIFileCallback* aCallback,
+                          const nsAString& aType,
+                          nsIVariant* aParams,
+                          uint8_t optional_argc)
 {
   // do a trust check if this is a write-only canvas
   if (mWriteOnly && !nsContentUtils::IsCallerChrome()) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   if (!aCallback) {
     return NS_ERROR_UNEXPECTED;
@@ -633,34 +630,34 @@ nsHTMLCanvasElement::ToBlob(nsIFileCallb
     JS_updateMallocCounter(cx, imgSize);
   }
 
   nsRefPtr<ToBlobRunnable> runnable = new ToBlobRunnable(aCallback, blob);
   return NS_DispatchToCurrentThread(runnable);
 }
 
 NS_IMETHODIMP
-nsHTMLCanvasElement::MozGetAsFile(const nsAString& aName,
-                                  const nsAString& aType,
-                                  uint8_t optional_argc,
-                                  nsIDOMFile** aResult)
+HTMLCanvasElement::MozGetAsFile(const nsAString& aName,
+                                const nsAString& aType,
+                                uint8_t optional_argc,
+                                nsIDOMFile** aResult)
 {
   // do a trust check if this is a write-only canvas
   if ((mWriteOnly) &&
       !nsContentUtils::IsCallerChrome()) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   return MozGetAsFileImpl(aName, aType, aResult);
 }
 
 nsresult
-nsHTMLCanvasElement::MozGetAsFileImpl(const nsAString& aName,
-                                      const nsAString& aType,
-                                      nsIDOMFile** aResult)
+HTMLCanvasElement::MozGetAsFileImpl(const nsAString& aName,
+                                    const nsAString& aType,
+                                    nsIDOMFile** aResult)
 {
   bool fallbackToPNG = false;
 
   nsCOMPtr<nsIInputStream> stream;
   nsresult rv = ExtractData(aType, EmptyString(), getter_AddRefs(stream),
                             fallbackToPNG);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -687,18 +684,18 @@ nsHTMLCanvasElement::MozGetAsFileImpl(co
   nsRefPtr<nsDOMMemoryFile> file =
     new nsDOMMemoryFile(imgData, (uint32_t)imgSize, aName, type);
 
   file.forget(aResult);
   return NS_OK;
 }
 
 nsresult
-nsHTMLCanvasElement::GetContextHelper(const nsAString& aContextId,
-                                      nsICanvasRenderingContextInternal **aContext)
+HTMLCanvasElement::GetContextHelper(const nsAString& aContextId,
+                                    nsICanvasRenderingContextInternal **aContext)
 {
   NS_ENSURE_ARG(aContext);
 
   if (aContextId.EqualsLiteral("2d")) {
     Telemetry::Accumulate(Telemetry::CANVAS_2D_USED, 1);
     nsRefPtr<CanvasRenderingContext2D> ctx =
       new CanvasRenderingContext2D();
 
@@ -739,19 +736,19 @@ nsHTMLCanvasElement::GetContextHelper(co
   }
 
   ctx->SetCanvasElement(this);
   ctx.forget(aContext);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLCanvasElement::GetContext(const nsAString& aContextId,
-                                const JS::Value& aContextOptions,
-                                nsISupports **aContext)
+HTMLCanvasElement::GetContext(const nsAString& aContextId,
+                              const JS::Value& aContextOptions,
+                              nsISupports **aContext)
 {
   nsresult rv;
 
   if (mCurrentContextId.IsEmpty()) {
     rv = GetContextHelper(aContextId, getter_AddRefs(mCurrentContext));
     NS_ENSURE_SUCCESS(rv, rv);
     if (!mCurrentContext) {
       return NS_OK;
@@ -826,18 +823,18 @@ nsHTMLCanvasElement::GetContext(const ns
     return NS_OK;
   }
 
   NS_ADDREF (*aContext = mCurrentContext);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLCanvasElement::MozGetIPCContext(const nsAString& aContextId,
-                                      nsISupports **aContext)
+HTMLCanvasElement::MozGetIPCContext(const nsAString& aContextId,
+                                    nsISupports **aContext)
 {
   if(!nsContentUtils::IsCallerChrome()) {
     // XXX ERRMSG we need to report an error to developers here! (bug 329026)
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   // We only support 2d shmem contexts for now.
   if (!aContextId.Equals(NS_LITERAL_STRING("2d")))
@@ -861,17 +858,17 @@ nsHTMLCanvasElement::MozGetIPCContext(co
     return NS_ERROR_INVALID_ARG;
   }
 
   NS_ADDREF (*aContext = mCurrentContext);
   return NS_OK;
 }
 
 nsresult
-nsHTMLCanvasElement::UpdateContext(nsIPropertyBag *aNewContextOptions)
+HTMLCanvasElement::UpdateContext(nsIPropertyBag *aNewContextOptions)
 {
   if (!mCurrentContext)
     return NS_OK;
 
   nsIntSize sz = GetWidthHeight();
 
   nsresult rv = mCurrentContext->SetIsOpaque(GetIsOpaque());
   if (NS_FAILED(rv)) {
@@ -893,35 +890,35 @@ nsHTMLCanvasElement::UpdateContext(nsIPr
     mCurrentContextId.Truncate();
     return rv;
   }
 
   return rv;
 }
 
 nsIntSize
-nsHTMLCanvasElement::GetSize()
+HTMLCanvasElement::GetSize()
 {
   return GetWidthHeight();
 }
 
 bool
-nsHTMLCanvasElement::IsWriteOnly()
+HTMLCanvasElement::IsWriteOnly()
 {
   return mWriteOnly;
 }
 
 void
-nsHTMLCanvasElement::SetWriteOnly()
+HTMLCanvasElement::SetWriteOnly()
 {
   mWriteOnly = true;
 }
 
 void
-nsHTMLCanvasElement::InvalidateCanvasContent(const gfx::Rect* damageRect)
+HTMLCanvasElement::InvalidateCanvasContent(const gfx::Rect* damageRect)
 {
   // We don't need to flush anything here; if there's no frame or if
   // we plan to reframe we don't need to invalidate it anyway.
   nsIFrame *frame = GetPrimaryFrame();
   if (!frame)
     return;
 
   frame->MarkLayersActive(nsChangeHint(0));
@@ -957,84 +954,89 @@ nsHTMLCanvasElement::InvalidateCanvasCon
     JSObject *obj = scope->GetGlobalJSObject();
     if (obj) {
       js::NotifyAnimationActivity(obj);
     }
   }
 }
 
 void
-nsHTMLCanvasElement::InvalidateCanvas()
+HTMLCanvasElement::InvalidateCanvas()
 {
   // We don't need to flush anything here; if there's no frame or if
   // we plan to reframe we don't need to invalidate it anyway.
   nsIFrame *frame = GetPrimaryFrame();
   if (!frame)
     return;
 
   frame->InvalidateFrame();
 }
 
 int32_t
-nsHTMLCanvasElement::CountContexts()
+HTMLCanvasElement::CountContexts()
 {
   if (mCurrentContext)
     return 1;
 
   return 0;
 }
 
 nsICanvasRenderingContextInternal *
-nsHTMLCanvasElement::GetContextAtIndex(int32_t index)
+HTMLCanvasElement::GetContextAtIndex(int32_t index)
 {
   if (mCurrentContext && index == 0)
     return mCurrentContext;
 
   return NULL;
 }
 
 bool
-nsHTMLCanvasElement::GetIsOpaque()
+HTMLCanvasElement::GetIsOpaque()
 {
   return HasAttr(kNameSpaceID_None, nsGkAtoms::moz_opaque);
 }
 
 already_AddRefed<CanvasLayer>
-nsHTMLCanvasElement::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
-                                    CanvasLayer *aOldLayer,
-                                    LayerManager *aManager)
+HTMLCanvasElement::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
+                                  CanvasLayer *aOldLayer,
+                                  LayerManager *aManager)
 {
   if (!mCurrentContext)
     return nullptr;
 
   return mCurrentContext->GetCanvasLayer(aBuilder, aOldLayer, aManager);
 }
 
 bool
-nsHTMLCanvasElement::ShouldForceInactiveLayer(LayerManager *aManager)
+HTMLCanvasElement::ShouldForceInactiveLayer(LayerManager *aManager)
 {
   return !mCurrentContext || mCurrentContext->ShouldForceInactiveLayer(aManager);
 }
 
 void
-nsHTMLCanvasElement::MarkContextClean()
+HTMLCanvasElement::MarkContextClean()
 {
   if (!mCurrentContext)
     return;
 
   mCurrentContext->MarkContextClean();
 }
 
 NS_IMETHODIMP_(nsIntSize)
-nsHTMLCanvasElement::GetSizeExternal()
+HTMLCanvasElement::GetSizeExternal()
 {
   return GetWidthHeight();
 }
 
 NS_IMETHODIMP
-nsHTMLCanvasElement::RenderContextsExternal(gfxContext *aContext, gfxPattern::GraphicsFilter aFilter, uint32_t aFlags)
+HTMLCanvasElement::RenderContextsExternal(gfxContext *aContext, gfxPattern::GraphicsFilter aFilter, uint32_t aFlags)
 {
   if (!mCurrentContext)
     return NS_OK;
 
   return mCurrentContext->Render(aContext, aFilter, aFlags);
 }
 
+} // namespace dom
+} // namespace mozilla
+
+DOMCI_NODE_DATA(HTMLCanvasElement, mozilla::dom::HTMLCanvasElement)
+DOMCI_DATA(MozCanvasPrintState, mozilla::dom::HTMLCanvasPrintState)
--- a/content/html/content/src/Makefile.in
+++ b/content/html/content/src/Makefile.in
@@ -50,17 +50,17 @@ CPPSRCS		= \
 		nsFormSubmission.cpp \
 		nsTextEditorState.cpp \
 		HTMLElement.cpp \
 		nsHTMLAnchorElement.cpp \
 		nsHTMLAreaElement.cpp \
 		nsHTMLBRElement.cpp \
 		HTMLBodyElement.cpp \
 		nsHTMLButtonElement.cpp \
-		nsHTMLCanvasElement.cpp \
+		HTMLCanvasElement.cpp \
 		HTMLDataListElement.cpp \
 		HTMLDivElement.cpp \
 		nsHTMLFieldSetElement.cpp \
 		HTMLFontElement.cpp \
 		nsHTMLFormElement.cpp \
 		nsHTMLFrameElement.cpp \
 		HTMLFrameSetElement.cpp \
 		nsHTMLHRElement.cpp \
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1020,17 +1020,16 @@ def addExternalIface(iface, nativeType=N
 
 # If you add one of these, you need to make sure nsDOMQS.h has the relevant
 # macros added for it
 def addExternalHTMLElement(element):
    nativeElement = 'ns' + element
    addExternalIface(element, nativeType=nativeElement,
                     headerFile=nativeElement + '.h')
 
-addExternalHTMLElement('HTMLCanvasElement')
 addExternalHTMLElement('HTMLFormElement')
 addExternalHTMLElement('HTMLMenuElement')
 addExternalHTMLElement('HTMLOptionElement')
 addExternalHTMLElement('HTMLOptGroupElement')
 addExternalHTMLElement('HTMLVideoElement')
 addExternalIface('Attr')
 addExternalIface('CanvasGradient', headerFile='nsIDOMCanvasRenderingContext2D.h')
 addExternalIface('CanvasPattern', headerFile='nsIDOMCanvasRenderingContext2D.h')
@@ -1039,16 +1038,17 @@ addExternalIface('ClientRect')
 addExternalIface('Comment', nativeType='mozilla::dom::Comment')
 addExternalIface("Counter")
 addExternalIface('CSSRule')
 addExternalIface('DOMRequest')
 addExternalIface('DOMStringList')
 addExternalIface('File')
 addExternalIface('HitRegionOptions', nativeType='nsISupports')
 addExternalIface('HTMLHeadElement', nativeType='mozilla::dom::Element')
+addExternalIface('HTMLCanvasElement', nativeType='mozilla::dom::HTMLCanvasElement')
 addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
 addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
 addExternalIface('LockedFile')
 addExternalIface('MediaStream')
 addExternalIface('NamedNodeMap')
 addExternalIface('NodeIterator')
 addExternalIface('nsIStreamListener', nativeType='nsIStreamListener', notflattened=True)
 addExternalIface('nsISupports', nativeType='nsISupports')
--- a/js/xpconnect/src/nsDOMQS.h
+++ b/js/xpconnect/src/nsDOMQS.h
@@ -2,17 +2,17 @@
  * 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 nsDOMQS_h__
 #define nsDOMQS_h__
 
 #include "nsDOMClassInfoID.h"
 #include "nsGenericHTMLElement.h"
-#include "nsHTMLCanvasElement.h"
+#include "mozilla/dom/HTMLCanvasElement.h"
 #include "nsHTMLFormElement.h"
 #include "mozilla/dom/HTMLImageElement.h"
 #include "nsHTMLOptionElement.h"
 #include "nsHTMLOptGroupElement.h"
 #include "nsHTMLVideoElement.h"
 #include "nsHTMLDocument.h"
 #include "nsICSSDeclaration.h"
 #include "nsSVGElement.h"
@@ -163,17 +163,17 @@ xpc_qsUnwrapArg<_clazz>(JSContext *cx, j
                         _clazz **ppArgRef, jsval *vp)                         \
 {                                                                             \
     nsISupports* argRef = static_cast<nsIContent*>(*ppArgRef);                \
     nsresult rv = xpc_qsUnwrapArg<_clazz>(cx, v, ppArg, &argRef, vp);         \
     *ppArgRef = static_cast<_clazz*>(static_cast<nsIContent*>(argRef));       \
     return rv;                                                                \
 }
 
-DEFINE_UNWRAP_CAST_HTML(canvas, nsHTMLCanvasElement)
+DEFINE_UNWRAP_CAST_HTML(canvas, mozilla::dom::HTMLCanvasElement)
 DEFINE_UNWRAP_CAST_HTML(form, nsHTMLFormElement)
 DEFINE_UNWRAP_CAST_HTML(img, mozilla::dom::HTMLImageElement)
 DEFINE_UNWRAP_CAST_HTML(optgroup, nsHTMLOptGroupElement)
 DEFINE_UNWRAP_CAST_HTML(option, nsHTMLOptionElement)
 DEFINE_UNWRAP_CAST_HTML(video, nsHTMLVideoElement)
 
 inline nsISupports*
 ToSupports(nsContentList *p)
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -44,17 +44,17 @@
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIWidget.h"
 #include "gfxMatrix.h"
 #include "gfxPoint3D.h"
 #include "gfxTypes.h"
 #include "gfxUserFontSet.h"
 #include "nsTArray.h"
-#include "nsHTMLCanvasElement.h"
+#include "mozilla/dom/HTMLCanvasElement.h"
 #include "nsICanvasRenderingContextInternal.h"
 #include "gfxPlatform.h"
 #include "nsClientRect.h"
 #ifdef MOZ_MEDIA
 #include "nsHTMLVideoElement.h"
 #endif
 #include "mozilla/dom/HTMLImageElement.h"
 #include "imgIRequest.h"
@@ -4515,17 +4515,17 @@ nsLayoutUtils::SurfaceFromElementResult
 nsLayoutUtils::SurfaceFromElement(HTMLImageElement *aElement,
                                   uint32_t aSurfaceFlags)
 {
   return SurfaceFromElement(static_cast<nsIImageLoadingContent*>(aElement),
                             aSurfaceFlags);
 }
 
 nsLayoutUtils::SurfaceFromElementResult
-nsLayoutUtils::SurfaceFromElement(nsHTMLCanvasElement* aElement,
+nsLayoutUtils::SurfaceFromElement(HTMLCanvasElement* aElement,
                                   uint32_t aSurfaceFlags)
 {
   SurfaceFromElementResult result;
   nsresult rv;
 
   bool forceCopy = (aSurfaceFlags & SFE_WANT_NEW_SURFACE) != 0;
   bool wantImageSurface = (aSurfaceFlags & SFE_WANT_IMAGE_SURFACE) != 0;
   bool premultAlpha = (aSurfaceFlags & SFE_NO_PREMULTIPLY_ALPHA) == 0;
@@ -4554,17 +4554,17 @@ nsLayoutUtils::SurfaceFromElement(nsHTML
     if (wantImageSurface) {
       surf = new gfxImageSurface(size, gfxASurface::ImageFormatARGB32);
     } else {
       surf = gfxPlatform::GetPlatform()->CreateOffscreenSurface(size, gfxASurface::CONTENT_COLOR_ALPHA);
     }
 
     nsRefPtr<gfxContext> ctx = new gfxContext(surf);
     // XXX shouldn't use the external interface, but maybe we can layerify this
-    uint32_t flags = premultAlpha ? nsHTMLCanvasElement::RenderFlagPremultAlpha : 0;
+    uint32_t flags = premultAlpha ? HTMLCanvasElement::RenderFlagPremultAlpha : 0;
     rv = aElement->RenderContextsExternal(ctx, gfxPattern::FILTER_NEAREST, flags);
     if (NS_FAILED(rv))
       return result;
   }
 
   // Ensure that any future changes to the canvas trigger proper invalidation,
   // in case this is being used by -moz-element()
   aElement->MarkContextClean();
@@ -4631,18 +4631,18 @@ nsLayoutUtils::SurfaceFromElement(nsHTML
   return result;
 }
 
 nsLayoutUtils::SurfaceFromElementResult
 nsLayoutUtils::SurfaceFromElement(dom::Element* aElement,
                                   uint32_t aSurfaceFlags)
 {
   // If it's a <canvas>, we may be able to just grab its internal surface
-  if (nsHTMLCanvasElement* canvas =
-        nsHTMLCanvasElement::FromContentOrNull(aElement)) {
+  if (HTMLCanvasElement* canvas =
+        HTMLCanvasElement::FromContentOrNull(aElement)) {
     return SurfaceFromElement(canvas, aSurfaceFlags);
   }
 
 #ifdef MOZ_MEDIA
   // Maybe it's <video>?
   if (nsHTMLVideoElement* video =
         nsHTMLVideoElement::FromContentOrNull(aElement)) {
     return SurfaceFromElement(video, aSurfaceFlags);
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -13,17 +13,16 @@ class nsIAtom;
 class nsIScrollableFrame;
 class nsIDOMEvent;
 class nsRegion;
 class nsDisplayListBuilder;
 class nsDisplayItem;
 class nsFontMetrics;
 class nsClientRectList;
 class nsFontFaceList;
-class nsHTMLCanvasElement;
 class nsHTMLVideoElement;
 class nsIImageLoadingContent;
 
 #include "nsChangeHint.h"
 #include "nsStyleContext.h"
 #include "nsAutoPtr.h"
 #include "nsStyleSet.h"
 #include "nsView.h"
@@ -42,16 +41,17 @@ class nsIImageLoadingContent;
 
 class nsBlockFrame;
 class gfxDrawable;
 
 namespace mozilla {
 namespace dom {
 class Element;
 class HTMLImageElement;
+class HTMLCanvasElement;
 } // namespace dom
 } // namespace mozilla
 
 /**
  * nsLayoutUtils is a namespace class used for various helper
  * functions that are useful in multiple places in layout.  The goal
  * is not to define multiple copies of the same static helper.
  */
@@ -1471,17 +1471,17 @@ public:
                                                      uint32_t aSurfaceFlags = 0);
   static SurfaceFromElementResult SurfaceFromElement(nsIImageLoadingContent *aElement,
                                                      uint32_t aSurfaceFlags = 0);
   // Need an HTMLImageElement overload, because otherwise the
   // nsIImageLoadingContent and mozilla::dom::Element overloads are ambiguous
   // for HTMLImageElement.
   static SurfaceFromElementResult SurfaceFromElement(mozilla::dom::HTMLImageElement *aElement,
                                                      uint32_t aSurfaceFlags = 0);
-  static SurfaceFromElementResult SurfaceFromElement(nsHTMLCanvasElement *aElement,
+  static SurfaceFromElementResult SurfaceFromElement(mozilla::dom::HTMLCanvasElement *aElement,
                                                      uint32_t aSurfaceFlags = 0);
   static SurfaceFromElementResult SurfaceFromElement(nsHTMLVideoElement *aElement,
                                                      uint32_t aSurfaceFlags = 0);
 
   /**
    * When the document is editable by contenteditable attribute of its root
    * content or body content.
    *
--- a/layout/generic/nsHTMLCanvasFrame.cpp
+++ b/layout/generic/nsHTMLCanvasFrame.cpp
@@ -6,26 +6,27 @@
 /* rendering object for the HTML <canvas> element */
 
 #include "nsHTMLParts.h"
 #include "nsCOMPtr.h"
 #include "nsIServiceManager.h"
 #include "nsGkAtoms.h"
 
 #include "nsHTMLCanvasFrame.h"
-#include "nsHTMLCanvasElement.h"
+#include "mozilla/dom/HTMLCanvasElement.h"
 #include "nsDisplayList.h"
 #include "nsLayoutUtils.h"
 #include "Layers.h"
 
 #include "nsTransform2D.h"
 
 #include "gfxContext.h"
 
 using namespace mozilla;
+using namespace mozilla::dom;
 using namespace mozilla::layers;
 
 class nsDisplayCanvas : public nsDisplayItem {
 public:
   nsDisplayCanvas(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
     : nsDisplayItem(aBuilder, aFrame)
   {
     MOZ_COUNT_CTOR(nsDisplayCanvas);
@@ -37,18 +38,18 @@ public:
 #endif
 
   NS_DISPLAY_DECL_NAME("nsDisplayCanvas", TYPE_CANVAS)
 
   virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
                                    bool* aSnap) {
     *aSnap = false;
     nsIFrame* f = GetUnderlyingFrame();
-    nsHTMLCanvasElement *canvas =
-      nsHTMLCanvasElement::FromContent(f->GetContent());
+    HTMLCanvasElement *canvas =
+      HTMLCanvasElement::FromContent(f->GetContent());
     nsRegion result;
     if (canvas->GetIsOpaque()) {
       result = GetBounds(aBuilder, aSnap);
     }
     return result;
   }
 
   virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) {
@@ -63,17 +64,17 @@ public:
   {
     return static_cast<nsHTMLCanvasFrame*>(mFrame)->
       BuildLayer(aBuilder, aManager, this, aContainerParameters);
   }
   virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
                                    LayerManager* aManager,
                                    const FrameLayerBuilder::ContainerParameters& aParameters)
   {
-    if (nsHTMLCanvasElement::FromContent(mFrame->GetContent())->ShouldForceInactiveLayer(aManager))
+    if (HTMLCanvasElement::FromContent(mFrame->GetContent())->ShouldForceInactiveLayer(aManager))
       return LAYER_INACTIVE;
 
     // If compositing is cheap, just do that
     if (aManager->IsCompositingCheap())
       return mozilla::LAYER_ACTIVE;
 
     return mFrame->AreLayersMarkedActive() ? LAYER_ACTIVE : LAYER_INACTIVE;
   }
@@ -106,18 +107,18 @@ nsHTMLCanvasFrame::Init(nsIContent* aCon
 nsHTMLCanvasFrame::~nsHTMLCanvasFrame()
 {
 }
 
 nsIntSize
 nsHTMLCanvasFrame::GetCanvasSize()
 {
   nsIntSize size(0,0);
-  nsHTMLCanvasElement *canvas =
-    nsHTMLCanvasElement::FromContentOrNull(GetContent());
+  HTMLCanvasElement *canvas =
+    HTMLCanvasElement::FromContentOrNull(GetContent());
   if (canvas) {
     size = canvas->GetSize();
   } else {
     NS_NOTREACHED("couldn't get canvas size");
   }
 
   return size;
 }
@@ -240,17 +241,17 @@ nsHTMLCanvasFrame::GetInnerArea() const
 
 already_AddRefed<Layer>
 nsHTMLCanvasFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
                               LayerManager* aManager,
                               nsDisplayItem* aItem,
                               const ContainerParameters& aContainerParameters)
 {
   nsRect area = GetContentRect() - GetPosition() + aItem->ToReferenceFrame();
-  nsHTMLCanvasElement* element = static_cast<nsHTMLCanvasElement*>(GetContent());
+  HTMLCanvasElement* element = static_cast<HTMLCanvasElement*>(GetContent());
   nsIntSize canvasSize = GetCanvasSize();
 
   nsPresContext* presContext = PresContext();
   element->HandlePrintCallback(presContext->Type());
 
   if (canvasSize.width <= 0 || canvasSize.height <= 0 || area.IsEmpty())
     return nullptr;
 
--- a/layout/generic/nsSimplePageSequence.cpp
+++ b/layout/generic/nsSimplePageSequence.cpp
@@ -15,30 +15,31 @@
 #include "nsSubDocumentFrame.h"
 #include "nsStyleConsts.h"
 #include "nsRegion.h"
 #include "nsCSSFrameConstructor.h"
 #include "nsContentUtils.h"
 #include "nsDisplayList.h"
 #include "mozilla/Preferences.h"
 #include "nsHTMLCanvasFrame.h"
-#include "nsHTMLCanvasElement.h"
+#include "mozilla/dom/HTMLCanvasElement.h"
 #include "nsICanvasRenderingContextInternal.h"
 
 // DateTime Includes
 #include "nsDateTimeFormatCID.h"
 
 #define OFFSET_NOT_SET -1
 
 // Print Options
 #include "nsIPrintOptions.h"
 #include "nsGfxCIID.h"
 #include "nsIServiceManager.h"
 
 using namespace mozilla;
+using namespace mozilla::dom;
 
 static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printsettings-service;1";
 
 //
 
 #include "prlog.h"
 #ifdef PR_LOGGING 
 PRLogModuleInfo *
@@ -477,35 +478,35 @@ nsSimplePageSequenceFrame::StartPrint(ns
   if (mTotalPages == -1) {
     mTotalPages = totalPages;
   }
 
   return rv;
 }
 
 void
-GetPrintCanvasElementsInFrame(nsIFrame* aFrame, nsTArray<nsRefPtr<nsHTMLCanvasElement> >* aArr)
+GetPrintCanvasElementsInFrame(nsIFrame* aFrame, nsTArray<nsRefPtr<HTMLCanvasElement> >* aArr)
 {
   if (!aFrame) {
     return;
   }
   for (nsIFrame::ChildListIterator childLists(aFrame);
     !childLists.IsDone(); childLists.Next()) {
 
     nsFrameList children = childLists.CurrentList();
     for (nsFrameList::Enumerator e(children); !e.AtEnd(); e.Next()) {
       nsIFrame* child = e.get();
 
       // Check if child is a nsHTMLCanvasFrame.
       nsHTMLCanvasFrame* canvasFrame = do_QueryFrame(child);
 
       // If there is a canvasFrame, try to get actual canvas element.
       if (canvasFrame) {
-        nsHTMLCanvasElement* canvas =
-          nsHTMLCanvasElement::FromContentOrNull(canvasFrame->GetContent());
+        HTMLCanvasElement* canvas =
+          HTMLCanvasElement::FromContentOrNull(canvasFrame->GetContent());
         nsCOMPtr<nsIPrintCallback> printCallback;
         if (canvas &&
             NS_SUCCEEDED(canvas->GetMozPrintCallback(getter_AddRefs(printCallback))) &&
             printCallback) {
           aArr->AppendElement(canvas);
           continue;
         }
       }
@@ -514,18 +515,18 @@ GetPrintCanvasElementsInFrame(nsIFrame* 
         nsSubDocumentFrame* subdocumentFrame = do_QueryFrame(child);
         if (subdocumentFrame) {
           // Descend into the subdocument
           nsIFrame* root = subdocumentFrame->GetSubdocumentRootFrame();
           child = root;
         }
       }
       // The current child is not a nsHTMLCanvasFrame OR it is but there is
-      // no nsHTMLCanvasElement on it. Check if children of `child` might
-      // contain a nsHTMLCanvasElement.
+      // no HTMLCanvasElement on it. Check if children of `child` might
+      // contain a HTMLCanvasElement.
       GetPrintCanvasElementsInFrame(child, aArr);
     }
   }
 }
 
 void
 nsSimplePageSequenceFrame::DetermineWhetherToPrintPage()
 {
@@ -585,17 +586,17 @@ nsSimplePageSequenceFrame::PrePrintNextP
   if (!mCurrentPageFrame) {
     *aDone = true;
     return NS_ERROR_FAILURE;
   }
   
   DetermineWhetherToPrintPage();
   // Nothing to do if the current page doesn't get printed OR rendering to
   // preview. For preview, the `CallPrintCallback` is called from within the
-  // nsHTMLCanvasElement::HandlePrintCallback.
+  // HTMLCanvasElement::HandlePrintCallback.
   if (!mPrintThisPage || !PresContext()->IsRootPaginatedDocument()) {
     *aDone = true;
     return NS_OK;
   }
 
   // If the canvasList is null, then generate it and start the render
   // process for all the canvas.
   if (!mCurrentCanvasListSetup) {
@@ -618,17 +619,17 @@ nsSimplePageSequenceFrame::PrePrintNextP
       dc->CreateRenderingContext(*getter_AddRefs(renderingContext));
       NS_ENSURE_TRUE(renderingContext, NS_ERROR_OUT_OF_MEMORY);
 
       nsRefPtr<gfxASurface> renderingSurface =
           renderingContext->ThebesContext()->CurrentSurface();
       NS_ENSURE_TRUE(renderingSurface, NS_ERROR_OUT_OF_MEMORY);
 
       for (int32_t i = mCurrentCanvasList.Length() - 1; i >= 0 ; i--) {
-        nsHTMLCanvasElement* canvas = mCurrentCanvasList[i];
+        HTMLCanvasElement* canvas = mCurrentCanvasList[i];
         nsIntSize size = canvas->GetSize();
 
         nsRefPtr<gfxASurface> printSurface = renderingSurface->
            CreateSimilarSurface(
              gfxASurface::CONTENT_COLOR_ALPHA,
              size
            );
 
@@ -645,33 +646,33 @@ nsSimplePageSequenceFrame::PrePrintNextP
         nsWeakFrame weakFrame = this;
         canvas->DispatchPrintCallback(aCallback);
         NS_ENSURE_STATE(weakFrame.IsAlive());
       }
     }
   }
   uint32_t doneCounter = 0;
   for (int32_t i = mCurrentCanvasList.Length() - 1; i >= 0 ; i--) {
-    nsHTMLCanvasElement* canvas = mCurrentCanvasList[i];
+    HTMLCanvasElement* canvas = mCurrentCanvasList[i];
 
     if (canvas->IsPrintCallbackDone()) {
       doneCounter++;
     }
   }
   // If all canvas have finished rendering, return true, otherwise false.
   *aDone = doneCounter == mCurrentCanvasList.Length();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSimplePageSequenceFrame::ResetPrintCanvasList()
 {
   for (int32_t i = mCurrentCanvasList.Length() - 1; i >= 0 ; i--) {
-    nsHTMLCanvasElement* canvas = mCurrentCanvasList[i];
+    HTMLCanvasElement* canvas = mCurrentCanvasList[i];
     canvas->ResetPrintCallback();
   }
 
   mCurrentCanvasList.Clear();
   mCurrentCanvasListSetup = false; 
   return NS_OK;
 } 
 
--- a/layout/generic/nsSimplePageSequence.h
+++ b/layout/generic/nsSimplePageSequence.h
@@ -6,17 +6,17 @@
 #define nsSimplePageSequence_h___
 
 #include "mozilla/Attributes.h"
 #include "nsIPageSequenceFrame.h"
 #include "nsContainerFrame.h"
 #include "nsIPrintSettings.h"
 #include "nsIPrintOptions.h"
 #include "nsIDateTimeFormat.h"
-#include "nsHTMLCanvasElement.h"
+#include "mozilla/dom/HTMLCanvasElement.h"
 
 //-----------------------------------------------
 // This class maintains all the data that 
 // is used by all the page frame
 // It lives while the nsSimplePageSequenceFrame lives
 class nsSharedPageData {
 public:
   nsSharedPageData();
@@ -130,17 +130,17 @@ protected:
   // Asynch Printing
   nsIFrame *   mCurrentPageFrame;
   int32_t      mPageNum;
   int32_t      mTotalPages;
   int32_t      mPrintRangeType;
   int32_t      mFromPageNum;
   int32_t      mToPageNum;
   nsTArray<int32_t> mPageRanges;
-  nsTArray<nsRefPtr<nsHTMLCanvasElement> > mCurrentCanvasList;
+  nsTArray<nsRefPtr<mozilla::dom::HTMLCanvasElement> > mCurrentCanvasList;
 
   // Selection Printing Info
   nscoord      mSelectionHeight;
   nscoord      mYSelOffset;
 
   // Asynch Printing
   bool mPrintThisPage;
   bool mDoingPageRange;
--- a/layout/printing/nsPrintEngine.h
+++ b/layout/printing/nsPrintEngine.h
@@ -9,17 +9,17 @@
 
 #include "nsCOMPtr.h"
 
 #include "nsPrintObject.h"
 #include "nsPrintData.h"
 #include "nsFrameList.h"
 #include "mozilla/Attributes.h"
 #include "nsIWebProgress.h"
-#include "nsHTMLCanvasElement.h"
+#include "mozilla/dom/HTMLCanvasElement.h"
 #include "nsIWebProgressListener.h"
 #include "nsWeakReference.h"
 
 // Interfaces
 #include "nsIDocument.h"
 #include "nsIDOMWindow.h"
 #include "nsIObserver.h"