Bug 836176: Add nsIDocument::AsHTMLDocument r=bz
authorDavid Zbarsky <dzbarsky@gmail.com>
Wed, 30 Jan 2013 01:31:11 -0500
changeset 120338 1412c8db2f22d1509f26e8632a3a9c6e105150b5
parent 120337 6c7188fd196252d6ec97406a6cd7e89877d40533
child 120339 8cbed30d66fc65ad684cd5949247b52e5dd8f4e7
push id24246
push userryanvm@gmail.com
push dateWed, 30 Jan 2013 13:05:37 +0000
treeherdermozilla-central@5f9775715519 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs836176
milestone21.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 836176: Add nsIDocument::AsHTMLDocument r=bz
content/base/public/nsIDocument.h
content/base/src/nsDocument.cpp
--- a/content/base/public/nsIDocument.h
+++ b/content/base/public/nsIDocument.h
@@ -29,16 +29,17 @@
 class imgIRequest;
 class nsAString;
 class nsBindingManager;
 class nsCSSStyleSheet;
 class nsDOMNavigationTiming;
 class nsEventStates;
 class nsFrameLoader;
 class nsHTMLCSSStyleSheet;
+class nsHTMLDocument;
 class nsHTMLStyleSheet;
 class nsIAtom;
 class nsIBFCacheEntry;
 class nsIBoxObject;
 class nsIChannel;
 class nsIContent;
 class nsIContentSink;
 class nsIDocShell;
@@ -1969,16 +1970,18 @@ public:
                 float aRotationAngle, float aForce);
   already_AddRefed<nsIDOMTouchList> CreateTouchList();
   already_AddRefed<nsIDOMTouchList>
     CreateTouchList(nsIDOMTouch* aTouch,
                     const mozilla::dom::Sequence<nsRefPtr<nsIDOMTouch> >& aTouches);
   already_AddRefed<nsIDOMTouchList>
     CreateTouchList(const mozilla::dom::Sequence<nsRefPtr<nsIDOMTouch> >& aTouches);
 
+  nsHTMLDocument* AsHTMLDocument();
+
 private:
   uint64_t mWarnedAbout;
 
 protected:
   ~nsIDocument();
   nsPropertyTable* GetExtraPropertyTable(uint16_t aCategory);
 
   // Never ever call this. Only call GetWindow!
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -1845,16 +1845,22 @@ nsDocument::Init()
   mScriptLoader = new nsScriptLoader(this);
 
   mImageTracker.Init();
   mPlugins.Init();
 
   return NS_OK;
 }
 
+nsHTMLDocument*
+nsIDocument::AsHTMLDocument()
+{
+  return IsHTML() ? static_cast<nsHTMLDocument*>(this) : nullptr;
+}
+
 void
 nsIDocument::DeleteAllProperties()
 {
   for (uint32_t i = 0; i < GetPropertyTableCount(); ++i) {
     PropertyTable(i)->DeleteAllProperties();
   }
 }