diff --git a/dom/public/base/nsIDOMWindow.h b/dom/public/base/nsIDOMWindow.h index 32b45295f96a..595c7175f723 100644 --- a/dom/public/base/nsIDOMWindow.h +++ b/dom/public/base/nsIDOMWindow.h @@ -139,6 +139,8 @@ public: NS_IMETHOD CreatePopup(nsIDOMElement* aElement, nsIDOMElement* aPopupContent, PRInt32 aXPos, PRInt32 aYPos, const nsString& aPopupType, const nsString& aPopupAlignment)=0; + NS_IMETHOD CreateAnchoredPopup(nsIDOMElement* aElement, nsIDOMElement* aPopupContent, const nsString& aAnchorAlignment, 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; @@ -201,6 +203,7 @@ public: 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 CreateAnchoredPopup(nsIDOMElement* aElement, nsIDOMElement* aPopupContent, const nsString& aAnchorAlignment, 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); \ @@ -262,6 +265,7 @@ public: 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 CreateAnchoredPopup(nsIDOMElement* aElement, nsIDOMElement* aPopupContent, const nsString& aAnchorAlignment, const nsString& aPopupType, const nsString& aPopupAlignment) { return _to CreateAnchoredPopup(aElement, aPopupContent, aAnchorAlignment, 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 2317e35309be..5aab6e08ba94 100644 --- a/dom/public/idl/base/Window.idl +++ b/dom/public/idl/base/Window.idl @@ -52,6 +52,10 @@ in long xPos, in long yPos, in DOMString popupType, in DOMString popupAlignment); + void createAnchoredPopup(in Element element, in Element popupContent, + in DOMString anchorAlignment, + 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 2ed8c95a103d..77b0b6dae34d 100644 --- a/dom/src/base/nsGlobalWindow.cpp +++ b/dom/src/base/nsGlobalWindow.cpp @@ -1636,6 +1636,14 @@ GlobalWindowImpl::CreatePopup(nsIDOMElement* aElement, nsIDOMElement* aPopupCont return NS_OK; } +NS_IMETHODIMP +GlobalWindowImpl::CreateAnchoredPopup(nsIDOMElement* aElement, nsIDOMElement* aPopupContent, + const nsString& anAnchorAlignment, + 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 b106cb76cf20..05c99a7b06ec 100644 --- a/dom/src/base/nsGlobalWindow.h +++ b/dom/src/base/nsGlobalWindow.h @@ -152,6 +152,10 @@ public: NS_IMETHOD CreatePopup(nsIDOMElement* aElement, nsIDOMElement* aPopupContent, PRInt32 aXPos, PRInt32 aYPos, const nsString& aPopupType, const nsString& aPopupAlignment); + + NS_IMETHOD CreateAnchoredPopup(nsIDOMElement* aElement, nsIDOMElement* aPopupContent, + const nsString& anAnchorAlignment, + const nsString& aPopupType, const nsString& aPopupAlignment); // nsIDOMEventCapturer interface NS_IMETHOD CaptureEvent(const nsString& aType); diff --git a/dom/src/base/nsJSWindow.cpp b/dom/src/base/nsJSWindow.cpp index 5c1e3981334f..68703be8d2d3 100644 --- a/dom/src/base/nsJSWindow.cpp +++ b/dom/src/base/nsJSWindow.cpp @@ -1416,6 +1416,66 @@ WindowCreatePopup(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval * } +// +// Native method CreateAnchoredPopup +// +PR_STATIC_CALLBACK(JSBool) +WindowCreateAnchoredPopup(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; + nsAutoString b2; + nsAutoString b3; + nsAutoString b4; + + *rval = JSVAL_NULL; + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == nativeThis) { + return JS_TRUE; + } + + if (argc >= 5) { + + 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; + } + + nsJSUtils::nsConvertJSValToString(b2, cx, argv[2]); + + nsJSUtils::nsConvertJSValToString(b3, cx, argv[3]); + + nsJSUtils::nsConvertJSValToString(b4, cx, argv[4]); + + if (NS_OK != nativeThis->CreateAnchoredPopup(b0, b1, b2, b3, b4)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function createAnchoredPopup requires 5 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + // // Native method Open // @@ -1763,6 +1823,7 @@ static JSFunctionSpec WindowMethods[] = {"setTimeout", WindowSetTimeout, 0}, {"setInterval", WindowSetInterval, 0}, {"createPopup", WindowCreatePopup, 6}, + {"createAnchoredPopup", WindowCreateAnchoredPopup, 5}, {"open", WindowOpen, 0}, {"openDialog", WindowOpenDialog, 0}, {"captureEvent", EventCapturerCaptureEvent, 1},