Bug 1017424 part 2. Rip out code in nsGlobalWindow that handles the window being on non-WebIDL bindings. r=peterv

This commit is contained in:
Boris Zbarsky 2014-09-05 14:28:44 -04:00
parent a55fbb463f
commit 0c9df8954c

View File

@ -2282,22 +2282,10 @@ CreateNativeGlobalForInner(JSContext* aCx,
uint32_t flags = needComponents ? 0 : nsIXPConnect::OMIT_COMPONENTS_OBJECT;
flags |= nsIXPConnect::DONT_FIRE_ONNEWGLOBALHOOK;
if (aNewInner->IsDOMBinding()) {
aGlobal.set(WindowBinding::Wrap(aCx, aNewInner, aNewInner, options,
nsJSPrincipals::get(aPrincipal), false));
if (!aGlobal || !xpc::InitGlobalObject(aCx, aGlobal, flags)) {
return NS_ERROR_FAILURE;
}
} else {
nsIXPConnect* xpc = nsContentUtils::XPConnect();
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
nsresult rv = xpc->InitClassesWithNewWrappedGlobal(
aCx, ToSupports(aNewInner),
aPrincipal, flags, options, getter_AddRefs(holder));
NS_ENSURE_SUCCESS(rv, rv);
aGlobal.set(holder->GetJSObject());
MOZ_ASSERT(aGlobal);
aGlobal.set(WindowBinding::Wrap(aCx, aNewInner, aNewInner, options,
nsJSPrincipals::get(aPrincipal), false));
if (!aGlobal || !xpc::InitGlobalObject(aCx, aGlobal, flags)) {
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(aNewInner->GetWrapperPreserveColor() == aGlobal);
@ -2400,7 +2388,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
// having to *always* reach into the inner window to find the
// document.
mDoc = aDocument;
if (IsInnerWindow() && IsDOMBinding()) {
if (IsInnerWindow()) {
WindowBinding::ClearCachedDocumentValue(cx, this);
}
@ -2608,21 +2596,10 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
// If we created a new inner window above, we need to do the last little bit
// of initialization now that the dust has settled.
if (createdInnerWindow) {
if (newInnerWindow->IsDOMBinding()) {
JS::Rooted<JSObject*> global(cx, newInnerGlobal);
JS::Rooted<JSObject*> proto(cx);
JS_GetPrototype(cx, global, &proto);
WindowNamedPropertiesHandler::Install(cx, proto);
} else {
nsIXPConnect *xpc = nsContentUtils::XPConnect();
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
nsresult rv = xpc->GetWrappedNativeOfJSObject(cx, newInnerGlobal,
getter_AddRefs(wrapper));
NS_ENSURE_SUCCESS(rv, rv);
NS_ABORT_IF_FALSE(wrapper, "bad wrapper");
rv = wrapper->FinishInitForWrappedGlobal();
NS_ENSURE_SUCCESS(rv, rv);
}
JS::Rooted<JSObject*> global(cx, newInnerGlobal);
JS::Rooted<JSObject*> proto(cx);
JS_GetPrototype(cx, global, &proto);
WindowNamedPropertiesHandler::Install(cx, proto);
}
if (!aState) {
@ -2679,17 +2656,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
newInnerWindow->mLocalStorage = nullptr;
newInnerWindow->mSessionStorage = nullptr;
if (newInnerWindow->IsDOMBinding()) {
WindowBinding::ClearCachedDocumentValue(cx, newInnerWindow);
} else {
// We're reusing the inner window for a new document. In this
// case we don't clear the inner window's scope, but we must
// make sure the cached document property gets updated.
JS::Rooted<JSObject*> obj(cx,
currentInner->GetWrapperPreserveColor());
::JS_DeleteProperty(cx, obj, "document");
}
WindowBinding::ClearCachedDocumentValue(cx, newInnerWindow);
}
} else {
newInnerWindow->InnerSetNewDocument(cx, aDocument);
@ -2831,9 +2798,7 @@ nsGlobalWindow::InnerSetNewDocument(JSContext* aCx, nsIDocument* aDocument)
#endif
mDoc = aDocument;
if (IsDOMBinding()) {
WindowBinding::ClearCachedDocumentValue(aCx, this);
}
WindowBinding::ClearCachedDocumentValue(aCx, this);
mFocusedNode = nullptr;
mLocalStorage = nullptr;
mSessionStorage = nullptr;