зеркало из https://github.com/mozilla/pjs.git
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.
This commit is contained in:
Родитель
aa2fe05fbe
Коммит
eb690d2418
|
@ -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<nsIPresShell> presShell;
|
||||
|
||||
presShell = dont_AddRef(mInner.mDocument->GetShellAt(0));
|
||||
NS_ENSURE_TRUE(presShell, NS_OK);
|
||||
|
||||
nsCOMPtr<nsISupports> tmp;
|
||||
|
||||
presShell->GetSubShellFor(this, getter_AddRefs(tmp));
|
||||
NS_ENSURE_TRUE(tmp, 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;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLFrameElement::SetContentDocument(nsIDOMDocument* aContentDocument)
|
||||
{
|
||||
return NS_ERROR_DOM_INVALID_MODIFICATION_ERR;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLFrameElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
|
|
|
@ -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<nsIPresShell> presShell;
|
||||
|
||||
presShell = dont_AddRef(mInner.mDocument->GetShellAt(0));
|
||||
NS_ENSURE_TRUE(presShell, NS_OK);
|
||||
|
||||
nsCOMPtr<nsISupports> tmp;
|
||||
|
||||
presShell->GetSubShellFor(this, getter_AddRefs(tmp));
|
||||
NS_ENSURE_TRUE(tmp, 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;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLIFrameElement::SetContentDocument(nsIDOMDocument* aContentDocument)
|
||||
{
|
||||
return NS_ERROR_DOM_INVALID_MODIFICATION_ERR;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLIFrameElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
interface HTMLFrameElement : HTMLElement {
|
||||
/* IID: { 0xa6cf90b9, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } */
|
||||
|
||||
attribute DOMString frameBorder;
|
||||
attribute DOMString longDesc;
|
||||
attribute DOMString marginHeight;
|
||||
attribute DOMString marginWidth;
|
||||
attribute DOMString name;
|
||||
attribute boolean noResize;
|
||||
attribute DOMString scrolling;
|
||||
attribute DOMString src;
|
||||
};
|
|
@ -1,15 +0,0 @@
|
|||
interface HTMLIFrameElement : HTMLElement {
|
||||
/* IID: { 0xa6cf90ba, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } */
|
||||
|
||||
attribute DOMString align;
|
||||
attribute DOMString frameBorder;
|
||||
attribute DOMString height;
|
||||
attribute DOMString longDesc;
|
||||
attribute DOMString marginHeight;
|
||||
attribute DOMString marginWidth;
|
||||
attribute DOMString name;
|
||||
attribute DOMString scrolling;
|
||||
attribute DOMString src;
|
||||
attribute DOMString width;
|
||||
};
|
|
@ -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,
|
||||
|
|
|
@ -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", \
|
||||
|
|
|
@ -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}
|
||||
};
|
||||
|
||||
|
|
|
@ -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}
|
||||
};
|
||||
|
||||
|
|
|
@ -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<nsIPresShell> presShell;
|
||||
|
||||
presShell = dont_AddRef(mInner.mDocument->GetShellAt(0));
|
||||
NS_ENSURE_TRUE(presShell, NS_OK);
|
||||
|
||||
nsCOMPtr<nsISupports> tmp;
|
||||
|
||||
presShell->GetSubShellFor(this, getter_AddRefs(tmp));
|
||||
NS_ENSURE_TRUE(tmp, 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;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLFrameElement::SetContentDocument(nsIDOMDocument* aContentDocument)
|
||||
{
|
||||
return NS_ERROR_DOM_INVALID_MODIFICATION_ERR;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLFrameElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
|
|
|
@ -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<nsIPresShell> presShell;
|
||||
|
||||
presShell = dont_AddRef(mInner.mDocument->GetShellAt(0));
|
||||
NS_ENSURE_TRUE(presShell, NS_OK);
|
||||
|
||||
nsCOMPtr<nsISupports> tmp;
|
||||
|
||||
presShell->GetSubShellFor(this, getter_AddRefs(tmp));
|
||||
NS_ENSURE_TRUE(tmp, 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;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLIFrameElement::SetContentDocument(nsIDOMDocument* aContentDocument)
|
||||
{
|
||||
return NS_ERROR_DOM_INVALID_MODIFICATION_ERR;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLIFrameElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
|
|
Загрузка…
Ссылка в новой задаче