Implementing nsHTMLObjectElement::GetContentDocument, patch by adu@sparc.spb.su bug 36240 r=peterl sr=jst

This commit is contained in:
peterlubczynski%netscape.com 2002-02-21 02:01:12 +00:00
parent 1d1a9ed4e4
commit edc2bd61e5
2 changed files with 56 additions and 0 deletions

View File

@ -41,6 +41,10 @@
#include "nsStyleConsts.h"
#include "nsDOMError.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsIDOMDocument.h"
#include "nsIWebNavigation.h"
class nsHTMLObjectElement : public nsGenericHTMLContainerElement,
public nsIDOMHTMLObjectElement
@ -183,8 +187,32 @@ NS_IMETHODIMP
nsHTMLObjectElement::GetContentDocument(nsIDOMDocument** aContentDocument)
{
NS_ENSURE_ARG_POINTER(aContentDocument);
*aContentDocument = nsnull;
NS_ENSURE_TRUE(mDocument, NS_OK);
nsCOMPtr<nsIPresShell> presShell;
mDocument->GetShellAt(0, getter_AddRefs(presShell));
NS_ENSURE_TRUE(presShell, NS_OK);
nsCOMPtr<nsISupports> tmp;
presShell->GetSubShellFor(this, getter_AddRefs(tmp));
if (!tmp) return NS_OK;
nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(tmp);
NS_ENSURE_TRUE(webNav, NS_OK);
nsCOMPtr<nsIDOMDocument> domDoc;
webNav->GetDocument(getter_AddRefs(domDoc));
*aContentDocument = domDoc;
NS_IF_ADDREF(*aContentDocument);
return NS_OK;
}

View File

@ -41,6 +41,10 @@
#include "nsStyleConsts.h"
#include "nsDOMError.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsIDOMDocument.h"
#include "nsIWebNavigation.h"
class nsHTMLObjectElement : public nsGenericHTMLContainerElement,
public nsIDOMHTMLObjectElement
@ -183,8 +187,32 @@ NS_IMETHODIMP
nsHTMLObjectElement::GetContentDocument(nsIDOMDocument** aContentDocument)
{
NS_ENSURE_ARG_POINTER(aContentDocument);
*aContentDocument = nsnull;
NS_ENSURE_TRUE(mDocument, NS_OK);
nsCOMPtr<nsIPresShell> presShell;
mDocument->GetShellAt(0, getter_AddRefs(presShell));
NS_ENSURE_TRUE(presShell, NS_OK);
nsCOMPtr<nsISupports> tmp;
presShell->GetSubShellFor(this, getter_AddRefs(tmp));
if (!tmp) return NS_OK;
nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(tmp);
NS_ENSURE_TRUE(webNav, NS_OK);
nsCOMPtr<nsIDOMDocument> domDoc;
webNav->GetDocument(getter_AddRefs(domDoc));
*aContentDocument = domDoc;
NS_IF_ADDREF(*aContentDocument);
return NS_OK;
}