Bug 678465 - 'document-element-inserted' doesn't fire on ImageDocument; r=bz

This commit is contained in:
Gabor Krizsanits
2011-12-15 15:10:36 +00:00
parent cedc6b6c10
commit d1e1ae9f59
7 changed files with 85 additions and 19 deletions

View File

@@ -363,7 +363,7 @@ ImageDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject)
// Set the script global object on the superclass before doing
// anything that might require it....
nsHTMLDocument::SetScriptGlobalObject(aScriptGlobalObject);
MediaDocument::SetScriptGlobalObject(aScriptGlobalObject);
if (aScriptGlobalObject) {
if (!GetRootElement()) {

View File

@@ -51,6 +51,7 @@
#include "nsIParser.h" // kCharsetFrom* macro definition
#include "nsIDocumentCharsetInfo.h"
#include "nsNodeInfoManager.h"
#include "nsContentUtils.h"
namespace mozilla {
namespace dom {
@@ -130,6 +131,7 @@ const char* const MediaDocument::sFormatNames[4] =
};
MediaDocument::MediaDocument()
: mDocumentElementInserted(false)
{
}
MediaDocument::~MediaDocument()
@@ -433,5 +435,16 @@ MediaDocument::UpdateTitleAndCharset(const nsACString& aTypeStr,
}
}
void
MediaDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject)
{
nsHTMLDocument::SetScriptGlobalObject(aGlobalObject);
if (!mDocumentElementInserted && aGlobalObject) {
mDocumentElementInserted = true;
nsContentUtils::AddScriptRunner(
new nsDocElementCreatedNotificationRunner(this));
}
}
} // namespace dom
} // namespace mozilla

View File

@@ -64,6 +64,8 @@ public:
bool aReset = true,
nsIContentSink* aSink = nsnull);
virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject);
protected:
virtual nsresult CreateSyntheticDocument();
@@ -93,9 +95,10 @@ protected:
nsCOMPtr<nsIStringBundle> mStringBundle;
static const char* const sFormatNames[4];
private:
enum {eWithNoInfo, eWithFile, eWithDim, eWithDimAndFile};
bool mDocumentElementInserted;
};