Remove #ifndef NECKO around the alert and replace nsINetSupport with nsIPrompt

This commit is contained in:
davidm%netscape.com 1999-08-11 03:05:25 +00:00
Родитель 34446224ea
Коммит 95e413cf5a
2 изменённых файлов: 133 добавлений и 83 удалений

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

@ -174,12 +174,9 @@ static NS_DEFINE_IID(kIUrlDispatcherIID, NS_IURLDISPATCHER_IID);
#ifdef DEBUG_rods
#define DEBUG_MENUSDEL 1
#endif
#ifndef NECKO
static NS_DEFINE_IID(kINetSupportIID, NS_INETSUPPORT_IID);
#include "nsINetSupportDialogService.h"
static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
#endif
#include "nsICommonDialogs.h"
static NS_DEFINE_CID( kCommonDialogsCID, NS_CommonDialog_CID );
static NS_DEFINE_IID( kIPromptIID, NS_IPROMPT_IID );
#include "nsIWebShell.h"
const char * kThrobberOnStr = "resource:/res/throbber/anims07.gif";
@ -304,13 +301,12 @@ nsWebShellWindow::QueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_ADDREF_THIS();
return NS_OK;
}
#ifndef NECKO
if (aIID.Equals(kINetSupportIID )) {
*aInstancePtr = (void*)(nsINetSupport*)this;
if (aIID.Equals(kIPromptIID )) {
*aInstancePtr = (void*)(nsIPrompt*)this;
NS_ADDREF_THIS();
return NS_OK;
}
#endif
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*)(nsISupports*)(nsIWebShellContainer*)this;
NS_ADDREF_THIS();
@ -2783,69 +2779,127 @@ nsWebShellWindow::IsIntrinsicallySized(PRBool& aResult)
}
// nsINetSupport
#ifdef NECKO
#else
void nsWebShellWindow::Alert(const nsString &aText)
// nsIPrompt
NS_IMETHODIMP nsWebShellWindow::Alert(const PRUnichar *text)
{
nsresult rv;
NS_WITH_SERVICE(nsINetSupportDialogService, dialog, kNetSupportDialogCID, &rv);
if ( dialog )
dialog->Alert( aText );
}
PRBool nsWebShellWindow::Confirm(const nsString &aText)
{
nsresult rv;
NS_WITH_SERVICE(nsINetSupportDialogService, dialog, kNetSupportDialogCID, &rv);
PRInt32 result = 0;
nsresult rv;
nsCOMPtr<nsIDOMWindow> domWindow;
nsIWebShell* tempWebShell;
GetWebShell(tempWebShell );
nsCOMPtr<nsIWebShell> webShell( dont_AddRef(tempWebShell) );
if (NS_FAILED(rv = ConvertWebShellToDOMWindow(webShell, getter_AddRefs(domWindow))))
{
NS_ERROR("Unable to retrieve the DOM window from the new web shell.");
return rv;
}
if ( dialog )
dialog->Confirm( aText,&result );
return result ? PR_TRUE : PR_FALSE;
NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv);
if ( NS_SUCCEEDED( rv ) )
rv = dialog->Alert( domWindow, text );
return rv;
}
PRBool nsWebShellWindow::Prompt(const nsString &aText,
const nsString &aDefault,
nsString &aResult)
NS_IMETHODIMP nsWebShellWindow::Confirm(const PRUnichar *text, PRBool *_retval)
{
nsresult rv;
NS_WITH_SERVICE(nsINetSupportDialogService, dialog, kNetSupportDialogCID, &rv);
PRInt32 result = 0;
if ( dialog )
nsresult rv;
nsCOMPtr<nsIDOMWindow> domWindow;
nsIWebShell* tempWebShell;
GetWebShell(tempWebShell );
nsCOMPtr<nsIWebShell> webShell( dont_AddRef(tempWebShell) );
if (NS_FAILED(rv = ConvertWebShellToDOMWindow(webShell, getter_AddRefs(domWindow))))
{
dialog->Prompt( aText, aDefault, aResult,&result );
}
return result ? PR_TRUE : PR_FALSE;
NS_ERROR("Unable to retrieve the DOM window from the new web shell.");
return rv;
}
NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv);
if ( NS_SUCCEEDED( rv ) )
rv = dialog->Confirm( domWindow, text, _retval );
return rv;
}
PRBool nsWebShellWindow::PromptUserAndPassword(
const nsString &aText, nsString &aUser, nsString &aPassword)
NS_IMETHODIMP nsWebShellWindow::ConfirmCheck(const PRUnichar *text, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
{
nsresult rv;
NS_WITH_SERVICE(nsINetSupportDialogService, dialog, kNetSupportDialogCID, &rv);
PRInt32 result = 0;
if ( dialog )
nsresult rv;
nsCOMPtr<nsIDOMWindow> domWindow;
nsIWebShell* tempWebShell;
GetWebShell(tempWebShell );
nsCOMPtr<nsIWebShell> webShell( dont_AddRef(tempWebShell) );
if (NS_FAILED(rv = ConvertWebShellToDOMWindow(webShell, getter_AddRefs(domWindow))))
{
dialog->PromptUserAndPassword( aText, aUser, aPassword, &result );
}
return result ? PR_TRUE : PR_FALSE;
NS_ERROR("Unable to retrieve the DOM window from the new web shell.");
return rv;
}
NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv);
if ( NS_SUCCEEDED( rv ) )
rv =dialog->ConfirmCheck( domWindow, text, checkMsg, checkValue, _retval );
return rv;
}
PRBool nsWebShellWindow::PromptPassword(const nsString &aText,
nsString &aPassword)
{
nsresult rv;
NS_WITH_SERVICE(nsINetSupportDialogService, dialog, kNetSupportDialogCID, &rv);
PRInt32 result = 0;
if ( dialog )
NS_IMETHODIMP nsWebShellWindow::Prompt(const PRUnichar *text, const PRUnichar *defaultText, PRUnichar **result, PRBool *_retval)
{
nsresult rv;
nsCOMPtr<nsIDOMWindow> domWindow;
nsIWebShell* tempWebShell;
GetWebShell(tempWebShell );
nsCOMPtr<nsIWebShell> webShell( dont_AddRef(tempWebShell) );
if (NS_FAILED(rv = ConvertWebShellToDOMWindow(webShell, getter_AddRefs(domWindow))))
{
dialog->PromptPassword( aText, aPassword, &result );
}
return result ? PR_TRUE : PR_FALSE;
}
#endif
NS_ERROR("Unable to retrieve the DOM window from the new web shell.");
return rv;
}
NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv);
if ( NS_SUCCEEDED( rv ) )
rv = dialog->Prompt( domWindow, text, defaultText, result, _retval );
return rv;
}
NS_IMETHODIMP nsWebShellWindow::PromptUsernameAndPassword(const PRUnichar *text, PRUnichar **user, PRUnichar **pwd, PRBool *_retval)
{
nsresult rv;
nsCOMPtr<nsIDOMWindow> domWindow;
nsIWebShell* tempWebShell;
GetWebShell(tempWebShell );
nsCOMPtr<nsIWebShell> webShell( dont_AddRef(tempWebShell) );
if (NS_FAILED(rv = ConvertWebShellToDOMWindow(webShell, getter_AddRefs(domWindow))))
{
NS_ERROR("Unable to retrieve the DOM window from the new web shell.");
return rv;
}
NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv);
if ( NS_SUCCEEDED( rv ) )
rv = dialog->PromptUsernameAndPassword( domWindow, text, user, pwd, _retval );
return rv;
}
NS_IMETHODIMP nsWebShellWindow::PromptPassword(const PRUnichar *text, PRUnichar **pwd, PRBool *_retval)
{
nsresult rv;
nsCOMPtr<nsIDOMWindow> domWindow;
nsIWebShell* tempWebShell;
GetWebShell(tempWebShell );
nsCOMPtr<nsIWebShell> webShell( dont_AddRef(tempWebShell) );
if (NS_FAILED(rv = ConvertWebShellToDOMWindow(webShell, getter_AddRefs(domWindow))))
{
NS_ERROR("Unable to retrieve the DOM window from the new web shell.");
return rv;
}
NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv);
if ( NS_SUCCEEDED( rv ) )
rv = dialog->PromptPassword( domWindow, text, pwd, _retval );
return rv;
}
NS_IMETHODIMP nsWebShellWindow::ConfirmYN(const PRUnichar *text, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsWebShellWindow::ConfirmCheckYN(const PRUnichar *text, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -30,9 +30,9 @@
#include "nsVoidArray.h"
#include "nsIMenu.h"
#include "nsIUrlDispatcher.h"
#ifndef NECKO
#include "nsINetSupport.h"
#endif
#include "nsIPrompt.h"
// can't use forward class decl's because of template bugs on Solaris
#include "nsIDOMDocument.h"
#include "nsIDOMNode.h"
@ -62,10 +62,9 @@ class nsWebShellWindow : public nsIWebShellWindow,
public nsIDocumentLoaderObserver,
public nsIDocumentObserver,
public nsIUrlDispatcher
#ifdef NECKO
#else
, public nsINetSupport
#endif
, public nsIPrompt
{
public:
nsWebShellWindow();
@ -255,19 +254,16 @@ public:
NS_DECL_IURLDISPATCHER
// nsINetSupport
#if NECKO
#else
NS_IMETHOD_(void) Alert(const nsString &aText);
NS_IMETHOD_(PRBool) Confirm(const nsString &aText);
NS_IMETHOD_(PRBool) Prompt(const nsString &aText,
const nsString &aDefault,
nsString &aResult);
NS_IMETHOD_(PRBool) PromptUserAndPassword(const nsString &aText,
nsString &aUser,
nsString &aPassword);
NS_IMETHOD_(PRBool) PromptPassword(const nsString &aText,
nsString &aPassword);
#endif
NS_IMETHOD Alert(const PRUnichar *text);
NS_IMETHOD Confirm(const PRUnichar *text, PRBool *_retval);
NS_IMETHOD ConfirmCheck(const PRUnichar *text, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval);
NS_IMETHOD Prompt(const PRUnichar *text, const PRUnichar *defaultText, PRUnichar **result, PRBool *_retval);
NS_IMETHOD PromptUsernameAndPassword(const PRUnichar *text, PRUnichar **user, PRUnichar **pwd, PRBool *_retval);
NS_IMETHOD PromptPassword(const PRUnichar *text, PRUnichar **pwd, PRBool *_retval);
NS_IMETHOD ConfirmYN(const PRUnichar *text, PRBool *_retval);
NS_IMETHOD ConfirmCheckYN(const PRUnichar *text, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval);
protected:
PRInt32 GetDocHeight(nsIDocument * aDoc);