implement intrinsically sized chrome windows. useful when using default nsIPrompts, as winEmbed does. part of bug 75745. r=blizzard,ccarlen,hyatt a=chofmann
git-svn-id: svn://10.0.0.236/trunk@93034 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "nsIWebProgress.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIRequest.h"
|
||||
#include "nsIChannel.h"
|
||||
@@ -46,6 +47,7 @@ WebBrowserChrome::WebBrowserChrome()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mNativeWindow = nsnull;
|
||||
mSizeSet = PR_FALSE;
|
||||
}
|
||||
|
||||
WebBrowserChrome::~WebBrowserChrome()
|
||||
@@ -196,6 +198,9 @@ NS_IMETHODIMP WebBrowserChrome::CreateBrowserWindow(PRUint32 aChromeFlags,
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
newChrome->GetWebBrowser(_retval);
|
||||
// leave chrome windows hidden until the chrome is loaded
|
||||
if (!(aChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME))
|
||||
WebBrowserChromeUI::ShowWindow(this, PR_TRUE);
|
||||
}
|
||||
|
||||
return rv;
|
||||
@@ -211,7 +216,12 @@ NS_IMETHODIMP WebBrowserChrome::DestroyBrowserWindow(void)
|
||||
|
||||
NS_IMETHODIMP WebBrowserChrome::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
/* This isn't exactly correct: we're setting the whole window to
|
||||
the size requested for the browser. At time of writing, though,
|
||||
it's fine and useful for winEmbed's purposes. */
|
||||
WebBrowserChromeUI::SizeTo(this, aCX, aCY);
|
||||
mSizeSet = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -266,6 +276,7 @@ NS_IMETHODIMP WebBrowserChrome::OnStateChange(nsIWebProgress *progress, nsIReque
|
||||
WebBrowserChromeUI::UpdateBusyState(this, PR_FALSE);
|
||||
WebBrowserChromeUI::UpdateProgress(this, 0, 100);
|
||||
WebBrowserChromeUI::UpdateStatusBarText(this, nsnull);
|
||||
ContentFinishedLoading();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@@ -426,6 +437,22 @@ WebBrowserChrome::SendHistoryStatusMessage(nsIURI * aURI, char * operation, PRIn
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void WebBrowserChrome::ContentFinishedLoading()
|
||||
{
|
||||
// if it was a chrome window and no one has already specified a size,
|
||||
// size to content
|
||||
if (mWebBrowser && !mSizeSet &&
|
||||
(mChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME)) {
|
||||
nsCOMPtr<nsIDOMWindow> contentWin;
|
||||
mWebBrowser->GetContentDOMWindow(getter_AddRefs(contentWin));
|
||||
nsCOMPtr<nsIDOMWindowInternal> contentIWin(do_QueryInterface(contentWin));
|
||||
if (contentIWin)
|
||||
contentIWin->SizeToContent();
|
||||
WebBrowserChromeUI::ShowWindow(this, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
// WebBrowserChrome::nsIEmbeddingSiteWindow
|
||||
//*****************************************************************************
|
||||
|
||||
@@ -56,6 +56,8 @@ public:
|
||||
static void ShowContextMenu(nsIWebBrowserChrome *aChrome, PRUint32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode);
|
||||
static void ShowTooltip(nsIWebBrowserChrome *aChrome, PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText);
|
||||
static void HideTooltip(nsIWebBrowserChrome *aChrome);
|
||||
static void ShowWindow(nsIWebBrowserChrome *aChrome, PRBool aShow);
|
||||
static void SizeTo(nsIWebBrowserChrome *aChrome, PRInt32 aWidth, PRInt32 aHeight);
|
||||
};
|
||||
|
||||
class WebBrowserChrome : public nsIWebBrowserChrome,
|
||||
@@ -92,9 +94,12 @@ public:
|
||||
protected:
|
||||
nsresult SendHistoryStatusMessage(nsIURI * aURI, char * operation, PRInt32 info1=0, PRUint32 info2=0);
|
||||
|
||||
void ContentFinishedLoading();
|
||||
|
||||
nativeWindow mNativeWindow;
|
||||
PRUint32 mChromeFlags;
|
||||
PRBool mContinueModalLoop;
|
||||
PRBool mSizeSet;
|
||||
|
||||
nsCOMPtr<nsIWebBrowser> mWebBrowser;
|
||||
nsCOMPtr<nsIWebBrowserChrome> mDependentParent; // opener (for dependent windows only)
|
||||
|
||||
@@ -284,6 +284,7 @@ nsresult OpenWebPage(const char *url)
|
||||
nsnull, &chrome);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
WebBrowserChromeUI::ShowWindow(chrome, PR_TRUE);
|
||||
// Start loading a page
|
||||
nsCOMPtr<nsIWebBrowser> newBrowser;
|
||||
chrome->GetWebBrowser(getter_AddRefs(newBrowser));
|
||||
@@ -408,7 +409,7 @@ void SaveWebPage(nsIWebBrowser *aWebBrowser)
|
||||
//
|
||||
// FUNCTION: ResizeEmbedding()
|
||||
//
|
||||
// PURPOSE: Resizes the webbrowser window to fit it's container.
|
||||
// PURPOSE: Resizes the webbrowser window to fit its container.
|
||||
//
|
||||
nsresult ResizeEmbedding(nsIWebBrowserChrome* chrome)
|
||||
{
|
||||
@@ -1207,6 +1208,21 @@ void WebBrowserChromeUI::HideTooltip(nsIWebBrowserChrome *aChrome)
|
||||
// TODO code to hide a tooltip should go here
|
||||
}
|
||||
|
||||
void WebBrowserChromeUI::ShowWindow(nsIWebBrowserChrome *aChrome, PRBool aShow)
|
||||
{
|
||||
HWND win = GetBrowserDlgFromChrome(aChrome);
|
||||
::ShowWindow(win, aShow ? SW_RESTORE : SW_HIDE);
|
||||
}
|
||||
|
||||
void WebBrowserChromeUI::SizeTo(nsIWebBrowserChrome *aChrome, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
HWND win = GetBrowserDlgFromChrome(aChrome);
|
||||
RECT winRect;
|
||||
|
||||
::GetWindowRect(win, &winRect);
|
||||
::MoveWindow(win, winRect.left, winRect.top, aWidth, aHeight, TRUE);
|
||||
}
|
||||
|
||||
//
|
||||
// FUNCTION: GetResourceStringByID()
|
||||
//
|
||||
|
||||
@@ -153,7 +153,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
|
||||
//
|
||||
|
||||
IDD_BROWSER DIALOG DISCARDABLE 0, 0, 400, 217
|
||||
STYLE WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE |
|
||||
STYLE WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP |
|
||||
WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
||||
CAPTION "winEmbed sample"
|
||||
MENU IDC_WINEMBED
|
||||
@@ -176,7 +176,7 @@ BEGIN
|
||||
END
|
||||
|
||||
IDD_BROWSER_NC DIALOG DISCARDABLE 0, 0, 400, 217
|
||||
STYLE WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE |
|
||||
STYLE WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP |
|
||||
WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
||||
CAPTION "winEmbed chromeless sample"
|
||||
MENU IDC_WINEMBED
|
||||
|
||||
Reference in New Issue
Block a user