moved SizeToContent from nsIDOMWindowInternal to nsIDOMWindow and updated existing code. Fixes bug 69922, r=dr, sr=brendan, a=blizzard.

This commit is contained in:
arik%netscape.com 2001-04-28 02:42:23 +00:00
parent 6316cae1ec
commit 96627cc8b7
7 changed files with 45 additions and 57 deletions

View File

@ -68,6 +68,8 @@ public:
NS_IMETHOD ScrollByLines(PRInt32 aNumLines)=0;
NS_IMETHOD ScrollByPages(PRInt32 aNumPages)=0;
NS_IMETHOD SizeToContent()=0;
};
@ -86,6 +88,7 @@ public:
NS_IMETHOD GetSelection(nsISelection** aReturn); \
NS_IMETHOD ScrollByLines(PRInt32 aNumLines); \
NS_IMETHOD ScrollByPages(PRInt32 aNumPages); \
NS_IMETHOD SizeToContent(); \
@ -104,6 +107,7 @@ public:
NS_IMETHOD GetSelection(nsISelection** aReturn) { return _to GetSelection(aReturn); } \
NS_IMETHOD ScrollByLines(PRInt32 aNumLines) { return _to ScrollByLines(aNumLines); } \
NS_IMETHOD ScrollByPages(PRInt32 aNumPages) { return _to ScrollByPages(aNumPages); } \
NS_IMETHOD SizeToContent() { return _to SizeToContent(); } \
extern nsresult NS_InitWindowClass(nsIScriptContext *aContext, nsIScriptGlobalObject *aGlobal);

View File

@ -157,8 +157,6 @@ public:
NS_IMETHOD ResizeBy(PRInt32 aWidthDif, PRInt32 aHeightDif)=0;
NS_IMETHOD SizeToContent()=0;
NS_IMETHOD GetAttention()=0;
NS_IMETHOD Scroll(PRInt32 aXScroll, PRInt32 aYScroll)=0;
@ -260,7 +258,6 @@ public:
NS_IMETHOD MoveBy(PRInt32 aXDif, PRInt32 aYDif); \
NS_IMETHOD ResizeTo(PRInt32 aWidth, PRInt32 aHeight); \
NS_IMETHOD ResizeBy(PRInt32 aWidthDif, PRInt32 aHeightDif); \
NS_IMETHOD SizeToContent(); \
NS_IMETHOD GetAttention(); \
NS_IMETHOD Scroll(PRInt32 aXScroll, PRInt32 aYScroll); \
NS_IMETHOD ClearTimeout(PRInt32 aTimerID); \
@ -344,7 +341,6 @@ public:
NS_IMETHOD MoveBy(PRInt32 aXDif, PRInt32 aYDif) { return _to MoveBy(aXDif, aYDif); } \
NS_IMETHOD ResizeTo(PRInt32 aWidth, PRInt32 aHeight) { return _to ResizeTo(aWidth, aHeight); } \
NS_IMETHOD ResizeBy(PRInt32 aWidthDif, PRInt32 aHeightDif) { return _to ResizeBy(aWidthDif, aHeightDif); } \
NS_IMETHOD SizeToContent() { return _to SizeToContent(); } \
NS_IMETHOD GetAttention() { return _to GetAttention(); } \
NS_IMETHOD Scroll(PRInt32 aXScroll, PRInt32 aYScroll) { return _to Scroll(aXScroll, aYScroll); } \
NS_IMETHOD ClearTimeout(PRInt32 aTimerID) { return _to ClearTimeout(aTimerID); } \

View File

@ -935,6 +935,7 @@
"window.scrollto", \
"window.scrollx", \
"window.scrolly", \
"window.sizetocontent", \
"window.top", \
"windowcollection.item", \
"windowcollection.length", \
@ -1020,7 +1021,6 @@
"windowinternal.setinterval", \
"windowinternal.settimeout", \
"windowinternal.sidebar", \
"windowinternal.sizetocontent", \
"windowinternal.status", \
"windowinternal.statusbar", \
"windowinternal.stop", \

View File

