Don't go through presshells to get to our window; just use the global object.

This fixes various issues that could bite display:none iframes, in particular
bug 262998.  r+sr=jst
This commit is contained in:
bzbarsky%mit.edu 2004-10-06 20:24:18 +00:00
Родитель a383838588
Коммит 4925781bb0
2 изменённых файлов: 6 добавлений и 43 удалений

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

@ -2793,25 +2793,11 @@ nsDocument::CreateTreeWalker(nsIDOMNode *aRoot,
NS_IMETHODIMP
nsDocument::GetDefaultView(nsIDOMAbstractView** aDefaultView)
{
NS_ENSURE_ARG_POINTER(aDefaultView);
if (mScriptGlobalObject) {
return CallQueryInterface(mScriptGlobalObject, aDefaultView);
}
*aDefaultView = nsnull;
NS_ENSURE_TRUE(mPresShells.Count() != 0, NS_OK);
nsCOMPtr<nsIPresShell> shell = NS_STATIC_CAST(nsIPresShell *,
mPresShells.ElementAt(0));
NS_ENSURE_TRUE(shell, NS_OK);
nsPresContext *ctx = shell->GetPresContext();
NS_ENSURE_TRUE(ctx, NS_OK);
nsCOMPtr<nsISupports> container = ctx->GetContainer();
NS_ENSURE_TRUE(container, NS_OK);
nsCOMPtr<nsIDOMWindowInternal> window = do_GetInterface(container);
NS_ENSURE_TRUE(window, NS_OK);
CallQueryInterface(window, aDefaultView);
return NS_OK;
}

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

@ -2778,19 +2778,7 @@ nsHTMLDocument::GetSelection(nsAString& aReturn)
consoleService->LogStringMessage(NS_LITERAL_STRING("Deprecated method document.getSelection() called. Please use window.getSelection() instead.").get());
}
nsCOMPtr<nsIPresShell> shell = (nsIPresShell*)mPresShells.SafeElementAt(0);
if (!shell) {
return NS_OK;
}
nsPresContext *cx = shell->GetPresContext();
NS_ENSURE_TRUE(cx, NS_OK);
nsCOMPtr<nsISupports> container = cx->GetContainer();
NS_ENSURE_TRUE(container, NS_OK);
nsCOMPtr<nsIDOMWindow> window(do_GetInterface(container));
nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(mScriptGlobalObject));
NS_ENSURE_TRUE(window, NS_OK);
nsCOMPtr<nsISelection> selection;
@ -3531,18 +3519,7 @@ nsHTMLDocument::SetDesignMode(const nsAString & aDesignMode)
return NS_ERROR_FAILURE;
if (aDesignMode.LowerCaseEqualsLiteral("on")) {
// go through hoops to get dom window (see nsHTMLDocument::GetSelection)
nsCOMPtr<nsIPresShell> shell = (nsIPresShell*)mPresShells.SafeElementAt(0);
NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE);
nsPresContext *cx = shell->GetPresContext();
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
nsCOMPtr<nsISupports> container = cx->GetContainer();
NS_ENSURE_TRUE(container, NS_OK);
// get content root frame
nsCOMPtr<nsIDOMWindow> domwindow(do_GetInterface(container));
nsCOMPtr<nsIDOMWindow> domwindow(do_QueryInterface(mScriptGlobalObject));
NS_ENSURE_TRUE(domwindow, NS_ERROR_FAILURE);
rv = editSession->MakeWindowEditable(domwindow, "html", PR_FALSE);