Bug 820170 - documents should know their globals. r=smaug

This commit is contained in:
Gabor Krizsanits 2013-04-04 11:32:29 +02:00
Родитель 2e8e9ba1de
Коммит e18caa1c32
6 изменённых файлов: 15 добавлений и 10 удалений

Просмотреть файл

@ -2515,7 +2515,7 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
nsIURI* aBaseURI,
nsIPrincipal* aPrincipal,
bool aLoadedAsData,
nsIScriptGlobalObject* aEventObject,
nsIGlobalObject* aEventObject,
DocumentFlavor aFlavor);
// This is used only for xbl documents created from the startup cache.

Просмотреть файл

@ -114,7 +114,7 @@ DOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
}
}
nsCOMPtr<nsIScriptGlobalObject> scriptHandlingObject =
nsCOMPtr<nsIGlobalObject> scriptHandlingObject =
do_QueryReferent(mScriptObject);
NS_ENSURE_STATE(!mScriptObject || scriptHandlingObject);
@ -182,7 +182,7 @@ DOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIScriptGlobalObject> scriptHandlingObject =
nsCOMPtr<nsIGlobalObject> scriptHandlingObject =
do_QueryReferent(mScriptObject);
NS_ENSURE_STATE(!mScriptObject || scriptHandlingObject);

Просмотреть файл

@ -29,7 +29,7 @@ class DOMImplementation MOZ_FINAL : public nsIDOMDOMImplementation
{
public:
DOMImplementation(nsIDocument* aOwner,
nsIScriptGlobalObject* aScriptObject,
nsIGlobalObject* aScriptObject,
nsIURI* aDocumentURI,
nsIURI* aBaseURI)
: mOwner(aOwner)

Просмотреть файл

@ -4177,8 +4177,8 @@ nsDocument::SetScriptHandlingObject(nsIScriptGlobalObject* aScriptObject)
"Wrong script object!");
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aScriptObject);
NS_ASSERTION(!win || win->IsInnerWindow(), "Should have inner window here!");
mScopeObject = do_GetWeakReference(aScriptObject);
if (aScriptObject) {
mScopeObject = do_GetWeakReference(aScriptObject);
mHasHadScriptHandlingObject = true;
mHasHadDefaultView = false;
}
@ -4647,7 +4647,8 @@ nsDocument::GetImplementation(ErrorResult& rv)
rv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
mDOMImplementation = new DOMImplementation(this, scriptObject, uri, uri);
mDOMImplementation = new DOMImplementation(this,
scriptObject ? scriptObject : GetScopeObject(), uri, uri);
}
return mDOMImplementation;

Просмотреть файл

@ -2000,8 +2000,8 @@ nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
// principal, so use mPrincipal when creating the document, then reset the
// principal.
const nsAString& emptyStr = EmptyString();
nsCOMPtr<nsIScriptGlobalObject> global = do_QueryInterface(GetOwner());
nsCOMPtr<nsIDOMDocument> responseDoc;
nsIGlobalObject* global = nsDOMEventTargetHelper::GetParentObject();
rv = NS_NewDOMDocument(getter_AddRefs(responseDoc),
emptyStr, emptyStr, nullptr, docURI,
baseURI, mPrincipal, true, global,

Просмотреть файл

@ -71,7 +71,7 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
nsIURI* aBaseURI,
nsIPrincipal* aPrincipal,
bool aLoadedAsData,
nsIScriptGlobalObject* aEventObject,
nsIGlobalObject* aEventObject,
DocumentFlavor aFlavor)
{
// Note: can't require that aDocumentURI/aBaseURI/aPrincipal be non-null,
@ -127,8 +127,12 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
return rv;
}
d->SetScriptHandlingObject(aEventObject);
if (nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aEventObject)) {
d->SetScriptHandlingObject(sgo);
} else if (aEventObject){
d->SetScopeObject(aEventObject);
}
if (isHTML) {
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(d);
NS_ASSERTION(htmlDoc, "HTML Document doesn't implement nsIHTMLDocument?");