From 3efeaf17d37d17be4f581cff252084b2cdcc76c3 Mon Sep 17 00:00:00 2001 From: "jst%netscape.com" Date: Sun, 2 Apr 2000 14:04:19 +0000 Subject: [PATCH] Updating HTMLFrameElement and HTMLIFrameElement to comply with the Level 2 DOM, this adds a 'contentDocument' attribute to those two interfaces that can be used to access the document contained in the frame. git-svn-id: svn://10.0.0.236/trunk@64937 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/content/src/nsHTMLFrameElement.cpp | 47 +++++++++++++++++++ .../html/content/src/nsHTMLIFrameElement.cpp | 47 +++++++++++++++++++ .../dom/public/html/nsIDOMHTMLFrameElement.h | 8 ++++ .../dom/public/html/nsIDOMHTMLIFrameElement.h | 8 ++++ .../dom/public/idl/html/HTMLFrameElement.idl | 2 + .../dom/public/idl/html/HTMLIFrameElement.idl | 2 + mozilla/dom/public/nsDOMPropEnums.h | 2 + mozilla/dom/public/nsDOMPropNames.h | 2 + mozilla/dom/src/html/nsJSHTMLFrameElement.cpp | 35 +++++++++++++- .../dom/src/html/nsJSHTMLIFrameElement.cpp | 35 +++++++++++++- .../html/content/src/nsHTMLFrameElement.cpp | 47 +++++++++++++++++++ .../html/content/src/nsHTMLIFrameElement.cpp | 47 +++++++++++++++++++ 12 files changed, 280 insertions(+), 2 deletions(-) diff --git a/mozilla/content/html/content/src/nsHTMLFrameElement.cpp b/mozilla/content/html/content/src/nsHTMLFrameElement.cpp index ddc374e61de..c92c044561c 100644 --- a/mozilla/content/html/content/src/nsHTMLFrameElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLFrameElement.cpp @@ -30,7 +30,12 @@ #include "nsIMutableStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" +#include "nsIPresShell.h" +#include "nsIDocument.h" +#include "nsIDOMDocument.h" +#include "nsIWebNavigation.h" #include "nsIChromeEventHandler.h" +#include "nsDOMError.h" static NS_DEFINE_IID(kIDOMHTMLFrameElementIID, NS_IDOMHTMLFRAMEELEMENT_IID); @@ -72,6 +77,8 @@ public: NS_IMETHOD SetScrolling(const nsString& aScrolling); NS_IMETHOD GetSrc(nsString& aSrc); NS_IMETHOD SetSrc(const nsString& aSrc); + NS_IMETHOD GetContentDocument(nsIDOMDocument** aContentDocument); + NS_IMETHOD SetContentDocument(nsIDOMDocument* aContentDocument); // nsIJSScriptObject NS_IMPL_IJSSCRIPTOBJECT_USING_GENERIC(mInner) @@ -156,6 +163,46 @@ NS_IMPL_BOOL_ATTR(nsHTMLFrameElement, NoResize, noresize) NS_IMPL_STRING_ATTR(nsHTMLFrameElement, Scrolling, scrolling) NS_IMPL_STRING_ATTR(nsHTMLFrameElement, Src, src) + +NS_IMETHODIMP +nsHTMLFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument) +{ + NS_ENSURE_ARG_POINTER(aContentDocument); + + *aContentDocument = nsnull; + + NS_ENSURE_TRUE(mInner.mDocument, NS_OK); + + nsCOMPtr presShell; + + presShell = dont_AddRef(mInner.mDocument->GetShellAt(0)); + NS_ENSURE_TRUE(presShell, NS_OK); + + nsCOMPtr tmp; + + presShell->GetSubShellFor(this, getter_AddRefs(tmp)); + NS_ENSURE_TRUE(tmp, NS_OK); + + nsCOMPtr webNav = do_QueryInterface(tmp); + NS_ENSURE_TRUE(webNav, NS_OK); + + nsCOMPtr domDoc; + + webNav->GetDocument(getter_AddRefs(domDoc)); + + *aContentDocument = domDoc; + + NS_IF_ADDREF(*aContentDocument); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLFrameElement::SetContentDocument(nsIDOMDocument* aContentDocument) +{ + return NS_ERROR_DOM_INVALID_MODIFICATION_ERR; +} + NS_IMETHODIMP nsHTMLFrameElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, diff --git a/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp b/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp index 840ed22be26..209d51e8cb4 100644 --- a/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp @@ -30,8 +30,13 @@ #include "nsIMutableStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" +#include "nsIPresShell.h" +#include "nsIDocument.h" +#include "nsIDOMDocument.h" +#include "nsIWebNavigation.h" #include "nsIHTMLAttributes.h" #include "nsIChromeEventHandler.h" +#include "nsDOMError.h" static NS_DEFINE_IID(kIDOMHTMLIFrameElementIID, NS_IDOMHTMLIFRAMEELEMENT_IID); @@ -77,6 +82,8 @@ public: NS_IMETHOD SetSrc(const nsString& aSrc); NS_IMETHOD GetWidth(nsString& aWidth); NS_IMETHOD SetWidth(const nsString& aWidth); + NS_IMETHOD GetContentDocument(nsIDOMDocument** aContentDocument); + NS_IMETHOD SetContentDocument(nsIDOMDocument* aContentDocument); // nsIJSScriptObject NS_IMPL_IJSSCRIPTOBJECT_USING_GENERIC(mInner) @@ -163,6 +170,46 @@ NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Scrolling, scrolling) NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Src, src) NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Width, width) + +NS_IMETHODIMP +nsHTMLIFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument) +{ + NS_ENSURE_ARG_POINTER(aContentDocument); + + *aContentDocument = nsnull; + + NS_ENSURE_TRUE(mInner.mDocument, NS_OK); + + nsCOMPtr presShell; + + presShell = dont_AddRef(mInner.mDocument->GetShellAt(0)); + NS_ENSURE_TRUE(presShell, NS_OK); + + nsCOMPtr tmp; + + presShell->GetSubShellFor(this, getter_AddRefs(tmp)); + NS_ENSURE_TRUE(tmp, NS_OK); + + nsCOMPtr webNav = do_QueryInterface(tmp); + NS_ENSURE_TRUE(webNav, NS_OK); + + nsCOMPtr domDoc; + + webNav->GetDocument(getter_AddRefs(domDoc)); + + *aContentDocument = domDoc; + + NS_IF_ADDREF(*aContentDocument); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLIFrameElement::SetContentDocument(nsIDOMDocument* aContentDocument) +{ + return NS_ERROR_DOM_INVALID_MODIFICATION_ERR; +} + NS_IMETHODIMP nsHTMLIFrameElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, diff --git a/mozilla/dom/public/html/nsIDOMHTMLFrameElement.h b/mozilla/dom/public/html/nsIDOMHTMLFrameElement.h index 8c6dafca695..cade524c1ab 100644 --- a/mozilla/dom/public/html/nsIDOMHTMLFrameElement.h +++ b/mozilla/dom/public/html/nsIDOMHTMLFrameElement.h @@ -29,6 +29,7 @@ #include "nsIScriptContext.h" #include "nsIDOMHTMLElement.h" +class nsIDOMDocument; #define NS_IDOMHTMLFRAMEELEMENT_IID \ { 0xa6cf90b9, 0x15b3, 0x11d2, \ @@ -61,6 +62,9 @@ public: NS_IMETHOD GetSrc(nsString& aSrc)=0; NS_IMETHOD SetSrc(const nsString& aSrc)=0; + + NS_IMETHOD GetContentDocument(nsIDOMDocument** aContentDocument)=0; + NS_IMETHOD SetContentDocument(nsIDOMDocument* aContentDocument)=0; }; @@ -81,6 +85,8 @@ public: NS_IMETHOD SetScrolling(const nsString& aScrolling); \ NS_IMETHOD GetSrc(nsString& aSrc); \ NS_IMETHOD SetSrc(const nsString& aSrc); \ + NS_IMETHOD GetContentDocument(nsIDOMDocument** aContentDocument); \ + NS_IMETHOD SetContentDocument(nsIDOMDocument* aContentDocument); \ @@ -101,6 +107,8 @@ public: NS_IMETHOD SetScrolling(const nsString& aScrolling) { return _to SetScrolling(aScrolling); } \ NS_IMETHOD GetSrc(nsString& aSrc) { return _to GetSrc(aSrc); } \ NS_IMETHOD SetSrc(const nsString& aSrc) { return _to SetSrc(aSrc); } \ + NS_IMETHOD GetContentDocument(nsIDOMDocument** aContentDocument) { return _to GetContentDocument(aContentDocument); } \ + NS_IMETHOD SetContentDocument(nsIDOMDocument* aContentDocument) { return _to SetContentDocument(aContentDocument); } \ extern "C" NS_DOM nsresult NS_InitHTMLFrameElementClass(nsIScriptContext *aContext, void **aPrototype); diff --git a/mozilla/dom/public/html/nsIDOMHTMLIFrameElement.h b/mozilla/dom/public/html/nsIDOMHTMLIFrameElement.h index 324a1660974..6d8bd97641f 100644 --- a/mozilla/dom/public/html/nsIDOMHTMLIFrameElement.h +++ b/mozilla/dom/public/html/nsIDOMHTMLIFrameElement.h @@ -29,6 +29,7 @@ #include "nsIScriptContext.h" #include "nsIDOMHTMLElement.h" +class nsIDOMDocument; #define NS_IDOMHTMLIFRAMEELEMENT_IID \ { 0xa6cf90ba, 0x15b3, 0x11d2, \ @@ -67,6 +68,9 @@ public: NS_IMETHOD GetWidth(nsString& aWidth)=0; NS_IMETHOD SetWidth(const nsString& aWidth)=0; + + NS_IMETHOD GetContentDocument(nsIDOMDocument** aContentDocument)=0; + NS_IMETHOD SetContentDocument(nsIDOMDocument* aContentDocument)=0; }; @@ -91,6 +95,8 @@ public: NS_IMETHOD SetSrc(const nsString& aSrc); \ NS_IMETHOD GetWidth(nsString& aWidth); \ NS_IMETHOD SetWidth(const nsString& aWidth); \ + NS_IMETHOD GetContentDocument(nsIDOMDocument** aContentDocument); \ + NS_IMETHOD SetContentDocument(nsIDOMDocument* aContentDocument); \ @@ -115,6 +121,8 @@ public: NS_IMETHOD SetSrc(const nsString& aSrc) { return _to SetSrc(aSrc); } \ NS_IMETHOD GetWidth(nsString& aWidth) { return _to GetWidth(aWidth); } \ NS_IMETHOD SetWidth(const nsString& aWidth) { return _to SetWidth(aWidth); } \ + NS_IMETHOD GetContentDocument(nsIDOMDocument** aContentDocument) { return _to GetContentDocument(aContentDocument); } \ + NS_IMETHOD SetContentDocument(nsIDOMDocument* aContentDocument) { return _to SetContentDocument(aContentDocument); } \ extern "C" NS_DOM nsresult NS_InitHTMLIFrameElementClass(nsIScriptContext *aContext, void **aPrototype); diff --git a/mozilla/dom/public/idl/html/HTMLFrameElement.idl b/mozilla/dom/public/idl/html/HTMLFrameElement.idl index 3c749673e0b..bd28d13fbea 100644 --- a/mozilla/dom/public/idl/html/HTMLFrameElement.idl +++ b/mozilla/dom/public/idl/html/HTMLFrameElement.idl @@ -10,4 +10,6 @@ attribute boolean noResize; attribute DOMString scrolling; attribute DOMString src; + // Introduced in DOM Level 2: + attribute Document contentDocument; }; diff --git a/mozilla/dom/public/idl/html/HTMLIFrameElement.idl b/mozilla/dom/public/idl/html/HTMLIFrameElement.idl index 45d8f1af374..a36da1a5530 100644 --- a/mozilla/dom/public/idl/html/HTMLIFrameElement.idl +++ b/mozilla/dom/public/idl/html/HTMLIFrameElement.idl @@ -12,4 +12,6 @@ attribute DOMString scrolling; attribute DOMString src; attribute DOMString width; + // Introduced in DOM Level 2: + attribute Document contentDocument; }; diff --git a/mozilla/dom/public/nsDOMPropEnums.h b/mozilla/dom/public/nsDOMPropEnums.h index cf94de12b54..8135ad2cce1 100644 --- a/mozilla/dom/public/nsDOMPropEnums.h +++ b/mozilla/dom/public/nsDOMPropEnums.h @@ -367,6 +367,7 @@ enum nsDOMProp { NS_DOM_PROP_HTMLFORMELEMENT_RESET, NS_DOM_PROP_HTMLFORMELEMENT_SUBMIT, NS_DOM_PROP_HTMLFORMELEMENT_TARGET, + NS_DOM_PROP_HTMLFRAMEELEMENT_CONTENTDOCUMENT, NS_DOM_PROP_HTMLFRAMEELEMENT_FRAMEBORDER, NS_DOM_PROP_HTMLFRAMEELEMENT_LONGDESC, NS_DOM_PROP_HTMLFRAMEELEMENT_MARGINHEIGHT, @@ -385,6 +386,7 @@ enum nsDOMProp { NS_DOM_PROP_HTMLHRELEMENT_WIDTH, NS_DOM_PROP_HTMLHTMLELEMENT_VERSION, NS_DOM_PROP_HTMLIFRAMEELEMENT_ALIGN, + NS_DOM_PROP_HTMLIFRAMEELEMENT_CONTENTDOCUMENT, NS_DOM_PROP_HTMLIFRAMEELEMENT_FRAMEBORDER, NS_DOM_PROP_HTMLIFRAMEELEMENT_HEIGHT, NS_DOM_PROP_HTMLIFRAMEELEMENT_LONGDESC, diff --git a/mozilla/dom/public/nsDOMPropNames.h b/mozilla/dom/public/nsDOMPropNames.h index 3ce0844ab82..4fae402b968 100644 --- a/mozilla/dom/public/nsDOMPropNames.h +++ b/mozilla/dom/public/nsDOMPropNames.h @@ -366,6 +366,7 @@ "htmlformelement.reset", \ "htmlformelement.submit", \ "htmlformelement.target", \ + "htmlframeelement.contentdocument", \ "htmlframeelement.frameborder", \ "htmlframeelement.longdesc", \ "htmlframeelement.marginheight", \ @@ -384,6 +385,7 @@ "htmlhrelement.width", \ "htmlhtmlelement.version", \ "htmliframeelement.align", \ + "htmliframeelement.contentdocument", \ "htmliframeelement.frameborder", \ "htmliframeelement.height", \ "htmliframeelement.longdesc", \ diff --git a/mozilla/dom/src/html/nsJSHTMLFrameElement.cpp b/mozilla/dom/src/html/nsJSHTMLFrameElement.cpp index bb616cd4f99..56cd9e32742 100644 --- a/mozilla/dom/src/html/nsJSHTMLFrameElement.cpp +++ b/mozilla/dom/src/html/nsJSHTMLFrameElement.cpp @@ -34,12 +34,14 @@ #include "nsCOMPtr.h" #include "nsDOMPropEnums.h" #include "nsString.h" +#include "nsIDOMDocument.h" #include "nsIDOMHTMLFrameElement.h" static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID); static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID); +static NS_DEFINE_IID(kIDocumentIID, NS_IDOMDOCUMENT_IID); static NS_DEFINE_IID(kIHTMLFrameElementIID, NS_IDOMHTMLFRAMEELEMENT_IID); // @@ -53,7 +55,8 @@ enum HTMLFrameElement_slots { HTMLFRAMEELEMENT_NAME = -5, HTMLFRAMEELEMENT_NORESIZE = -6, HTMLFRAMEELEMENT_SCROLLING = -7, - HTMLFRAMEELEMENT_SRC = -8 + HTMLFRAMEELEMENT_SRC = -8, + HTMLFRAMEELEMENT_CONTENTDOCUMENT = -9 }; /***********************************************************************/ @@ -172,6 +175,19 @@ GetHTMLFrameElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) } break; } + case HTMLFRAMEELEMENT_CONTENTDOCUMENT: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLFRAMEELEMENT_CONTENTDOCUMENT, PR_FALSE); + if (NS_SUCCEEDED(rv)) { + nsIDOMDocument* prop; + rv = a->GetContentDocument(&prop); + if (NS_SUCCEEDED(rv)) { + // get the js object + nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, obj, vp); + } + } + break; + } default: return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp); } @@ -303,6 +319,22 @@ SetHTMLFrameElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) } break; } + case HTMLFRAMEELEMENT_CONTENTDOCUMENT: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLFRAMEELEMENT_CONTENTDOCUMENT, PR_TRUE); + if (NS_SUCCEEDED(rv)) { + nsIDOMDocument* prop; + if (PR_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&prop, + kIDocumentIID, "Document", + cx, *vp)) { + rv = NS_ERROR_DOM_NOT_OBJECT_ERR; + } + + rv = a->SetContentDocument(prop); + NS_IF_RELEASE(prop); + } + break; + } default: return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp); } @@ -380,6 +412,7 @@ static JSPropertySpec HTMLFrameElementProperties[] = {"noResize", HTMLFRAMEELEMENT_NORESIZE, JSPROP_ENUMERATE}, {"scrolling", HTMLFRAMEELEMENT_SCROLLING, JSPROP_ENUMERATE}, {"src", HTMLFRAMEELEMENT_SRC, JSPROP_ENUMERATE}, + {"contentDocument", HTMLFRAMEELEMENT_CONTENTDOCUMENT, JSPROP_ENUMERATE}, {0} }; diff --git a/mozilla/dom/src/html/nsJSHTMLIFrameElement.cpp b/mozilla/dom/src/html/nsJSHTMLIFrameElement.cpp index 0c76b0cbb00..2536ddbeb8d 100644 --- a/mozilla/dom/src/html/nsJSHTMLIFrameElement.cpp +++ b/mozilla/dom/src/html/nsJSHTMLIFrameElement.cpp @@ -34,12 +34,14 @@ #include "nsCOMPtr.h" #include "nsDOMPropEnums.h" #include "nsString.h" +#include "nsIDOMDocument.h" #include "nsIDOMHTMLIFrameElement.h" static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID); static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID); +static NS_DEFINE_IID(kIDocumentIID, NS_IDOMDOCUMENT_IID); static NS_DEFINE_IID(kIHTMLIFrameElementIID, NS_IDOMHTMLIFRAMEELEMENT_IID); // @@ -55,7 +57,8 @@ enum HTMLIFrameElement_slots { HTMLIFRAMEELEMENT_NAME = -7, HTMLIFRAMEELEMENT_SCROLLING = -8, HTMLIFRAMEELEMENT_SRC = -9, - HTMLIFRAMEELEMENT_WIDTH = -10 + HTMLIFRAMEELEMENT_WIDTH = -10, + HTMLIFRAMEELEMENT_CONTENTDOCUMENT = -11 }; /***********************************************************************/ @@ -198,6 +201,19 @@ GetHTMLIFrameElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) } break; } + case HTMLIFRAMEELEMENT_CONTENTDOCUMENT: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLIFRAMEELEMENT_CONTENTDOCUMENT, PR_FALSE); + if (NS_SUCCEEDED(rv)) { + nsIDOMDocument* prop; + rv = a->GetContentDocument(&prop); + if (NS_SUCCEEDED(rv)) { + // get the js object + nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, obj, vp); + } + } + break; + } default: return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp); } @@ -351,6 +367,22 @@ SetHTMLIFrameElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) } break; } + case HTMLIFRAMEELEMENT_CONTENTDOCUMENT: + { + rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLIFRAMEELEMENT_CONTENTDOCUMENT, PR_TRUE); + if (NS_SUCCEEDED(rv)) { + nsIDOMDocument* prop; + if (PR_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&prop, + kIDocumentIID, "Document", + cx, *vp)) { + rv = NS_ERROR_DOM_NOT_OBJECT_ERR; + } + + rv = a->SetContentDocument(prop); + NS_IF_RELEASE(prop); + } + break; + } default: return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp); } @@ -430,6 +462,7 @@ static JSPropertySpec HTMLIFrameElementProperties[] = {"scrolling", HTMLIFRAMEELEMENT_SCROLLING, JSPROP_ENUMERATE}, {"src", HTMLIFRAMEELEMENT_SRC, JSPROP_ENUMERATE}, {"width", HTMLIFRAMEELEMENT_WIDTH, JSPROP_ENUMERATE}, + {"contentDocument", HTMLIFRAMEELEMENT_CONTENTDOCUMENT, JSPROP_ENUMERATE}, {0} }; diff --git a/mozilla/layout/html/content/src/nsHTMLFrameElement.cpp b/mozilla/layout/html/content/src/nsHTMLFrameElement.cpp index ddc374e61de..c92c044561c 100644 --- a/mozilla/layout/html/content/src/nsHTMLFrameElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLFrameElement.cpp @@ -30,7 +30,12 @@ #include "nsIMutableStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" +#include "nsIPresShell.h" +#include "nsIDocument.h" +#include "nsIDOMDocument.h" +#include "nsIWebNavigation.h" #include "nsIChromeEventHandler.h" +#include "nsDOMError.h" static NS_DEFINE_IID(kIDOMHTMLFrameElementIID, NS_IDOMHTMLFRAMEELEMENT_IID); @@ -72,6 +77,8 @@ public: NS_IMETHOD SetScrolling(const nsString& aScrolling); NS_IMETHOD GetSrc(nsString& aSrc); NS_IMETHOD SetSrc(const nsString& aSrc); + NS_IMETHOD GetContentDocument(nsIDOMDocument** aContentDocument); + NS_IMETHOD SetContentDocument(nsIDOMDocument* aContentDocument); // nsIJSScriptObject NS_IMPL_IJSSCRIPTOBJECT_USING_GENERIC(mInner) @@ -156,6 +163,46 @@ NS_IMPL_BOOL_ATTR(nsHTMLFrameElement, NoResize, noresize) NS_IMPL_STRING_ATTR(nsHTMLFrameElement, Scrolling, scrolling) NS_IMPL_STRING_ATTR(nsHTMLFrameElement, Src, src) + +NS_IMETHODIMP +nsHTMLFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument) +{ + NS_ENSURE_ARG_POINTER(aContentDocument); + + *aContentDocument = nsnull; + + NS_ENSURE_TRUE(mInner.mDocument, NS_OK); + + nsCOMPtr presShell; + + presShell = dont_AddRef(mInner.mDocument->GetShellAt(0)); + NS_ENSURE_TRUE(presShell, NS_OK); + + nsCOMPtr tmp; + + presShell->GetSubShellFor(this, getter_AddRefs(tmp)); + NS_ENSURE_TRUE(tmp, NS_OK); + + nsCOMPtr webNav = do_QueryInterface(tmp); + NS_ENSURE_TRUE(webNav, NS_OK); + + nsCOMPtr domDoc; + + webNav->GetDocument(getter_AddRefs(domDoc)); + + *aContentDocument = domDoc; + + NS_IF_ADDREF(*aContentDocument); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLFrameElement::SetContentDocument(nsIDOMDocument* aContentDocument) +{ + return NS_ERROR_DOM_INVALID_MODIFICATION_ERR; +} + NS_IMETHODIMP nsHTMLFrameElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, diff --git a/mozilla/layout/html/content/src/nsHTMLIFrameElement.cpp b/mozilla/layout/html/content/src/nsHTMLIFrameElement.cpp index 840ed22be26..209d51e8cb4 100644 --- a/mozilla/layout/html/content/src/nsHTMLIFrameElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLIFrameElement.cpp @@ -30,8 +30,13 @@ #include "nsIMutableStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" +#include "nsIPresShell.h" +#include "nsIDocument.h" +#include "nsIDOMDocument.h" +#include "nsIWebNavigation.h" #include "nsIHTMLAttributes.h" #include "nsIChromeEventHandler.h" +#include "nsDOMError.h" static NS_DEFINE_IID(kIDOMHTMLIFrameElementIID, NS_IDOMHTMLIFRAMEELEMENT_IID); @@ -77,6 +82,8 @@ public: NS_IMETHOD SetSrc(const nsString& aSrc); NS_IMETHOD GetWidth(nsString& aWidth); NS_IMETHOD SetWidth(const nsString& aWidth); + NS_IMETHOD GetContentDocument(nsIDOMDocument** aContentDocument); + NS_IMETHOD SetContentDocument(nsIDOMDocument* aContentDocument); // nsIJSScriptObject NS_IMPL_IJSSCRIPTOBJECT_USING_GENERIC(mInner) @@ -163,6 +170,46 @@ NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Scrolling, scrolling) NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Src, src) NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Width, width) + +NS_IMETHODIMP +nsHTMLIFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument) +{ + NS_ENSURE_ARG_POINTER(aContentDocument); + + *aContentDocument = nsnull; + + NS_ENSURE_TRUE(mInner.mDocument, NS_OK); + + nsCOMPtr presShell; + + presShell = dont_AddRef(mInner.mDocument->GetShellAt(0)); + NS_ENSURE_TRUE(presShell, NS_OK); + + nsCOMPtr tmp; + + presShell->GetSubShellFor(this, getter_AddRefs(tmp)); + NS_ENSURE_TRUE(tmp, NS_OK); + + nsCOMPtr webNav = do_QueryInterface(tmp); + NS_ENSURE_TRUE(webNav, NS_OK); + + nsCOMPtr domDoc; + + webNav->GetDocument(getter_AddRefs(domDoc)); + + *aContentDocument = domDoc; + + NS_IF_ADDREF(*aContentDocument); + + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLIFrameElement::SetContentDocument(nsIDOMDocument* aContentDocument) +{ + return NS_ERROR_DOM_INVALID_MODIFICATION_ERR; +} + NS_IMETHODIMP nsHTMLIFrameElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue,