Changed nsIBrowserWindow references to reference nsBrowserWindow. nsBrowserWindow is no longer a component. More implementation to get nsBrowserWindow and nsWebBrowserChrome implementations geared towards the embedding code. made nsBrowserWindow implement nsIBaseWindow.

This commit is contained in:
tbogard%aol.net 2000-03-14 11:08:43 +00:00
Родитель 54958006d1
Коммит 58e5886488
8 изменённых файлов: 370 добавлений и 362 удалений

Просмотреть файл

@ -152,7 +152,6 @@ static NS_DEFINE_CID(kWalletServiceCID, NS_WALLETSERVICE_CID);
#endif #endif
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
static NS_DEFINE_CID(kBrowserWindowCID, NS_BROWSER_WINDOW_CID);
static NS_DEFINE_CID(kButtonCID, NS_BUTTON_CID); static NS_DEFINE_CID(kButtonCID, NS_BUTTON_CID);
static NS_DEFINE_CID(kFileWidgetCID, NS_FILEWIDGET_CID); static NS_DEFINE_CID(kFileWidgetCID, NS_FILEWIDGET_CID);
static NS_DEFINE_CID(kTextFieldCID, NS_TEXTFIELD_CID); static NS_DEFINE_CID(kTextFieldCID, NS_TEXTFIELD_CID);
@ -165,7 +164,6 @@ static NS_DEFINE_CID(kLabelCID, NS_LABEL_CID);
static NS_DEFINE_IID(kIXPBaseWindowIID, NS_IXPBASE_WINDOW_IID); static NS_DEFINE_IID(kIXPBaseWindowIID, NS_IXPBASE_WINDOW_IID);
static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID); static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
static NS_DEFINE_IID(kIBrowserWindowIID, NS_IBROWSER_WINDOW_IID);
static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID); static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID);
static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID); static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
@ -203,6 +201,244 @@ static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent);
#endif #endif
static void* GetItemsNativeData(nsISupports* aObject); static void* GetItemsNativeData(nsISupports* aObject);
//******* Cleanup Above here***********/
//*****************************************************************************
// nsBrowserWindow::nsIBaseWindow
//*****************************************************************************
NS_IMETHODIMP nsBrowserWindow::InitWindow(nativeWindow aParentNativeWindow,
nsIWidget* parentWidget, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)
{
// Ignore wigdet parents for now. Don't think those are a vaild thing to call.
NS_ENSURE_SUCCESS(SetPositionAndSize(x, y, cx, cy, PR_FALSE), NS_ERROR_FAILURE);
return NS_OK;
}
NS_IMETHODIMP nsBrowserWindow::Create()
{
NS_ASSERTION(PR_FALSE, "You can't call this");
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP nsBrowserWindow::Destroy()
{
RemoveBrowser(this);
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
if(webShell)
{
//XXXTAB Should do this on the docShell
nsCOMPtr<nsIDocumentLoader> docLoader;
webShell->GetDocumentLoader(*getter_AddRefs(docLoader));
if(docLoader)
docLoader->RemoveObserver(this);
nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell));
docShellWin->Destroy();
NS_RELEASE(mDocShell);
}
DestroyWidget(mBack);
mBack = nsnull;
DestroyWidget(mForward);
mForward = nsnull;
DestroyWidget(mLocation);
mLocation = nsnull;
DestroyWidget(mStatus);
mStatus = nsnull;
if(mThrobber)
{
mThrobber->Destroy();
NS_RELEASE(mThrobber);
mThrobber = nsnull;
}
DestroyWidget(mWindow);
mWindow = nsnull;
return NS_OK;
}
NS_IMETHODIMP nsBrowserWindow::SetPosition(PRInt32 aX, PRInt32 aY)
{
PRInt32 cx=0;
PRInt32 cy=0;
NS_ENSURE_SUCCESS(GetSize(&cx, &cy), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(SetPositionAndSize(aX, aY, cx, cy, PR_FALSE),
NS_ERROR_FAILURE);
return NS_OK;
}
NS_IMETHODIMP nsBrowserWindow::GetPosition(PRInt32* aX, PRInt32* aY)
{
return GetPositionAndSize(aX, aY, nsnull, nsnull);
}
NS_IMETHODIMP nsBrowserWindow::SetSize(PRInt32 aCX, PRInt32 aCY, PRBool aRepaint)
{
PRInt32 x=0;
PRInt32 y=0;
NS_ENSURE_SUCCESS(GetPosition(&x, &y), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(SetPositionAndSize(x, y, aCX, aCY, aRepaint),
NS_ERROR_FAILURE);
return NS_OK;
}
NS_IMETHODIMP nsBrowserWindow::GetSize(PRInt32* aCX, PRInt32* aCY)
{
return GetPositionAndSize(nsnull, nsnull, aCX, aCY);
}
NS_IMETHODIMP nsBrowserWindow::SetPositionAndSize(PRInt32 aX, PRInt32 aY,
PRInt32 aCX, PRInt32 aCY, PRBool aRepaint)
{
NS_ENSURE_SUCCESS(mWindow->Resize(aX, aY, aCX, aCY, aRepaint),
NS_ERROR_FAILURE);
return NS_OK;
}
NS_IMETHODIMP nsBrowserWindow::GetPositionAndSize(PRInt32* aX, PRInt32* aY,
PRInt32* aCX, PRInt32* aCY)
{
nsRect bounds;
NS_ENSURE_SUCCESS(mWindow->GetBounds(bounds), NS_ERROR_FAILURE);
if(aX)
*aX = bounds.x;
if(aY)
*aY = bounds.y;
if(aCX)
*aCX = bounds.width;
if(aCY)
*aCY = bounds.height;
return NS_OK;
}
NS_IMETHODIMP nsBrowserWindow::Repaint(PRBool aForce)
{
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP nsBrowserWindow::GetParentWidget(nsIWidget** aParentWidget)
{
NS_ENSURE_ARG_POINTER(aParentWidget);
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP nsBrowserWindow::SetParentWidget(nsIWidget* aParentWidget)
{
NS_ASSERTION(PR_FALSE, "You can't call this");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsBrowserWindow::GetParentNativeWindow(nativeWindow* aParentNativeWindow)
{
NS_ENSURE_ARG_POINTER(aParentNativeWindow);
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP nsBrowserWindow::SetParentNativeWindow(nativeWindow aParentNativeWindow)
{
NS_ASSERTION(PR_FALSE, "You can't call this");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsBrowserWindow::GetVisibility(PRBool* aVisibility)
{
NS_ENSURE_ARG_POINTER(aVisibility);
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP nsBrowserWindow::SetVisibility(PRBool aVisibility)
{
NS_ENSURE_STATE(mWindow);
NS_ENSURE_SUCCESS(mWindow->Show(aVisibility), NS_ERROR_FAILURE);
return NS_OK;
}
NS_IMETHODIMP nsBrowserWindow::GetMainWidget(nsIWidget** aMainWidget)
{
NS_ENSURE_ARG_POINTER(aMainWidget);
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP nsBrowserWindow::SetFocus()
{
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP nsBrowserWindow::FocusAvailable(nsIBaseWindow* aCurrentFocus,
PRBool* aTookFocus)
{
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP nsBrowserWindow::GetTitle(PRUnichar** aTitle)
{
NS_ENSURE_ARG_POINTER(aTitle);
*aTitle = mTitle.ToNewUnicode();
return NS_OK;
}
NS_IMETHODIMP nsBrowserWindow::SetTitle(const PRUnichar* aTitle)
{
NS_ENSURE_STATE(mWindow);
mTitle = aTitle;
NS_ENSURE_SUCCESS(mWindow->SetTitle(aTitle), NS_ERROR_FAILURE);
return NS_OK;
}
//*****************************************************************************
// nsBrowserWindow: Helper Function
//*****************************************************************************
void nsBrowserWindow::DestroyWidget(nsISupports* aWidget)
{
if(aWidget)
{
nsCOMPtr<nsIWidget> w(do_QueryInterface(aWidget));
if(w)
w->Destroy();
}
}
//******* Cleanup below here *************/
//---------------------------------------------------------------------- //----------------------------------------------------------------------
static static
@ -310,7 +546,7 @@ nsBrowserWindow::CloseAllWindows()
while (0 != gBrowsers.Count()) { while (0 != gBrowsers.Count()) {
nsBrowserWindow* bw = (nsBrowserWindow*) gBrowsers.ElementAt(0); nsBrowserWindow* bw = (nsBrowserWindow*) gBrowsers.ElementAt(0);
NS_ADDREF(bw); NS_ADDREF(bw);
bw->Close(); bw->Destroy();
NS_RELEASE(bw); NS_RELEASE(bw);
} }
gBrowsers.Clear(); gBrowsers.Clear();
@ -682,10 +918,10 @@ nsBrowserWindow::DispatchMenuItem(PRInt32 aID)
#ifndef HTMLDialogs #ifndef HTMLDialogs
if (aID == PRVCY_PREFILL) { if (aID == PRVCY_PREFILL) {
nsAutoString url("file:///y|/htmldlgs.htm"); nsAutoString url("file:///y|/htmldlgs.htm");
nsIBrowserWindow* bw = nsnull; nsBrowserWindow* bw = nsnull;
mApp->OpenWindow(PRUint32(~0), bw); mApp->OpenWindow(PRUint32(~0), bw);
bw->Show(); bw->SetVisibility(PR_TRUE);
((nsBrowserWindow *)bw)->GoTo(url.GetUnicode()); bw->GoTo(url.GetUnicode());
NS_RELEASE(bw); NS_RELEASE(bw);
} }
#endif #endif
@ -822,7 +1058,7 @@ nsBrowserWindow::DoFileOpen()
// Ask the Web widget to load the file URL // Ask the Web widget to load the file URL
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell)); nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
webShell->LoadURL(nsString(fileURL.GetURLString()).GetUnicode()); webShell->LoadURL(nsString(fileURL.GetURLString()).GetUnicode());
Show(); SetVisibility(PR_TRUE);
} }
} }
@ -1049,11 +1285,6 @@ nsBrowserWindow::QueryInterface(const nsIID& aIID,
*aInstancePtrResult = NULL; *aInstancePtrResult = NULL;
if (aIID.Equals(kIBrowserWindowIID)) {
*aInstancePtrResult = (void*) ((nsIBrowserWindow*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIDocumentLoaderObserverIID)) { if (aIID.Equals(kIDocumentLoaderObserverIID)) {
*aInstancePtrResult = (void*) ((nsIDocumentLoaderObserver*)this); *aInstancePtrResult = (void*) ((nsIDocumentLoaderObserver*)this);
NS_ADDREF_THIS(); NS_ADDREF_THIS();
@ -1075,7 +1306,7 @@ nsBrowserWindow::QueryInterface(const nsIID& aIID,
return NS_OK; return NS_OK;
} }
if (aIID.Equals(kISupportsIID)) { if (aIID.Equals(kISupportsIID)) {
*aInstancePtrResult = (void*) ((nsISupports*)((nsIBrowserWindow*)this)); *aInstancePtrResult = (void*) ((nsISupports*)((nsIWebShellContainer*)this));
NS_ADDREF_THIS(); NS_ADDREF_THIS();
return NS_OK; return NS_OK;
} }
@ -1137,7 +1368,7 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell,
} }
webBrowserWin->SetVisibility(PR_TRUE); webBrowserWin->SetVisibility(PR_TRUE);
if (NS_CHROME_MENU_BAR_ON & aChromeMask) { if (nsIWebBrowserChrome::menuBarOn & aChromeMask) {
rv = CreateMenuBar(r.width); rv = CreateMenuBar(r.width);
if (NS_OK != rv) { if (NS_OK != rv) {
return rv; return rv;
@ -1146,14 +1377,14 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell,
r.x = r.y = 0; r.x = r.y = 0;
} }
if (NS_CHROME_TOOL_BAR_ON & aChromeMask) { if (nsIWebBrowserChrome::toolBarOn & aChromeMask) {
rv = CreateToolBar(r.width); rv = CreateToolBar(r.width);
if (NS_OK != rv) { if (NS_OK != rv) {
return rv; return rv;
} }
} }
if (NS_CHROME_STATUS_BAR_ON & aChromeMask) { if (nsIWebBrowserChrome::statusBarOn & aChromeMask) {
rv = CreateStatusBar(r.width); rv = CreateStatusBar(r.width);
if (NS_OK != rv) { if (NS_OK != rv) {
return rv; return rv;
@ -1215,7 +1446,7 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell,
docLoader->AddObserver(this); docLoader->AddObserver(this);
} }
if (NS_CHROME_MENU_BAR_ON & aChromeMask) { if (nsIWebBrowserChrome::menuBarOn & aChromeMask) {
rv = CreateMenuBar(r.width); rv = CreateMenuBar(r.width);
if (NS_OK != rv) { if (NS_OK != rv) {
return rv; return rv;
@ -1224,14 +1455,14 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell,
r.x = r.y = 0; r.x = r.y = 0;
} }
if (NS_CHROME_TOOL_BAR_ON & aChromeMask) { if (nsIWebBrowserChrome::toolBarOn & aChromeMask) {
rv = CreateToolBar(r.width); rv = CreateToolBar(r.width);
if (NS_OK != rv) { if (NS_OK != rv) {
return rv; return rv;
} }
} }
if (NS_CHROME_STATUS_BAR_ON & aChromeMask) { if (nsIWebBrowserChrome::statusBarOn & aChromeMask) {
rv = CreateStatusBar(r.width); rv = CreateStatusBar(r.width);
if (NS_OK != rv) { if (NS_OK != rv) {
return rv; return rv;
@ -1459,7 +1690,7 @@ nsBrowserWindow::Layout(PRInt32 aWidth, PRInt32 aHeight)
nsRect rr(0, 0, aWidth, aHeight); nsRect rr(0, 0, aWidth, aHeight);
// position location bar (it's stretchy) // position location bar (it's stretchy)
if (NS_CHROME_TOOL_BAR_ON & mChromeMask) { if (nsIWebBrowserChrome::toolBarOn & mChromeMask) {
nsIWidget* locationWidget = nsnull; nsIWidget* locationWidget = nsnull;
if (mLocation && if (mLocation &&
NS_SUCCEEDED(mLocation->QueryInterface(kIWidgetIID, NS_SUCCEEDED(mLocation->QueryInterface(kIWidgetIID,
@ -1526,7 +1757,7 @@ nsBrowserWindow::Layout(PRInt32 aWidth, PRInt32 aHeight)
nsIWidget* statusWidget = nsnull; nsIWidget* statusWidget = nsnull;
if (mStatus && NS_OK == mStatus->QueryInterface(kIWidgetIID,(void**)&statusWidget)) { if (mStatus && NS_OK == mStatus->QueryInterface(kIWidgetIID,(void**)&statusWidget)) {
if (mChromeMask & NS_CHROME_STATUS_BAR_ON) { if (mChromeMask & nsIWebBrowserChrome::statusBarOn) {
statusWidget->Resize(0, aHeight - txtHeight, statusWidget->Resize(0, aHeight - txtHeight,
aWidth, txtHeight, aWidth, txtHeight,
PR_TRUE); PR_TRUE);
@ -1543,7 +1774,7 @@ nsBrowserWindow::Layout(PRInt32 aWidth, PRInt32 aHeight)
// inset the web widget // inset the web widget
if (NS_CHROME_TOOL_BAR_ON & mChromeMask) { if (nsIWebBrowserChrome::toolBarOn & mChromeMask) {
rr.height -= BUTTON_HEIGHT; rr.height -= BUTTON_HEIGHT;
rr.y += BUTTON_HEIGHT; rr.y += BUTTON_HEIGHT;
} }
@ -1605,69 +1836,6 @@ nsBrowserWindow::GetWindowBounds(nsRect& aBounds)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsBrowserWindow::Show()
{
NS_PRECONDITION(nsnull != mWindow, "null window");
mWindow->Show(PR_TRUE);
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::Hide()
{
NS_PRECONDITION(nsnull != mWindow, "null window");
mWindow->Show(PR_FALSE);
return NS_OK;
}
static void DestroyWidget(nsISupports* aWidget)
{
if (aWidget) {
nsIWidget* w;
nsresult rv = aWidget->QueryInterface(kIWidgetIID, (void**) &w);
if (NS_SUCCEEDED(rv)) {
w->Destroy();
NS_RELEASE(w);
}
NS_RELEASE(aWidget);
}
}
NS_IMETHODIMP
nsBrowserWindow::Close()
{
RemoveBrowser(this);
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
if (nsnull != webShell) {
nsCOMPtr<nsIDocumentLoader> docLoader;
webShell->GetDocumentLoader(*getter_AddRefs(docLoader));
if (docLoader) {
docLoader->RemoveObserver(this);
}
nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell));
docShellWin->Destroy();
NS_RELEASE(mDocShell);
}
DestroyWidget(mBack); mBack = nsnull;
DestroyWidget(mForward); mForward = nsnull;
DestroyWidget(mLocation); mLocation = nsnull;
DestroyWidget(mStatus); mStatus = nsnull;
if (mThrobber) {
mThrobber->Destroy();
NS_RELEASE(mThrobber);
mThrobber = nsnull;
}
DestroyWidget(mWindow); mWindow = nsnull;
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsBrowserWindow::ShowModally(PRBool aPrepare) nsBrowserWindow::ShowModally(PRBool aPrepare)
{ {
@ -1712,55 +1880,6 @@ nsBrowserWindow::GetContentWebShell(nsIWebShell **aResult)
} }
//---------------------------------------- //----------------------------------------
NS_IMETHODIMP
nsBrowserWindow::IsIntrinsicallySized(PRBool& aResult)
{
aResult = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::SetTitle(const PRUnichar* aTitle)
{
EnsureWebBrowserChrome();
return mWebBrowserChrome->SetTitle(aTitle);
}
NS_IMETHODIMP
nsBrowserWindow::GetTitle(PRUnichar** aResult)
{
*aResult = mTitle.ToNewUnicode();
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::SetStatus(const PRUnichar* aStatus)
{
if (nsnull != mStatus) {
PRUint32 size;
mStatus->SetText(aStatus,size);
}
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::GetStatus(const PRUnichar** aResult)
{
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::SetDefaultStatus(const PRUnichar* aStatus)
{
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::GetDefaultStatus(const PRUnichar** aResult)
{
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsBrowserWindow::SetProgress(PRInt32 aProgress, PRInt32 aProgressMax) nsBrowserWindow::SetProgress(PRInt32 aProgress, PRInt32 aProgressMax)
{ {
@ -1881,7 +2000,7 @@ nsBrowserWindow::NewWebShell(PRUint32 aChromeMask,
{ {
// Default is to startup hidden // Default is to startup hidden
if (aVisible) { if (aVisible) {
browser->Show(); browser->SetVisibility(PR_TRUE);
} }
nsIWebShell *shell; nsIWebShell *shell;
rv = browser->GetWebShell(shell); rv = browser->GetWebShell(shell);
@ -1889,7 +2008,7 @@ nsBrowserWindow::NewWebShell(PRUint32 aChromeMask,
} }
else else
{ {
browser->Close(); browser->Destroy();
} }
} }
else else
@ -2318,8 +2437,8 @@ nsBrowserWindow::ShowPrintPreview(PRInt32 aID)
nsBrowserWindow* bw = new nsNativeBrowserWindow; nsBrowserWindow* bw = new nsNativeBrowserWindow;
bw->SetApp(mApp); bw->SetApp(mApp);
bw->Init(mAppShell, nsRect(0, 0, 600, 400), bw->Init(mAppShell, nsRect(0, 0, 600, 400),
NS_CHROME_MENU_BAR_ON, PR_TRUE, docv, printContext); nsIWebBrowserChrome::menuBarOn, PR_TRUE, docv, printContext);
bw->Show(); bw->SetVisibility(PR_TRUE);
NS_RELEASE(printContext); NS_RELEASE(printContext);
} }
@ -3438,107 +3557,4 @@ NS_IMETHODIMP nsBrowserWindow::EnsureWebBrowserChrome()
return NS_OK; return NS_OK;
} }
//----------------------------------------------------------------------
// Factory code for creating nsBrowserWindow's
class nsBrowserWindowFactory : public nsIFactory
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIFACTORY
nsBrowserWindowFactory();
virtual ~nsBrowserWindowFactory();
};
nsBrowserWindowFactory::nsBrowserWindowFactory()
{
NS_INIT_REFCNT();
}
nsBrowserWindowFactory::~nsBrowserWindowFactory()
{
}
nsresult
nsBrowserWindowFactory::QueryInterface(const nsIID &aIID, void **aResult)
{
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
// Always NULL result, in case of failure
*aResult = NULL;
if (aIID.Equals(kISupportsIID)) {
*aResult = (void *)(nsISupports*)this;
} else if (aIID.Equals(kIFactoryIID)) {
*aResult = (void *)(nsIFactory*)this;
}
if (*aResult == NULL) {
return NS_NOINTERFACE;
}
NS_ADDREF_THIS(); // Increase reference count for caller
return NS_OK;
}
NS_IMPL_ADDREF(nsBrowserWindowFactory);
NS_IMPL_RELEASE(nsBrowserWindowFactory);
nsresult
nsBrowserWindowFactory::CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult)
{
nsresult rv;
nsBrowserWindow *inst;
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
*aResult = NULL;
if (nsnull != aOuter) {
rv = NS_ERROR_NO_AGGREGATION;
goto done;
}
NS_NEWXPCOM(inst, nsNativeBrowserWindow);
if (inst == NULL) {
rv = NS_ERROR_OUT_OF_MEMORY;
goto done;
}
NS_ADDREF(inst);
rv = inst->QueryInterface(aIID, aResult);
NS_RELEASE(inst);
done:
return rv;
}
nsresult
nsBrowserWindowFactory::LockFactory(PRBool aLock)
{
// Not implemented in simplest case.
return NS_OK;
}
nsresult NS_NewBrowserWindowFactory(nsIFactory** aFactory);
nsresult
NS_NewBrowserWindowFactory(nsIFactory** aFactory)
{
nsresult rv = NS_OK;
nsBrowserWindowFactory* inst;
NS_NEWXPCOM(inst, nsBrowserWindowFactory);
if (nsnull == inst) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
else {
NS_ADDREF(inst);
}
*aFactory = inst;
return rv;
}

Просмотреть файл

@ -25,9 +25,13 @@
// Local Includes // Local Includes
#include "nsWebBrowserChrome.h" #include "nsWebBrowserChrome.h"
// Helper Classes
// Interfaces Needed
#include "nsIBaseWindow.h"
#include "nsIWebBrowser.h" #include "nsIWebBrowser.h"
#include "nsIBrowserWindow.h"
#include "nsIStreamListener.h" #include "nsIStreamListener.h"
#include "nsIProgressEventSink.h" #include "nsIProgressEventSink.h"
#include "nsIWebShell.h" #include "nsIWebShell.h"
@ -62,7 +66,7 @@ class nsWebCrawler;
/** /**
* Abstract base class for our test app's browser windows * Abstract base class for our test app's browser windows
*/ */
class nsBrowserWindow : public nsIBrowserWindow, class nsBrowserWindow : public nsIBaseWindow,
public nsIDocumentLoaderObserver, public nsIDocumentLoaderObserver,
public nsIProgressEventSink, public nsIProgressEventSink,
public nsIWebShellContainer, public nsIWebShellContainer,
@ -76,6 +80,14 @@ public:
// nsISupports // nsISupports
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
// nsIBaseWindow
NS_DECL_NSIBASEWINDOW
protected:
void DestroyWidget(nsISupports* aWidget);
public:
// nsIBrowserWindow // nsIBrowserWindow
NS_IMETHOD Init(nsIAppShell* aAppShell, NS_IMETHOD Init(nsIAppShell* aAppShell,
const nsRect& aBounds, const nsRect& aBounds,
@ -92,20 +104,9 @@ public:
PRBool aWidthTransient, PRBool aHeightTransient); PRBool aWidthTransient, PRBool aHeightTransient);
NS_IMETHOD GetContentBounds(nsRect& aBounds); NS_IMETHOD GetContentBounds(nsRect& aBounds);
NS_IMETHOD GetWindowBounds(nsRect& aBounds); NS_IMETHOD GetWindowBounds(nsRect& aBounds);
NS_IMETHOD IsIntrinsicallySized(PRBool& aResult);
NS_IMETHOD ShowAfterCreation() { return Show(); }
NS_IMETHOD Show();
NS_IMETHOD Hide();
NS_IMETHOD Close();
NS_IMETHOD ShowModally(PRBool aPrepare); NS_IMETHOD ShowModally(PRBool aPrepare);
NS_IMETHOD SetChrome(PRUint32 aNewChromeMask); NS_IMETHOD SetChrome(PRUint32 aNewChromeMask);
NS_IMETHOD GetChrome(PRUint32& aChromeMaskResult); NS_IMETHOD GetChrome(PRUint32& aChromeMaskResult);
NS_IMETHOD SetTitle(const PRUnichar* aTitle);
NS_IMETHOD GetTitle(PRUnichar** aResult);
NS_IMETHOD SetStatus(const PRUnichar* aStatus);
NS_IMETHOD GetStatus(const PRUnichar** aResult);
NS_IMETHOD SetDefaultStatus(const PRUnichar* aStatus);
NS_IMETHOD GetDefaultStatus(const PRUnichar** aResult);
NS_IMETHOD SetProgress(PRInt32 aProgress, PRInt32 aProgressMax); NS_IMETHOD SetProgress(PRInt32 aProgress, PRInt32 aProgressMax);
NS_IMETHOD ShowMenuBar(PRBool aShow); NS_IMETHOD ShowMenuBar(PRBool aShow);
NS_IMETHOD GetWebShell(nsIWebShell*& aResult); NS_IMETHOD GetWebShell(nsIWebShell*& aResult);

Просмотреть файл

@ -174,9 +174,9 @@ void nsNativeViewerApp::DispatchMenuItemWithoutWindow(PRInt32 menuResult)
gTheApp->OpenWindow(); gTheApp->OpenWindow();
break; break;
case cmd_Open: case cmd_Open:
nsIBrowserWindow * newWindow; nsBrowserWindow * newWindow;
gTheApp->OpenWindow((PRUint32)0, newWindow); gTheApp->OpenWindow((PRUint32)0, newWindow);
((nsBrowserWindow*)newWindow)->DoFileOpen(); newWindow->DoFileOpen();
break; break;
case cmd_Quit: case cmd_Quit:
gTheApp->Exit(); gTheApp->Exit();

Просмотреть файл

@ -98,21 +98,18 @@
#include <fullsoft.h> #include <fullsoft.h>
#endif #endif
extern nsresult NS_NewBrowserWindowFactory(nsIFactory** aFactory);
extern nsresult NS_NewXPBaseWindowFactory(nsIFactory** aFactory); extern nsresult NS_NewXPBaseWindowFactory(nsIFactory** aFactory);
extern "C" void NS_SetupRegistry(); extern "C" void NS_SetupRegistry();
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_IID(kAppShellCID, NS_APPSHELL_CID); static NS_DEFINE_IID(kAppShellCID, NS_APPSHELL_CID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_IID(kBrowserWindowCID, NS_BROWSER_WINDOW_CID);
static NS_DEFINE_IID(kXPBaseWindowCID, NS_XPBASE_WINDOW_CID); static NS_DEFINE_IID(kXPBaseWindowCID, NS_XPBASE_WINDOW_CID);
static NS_DEFINE_IID(kCookieServiceCID, NS_COOKIESERVICE_CID); static NS_DEFINE_IID(kCookieServiceCID, NS_COOKIESERVICE_CID);
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID); static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
static NS_DEFINE_IID(kIAppShellIID, NS_IAPPSHELL_IID); static NS_DEFINE_IID(kIAppShellIID, NS_IAPPSHELL_IID);
static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID); static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID);
static NS_DEFINE_IID(kIBrowserWindowIID, NS_IBROWSER_WINDOW_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIXPBaseWindowIID, NS_IXPBASE_WINDOW_IID); static NS_DEFINE_IID(kIXPBaseWindowIID, NS_IXPBASE_WINDOW_IID);
@ -280,10 +277,6 @@ nsViewerApp::SetupRegistry()
// Register our browser window factory // Register our browser window factory
nsIFactory* bwf; nsIFactory* bwf;
NS_NewBrowserWindowFactory(&bwf);
nsComponentManager::RegisterFactory(kBrowserWindowCID, 0, 0, bwf, PR_FALSE);
NS_RELEASE(bwf);
NS_NewXPBaseWindowFactory(&bwf); NS_NewXPBaseWindowFactory(&bwf);
nsComponentManager::RegisterFactory(kXPBaseWindowCID, 0, 0, bwf, PR_FALSE); nsComponentManager::RegisterFactory(kXPBaseWindowCID, 0, 0, bwf, PR_FALSE);
NS_RELEASE(bwf); NS_RELEASE(bwf);
@ -694,19 +687,16 @@ nsViewerApp::OpenWindow()
// XXX Some piece of code needs to properly hold the reference to this // XXX Some piece of code needs to properly hold the reference to this
// browser window. For the time being the reference is released by the // browser window. For the time being the reference is released by the
// browser event handling code during processing of the NS_DESTROY event... // browser event handling code during processing of the NS_DESTROY event...
nsBrowserWindow* bw = nsnull; nsBrowserWindow* bw = new nsNativeBrowserWindow();
nsresult rv = nsComponentManager::CreateInstance(kBrowserWindowCID, nsnull, NS_ENSURE_TRUE(bw, NS_ERROR_FAILURE);
kIBrowserWindowIID, NS_ADDREF(bw);
(void**) &bw);
if (NS_FAILED(rv)) {
return rv;
}
bw->SetApp(this); bw->SetApp(this);
bw->SetShowLoadTimes(mShowLoadTimes); bw->SetShowLoadTimes(mShowLoadTimes);
bw->Init(mAppShell, nsRect(0, 0, mWidth, mHeight), bw->Init(mAppShell, nsRect(0, 0, mWidth, mHeight),
PRUint32(~0), mAllowPlugins); PRUint32(~0), mAllowPlugins);
bw->Show(); bw->SetVisibility(PR_TRUE);
nsIBrowserWindow* bwCurrent; nsBrowserWindow* bwCurrent;
mCrawler->GetBrowserWindow(&bwCurrent); mCrawler->GetBrowserWindow(&bwCurrent);
if (!bwCurrent) { if (!bwCurrent) {
mCrawler->SetBrowserWindow(bw); mCrawler->SetBrowserWindow(bw);
@ -745,8 +735,8 @@ nsViewerApp::OpenWindow()
NS_IMETHODIMP NS_IMETHODIMP
nsViewerApp::CloseWindow(nsBrowserWindow* aBrowserWindow) nsViewerApp::CloseWindow(nsBrowserWindow* aBrowserWindow)
{ {
aBrowserWindow->Close(); aBrowserWindow->Destroy();
nsIBrowserWindow* bw; nsBrowserWindow* bw;
mCrawler->GetBrowserWindow(&bw); mCrawler->GetBrowserWindow(&bw);
if (bw == aBrowserWindow) { if (bw == aBrowserWindow) {
mCrawler->SetBrowserWindow(nsnull); mCrawler->SetBrowserWindow(nsnull);
@ -764,18 +754,15 @@ nsViewerApp::ViewSource(nsString& aURL)
// XXX Some piece of code needs to properly hold the reference to this // XXX Some piece of code needs to properly hold the reference to this
// browser window. For the time being the reference is released by the // browser window. For the time being the reference is released by the
// browser event handling code during processing of the NS_DESTROY event... // browser event handling code during processing of the NS_DESTROY event...
nsBrowserWindow* bw = nsnull; nsBrowserWindow* bw = new nsNativeBrowserWindow();
nsresult rv = nsComponentManager::CreateInstance(kBrowserWindowCID, nsnull, NS_ENSURE_TRUE(bw, NS_ERROR_FAILURE);
kIBrowserWindowIID, NS_ADDREF(bw);
(void**) &bw);
if (NS_FAILED(rv)) {
return rv;
}
bw->SetApp(this); bw->SetApp(this);
bw->Init(mAppShell, nsRect(0, 0, 620, 400), PRUint32(~0), mAllowPlugins); bw->Init(mAppShell, nsRect(0, 0, 620, 400), PRUint32(~0), mAllowPlugins);
bw->mDocShell->SetViewMode(nsIDocShell::viewSource); bw->mDocShell->SetViewMode(nsIDocShell::viewSource);
bw->SetTitle(nsAutoString("View Source").GetUnicode()); bw->SetTitle(nsAutoString("View Source").GetUnicode());
bw->Show(); bw->SetVisibility(PR_TRUE);
bw->GoTo(aURL.GetUnicode(),"view-source"); bw->GoTo(aURL.GetUnicode(),"view-source");
NS_RELEASE(bw); NS_RELEASE(bw);
@ -783,16 +770,13 @@ nsViewerApp::ViewSource(nsString& aURL)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsViewerApp::OpenWindow(PRUint32 aNewChromeMask, nsIBrowserWindow*& aNewWindow) nsViewerApp::OpenWindow(PRUint32 aNewChromeMask, nsBrowserWindow*& aNewWindow)
{ {
// Create browser window // Create browser window
nsBrowserWindow* bw = nsnull; nsBrowserWindow* bw = new nsNativeBrowserWindow();
nsresult rv = nsComponentManager::CreateInstance(kBrowserWindowCID, nsnull, NS_ENSURE_TRUE(bw, NS_ERROR_FAILURE);
kIBrowserWindowIID, NS_ADDREF(bw);
(void**) &bw);
if (NS_FAILED(rv)) {
return rv;
}
bw->SetApp(this); bw->SetApp(this);
bw->Init(mAppShell, nsRect(0, 0, 620, 400), aNewChromeMask, mAllowPlugins); bw->Init(mAppShell, nsRect(0, 0, 620, 400), aNewChromeMask, mAllowPlugins);

Просмотреть файл

@ -31,7 +31,6 @@
class nsIEventQueueService; class nsIEventQueueService;
class nsIPref; class nsIPref;
class nsBrowserWindow; class nsBrowserWindow;
class nsIBrowserWindow;
class nsViewerApp : public nsISupports, public nsDispatchListener class nsViewerApp : public nsISupports, public nsDispatchListener
{ {
@ -53,7 +52,7 @@ public:
NS_IMETHOD OpenWindow(); NS_IMETHOD OpenWindow();
NS_IMETHOD CloseWindow(nsBrowserWindow* aBrowserWindow); NS_IMETHOD CloseWindow(nsBrowserWindow* aBrowserWindow);
NS_IMETHOD ViewSource(nsString& aURL); NS_IMETHOD ViewSource(nsString& aURL);
NS_IMETHOD OpenWindow(PRUint32 aNewChromeMask, nsIBrowserWindow*& aNewWindow); NS_IMETHOD OpenWindow(PRUint32 aNewChromeMask, nsBrowserWindow*& aNewWindow);
NS_IMETHOD CreateRobot(nsBrowserWindow* aWindow); NS_IMETHOD CreateRobot(nsBrowserWindow* aWindow);
NS_IMETHOD CreateSiteWalker(nsBrowserWindow* aWindow); NS_IMETHOD CreateSiteWalker(nsBrowserWindow* aWindow);
NS_IMETHOD CreateJSConsole(nsBrowserWindow* aWindow); NS_IMETHOD CreateJSConsole(nsBrowserWindow* aWindow);

Просмотреть файл

@ -23,6 +23,8 @@
// Local Includes // Local Includes
#include "nsWebBrowserChrome.h" #include "nsWebBrowserChrome.h"
#include "nsBrowserWindow.h" #include "nsBrowserWindow.h"
#include "nsWebCrawler.h"
#include "nsViewerApp.h"
// Helper Classes // Helper Classes
#include "nsIGenericFactory.h" #include "nsIGenericFactory.h"
@ -30,6 +32,7 @@
// Interfaces needed to be included // Interfaces needed to be included
#include "nsIDocShellTreeItem.h"
// CIDs // CIDs
@ -126,8 +129,22 @@ NS_IMETHODIMP nsWebBrowserChrome::GetChromeMask(PRUint32* aChromeMask)
NS_IMETHODIMP nsWebBrowserChrome::GetNewBrowser(PRUint32 aChromeMask, NS_IMETHODIMP nsWebBrowserChrome::GetNewBrowser(PRUint32 aChromeMask,
nsIWebBrowser** aWebBrowser) nsIWebBrowser** aWebBrowser)
{ {
NS_ERROR("Haven't Implemented this yet"); if(mBrowserWindow->mWebCrawler && (mBrowserWindow->mWebCrawler->Crawling() ||
return NS_ERROR_FAILURE; mBrowserWindow->mWebCrawler->LoadingURLList()))
{
// Do not fly javascript popups when we are crawling
*aWebBrowser = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
nsBrowserWindow* browser = nsnull;
mBrowserWindow->mApp->OpenWindow(aChromeMask, browser);
NS_ENSURE_TRUE(browser, NS_ERROR_FAILURE);
*aWebBrowser = browser->mWebBrowser;
NS_IF_ADDREF(*aWebBrowser);
return NS_OK;
} }
NS_IMETHODIMP nsWebBrowserChrome::FindNamedBrowserChrome(const PRUnichar* aName, NS_IMETHODIMP nsWebBrowserChrome::FindNamedBrowserChrome(const PRUnichar* aName,
@ -188,8 +205,23 @@ NS_IMETHODIMP nsWebBrowserChrome::ShowModal()
NS_IMETHODIMP nsWebBrowserChrome::GetNewWindow(PRInt32 aChromeFlags, NS_IMETHODIMP nsWebBrowserChrome::GetNewWindow(PRInt32 aChromeFlags,
nsIDocShellTreeItem** aDocShellTreeItem) nsIDocShellTreeItem** aDocShellTreeItem)
{ {
NS_ERROR("Haven't Implemented this yet"); if(mBrowserWindow->mWebCrawler && (mBrowserWindow->mWebCrawler->Crawling() ||
return NS_ERROR_FAILURE; mBrowserWindow->mWebCrawler->LoadingURLList()))
{
// Do not fly javascript popups when we are crawling
*aDocShellTreeItem = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
nsBrowserWindow* browser = nsnull;
mBrowserWindow->mApp->OpenWindow(nsIWebBrowserChrome::allChrome, browser);
NS_ENSURE_TRUE(browser, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocShellTreeItem> newDocShellAsItem(do_QueryInterface(browser->mDocShell));
*aDocShellTreeItem = newDocShellAsItem;
NS_IF_ADDREF(*aDocShellTreeItem);
return NS_OK;
} }
//***************************************************************************** //*****************************************************************************
@ -213,64 +245,57 @@ NS_IMETHODIMP nsWebBrowserChrome::Create()
NS_IMETHODIMP nsWebBrowserChrome::Destroy() NS_IMETHODIMP nsWebBrowserChrome::Destroy()
{ {
NS_ASSERTION(PR_FALSE, "You can't call this"); return mBrowserWindow->Destroy();
return NS_ERROR_UNEXPECTED;
} }
NS_IMETHODIMP nsWebBrowserChrome::SetPosition(PRInt32 x, PRInt32 y) NS_IMETHODIMP nsWebBrowserChrome::SetPosition(PRInt32 aX, PRInt32 aY)
{ {
//XXX First Check In PRInt32 cx=0;
NS_ASSERTION(PR_FALSE, "Not Yet Implemented"); PRInt32 cy=0;
NS_ENSURE_SUCCESS(GetSize(&cx, &cy), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(SetPositionAndSize(aX, aY, cx, cy, PR_FALSE),
NS_ERROR_FAILURE);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsWebBrowserChrome::GetPosition(PRInt32* x, PRInt32* y) NS_IMETHODIMP nsWebBrowserChrome::GetPosition(PRInt32* aX, PRInt32* aY)
{ {
NS_ENSURE_ARG_POINTER(x && y); return GetPositionAndSize(aX, aY, nsnull, nsnull);
}
NS_IMETHODIMP nsWebBrowserChrome::SetSize(PRInt32 aCX, PRInt32 aCY, PRBool aRepaint)
{
PRInt32 x=0;
PRInt32 y=0;
NS_ENSURE_SUCCESS(GetPosition(&x, &y), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(SetPositionAndSize(x, y, aCX, aCY, aRepaint),
NS_ERROR_FAILURE);
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsWebBrowserChrome::SetSize(PRInt32 cx, PRInt32 cy, PRBool fRepaint) NS_IMETHODIMP nsWebBrowserChrome::GetSize(PRInt32* aCX, PRInt32* aCY)
{ {
//XXX First Check In return GetPositionAndSize(nsnull, nsnull, aCX, aCY);
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
} }
NS_IMETHODIMP nsWebBrowserChrome::GetSize(PRInt32* cx, PRInt32* cy) NS_IMETHODIMP nsWebBrowserChrome::SetPositionAndSize(PRInt32 aX, PRInt32 aY,
PRInt32 aCX, PRInt32 aCY, PRBool aRepaint)
{ {
NS_ENSURE_ARG_POINTER(cx && cy); return mBrowserWindow->SetPositionAndSize(aX, aY, aCX, aCY, aRepaint);
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
} }
NS_IMETHODIMP nsWebBrowserChrome::SetPositionAndSize(PRInt32 x, PRInt32 y, PRInt32 cx, NS_IMETHODIMP nsWebBrowserChrome::GetPositionAndSize(PRInt32* aX, PRInt32* aY,
PRInt32 cy, PRBool fRepaint) PRInt32* aCX, PRInt32* aCY)
{ {
//XXX First Check In return mBrowserWindow->GetPositionAndSize(aX, aY, aCX, aCY);
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
}
NS_IMETHODIMP nsWebBrowserChrome::GetPositionAndSize(PRInt32* x, PRInt32* y, PRInt32* cx,
PRInt32* cy)
{
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
} }
NS_IMETHODIMP nsWebBrowserChrome::Repaint(PRBool aForce) NS_IMETHODIMP nsWebBrowserChrome::Repaint(PRBool aForce)
{ {
//XXX First Check In return mBrowserWindow->Repaint(aForce);
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
} }
NS_IMETHODIMP nsWebBrowserChrome::GetParentWidget(nsIWidget** aParentWidget) NS_IMETHODIMP nsWebBrowserChrome::GetParentWidget(nsIWidget** aParentWidget)
@ -304,18 +329,12 @@ NS_IMETHODIMP nsWebBrowserChrome::SetParentNativeWindow(nativeWindow aParentNati
NS_IMETHODIMP nsWebBrowserChrome::GetVisibility(PRBool* aVisibility) NS_IMETHODIMP nsWebBrowserChrome::GetVisibility(PRBool* aVisibility)
{ {
NS_ENSURE_ARG_POINTER(aVisibility); return mBrowserWindow->GetVisibility(aVisibility);
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
} }
NS_IMETHODIMP nsWebBrowserChrome::SetVisibility(PRBool aVisibility) NS_IMETHODIMP nsWebBrowserChrome::SetVisibility(PRBool aVisibility)
{ {
//XXX First Check In return mBrowserWindow->SetVisibility(aVisibility);
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
} }
NS_IMETHODIMP nsWebBrowserChrome::GetMainWidget(nsIWidget** aMainWidget) NS_IMETHODIMP nsWebBrowserChrome::GetMainWidget(nsIWidget** aMainWidget)
@ -328,40 +347,30 @@ NS_IMETHODIMP nsWebBrowserChrome::GetMainWidget(nsIWidget** aMainWidget)
} }
NS_IMETHODIMP nsWebBrowserChrome::SetFocus() NS_IMETHODIMP nsWebBrowserChrome::SetFocus()
{ {
//XXX First Check In return mBrowserWindow->SetFocus();
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
} }
NS_IMETHODIMP nsWebBrowserChrome::FocusAvailable(nsIBaseWindow* aCurrentFocus, NS_IMETHODIMP nsWebBrowserChrome::FocusAvailable(nsIBaseWindow* aCurrentFocus,
PRBool* aTookFocus) PRBool* aTookFocus)
{ {
//XXX First Check In return mBrowserWindow->FocusAvailable(aCurrentFocus, aTookFocus);
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
} }
NS_IMETHODIMP nsWebBrowserChrome::GetTitle(PRUnichar** aTitle) NS_IMETHODIMP nsWebBrowserChrome::GetTitle(PRUnichar** aTitle)
{ {
NS_ENSURE_ARG_POINTER(aTitle); return mBrowserWindow->GetTitle(aTitle);
//XXX First Check In
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
return NS_OK;
} }
NS_IMETHODIMP nsWebBrowserChrome::SetTitle(const PRUnichar* aTitle) NS_IMETHODIMP nsWebBrowserChrome::SetTitle(const PRUnichar* aTitle)
{ {
NS_ENSURE_STATE(mBrowserWindow->mWindow);
mBrowserWindow->mTitle = aTitle; mBrowserWindow->mTitle = aTitle;
nsAutoString newTitle(aTitle); nsAutoString newTitle(aTitle);
newTitle.Append(" - Raptor"); newTitle.Append(" - Raptor");
mBrowserWindow->mWindow->SetTitle(newTitle); mBrowserWindow->SetTitle(newTitle.GetUnicode());
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -24,7 +24,6 @@
#include "nsWebCrawler.h" #include "nsWebCrawler.h"
#include "nsViewerApp.h" #include "nsViewerApp.h"
#include "nsIWebShell.h" #include "nsIWebShell.h"
#include "nsIBrowserWindow.h"
#include "nsIContentViewer.h" #include "nsIContentViewer.h"
#include "nsIDocumentViewer.h" #include "nsIDocumentViewer.h"
#include "nsIDocument.h" #include "nsIDocument.h"
@ -778,7 +777,7 @@ nsWebCrawler::FindMoreURLs()
} }
void void
nsWebCrawler::SetBrowserWindow(nsIBrowserWindow* aWindow) nsWebCrawler::SetBrowserWindow(nsBrowserWindow* aWindow)
{ {
NS_IF_RELEASE(mBrowser); NS_IF_RELEASE(mBrowser);
mBrowser = aWindow; mBrowser = aWindow;
@ -786,7 +785,7 @@ nsWebCrawler::SetBrowserWindow(nsIBrowserWindow* aWindow)
} }
void void
nsWebCrawler::GetBrowserWindow(nsIBrowserWindow** aWindow) nsWebCrawler::GetBrowserWindow(nsBrowserWindow** aWindow)
{ {
NS_IF_ADDREF(mBrowser); NS_IF_ADDREF(mBrowser);
*aWindow = mBrowser; *aWindow = mBrowser;

Просмотреть файл

@ -23,7 +23,7 @@
#define nsWebCrawler_h___ #define nsWebCrawler_h___
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIBrowserWindow.h" #include "nsBrowserWindow.h"
#include "nsIDocumentLoader.h" #include "nsIDocumentLoader.h"
#include "nsIDocumentLoaderObserver.h" #include "nsIDocumentLoaderObserver.h"
#include "nsVoidArray.h" #include "nsVoidArray.h"
@ -59,8 +59,8 @@ public:
// Add a domain that must be avoided // Add a domain that must be avoided
void AddAvoidDomain(const nsString& aDomain); void AddAvoidDomain(const nsString& aDomain);
void SetBrowserWindow(nsIBrowserWindow* aWindow); void SetBrowserWindow(nsBrowserWindow* aWindow);
void GetBrowserWindow(nsIBrowserWindow** aWindow); void GetBrowserWindow(nsBrowserWindow** aWindow);
// Set the delay (by default, the timer is set to one second) // Set the delay (by default, the timer is set to one second)
void SetDelay(PRInt32 aSeconds) { void SetDelay(PRInt32 aSeconds) {
@ -143,7 +143,7 @@ protected:
void PerformRegressionTest(const nsString& aOutputName); void PerformRegressionTest(const nsString& aOutputName);
nsCOMPtr<nsIDocumentLoader> mDocLoader; nsCOMPtr<nsIDocumentLoader> mDocLoader;
nsIBrowserWindow* mBrowser; nsBrowserWindow* mBrowser;
nsViewerApp* mViewer; nsViewerApp* mViewer;
nsITimer* mTimer; nsITimer* mTimer;
FILE* mRecord; FILE* mRecord;