зеркало из https://github.com/mozilla/gecko-dev.git
Bug 820170 - documents should know their globals. r=smaug
This commit is contained in:
Родитель
2e8e9ba1de
Коммит
e18caa1c32
|
@ -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?");
|
||||
|
|
Загрузка…
Ссылка в новой задаче