@ -3111,6 +3111,41 @@ WindowScrollByPages(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
}
//
// Native method SizeToContent
//
PR_STATIC_CALLBACK(JSBool)
WindowSizeToContent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMWindow *nativeThis = (nsIDOMWindow*)nsJSUtils::nsGetNativeThis(cx, obj);
nsresult result = NS_OK;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
{
*rval = JSVAL_NULL;
nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj);
if (!secMan)
return PR_FALSE;
result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_WINDOW_SIZETOCONTENT, PR_FALSE);
if (NS_FAILED(result)) {
return nsJSUtils::nsReportError(cx, obj, result);
}
result = nativeThis->SizeToContent();
if (NS_FAILED(result)) {
return nsJSUtils::nsReportError(cx, obj, result);
}
*rval = JSVAL_VOID;
}
return JS_TRUE;
}
//
// Native method Dump
//
@ -3767,46 +3802,6 @@ WindowInternalResizeBy(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
}
//
// Native method SizeToContent
//
PR_STATIC_CALLBACK(JSBool)
WindowInternalSizeToContent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMWindow *privateThis = (nsIDOMWindow*)nsJSUtils::nsGetNativeThis(cx, obj);
nsCOMPtr<nsIDOMWindowInternal> nativeThis;
nsresult result = NS_OK;
if (NS_OK != privateThis->QueryInterface(kIWindowInternalIID, getter_AddRefs(nativeThis))) {
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_WRONG_TYPE_ERR);
}
// If there's no private data, this must be the prototype, so ignore
if (!nativeThis) {
return JS_TRUE;
}
{
*rval = JSVAL_NULL;
nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj);
if (!secMan)
return PR_FALSE;
result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_WINDOWINTERNAL_SIZETOCONTENT, PR_FALSE);
if (NS_FAILED(result)) {
return nsJSUtils::nsReportError(cx, obj, result);
}
result = nativeThis->SizeToContent();
if (NS_FAILED(result)) {
return nsJSUtils::nsReportError(cx, obj, result);
}
*rval = JSVAL_VOID;
}
return JS_TRUE;
}
//
// Native method GetAttention
//
@ -4864,6 +4859,7 @@ static JSFunctionSpec WindowMethods[] =
{"getSelection", WindowGetSelection, 0},
{"scrollByLines", WindowScrollByLines, 1},
{"scrollByPages", WindowScrollByPages, 1},
{"sizeToContent", WindowSizeToContent, 0},
{"dump", WindowInternalDump, 1},
{"alert", WindowInternalAlert, 0},
{"confirm", WindowInternalConfirm, 0},
@ -4879,7 +4875,6 @@ static JSFunctionSpec WindowMethods[] =
{"moveBy", WindowInternalMoveBy, 2},
{"resizeTo", WindowInternalResizeTo, 2},
{"resizeBy", WindowInternalResizeBy, 2},
{"sizeToContent", WindowInternalSizeToContent, 0},
{"GetAttention", WindowInternalGetAttention, 0},
{"scroll", WindowInternalScroll, 2},
{"clearTimeout", WindowInternalClearTimeout, 1},

View File

@ -480,12 +480,8 @@ EmbedPrivate::ContentFinishedLoading(void)
return;
}
// get the private DOM window
nsCOMPtr<nsIDOMWindowInternal> domWindowInternal =
do_QueryInterface(domWindow);
// resize the content
domWindowInternal->SizeToContent();
domWindow->SizeToContent();
// and since we're done loading show the window, assuming that the
// visibility flag has been set.

View File

@ -553,9 +553,7 @@ NS_METHOD CBrowserWindow::SizeToContent()
nsCOMPtr<nsIDOMWindow> domWindow;
rv = mBrowserChrome->GetInterface(NS_GET_IID(nsIDOMWindow), getter_AddRefs(domWindow));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMWindowInternal> domWindowInternal(do_QueryInterface(domWindow, &rv));
if (NS_FAILED(rv)) return rv;
return domWindowInternal->SizeToContent();
return domWindow->SizeToContent();
}
NS_METHOD CBrowserWindow::Stop()

View File

@ -459,9 +459,8 @@ void WebBrowserChrome::ContentFinishedLoading()
(mChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME)) {
nsCOMPtr<nsIDOMWindow> contentWin;
mWebBrowser->GetContentDOMWindow(getter_AddRefs(contentWin));
nsCOMPtr<nsIDOMWindowInternal> contentIWin(do_QueryInterface(contentWin));
if (contentIWin)
contentIWin->SizeToContent();
if (contentWin)
contentWin->SizeToContent();
WebBrowserChromeUI::ShowWindow(this, PR_TRUE);
}
}