1998-07-19 01:43:02 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2000-03-08 03:40:49 +03:00
|
|
|
* vi:tw=2:ts=2:et:sw=2:
|
1998-07-19 01:43:02 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (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/
|
1998-07-19 01:43:02 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* 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.
|
1998-07-19 01:43:02 +04:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape Communications
|
1999-11-06 06:43:54 +03:00
|
|
|
* Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
2000-03-11 04:05:08 +03:00
|
|
|
* Contributor(s):
|
|
|
|
* Travis Bogard <travis@netscape.com>
|
2000-01-11 23:49:15 +03:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
1998-07-19 01:43:02 +04:00
|
|
|
*/
|
2000-02-03 06:44:22 +03:00
|
|
|
|
2000-02-28 17:51:35 +03:00
|
|
|
#ifdef XP_OS2_VACPP
|
|
|
|
// XXX every other file that pulls in _os2.h has no problem with HTMX there;
|
|
|
|
// this one does; the problem may lie with the order of the headers below,
|
|
|
|
// which is why this fix is here instead of in _os2.h
|
|
|
|
typedef unsigned long HMTX;
|
|
|
|
#endif
|
1999-12-18 05:29:57 +03:00
|
|
|
#include "nsDocShell.h"
|
1998-07-19 01:43:02 +04:00
|
|
|
#include "nsIWebShell.h"
|
2000-02-14 12:16:26 +03:00
|
|
|
#include "nsIWebBrowserChrome.h"
|
1999-11-13 07:06:23 +03:00
|
|
|
#include "nsIInterfaceRequestor.h"
|
1998-07-19 01:43:02 +04:00
|
|
|
#include "nsIDocumentLoader.h"
|
2000-01-29 09:06:25 +03:00
|
|
|
#include "nsIDocumentLoaderObserver.h"
|
|
|
|
#include "nsIDocumentLoaderFactory.h"
|
1998-07-19 01:43:02 +04:00
|
|
|
#include "nsIContentViewer.h"
|
1998-08-12 08:56:40 +04:00
|
|
|
#include "nsIDocumentViewer.h"
|
1999-11-19 10:35:27 +03:00
|
|
|
#include "nsIMarkupDocumentViewer.h"
|
1998-11-04 11:48:22 +03:00
|
|
|
#include "nsIClipboardCommands.h"
|
1998-07-19 01:43:02 +04:00
|
|
|
#include "nsILinkHandler.h"
|
|
|
|
#include "nsIStreamListener.h"
|
2000-01-12 02:11:32 +03:00
|
|
|
#include "nsIPrompt.h"
|
1999-11-30 07:50:42 +03:00
|
|
|
#include "nsNetUtil.h"
|
1999-07-30 08:20:34 +04:00
|
|
|
#include "nsIProtocolHandler.h"
|
|
|
|
#include "nsIDNSService.h"
|
1999-08-04 01:48:40 +04:00
|
|
|
#include "nsIRefreshURI.h"
|
1998-07-21 08:46:55 +04:00
|
|
|
#include "nsIScriptGlobalObject.h"
|
1999-12-03 12:24:22 +03:00
|
|
|
#include "nsIScriptGlobalObjectOwner.h"
|
1998-08-12 08:56:40 +04:00
|
|
|
#include "nsDOMEvent.h"
|
|
|
|
#include "nsIPresContext.h"
|
1999-03-09 12:44:27 +03:00
|
|
|
#include "nsIComponentManager.h"
|
1999-01-05 12:46:33 +03:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIEventQueueService.h"
|
1998-07-19 01:43:02 +04:00
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "nsVoidArray.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsWidgetsCID.h"
|
|
|
|
#include "nsGfxCIID.h"
|
|
|
|
#include "plevent.h"
|
1998-08-15 03:08:54 +04:00
|
|
|
#include "prprf.h"
|
1998-07-28 03:08:52 +04:00
|
|
|
#include "nsIPluginHost.h"
|
1998-08-02 02:19:05 +04:00
|
|
|
#include "nsplugin.h"
|
1999-02-04 03:03:18 +03:00
|
|
|
//#include "nsPluginsCID.h"
|
|
|
|
#include "nsIPluginManager.h"
|
1998-07-31 10:02:06 +04:00
|
|
|
#include "nsIPref.h"
|
1998-08-19 03:25:17 +04:00
|
|
|
#include "nsITimer.h"
|
1998-09-26 02:25:21 +04:00
|
|
|
#include "nsITimerCallback.h"
|
1998-11-14 03:21:19 +03:00
|
|
|
#include "nsIContent.h"
|
1998-07-27 22:17:07 +04:00
|
|
|
#include "prlog.h"
|
1999-02-12 08:43:46 +03:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIPresShell.h"
|
1999-05-06 05:58:48 +04:00
|
|
|
#include "nsIWebShellServices.h"
|
1999-05-18 09:21:37 +04:00
|
|
|
#include "nsIGlobalHistory.h"
|
1999-06-28 14:35:57 +04:00
|
|
|
#include "prmem.h"
|
1999-07-03 07:41:34 +04:00
|
|
|
#include "nsXPIDLString.h"
|
2000-02-11 07:48:09 +03:00
|
|
|
#include "nsDOMError.h"
|
1999-09-02 00:14:02 +04:00
|
|
|
#include "nsIDOMHTMLElement.h"
|
|
|
|
#include "nsIDOMHTMLDocument.h"
|
|
|
|
#include "nsLayoutCID.h"
|
|
|
|
#include "nsIDOMRange.h"
|
1999-11-18 10:06:39 +03:00
|
|
|
#include "nsIURIContentListener.h"
|
1999-11-12 03:19:00 +03:00
|
|
|
#include "nsIDOMDocument.h"
|
1999-11-27 05:14:40 +03:00
|
|
|
#include "nsIBaseWindow.h"
|
1999-11-30 07:32:09 +03:00
|
|
|
#include "nsIDocShell.h"
|
1999-12-03 13:57:59 +03:00
|
|
|
#include "nsIDocShellTreeItem.h"
|
|
|
|
#include "nsIDocShellTreeNode.h"
|
1999-12-12 13:16:15 +03:00
|
|
|
#include "nsIDocShellTreeOwner.h"
|
1999-11-30 07:32:09 +03:00
|
|
|
#include "nsCURILoader.h"
|
2000-02-08 16:40:10 +03:00
|
|
|
#include "nsIDOMWindow.h"
|
2000-02-29 10:07:36 +03:00
|
|
|
#include "nsEscape.h"
|
|
|
|
#include "nsIPlatformCharset.h"
|
|
|
|
#include "nsICharsetConverterManager.h"
|
2000-02-26 04:04:50 +03:00
|
|
|
#include "nsISocketTransportService.h"
|
2000-04-02 05:19:27 +04:00
|
|
|
#include "nsILayoutHistoryState.h"
|
2000-05-19 01:52:23 +04:00
|
|
|
#include "nsTextFormatter.h"
|
1998-07-27 22:17:07 +04:00
|
|
|
|
2000-01-29 09:06:25 +03:00
|
|
|
#include "nsIHTTPChannel.h" // add this to the ick include list...we need it to QI for post data interface
|
|
|
|
#include "nsHTTPEnums.h"
|
|
|
|
|
|
|
|
|
1999-09-13 22:38:02 +04:00
|
|
|
#include "nsILocaleService.h"
|
2000-01-12 02:11:32 +03:00
|
|
|
#include "nsIStringBundle.h"
|
1999-09-13 22:38:02 +04:00
|
|
|
static NS_DEFINE_CID(kLocaleServiceCID, NS_LOCALESERVICE_CID);
|
1999-12-02 10:00:17 +03:00
|
|
|
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
2000-01-12 02:11:32 +03:00
|
|
|
static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
2000-02-29 10:07:36 +03:00
|
|
|
static NS_DEFINE_CID(kPlatformCharsetCID, NS_PLATFORMCHARSET_CID);
|
|
|
|
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
|
1999-08-29 18:31:08 +04:00
|
|
|
|
2000-01-13 01:54:07 +03:00
|
|
|
|
1999-06-18 21:34:08 +04:00
|
|
|
#include "nsIIOService.h"
|
1999-06-23 07:29:44 +04:00
|
|
|
#include "nsIURL.h"
|
2000-01-13 01:54:07 +03:00
|
|
|
#include "nsIProtocolHandler.h"
|
1998-08-20 10:17:47 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
//XXX for nsIPostData; this is wrong; we shouldn't see the nsIDocument type
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
|
2000-04-12 14:00:04 +04:00
|
|
|
|
1998-11-26 21:06:47 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
#undef NOISY_LINKS
|
1999-10-05 04:08:41 +04:00
|
|
|
#undef NOISY_WEBSHELL_LEAKS
|
1998-11-26 21:06:47 +03:00
|
|
|
#else
|
|
|
|
#undef NOISY_LINKS
|
1999-10-05 04:08:41 +04:00
|
|
|
#undef NOISY_WEBSHELL_LEAKS
|
|
|
|
#endif
|
|
|
|
|
1999-12-09 10:21:34 +03:00
|
|
|
#define NOISY_WEBSHELL_LEAKS
|
1999-10-05 04:08:41 +04:00
|
|
|
#ifdef NOISY_WEBSHELL_LEAKS
|
|
|
|
#undef DETECT_WEBSHELL_LEAKS
|
|
|
|
#define DETECT_WEBSHELL_LEAKS
|
1998-11-26 21:06:47 +03:00
|
|
|
#endif
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
/**
|
|
|
|
* Note: the log module is created during initialization which
|
|
|
|
* means that you cannot perform logging before then.
|
|
|
|
*/
|
1998-09-15 04:18:10 +04:00
|
|
|
static PRLogModuleInfo* gLogModule = PR_NewLogModule("webshell");
|
1998-07-19 01:43:02 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define WEB_TRACE_CALLS 0x1
|
|
|
|
#define WEB_TRACE_HISTORY 0x2
|
1999-07-05 03:40:15 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
#define WEB_LOG_TEST(_lm,_bit) (PRIntn((_lm)->level) & (_bit))
|
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
#define WEB_TRACE(_bit,_args) \
|
|
|
|
PR_BEGIN_MACRO \
|
|
|
|
if (WEB_LOG_TEST(gLogModule,_bit)) { \
|
|
|
|
PR_LogPrint _args; \
|
|
|
|
} \
|
|
|
|
PR_END_MACRO
|
|
|
|
#else
|
|
|
|
#define WEB_TRACE(_bit,_args)
|
|
|
|
#endif
|
|
|
|
|
1999-06-08 01:26:10 +04:00
|
|
|
static NS_DEFINE_CID(kGlobalHistoryCID, NS_GLOBALHISTORY_CID);
|
1999-06-18 21:34:08 +04:00
|
|
|
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
1999-06-08 01:26:10 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1999-09-23 07:27:53 +04:00
|
|
|
typedef enum {
|
|
|
|
eCharsetReloadInit,
|
|
|
|
eCharsetReloadRequested,
|
1999-09-24 01:30:07 +04:00
|
|
|
eCharsetReloadStopOrigional
|
1999-09-23 07:27:53 +04:00
|
|
|
} eCharsetReloadState;
|
|
|
|
|
1999-12-18 05:29:57 +03:00
|
|
|
class nsWebShell : public nsDocShell,
|
|
|
|
public nsIWebShell,
|
1998-07-19 01:43:02 +04:00
|
|
|
public nsIWebShellContainer,
|
1999-05-06 05:58:48 +04:00
|
|
|
public nsIWebShellServices,
|
1998-07-21 08:46:55 +04:00
|
|
|
public nsILinkHandler,
|
1998-08-19 03:25:17 +04:00
|
|
|
public nsIDocumentLoaderObserver,
|
1999-12-18 05:29:57 +03:00
|
|
|
public nsIClipboardCommands
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsWebShell();
|
|
|
|
virtual ~nsWebShell();
|
|
|
|
|
1999-02-26 23:02:06 +03:00
|
|
|
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
1998-07-19 01:43:02 +04:00
|
|
|
|
|
|
|
// nsISupports
|
2000-03-06 00:26:01 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1999-11-13 07:06:23 +03:00
|
|
|
// nsIInterfaceRequestor
|
|
|
|
NS_DECL_NSIINTERFACEREQUESTOR
|
|
|
|
|
2000-01-29 09:06:25 +03:00
|
|
|
NS_DECL_NSIDOCUMENTLOADEROBSERVER
|
|
|
|
|
2000-03-01 01:35:33 +03:00
|
|
|
NS_IMETHOD SetupNewViewer(nsIContentViewer* aViewer);
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
// nsIContentViewerContainer
|
1999-09-07 02:59:11 +04:00
|
|
|
NS_IMETHOD Embed(nsIContentViewer* aDocViewer,
|
1998-07-19 01:43:02 +04:00
|
|
|
const char* aCommand,
|
|
|
|
nsISupports* aExtraInfo);
|
|
|
|
|
|
|
|
// nsIWebShell
|
|
|
|
NS_IMETHOD SetContainer(nsIWebShellContainer* aContainer);
|
|
|
|
NS_IMETHOD GetContainer(nsIWebShellContainer*& aResult);
|
1999-11-16 23:06:12 +03:00
|
|
|
NS_IMETHOD GetTopLevelWindow(nsIWebShellContainer** aWebShellWindow);
|
1998-07-19 05:18:40 +04:00
|
|
|
NS_IMETHOD GetRootWebShell(nsIWebShell*& aResult);
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IMETHOD SetParent(nsIWebShell* aParent);
|
|
|
|
NS_IMETHOD GetParent(nsIWebShell*& aParent);
|
1999-10-26 02:20:10 +04:00
|
|
|
NS_IMETHOD GetReferrer(nsIURI **aReferrer);
|
1999-04-16 12:15:04 +04:00
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
// Document load api's
|
|
|
|
NS_IMETHOD GetDocumentLoader(nsIDocumentLoader*& aResult);
|
2000-04-02 05:19:27 +04:00
|
|
|
|
2000-04-16 15:18:41 +04:00
|
|
|
/* NS_IMETHOD LoadURL(const PRUnichar *aURLSpec,
|
1998-11-11 23:31:45 +03:00
|
|
|
const char* aCommand,
|
1999-08-04 00:51:41 +04:00
|
|
|
nsIInputStream* aPostDataStream=nsnull,
|
1998-11-11 23:31:45 +03:00
|
|
|
PRBool aModifyHistory=PR_TRUE,
|
1999-07-01 23:30:20 +04:00
|
|
|
nsLoadFlags aType = nsIChannel::LOAD_NORMAL,
|
1999-09-17 08:26:02 +04:00
|
|
|
nsISupports * aHistoryState=nsnull,
|
2000-02-16 10:30:17 +03:00
|
|
|
const PRUnichar* aReferrer=nsnull,
|
|
|
|
const char * aWindowTarget = nsnull);
|
1998-11-11 23:31:45 +03:00
|
|
|
|
1999-09-08 07:59:21 +04:00
|
|
|
NS_IMETHOD LoadURI(nsIURI * aUri,
|
|
|
|
const char * aCommand,
|
|
|
|
nsIInputStream* aPostDataStream=nsnull,
|
|
|
|
PRBool aModifyHistory=PR_TRUE,
|
|
|
|
nsLoadFlags aType = nsIChannel::LOAD_NORMAL,
|
2000-02-16 10:30:17 +03:00
|
|
|
nsISupports * aHistoryState=nsnull,
|
|
|
|
const PRUnichar* aReferrer=nsnull,
|
|
|
|
const char * aWindowTarget = nsnull);
|
2000-04-16 15:18:41 +04:00
|
|
|
*/
|
2000-02-24 07:16:17 +03:00
|
|
|
void SetReferrer(const PRUnichar* aReferrer);
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
// History api's
|
1998-07-22 15:24:50 +04:00
|
|
|
NS_IMETHOD GoTo(PRInt32 aHistoryIndex);
|
1999-01-29 02:13:48 +03:00
|
|
|
NS_IMETHOD GetHistoryLength(PRInt32& aResult);
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IMETHOD GetHistoryIndex(PRInt32& aResult);
|
1999-02-14 09:35:01 +03:00
|
|
|
NS_IMETHOD GetURL(PRInt32 aHistoryIndex, const PRUnichar** aURLResult);
|
1998-07-19 01:43:02 +04:00
|
|
|
|
|
|
|
// nsIWebShellContainer
|
1999-08-31 18:49:21 +04:00
|
|
|
NS_IMETHOD SetHistoryState(nsISupports* aLayoutHistoryState);
|
2000-02-16 01:55:36 +03:00
|
|
|
NS_IMETHOD FireUnloadEvent(void);
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1999-05-06 05:58:48 +04:00
|
|
|
// nsIWebShellServices
|
1999-09-07 02:59:11 +04:00
|
|
|
NS_IMETHOD LoadDocument(const char* aURL,
|
|
|
|
const char* aCharset= nsnull ,
|
1999-05-19 04:23:03 +04:00
|
|
|
nsCharsetSource aSource = kCharsetUninitialized);
|
1999-09-07 02:59:11 +04:00
|
|
|
NS_IMETHOD ReloadDocument(const char* aCharset= nsnull ,
|
2000-03-27 06:35:05 +04:00
|
|
|
nsCharsetSource aSource = kCharsetUninitialized);
|
1999-05-06 05:58:48 +04:00
|
|
|
NS_IMETHOD StopDocumentLoad(void);
|
|
|
|
NS_IMETHOD SetRendering(PRBool aRender);
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
// nsILinkHandler
|
1999-09-07 02:59:11 +04:00
|
|
|
NS_IMETHOD OnLinkClick(nsIContent* aContent,
|
1998-11-14 03:21:19 +03:00
|
|
|
nsLinkVerb aVerb,
|
1998-08-15 03:08:54 +04:00
|
|
|
const PRUnichar* aURLSpec,
|
|
|
|
const PRUnichar* aTargetSpec,
|
1999-08-04 00:51:41 +04:00
|
|
|
nsIInputStream* aPostDataStream = 0);
|
1998-11-14 03:21:19 +03:00
|
|
|
NS_IMETHOD OnOverLink(nsIContent* aContent,
|
1998-08-15 03:08:54 +04:00
|
|
|
const PRUnichar* aURLSpec,
|
|
|
|
const PRUnichar* aTargetSpec);
|
2000-04-18 08:34:20 +04:00
|
|
|
NS_IMETHOD GetLinkState(const nsString& aLinkURI, nsLinkState& aState);
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1999-09-07 02:59:11 +04:00
|
|
|
// nsIClipboardCommands
|
1998-11-04 11:48:22 +03:00
|
|
|
NS_IMETHOD CanCutSelection (PRBool* aResult);
|
|
|
|
NS_IMETHOD CanCopySelection (PRBool* aResult);
|
|
|
|
NS_IMETHOD CanPasteSelection(PRBool* aResult);
|
|
|
|
|
|
|
|
NS_IMETHOD CutSelection (void);
|
|
|
|
NS_IMETHOD CopySelection (void);
|
|
|
|
NS_IMETHOD PasteSelection(void);
|
|
|
|
|
|
|
|
NS_IMETHOD SelectAll(void);
|
|
|
|
NS_IMETHOD SelectNone(void);
|
|
|
|
|
1998-10-24 00:47:57 +04:00
|
|
|
NS_IMETHOD FindNext(const PRUnichar * aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound);
|
|
|
|
|
1999-11-27 05:14:40 +03:00
|
|
|
// nsIBaseWindow
|
2000-03-11 04:05:08 +03:00
|
|
|
NS_IMETHOD Create();
|
|
|
|
NS_IMETHOD Destroy();
|
|
|
|
NS_IMETHOD SetPositionAndSize(PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy,
|
|
|
|
PRBool fRepaint);
|
|
|
|
NS_IMETHOD GetPositionAndSize(PRInt32* x, PRInt32* y, PRInt32* cx,
|
|
|
|
PRInt32* cy);
|
1999-11-27 05:14:40 +03:00
|
|
|
|
1999-11-30 07:32:09 +03:00
|
|
|
// nsIDocShell
|
2000-03-11 04:05:08 +03:00
|
|
|
NS_IMETHOD SetDocument(nsIDOMDocument *aDOMDoc, nsIDOMElement *aRootNode);
|
1999-11-30 07:32:09 +03:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
// nsWebShell
|
1999-05-05 03:34:10 +04:00
|
|
|
nsIEventQueue* GetEventQueue(void);
|
1998-11-14 03:21:19 +03:00
|
|
|
void HandleLinkClickEvent(nsIContent *aContent,
|
|
|
|
nsLinkVerb aVerb,
|
|
|
|
const PRUnichar* aURLSpec,
|
1998-08-15 03:08:54 +04:00
|
|
|
const PRUnichar* aTargetSpec,
|
1999-08-04 00:51:41 +04:00
|
|
|
nsIInputStream* aPostDataStream = 0);
|
1998-07-19 01:43:02 +04:00
|
|
|
|
|
|
|
static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent);
|
|
|
|
|
1999-06-15 02:11:47 +04:00
|
|
|
NS_IMETHOD SetURL(const PRUnichar* aURL);
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
protected:
|
1999-11-16 23:06:12 +03:00
|
|
|
void GetRootWebShellEvenIfChrome(nsIWebShell** aResult);
|
2000-02-29 09:51:48 +03:00
|
|
|
void InitFrameData();
|
1999-01-19 20:26:06 +03:00
|
|
|
|
1999-05-05 03:34:10 +04:00
|
|
|
nsIEventQueue* mThreadEventQueue;
|
1998-07-21 08:46:55 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
nsIWebShellContainer* mContainer;
|
|
|
|
nsIDocumentLoader* mDocLoader;
|
|
|
|
|
2000-02-16 01:55:36 +03:00
|
|
|
PRBool mFiredUnloadEvent;
|
1999-08-09 04:03:12 +04:00
|
|
|
|
2000-03-11 04:05:08 +03:00
|
|
|
nsRect mBounds;
|
1999-08-24 22:20:30 +04:00
|
|
|
|
1999-09-23 07:27:53 +04:00
|
|
|
eCharsetReloadState mCharsetReloadState;
|
|
|
|
|
1999-08-31 18:49:21 +04:00
|
|
|
nsISupports* mHistoryState; // Weak reference. Session history owns this.
|
1999-04-16 12:15:04 +04:00
|
|
|
|
2000-02-16 01:55:36 +03:00
|
|
|
nsresult FireUnloadForChildren();
|
1999-12-28 12:18:47 +03:00
|
|
|
|
|
|
|
nsresult CreateViewer(nsIChannel* aChannel,
|
|
|
|
const char* aContentType,
|
|
|
|
const char* aCommand,
|
|
|
|
nsIStreamListener** aResult);
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1999-09-22 05:24:20 +04:00
|
|
|
#ifdef DETECT_WEBSHELL_LEAKS
|
1999-08-27 16:32:20 +04:00
|
|
|
private:
|
1999-09-07 02:59:11 +04:00
|
|
|
// We're counting the number of |nsWebShells| to help find leaks
|
|
|
|
static unsigned long gNumberOfWebShells;
|
1999-08-27 16:32:20 +04:00
|
|
|
|
1999-08-27 16:56:52 +04:00
|
|
|
public:
|
1999-09-07 02:59:11 +04:00
|
|
|
static unsigned long TotalWebShellsInExistence() { return gNumberOfWebShells; }
|
1999-08-27 16:32:20 +04:00
|
|
|
#endif
|
1998-07-19 01:43:02 +04:00
|
|
|
};
|
|
|
|
|
1999-09-22 05:24:20 +04:00
|
|
|
#ifdef DETECT_WEBSHELL_LEAKS
|
1999-08-27 16:32:20 +04:00
|
|
|
unsigned long nsWebShell::gNumberOfWebShells = 0;
|
|
|
|
|
1999-08-27 18:01:44 +04:00
|
|
|
extern "C" NS_WEB
|
1999-08-27 16:32:20 +04:00
|
|
|
unsigned long
|
|
|
|
NS_TotalWebShellsInExistence()
|
1999-09-22 05:24:20 +04:00
|
|
|
{
|
|
|
|
return nsWebShell::TotalWebShellsInExistence();
|
|
|
|
}
|
1999-08-27 16:32:20 +04:00
|
|
|
#endif
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Class IID's
|
1999-01-05 12:46:33 +03:00
|
|
|
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
1998-09-26 02:25:21 +04:00
|
|
|
static NS_DEFINE_IID(kChildCID, NS_CHILD_CID);
|
1999-01-17 14:48:58 +03:00
|
|
|
static NS_DEFINE_IID(kDocLoaderServiceCID, NS_DOCUMENTLOADER_SERVICE_CID);
|
1998-09-26 02:25:21 +04:00
|
|
|
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
|
1998-07-19 01:43:02 +04:00
|
|
|
|
|
|
|
// IID's
|
|
|
|
static NS_DEFINE_IID(kIContentViewerContainerIID,
|
|
|
|
NS_ICONTENT_VIEWER_CONTAINER_IID);
|
1998-09-26 02:25:21 +04:00
|
|
|
static NS_DEFINE_IID(kIDocumentLoaderIID, NS_IDOCUMENTLOADER_IID);
|
|
|
|
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
1999-05-07 23:25:58 +04:00
|
|
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
1999-08-04 01:48:40 +04:00
|
|
|
static NS_DEFINE_IID(kRefreshURIIID, NS_IREFRESHURI_IID);
|
|
|
|
|
1998-09-26 02:25:21 +04:00
|
|
|
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
|
|
|
|
static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID);
|
|
|
|
static NS_DEFINE_IID(kIPluginHostIID, NS_IPLUGINHOST_IID);
|
1999-02-04 03:03:18 +03:00
|
|
|
static NS_DEFINE_IID(kCPluginManagerCID, NS_PLUGINMANAGER_CID);
|
1998-09-26 02:25:21 +04:00
|
|
|
static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID);
|
|
|
|
static NS_DEFINE_IID(kITimerCallbackIID, NS_ITIMERCALLBACK_IID);
|
|
|
|
static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID);
|
1998-11-04 11:48:22 +03:00
|
|
|
static NS_DEFINE_IID(kIClipboardCommandsIID, NS_ICLIPBOARDCOMMANDS_IID);
|
1999-01-05 12:46:33 +03:00
|
|
|
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
|
1999-09-02 00:14:02 +04:00
|
|
|
static NS_DEFINE_IID(kIDOMHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID);
|
|
|
|
static NS_DEFINE_CID(kCDOMRangeCID, NS_RANGE_CID);
|
1998-07-19 01:43:02 +04:00
|
|
|
// XXX not sure
|
1998-09-26 02:25:21 +04:00
|
|
|
static NS_DEFINE_IID(kILinkHandlerIID, NS_ILINKHANDLER_IID);
|
1998-07-19 01:43:02 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Note: operator new zeros our memory
|
1999-12-18 05:29:57 +03:00
|
|
|
nsWebShell::nsWebShell() : nsDocShell()
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
1999-09-22 05:24:20 +04:00
|
|
|
#ifdef DETECT_WEBSHELL_LEAKS
|
1999-09-07 02:59:11 +04:00
|
|
|
// We're counting the number of |nsWebShells| to help find leaks
|
|
|
|
++gNumberOfWebShells;
|
1999-08-27 16:32:20 +04:00
|
|
|
#endif
|
1999-10-05 04:08:41 +04:00
|
|
|
#ifdef NOISY_WEBSHELL_LEAKS
|
1999-12-22 02:03:29 +03:00
|
|
|
printf("WEBSHELL+ = %ld\n", gNumberOfWebShells);
|
1999-10-05 04:08:41 +04:00
|
|
|
#endif
|
1999-08-27 16:32:20 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_INIT_REFCNT();
|
1999-09-07 02:59:11 +04:00
|
|
|
mThreadEventQueue = nsnull;
|
2000-02-29 09:51:48 +03:00
|
|
|
InitFrameData();
|
1999-12-08 07:57:23 +03:00
|
|
|
mItemType = typeContent;
|
1999-09-23 07:27:53 +04:00
|
|
|
mCharsetReloadState = eCharsetReloadInit;
|
1999-08-31 18:49:21 +04:00
|
|
|
mHistoryState = nsnull;
|
2000-02-16 01:55:36 +03:00
|
|
|
mFiredUnloadEvent = PR_FALSE;
|
2000-03-11 04:05:08 +03:00
|
|
|
mBounds.SetRect(0, 0, 0, 0);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsWebShell::~nsWebShell()
|
|
|
|
{
|
2000-04-13 07:11:25 +04:00
|
|
|
Destroy();
|
1999-06-08 01:26:10 +04:00
|
|
|
|
1998-07-23 08:24:36 +04:00
|
|
|
// Stop any pending document loads and destroy the loader...
|
1998-08-01 10:45:43 +04:00
|
|
|
if (nsnull != mDocLoader) {
|
|
|
|
mDocLoader->Stop();
|
1998-08-12 08:56:40 +04:00
|
|
|
mDocLoader->RemoveObserver((nsIDocumentLoaderObserver*)this);
|
1999-01-14 09:44:23 +03:00
|
|
|
mDocLoader->SetContainer(nsnull);
|
2000-06-19 09:54:37 +04:00
|
|
|
mDocLoader->Destroy();
|
1998-08-01 10:45:43 +04:00
|
|
|
NS_RELEASE(mDocLoader);
|
|
|
|
}
|
1998-08-19 03:25:17 +04:00
|
|
|
// Cancel any timers that were set for this loader.
|
1999-08-04 01:48:40 +04:00
|
|
|
CancelRefreshURITimers();
|
1998-07-23 08:24:36 +04:00
|
|
|
|
1999-06-02 03:02:15 +04:00
|
|
|
++mRefCnt; // following releases can cause this destructor to be called
|
|
|
|
// recursively if the refcount is allowed to remain 0
|
|
|
|
|
1999-05-05 03:34:10 +04:00
|
|
|
NS_IF_RELEASE(mThreadEventQueue);
|
1999-12-18 05:29:57 +03:00
|
|
|
mContentViewer=nsnull;
|
2000-03-11 04:05:08 +03:00
|
|
|
mDeviceContext=nsnull;
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IF_RELEASE(mContainer);
|
|
|
|
|
2000-02-14 09:48:39 +03:00
|
|
|
if (mScriptGlobal) {
|
2000-02-08 16:40:10 +03:00
|
|
|
mScriptGlobal->SetDocShell(nsnull);
|
2000-02-14 09:48:39 +03:00
|
|
|
mScriptGlobal = nsnull;
|
1998-08-07 08:45:03 +04:00
|
|
|
}
|
2000-02-14 09:48:39 +03:00
|
|
|
if (mScriptContext) {
|
1999-09-09 03:16:49 +04:00
|
|
|
mScriptContext->SetOwner(nsnull);
|
2000-02-14 09:48:39 +03:00
|
|
|
mScriptContext = nsnull;
|
1999-09-09 03:16:49 +04:00
|
|
|
}
|
1998-07-25 05:53:54 +04:00
|
|
|
|
2000-02-29 09:51:48 +03:00
|
|
|
InitFrameData();
|
1999-01-19 20:26:06 +03:00
|
|
|
|
1999-09-22 05:24:20 +04:00
|
|
|
#ifdef DETECT_WEBSHELL_LEAKS
|
1999-09-07 02:59:11 +04:00
|
|
|
// We're counting the number of |nsWebShells| to help find leaks
|
|
|
|
--gNumberOfWebShells;
|
1999-08-27 16:32:20 +04:00
|
|
|
#endif
|
1999-10-05 04:08:41 +04:00
|
|
|
#ifdef NOISY_WEBSHELL_LEAKS
|
1999-12-22 02:03:29 +03:00
|
|
|
printf("WEBSHELL- = %ld\n", gNumberOfWebShells);
|
1999-10-05 04:08:41 +04:00
|
|
|
#endif
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
2000-02-29 09:51:48 +03:00
|
|
|
void nsWebShell::InitFrameData()
|
1999-01-19 20:26:06 +03:00
|
|
|
{
|
2000-02-29 09:51:48 +03:00
|
|
|
SetMarginWidth(-1);
|
|
|
|
SetMarginHeight(-1);
|
1999-01-19 20:26:06 +03:00
|
|
|
}
|
|
|
|
|
2000-02-16 01:55:36 +03:00
|
|
|
nsresult
|
|
|
|
nsWebShell::FireUnloadForChildren()
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
PRInt32 i, n = mChildren.Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
nsIDocShell* shell = (nsIDocShell*) mChildren.ElementAt(i);
|
|
|
|
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(shell));
|
|
|
|
rv = webShell->FireUnloadEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::FireUnloadEvent()
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2000-05-26 04:26:54 +04:00
|
|
|
if (!mFiredUnloadEvent) {
|
|
|
|
mFiredUnloadEvent = PR_TRUE;
|
|
|
|
|
|
|
|
if (mScriptGlobal) {
|
|
|
|
nsIDocumentViewer* docViewer;
|
|
|
|
if (mContentViewer && NS_SUCCEEDED(mContentViewer->QueryInterface(kIDocumentViewerIID, (void**)&docViewer))) {
|
|
|
|
nsIPresContext *presContext;
|
|
|
|
if (NS_SUCCEEDED(docViewer->GetPresContext(presContext))) {
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
|
|
|
nsMouseEvent event;
|
|
|
|
event.eventStructType = NS_EVENT;
|
|
|
|
event.message = NS_PAGE_UNLOAD;
|
|
|
|
rv = mScriptGlobal->HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
|
|
|
|
|
|
|
|
NS_RELEASE(presContext);
|
|
|
|
}
|
|
|
|
NS_RELEASE(docViewer);
|
2000-02-16 01:55:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Fire child unloads now while our data is intact.
|
|
|
|
rv = FireUnloadForChildren();
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-03-06 00:26:01 +03:00
|
|
|
NS_IMPL_ADDREF_INHERITED(nsWebShell, nsDocShell)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsWebShell, nsDocShell)
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1999-11-23 13:08:32 +03:00
|
|
|
NS_INTERFACE_MAP_BEGIN(nsWebShell)
|
2000-03-06 00:26:01 +03:00
|
|
|
#if 0 // inherits from nsDocShell:
|
1999-11-23 13:08:32 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebShell)
|
2000-03-06 00:26:01 +03:00
|
|
|
#endif
|
1999-11-23 13:08:32 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebShell)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebShellServices)
|
1999-12-18 05:29:57 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIContentViewerContainer, nsIWebShell)
|
1999-11-23 13:08:32 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDocumentLoaderObserver)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebShellContainer)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsILinkHandler)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIClipboardCommands)
|
2000-03-06 00:26:01 +03:00
|
|
|
#if 0 // inherits from nsDocShell:
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIScriptGlobalObjectOwner)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
1999-11-27 05:14:40 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIBaseWindow)
|
1999-11-30 07:32:09 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDocShell)
|
1999-12-03 13:57:59 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeItem)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeNode)
|
2000-02-14 09:48:39 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebNavigation)
|
2000-04-13 07:11:25 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIRefreshURI)
|
2000-02-29 09:51:48 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIScrollable)
|
2000-03-06 00:26:01 +03:00
|
|
|
#endif
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsDocShell)
|
1998-07-19 01:43:02 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-13 07:06:23 +03:00
|
|
|
nsWebShell::GetInterface(const nsIID &aIID, void** aInstancePtr)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
1999-11-13 07:06:23 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
2000-01-11 23:59:24 +03:00
|
|
|
nsresult rv = NS_OK;
|
2000-02-19 05:05:52 +03:00
|
|
|
*aInstancePtr = nsnull;
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1999-11-13 07:06:23 +03:00
|
|
|
if(aIID.Equals(NS_GET_IID(nsILinkHandler)))
|
|
|
|
{
|
|
|
|
*aInstancePtr = NS_STATIC_CAST(nsILinkHandler*, this);
|
1999-12-03 12:24:22 +03:00
|
|
|
NS_ADDREF((nsISupports*)*aInstancePtr);
|
1999-11-13 07:06:23 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-12-03 12:24:22 +03:00
|
|
|
else if(aIID.Equals(NS_GET_IID(nsIScriptGlobalObjectOwner)))
|
1999-11-13 07:06:23 +03:00
|
|
|
{
|
1999-12-03 12:24:22 +03:00
|
|
|
*aInstancePtr = NS_STATIC_CAST(nsIScriptGlobalObjectOwner*, this);
|
|
|
|
NS_ADDREF((nsISupports*)*aInstancePtr);
|
1999-11-13 07:06:23 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-12-03 12:24:22 +03:00
|
|
|
else if(aIID.Equals(NS_GET_IID(nsIScriptGlobalObject)))
|
|
|
|
{
|
2000-02-14 09:48:39 +03:00
|
|
|
NS_ENSURE_SUCCESS(EnsureScriptEnvironment(), NS_ERROR_FAILURE);
|
1999-12-03 12:24:22 +03:00
|
|
|
*aInstancePtr = mScriptGlobal;
|
|
|
|
NS_ADDREF((nsISupports*)*aInstancePtr);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-02-08 16:40:10 +03:00
|
|
|
else if(aIID.Equals(NS_GET_IID(nsIDOMWindow)))
|
|
|
|
{
|
2000-02-14 09:48:39 +03:00
|
|
|
NS_ENSURE_SUCCESS(EnsureScriptEnvironment(), NS_ERROR_FAILURE);
|
2000-02-08 16:40:10 +03:00
|
|
|
NS_ENSURE_SUCCESS(mScriptGlobal->QueryInterface(NS_GET_IID(nsIDOMWindow),
|
|
|
|
aInstancePtr), NS_ERROR_FAILURE);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-07-28 03:08:52 +04:00
|
|
|
|
2000-01-11 23:59:24 +03:00
|
|
|
if (!*aInstancePtr || NS_FAILED(rv))
|
2000-03-08 03:40:49 +03:00
|
|
|
return nsDocShell::GetInterface(aIID,aInstancePtr);
|
2000-01-11 23:59:24 +03:00
|
|
|
else
|
|
|
|
return rv;
|
1999-11-13 07:06:23 +03:00
|
|
|
}
|
1998-07-28 03:08:52 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IMETHODIMP
|
2000-03-01 01:35:33 +03:00
|
|
|
nsWebShell::SetupNewViewer(nsIContentViewer* aViewer)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
2000-03-01 01:35:33 +03:00
|
|
|
NS_ENSURE_SUCCESS(nsDocShell::SetupNewViewer(aViewer), NS_ERROR_FAILURE);
|
1999-08-31 18:49:21 +04:00
|
|
|
// If the history state has been set by session history,
|
|
|
|
// set it on the pres shell now that we have a content
|
|
|
|
// viewer.
|
2000-03-01 01:35:33 +03:00
|
|
|
if(mContentViewer && mHistoryState)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(mContentViewer));
|
|
|
|
if(docv)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
docv->GetPresShell(*getter_AddRefs(shell));
|
|
|
|
if(shell)
|
|
|
|
shell->SetHistoryState((nsILayoutHistoryState*)mHistoryState);
|
|
|
|
}
|
1999-08-31 18:49:21 +04:00
|
|
|
}
|
2000-03-01 01:35:33 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-07-19 01:43:02 +04:00
|
|
|
|
2000-03-01 01:35:33 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::Embed(nsIContentViewer* aContentViewer,
|
|
|
|
const char* aCommand,
|
|
|
|
nsISupports* aExtraInfo)
|
|
|
|
{
|
|
|
|
return SetupNewViewer(aContentViewer);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetContainer(nsIWebShellContainer* aContainer)
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mContainer);
|
|
|
|
mContainer = aContainer;
|
1999-11-18 10:06:39 +03:00
|
|
|
NS_IF_ADDREF(mContainer);
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetContainer(nsIWebShellContainer*& aResult)
|
|
|
|
{
|
|
|
|
aResult = mContainer;
|
|
|
|
NS_IF_ADDREF(mContainer);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-16 23:06:12 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetTopLevelWindow(nsIWebShellContainer** aTopLevelWindow)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aTopLevelWindow);
|
1999-11-17 07:19:39 +03:00
|
|
|
*aTopLevelWindow = nsnull;
|
1999-11-16 23:06:12 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIWebShell> rootWebShell;
|
|
|
|
|
|
|
|
GetRootWebShellEvenIfChrome(getter_AddRefs(rootWebShell));
|
1999-11-17 07:19:39 +03:00
|
|
|
if(!rootWebShell)
|
|
|
|
return NS_OK;
|
1999-11-16 23:06:12 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIWebShellContainer> rootContainer;
|
|
|
|
rootWebShell->GetContainer(*aTopLevelWindow);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
nsEventStatus PR_CALLBACK
|
|
|
|
nsWebShell::HandleEvent(nsGUIEvent *aEvent)
|
1999-09-07 02:59:11 +04:00
|
|
|
{
|
1998-07-19 01:43:02 +04:00
|
|
|
return nsEventStatus_eIgnore;
|
|
|
|
}
|
|
|
|
|
1998-10-02 22:44:56 +04:00
|
|
|
NS_IMETHODIMP
|
1998-07-19 05:18:40 +04:00
|
|
|
nsWebShell::GetRootWebShell(nsIWebShell*& aResult)
|
|
|
|
{
|
1999-12-18 05:29:57 +03:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> top;
|
|
|
|
GetSameTypeRootTreeItem(getter_AddRefs(top));
|
|
|
|
nsCOMPtr<nsIWebShell> topAsWebShell(do_QueryInterface(top));
|
|
|
|
aResult = topAsWebShell;
|
|
|
|
NS_IF_ADDREF(aResult);
|
|
|
|
return NS_OK;
|
1998-07-19 05:18:40 +04:00
|
|
|
}
|
|
|
|
|
1999-11-16 23:06:12 +03:00
|
|
|
void
|
|
|
|
nsWebShell::GetRootWebShellEvenIfChrome(nsIWebShell** aResult)
|
1999-04-16 12:15:04 +04:00
|
|
|
{
|
1999-12-18 05:29:57 +03:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> top;
|
|
|
|
GetRootTreeItem(getter_AddRefs(top));
|
|
|
|
nsCOMPtr<nsIWebShell> topAsWebShell(do_QueryInterface(top));
|
|
|
|
*aResult = topAsWebShell;
|
1999-11-16 23:06:12 +03:00
|
|
|
NS_IF_ADDREF(*aResult);
|
1999-04-16 12:15:04 +04:00
|
|
|
}
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetParent(nsIWebShell* aParent)
|
|
|
|
{
|
1999-12-03 13:57:59 +03:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> parentAsTreeItem(do_QueryInterface(aParent));
|
|
|
|
|
|
|
|
mParent = parentAsTreeItem.get();
|
1999-11-30 07:32:09 +03:00
|
|
|
return NS_OK;
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetParent(nsIWebShell*& aParent)
|
1999-04-16 12:15:04 +04:00
|
|
|
{
|
1999-12-08 07:57:23 +03:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> parent;
|
|
|
|
NS_ENSURE_SUCCESS(GetSameTypeParent(getter_AddRefs(parent)), NS_ERROR_FAILURE);
|
1999-04-16 12:15:04 +04:00
|
|
|
|
1999-12-08 07:57:23 +03:00
|
|
|
if(parent)
|
|
|
|
parent->QueryInterface(NS_GET_IID(nsIWebShell), (void**)&aParent);
|
|
|
|
else
|
|
|
|
aParent = nsnull;
|
|
|
|
return NS_OK;
|
1999-04-16 12:15:04 +04:00
|
|
|
}
|
|
|
|
|
1999-10-26 02:20:10 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetReferrer(nsIURI **aReferrer)
|
|
|
|
{
|
2000-02-24 07:16:17 +03:00
|
|
|
*aReferrer = mReferrerURI;
|
|
|
|
NS_IF_ADDREF(*aReferrer);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsWebShell::SetReferrer(const PRUnichar* aReferrer)
|
|
|
|
{
|
|
|
|
NS_NewURI(getter_AddRefs(mReferrerURI), aReferrer, nsnull);
|
1999-10-26 02:20:10 +04:00
|
|
|
}
|
|
|
|
|
1999-06-15 02:11:47 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetURL(const PRUnichar* aURL)
|
|
|
|
{
|
2000-03-04 01:55:40 +03:00
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
NS_ENSURE_SUCCESS(NS_NewURI(getter_AddRefs(uri), aURL, nsnull),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
SetCurrentURI(uri);
|
1999-06-15 02:11:47 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
/**
|
|
|
|
* Document Load methods
|
|
|
|
*/
|
1999-09-07 02:59:11 +04:00
|
|
|
NS_IMETHODIMP
|
1998-08-15 03:08:54 +04:00
|
|
|
nsWebShell::GetDocumentLoader(nsIDocumentLoader*& aResult)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
1998-08-15 03:08:54 +04:00
|
|
|
aResult = mDocLoader;
|
|
|
|
NS_IF_ADDREF(mDocLoader);
|
|
|
|
return (nsnull != mDocLoader) ? NS_OK : NS_ERROR_FAILURE;
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
1999-07-03 05:14:51 +04:00
|
|
|
static PRBool EqualBaseURLs(nsIURI* url1, nsIURI* url2)
|
|
|
|
{
|
1999-10-15 07:50:47 +04:00
|
|
|
nsXPIDLCString spec1;
|
|
|
|
nsXPIDLCString spec2;
|
|
|
|
char * anchor1 = nsnull, * anchor2=nsnull;
|
|
|
|
PRBool rv = PR_FALSE;
|
|
|
|
|
|
|
|
if (url1 && url2) {
|
|
|
|
// XXX We need to make these strcmps case insensitive.
|
|
|
|
url1->GetSpec(getter_Copies(spec1));
|
|
|
|
url2->GetSpec(getter_Copies(spec2));
|
|
|
|
|
|
|
|
/* Don't look at the ref-part */
|
|
|
|
anchor1 = PL_strrchr(spec1, '#');
|
|
|
|
anchor2 = PL_strrchr(spec2, '#');
|
|
|
|
|
|
|
|
if (anchor1)
|
|
|
|
*anchor1 = '\0';
|
|
|
|
if (anchor2)
|
|
|
|
*anchor2 = '\0';
|
|
|
|
|
|
|
|
if (0 == PL_strcmp(spec1,spec2)) {
|
|
|
|
rv = PR_TRUE;
|
|
|
|
}
|
|
|
|
} // url1 && url2
|
1999-07-03 05:14:51 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
// History methods
|
|
|
|
|
2000-04-16 15:18:41 +04:00
|
|
|
NS_IMETHODIMP nsWebShell::GoTo(PRInt32 aIndex)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
2000-04-16 15:18:41 +04:00
|
|
|
NS_ENSURE_STATE(mSessionHistory);
|
|
|
|
NS_ENSURE_TRUE(!IsFrame(), NS_ERROR_FAILURE);
|
1998-07-19 01:43:02 +04:00
|
|
|
|
2000-04-16 15:18:41 +04:00
|
|
|
nsCOMPtr<nsISHEntry> entry;
|
1998-07-19 01:43:02 +04:00
|
|
|
|
2000-04-16 15:18:41 +04:00
|
|
|
NS_ENSURE_SUCCESS(mSessionHistory->GetEntryAtIndex(aIndex, PR_TRUE,
|
|
|
|
getter_AddRefs(entry)), NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_TRUE(entry, NS_ERROR_FAILURE);
|
2000-04-12 03:52:28 +04:00
|
|
|
|
2000-04-16 15:18:41 +04:00
|
|
|
UpdateCurrentSessionHistory();
|
1999-09-08 07:59:21 +04:00
|
|
|
|
2000-04-16 15:18:41 +04:00
|
|
|
NS_ENSURE_SUCCESS(LoadHistoryEntry(entry), NS_ERROR_FAILURE);
|
1999-08-09 04:03:12 +04:00
|
|
|
|
2000-04-16 15:18:41 +04:00
|
|
|
return NS_OK;
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
1999-01-29 02:13:48 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetHistoryLength(PRInt32& aResult)
|
|
|
|
{
|
2000-04-16 15:18:41 +04:00
|
|
|
NS_ENSURE_STATE(mSessionHistory);
|
|
|
|
NS_ENSURE_TRUE(!IsFrame(), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(mSessionHistory->GetCount(&aResult), NS_ERROR_FAILURE);
|
|
|
|
return NS_OK;
|
1999-01-29 02:13:48 +03:00
|
|
|
}
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetHistoryIndex(PRInt32& aResult)
|
|
|
|
{
|
2000-04-16 15:18:41 +04:00
|
|
|
NS_ENSURE_STATE(mSessionHistory);
|
|
|
|
NS_ENSURE_TRUE(!IsFrame(), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(mSessionHistory->GetIndex(&aResult), NS_ERROR_FAILURE);
|
|
|
|
return NS_OK;
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
1998-07-23 03:40:54 +04:00
|
|
|
NS_IMETHODIMP
|
2000-04-16 15:18:41 +04:00
|
|
|
nsWebShell::GetURL(PRInt32 aIndex, const PRUnichar** aURLResult)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mSessionHistory);
|
|
|
|
NS_ENSURE_TRUE(!IsFrame(), NS_ERROR_FAILURE);
|
1998-07-23 03:40:54 +04:00
|
|
|
|
2000-04-16 15:18:41 +04:00
|
|
|
nsCOMPtr<nsISHEntry> entry;
|
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(mSessionHistory->GetEntryAtIndex(aIndex, PR_TRUE,
|
|
|
|
getter_AddRefs(entry)), NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_TRUE(entry, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
|
|
|
|
entry->GetURI(getter_AddRefs(uri));
|
|
|
|
|
|
|
|
NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
|
1998-07-19 01:43:02 +04:00
|
|
|
|
2000-04-16 15:18:41 +04:00
|
|
|
nsXPIDLCString spec;
|
|
|
|
uri->GetSpec(getter_Copies(spec));
|
|
|
|
|
2000-04-17 15:24:01 +04:00
|
|
|
*aURLResult = NS_ConvertASCIItoUCS2(spec).ToNewUnicode();
|
2000-04-16 15:18:41 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-08-09 04:03:12 +04:00
|
|
|
|
1998-07-19 05:18:40 +04:00
|
|
|
//----------------------------------------
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// WebShell container implementation
|
|
|
|
|
1999-08-31 18:49:21 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetHistoryState(nsISupports* aLayoutHistoryState)
|
|
|
|
{
|
|
|
|
mHistoryState = aLayoutHistoryState;
|
1999-09-07 02:59:11 +04:00
|
|
|
return NS_OK;
|
1999-08-31 18:49:21 +04:00
|
|
|
}
|
|
|
|
|
1999-05-06 05:58:48 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Web Shell Services API
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-09-07 02:59:11 +04:00
|
|
|
nsWebShell::LoadDocument(const char* aURL,
|
|
|
|
const char* aCharset,
|
1999-05-06 07:54:40 +04:00
|
|
|
nsCharsetSource aSource)
|
1999-05-06 05:58:48 +04:00
|
|
|
{
|
1999-05-19 04:23:03 +04:00
|
|
|
// XXX hack. kee the aCharset and aSource wait to pick it up
|
1999-11-19 10:35:27 +03:00
|
|
|
nsCOMPtr<nsIContentViewer> cv;
|
|
|
|
NS_ENSURE_SUCCESS(GetContentViewer(getter_AddRefs(cv)), NS_ERROR_FAILURE);
|
|
|
|
if (cv)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIMarkupDocumentViewer> muDV = do_QueryInterface(cv);
|
|
|
|
if (muDV)
|
1999-09-23 07:27:53 +04:00
|
|
|
{
|
1999-11-19 10:35:27 +03:00
|
|
|
nsCharsetSource hint;
|
|
|
|
muDV->GetHintCharacterSetSource((PRInt32 *)(&hint));
|
|
|
|
if( aSource > hint )
|
|
|
|
{
|
2000-04-17 15:24:01 +04:00
|
|
|
muDV->SetHintCharacterSet(NS_ConvertASCIItoUCS2(aCharset).GetUnicode());
|
1999-11-19 10:35:27 +03:00
|
|
|
muDV->SetHintCharacterSetSource((PRInt32)aSource);
|
|
|
|
if(eCharsetReloadRequested != mCharsetReloadState)
|
|
|
|
{
|
|
|
|
mCharsetReloadState = eCharsetReloadRequested;
|
2000-04-17 15:24:01 +04:00
|
|
|
LoadURI(NS_ConvertASCIItoUCS2(aURL).GetUnicode());
|
1999-11-19 10:35:27 +03:00
|
|
|
}
|
|
|
|
}
|
1999-09-23 07:27:53 +04:00
|
|
|
}
|
|
|
|
}
|
1999-05-06 05:58:48 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-07 02:59:11 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::ReloadDocument(const char* aCharset,
|
2000-03-27 06:35:05 +04:00
|
|
|
nsCharsetSource aSource)
|
1999-09-07 02:59:11 +04:00
|
|
|
{
|
1999-05-29 01:32:29 +04:00
|
|
|
|
1999-09-07 02:59:11 +04:00
|
|
|
// XXX hack. kee the aCharset and aSource wait to pick it up
|
1999-11-19 10:35:27 +03:00
|
|
|
nsCOMPtr<nsIContentViewer> cv;
|
|
|
|
NS_ENSURE_SUCCESS(GetContentViewer(getter_AddRefs(cv)), NS_ERROR_FAILURE);
|
|
|
|
if (cv)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIMarkupDocumentViewer> muDV = do_QueryInterface(cv);
|
|
|
|
if (muDV)
|
|
|
|
{
|
|
|
|
nsCharsetSource hint;
|
|
|
|
muDV->GetHintCharacterSetSource((PRInt32 *)(&hint));
|
|
|
|
if( aSource > hint )
|
|
|
|
{
|
2000-04-17 15:24:01 +04:00
|
|
|
muDV->SetHintCharacterSet(NS_ConvertASCIItoUCS2(aCharset).GetUnicode());
|
1999-11-19 10:35:27 +03:00
|
|
|
muDV->SetHintCharacterSetSource((PRInt32)aSource);
|
|
|
|
if(eCharsetReloadRequested != mCharsetReloadState)
|
|
|
|
{
|
|
|
|
mCharsetReloadState = eCharsetReloadRequested;
|
2000-03-27 06:35:05 +04:00
|
|
|
return Reload(reloadNormal);
|
1999-11-19 10:35:27 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-09-23 07:27:53 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
1999-05-19 04:23:03 +04:00
|
|
|
}
|
|
|
|
|
1999-08-18 05:39:20 +04:00
|
|
|
|
1999-05-06 05:58:48 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::StopDocumentLoad(void)
|
|
|
|
{
|
1999-09-23 07:27:53 +04:00
|
|
|
if(eCharsetReloadRequested != mCharsetReloadState)
|
|
|
|
{
|
|
|
|
Stop();
|
|
|
|
}
|
1999-05-06 05:58:48 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetRendering(PRBool aRender)
|
|
|
|
{
|
1999-09-23 07:27:53 +04:00
|
|
|
if(eCharsetReloadRequested != mCharsetReloadState)
|
|
|
|
{
|
|
|
|
if (mContentViewer) {
|
|
|
|
mContentViewer->SetEnableRendering(aRender);
|
|
|
|
}
|
1999-05-07 23:25:58 +04:00
|
|
|
}
|
1999-05-06 05:58:48 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// WebShell link handling
|
|
|
|
|
|
|
|
struct OnLinkClickEvent : public PLEvent {
|
1998-11-14 03:21:19 +03:00
|
|
|
OnLinkClickEvent(nsWebShell* aHandler, nsIContent* aContent,
|
|
|
|
nsLinkVerb aVerb, const PRUnichar* aURLSpec,
|
1999-08-04 00:51:41 +04:00
|
|
|
const PRUnichar* aTargetSpec, nsIInputStream* aPostDataStream = 0);
|
1998-07-19 01:43:02 +04:00
|
|
|
~OnLinkClickEvent();
|
|
|
|
|
|
|
|
void HandleEvent() {
|
1999-09-07 02:59:11 +04:00
|
|
|
mHandler->HandleLinkClickEvent(mContent, mVerb, mURLSpec->GetUnicode(),
|
1999-08-04 00:51:41 +04:00
|
|
|
mTargetSpec->GetUnicode(), mPostDataStream);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsWebShell* mHandler;
|
|
|
|
nsString* mURLSpec;
|
|
|
|
nsString* mTargetSpec;
|
1999-08-04 00:51:41 +04:00
|
|
|
nsIInputStream* mPostDataStream;
|
|
|
|
nsIContent* mContent;
|
|
|
|
nsLinkVerb mVerb;
|
1998-07-19 01:43:02 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void PR_CALLBACK HandlePLEvent(OnLinkClickEvent* aEvent)
|
|
|
|
{
|
|
|
|
aEvent->HandleEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PR_CALLBACK DestroyPLEvent(OnLinkClickEvent* aEvent)
|
|
|
|
{
|
|
|
|
delete aEvent;
|
|
|
|
}
|
|
|
|
|
|
|
|
OnLinkClickEvent::OnLinkClickEvent(nsWebShell* aHandler,
|
1998-11-14 03:21:19 +03:00
|
|
|
nsIContent *aContent,
|
|
|
|
nsLinkVerb aVerb,
|
1998-08-15 03:08:54 +04:00
|
|
|
const PRUnichar* aURLSpec,
|
|
|
|
const PRUnichar* aTargetSpec,
|
1999-08-04 00:51:41 +04:00
|
|
|
nsIInputStream* aPostDataStream)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
1999-05-05 03:34:10 +04:00
|
|
|
nsIEventQueue* eventQueue;
|
1999-01-05 12:46:33 +03:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
mHandler = aHandler;
|
|
|
|
NS_ADDREF(aHandler);
|
|
|
|
mURLSpec = new nsString(aURLSpec);
|
|
|
|
mTargetSpec = new nsString(aTargetSpec);
|
1999-08-04 00:51:41 +04:00
|
|
|
mPostDataStream = aPostDataStream;
|
|
|
|
NS_IF_ADDREF(mPostDataStream);
|
1998-11-14 03:21:19 +03:00
|
|
|
mContent = aContent;
|
|
|
|
NS_IF_ADDREF(mContent);
|
|
|
|
mVerb = aVerb;
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
PL_InitEvent(this, nsnull,
|
|
|
|
(PLHandleEventProc) ::HandlePLEvent,
|
|
|
|
(PLDestroyEventProc) ::DestroyPLEvent);
|
|
|
|
|
1999-01-23 03:52:01 +03:00
|
|
|
eventQueue = aHandler->GetEventQueue();
|
1999-09-07 02:59:11 +04:00
|
|
|
eventQueue->PostEvent(this);
|
|
|
|
NS_RELEASE(eventQueue);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
OnLinkClickEvent::~OnLinkClickEvent()
|
|
|
|
{
|
1998-11-14 03:21:19 +03:00
|
|
|
NS_IF_RELEASE(mContent);
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IF_RELEASE(mHandler);
|
1999-08-04 00:51:41 +04:00
|
|
|
NS_IF_RELEASE(mPostDataStream);
|
1998-07-19 01:43:02 +04:00
|
|
|
if (nsnull != mURLSpec) delete mURLSpec;
|
|
|
|
if (nsnull != mTargetSpec) delete mTargetSpec;
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-09-07 02:59:11 +04:00
|
|
|
nsWebShell::OnLinkClick(nsIContent* aContent,
|
1998-11-14 03:21:19 +03:00
|
|
|
nsLinkVerb aVerb,
|
1998-08-15 03:08:54 +04:00
|
|
|
const PRUnichar* aURLSpec,
|
|
|
|
const PRUnichar* aTargetSpec,
|
1999-08-04 00:51:41 +04:00
|
|
|
nsIInputStream* aPostDataStream)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
1998-07-25 01:03:33 +04:00
|
|
|
OnLinkClickEvent* ev;
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
1999-09-07 02:59:11 +04:00
|
|
|
ev = new OnLinkClickEvent(this, aContent, aVerb, aURLSpec,
|
1999-08-04 00:51:41 +04:00
|
|
|
aTargetSpec, aPostDataStream);
|
1998-07-25 01:03:33 +04:00
|
|
|
if (nsnull == ev) {
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
return rv;
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
1999-05-05 03:34:10 +04:00
|
|
|
nsIEventQueue* nsWebShell::GetEventQueue(void)
|
1999-01-05 12:46:33 +03:00
|
|
|
{
|
1999-05-05 03:34:10 +04:00
|
|
|
NS_PRECONDITION(nsnull != mThreadEventQueue, "EventQueue for thread is null");
|
1999-09-07 02:59:11 +04:00
|
|
|
NS_ADDREF(mThreadEventQueue);
|
1999-01-05 12:46:33 +03:00
|
|
|
return mThreadEventQueue;
|
|
|
|
}
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
void
|
1998-11-14 03:21:19 +03:00
|
|
|
nsWebShell::HandleLinkClickEvent(nsIContent *aContent,
|
|
|
|
nsLinkVerb aVerb,
|
|
|
|
const PRUnichar* aURLSpec,
|
1998-08-15 03:08:54 +04:00
|
|
|
const PRUnichar* aTargetSpec,
|
1999-08-04 00:51:41 +04:00
|
|
|
nsIInputStream* aPostDataStream)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
2000-05-17 09:43:14 +04:00
|
|
|
nsCAutoString target; target.AssignWithConversion(aTargetSpec);
|
1998-11-14 03:21:19 +03:00
|
|
|
|
|
|
|
switch(aVerb) {
|
|
|
|
case eLinkVerb_New:
|
2000-05-17 09:43:14 +04:00
|
|
|
target = "_blank";
|
1998-11-14 03:21:19 +03:00
|
|
|
// Fall into replace case
|
2000-04-01 04:39:15 +04:00
|
|
|
case eLinkVerb_Undefined:
|
|
|
|
// Fall through, this seems like the most reasonable action
|
1999-09-07 02:59:11 +04:00
|
|
|
case eLinkVerb_Replace:
|
1998-11-14 03:21:19 +03:00
|
|
|
{
|
2000-02-15 07:05:04 +03:00
|
|
|
// for now, just hack the verb to be view-link-clicked
|
|
|
|
// and down in the load document code we'll detect this and
|
|
|
|
// set the correct uri loader command
|
2000-04-16 15:18:41 +04:00
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
NS_NewURI(getter_AddRefs(uri), aURLSpec, nsnull);
|
|
|
|
|
2000-06-14 03:56:30 +04:00
|
|
|
nsCOMPtr<nsISupports> owner;
|
|
|
|
GetCurrentDocumentOwner(getter_AddRefs(owner));
|
|
|
|
|
|
|
|
InternalLoad(uri, mCurrentURI, owner, target, aPostDataStream, loadLink);
|
1998-11-14 03:21:19 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case eLinkVerb_Embed:
|
2000-04-01 04:39:15 +04:00
|
|
|
// XXX TODO Should be similar to the HTML IMG ALT attribute handling
|
|
|
|
// in NS 4.x
|
1998-11-14 03:21:19 +03:00
|
|
|
default:
|
2000-04-01 04:39:15 +04:00
|
|
|
NS_ABORT_IF_FALSE(0,"unexpected link verb");
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-11-14 03:21:19 +03:00
|
|
|
nsWebShell::OnOverLink(nsIContent* aContent,
|
1998-08-15 03:08:54 +04:00
|
|
|
const PRUnichar* aURLSpec,
|
|
|
|
const PRUnichar* aTargetSpec)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
2000-04-01 04:39:15 +04:00
|
|
|
nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(mTreeOwner));
|
1998-10-02 22:44:56 +04:00
|
|
|
|
2000-03-31 06:47:04 +04:00
|
|
|
if(browserChrome)
|
2000-03-16 04:02:23 +03:00
|
|
|
browserChrome->SetOverLink(aURLSpec);
|
2000-03-31 06:47:04 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-04-18 08:34:20 +04:00
|
|
|
nsWebShell::GetLinkState(const nsString& aLinkURI, nsLinkState& aState)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
2000-05-16 09:35:23 +04:00
|
|
|
aState = eLinkState_Unvisited;
|
1999-05-18 09:21:37 +04:00
|
|
|
|
2000-04-22 03:31:41 +04:00
|
|
|
if(mGlobalHistory)
|
|
|
|
{
|
|
|
|
nsCAutoString url;
|
|
|
|
url.AssignWithConversion(aLinkURI.GetUnicode());
|
1999-09-07 02:59:11 +04:00
|
|
|
|
2000-04-22 03:31:41 +04:00
|
|
|
PRInt64 lastVisitDate;
|
|
|
|
NS_ENSURE_SUCCESS(mGlobalHistory->GetLastVisitDate(url.GetBuffer(),
|
|
|
|
&lastVisitDate), NS_ERROR_FAILURE);
|
1999-09-07 02:59:11 +04:00
|
|
|
|
2000-04-22 03:31:41 +04:00
|
|
|
// a last-visit-date of zero means we've never seen it before; so
|
|
|
|
// if it's not zero, we must've seen it.
|
|
|
|
if(!LL_IS_ZERO(lastVisitDate))
|
|
|
|
aState = eLinkState_Visited;
|
1999-09-07 02:59:11 +04:00
|
|
|
|
2000-04-22 03:31:41 +04:00
|
|
|
// XXX how to tell if eLinkState_OutOfDate?
|
|
|
|
}
|
1999-05-18 09:21:37 +04:00
|
|
|
|
2000-04-22 03:31:41 +04:00
|
|
|
return NS_OK;
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
1999-03-29 13:21:01 +04:00
|
|
|
NS_IMETHODIMP
|
1999-09-07 02:59:11 +04:00
|
|
|
nsWebShell::OnStartDocumentLoad(nsIDocumentLoader* loader,
|
|
|
|
nsIURI* aURL,
|
1999-04-28 10:47:40 +04:00
|
|
|
const char* aCommand)
|
1999-03-29 13:21:01 +04:00
|
|
|
{
|
1999-03-30 03:01:13 +04:00
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
1999-05-06 07:54:40 +04:00
|
|
|
|
2000-04-22 03:31:41 +04:00
|
|
|
if(loader == mDocLoader)
|
|
|
|
{
|
2000-05-26 04:26:54 +04:00
|
|
|
//fire unload event to old doc
|
|
|
|
rv = FireUnloadEvent();
|
|
|
|
//reset mFiredUnloadEvent for the new doc
|
|
|
|
mFiredUnloadEvent = PR_FALSE;
|
|
|
|
|
2000-04-22 03:31:41 +04:00
|
|
|
nsCOMPtr<nsIDocumentLoaderObserver> dlObserver;
|
1999-09-15 01:49:21 +04:00
|
|
|
|
2000-04-22 03:31:41 +04:00
|
|
|
if(!mDocLoaderObserver && mParent)
|
|
|
|
{
|
|
|
|
/* If this is a frame (in which case it would have a parent && doesn't
|
|
|
|
* have a documentloaderObserver, get it from the rootWebShell
|
|
|
|
*/
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> rootItem;
|
|
|
|
GetSameTypeRootTreeItem(getter_AddRefs(rootItem));
|
|
|
|
nsCOMPtr<nsIDocShell> rootDocShell(do_QueryInterface(rootItem));
|
|
|
|
if(rootDocShell)
|
|
|
|
rootDocShell->GetDocLoaderObserver(getter_AddRefs(dlObserver));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
dlObserver = do_QueryInterface(mDocLoaderObserver); // we need this to addref
|
|
|
|
/*
|
|
|
|
* Fire the OnStartDocumentLoad of the webshell observer
|
1999-09-15 01:49:21 +04:00
|
|
|
*/
|
2000-04-22 03:31:41 +04:00
|
|
|
if(mContainer && dlObserver)
|
|
|
|
dlObserver->OnStartDocumentLoad(mDocLoader, aURL, aCommand);
|
|
|
|
}
|
|
|
|
return rv;
|
1999-03-29 13:21:01 +04:00
|
|
|
}
|
|
|
|
|
1999-04-07 01:01:04 +04:00
|
|
|
|
|
|
|
|
1999-03-29 13:21:01 +04:00
|
|
|
NS_IMETHODIMP
|
1999-09-07 02:59:11 +04:00
|
|
|
nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader,
|
|
|
|
nsIChannel* channel,
|
1999-12-29 10:32:59 +03:00
|
|
|
nsresult aStatus)
|
1999-03-29 13:21:01 +04:00
|
|
|
{
|
2000-04-22 03:31:41 +04:00
|
|
|
if(loader != mDocLoader)
|
|
|
|
return NS_OK;
|
|
|
|
|
2000-06-08 03:13:12 +04:00
|
|
|
nsresult rv = NS_OK;
|
2000-04-22 03:31:41 +04:00
|
|
|
if(!channel)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-06-28 14:35:57 +04:00
|
|
|
|
2000-04-22 03:31:41 +04:00
|
|
|
nsCOMPtr<nsIURI> aURL;
|
|
|
|
NS_ENSURE_SUCCESS(channel->GetURI(getter_AddRefs(aURL)), NS_ERROR_FAILURE);
|
1999-12-16 00:26:12 +03:00
|
|
|
|
2000-04-22 03:31:41 +04:00
|
|
|
// clean up reload state for meta charset
|
|
|
|
if(eCharsetReloadRequested == mCharsetReloadState)
|
1999-12-16 00:26:12 +03:00
|
|
|
mCharsetReloadState = eCharsetReloadStopOrigional;
|
2000-04-22 03:31:41 +04:00
|
|
|
else
|
1999-12-16 00:26:12 +03:00
|
|
|
mCharsetReloadState = eCharsetReloadInit;
|
1999-06-28 14:35:57 +04:00
|
|
|
|
2000-04-22 03:31:41 +04:00
|
|
|
/* one of many safeguards that prevent death and destruction if
|
|
|
|
someone is so very very rude as to bring this window down
|
|
|
|
during this load handler. */
|
|
|
|
nsCOMPtr<nsIWebShell> kungFuDeathGrip(this);
|
|
|
|
|
2000-06-19 09:54:37 +04:00
|
|
|
if(mScriptGlobal && !mEODForCurrentDocument && NS_SUCCEEDED(aStatus))
|
2000-04-22 03:31:41 +04:00
|
|
|
{
|
|
|
|
if(mContentViewer)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIPresContext> presContext;
|
|
|
|
GetPresContext(getter_AddRefs(presContext));
|
|
|
|
if(presContext)
|
|
|
|
{
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
|
|
|
nsMouseEvent event;
|
|
|
|
event.eventStructType = NS_EVENT;
|
|
|
|
event.message = NS_PAGE_LOAD;
|
|
|
|
rv = mScriptGlobal->HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
|
|
|
|
}
|
|
|
|
}
|
1999-04-07 01:01:04 +04:00
|
|
|
}
|
|
|
|
|
2000-04-22 03:31:41 +04:00
|
|
|
mEODForCurrentDocument = PR_TRUE;
|
|
|
|
nsCOMPtr<nsIDocumentLoaderObserver> dlObserver;
|
1999-06-22 02:17:14 +04:00
|
|
|
|
2000-04-22 03:31:41 +04:00
|
|
|
if(!mDocLoaderObserver && mParent)
|
|
|
|
{
|
1999-06-15 02:11:47 +04:00
|
|
|
/* If this is a frame (in which case it would have a parent && doesn't
|
|
|
|
* have a documentloaderObserver, get it from the rootWebShell
|
|
|
|
*/
|
2000-03-11 04:05:08 +03:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> rootItem;
|
|
|
|
GetSameTypeRootTreeItem(getter_AddRefs(rootItem));
|
|
|
|
nsCOMPtr<nsIDocShell> rootDocShell(do_QueryInterface(rootItem));
|
1999-09-07 02:59:11 +04:00
|
|
|
|
2000-04-22 03:31:41 +04:00
|
|
|
if(rootDocShell)
|
|
|
|
rootDocShell->GetDocLoaderObserver(getter_AddRefs(dlObserver));
|
|
|
|
}
|
|
|
|
else
|
1999-09-07 02:59:11 +04:00
|
|
|
dlObserver = do_QueryInterface(mDocLoaderObserver); // we need this to addref
|
|
|
|
|
2000-04-22 03:31:41 +04:00
|
|
|
/*
|
|
|
|
* Fire the OnEndDocumentLoad of the DocLoaderobserver
|
|
|
|
*/
|
|
|
|
if(dlObserver && aURL)
|
|
|
|
dlObserver->OnEndDocumentLoad(mDocLoader, channel, aStatus);
|
|
|
|
|
|
|
|
if(mDocLoader == loader && NS_FAILED(aStatus))
|
|
|
|
{
|
|
|
|
nsXPIDLCString host;
|
2000-06-08 03:13:12 +04:00
|
|
|
nsresult hostResult = aURL->GetHost(getter_Copies(host));
|
|
|
|
if (NS_SUCCEEDED(hostResult) && host)
|
|
|
|
{
|
2000-04-22 03:31:41 +04:00
|
|
|
CBufDescriptor buf((const char *)host, PR_TRUE, PL_strlen(host) + 1);
|
|
|
|
nsCAutoString hostStr(buf);
|
|
|
|
PRInt32 dotLoc = hostStr.FindChar('.');
|
1999-06-15 02:11:47 +04:00
|
|
|
|
2000-04-22 03:31:41 +04:00
|
|
|
|
|
|
|
if(aStatus == NS_ERROR_UNKNOWN_HOST ||
|
|
|
|
aStatus == NS_ERROR_CONNECTION_REFUSED ||
|
|
|
|
aStatus == NS_ERROR_NET_TIMEOUT)
|
|
|
|
{
|
|
|
|
PRBool keywordsEnabled = PR_FALSE;
|
|
|
|
NS_ENSURE_SUCCESS(mPrefs->GetBoolPref("keyword.enabled", &keywordsEnabled),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
if(keywordsEnabled && (-1 == dotLoc))
|
|
|
|
{
|
|
|
|
// only send non-qualified hosts to the keyword server
|
|
|
|
nsAutoString keywordSpec; keywordSpec.AssignWithConversion("keyword:");
|
|
|
|
keywordSpec.AppendWithConversion(host);
|
|
|
|
return LoadURI(keywordSpec.GetUnicode());
|
2000-02-12 04:22:25 +03:00
|
|
|
} // end keywordsEnabled
|
2000-04-22 03:31:41 +04:00
|
|
|
}
|
2000-02-02 01:31:20 +03:00
|
|
|
|
2000-04-22 03:31:41 +04:00
|
|
|
// Doc failed to load because the host was not found.
|
|
|
|
if(aStatus == NS_ERROR_UNKNOWN_HOST)
|
|
|
|
{
|
|
|
|
// Try our www.*.com trick.
|
|
|
|
nsCAutoString retryHost;
|
|
|
|
nsXPIDLCString scheme;
|
|
|
|
NS_ENSURE_SUCCESS(aURL->GetScheme(getter_Copies(scheme)),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
PRUint32 schemeLen = PL_strlen((const char*)scheme);
|
|
|
|
CBufDescriptor schemeBuf((const char*)scheme, PR_TRUE, schemeLen+1, schemeLen);
|
|
|
|
nsCAutoString schemeStr(schemeBuf);
|
|
|
|
|
|
|
|
if(schemeStr.Find("http") == 0)
|
|
|
|
{
|
|
|
|
if(-1 == dotLoc)
|
|
|
|
{
|
|
|
|
retryHost = "www.";
|
|
|
|
retryHost += hostStr;
|
|
|
|
retryHost += ".com";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PRInt32 hostLen = hostStr.Length();
|
|
|
|
if(((hostLen - dotLoc) == 3) || ((hostLen - dotLoc) == 4))
|
|
|
|
{
|
|
|
|
retryHost = "www.";
|
|
|
|
retryHost += hostStr;
|
|
|
|
}
|
|
|
|
}
|
2000-01-14 02:23:20 +03:00
|
|
|
}
|
2000-01-12 02:11:32 +03:00
|
|
|
|
2000-04-22 03:31:41 +04:00
|
|
|
if(!retryHost.IsEmpty())
|
|
|
|
{
|
|
|
|
NS_ENSURE_SUCCESS(aURL->SetHost(retryHost.GetBuffer()),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
nsXPIDLCString aSpec;
|
|
|
|
NS_ENSURE_SUCCESS(aURL->GetSpec(getter_Copies(aSpec)),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
// reload the url
|
|
|
|
return LoadURI(NS_ConvertASCIItoUCS2(aSpec).GetUnicode());
|
2000-01-25 05:47:58 +03:00
|
|
|
} // retry
|
|
|
|
|
2000-04-22 03:31:41 +04:00
|
|
|
// throw a DNS failure dialog
|
|
|
|
nsCOMPtr<nsIPrompt> prompter;
|
|
|
|
nsCOMPtr<nsIStringBundle> stringBundle;
|
|
|
|
GetPromptAndStringBundle(getter_AddRefs(prompter),
|
|
|
|
getter_AddRefs(stringBundle));
|
|
|
|
NS_ENSURE_TRUE(stringBundle, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsXPIDLString messageStr;
|
|
|
|
NS_ENSURE_SUCCESS(stringBundle->GetStringFromName(
|
|
|
|
NS_ConvertASCIItoUCS2("dnsNotFound").GetUnicode(),
|
|
|
|
getter_Copies(messageStr)), NS_ERROR_FAILURE);
|
|
|
|
|
2000-06-06 02:21:37 +04:00
|
|
|
if (host) {
|
|
|
|
PRUnichar *msg = nsTextFormatter::smprintf(messageStr, (const char*)host);
|
|
|
|
if (!msg) return NS_ERROR_OUT_OF_MEMORY;
|
2000-04-22 03:31:41 +04:00
|
|
|
|
2000-06-06 02:21:37 +04:00
|
|
|
prompter->Alert(nsnull, msg);
|
|
|
|
nsTextFormatter::smprintf_free(msg);
|
|
|
|
}
|
2000-04-22 03:31:41 +04:00
|
|
|
}
|
|
|
|
else if(aStatus == NS_ERROR_CONNECTION_REFUSED)
|
|
|
|
{// Doc failed to load because we couldn't connect to the server.
|
|
|
|
// throw a connection failure dialog
|
|
|
|
PRInt32 port = -1;
|
|
|
|
NS_ENSURE_SUCCESS(aURL->GetPort(&port), NS_ERROR_FAILURE);
|
|
|
|
|
2000-06-08 03:13:12 +04:00
|
|
|
nsCOMPtr<nsIPrompt> prompter;
|
|
|
|
nsCOMPtr<nsIStringBundle> stringBundle;
|
|
|
|
GetPromptAndStringBundle(getter_AddRefs(prompter),
|
|
|
|
getter_AddRefs(stringBundle));
|
|
|
|
NS_ENSURE_TRUE(stringBundle, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsXPIDLString messageStr;
|
|
|
|
NS_ENSURE_SUCCESS(stringBundle->GetStringFromName(
|
|
|
|
NS_ConvertASCIItoUCS2("connectionFailure").GetUnicode(),
|
|
|
|
getter_Copies(messageStr)), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
// build up the host:port string.
|
|
|
|
nsCAutoString combo(host);
|
|
|
|
if (port > 0) {
|
|
|
|
combo.Append(':');
|
|
|
|
combo.AppendInt(port);
|
|
|
|
}
|
|
|
|
PRUnichar *msg = nsTextFormatter::smprintf(messageStr, combo.GetBuffer());
|
|
|
|
if (!msg) return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
prompter->Alert(nsnull, msg);
|
|
|
|
nsTextFormatter::smprintf_free(msg);
|
|
|
|
}
|
|
|
|
else if(aStatus == NS_ERROR_NET_TIMEOUT)
|
|
|
|
{// Doc failed to load because the socket function timed out.
|
|
|
|
// throw a timeout dialog
|
|
|
|
nsCOMPtr<nsIPrompt> prompter;
|
|
|
|
nsCOMPtr<nsIStringBundle> stringBundle;
|
|
|
|
GetPromptAndStringBundle(getter_AddRefs(prompter),
|
|
|
|
getter_AddRefs(stringBundle));
|
|
|
|
NS_ENSURE_TRUE(stringBundle, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
|
|
|
|
nsXPIDLString messageStr;
|
|
|
|
NS_ENSURE_SUCCESS(stringBundle->GetStringFromName(
|
|
|
|
NS_ConvertASCIItoUCS2("netTimeout").GetUnicode(),
|
|
|
|
getter_Copies(messageStr)), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
PRUnichar *msg = nsTextFormatter::smprintf(messageStr, (const char*)host);
|
|
|
|
if (!msg) return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
prompter->Alert(nsnull, msg);
|
|
|
|
nsTextFormatter::smprintf_free(msg);
|
|
|
|
} // end NS_ERROR_NET_TIMEOUT
|
|
|
|
} // if we have a host
|
2000-04-22 03:31:41 +04:00
|
|
|
} // end mDocLoader == loader
|
1999-05-04 03:04:50 +04:00
|
|
|
|
2000-04-23 03:19:40 +04:00
|
|
|
return rv;
|
1999-03-29 13:21:01 +04:00
|
|
|
}
|
|
|
|
|
1999-01-14 09:44:23 +03:00
|
|
|
NS_IMETHODIMP
|
1999-09-07 02:59:11 +04:00
|
|
|
nsWebShell::OnStartURLLoad(nsIDocumentLoader* loader,
|
1999-12-29 10:32:59 +03:00
|
|
|
nsIChannel* channel)
|
1999-01-14 09:44:23 +03:00
|
|
|
{
|
1999-06-28 14:35:57 +04:00
|
|
|
nsresult rv;
|
1999-09-15 04:23:40 +04:00
|
|
|
|
1999-06-28 14:35:57 +04:00
|
|
|
nsCOMPtr<nsIURI> aURL;
|
|
|
|
rv = channel->GetURI(getter_AddRefs(aURL));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-04-07 01:01:04 +04:00
|
|
|
|
1999-09-15 23:33:46 +04:00
|
|
|
|
1999-07-07 14:47:35 +04:00
|
|
|
// Stop loading of the earlier document completely when the document url
|
|
|
|
// load starts. Now we know that this url is valid and available.
|
2000-03-11 05:57:39 +03:00
|
|
|
PRBool equals = PR_FALSE;
|
|
|
|
if (NS_SUCCEEDED(aURL->Equals(mCurrentURI, &equals)) && equals)
|
2000-03-11 04:05:08 +03:00
|
|
|
Stop();
|
1999-07-07 14:47:35 +04:00
|
|
|
|
1999-04-07 01:01:04 +04:00
|
|
|
/*
|
|
|
|
*Fire the OnStartDocumentLoad of the webshell observer
|
|
|
|
*/
|
|
|
|
if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver))
|
|
|
|
{
|
1999-12-29 10:32:59 +03:00
|
|
|
mDocLoaderObserver->OnStartURLLoad(mDocLoader, channel);
|
1999-04-07 01:01:04 +04:00
|
|
|
}
|
2000-04-29 04:07:40 +04:00
|
|
|
|
1999-01-14 09:44:23 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-29 13:21:01 +04:00
|
|
|
NS_IMETHODIMP
|
1999-09-07 02:59:11 +04:00
|
|
|
nsWebShell::OnProgressURLLoad(nsIDocumentLoader* loader,
|
|
|
|
nsIChannel* channel,
|
|
|
|
PRUint32 aProgress,
|
1999-03-29 13:21:01 +04:00
|
|
|
PRUint32 aProgressMax)
|
|
|
|
{
|
1999-04-07 01:01:04 +04:00
|
|
|
/*
|
|
|
|
*Fire the OnStartDocumentLoad of the webshell observer and container...
|
|
|
|
*/
|
|
|
|
if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver))
|
|
|
|
{
|
1999-06-28 14:35:57 +04:00
|
|
|
mDocLoaderObserver->OnProgressURLLoad(mDocLoader, channel, aProgress, aProgressMax);
|
1999-04-07 01:01:04 +04:00
|
|
|
}
|
|
|
|
|
1999-03-29 13:21:01 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-09-07 02:59:11 +04:00
|
|
|
nsWebShell::OnStatusURLLoad(nsIDocumentLoader* loader,
|
|
|
|
nsIChannel* channel,
|
1999-04-28 10:47:40 +04:00
|
|
|
nsString& aMsg)
|
1999-03-29 13:21:01 +04:00
|
|
|
{
|
1999-04-07 01:01:04 +04:00
|
|
|
/*
|
|
|
|
*Fire the OnStartDocumentLoad of the webshell observer and container...
|
|
|
|
*/
|
|
|
|
if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver))
|
|
|
|
{
|
1999-06-28 14:35:57 +04:00
|
|
|
mDocLoaderObserver->OnStatusURLLoad(mDocLoader, channel, aMsg);
|
1999-04-07 01:01:04 +04:00
|
|
|
}
|
|
|
|
|
1999-03-29 13:21:01 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-09-07 02:59:11 +04:00
|
|
|
nsWebShell::OnEndURLLoad(nsIDocumentLoader* loader,
|
1999-08-05 05:28:30 +04:00
|
|
|
nsIChannel* channel,
|
|
|
|
nsresult aStatus)
|
1999-03-29 13:21:01 +04:00
|
|
|
{
|
1999-04-30 04:09:52 +04:00
|
|
|
#if 0
|
1999-12-19 21:32:21 +03:00
|
|
|
const char* spec;
|
1999-04-30 04:09:52 +04:00
|
|
|
aURL->GetSpec(&spec);
|
|
|
|
printf("nsWebShell::OnEndURLLoad:%p: loader=%p url=%s status=%d\n", this, loader, spec, aStatus);
|
|
|
|
#endif
|
1999-04-07 01:01:04 +04:00
|
|
|
/*
|
1999-10-13 14:24:12 +04:00
|
|
|
*Fire the OnEndDocumentLoad of the webshell observer
|
1999-04-07 01:01:04 +04:00
|
|
|
*/
|
|
|
|
if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver))
|
|
|
|
{
|
1999-06-28 14:35:57 +04:00
|
|
|
mDocLoaderObserver->OnEndURLLoad(mDocLoader, channel, aStatus);
|
1999-04-07 01:01:04 +04:00
|
|
|
}
|
1999-03-29 13:21:01 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-01-14 09:44:23 +03:00
|
|
|
|
1998-10-24 00:47:57 +04:00
|
|
|
//----------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
1998-11-04 11:48:22 +03:00
|
|
|
nsWebShell::CanCutSelection(PRBool* aResult)
|
1998-10-24 00:47:57 +04:00
|
|
|
{
|
1998-11-04 11:48:22 +03:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
rv = NS_ERROR_NULL_POINTER;
|
|
|
|
} else {
|
|
|
|
*aResult = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
1998-10-24 00:47:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-11-04 11:48:22 +03:00
|
|
|
nsWebShell::CanCopySelection(PRBool* aResult)
|
1998-10-24 00:47:57 +04:00
|
|
|
{
|
1998-11-04 11:48:22 +03:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
rv = NS_ERROR_NULL_POINTER;
|
|
|
|
} else {
|
|
|
|
*aResult = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
1998-10-24 00:47:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-11-04 11:48:22 +03:00
|
|
|
nsWebShell::CanPasteSelection(PRBool* aResult)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
rv = NS_ERROR_NULL_POINTER;
|
|
|
|
} else {
|
|
|
|
*aResult = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::CutSelection(void)
|
1998-10-24 00:47:57 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-11-04 11:48:22 +03:00
|
|
|
nsWebShell::CopySelection(void)
|
1998-10-24 00:47:57 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-11-04 11:48:22 +03:00
|
|
|
nsWebShell::PasteSelection(void)
|
1998-10-24 00:47:57 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-11-04 11:48:22 +03:00
|
|
|
nsWebShell::SelectAll(void)
|
1998-10-24 00:47:57 +04:00
|
|
|
{
|
1999-09-02 00:14:02 +04:00
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocumentViewer> docViewer;
|
|
|
|
rv = mContentViewer->QueryInterface(kIDocumentViewerIID,
|
|
|
|
getter_AddRefs(docViewer));
|
|
|
|
if (NS_FAILED(rv) || !docViewer) return rv;
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1999-09-02 00:14:02 +04:00
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
rv = docViewer->GetPresShell(*getter_AddRefs(presShell));
|
|
|
|
if (NS_FAILED(rv) || !presShell) return rv;
|
2000-04-27 11:37:12 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsISelectionController> selCon = do_QueryInterface(presShell);
|
|
|
|
if (NS_FAILED(rv) || !selCon) return rv;
|
1999-09-02 00:14:02 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMSelection> selection;
|
2000-04-27 11:37:12 +04:00
|
|
|
rv = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
|
1999-09-02 00:14:02 +04:00
|
|
|
if (NS_FAILED(rv) || !selection) return rv;
|
|
|
|
|
|
|
|
// Get the document object
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
rv = docViewer->GetDocument(*getter_AddRefs(doc));
|
|
|
|
if (NS_FAILED(rv) || !doc) return rv;
|
|
|
|
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMHTMLDocument> htmldoc;
|
|
|
|
rv = doc->QueryInterface(kIDOMHTMLDocumentIID, (void**)&htmldoc);
|
|
|
|
if (NS_FAILED(rv) || !htmldoc) return rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMHTMLElement>bodyElement;
|
|
|
|
rv = htmldoc->GetBody(getter_AddRefs(bodyElement));
|
|
|
|
if (NS_FAILED(rv) || !bodyElement) return rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode>bodyNode = do_QueryInterface(bodyElement);
|
|
|
|
if (!bodyNode) return NS_ERROR_NO_INTERFACE;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
rv = selection->Collapse(bodyNode, 0);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1999-09-02 00:14:02 +04:00
|
|
|
nsCOMPtr<nsIDOMRange>range;
|
|
|
|
rv = selection->GetRangeAt(0, getter_AddRefs(range));
|
|
|
|
if (NS_FAILED(rv) || !range) return rv;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rv = selection->ClearSelection();
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMRange> range;
|
|
|
|
rv = nsComponentManager::CreateInstance(kCDOMRangeCID, nsnull,
|
2000-01-11 23:49:15 +03:00
|
|
|
NS_GET_IID(nsIDOMRange),
|
1999-09-02 00:14:02 +04:00
|
|
|
getter_AddRefs(range));
|
|
|
|
|
|
|
|
rv = range->SelectNodeContents(bodyNode);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
rv = selection->AddRange(range);
|
|
|
|
return rv;
|
1998-10-24 00:47:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-11-04 11:48:22 +03:00
|
|
|
nsWebShell::SelectNone(void)
|
1998-10-24 00:47:57 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1999-05-19 04:23:03 +04:00
|
|
|
|
1998-10-24 00:47:57 +04:00
|
|
|
//----------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::FindNext(const PRUnichar * aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound)
|
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1999-11-27 05:14:40 +03:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsWebShell::nsIBaseWindow
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::Create()
|
|
|
|
{
|
2000-03-11 04:05:08 +03:00
|
|
|
// Cache the PL_EventQueue of the current UI thread...
|
|
|
|
//
|
|
|
|
// Since this call must be made on the UI thread, we know the Event Queue
|
|
|
|
// will be associated with the current thread...
|
|
|
|
//
|
|
|
|
nsCOMPtr<nsIEventQueueService> eventService(do_GetService(kEventQueueServiceCID));
|
|
|
|
NS_ENSURE_TRUE(eventService, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(eventService->GetThreadEventQueue(NS_CURRENT_THREAD,
|
|
|
|
&mThreadEventQueue), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
WEB_TRACE(WEB_TRACE_CALLS,
|
|
|
|
("nsWebShell::Init: this=%p", this));
|
|
|
|
|
|
|
|
// HACK....force the uri loader to give us a load cookie for this webshell...then get it's
|
|
|
|
// doc loader and store it...as more of the docshell lands, we'll be able to get rid
|
|
|
|
// of this hack...
|
|
|
|
nsCOMPtr<nsIURILoader> uriLoader = do_GetService(NS_URI_LOADER_PROGID);
|
|
|
|
uriLoader->GetDocumentLoaderForContext(NS_STATIC_CAST( nsISupports*, (nsIWebShell *) this), &mDocLoader);
|
|
|
|
|
|
|
|
// Set the webshell as the default IContentViewerContainer for the loader...
|
|
|
|
mDocLoader->SetContainer(NS_STATIC_CAST(nsIContentViewerContainer*, (nsIWebShell*)this));
|
|
|
|
|
|
|
|
//Register ourselves as an observer for the new doc loader
|
|
|
|
mDocLoader->AddObserver((nsIDocumentLoaderObserver*)this);
|
|
|
|
|
2000-02-14 09:48:39 +03:00
|
|
|
return nsDocShell::Create();
|
1999-11-27 05:14:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::Destroy()
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2000-05-26 04:26:54 +04:00
|
|
|
//Fire unload event before we blow anything away.
|
|
|
|
rv = FireUnloadEvent();
|
1999-11-27 05:14:40 +03:00
|
|
|
|
2000-03-31 04:15:55 +04:00
|
|
|
nsDocShell::Destroy();
|
1999-11-27 05:14:40 +03:00
|
|
|
|
|
|
|
SetContainer(nsnull);
|
|
|
|
|
2000-03-31 04:15:55 +04:00
|
|
|
return NS_OK;
|
1999-11-27 05:14:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::SetPositionAndSize(PRInt32 x, PRInt32 y, PRInt32 cx,
|
|
|
|
PRInt32 cy, PRBool fRepaint)
|
|
|
|
{
|
2000-03-11 04:05:08 +03:00
|
|
|
mBounds.SetRect(x, y, cx, cy);
|
|
|
|
return nsDocShell::SetPositionAndSize(x, y, cx, cy, fRepaint);
|
1999-12-02 12:43:07 +03:00
|
|
|
}
|
2000-03-11 05:57:39 +03:00
|
|
|
|
2000-03-11 04:05:08 +03:00
|
|
|
NS_IMETHODIMP nsWebShell::GetPositionAndSize(PRInt32* x, PRInt32* y,
|
|
|
|
PRInt32* cx, PRInt32* cy)
|
1999-11-27 05:14:40 +03:00
|
|
|
{
|
2000-03-11 04:05:08 +03:00
|
|
|
if(x)
|
|
|
|
*x = mBounds.x;
|
|
|
|
if(y)
|
|
|
|
*y = mBounds.y;
|
|
|
|
if(cx)
|
|
|
|
*cx = mBounds.width;
|
|
|
|
if(cy)
|
|
|
|
*cy = mBounds.height;
|
|
|
|
|
|
|
|
return NS_OK;
|
1999-11-27 05:14:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-30 07:32:09 +03:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsWebShell::nsIDocShell
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::SetDocument(nsIDOMDocument *aDOMDoc,
|
|
|
|
nsIDOMElement *aRootNode)
|
|
|
|
{
|
|
|
|
// The tricky part is bypassing the normal load process and just putting a document into
|
|
|
|
// the webshell. This is particularly nasty, since webshells don't normally even know
|
|
|
|
// about their documents
|
|
|
|
|
|
|
|
// (1) Create a document viewer
|
|
|
|
nsCOMPtr<nsIContentViewer> documentViewer;
|
|
|
|
nsCOMPtr<nsIDocumentLoaderFactory> docFactory;
|
|
|
|
static NS_DEFINE_CID(kLayoutDocumentLoaderFactoryCID, NS_LAYOUT_DOCUMENT_LOADER_FACTORY_CID);
|
|
|
|
NS_ENSURE_SUCCESS(nsComponentManager::CreateInstance(kLayoutDocumentLoaderFactoryCID, nsnull,
|
2000-01-11 23:49:15 +03:00
|
|
|
NS_GET_IID(nsIDocumentLoaderFactory),
|
1999-11-30 07:32:09 +03:00
|
|
|
(void**)getter_AddRefs(docFactory)),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDOMDoc);
|
|
|
|
if (!doc) { return NS_ERROR_NULL_POINTER; }
|
|
|
|
|
1999-12-18 05:29:57 +03:00
|
|
|
NS_ENSURE_SUCCESS(docFactory->CreateInstanceForDocument(NS_STATIC_CAST(nsIContentViewerContainer*, (nsIWebShell*)this),
|
1999-11-30 07:32:09 +03:00
|
|
|
doc,
|
|
|
|
"view",
|
|
|
|
getter_AddRefs(documentViewer)),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
// (2) Feed the webshell to the content viewer
|
|
|
|
NS_ENSURE_SUCCESS(documentViewer->SetContainer((nsIWebShell*)this), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
// (3) Tell the content viewer container to embed the content viewer.
|
|
|
|
// (This step causes everything to be set up for an initial flow.)
|
2000-03-11 04:05:08 +03:00
|
|
|
NS_ENSURE_SUCCESS(SetupNewViewer(documentViewer), NS_ERROR_FAILURE);
|
1999-11-30 07:32:09 +03:00
|
|
|
|
|
|
|
// XXX: It would be great to get rid of this dummy channel!
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
2000-04-17 15:24:01 +04:00
|
|
|
NS_ENSURE_SUCCESS(NS_NewURI(getter_AddRefs(uri), NS_ConvertASCIItoUCS2("about:blank")), NS_ERROR_FAILURE);
|
1999-11-30 07:32:09 +03:00
|
|
|
if (!uri) { return NS_ERROR_OUT_OF_MEMORY; }
|
|
|
|
|
|
|
|
nsCOMPtr<nsIChannel> dummyChannel;
|
|
|
|
NS_ENSURE_SUCCESS(NS_OpenURI(getter_AddRefs(dummyChannel), uri, nsnull), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
// (4) fire start document load notification
|
1999-12-09 10:21:34 +03:00
|
|
|
nsCOMPtr<nsIStreamListener> outStreamListener; // a valid pointer is required for the returned stream listener
|
|
|
|
// XXX: warning: magic cookie! should get string "view delayedContentLoad"
|
|
|
|
// from somewhere, maybe nsIHTMLDocument?
|
2000-05-01 10:58:53 +04:00
|
|
|
NS_ENSURE_SUCCESS(doc->StartDocumentLoad("view delayedContentLoad",
|
|
|
|
dummyChannel,
|
|
|
|
nsnull,
|
|
|
|
NS_STATIC_CAST(nsIContentViewerContainer*, (nsIWebShell*)this),
|
|
|
|
getter_AddRefs(outStreamListener),
|
|
|
|
PR_TRUE),
|
1999-11-30 07:32:09 +03:00
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_SUCCESS(OnStartDocumentLoad(mDocLoader, uri, "load"), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
// (5) hook up the document and its content
|
|
|
|
nsCOMPtr<nsIContent> rootContent = do_QueryInterface(aRootNode);
|
|
|
|
if (!doc) { return NS_ERROR_OUT_OF_MEMORY; }
|
2000-05-19 08:48:43 +04:00
|
|
|
NS_ENSURE_SUCCESS(rootContent->SetDocument(doc, PR_FALSE, PR_TRUE), NS_ERROR_FAILURE);
|
1999-11-30 07:32:09 +03:00
|
|
|
doc->SetRootContent(rootContent);
|
2000-05-19 08:48:43 +04:00
|
|
|
rootContent->SetDocument(doc, PR_TRUE, PR_TRUE);
|
1999-11-30 07:32:09 +03:00
|
|
|
|
|
|
|
// (6) reflow the document
|
|
|
|
PRInt32 i;
|
|
|
|
PRInt32 ns = doc->GetNumberOfShells();
|
|
|
|
for (i = 0; i < ns; i++)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIPresShell> shell(dont_AddRef(doc->GetShellAt(i)));
|
|
|
|
if (shell)
|
|
|
|
{
|
|
|
|
// Make shell an observer for next time
|
|
|
|
NS_ENSURE_SUCCESS(shell->BeginObservingDocument(), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
// Resize-reflow this time
|
|
|
|
nsCOMPtr<nsIDocumentViewer> docViewer = do_QueryInterface(documentViewer);
|
|
|
|
if (!docViewer) { return NS_ERROR_OUT_OF_MEMORY; }
|
|
|
|
nsCOMPtr<nsIPresContext> presContext;
|
|
|
|
NS_ENSURE_SUCCESS(docViewer->GetPresContext(*(getter_AddRefs(presContext))), NS_ERROR_FAILURE);
|
|
|
|
if (!presContext) { return NS_ERROR_OUT_OF_MEMORY; }
|
|
|
|
float p2t;
|
|
|
|
presContext->GetScaledPixelsToTwips(&p2t);
|
|
|
|
|
|
|
|
nsRect r;
|
1999-12-18 05:29:57 +03:00
|
|
|
GetPositionAndSize(&r.x, &r.y, &r.width, &r.height);
|
1999-11-30 07:32:09 +03:00
|
|
|
NS_ENSURE_SUCCESS(shell->InitialReflow(NSToCoordRound(r.width * p2t), NSToCoordRound(r.height * p2t)), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
// Now trigger a refresh
|
|
|
|
nsCOMPtr<nsIViewManager> vm;
|
|
|
|
NS_ENSURE_SUCCESS(shell->GetViewManager(getter_AddRefs(vm)), NS_ERROR_FAILURE);
|
|
|
|
if (vm)
|
|
|
|
{
|
|
|
|
PRBool enabled;
|
|
|
|
documentViewer->GetEnableRendering(&enabled);
|
|
|
|
if (enabled) {
|
2000-02-09 18:48:01 +03:00
|
|
|
vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
|
1999-11-30 07:32:09 +03:00
|
|
|
}
|
|
|
|
NS_ENSURE_SUCCESS(vm->SetWindowDimensions(NSToCoordRound(r.width * p2t),
|
|
|
|
NSToCoordRound(r.height * p2t)),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// (7) fire end document load notification
|
|
|
|
nsresult rv = NS_OK;
|
1999-12-29 10:32:59 +03:00
|
|
|
NS_ENSURE_SUCCESS(OnEndDocumentLoad(mDocLoader, dummyChannel, rv), NS_ERROR_FAILURE);
|
1999-11-30 07:32:09 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); // test the resulting out-param separately
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-08-20 10:17:47 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
// Factory code for creating nsWebShell's
|
|
|
|
|
|
|
|
class nsWebShellFactory : public nsIFactory
|
1998-07-19 05:18:40 +04:00
|
|
|
{
|
1998-07-19 01:43:02 +04:00
|
|
|
public:
|
1998-07-19 05:18:40 +04:00
|
|
|
nsWebShellFactory();
|
1998-07-25 01:03:33 +04:00
|
|
|
virtual ~nsWebShellFactory();
|
1998-07-19 05:18:40 +04:00
|
|
|
|
1999-12-01 06:41:43 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
1998-07-19 01:43:02 +04:00
|
|
|
|
|
|
|
// nsIFactory methods
|
|
|
|
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
|
|
|
const nsIID &aIID,
|
|
|
|
void **aResult);
|
|
|
|
|
|
|
|
NS_IMETHOD LockFactory(PRBool aLock);
|
1998-07-19 05:18:40 +04:00
|
|
|
};
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1998-07-19 05:18:40 +04:00
|
|
|
nsWebShellFactory::nsWebShellFactory()
|
|
|
|
{
|
1999-12-01 06:41:43 +03:00
|
|
|
NS_INIT_REFCNT();
|
1998-07-19 05:18:40 +04:00
|
|
|
}
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1998-07-19 05:18:40 +04:00
|
|
|
nsWebShellFactory::~nsWebShellFactory()
|
|
|
|
{
|
|
|
|
}
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1999-10-08 05:49:06 +04:00
|
|
|
NS_IMPL_ADDREF(nsWebShellFactory);
|
|
|
|
NS_IMPL_RELEASE(nsWebShellFactory);
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1999-11-24 12:40:56 +03:00
|
|
|
NS_INTERFACE_MAP_BEGIN(nsWebShellFactory)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIFactory)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
nsresult
|
|
|
|
nsWebShellFactory::CreateInstance(nsISupports *aOuter,
|
|
|
|
const nsIID &aIID,
|
|
|
|
void **aResult)
|
|
|
|
{
|
1998-07-19 05:18:40 +04:00
|
|
|
nsresult rv;
|
|
|
|
nsWebShell *inst;
|
|
|
|
|
1999-12-01 06:41:43 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
|
|
|
NS_ENSURE_NO_AGGREGATION(aOuter);
|
1998-07-19 01:43:02 +04:00
|
|
|
*aResult = NULL;
|
|
|
|
|
1998-09-18 01:27:22 +04:00
|
|
|
NS_NEWXPCOM(inst, nsWebShell);
|
1999-12-01 06:41:43 +03:00
|
|
|
NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1998-07-19 05:18:40 +04:00
|
|
|
NS_ADDREF(inst);
|
|
|
|
rv = inst->QueryInterface(aIID, aResult);
|
|
|
|
NS_RELEASE(inst);
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1998-07-19 05:18:40 +04:00
|
|
|
return rv;
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsWebShellFactory::LockFactory(PRBool aLock)
|
|
|
|
{
|
|
|
|
// Not implemented in simplest case.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" NS_WEB nsresult
|
1998-07-19 05:18:40 +04:00
|
|
|
NS_NewWebShellFactory(nsIFactory** aFactory)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
1998-07-19 05:18:40 +04:00
|
|
|
nsIFactory* inst = new nsWebShellFactory();
|
|
|
|
if (nsnull == inst) {
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
1998-07-19 05:18:40 +04:00
|
|
|
else {
|
|
|
|
NS_ADDREF(inst);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
1998-07-19 05:18:40 +04:00
|
|
|
*aFactory = inst;
|
1998-07-19 01:43:02 +04:00
|
|
|
return rv;
|
|
|
|
}
|