1998-07-20 16:19:22 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS"
|
|
|
|
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
|
|
|
* the License for the specific language governing rights and limitations
|
|
|
|
* under the License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape Communications
|
|
|
|
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
|
|
|
* Netscape Communications Corporation. All Rights Reserved.
|
|
|
|
*/
|
1998-07-29 23:43:22 +00:00
|
|
|
#ifdef XP_MAC
|
1998-07-20 21:16:38 +00:00
|
|
|
#include "nsBrowserWindow.h"
|
1998-07-29 21:06:19 +00:00
|
|
|
#define NS_IMPL_IDS
|
1998-07-29 23:43:22 +00:00
|
|
|
#else
|
|
|
|
#define NS_IMPL_IDS
|
|
|
|
#include "nsBrowserWindow.h"
|
|
|
|
#endif
|
1998-07-20 16:19:22 +00:00
|
|
|
#include "nsIStreamListener.h"
|
|
|
|
#include "nsIAppShell.h"
|
|
|
|
#include "nsIWidget.h"
|
|
|
|
#include "nsITextWidget.h"
|
|
|
|
#include "nsIButton.h"
|
|
|
|
#include "nsIImageGroup.h"
|
|
|
|
#include "nsITimer.h"
|
|
|
|
#include "nsIThrobber.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
#include "nsIURL.h"
|
1998-07-21 16:45:21 +00:00
|
|
|
#include "nsIFileWidget.h"
|
1998-07-20 16:19:22 +00:00
|
|
|
#include "nsRepository.h"
|
|
|
|
#include "nsIFactory.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "nsWidgetsCID.h"
|
1998-07-20 21:16:38 +00:00
|
|
|
#include "nsViewerApp.h"
|
1998-07-21 16:45:21 +00:00
|
|
|
#include "prprf.h"
|
1998-07-30 22:42:27 +00:00
|
|
|
#include "nsRepository.h"
|
|
|
|
#include "nsParserCIID.h"
|
1998-07-20 21:16:38 +00:00
|
|
|
|
1998-07-31 16:53:45 +00:00
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIDocumentViewer.h"
|
|
|
|
#include "nsIContentViewer.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsXIFDTD.h"
|
|
|
|
#include "nsIParser.h"
|
|
|
|
#include "nsHTMLContentSinkStream.h"
|
1998-08-07 04:45:03 +00:00
|
|
|
#include "nsEditorMode.h"
|
1998-07-31 16:53:45 +00:00
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
#include "resources.h"
|
1998-07-27 21:10:02 +00:00
|
|
|
|
|
|
|
#if defined(WIN32)
|
1998-07-27 18:17:07 +00:00
|
|
|
#include <strstrea.h>
|
1998-07-29 21:21:08 +00:00
|
|
|
#else
|
1998-07-30 03:38:37 +00:00
|
|
|
#if defined(XP_MAC)
|
|
|
|
#include "ostrstream.h"
|
|
|
|
#else
|
1998-07-30 04:47:44 +00:00
|
|
|
#include <strstream.h>
|
1998-07-30 03:38:37 +00:00
|
|
|
#endif
|
1998-07-27 21:10:02 +00:00
|
|
|
#endif
|
1998-07-27 18:17:07 +00:00
|
|
|
|
|
|
|
#if defined(WIN32)
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
|
1998-07-24 16:03:11 +00:00
|
|
|
// XXX For font setting below
|
|
|
|
#include "nsFont.h"
|
|
|
|
#include "nsUnitConversion.h"
|
|
|
|
#include "nsIDeviceContext.h"
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
// XXX greasy constants
|
|
|
|
#define THROBBER_WIDTH 32
|
|
|
|
#define THROBBER_HEIGHT 32
|
|
|
|
#define BUTTON_WIDTH 90
|
|
|
|
#define BUTTON_HEIGHT THROBBER_HEIGHT
|
1998-08-05 15:11:46 +00:00
|
|
|
#ifdef XP_PC
|
1998-07-24 16:03:11 +00:00
|
|
|
#define STATUS_HEIGHT 24
|
1998-08-05 15:11:46 +00:00
|
|
|
#else
|
|
|
|
#define STATUS_HEIGHT 28
|
|
|
|
#endif
|
1998-07-20 16:19:22 +00:00
|
|
|
#ifdef INSET_WEBSHELL
|
|
|
|
#define WEBSHELL_LEFT_INSET 5
|
|
|
|
#define WEBSHELL_RIGHT_INSET 5
|
|
|
|
#define WEBSHELL_TOP_INSET 5
|
|
|
|
#define WEBSHELL_BOTTOM_INSET 5
|
|
|
|
#else
|
|
|
|
#define WEBSHELL_LEFT_INSET 0
|
|
|
|
#define WEBSHELL_RIGHT_INSET 0
|
|
|
|
#define WEBSHELL_TOP_INSET 0
|
|
|
|
#define WEBSHELL_BOTTOM_INSET 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kBrowserWindowCID, NS_BROWSER_WINDOW_CID);
|
|
|
|
static NS_DEFINE_IID(kButtonCID, NS_BUTTON_CID);
|
1998-07-21 16:45:21 +00:00
|
|
|
static NS_DEFINE_IID(kFileWidgetCID, NS_FILEWIDGET_CID);
|
1998-07-20 16:19:22 +00:00
|
|
|
static NS_DEFINE_IID(kTextFieldCID, NS_TEXTFIELD_CID);
|
|
|
|
static NS_DEFINE_IID(kThrobberCID, NS_THROBBER_CID);
|
|
|
|
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
|
|
|
|
static NS_DEFINE_IID(kWindowCID, NS_WINDOW_CID);
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kIBrowserWindowIID, NS_IBROWSER_WINDOW_IID);
|
|
|
|
static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID);
|
|
|
|
static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID);
|
|
|
|
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
1998-07-21 16:45:21 +00:00
|
|
|
static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID);
|
1998-07-20 16:19:22 +00:00
|
|
|
static NS_DEFINE_IID(kIStreamObserverIID, NS_ISTREAMOBSERVER_IID);
|
|
|
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
|
|
|
static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID);
|
|
|
|
static NS_DEFINE_IID(kIThrobberIID, NS_ITHROBBER_IID);
|
|
|
|
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
|
|
|
|
static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID);
|
|
|
|
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
nsVoidArray nsBrowserWindow::gBrowsers;
|
1998-07-20 16:19:22 +00:00
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
nsBrowserWindow*
|
|
|
|
nsBrowserWindow::FindBrowserFor(nsIWidget* aWidget, PRIntn aWhich)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
1998-08-06 02:21:23 +00:00
|
|
|
nsIWidget* widget;
|
|
|
|
nsBrowserWindow* result = nsnull;
|
1998-07-20 16:19:22 +00:00
|
|
|
|
|
|
|
PRInt32 i, n = gBrowsers.Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
nsBrowserWindow* bw = (nsBrowserWindow*) gBrowsers.ElementAt(i);
|
|
|
|
if (nsnull != bw) {
|
|
|
|
switch (aWhich) {
|
|
|
|
case FIND_WINDOW:
|
|
|
|
bw->mWindow->QueryInterface(kIWidgetIID, (void**) &widget);
|
1998-08-06 02:21:23 +00:00
|
|
|
if (widget == aWidget) {
|
|
|
|
result = bw;
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(widget);
|
1998-07-20 16:19:22 +00:00
|
|
|
break;
|
|
|
|
case FIND_BACK:
|
1998-08-12 21:41:05 +00:00
|
|
|
if (bw->mBack) {
|
|
|
|
bw->mBack->QueryInterface(kIWidgetIID, (void**) &widget);
|
|
|
|
if (widget == aWidget) {
|
|
|
|
result = bw;
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(widget);
|
1998-08-06 02:21:23 +00:00
|
|
|
}
|
1998-07-20 16:19:22 +00:00
|
|
|
break;
|
|
|
|
case FIND_FORWARD:
|
1998-08-12 21:41:05 +00:00
|
|
|
if (bw->mForward) {
|
|
|
|
bw->mForward->QueryInterface(kIWidgetIID, (void**) &widget);
|
|
|
|
if (widget == aWidget) {
|
|
|
|
result = bw;
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(widget);
|
1998-08-06 02:21:23 +00:00
|
|
|
}
|
1998-07-20 16:19:22 +00:00
|
|
|
break;
|
|
|
|
case FIND_LOCATION:
|
1998-08-12 21:41:05 +00:00
|
|
|
if (bw->mLocation) {
|
|
|
|
bw->mLocation->QueryInterface(kIWidgetIID, (void**) &widget);
|
|
|
|
if (widget == aWidget) {
|
|
|
|
result = bw;
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(widget);
|
1998-08-06 02:21:23 +00:00
|
|
|
}
|
1998-07-20 16:19:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-08-06 02:21:23 +00:00
|
|
|
return result;
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::AddBrowser(nsBrowserWindow* aBrowser)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
|
|
|
gBrowsers.AppendElement(aBrowser);
|
|
|
|
}
|
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::RemoveBrowser(nsBrowserWindow* aBrowser)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
|
|
|
gBrowsers.RemoveElement(aBrowser);
|
|
|
|
if (0 == gBrowsers.Count()) {
|
1998-07-20 21:16:38 +00:00
|
|
|
aBrowser->mApp->Exit();
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsEventStatus PR_CALLBACK
|
|
|
|
HandleBrowserEvent(nsGUIEvent *aEvent)
|
|
|
|
{
|
1998-07-20 21:16:38 +00:00
|
|
|
nsBrowserWindow* bw =
|
|
|
|
nsBrowserWindow::FindBrowserFor(aEvent->widget, FIND_WINDOW);
|
1998-07-20 16:19:22 +00:00
|
|
|
if (nsnull == bw) {
|
|
|
|
return nsEventStatus_eIgnore;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSizeEvent* sizeEvent;
|
|
|
|
nsEventStatus result = nsEventStatus_eIgnore;
|
|
|
|
switch(aEvent->message) {
|
|
|
|
case NS_SIZE:
|
|
|
|
sizeEvent = (nsSizeEvent*)aEvent;
|
|
|
|
bw->Layout(sizeEvent->windowSize->width,
|
|
|
|
sizeEvent->windowSize->height);
|
|
|
|
return nsEventStatus_eConsumeNoDefault;
|
|
|
|
|
|
|
|
case NS_DESTROY:
|
|
|
|
bw->Destroy();
|
1998-08-10 18:20:20 +00:00
|
|
|
NS_RELEASE(bw);
|
1998-07-20 16:19:22 +00:00
|
|
|
return nsEventStatus_eConsumeDoDefault;
|
|
|
|
|
1998-07-20 22:13:11 +00:00
|
|
|
case NS_MENU_SELECTED:
|
|
|
|
return bw->DispatchMenuItem(((nsMenuEvent*)aEvent)->menuItem);
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1998-07-20 22:13:11 +00:00
|
|
|
return nsEventStatus_eIgnore;
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsEventStatus PR_CALLBACK
|
|
|
|
HandleBackEvent(nsGUIEvent *aEvent)
|
|
|
|
{
|
1998-07-20 21:16:38 +00:00
|
|
|
nsBrowserWindow* bw =
|
|
|
|
nsBrowserWindow::FindBrowserFor(aEvent->widget, FIND_BACK);
|
1998-07-20 16:19:22 +00:00
|
|
|
if (nsnull == bw) {
|
|
|
|
return nsEventStatus_eIgnore;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(aEvent->message) {
|
|
|
|
case NS_MOUSE_LEFT_BUTTON_UP:
|
|
|
|
bw->Back();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return nsEventStatus_eIgnore;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsEventStatus PR_CALLBACK
|
|
|
|
HandleForwardEvent(nsGUIEvent *aEvent)
|
|
|
|
{
|
1998-07-20 21:16:38 +00:00
|
|
|
nsBrowserWindow* bw =
|
|
|
|
nsBrowserWindow::FindBrowserFor(aEvent->widget, FIND_FORWARD);
|
1998-07-20 16:19:22 +00:00
|
|
|
if (nsnull == bw) {
|
|
|
|
return nsEventStatus_eIgnore;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(aEvent->message) {
|
|
|
|
case NS_MOUSE_LEFT_BUTTON_UP:
|
|
|
|
bw->Forward();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return nsEventStatus_eIgnore;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsEventStatus PR_CALLBACK
|
|
|
|
HandleLocationEvent(nsGUIEvent *aEvent)
|
|
|
|
{
|
1998-07-20 21:16:38 +00:00
|
|
|
nsBrowserWindow* bw =
|
|
|
|
nsBrowserWindow::FindBrowserFor(aEvent->widget, FIND_LOCATION);
|
1998-07-20 16:19:22 +00:00
|
|
|
if (nsnull == bw) {
|
|
|
|
return nsEventStatus_eIgnore;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (aEvent->message) {
|
|
|
|
case NS_KEY_UP:
|
|
|
|
if (NS_VK_RETURN == ((nsKeyEvent*)aEvent)->keyCode) {
|
|
|
|
nsAutoString text;
|
|
|
|
bw->mLocation->GetText(text, 1000);
|
|
|
|
bw->GoTo(text);
|
|
|
|
}
|
|
|
|
break;
|
1998-08-07 04:45:03 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nsEventStatus_eIgnore;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsEventStatus
|
1998-07-20 22:13:11 +00:00
|
|
|
nsBrowserWindow::DispatchMenuItem(PRInt32 aID)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
1998-07-20 22:45:35 +00:00
|
|
|
#ifdef NS_DEBUG
|
1998-07-20 22:13:11 +00:00
|
|
|
nsEventStatus result = DispatchDebugMenu(aID);
|
|
|
|
if (nsEventStatus_eIgnore != result) {
|
|
|
|
return result;
|
|
|
|
}
|
1998-07-20 22:45:35 +00:00
|
|
|
#endif
|
1998-07-20 22:13:11 +00:00
|
|
|
switch (aID) {
|
|
|
|
case VIEWER_EXIT:
|
|
|
|
mApp->Exit();
|
|
|
|
return nsEventStatus_eConsumeNoDefault;
|
|
|
|
|
1998-07-21 16:45:21 +00:00
|
|
|
case VIEWER_FILE_OPEN:
|
|
|
|
DoFileOpen();
|
|
|
|
break;
|
1998-07-27 18:17:07 +00:00
|
|
|
|
|
|
|
case VIEWER_EDIT_COPY:
|
|
|
|
DoCopy();
|
|
|
|
break;
|
1998-07-21 16:45:21 +00:00
|
|
|
|
1998-08-03 22:32:34 +00:00
|
|
|
case VIEWER_EDIT_SELECTALL:
|
|
|
|
DoSelectAll();
|
|
|
|
break;
|
|
|
|
|
1998-07-20 22:13:11 +00:00
|
|
|
case VIEWER_DEMO0:
|
|
|
|
case VIEWER_DEMO1:
|
|
|
|
case VIEWER_DEMO2:
|
|
|
|
case VIEWER_DEMO3:
|
|
|
|
case VIEWER_DEMO4:
|
|
|
|
case VIEWER_DEMO5:
|
|
|
|
case VIEWER_DEMO6:
|
|
|
|
case VIEWER_DEMO7:
|
|
|
|
case VIEWER_DEMO8:
|
|
|
|
case VIEWER_DEMO9:
|
|
|
|
{
|
|
|
|
PRIntn ix = aID - VIEWER_DEMO0;
|
|
|
|
nsAutoString url(SAMPLES_BASE_URL);
|
|
|
|
url.Append("/test");
|
|
|
|
url.Append(ix, 10);
|
|
|
|
url.Append(".html");
|
|
|
|
LoadURL(url);
|
1998-07-20 21:16:38 +00:00
|
|
|
}
|
1998-07-20 22:13:11 +00:00
|
|
|
break;
|
1998-08-07 04:45:03 +00:00
|
|
|
case JS_CONSOLE:
|
|
|
|
DoJSConsole();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EDITOR_MODE:
|
1998-08-14 01:51:00 +00:00
|
|
|
DoEditorMode(mWebShell);
|
1998-08-07 04:45:03 +00:00
|
|
|
break;
|
1998-07-20 21:16:38 +00:00
|
|
|
}
|
1998-08-07 04:45:03 +00:00
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
return nsEventStatus_eIgnore;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::Destroy()
|
|
|
|
{
|
1998-07-27 23:19:06 +00:00
|
|
|
RemoveBrowser(this);
|
|
|
|
if (nsnull != mWebShell) {
|
1998-07-29 10:49:51 +00:00
|
|
|
mWebShell->Destroy();
|
1998-07-27 23:19:06 +00:00
|
|
|
NS_RELEASE(mWebShell);
|
|
|
|
}
|
1998-08-03 21:11:22 +00:00
|
|
|
|
1998-08-06 02:21:23 +00:00
|
|
|
NS_IF_RELEASE(mWindow);
|
1998-08-05 22:06:58 +00:00
|
|
|
NS_IF_RELEASE(mBack);
|
|
|
|
NS_IF_RELEASE(mForward);
|
|
|
|
NS_IF_RELEASE(mLocation);
|
1998-08-03 21:11:22 +00:00
|
|
|
NS_IF_RELEASE(mThrobber);
|
1998-08-06 02:21:23 +00:00
|
|
|
NS_IF_RELEASE(mStatus);
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::Back()
|
|
|
|
{
|
1998-07-22 11:26:18 +00:00
|
|
|
mWebShell->Back();
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::Forward()
|
|
|
|
{
|
1998-07-22 11:26:18 +00:00
|
|
|
mWebShell->Forward();
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-08-14 23:08:54 +00:00
|
|
|
nsBrowserWindow::GoTo(const PRUnichar* aURL)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
1998-07-22 11:26:18 +00:00
|
|
|
mWebShell->LoadURL(aURL, nsnull);
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
1998-07-21 16:45:21 +00:00
|
|
|
#define FILE_PROTOCOL "file://"
|
|
|
|
|
|
|
|
static PRBool GetFileNameFromFileSelector(nsIWidget* aParentWindow,
|
|
|
|
nsString* aFileName)
|
|
|
|
{
|
|
|
|
PRBool selectedFileName = PR_FALSE;
|
|
|
|
nsIFileWidget *fileWidget;
|
|
|
|
nsString title("Open HTML");
|
|
|
|
nsresult rv = NSRepository::CreateInstance(kFileWidgetCID,
|
|
|
|
nsnull,
|
|
|
|
kIFileWidgetIID,
|
|
|
|
(void**)&fileWidget);
|
|
|
|
if (NS_OK == rv) {
|
|
|
|
nsString titles[] = {"all files","html" };
|
|
|
|
nsString filters[] = {"*.*", "*.html"};
|
|
|
|
fileWidget->SetFilterList(2, titles, filters);
|
|
|
|
fileWidget->Create(aParentWindow,
|
|
|
|
title,
|
|
|
|
eMode_load,
|
|
|
|
nsnull,
|
|
|
|
nsnull);
|
|
|
|
|
|
|
|
PRUint32 result = fileWidget->Show();
|
|
|
|
if (result) {
|
|
|
|
fileWidget->GetFile(*aFileName);
|
|
|
|
selectedFileName = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_RELEASE(fileWidget);
|
|
|
|
}
|
|
|
|
|
|
|
|
return selectedFileName;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::DoFileOpen()
|
|
|
|
{
|
|
|
|
nsAutoString fileName;
|
|
|
|
char szFile[1000];
|
|
|
|
if (GetFileNameFromFileSelector(mWindow, &fileName)) {
|
|
|
|
fileName.ToCString(szFile, sizeof(szFile));
|
|
|
|
PRInt32 len = strlen(szFile);
|
|
|
|
PRInt32 sum = len + sizeof(FILE_PROTOCOL);
|
|
|
|
char* lpszFileURL = new char[sum];
|
|
|
|
|
|
|
|
// Translate '\' to '/'
|
|
|
|
for (PRInt32 i = 0; i < len; i++) {
|
|
|
|
if (szFile[i] == '\\') {
|
|
|
|
szFile[i] = '/';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Build the file URL
|
|
|
|
PR_snprintf(lpszFileURL, sum, "%s%s", FILE_PROTOCOL, szFile);
|
|
|
|
|
|
|
|
// Ask the Web widget to load the file URL
|
1998-08-14 23:08:54 +00:00
|
|
|
LoadURL(nsString(lpszFileURL));
|
1998-07-21 16:45:21 +00:00
|
|
|
delete lpszFileURL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-08-04 20:04:55 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::DoSelectAll()
|
|
|
|
{
|
|
|
|
|
|
|
|
nsIPresShell* shell = GetPresShell();
|
|
|
|
if (nsnull != shell) {
|
|
|
|
nsIDocument* doc = shell->GetDocument();
|
|
|
|
if (nsnull != doc) {
|
|
|
|
doc->SelectAll();
|
|
|
|
ForceRefresh();
|
|
|
|
NS_RELEASE(doc);
|
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::ForceRefresh()
|
|
|
|
{
|
|
|
|
nsIPresShell* shell = GetPresShell();
|
|
|
|
if (nsnull != shell) {
|
|
|
|
nsIViewManager* vm = shell->GetViewManager();
|
|
|
|
if (nsnull != vm) {
|
|
|
|
nsIView* root = vm->GetRootView();
|
|
|
|
if (nsnull != root) {
|
|
|
|
vm->UpdateView(root, (nsIRegion*)nsnull, NS_VMREFRESH_IMMEDIATE);
|
|
|
|
}
|
|
|
|
NS_RELEASE(vm);
|
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Note: operator new zeros our memory
|
|
|
|
nsBrowserWindow::nsBrowserWindow()
|
|
|
|
{
|
|
|
|
AddBrowser(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBrowserWindow::~nsBrowserWindow()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF(nsBrowserWindow)
|
|
|
|
NS_IMPL_RELEASE(nsBrowserWindow)
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsBrowserWindow::QueryInterface(const nsIID& aIID,
|
|
|
|
void** aInstancePtrResult)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
|
|
|
|
if (nsnull == aInstancePtrResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1998-07-22 00:26:23 +00:00
|
|
|
|
|
|
|
*aInstancePtrResult = NULL;
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
if (aIID.Equals(kIBrowserWindowIID)) {
|
|
|
|
*aInstancePtrResult = (void*) ((nsIBrowserWindow*)this);
|
|
|
|
AddRef();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
if (aIID.Equals(kIStreamObserverIID)) {
|
|
|
|
*aInstancePtrResult = (void*) ((nsIStreamObserver*)this);
|
|
|
|
AddRef();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
if (aIID.Equals(kIWebShellContainerIID)) {
|
|
|
|
*aInstancePtrResult = (void*) ((nsIWebShellContainer*)this);
|
|
|
|
AddRef();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-07-22 00:26:23 +00:00
|
|
|
if (aIID.Equals(kINetSupportIID)) {
|
|
|
|
*aInstancePtrResult = (void*) ((nsINetSupport*)this);
|
|
|
|
AddRef();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-07-20 16:19:22 +00:00
|
|
|
if (aIID.Equals(kISupportsIID)) {
|
|
|
|
*aInstancePtrResult = (void*) ((nsISupports*)((nsIBrowserWindow*)this));
|
|
|
|
AddRef();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
nsresult
|
|
|
|
nsBrowserWindow::Init(nsIAppShell* aAppShell,
|
1998-07-31 06:01:45 +00:00
|
|
|
nsIPref* aPrefs,
|
1998-07-20 21:16:38 +00:00
|
|
|
const nsRect& aBounds,
|
1998-08-05 04:23:21 +00:00
|
|
|
PRUint32 aChromeMask,
|
|
|
|
PRBool aAllowPlugins)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
|
|
|
mChromeMask = aChromeMask;
|
|
|
|
|
|
|
|
// Create top level window
|
|
|
|
nsresult rv = NSRepository::CreateInstance(kWindowCID, nsnull, kIWidgetIID,
|
|
|
|
(void**)&mWindow);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
nsRect r(0, 0, aBounds.width, aBounds.height);
|
|
|
|
mWindow->Create((nsIWidget*)NULL, r, HandleBrowserEvent,
|
1998-07-29 18:50:51 +00:00
|
|
|
nsnull, aAppShell);
|
1998-07-20 16:19:22 +00:00
|
|
|
mWindow->GetBounds(r);
|
|
|
|
|
|
|
|
// Create web shell
|
|
|
|
rv = NSRepository::CreateInstance(kWebShellCID, nsnull,
|
|
|
|
kIWebShellIID,
|
|
|
|
(void**)&mWebShell);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
r.x = r.y = 0;
|
1998-08-14 23:08:54 +00:00
|
|
|
rv = mWebShell->Init(mWindow->GetNativeData(NS_NATIVE_WIDGET),
|
|
|
|
r.x, r.y, r.width, r.height,
|
1998-08-05 04:23:21 +00:00
|
|
|
nsScrollPreference_kAuto, aAllowPlugins);
|
1998-07-20 16:19:22 +00:00
|
|
|
mWebShell->SetContainer((nsIWebShellContainer*) this);
|
1998-07-22 11:26:18 +00:00
|
|
|
mWebShell->SetObserver((nsIStreamObserver*)this);
|
1998-07-31 06:01:45 +00:00
|
|
|
mWebShell->SetPrefs(aPrefs);
|
1998-07-20 16:19:22 +00:00
|
|
|
mWebShell->Show();
|
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
if (NS_CHROME_MENU_BAR_ON & aChromeMask) {
|
|
|
|
rv = CreateMenuBar(r.width);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
mWindow->GetBounds(r);
|
|
|
|
r.x = r.y = 0;
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
if (NS_CHROME_TOOL_BAR_ON & aChromeMask) {
|
|
|
|
rv = CreateToolBar(r.width);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
if (NS_CHROME_STATUS_BAR_ON & aChromeMask) {
|
|
|
|
rv = CreateStatusBar(r.width);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
1998-07-20 16:19:22 +00:00
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
// Now lay it all out
|
1998-07-20 16:19:22 +00:00
|
|
|
Layout(r.width, r.height);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-24 16:03:11 +00:00
|
|
|
// XXX This sort of thing should be in a resource
|
|
|
|
#define TOOL_BAR_FONT "Helvetica"
|
1998-07-31 06:01:45 +00:00
|
|
|
#define TOOL_BAR_FONT_SIZE 12
|
1998-07-24 16:03:11 +00:00
|
|
|
#define STATUS_BAR_FONT "Helvetica"
|
1998-07-31 06:01:45 +00:00
|
|
|
#define STATUS_BAR_FONT_SIZE 10
|
1998-07-24 16:03:11 +00:00
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
nsresult
|
|
|
|
nsBrowserWindow::CreateToolBar(PRInt32 aWidth)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
1998-07-24 16:03:11 +00:00
|
|
|
nsIDeviceContext* dc = mWindow->GetDeviceContext();
|
|
|
|
float t2d = dc->GetTwipsToDevUnits();
|
|
|
|
nsFont font(TOOL_BAR_FONT, NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
|
|
|
|
NS_FONT_WEIGHT_NORMAL, 0,
|
1998-07-31 23:34:45 +00:00
|
|
|
nscoord(t2d * NSIntPointsToTwips(TOOL_BAR_FONT_SIZE)));
|
1998-07-24 16:03:11 +00:00
|
|
|
NS_RELEASE(dc);
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
// Create and place back button
|
|
|
|
rv = NSRepository::CreateInstance(kButtonCID, nsnull, kIButtonIID,
|
|
|
|
(void**)&mBack);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
nsRect r(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT);
|
|
|
|
mBack->Create(mWindow, r, HandleBackEvent, NULL);
|
|
|
|
mBack->SetLabel("Back");
|
1998-07-24 16:03:11 +00:00
|
|
|
mBack->SetFont(font);
|
1998-07-20 16:19:22 +00:00
|
|
|
mBack->Show(PR_TRUE);
|
|
|
|
|
|
|
|
// Create and place forward button
|
|
|
|
r.SetRect(BUTTON_WIDTH, 0, BUTTON_WIDTH, BUTTON_HEIGHT);
|
|
|
|
rv = NSRepository::CreateInstance(kButtonCID, nsnull, kIButtonIID,
|
1998-07-24 16:03:11 +00:00
|
|
|
(void**)&mForward);
|
1998-07-20 16:19:22 +00:00
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
mForward->Create(mWindow, r, HandleForwardEvent, NULL);
|
|
|
|
mForward->SetLabel("Forward");
|
1998-07-24 16:03:11 +00:00
|
|
|
mForward->SetFont(font);
|
1998-07-20 16:19:22 +00:00
|
|
|
mForward->Show(PR_TRUE);
|
|
|
|
|
|
|
|
// Create and place location bar
|
|
|
|
r.SetRect(2*BUTTON_WIDTH, 0,
|
|
|
|
aWidth - 2*BUTTON_WIDTH - THROBBER_WIDTH,
|
|
|
|
BUTTON_HEIGHT);
|
|
|
|
rv = NSRepository::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID,
|
|
|
|
(void**)&mLocation);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
mLocation->Create(mWindow, r, HandleLocationEvent, NULL);
|
|
|
|
mLocation->SetText("");
|
1998-08-03 22:32:34 +00:00
|
|
|
mLocation->SetForegroundColor(NS_RGB(0, 0, 0));
|
1998-07-20 16:19:22 +00:00
|
|
|
mLocation->SetBackgroundColor(NS_RGB(255, 255, 255));
|
|
|
|
mLocation->Show(PR_TRUE);
|
1998-07-24 16:03:11 +00:00
|
|
|
mLocation->SetFont(font);
|
1998-07-20 16:19:22 +00:00
|
|
|
|
|
|
|
// Create and place throbber
|
|
|
|
r.SetRect(aWidth - THROBBER_WIDTH, 0,
|
|
|
|
THROBBER_WIDTH, THROBBER_HEIGHT);
|
|
|
|
rv = NSRepository::CreateInstance(kThrobberCID, nsnull, kIThrobberIID,
|
|
|
|
(void**)&mThrobber);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
mThrobber->Init(mWindow, r);
|
|
|
|
mThrobber->Show();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsBrowserWindow::CreateStatusBar(PRInt32 aWidth)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
1998-07-24 16:03:11 +00:00
|
|
|
nsIDeviceContext* dc = mWindow->GetDeviceContext();
|
|
|
|
float t2d = dc->GetTwipsToDevUnits();
|
|
|
|
nsFont font(STATUS_BAR_FONT, NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
|
|
|
|
NS_FONT_WEIGHT_NORMAL, 0,
|
1998-07-31 23:34:45 +00:00
|
|
|
nscoord(t2d * NSIntPointsToTwips(STATUS_BAR_FONT_SIZE)));
|
1998-07-24 16:03:11 +00:00
|
|
|
NS_RELEASE(dc);
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
nsRect r(0, 0, aWidth, THROBBER_HEIGHT);
|
|
|
|
rv = NSRepository::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID,
|
|
|
|
(void**)&mStatus);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
mStatus->Create(mWindow, r, HandleLocationEvent, NULL);
|
|
|
|
mStatus->SetText("");
|
1998-08-03 22:32:34 +00:00
|
|
|
mStatus->SetForegroundColor(NS_RGB(0, 0, 0));
|
1998-07-24 16:03:11 +00:00
|
|
|
mStatus->SetFont(font);
|
1998-07-20 16:19:22 +00:00
|
|
|
mStatus->Show(PR_TRUE);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::Layout(PRInt32 aWidth, PRInt32 aHeight)
|
|
|
|
{
|
|
|
|
// position location bar (it's stretchy)
|
|
|
|
if (mLocation) {
|
|
|
|
if (mThrobber) {
|
|
|
|
mLocation->Resize(2*BUTTON_WIDTH, 0,
|
|
|
|
aWidth - (2*BUTTON_WIDTH + THROBBER_WIDTH),
|
|
|
|
BUTTON_HEIGHT,
|
|
|
|
PR_TRUE);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mLocation->Resize(2*BUTTON_WIDTH, 0,
|
|
|
|
aWidth - 2*BUTTON_WIDTH,
|
|
|
|
BUTTON_HEIGHT,
|
|
|
|
PR_TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mThrobber) {
|
|
|
|
mThrobber->MoveTo(aWidth - THROBBER_WIDTH, 0);
|
|
|
|
}
|
|
|
|
|
1998-08-07 04:45:03 +00:00
|
|
|
nsRect rr(0, 0, aWidth, aHeight);
|
|
|
|
|
|
|
|
if (mLocation) {
|
|
|
|
rr.y += BUTTON_HEIGHT;
|
|
|
|
rr.height -= BUTTON_HEIGHT;
|
|
|
|
}
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
if (mStatus) {
|
1998-07-24 16:03:11 +00:00
|
|
|
mStatus->Resize(0, aHeight - STATUS_HEIGHT,
|
|
|
|
aWidth, STATUS_HEIGHT,
|
1998-07-20 16:19:22 +00:00
|
|
|
PR_TRUE);
|
1998-07-24 16:03:11 +00:00
|
|
|
rr.height -= STATUS_HEIGHT;
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// inset the web widget
|
|
|
|
rr.x += WEBSHELL_LEFT_INSET;
|
|
|
|
rr.y += WEBSHELL_TOP_INSET;
|
|
|
|
rr.width -= WEBSHELL_LEFT_INSET + WEBSHELL_RIGHT_INSET;
|
|
|
|
rr.height -= WEBSHELL_TOP_INSET + WEBSHELL_BOTTOM_INSET;
|
1998-08-14 23:08:54 +00:00
|
|
|
mWebShell->SetBounds(rr.x, rr.y, rr.width, rr.height);
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::MoveTo(PRInt32 aX, PRInt32 aY)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != mWindow, "null window");
|
|
|
|
mWindow->Move(aX, aY);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::SizeTo(PRInt32 aWidth, PRInt32 aHeight)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != mWindow, "null window");
|
|
|
|
|
|
|
|
// XXX We want to do this in one shot
|
|
|
|
mWindow->Resize(aWidth, aHeight, PR_FALSE);
|
|
|
|
Layout(aWidth, aHeight);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-21 00:48:35 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::GetBounds(nsRect& aBounds)
|
|
|
|
{
|
|
|
|
mWindow->GetBounds(aBounds);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1998-08-07 04:45:03 +00:00
|
|
|
NS_IMETHODIMP
|
1998-08-14 22:31:38 +00:00
|
|
|
nsBrowserWindow::OpenWindow(PRUint32 aNewChromeMask, nsIBrowserWindow*& aNewWindow)
|
1998-08-07 04:45:03 +00:00
|
|
|
{
|
1998-08-14 22:31:38 +00:00
|
|
|
return mApp->OpenWindow(aNewChromeMask, aNewWindow);
|
1998-08-07 04:45:03 +00:00
|
|
|
}
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::ChangeChrome(PRUint32 aChromeMask)
|
|
|
|
{
|
|
|
|
// XXX write me
|
|
|
|
mChromeMask = aChromeMask;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::GetChrome(PRUint32& aChromeMaskResult)
|
|
|
|
{
|
|
|
|
aChromeMaskResult = mChromeMask;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-08-14 23:08:54 +00:00
|
|
|
nsBrowserWindow::LoadURL(const PRUnichar* aURL)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
1998-07-22 11:26:18 +00:00
|
|
|
return mWebShell->LoadURL(aURL, nsnull);
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
1998-07-21 00:48:35 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::GetWebShell(nsIWebShell*& aResult)
|
|
|
|
{
|
|
|
|
aResult = mWebShell;
|
|
|
|
NS_IF_ADDREF(mWebShell);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-08-14 23:08:54 +00:00
|
|
|
nsBrowserWindow::SetTitle(const PRUnichar* aTitle)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != mWindow, "null window");
|
|
|
|
mTitle = aTitle;
|
|
|
|
mWindow->SetTitle(aTitle);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-08-14 23:08:54 +00:00
|
|
|
nsBrowserWindow::GetTitle(PRUnichar** aResult)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
1998-08-14 23:08:54 +00:00
|
|
|
*aResult = mTitle;
|
1998-07-20 16:19:22 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-31 18:22:27 +00:00
|
|
|
NS_IMETHODIMP
|
1998-08-14 23:08:54 +00:00
|
|
|
nsBrowserWindow::SetStatus(const PRUnichar* aStatus)
|
1998-07-31 18:22:27 +00:00
|
|
|
{
|
1998-08-07 04:45:03 +00:00
|
|
|
if (nsnull != mStatus) {
|
|
|
|
mStatus->SetText(aStatus);
|
|
|
|
}
|
1998-07-31 18:22:27 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-08-14 23:08:54 +00:00
|
|
|
nsBrowserWindow::GetStatus(PRUnichar** aResult)
|
1998-07-31 18:22:27 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
NS_IMETHODIMP
|
1998-08-14 23:08:54 +00:00
|
|
|
nsBrowserWindow::WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
|
|
|
if (mStatus) {
|
|
|
|
nsAutoString url("Connecting to ");
|
|
|
|
url.Append(aURL);
|
|
|
|
mStatus->SetText(url);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-08-14 23:08:54 +00:00
|
|
|
nsBrowserWindow::BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
|
|
|
if (mThrobber) {
|
|
|
|
mThrobber->Start();
|
|
|
|
mLocation->SetText(aURL);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-08-14 23:08:54 +00:00
|
|
|
nsBrowserWindow::ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
|
|
|
if (mThrobber) {
|
|
|
|
mThrobber->Stop();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-08-14 23:08:54 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
// Stream observer implementation
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::OnProgress(nsIURL* aURL,
|
|
|
|
PRInt32 aProgress,
|
1998-07-24 10:02:50 +00:00
|
|
|
PRInt32 aProgressMax)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
|
|
|
if (mStatus) {
|
1998-07-24 10:02:50 +00:00
|
|
|
nsAutoString url;
|
|
|
|
if (nsnull != aURL) {
|
|
|
|
aURL->ToString(url);
|
|
|
|
}
|
|
|
|
url.Append(": progress ");
|
|
|
|
url.Append(aProgress, 10);
|
|
|
|
if (0 != aProgressMax) {
|
|
|
|
url.Append(" (out of ");
|
|
|
|
url.Append(aProgressMax, 10);
|
|
|
|
url.Append(")");
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
1998-07-24 10:02:50 +00:00
|
|
|
mStatus->SetText(url);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::OnStatus(nsIURL* aURL, const nsString& aMsg)
|
|
|
|
{
|
|
|
|
if (mStatus) {
|
|
|
|
mStatus->SetText(aMsg);
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::OnStartBinding(nsIURL* aURL, const char *aContentType)
|
|
|
|
{
|
|
|
|
if (mStatus) {
|
|
|
|
nsAutoString url;
|
|
|
|
if (nsnull != aURL) {
|
|
|
|
aURL->ToString(url);
|
|
|
|
}
|
|
|
|
url.Append(": start");
|
|
|
|
mStatus->SetText(url);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::OnStopBinding(nsIURL* aURL,
|
|
|
|
PRInt32 status,
|
|
|
|
const nsString& aMsg)
|
|
|
|
{
|
|
|
|
if (mThrobber) {
|
|
|
|
mThrobber->Stop();
|
|
|
|
}
|
|
|
|
if (mStatus) {
|
|
|
|
nsAutoString url;
|
|
|
|
if (nsnull != aURL) {
|
|
|
|
aURL->ToString(url);
|
|
|
|
}
|
|
|
|
url.Append(": stop");
|
|
|
|
mStatus->SetText(url);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-22 00:26:23 +00:00
|
|
|
NS_IMETHODIMP_(void)
|
|
|
|
nsBrowserWindow::Alert(const nsString &aText)
|
|
|
|
{
|
|
|
|
nsAutoString str(aText);
|
|
|
|
printf("Browser Window Alert: %s\n", str);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(PRBool)
|
|
|
|
nsBrowserWindow::Confirm(const nsString &aText)
|
|
|
|
{
|
|
|
|
nsAutoString str(aText);
|
|
|
|
printf("Browser Window Confirm: %s (returning false)\n", str);
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(PRBool)
|
|
|
|
nsBrowserWindow::Prompt(const nsString &aText,
|
|
|
|
const nsString &aDefault,
|
|
|
|
nsString &aResult)
|
|
|
|
{
|
|
|
|
nsAutoString str(aText);
|
|
|
|
char buf[256];
|
|
|
|
printf("Browser Window: %s\n", str);
|
|
|
|
printf("Prompt: ");
|
|
|
|
scanf("%s", buf);
|
|
|
|
aResult = buf;
|
|
|
|
|
|
|
|
return (aResult.Length() > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(PRBool)
|
|
|
|
nsBrowserWindow::PromptUserAndPassword(const nsString &aText,
|
|
|
|
nsString &aUser,
|
|
|
|
nsString &aPassword)
|
|
|
|
{
|
|
|
|
nsAutoString str(aText);
|
|
|
|
char buf[256];
|
|
|
|
printf("Browser Window: %s\n", str);
|
|
|
|
printf("User: ");
|
|
|
|
scanf("%s", buf);
|
|
|
|
aUser = buf;
|
|
|
|
printf("Password: ");
|
|
|
|
scanf("%s", buf);
|
|
|
|
aPassword = buf;
|
|
|
|
|
|
|
|
return (aUser.Length() > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(PRBool)
|
|
|
|
nsBrowserWindow::PromptPassword(const nsString &aText,
|
|
|
|
nsString &aPassword)
|
|
|
|
{
|
|
|
|
nsAutoString str(aText);
|
|
|
|
char buf[256];
|
|
|
|
printf("Browser Window: %s\n", str);
|
|
|
|
printf("Password: ");
|
|
|
|
scanf("%s", buf);
|
|
|
|
aPassword = buf;
|
|
|
|
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
// Toolbar support
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::StartThrobber()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::StopThrobber()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::LoadThrobberImages()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::DestroyThrobberImages()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID);
|
|
|
|
|
1998-07-21 00:48:35 +00:00
|
|
|
nsIPresShell*
|
|
|
|
nsBrowserWindow::GetPresShell()
|
1998-07-20 21:16:38 +00:00
|
|
|
{
|
|
|
|
nsIPresShell* shell = nsnull;
|
1998-07-21 00:48:35 +00:00
|
|
|
if (nsnull != mWebShell) {
|
1998-07-20 21:16:38 +00:00
|
|
|
nsIContentViewer* cv = nsnull;
|
1998-07-21 00:48:35 +00:00
|
|
|
mWebShell->GetContentViewer(cv);
|
1998-07-20 21:16:38 +00:00
|
|
|
if (nsnull != cv) {
|
|
|
|
nsIDocumentViewer* docv = nsnull;
|
|
|
|
cv->QueryInterface(kIDocumentViewerIID, (void**) &docv);
|
|
|
|
if (nsnull != docv) {
|
|
|
|
nsIPresContext* cx;
|
|
|
|
docv->GetPresContext(cx);
|
|
|
|
if (nsnull != cx) {
|
|
|
|
shell = cx->GetShell();
|
|
|
|
NS_RELEASE(cx);
|
|
|
|
}
|
|
|
|
NS_RELEASE(docv);
|
|
|
|
}
|
|
|
|
NS_RELEASE(cv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return shell;
|
|
|
|
}
|
|
|
|
|
1998-07-31 16:53:45 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::DoCopy()
|
|
|
|
{
|
|
|
|
nsIPresShell* shell = GetPresShell();
|
|
|
|
if (nsnull != shell) {
|
|
|
|
nsIDocument* doc = shell->GetDocument();
|
|
|
|
if (nsnull != doc) {
|
|
|
|
nsString buffer;
|
|
|
|
|
|
|
|
doc->CreateXIF(buffer,PR_TRUE);
|
|
|
|
|
|
|
|
nsIParser* parser;
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
|
|
|
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
|
|
|
|
|
|
|
nsresult rv = NSRepository::CreateInstance(kCParserCID,
|
|
|
|
nsnull,
|
|
|
|
kCParserIID,
|
|
|
|
(void **)&parser);
|
|
|
|
|
|
|
|
if (NS_OK == rv) {
|
|
|
|
nsIHTMLContentSink* sink = nsnull;
|
|
|
|
|
|
|
|
rv = NS_New_HTML_ContentSinkStream(&sink,PR_FALSE,PR_FALSE);
|
|
|
|
|
|
|
|
ostrstream data;
|
|
|
|
((nsHTMLContentSinkStream*)sink)->SetOutputStream(data);
|
|
|
|
|
|
|
|
if (NS_OK == rv) {
|
|
|
|
parser->SetContentSink(sink);
|
|
|
|
|
|
|
|
nsIDTD* dtd = nsnull;
|
|
|
|
rv = NS_NewXIFDTD(&dtd);
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
parser->RegisterDTD(dtd);
|
|
|
|
dtd->SetContentSink(sink);
|
|
|
|
dtd->SetParser(parser);
|
|
|
|
parser->Parse(buffer, PR_FALSE);
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(dtd);
|
|
|
|
NS_IF_RELEASE(sink);
|
|
|
|
char* str = data.str();
|
|
|
|
|
|
|
|
#if defined(WIN32)
|
1998-08-07 22:35:44 +00:00
|
|
|
PRUint32 aolMail = RegisterClipboardFormat("AOLMAIL");
|
|
|
|
PRUint32 textHtml = RegisterClipboardFormat("text/html");
|
|
|
|
|
|
|
|
|
|
|
|
HGLOBAL hGlobalMemory1;
|
|
|
|
PSTR pGlobalMemory1;
|
|
|
|
|
|
|
|
HGLOBAL hGlobalMemory2;
|
|
|
|
PSTR pGlobalMemory2;
|
1998-07-31 16:53:45 +00:00
|
|
|
|
|
|
|
PRInt32 len = data.pcount();
|
|
|
|
if (len)
|
|
|
|
{
|
|
|
|
// Copy text to Global Memory Area
|
1998-08-07 22:35:44 +00:00
|
|
|
hGlobalMemory1 = (HGLOBAL)GlobalAlloc(GHND, len+1);
|
|
|
|
hGlobalMemory2 = (HGLOBAL)GlobalAlloc(GHND, len+1);
|
|
|
|
if (hGlobalMemory1 != NULL && hGlobalMemory2 != NULL) {
|
|
|
|
pGlobalMemory1 = (PSTR) GlobalLock(hGlobalMemory1);
|
|
|
|
pGlobalMemory2 = (PSTR) GlobalLock(hGlobalMemory2);
|
1998-07-31 16:53:45 +00:00
|
|
|
char * s = str;
|
|
|
|
for (int i=0;i< len;i++) {
|
1998-08-07 22:35:44 +00:00
|
|
|
*pGlobalMemory1++ = *s;
|
|
|
|
*pGlobalMemory2++ = *s++;
|
1998-07-31 16:53:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Put data on Clipboard
|
1998-08-07 22:35:44 +00:00
|
|
|
GlobalUnlock(hGlobalMemory1);
|
|
|
|
GlobalUnlock(hGlobalMemory2);
|
1998-07-31 16:53:45 +00:00
|
|
|
OpenClipboard(NULL);
|
|
|
|
EmptyClipboard();
|
1998-08-07 22:35:44 +00:00
|
|
|
SetClipboardData(aolMail, hGlobalMemory1);
|
|
|
|
SetClipboardData(textHtml, hGlobalMemory2);
|
1998-07-31 16:53:45 +00:00
|
|
|
CloseClipboard();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// in ostrstreams if you cal the str() function
|
|
|
|
// then you are responsible for deleting the string
|
|
|
|
#endif
|
|
|
|
if (str) delete str;
|
|
|
|
|
|
|
|
}
|
|
|
|
NS_RELEASE(parser);
|
|
|
|
}
|
|
|
|
NS_RELEASE(doc);
|
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1998-08-07 04:45:03 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::DoJSConsole()
|
|
|
|
{
|
|
|
|
mApp->CreateJSConsole(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-08-14 01:51:00 +00:00
|
|
|
nsBrowserWindow::DoEditorMode(nsIWebShell *aWebShell)
|
1998-08-07 04:45:03 +00:00
|
|
|
{
|
1998-08-14 01:51:00 +00:00
|
|
|
PRInt32 i, n;
|
|
|
|
if (nsnull != aWebShell) {
|
|
|
|
nsIContentViewer* mCViewer;
|
|
|
|
aWebShell->GetContentViewer(mCViewer);
|
|
|
|
if (nsnull != mCViewer) {
|
|
|
|
nsIDocumentViewer* mDViewer;
|
|
|
|
if (NS_OK == mCViewer->QueryInterface(kIDocumentViewerIID, (void**) &mDViewer)) {
|
|
|
|
nsIDocument* mDoc;
|
|
|
|
mDViewer->GetDocument(mDoc);
|
|
|
|
if (nsnull != mDoc) {
|
|
|
|
nsIDOMDocument* mDOMDoc;
|
|
|
|
if (NS_OK == mDoc->QueryInterface(kIDOMDocumentIID, (void**) &mDOMDoc)) {
|
|
|
|
NS_InitEditorMode(mDOMDoc);
|
|
|
|
NS_RELEASE(mDOMDoc);
|
|
|
|
}
|
|
|
|
NS_RELEASE(mDoc);
|
|
|
|
}
|
|
|
|
NS_RELEASE(mDViewer);
|
1998-08-07 04:45:03 +00:00
|
|
|
}
|
1998-08-14 01:51:00 +00:00
|
|
|
NS_RELEASE(mCViewer);
|
|
|
|
}
|
|
|
|
|
|
|
|
aWebShell->GetChildCount(n);
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
nsIWebShell* mChild;
|
|
|
|
aWebShell->ChildAt(i, mChild);
|
|
|
|
DoEditorMode(mChild);
|
|
|
|
NS_RELEASE(mChild);
|
1998-08-07 04:45:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-07-31 16:53:45 +00:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsISizeOfHandler.h"
|
|
|
|
#include "nsIStyleSet.h"
|
|
|
|
|
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::DumpContent(FILE* out)
|
|
|
|
{
|
1998-07-21 00:48:35 +00:00
|
|
|
nsIPresShell* shell = GetPresShell();
|
1998-07-20 21:16:38 +00:00
|
|
|
if (nsnull != shell) {
|
|
|
|
nsIDocument* doc = shell->GetDocument();
|
|
|
|
if (nsnull != doc) {
|
|
|
|
nsIContent* root = doc->GetRootContent();
|
|
|
|
if (nsnull != root) {
|
|
|
|
root->List(out);
|
|
|
|
NS_RELEASE(root);
|
|
|
|
}
|
|
|
|
NS_RELEASE(doc);
|
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fputs("null pres shell\n", out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::DumpFrames(FILE* out)
|
|
|
|
{
|
1998-07-21 00:48:35 +00:00
|
|
|
nsIPresShell* shell = GetPresShell();
|
1998-07-20 21:16:38 +00:00
|
|
|
if (nsnull != shell) {
|
|
|
|
nsIFrame* root = shell->GetRootFrame();
|
|
|
|
if (nsnull != root) {
|
|
|
|
root->List(out);
|
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fputs("null pres shell\n", out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-07-27 05:59:37 +00:00
|
|
|
DumpViewsRecurse(nsBrowserWindow* aBrowser, nsIWebShell* aWebShell, FILE* out)
|
1998-07-20 21:16:38 +00:00
|
|
|
{
|
1998-07-27 05:59:37 +00:00
|
|
|
if (nsnull != aWebShell) {
|
|
|
|
nsIPresShell* shell = aBrowser->GetPresShell();
|
|
|
|
if (nsnull != shell) {
|
|
|
|
nsIViewManager* vm = shell->GetViewManager();
|
|
|
|
if (nsnull != vm) {
|
|
|
|
nsIView* root = vm->GetRootView();
|
|
|
|
if (nsnull != root) {
|
|
|
|
root->List(out);
|
|
|
|
}
|
|
|
|
NS_RELEASE(vm);
|
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fputs("null pres shell\n", out);
|
|
|
|
}
|
|
|
|
// dump the views of the sub documents
|
|
|
|
PRInt32 i, n;
|
|
|
|
aWebShell->GetChildCount(n);
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
nsIWebShell* child;
|
|
|
|
aWebShell->ChildAt(i, child);
|
|
|
|
if (nsnull != child) {
|
|
|
|
DumpViewsRecurse(aBrowser, child, out);
|
1998-07-20 21:16:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-07-27 05:59:37 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::DumpViews(FILE* out)
|
|
|
|
{
|
|
|
|
DumpViewsRecurse(this, mWebShell, out);
|
|
|
|
}
|
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
static void DumpAWebShell(nsIWebShell* aShell, FILE* out, PRInt32 aIndent)
|
|
|
|
{
|
1998-08-14 23:08:54 +00:00
|
|
|
PRUnichar *name;
|
|
|
|
nsAutoString str;
|
1998-07-20 21:16:38 +00:00
|
|
|
nsIWebShell* parent;
|
|
|
|
PRInt32 i, n;
|
|
|
|
|
|
|
|
for (i = aIndent; --i >= 0; ) fprintf(out, " ");
|
|
|
|
|
|
|
|
fprintf(out, "%p '", aShell);
|
1998-08-14 23:08:54 +00:00
|
|
|
aShell->GetName(&name);
|
1998-07-20 21:16:38 +00:00
|
|
|
aShell->GetParent(parent);
|
1998-08-14 23:08:54 +00:00
|
|
|
str = name;
|
|
|
|
fputs(str, out);
|
1998-07-20 21:16:38 +00:00
|
|
|
fprintf(out, "' parent=%p <\n", parent);
|
|
|
|
NS_IF_RELEASE(parent);
|
|
|
|
|
|
|
|
aIndent++;
|
|
|
|
aShell->GetChildCount(n);
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
nsIWebShell* child;
|
|
|
|
aShell->ChildAt(i, child);
|
|
|
|
if (nsnull != child) {
|
|
|
|
DumpAWebShell(child, out, aIndent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aIndent--;
|
|
|
|
for (i = aIndent; --i >= 0; ) fprintf(out, " ");
|
|
|
|
fputs(">\n", out);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::DumpWebShells(FILE* out)
|
|
|
|
{
|
|
|
|
DumpAWebShell(mWebShell, out, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::DumpStyleSheets(FILE* out)
|
|
|
|
{
|
1998-07-21 00:48:35 +00:00
|
|
|
nsIPresShell* shell = GetPresShell();
|
1998-07-20 21:16:38 +00:00
|
|
|
if (nsnull != shell) {
|
|
|
|
nsIStyleSet* styleSet = shell->GetStyleSet();
|
|
|
|
if (nsnull == styleSet) {
|
|
|
|
fputs("null style set\n", out);
|
|
|
|
} else {
|
|
|
|
styleSet->List(out);
|
|
|
|
NS_RELEASE(styleSet);
|
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fputs("null pres shell\n", out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::DumpStyleContexts(FILE* out)
|
|
|
|
{
|
1998-07-21 00:48:35 +00:00
|
|
|
nsIPresShell* shell = GetPresShell();
|
1998-07-20 21:16:38 +00:00
|
|
|
if (nsnull != shell) {
|
|
|
|
nsIPresContext* cx = shell->GetPresContext();
|
|
|
|
nsIStyleSet* styleSet = shell->GetStyleSet();
|
|
|
|
if (nsnull == styleSet) {
|
|
|
|
fputs("null style set\n", out);
|
|
|
|
} else {
|
|
|
|
nsIFrame* root = shell->GetRootFrame();
|
|
|
|
if (nsnull == root) {
|
|
|
|
fputs("null root frame\n", out);
|
|
|
|
} else {
|
|
|
|
nsIStyleContext* rootContext;
|
|
|
|
root->GetStyleContext(cx, rootContext);
|
|
|
|
if (nsnull != rootContext) {
|
|
|
|
styleSet->ListContexts(rootContext, out);
|
|
|
|
NS_RELEASE(rootContext);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fputs("null root context", out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(styleSet);
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(cx);
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
} else {
|
|
|
|
fputs("null pres shell\n", out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::ToggleFrameBorders()
|
|
|
|
{
|
|
|
|
PRBool showing = nsIFrame::GetShowFrameBorders();
|
|
|
|
nsIFrame::ShowFrameBorders(!showing);
|
|
|
|
ForceRefresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::ShowContentSize()
|
|
|
|
{
|
|
|
|
nsISizeOfHandler* szh;
|
|
|
|
if (NS_OK != NS_NewSizeOfHandler(&szh)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-07-21 00:48:35 +00:00
|
|
|
nsIPresShell* shell = GetPresShell();
|
1998-07-20 21:16:38 +00:00
|
|
|
if (nsnull != shell) {
|
|
|
|
nsIDocument* doc = shell->GetDocument();
|
|
|
|
if (nsnull != doc) {
|
|
|
|
nsIContent* content = doc->GetRootContent();
|
|
|
|
if (nsnull != content) {
|
|
|
|
content->SizeOf(szh);
|
|
|
|
PRUint32 totalSize;
|
|
|
|
szh->GetSize(totalSize);
|
|
|
|
printf("Content model size is approximately %d bytes\n", totalSize);
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
NS_RELEASE(doc);
|
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
NS_RELEASE(szh);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::ShowFrameSize()
|
|
|
|
{
|
1998-07-21 00:48:35 +00:00
|
|
|
nsIPresShell* shell0 = GetPresShell();
|
1998-07-20 21:16:38 +00:00
|
|
|
if (nsnull != shell0) {
|
|
|
|
nsIDocument* doc = shell0->GetDocument();
|
|
|
|
if (nsnull != doc) {
|
|
|
|
PRInt32 i, shells = doc->GetNumberOfShells();
|
|
|
|
for (i = 0; i < shells; i++) {
|
|
|
|
nsIPresShell* shell = doc->GetShellAt(i);
|
|
|
|
if (nsnull != shell) {
|
|
|
|
nsISizeOfHandler* szh;
|
|
|
|
if (NS_OK != NS_NewSizeOfHandler(&szh)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nsIFrame* root;
|
|
|
|
root = shell->GetRootFrame();
|
|
|
|
if (nsnull != root) {
|
|
|
|
root->SizeOf(szh);
|
|
|
|
PRUint32 totalSize;
|
|
|
|
szh->GetSize(totalSize);
|
|
|
|
printf("Frame model for shell=%p size is approximately %d bytes\n",
|
|
|
|
shell, totalSize);
|
|
|
|
}
|
|
|
|
NS_RELEASE(szh);
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(doc);
|
|
|
|
}
|
|
|
|
NS_RELEASE(shell0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::ShowStyleSize()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-07-27 18:17:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static PRBool GetSaveFileNameFromFileSelector(nsIWidget* aParentWindow,
|
|
|
|
nsString& aFileName)
|
|
|
|
{
|
|
|
|
PRInt32 offset = aFileName.RFind('/');
|
|
|
|
if (offset != -1)
|
|
|
|
aFileName.Cut(0,offset+1);
|
|
|
|
|
|
|
|
PRBool selectedFileName = PR_FALSE;
|
|
|
|
nsIFileWidget *fileWidget;
|
|
|
|
nsString title("Save HTML");
|
|
|
|
nsresult rv = NSRepository::CreateInstance(kFileWidgetCID,
|
|
|
|
nsnull,
|
|
|
|
kIFileWidgetIID,
|
|
|
|
(void**)&fileWidget);
|
|
|
|
if (NS_OK == rv) {
|
|
|
|
nsString titles[] = {"html","txt"};
|
|
|
|
nsString filters[] = {"*.html", "*.txt"};
|
|
|
|
fileWidget->SetFilterList(2, titles, filters);
|
|
|
|
fileWidget->Create(aParentWindow,
|
|
|
|
title,
|
|
|
|
eMode_save,
|
|
|
|
nsnull,
|
|
|
|
nsnull);
|
|
|
|
fileWidget->SetDefaultString(aFileName);
|
|
|
|
|
|
|
|
PRUint32 result = fileWidget->Show();
|
|
|
|
if (result) {
|
|
|
|
fileWidget->GetFile(aFileName);
|
|
|
|
selectedFileName = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_RELEASE(fileWidget);
|
|
|
|
}
|
|
|
|
|
|
|
|
return selectedFileName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1998-07-20 22:22:13 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::DoDebugSave()
|
|
|
|
{
|
1998-07-27 18:17:07 +00:00
|
|
|
PRBool doSave = PR_FALSE;
|
|
|
|
nsString path;
|
|
|
|
|
1998-08-14 23:08:54 +00:00
|
|
|
PRUnichar *urlString;
|
|
|
|
mWebShell->GetURL(0,&urlString);
|
1998-07-27 18:17:07 +00:00
|
|
|
nsIURL* url;
|
|
|
|
nsresult rv = NS_NewURL(&url, urlString);
|
|
|
|
|
|
|
|
if (rv == NS_OK)
|
|
|
|
{
|
|
|
|
const char* name = url->GetFile();
|
|
|
|
path = name;
|
|
|
|
|
|
|
|
doSave = GetSaveFileNameFromFileSelector(mWindow, path);
|
|
|
|
NS_RELEASE(url);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (!doSave)
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
1998-07-21 00:48:35 +00:00
|
|
|
nsIPresShell* shell = GetPresShell();
|
1998-07-20 22:22:13 +00:00
|
|
|
if (nsnull != shell) {
|
|
|
|
nsIDocument* doc = shell->GetDocument();
|
|
|
|
if (nsnull != doc) {
|
|
|
|
nsString buffer;
|
1998-07-27 18:17:07 +00:00
|
|
|
|
1998-07-20 22:22:13 +00:00
|
|
|
doc->CreateXIF(buffer,PR_FALSE);
|
|
|
|
|
|
|
|
nsIParser* parser;
|
1998-07-30 22:42:27 +00:00
|
|
|
|
|
|
|
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
|
|
|
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
|
|
|
|
|
|
|
nsresult rv = NSRepository::CreateInstance(kCParserCID,
|
|
|
|
nsnull,
|
|
|
|
kCParserIID,
|
|
|
|
(void **)&parser);
|
|
|
|
|
1998-07-20 22:22:13 +00:00
|
|
|
if (NS_OK == rv) {
|
|
|
|
nsIHTMLContentSink* sink = nsnull;
|
1998-07-27 18:17:07 +00:00
|
|
|
|
1998-07-20 22:22:13 +00:00
|
|
|
rv = NS_New_HTML_ContentSinkStream(&sink);
|
1998-07-27 19:11:51 +00:00
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
#define BUFFER_SIZE MAX_PATH
|
|
|
|
#else
|
|
|
|
#define BUFFER_SIZE 1024
|
|
|
|
#endif
|
|
|
|
char filename[BUFFER_SIZE];
|
|
|
|
path.ToCString(filename,BUFFER_SIZE);
|
1998-07-27 18:17:07 +00:00
|
|
|
ofstream out(filename);
|
|
|
|
((nsHTMLContentSinkStream*)sink)->SetOutputStream(out);
|
|
|
|
|
1998-07-20 22:22:13 +00:00
|
|
|
if (NS_OK == rv) {
|
|
|
|
parser->SetContentSink(sink);
|
|
|
|
|
|
|
|
nsIDTD* dtd = nsnull;
|
|
|
|
rv = NS_NewXIFDTD(&dtd);
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
parser->RegisterDTD(dtd);
|
|
|
|
dtd->SetContentSink(sink);
|
|
|
|
dtd->SetParser(parser);
|
1998-07-27 18:17:07 +00:00
|
|
|
parser->Parse(buffer, PR_FALSE);
|
1998-07-20 22:22:13 +00:00
|
|
|
}
|
1998-07-27 18:17:07 +00:00
|
|
|
out.close();
|
|
|
|
|
1998-07-20 22:22:13 +00:00
|
|
|
NS_IF_RELEASE(dtd);
|
|
|
|
NS_IF_RELEASE(sink);
|
|
|
|
}
|
|
|
|
NS_RELEASE(parser);
|
|
|
|
}
|
1998-07-31 18:35:19 +00:00
|
|
|
NS_RELEASE(doc);
|
1998-07-20 22:22:13 +00:00
|
|
|
}
|
1998-07-31 18:35:19 +00:00
|
|
|
NS_RELEASE(shell);
|
1998-07-20 22:22:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-07-27 18:17:07 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::DoToggleSelection()
|
|
|
|
{
|
|
|
|
nsIPresShell* shell = GetPresShell();
|
|
|
|
if (nsnull != shell) {
|
|
|
|
nsIDocument* doc = shell->GetDocument();
|
|
|
|
if (nsnull != doc) {
|
|
|
|
PRBool current = doc->GetDisplaySelection();
|
|
|
|
doc->SetDisplaySelection(!current);
|
|
|
|
ForceRefresh();
|
1998-07-29 17:39:28 +00:00
|
|
|
NS_RELEASE(doc);
|
1998-07-27 18:17:07 +00:00
|
|
|
}
|
1998-07-29 17:39:28 +00:00
|
|
|
NS_RELEASE(shell);
|
1998-07-27 18:17:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-07-21 00:48:35 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::DoDebugRobot()
|
|
|
|
{
|
|
|
|
mApp->CreateRobot(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::DoSiteWalker()
|
|
|
|
{
|
|
|
|
mApp->CreateSiteWalker(this);
|
|
|
|
}
|
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
nsEventStatus
|
1998-07-20 22:13:11 +00:00
|
|
|
nsBrowserWindow::DispatchDebugMenu(PRInt32 aID)
|
1998-07-20 21:16:38 +00:00
|
|
|
{
|
|
|
|
nsEventStatus result = nsEventStatus_eIgnore;
|
|
|
|
|
1998-07-20 22:13:11 +00:00
|
|
|
switch(aID) {
|
1998-07-20 21:16:38 +00:00
|
|
|
case VIEWER_VISUAL_DEBUGGING:
|
|
|
|
ToggleFrameBorders();
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIEWER_DUMP_CONTENT:
|
|
|
|
DumpContent();
|
|
|
|
DumpWebShells();
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIEWER_DUMP_FRAMES:
|
|
|
|
DumpFrames();
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIEWER_DUMP_VIEWS:
|
|
|
|
DumpViews();
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIEWER_DUMP_STYLE_SHEETS:
|
|
|
|
DumpStyleSheets();
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIEWER_DUMP_STYLE_CONTEXTS:
|
|
|
|
DumpStyleContexts();
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIEWER_SHOW_CONTENT_SIZE:
|
|
|
|
ShowContentSize();
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIEWER_SHOW_FRAME_SIZE:
|
|
|
|
ShowFrameSize();
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIEWER_SHOW_STYLE_SIZE:
|
|
|
|
ShowStyleSize();
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIEWER_SHOW_CONTENT_QUALITY:
|
|
|
|
#if XXX_fix_me
|
|
|
|
if ((nsnull != wd) && (nsnull != wd->observer)) {
|
|
|
|
nsIPresContext *px = wd->observer->mWebWidget->GetPresContext();
|
|
|
|
nsIPresShell *ps = px->GetShell();
|
|
|
|
nsIViewManager *vm = ps->GetViewManager();
|
|
|
|
|
|
|
|
vm->ShowQuality(!vm->GetShowQuality());
|
|
|
|
|
|
|
|
NS_RELEASE(vm);
|
|
|
|
NS_RELEASE(ps);
|
|
|
|
NS_RELEASE(px);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
1998-07-20 22:22:13 +00:00
|
|
|
|
|
|
|
case VIEWER_DEBUGSAVE:
|
|
|
|
DoDebugSave();
|
|
|
|
break;
|
1998-07-21 00:48:35 +00:00
|
|
|
|
1998-07-27 18:17:07 +00:00
|
|
|
case VIEWER_TOGGLE_SELECTION:
|
|
|
|
DoToggleSelection();
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
1998-07-21 00:48:35 +00:00
|
|
|
case VIEWER_DEBUGROBOT:
|
|
|
|
DoDebugRobot();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIEWER_TOP100:
|
|
|
|
DoSiteWalker();
|
|
|
|
break;
|
1998-07-20 21:16:38 +00:00
|
|
|
}
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // NS_DEBUG
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
// Factory code for creating nsBrowserWindow's
|
|
|
|
|
|
|
|
class nsBrowserWindowFactory : public nsIFactory
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsBrowserWindowFactory();
|
|
|
|
~nsBrowserWindowFactory();
|
|
|
|
|
|
|
|
// nsISupports methods
|
|
|
|
NS_IMETHOD QueryInterface(const nsIID &aIID, void **aResult);
|
|
|
|
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
|
|
|
NS_IMETHOD_(nsrefcnt) Release(void);
|
|
|
|
|
|
|
|
// nsIFactory methods
|
|
|
|
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
|
|
|
const nsIID &aIID,
|
|
|
|
void **aResult);
|
|
|
|
|
|
|
|
NS_IMETHOD LockFactory(PRBool aLock);
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsrefcnt mRefCnt;
|
|
|
|
};
|
|
|
|
|
|
|
|
nsBrowserWindowFactory::nsBrowserWindowFactory()
|
|
|
|
{
|
|
|
|
mRefCnt = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBrowserWindowFactory::~nsBrowserWindowFactory()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
AddRef(); // Increase reference count for caller
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt
|
|
|
|
nsBrowserWindowFactory::AddRef()
|
|
|
|
{
|
|
|
|
return ++mRefCnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt
|
|
|
|
nsBrowserWindowFactory::Release()
|
|
|
|
{
|
|
|
|
if (--mRefCnt == 0) {
|
|
|
|
delete this;
|
|
|
|
return 0; // Don't access mRefCnt after deleting!
|
|
|
|
}
|
|
|
|
return mRefCnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
inst = new nsNativeBrowserWindow();
|
1998-07-20 16:19:22 +00:00
|
|
|
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 rv = NS_OK;
|
|
|
|
nsIFactory* inst = new nsBrowserWindowFactory();
|
|
|
|
if (nsnull == inst) {
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ADDREF(inst);
|
|
|
|
}
|
|
|
|
*aFactory = inst;
|
|
|
|
return rv;
|
|
|
|
}
|