diff --git a/dom/public/base/nsIDOMWindow.h b/dom/public/base/nsIDOMWindow.h index 8a3d9466d4bf..32b45295f96a 100644 --- a/dom/public/base/nsIDOMWindow.h +++ b/dom/public/base/nsIDOMWindow.h @@ -26,6 +26,7 @@ #include "jsapi.h" class nsIDOMNavigator; +class nsIDOMElement; class nsIDOMDocument; class nsIDOMScreen; class nsIDOMHistory; @@ -136,6 +137,8 @@ public: NS_IMETHOD SetInterval(JSContext *cx, jsval *argv, PRUint32 argc, PRInt32* aReturn)=0; + NS_IMETHOD CreatePopup(nsIDOMElement* aElement, nsIDOMElement* aPopupContent, PRInt32 aXPos, PRInt32 aYPos, const nsString& aPopupType, const nsString& aPopupAlignment)=0; + NS_IMETHOD Open(JSContext *cx, jsval *argv, PRUint32 argc, nsIDOMWindow** aReturn)=0; NS_IMETHOD OpenDialog(JSContext *cx, jsval *argv, PRUint32 argc, nsIDOMWindow** aReturn)=0; @@ -197,6 +200,7 @@ public: NS_IMETHOD ClearInterval(PRInt32 aTimerID); \ NS_IMETHOD SetTimeout(JSContext *cx, jsval *argv, PRUint32 argc, PRInt32* aReturn); \ NS_IMETHOD SetInterval(JSContext *cx, jsval *argv, PRUint32 argc, PRInt32* aReturn); \ + NS_IMETHOD CreatePopup(nsIDOMElement* aElement, nsIDOMElement* aPopupContent, PRInt32 aXPos, PRInt32 aYPos, const nsString& aPopupType, const nsString& aPopupAlignment); \ NS_IMETHOD Open(JSContext *cx, jsval *argv, PRUint32 argc, nsIDOMWindow** aReturn); \ NS_IMETHOD OpenDialog(JSContext *cx, jsval *argv, PRUint32 argc, nsIDOMWindow** aReturn); \ @@ -257,6 +261,7 @@ public: NS_IMETHOD ClearInterval(PRInt32 aTimerID) { return _to ClearInterval(aTimerID); } \ NS_IMETHOD SetTimeout(JSContext *cx, jsval *argv, PRUint32 argc, PRInt32* aReturn) { return _to SetTimeout(cx, argv, argc, aReturn); } \ NS_IMETHOD SetInterval(JSContext *cx, jsval *argv, PRUint32 argc, PRInt32* aReturn) { return _to SetInterval(cx, argv, argc, aReturn); } \ + NS_IMETHOD CreatePopup(nsIDOMElement* aElement, nsIDOMElement* aPopupContent, PRInt32 aXPos, PRInt32 aYPos, const nsString& aPopupType, const nsString& aPopupAlignment) { return _to CreatePopup(aElement, aPopupContent, aXPos, aYPos, aPopupType, aPopupAlignment); } \ NS_IMETHOD Open(JSContext *cx, jsval *argv, PRUint32 argc, nsIDOMWindow** aReturn) { return _to Open(cx, argv, argc, aReturn); } \ NS_IMETHOD OpenDialog(JSContext *cx, jsval *argv, PRUint32 argc, nsIDOMWindow** aReturn) { return _to OpenDialog(cx, argv, argc, aReturn); } \ diff --git a/dom/public/idl/base/Window.idl b/dom/public/idl/base/Window.idl index a3afbfa3eafe..2317e35309be 100644 --- a/dom/public/idl/base/Window.idl +++ b/dom/public/idl/base/Window.idl @@ -47,6 +47,11 @@ void clearInterval(in long timerID); long setTimeout(/* ... */); long setInterval(/* ... */); + + void createPopup(in Element element, in Element popupContent, + in long xPos, in long yPos, + in DOMString popupType, in DOMString popupAlignment); + Window open(/* ... */); Window openDialog(/* ... */); }; diff --git a/dom/src/base/nsGlobalWindow.cpp b/dom/src/base/nsGlobalWindow.cpp index cd5a593c205a..2ed8c95a103d 100644 --- a/dom/src/base/nsGlobalWindow.cpp +++ b/dom/src/base/nsGlobalWindow.cpp @@ -1628,6 +1628,14 @@ GlobalWindowImpl::OpenDialog(JSContext *cx, return res; } +NS_IMETHODIMP +GlobalWindowImpl::CreatePopup(nsIDOMElement* aElement, nsIDOMElement* aPopupContent, + PRInt32 aXPos, PRInt32 aYPos, + const nsString& aPopupType, const nsString& aPopupAlignment) +{ + return NS_OK; +} + nsresult GlobalWindowImpl::CheckWindowName(JSContext *cx, nsString& aName) { diff --git a/dom/src/base/nsGlobalWindow.h b/dom/src/base/nsGlobalWindow.h index f394643d38b1..b106cb76cf20 100644 --- a/dom/src/base/nsGlobalWindow.h +++ b/dom/src/base/nsGlobalWindow.h @@ -149,6 +149,10 @@ public: NS_IMETHOD OpenDialog(JSContext *cx, jsval *argv, PRUint32 argc, nsIDOMWindow** aReturn); + NS_IMETHOD CreatePopup(nsIDOMElement* aElement, nsIDOMElement* aPopupContent, + PRInt32 aXPos, PRInt32 aYPos, + const nsString& aPopupType, const nsString& aPopupAlignment); + // nsIDOMEventCapturer interface NS_IMETHOD CaptureEvent(const nsString& aType); NS_IMETHOD ReleaseEvent(const nsString& aType); diff --git a/dom/src/base/nsJSWindow.cpp b/dom/src/base/nsJSWindow.cpp index 035cdf08ece3..5c1e3981334f 100644 --- a/dom/src/base/nsJSWindow.cpp +++ b/dom/src/base/nsJSWindow.cpp @@ -27,6 +27,7 @@ #include "nsIPtr.h" #include "nsString.h" #include "nsIDOMNavigator.h" +#include "nsIDOMElement.h" #include "nsIDOMDocument.h" #include "nsIDOMScreen.h" #include "nsIDOMHistory.h" @@ -41,6 +42,7 @@ 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(kINavigatorIID, NS_IDOMNAVIGATOR_IID); +static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID); static NS_DEFINE_IID(kIDocumentIID, NS_IDOMDOCUMENT_IID); static NS_DEFINE_IID(kIScreenIID, NS_IDOMSCREEN_IID); static NS_DEFINE_IID(kIHistoryIID, NS_IDOMHISTORY_IID); @@ -51,6 +53,7 @@ static NS_DEFINE_IID(kIEventCapturerIID, NS_IDOMEVENTCAPTURER_IID); static NS_DEFINE_IID(kIWindowIID, NS_IDOMWINDOW_IID); NS_DEF_PTR(nsIDOMNavigator); +NS_DEF_PTR(nsIDOMElement); NS_DEF_PTR(nsIDOMDocument); NS_DEF_PTR(nsIDOMScreen); NS_DEF_PTR(nsIDOMHistory); @@ -1344,6 +1347,75 @@ WindowSetInterval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval * } +// +// Native method CreatePopup +// +PR_STATIC_CALLBACK(JSBool) +WindowCreatePopup(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMWindow *nativeThis = (nsIDOMWindow*)JS_GetPrivate(cx, obj); + JSBool rBool = JS_FALSE; + nsIDOMElementPtr b0; + nsIDOMElementPtr b1; + PRInt32 b2; + PRInt32 b3; + nsAutoString b4; + nsAutoString b5; + + *rval = JSVAL_NULL; + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == nativeThis) { + return JS_TRUE; + } + + if (argc >= 6) { + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, + kIElementIID, + "Element", + cx, + argv[0])) { + return JS_FALSE; + } + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1, + kIElementIID, + "Element", + cx, + argv[1])) { + return JS_FALSE; + } + + if (!JS_ValueToInt32(cx, argv[2], (int32 *)&b2)) { + JS_ReportError(cx, "Parameter must be a number"); + return JS_FALSE; + } + + if (!JS_ValueToInt32(cx, argv[3], (int32 *)&b3)) { + JS_ReportError(cx, "Parameter must be a number"); + return JS_FALSE; + } + + nsJSUtils::nsConvertJSValToString(b4, cx, argv[4]); + + nsJSUtils::nsConvertJSValToString(b5, cx, argv[5]); + + if (NS_OK != nativeThis->CreatePopup(b0, b1, b2, b3, b4, b5)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function createPopup requires 6 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + // // Native method Open // @@ -1690,6 +1762,7 @@ static JSFunctionSpec WindowMethods[] = {"clearInterval", WindowClearInterval, 1}, {"setTimeout", WindowSetTimeout, 0}, {"setInterval", WindowSetInterval, 0}, + {"createPopup", WindowCreatePopup, 6}, {"open", WindowOpen, 0}, {"openDialog", WindowOpenDialog, 0}, {"captureEvent", EventCapturerCaptureEvent, 1},