1998-07-19 01:43:02 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
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.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-07-19 01:43:02 +04:00
|
|
|
*/
|
|
|
|
#include "nsIWebShell.h"
|
1999-11-13 07:06:23 +03:00
|
|
|
#include "nsIInterfaceRequestor.h"
|
1998-07-19 01:43:02 +04:00
|
|
|
#include "nsIDocumentLoader.h"
|
|
|
|
#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 "nsIDeviceContext.h"
|
|
|
|
#include "nsILinkHandler.h"
|
|
|
|
#include "nsIStreamListener.h"
|
1999-07-01 23:30:20 +04: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"
|
|
|
|
#include "nsIScriptContextOwner.h"
|
1998-08-12 08:56:40 +04:00
|
|
|
#include "nsIDocumentLoaderObserver.h"
|
1999-10-13 14:24:12 +04:00
|
|
|
#include "nsIProgressEventSink.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"
|
1999-11-23 12:57:47 +03:00
|
|
|
#include "nsIChromeEventHandler.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-10-30 06:52:11 +04:00
|
|
|
#include "nsIFrame.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-09-09 05:19:11 +04:00
|
|
|
#include "nsIBrowserWindow.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"
|
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-10 06:41:09 +03:00
|
|
|
#include "nsTimer.h"
|
1999-11-27 05:14:40 +03:00
|
|
|
#include "nsIBaseWindow.h"
|
1999-11-30 07:32:09 +03:00
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "nsCURILoader.h"
|
1998-07-27 22:17:07 +04:00
|
|
|
|
1999-09-13 22:38:02 +04:00
|
|
|
#include "nsILocaleService.h"
|
|
|
|
static NS_DEFINE_CID(kLocaleServiceCID, NS_LOCALESERVICE_CID);
|
1999-08-29 18:31:08 +04:00
|
|
|
|
1999-01-25 15:18:51 +03:00
|
|
|
#ifdef XP_PC
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
1998-07-27 22:17:07 +04:00
|
|
|
|
1999-06-18 21:34:08 +04:00
|
|
|
#include "nsIIOService.h"
|
1999-06-23 07:29:44 +04:00
|
|
|
#include "nsIURL.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"
|
|
|
|
|
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
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
1998-08-12 23:54:39 +04:00
|
|
|
|
1999-01-23 03:52:01 +03:00
|
|
|
#if OLD_EVENT_QUEUE
|
|
|
|
/* The following is not used for the GTK version of the browser.
|
1999-09-07 02:59:11 +04:00
|
|
|
* It is still lurking around for Motif
|
1999-01-23 03:52:01 +03:00
|
|
|
*/
|
1998-08-12 23:54:39 +04:00
|
|
|
PLEventQueue* gWebShell_UnixEventQueue;
|
|
|
|
|
|
|
|
void nsWebShell_SetUnixEventQueue(PLEventQueue* aEventQueue)
|
|
|
|
{
|
|
|
|
gWebShell_UnixEventQueue = aEventQueue;
|
|
|
|
}
|
1999-01-23 03:52:01 +03:00
|
|
|
#endif /* OLD_EVENT_QUEUE */
|
1999-04-13 02:49:38 +04:00
|
|
|
|
1998-08-12 23:54:39 +04:00
|
|
|
|
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;
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
class nsWebShell : public nsIWebShell,
|
|
|
|
public nsIWebShellContainer,
|
1999-05-06 05:58:48 +04:00
|
|
|
public nsIWebShellServices,
|
1998-07-21 08:46:55 +04:00
|
|
|
public nsILinkHandler,
|
1998-08-12 08:56:40 +04:00
|
|
|
public nsIScriptContextOwner,
|
1998-08-19 03:25:17 +04:00
|
|
|
public nsIDocumentLoaderObserver,
|
1999-10-13 14:24:12 +04:00
|
|
|
public nsIProgressEventSink, // should go away (nsIDocLoaderObs)
|
1999-07-01 23:30:20 +04:00
|
|
|
public nsIPrompt,
|
1999-08-04 01:48:40 +04:00
|
|
|
public nsIRefreshURI,
|
1999-11-18 10:06:39 +03:00
|
|
|
public nsIURIContentListener,
|
1999-11-13 07:06:23 +03:00
|
|
|
public nsIClipboardCommands,
|
1999-11-27 05:14:40 +03:00
|
|
|
public nsIInterfaceRequestor,
|
1999-11-30 07:32:09 +03:00
|
|
|
public nsIBaseWindow,
|
|
|
|
public nsIDocShell
|
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
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
1999-11-18 10:06:39 +03:00
|
|
|
NS_DECL_NSIURICONTENTLISTENER
|
|
|
|
|
1999-11-13 07:06:23 +03:00
|
|
|
// nsIInterfaceRequestor
|
|
|
|
NS_DECL_NSIINTERFACEREQUESTOR
|
|
|
|
|
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 Init(nsNativeWidget aNativeParent,
|
1998-08-15 03:08:54 +04:00
|
|
|
PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h,
|
1998-08-05 08:23:21 +04:00
|
|
|
nsScrollPreference aScrolling = nsScrollPreference_kAuto,
|
1998-11-03 01:19:08 +03:00
|
|
|
PRBool aAllowPlugins = PR_TRUE,
|
1998-11-05 00:41:26 +03:00
|
|
|
PRBool aIsSunkenBorder = PR_FALSE);
|
1998-08-15 03:08:54 +04:00
|
|
|
NS_IMETHOD GetBounds(PRInt32 &x, PRInt32 &y, PRInt32 &w, PRInt32 &h);
|
|
|
|
NS_IMETHOD SetBounds(PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h);
|
1999-09-04 02:41:56 +04:00
|
|
|
NS_IMETHOD SizeToContent();
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IMETHOD MoveTo(PRInt32 aX, PRInt32 aY);
|
|
|
|
NS_IMETHOD Show();
|
|
|
|
NS_IMETHOD Hide();
|
1998-09-16 01:31:58 +04:00
|
|
|
NS_IMETHOD RemoveFocus();
|
1998-08-09 11:43:22 +04:00
|
|
|
NS_IMETHOD SetContentViewer(nsIContentViewer* aViewer);
|
1998-07-19 01:43:02 +04:00
|
|
|
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-31 10:02:06 +04:00
|
|
|
NS_IMETHOD GetPrefs(nsIPref*& aPrefs);
|
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-09-07 02:59:11 +04:00
|
|
|
NS_IMETHOD GetParentEvenIfChrome(nsIWebShell*& aParent);
|
1999-10-26 02:20:10 +04:00
|
|
|
NS_IMETHOD GetReferrer(nsIURI **aReferrer);
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IMETHOD GetChildCount(PRInt32& aResult);
|
1998-07-19 05:18:40 +04:00
|
|
|
NS_IMETHOD AddChild(nsIWebShell* aChild);
|
1999-05-05 04:23:51 +04:00
|
|
|
NS_IMETHOD RemoveChild(nsIWebShell* aChild);
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIWebShell*& aResult);
|
1999-02-14 09:35:01 +03:00
|
|
|
NS_IMETHOD GetName(const PRUnichar** aName);
|
1998-08-15 03:08:54 +04:00
|
|
|
NS_IMETHOD FindChildWithName(const PRUnichar* aName,
|
1998-07-19 01:43:02 +04:00
|
|
|
nsIWebShell*& aResult);
|
1999-04-16 12:15:04 +04:00
|
|
|
|
1999-09-07 02:59:11 +04:00
|
|
|
NS_IMETHOD SetWebShellType(nsWebShellType aWebShellType);
|
1999-05-28 01:05:27 +04:00
|
|
|
NS_IMETHOD GetWebShellType(nsWebShellType& aWebShellType);
|
1999-11-23 12:57:47 +03:00
|
|
|
NS_IMETHOD GetChromeEventHandler(nsIChromeEventHandler** aChromeEventHandler);
|
|
|
|
NS_IMETHOD SetChromeEventHandler(nsIChromeEventHandler* aChromeEventHander);
|
1999-04-16 12:15:04 +04:00
|
|
|
|
1998-11-10 02:30:16 +03:00
|
|
|
NS_IMETHOD GetScrolling(PRInt32& aScrolling);
|
1999-04-10 01:09:00 +04:00
|
|
|
NS_IMETHOD SetScrolling(PRInt32 aScrolling, PRBool aSetCurrentAndInitial = PR_TRUE);
|
1999-11-19 10:35:27 +03:00
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
// Document load api's
|
|
|
|
NS_IMETHOD GetDocumentLoader(nsIDocumentLoader*& aResult);
|
|
|
|
NS_IMETHOD LoadURL(const PRUnichar *aURLSpec,
|
1999-09-07 02:59:11 +04:00
|
|
|
nsIInputStream* aPostDataStream=nsnull,
|
1998-08-20 03:01:52 +04:00
|
|
|
PRBool aModifyHistory=PR_TRUE,
|
1999-07-01 23:30:20 +04:00
|
|
|
nsLoadFlags aType = nsIChannel::LOAD_NORMAL,
|
1999-09-03 01:39:01 +04:00
|
|
|
const PRUint32 localIP = 0,
|
1999-09-17 08:26:02 +04:00
|
|
|
nsISupports * aHistoryState = nsnull,
|
|
|
|
const PRUnichar* aReferrer=nsnull);
|
1998-11-11 23:31:45 +03:00
|
|
|
NS_IMETHOD LoadURL(const PRUnichar *aURLSpec,
|
|
|
|
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-03 01:39:01 +04:00
|
|
|
const PRUint32 localIP = 0,
|
1999-09-17 08:26:02 +04:00
|
|
|
nsISupports * aHistoryState=nsnull,
|
|
|
|
const PRUnichar* aReferrer=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,
|
|
|
|
const PRUint32 aLocalIP=0,
|
1999-09-17 08:26:02 +04:00
|
|
|
nsISupports * aHistoryState=nsnull,
|
|
|
|
const PRUnichar* aReferrer=nsnull);
|
1999-09-08 07:59:21 +04:00
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
NS_IMETHOD Stop(void);
|
1999-11-30 07:32:09 +03:00
|
|
|
NS_IMETHOD StopBeforeRequestingURL();
|
|
|
|
NS_IMETHOD StopAfterURLAvailable();
|
1999-08-09 04:03:12 +04:00
|
|
|
|
1999-07-01 23:30:20 +04:00
|
|
|
NS_IMETHOD Reload(nsLoadFlags aType);
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
// History api's
|
|
|
|
NS_IMETHOD Back(void);
|
|
|
|
NS_IMETHOD CanBack(void);
|
|
|
|
NS_IMETHOD Forward(void);
|
|
|
|
NS_IMETHOD CanForward(void);
|
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
|
1998-08-15 03:08:54 +04:00
|
|
|
NS_IMETHOD WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason);
|
|
|
|
NS_IMETHOD BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL);
|
|
|
|
NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax);
|
1999-08-05 05:28:30 +04:00
|
|
|
NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsresult aStatus);
|
1998-12-08 05:39:48 +03:00
|
|
|
NS_IMETHOD NewWebShell(PRUint32 aChromeMask,
|
|
|
|
PRBool aVisible,
|
|
|
|
nsIWebShell *&aNewWebShell);
|
1999-05-05 03:34:10 +04:00
|
|
|
NS_IMETHOD ContentShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode);
|
1999-09-07 02:59:11 +04:00
|
|
|
NS_IMETHOD CreatePopup(nsIDOMElement* aElement, nsIDOMElement* aPopupContent,
|
|
|
|
PRInt32 aXPos, PRInt32 aYPos,
|
|
|
|
const nsString& aPopupType, const nsString& anAnchorAlignment,
|
1999-06-09 12:36:06 +04:00
|
|
|
const nsString& aPopupAlignment,
|
1999-07-01 04:07:41 +04:00
|
|
|
nsIDOMWindow* aWindow, nsIDOMWindow** outPopup);
|
1998-09-18 04:35:55 +04:00
|
|
|
NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult);
|
1999-04-13 01:25:08 +04:00
|
|
|
NS_IMETHOD FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken);
|
1999-08-31 02:45:46 +04:00
|
|
|
NS_IMETHOD GetHistoryState(nsISupports** aLayoutHistoryState);
|
1999-08-31 18:49:21 +04:00
|
|
|
NS_IMETHOD SetHistoryState(nsISupports* aLayoutHistoryState);
|
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 ,
|
1999-09-16 18:15:16 +04:00
|
|
|
nsCharsetSource aSource = kCharsetUninitialized,
|
|
|
|
const char* aCmd=nsnull);
|
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);
|
|
|
|
NS_IMETHOD GetLinkState(const PRUnichar* aURLSpec, nsLinkState& aState);
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1998-07-21 08:46:55 +04:00
|
|
|
// nsIScriptContextOwner
|
1999-11-30 07:32:09 +03:00
|
|
|
NS_DECL_NSISCRIPTCONTEXTOWNER
|
1998-07-21 08:46:55 +04:00
|
|
|
|
1999-06-28 14:35:57 +04:00
|
|
|
// nsIDocumentLoaderObserver
|
1999-09-07 02:59:11 +04:00
|
|
|
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader,
|
1999-06-28 14:35:57 +04:00
|
|
|
nsIURI* aURL,
|
|
|
|
const char* aCommand);
|
1999-09-07 02:59:11 +04:00
|
|
|
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader,
|
|
|
|
nsIChannel* channel,
|
1999-08-05 05:28:30 +04:00
|
|
|
nsresult aStatus,
|
1999-07-16 15:14:36 +04:00
|
|
|
nsIDocumentLoaderObserver * );
|
1999-09-07 02:59:11 +04:00
|
|
|
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader,
|
1999-07-16 15:14:36 +04:00
|
|
|
nsIChannel* channel,
|
1999-06-28 14:35:57 +04:00
|
|
|
nsIContentViewer* aViewer);
|
1999-09-07 02:59:11 +04:00
|
|
|
NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader,
|
|
|
|
nsIChannel* channel, PRUint32 aProgress,
|
1999-06-28 14:35:57 +04:00
|
|
|
PRUint32 aProgressMax);
|
1999-09-07 02:59:11 +04:00
|
|
|
NS_IMETHOD OnStatusURLLoad(nsIDocumentLoader* loader,
|
1999-06-28 14:35:57 +04:00
|
|
|
nsIChannel* channel, nsString& aMsg);
|
1999-09-07 02:59:11 +04:00
|
|
|
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader,
|
1999-08-05 05:28:30 +04:00
|
|
|
nsIChannel* channel, nsresult aStatus);
|
1999-09-07 02:59:11 +04:00
|
|
|
NS_IMETHOD HandleUnknownContentType(nsIDocumentLoader* loader,
|
1999-06-28 14:35:57 +04:00
|
|
|
nsIChannel* channel,
|
|
|
|
const char *aContentType,
|
|
|
|
const char *aCommand );
|
1998-08-12 08:56:40 +04:00
|
|
|
|
1999-08-04 01:48:40 +04:00
|
|
|
|
1999-05-29 01:32:29 +04:00
|
|
|
NS_IMETHOD RefreshURL(const char* aURL, PRInt32 millis, PRBool repeat);
|
1998-08-19 03:25:17 +04:00
|
|
|
|
1999-08-04 01:48:40 +04:00
|
|
|
// nsIRefreshURL interface methods...
|
|
|
|
NS_IMETHOD RefreshURI(nsIURI* aURI, PRInt32 aMillis, PRBool aRepeat);
|
|
|
|
NS_IMETHOD CancelRefreshURITimers(void);
|
1999-04-07 01:01:04 +04:00
|
|
|
|
1999-07-01 23:30:20 +04:00
|
|
|
// nsIPrompt
|
1999-08-23 03:52:07 +04:00
|
|
|
NS_DECL_NSIPROMPT
|
1998-11-03 11:03:22 +03:00
|
|
|
|
1999-10-13 14:24:12 +04:00
|
|
|
// nsIProgressEventSink
|
|
|
|
NS_DECL_NSIPROGRESSEVENTSINK
|
|
|
|
|
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
|
|
|
|
NS_DECL_NSIBASEWINDOW
|
|
|
|
|
1999-11-30 07:32:09 +03:00
|
|
|
// nsIDocShell
|
|
|
|
NS_DECL_NSIDOCSHELL
|
|
|
|
|
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
|
|
|
|
|
|
|
void ShowHistory();
|
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
nsIWebShell* GetTarget(const PRUnichar* aName);
|
1998-10-02 22:44:56 +04:00
|
|
|
nsIBrowserWindow* GetBrowserWindow(void);
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1998-08-19 03:25:17 +04:00
|
|
|
static void RefreshURLCallback(nsITimer* aTimer, void* aClosure);
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent);
|
|
|
|
|
1998-09-15 07:46:05 +04:00
|
|
|
nsresult CreatePluginHost(PRBool aAllowPlugins);
|
|
|
|
nsresult DestroyPluginHost(void);
|
1998-07-28 03:08:52 +04:00
|
|
|
|
1999-07-15 18:22:06 +04:00
|
|
|
NS_IMETHOD IsBusy(PRBool& aResult);
|
1999-05-19 04:23:03 +04:00
|
|
|
|
1999-06-15 02:11:47 +04:00
|
|
|
NS_IMETHOD SetSessionHistory(nsISessionHistory * aSHist);
|
|
|
|
NS_IMETHOD GetSessionHistory(nsISessionHistory *& aResult);
|
|
|
|
NS_IMETHOD SetIsInSHist(PRBool aIsFrame);
|
|
|
|
NS_IMETHOD GetIsInSHist(PRBool& aIsFrame);
|
|
|
|
NS_IMETHOD GetURL(const PRUnichar** aURL);
|
|
|
|
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);
|
1999-04-10 01:09:00 +04:00
|
|
|
void InitFrameData(PRBool aCompleteInitScrolling);
|
1999-06-23 07:29:44 +04:00
|
|
|
nsresult CheckForTrailingSlash(nsIURI* aURL);
|
1999-09-19 04:54:55 +04:00
|
|
|
nsresult GetViewManager(nsIViewManager* *viewManager);
|
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
|
|
|
nsIScriptGlobalObject *mScriptGlobal;
|
|
|
|
nsIScriptContext* mScriptContext;
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
nsIWebShellContainer* mContainer;
|
|
|
|
nsIContentViewer* mContentViewer;
|
|
|
|
nsIDeviceContext* mDeviceContext;
|
1998-07-31 10:02:06 +04:00
|
|
|
nsIPref* mPrefs;
|
1998-07-19 01:43:02 +04:00
|
|
|
nsIWidget* mWindow;
|
|
|
|
nsIDocumentLoader* mDocLoader;
|
1999-04-07 01:01:04 +04:00
|
|
|
nsIDocumentLoaderObserver* mDocLoaderObserver;
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1999-11-30 07:32:09 +03:00
|
|
|
nsCOMPtr<nsIDocShell> mParent;
|
1998-07-19 01:43:02 +04:00
|
|
|
nsVoidArray mChildren;
|
|
|
|
nsString mName;
|
1999-03-23 01:21:22 +03:00
|
|
|
nsString mDefaultCharacterSet;
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1999-08-09 04:03:12 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
nsVoidArray mHistory;
|
|
|
|
PRInt32 mHistoryIndex;
|
1999-08-09 04:03:12 +04:00
|
|
|
|
|
|
|
|
1999-06-08 01:26:10 +04:00
|
|
|
nsIGlobalHistory* mHistoryService;
|
1999-06-15 02:11:47 +04:00
|
|
|
nsISessionHistory * mSHist;
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1998-07-19 05:18:40 +04:00
|
|
|
nsString mTitle;
|
1999-06-15 02:11:47 +04:00
|
|
|
nsString mURL;
|
1999-09-17 08:26:02 +04:00
|
|
|
nsString mReferrer;
|
1998-07-19 05:18:40 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
nsString mOverURL;
|
|
|
|
nsString mOverTarget;
|
1999-08-24 22:20:30 +04:00
|
|
|
|
|
|
|
PRPackedBool mIsInSHist;
|
|
|
|
PRPackedBool mFailedToLoadHistoryService;
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
nsScrollPreference mScrollPref;
|
1999-11-19 10:35:27 +03:00
|
|
|
|
1998-08-10 05:01:27 +04:00
|
|
|
PRInt32 mMarginWidth;
|
|
|
|
PRInt32 mMarginHeight;
|
1999-11-19 10:35:27 +03:00
|
|
|
|
1999-04-10 01:09:00 +04:00
|
|
|
PRInt32 mScrolling[2];
|
1998-08-19 03:25:17 +04:00
|
|
|
nsVoidArray mRefreshments;
|
1998-07-27 09:59:37 +04:00
|
|
|
|
1999-09-23 07:27:53 +04:00
|
|
|
eCharsetReloadState mCharsetReloadState;
|
|
|
|
|
1999-09-07 02:59:11 +04:00
|
|
|
nsWebShellType mWebShellType;
|
1999-11-23 12:57:47 +03:00
|
|
|
nsIChromeEventHandler* mChromeEventHandler; //Weak Reference
|
1999-09-21 05:02:29 +04:00
|
|
|
|
1999-08-31 18:49:21 +04:00
|
|
|
nsISupports* mHistoryState; // Weak reference. Session history owns this.
|
1999-04-16 12:15:04 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
void ReleaseChildren();
|
1998-11-22 06:11:26 +03:00
|
|
|
void DestroyChildren();
|
1998-11-23 11:09:11 +03:00
|
|
|
nsresult CreateScriptEnvironment();
|
1999-09-08 07:59:21 +04:00
|
|
|
nsresult DoLoadURL(nsIURI * aUri,
|
1999-02-12 20:32:17 +03:00
|
|
|
const char* aCommand,
|
1999-08-04 00:51:41 +04:00
|
|
|
nsIInputStream* aPostDataStream,
|
1999-07-01 23:30:20 +04:00
|
|
|
nsLoadFlags aType,
|
1999-09-17 08:26:02 +04:00
|
|
|
const PRUint32 aLocalIP,
|
1999-11-18 10:06:39 +03:00
|
|
|
const PRUnichar* aReferrer,
|
|
|
|
PRBool aKickOffLoad = PR_TRUE);
|
|
|
|
|
|
|
|
nsresult PrepareToLoadURI(nsIURI * aUri,
|
|
|
|
const char * aCommand,
|
|
|
|
nsIInputStream * aPostStream,
|
|
|
|
PRBool aModifyHistory,
|
|
|
|
nsLoadFlags aType,
|
|
|
|
const PRUint32 aLocalIP,
|
|
|
|
nsISupports * aHistoryState,
|
|
|
|
const PRUnichar * aReferrer);
|
1999-04-16 08:25:17 +04:00
|
|
|
float mZoom;
|
|
|
|
|
1998-07-28 03:08:52 +04:00
|
|
|
static nsIPluginHost *mPluginHost;
|
|
|
|
static nsIPluginManager *mPluginManager;
|
1998-09-15 07:46:05 +04:00
|
|
|
static PRUint32 mPluginInitCnt;
|
1999-05-04 03:04:50 +04:00
|
|
|
PRBool mProcessedEndDocumentLoad;
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1999-05-19 04:23:03 +04:00
|
|
|
// XXX store mHintCharset and mHintCharsetSource here untill we find out a good cood path
|
1999-11-19 10:35:27 +03:00
|
|
|
/*
|
1999-05-19 04:23:03 +04:00
|
|
|
nsString mHintCharset;
|
1999-09-07 02:59:11 +04:00
|
|
|
nsCharsetSource mHintCharsetSource;
|
1999-05-28 05:31:55 +04:00
|
|
|
nsString mForceCharacterSet;
|
1999-11-19 10:35:27 +03:00
|
|
|
*/
|
1999-08-09 18:30:32 +04:00
|
|
|
|
1999-11-19 10:35:27 +03:00
|
|
|
PRBool mViewSource;
|
|
|
|
|
1999-08-09 18:30:32 +04:00
|
|
|
// if there is no mWindow, this will keep track of the bounds --dwc0001
|
|
|
|
nsRect mBounds;
|
1999-08-27 16:32:20 +04:00
|
|
|
|
1999-11-18 10:06:39 +03:00
|
|
|
// the parent content listener has a life time longer than our own...
|
|
|
|
// so we should not have an owning ref on this variable
|
|
|
|
nsIURIContentListener * mParentContentListener;
|
|
|
|
|
1999-11-12 00:35:34 +03:00
|
|
|
MOZ_TIMER_DECLARE(mTotalTime)
|
1999-09-24 11:13:39 +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);
|
|
|
|
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_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);
|
1999-09-07 02:59:11 +04:00
|
|
|
static NS_DEFINE_IID(kIDocumentLoaderObserverIID,
|
1998-09-26 02:25:21 +04:00
|
|
|
NS_IDOCUMENT_LOADER_OBSERVER_IID);
|
1999-10-13 14:24:12 +04:00
|
|
|
static NS_DEFINE_IID(kIProgressEventSinkIID, NS_IPROGRESSEVENTSINK_IID);
|
1998-09-26 02:25:21 +04:00
|
|
|
static NS_DEFINE_IID(kIDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
|
|
|
|
static NS_DEFINE_IID(kIDocumentLoaderIID, NS_IDOCUMENTLOADER_IID);
|
|
|
|
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
1998-07-21 08:46:55 +04:00
|
|
|
static NS_DEFINE_IID(kIScriptContextOwnerIID, NS_ISCRIPTCONTEXTOWNER_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);
|
|
|
|
static NS_DEFINE_IID(kIBrowserWindowIID, NS_IBROWSER_WINDOW_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-10-12 08:37:43 +04:00
|
|
|
static NS_DEFINE_IID(kISessionHistoryIID, NS_ISESSIONHISTORY_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
|
|
|
|
1998-07-28 03:08:52 +04:00
|
|
|
nsIPluginHost *nsWebShell::mPluginHost = nsnull;
|
|
|
|
nsIPluginManager *nsWebShell::mPluginManager = nsnull;
|
1998-09-15 07:46:05 +04:00
|
|
|
PRUint32 nsWebShell::mPluginInitCnt = 0;
|
1998-07-28 03:08:52 +04:00
|
|
|
|
1998-09-15 07:46:05 +04:00
|
|
|
nsresult nsWebShell::CreatePluginHost(PRBool aAllowPlugins)
|
1998-07-28 03:08:52 +04:00
|
|
|
{
|
1998-09-15 07:46:05 +04:00
|
|
|
nsresult rv = NS_OK;
|
1998-07-28 03:08:52 +04:00
|
|
|
|
1998-09-15 07:46:05 +04:00
|
|
|
if ((PR_TRUE == aAllowPlugins) && (0 == mPluginInitCnt))
|
1998-07-28 03:08:52 +04:00
|
|
|
{
|
1998-09-15 07:46:05 +04:00
|
|
|
if (nsnull == mPluginManager)
|
1998-07-28 03:08:52 +04:00
|
|
|
{
|
1999-03-08 03:01:02 +03:00
|
|
|
// use the service manager to obtain the plugin manager.
|
|
|
|
rv = nsServiceManager::GetService(kCPluginManagerCID, kIPluginManagerIID,
|
1999-09-07 02:59:11 +04:00
|
|
|
(nsISupports**)&mPluginManager);
|
1998-09-15 07:46:05 +04:00
|
|
|
if (NS_OK == rv)
|
1998-07-28 03:08:52 +04:00
|
|
|
{
|
1998-09-15 07:46:05 +04:00
|
|
|
if (NS_OK == mPluginManager->QueryInterface(kIPluginHostIID,
|
|
|
|
(void **)&mPluginHost))
|
|
|
|
{
|
|
|
|
mPluginHost->Init();
|
|
|
|
}
|
1998-07-28 03:08:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-09-15 07:46:05 +04:00
|
|
|
mPluginInitCnt++;
|
|
|
|
|
1998-07-28 03:08:52 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-09-15 07:46:05 +04:00
|
|
|
nsresult nsWebShell::DestroyPluginHost(void)
|
|
|
|
{
|
|
|
|
mPluginInitCnt--;
|
|
|
|
|
|
|
|
NS_ASSERTION(!(mPluginInitCnt < 0), "underflow in plugin host destruction");
|
|
|
|
|
|
|
|
if (0 == mPluginInitCnt)
|
|
|
|
{
|
1999-03-08 03:01:02 +03:00
|
|
|
if (nsnull != mPluginHost) {
|
1998-09-15 07:46:05 +04:00
|
|
|
mPluginHost->Destroy();
|
1999-03-08 03:01:02 +03:00
|
|
|
mPluginHost->Release();
|
|
|
|
mPluginHost = NULL;
|
|
|
|
}
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1999-03-08 03:01:02 +03:00
|
|
|
// use the service manager to release the plugin manager.
|
|
|
|
if (nsnull != mPluginManager) {
|
|
|
|
nsServiceManager::ReleaseService(kCPluginManagerCID, mPluginManager);
|
|
|
|
mPluginManager = NULL;
|
|
|
|
}
|
1998-09-15 07:46:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Note: operator new zeros our memory
|
|
|
|
nsWebShell::nsWebShell()
|
|
|
|
{
|
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
|
|
|
|
printf("WEBSHELL+ = %d\n", gNumberOfWebShells);
|
|
|
|
#endif
|
1999-08-27 16:32:20 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_INIT_REFCNT();
|
|
|
|
mHistoryIndex = -1;
|
1998-07-27 09:59:37 +04:00
|
|
|
mScrollPref = nsScrollPreference_kAuto;
|
1998-07-25 05:53:54 +04:00
|
|
|
mScriptGlobal = nsnull;
|
|
|
|
mScriptContext = nsnull;
|
1999-09-07 02:59:11 +04:00
|
|
|
mThreadEventQueue = nsnull;
|
1999-04-10 01:09:00 +04:00
|
|
|
InitFrameData(PR_TRUE);
|
1999-09-07 02:59:11 +04:00
|
|
|
mWebShellType = nsWebShellContent;
|
1999-11-23 12:57:47 +03:00
|
|
|
mChromeEventHandler = nsnull;
|
1999-06-15 02:11:47 +04:00
|
|
|
mSHist = nsnull;
|
|
|
|
mIsInSHist = PR_FALSE;
|
1999-08-24 22:20:30 +04:00
|
|
|
mFailedToLoadHistoryService = PR_FALSE;
|
1999-07-15 00:57:57 +04:00
|
|
|
mDefaultCharacterSet = "";
|
1999-05-04 03:04:50 +04:00
|
|
|
mProcessedEndDocumentLoad = PR_FALSE;
|
1999-09-23 07:27:53 +04:00
|
|
|
mCharsetReloadState = eCharsetReloadInit;
|
1999-09-16 18:15:16 +04:00
|
|
|
mViewSource=PR_FALSE;
|
1999-06-08 01:26:10 +04:00
|
|
|
mHistoryService = nsnull;
|
1999-08-31 18:49:21 +04:00
|
|
|
mHistoryState = nsnull;
|
1999-11-18 10:06:39 +03:00
|
|
|
mParentContentListener = nsnull;
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsWebShell::~nsWebShell()
|
|
|
|
{
|
1999-06-08 01:26:10 +04:00
|
|
|
if (nsnull != mHistoryService) {
|
|
|
|
nsServiceManager::ReleaseService(kGlobalHistoryCID, mHistoryService);
|
|
|
|
mHistoryService = nsnull;
|
|
|
|
}
|
|
|
|
|
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);
|
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-10-12 08:37:43 +04:00
|
|
|
NS_IF_RELEASE(mSHist);
|
1998-10-07 02:33:13 +04:00
|
|
|
NS_IF_RELEASE(mWindow);
|
1999-05-05 03:34:10 +04:00
|
|
|
NS_IF_RELEASE(mThreadEventQueue);
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IF_RELEASE(mContentViewer);
|
1998-09-30 22:59:03 +04:00
|
|
|
NS_IF_RELEASE(mDeviceContext);
|
1998-07-31 10:02:06 +04:00
|
|
|
NS_IF_RELEASE(mPrefs);
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IF_RELEASE(mContainer);
|
|
|
|
|
1998-08-07 08:45:03 +04:00
|
|
|
if (nsnull != mScriptGlobal) {
|
|
|
|
mScriptGlobal->SetWebShell(nsnull);
|
|
|
|
NS_RELEASE(mScriptGlobal);
|
|
|
|
}
|
1999-09-09 03:16:49 +04:00
|
|
|
if (nsnull != mScriptContext) {
|
|
|
|
mScriptContext->SetOwner(nsnull);
|
|
|
|
NS_RELEASE(mScriptContext);
|
|
|
|
}
|
1998-07-25 05:53:54 +04:00
|
|
|
|
1999-04-10 01:09:00 +04:00
|
|
|
InitFrameData(PR_TRUE);
|
1999-01-19 20:26:06 +03:00
|
|
|
|
1998-11-22 06:11:26 +03:00
|
|
|
// XXX Because we hold references to the children and they hold references
|
|
|
|
// to us we never get destroyed. See Destroy() instead...
|
|
|
|
#if 0
|
1998-07-19 01:43:02 +04:00
|
|
|
// Release references on our children
|
|
|
|
ReleaseChildren();
|
1998-11-22 06:11:26 +03:00
|
|
|
#endif
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1999-08-09 04:03:12 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
// Free up history memory
|
|
|
|
PRInt32 i, n = mHistory.Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
nsString* s = (nsString*) mHistory.ElementAt(i);
|
|
|
|
delete s;
|
|
|
|
}
|
1998-09-15 07:46:05 +04:00
|
|
|
|
1999-08-09 04:03:12 +04:00
|
|
|
|
1998-09-15 07:46:05 +04:00
|
|
|
DestroyPluginHost();
|
1999-08-27 16:32:20 +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
|
|
|
|
printf("WEBSHELL- = %d\n", gNumberOfWebShells);
|
|
|
|
#endif
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
1999-04-10 01:09:00 +04:00
|
|
|
void nsWebShell::InitFrameData(PRBool aCompleteInitScrolling)
|
1999-01-19 20:26:06 +03:00
|
|
|
{
|
1999-04-10 01:09:00 +04:00
|
|
|
if (aCompleteInitScrolling) {
|
|
|
|
mScrolling[0] = -1;
|
|
|
|
mScrolling[1] = -1;
|
1999-11-19 10:35:27 +03:00
|
|
|
SetMarginWidth(-1);
|
|
|
|
SetMarginHeight(-1);
|
1999-04-10 01:09:00 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
mScrolling[1] = mScrolling[0];
|
|
|
|
}
|
1999-01-19 20:26:06 +03:00
|
|
|
}
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
void
|
|
|
|
nsWebShell::ReleaseChildren()
|
|
|
|
{
|
|
|
|
PRInt32 i, n = mChildren.Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
1999-11-30 07:32:09 +03:00
|
|
|
nsCOMPtr<nsIDocShell> shell = (nsIDocShell*) mChildren.ElementAt(i);
|
1998-07-19 01:43:02 +04:00
|
|
|
shell->SetParent(nsnull);
|
1998-08-09 11:43:22 +04:00
|
|
|
|
|
|
|
//Break circular reference of webshell to contentviewer
|
1999-11-30 07:32:09 +03:00
|
|
|
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(shell));
|
|
|
|
webShell->SetContentViewer(nsnull);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
mChildren.Clear();
|
|
|
|
}
|
|
|
|
|
1998-11-22 06:11:26 +03:00
|
|
|
void
|
|
|
|
nsWebShell::DestroyChildren()
|
|
|
|
{
|
|
|
|
PRInt32 i, n = mChildren.Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
1999-11-30 07:32:09 +03:00
|
|
|
nsCOMPtr<nsIDocShell> shell = (nsIDocShell*) mChildren.ElementAt(i);
|
1998-11-22 06:11:26 +03:00
|
|
|
shell->SetParent(nsnull);
|
1999-11-30 07:32:09 +03:00
|
|
|
nsCOMPtr<nsIBaseWindow> shellWin(do_QueryInterface(shell));
|
|
|
|
shellWin->Destroy();
|
1998-11-22 06:11:26 +03:00
|
|
|
}
|
|
|
|
mChildren.Clear();
|
|
|
|
}
|
|
|
|
|
1999-06-20 02:06:35 +04:00
|
|
|
|
1999-09-09 18:52:07 +04:00
|
|
|
NS_IMPL_ADDREF(nsWebShell)
|
|
|
|
NS_IMPL_RELEASE(nsWebShell)
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1999-11-23 13:08:32 +03:00
|
|
|
NS_INTERFACE_MAP_BEGIN(nsWebShell)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebShell)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebShell)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebShellServices)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIContentViewerContainer)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIScriptContextOwner)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDocumentLoaderObserver)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIProgressEventSink)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebShellContainer)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsILinkHandler)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIPrompt)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIRefreshURI)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIClipboardCommands)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIURIContentListener)
|
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-11-23 13:08:32 +03:00
|
|
|
NS_INTERFACE_MAP_END
|
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);
|
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);
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
else if(aIID.Equals(NS_GET_IID(nsIScriptContextOwner)))
|
|
|
|
{
|
|
|
|
*aInstancePtr = NS_STATIC_CAST(nsIScriptContextOwner*, this);
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-11-30 03:09:00 +03:00
|
|
|
else if (aIID.Equals(NS_GET_IID(nsIURIContentListener)))
|
|
|
|
{
|
|
|
|
*aInstancePtr = NS_STATIC_CAST(nsIURIContentListener*, this);
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-11-13 07:06:23 +03:00
|
|
|
else if(mPluginManager) //XXX this seems a little wrong. MMP
|
|
|
|
return mPluginManager->QueryInterface(aIID, aInstancePtr);
|
1998-07-28 03:08:52 +04:00
|
|
|
|
1999-11-17 11:14:52 +03:00
|
|
|
return QueryInterface(aIID, aInstancePtr);
|
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
|
1999-09-07 02:59:11 +04:00
|
|
|
nsWebShell::Embed(nsIContentViewer* aContentViewer,
|
|
|
|
const char* aCommand,
|
1998-07-19 01:43:02 +04:00
|
|
|
nsISupports* aExtraInfo)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsRect bounds;
|
|
|
|
|
|
|
|
WEB_TRACE(WEB_TRACE_CALLS,
|
|
|
|
("nsWebShell::Embed: this=%p aDocViewer=%p aCommand=%s aExtraInfo=%p",
|
|
|
|
this, aContentViewer, aCommand ? aCommand : "", aExtraInfo));
|
|
|
|
|
1999-11-19 10:35:27 +03:00
|
|
|
if (mContentViewer && (eCharsetReloadInit!=mCharsetReloadState))
|
|
|
|
{ // get any interesting state from the old content viewer
|
|
|
|
// XXX: it would be far better to just reuse the document viewer ,
|
|
|
|
// since we know we're just displaying the same document as before
|
|
|
|
PRUnichar *defaultCharset=nsnull;
|
|
|
|
PRUnichar *forceCharset=nsnull;
|
|
|
|
PRUnichar *hintCharset=nsnull;
|
|
|
|
PRInt32 hintCharsetSource;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIMarkupDocumentViewer> oldMUDV = do_QueryInterface(mContentViewer);
|
|
|
|
nsCOMPtr<nsIMarkupDocumentViewer> newMUDV = do_QueryInterface(aContentViewer);
|
|
|
|
if (oldMUDV && newMUDV)
|
|
|
|
{
|
|
|
|
NS_ENSURE_SUCCESS(oldMUDV->GetDefaultCharacterSet (&defaultCharset), NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_SUCCESS(oldMUDV->GetForceCharacterSet (&forceCharset), NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_SUCCESS(oldMUDV->GetHintCharacterSet (&hintCharset), NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_SUCCESS(oldMUDV->GetHintCharacterSetSource (&hintCharsetSource), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
// set the old state onto the new content viewer
|
|
|
|
NS_ENSURE_SUCCESS(newMUDV->SetDefaultCharacterSet (defaultCharset), NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_SUCCESS(newMUDV->SetForceCharacterSet (forceCharset), NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_SUCCESS(newMUDV->SetHintCharacterSet (hintCharset), NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_SUCCESS(newMUDV->SetHintCharacterSetSource (hintCharsetSource), NS_ERROR_FAILURE);
|
|
|
|
|
1999-11-19 11:43:27 +03:00
|
|
|
if (defaultCharset) {
|
|
|
|
Recycle(defaultCharset);
|
1999-11-19 10:35:27 +03:00
|
|
|
}
|
|
|
|
if (forceCharset) {
|
|
|
|
Recycle(forceCharset);
|
|
|
|
}
|
|
|
|
if (hintCharset) {
|
|
|
|
Recycle(hintCharset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IF_RELEASE(mContentViewer);
|
1998-10-27 02:22:59 +03:00
|
|
|
if (nsnull != mScriptContext) {
|
|
|
|
mScriptContext->GC();
|
|
|
|
}
|
1998-07-19 01:43:02 +04:00
|
|
|
mContentViewer = aContentViewer;
|
|
|
|
NS_ADDREF(aContentViewer);
|
|
|
|
|
1999-08-09 18:30:32 +04:00
|
|
|
// check to see if we have a window to embed into --dwc0001
|
1999-09-17 03:35:05 +04:00
|
|
|
/* Note we also need to check for the presence of a native widget. If the
|
|
|
|
webshell is hidden before it's embedded, which can happen in an onload
|
|
|
|
handler, the native widget is destroyed before this code is run. This
|
|
|
|
appears to be mostly harmless except on Windows, where the subsequent
|
|
|
|
attempt to create a child window without a parent is met with disdain
|
|
|
|
by the OS. It's handy, then, that GetNativeData on Windows returns
|
|
|
|
null in this case. */
|
|
|
|
if(mWindow && mWindow->GetNativeData(NS_NATIVE_WIDGET)) {
|
1999-08-09 18:30:32 +04:00
|
|
|
mWindow->GetClientBounds(bounds);
|
|
|
|
bounds.x = bounds.y = 0;
|
1999-09-07 02:59:11 +04:00
|
|
|
rv = mContentViewer->Init(mWindow->GetNativeData(NS_NATIVE_WIDGET),
|
|
|
|
mDeviceContext,
|
1999-08-09 18:30:32 +04:00
|
|
|
mPrefs,
|
|
|
|
bounds,
|
|
|
|
mScrollPref);
|
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.
|
|
|
|
if (mContentViewer && mHistoryState) {
|
|
|
|
nsCOMPtr<nsIDocumentViewer> docv = do_QueryInterface(mContentViewer);
|
|
|
|
if (nsnull != docv) {
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
rv = docv->GetPresShell(*getter_AddRefs(shell));
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = shell->SetHistoryState((nsILayoutHistoryState*) mHistoryState);
|
|
|
|
}
|
|
|
|
}
|
1999-09-07 02:59:11 +04:00
|
|
|
}
|
1999-08-31 18:49:21 +04:00
|
|
|
|
1999-08-09 18:30:32 +04:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
mContentViewer->Show();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mContentViewer = nsnull;
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
1998-07-23 08:24:36 +04:00
|
|
|
// Now that we have switched documents, forget all of our children
|
1999-04-30 04:09:52 +04:00
|
|
|
DestroyChildren();
|
1998-07-19 01:43:02 +04:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-04-08 08:21:15 +04:00
|
|
|
NS_IMETHODIMP
|
1999-09-07 02:59:11 +04:00
|
|
|
nsWebShell::HandleUnknownContentType(nsIDocumentLoader* loader,
|
1999-06-28 14:35:57 +04:00
|
|
|
nsIChannel* channel,
|
1999-04-28 10:47:40 +04:00
|
|
|
const char *aContentType,
|
|
|
|
const char *aCommand ) {
|
1999-04-08 08:21:15 +04:00
|
|
|
// If we have a doc loader observer, let it respond to this.
|
1999-06-28 14:35:57 +04:00
|
|
|
return mDocLoaderObserver ? mDocLoaderObserver->HandleUnknownContentType( mDocLoader, channel, aContentType, aCommand )
|
1999-04-08 08:21:15 +04:00
|
|
|
: NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::Init(nsNativeWidget aNativeParent,
|
1998-08-15 03:08:54 +04:00
|
|
|
PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h,
|
1998-08-05 08:23:21 +04:00
|
|
|
nsScrollPreference aScrolling,
|
1998-11-03 01:19:08 +03:00
|
|
|
PRBool aAllowPlugins,
|
|
|
|
PRBool aIsSunkenBorder)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
1999-01-05 12:46:33 +03:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
// Cache the PL_EventQueue of the current UI thread...
|
|
|
|
//
|
|
|
|
// Since this call must be made on the UI thread, we know the Event Queue
|
1999-09-07 02:59:11 +04:00
|
|
|
// will be associated with the current thread...
|
1999-01-05 12:46:33 +03:00
|
|
|
//
|
1999-09-21 00:53:31 +04:00
|
|
|
NS_WITH_SERVICE(nsIEventQueueService, eventService, kEventQueueServiceCID, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-01-05 12:46:33 +03:00
|
|
|
|
1999-11-30 03:32:43 +03:00
|
|
|
rv = eventService->GetThreadEventQueue(NS_CURRENT_THREAD, &mThreadEventQueue);
|
1999-09-21 00:53:31 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-01-05 12:46:33 +03:00
|
|
|
|
1998-07-28 03:08:52 +04:00
|
|
|
//XXX make sure plugins have started up. this really needs to
|
|
|
|
//be associated with the nsIContentViewerContainer interfaces,
|
|
|
|
//not the nsIWebShell interfaces. this is a hack. MMP
|
1998-08-15 03:08:54 +04:00
|
|
|
nsRect aBounds(x,y,w,h);
|
1999-08-09 18:30:32 +04:00
|
|
|
mBounds.SetRect(x,y,w,h); // initialize the webshells bounds --dwc0001
|
1998-10-22 03:33:52 +04:00
|
|
|
nsWidgetInitData widgetInit;
|
1998-08-05 08:23:21 +04:00
|
|
|
|
1998-09-15 07:46:05 +04:00
|
|
|
CreatePluginHost(aAllowPlugins);
|
1998-08-13 02:06:00 +04:00
|
|
|
|
1998-11-10 02:30:16 +03:00
|
|
|
//mScrollPref = aScrolling;
|
1998-07-27 09:59:37 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
WEB_TRACE(WEB_TRACE_CALLS,
|
|
|
|
("nsWebShell::Init: this=%p", this));
|
|
|
|
|
1999-08-09 18:30:32 +04:00
|
|
|
/* it is ok to have a webshell without an aNativeParent (used later to create the mWindow --dwc0001
|
1998-07-23 08:24:36 +04:00
|
|
|
// Initial error checking...
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_PRECONDITION(nsnull != aNativeParent, "null Parent Window");
|
|
|
|
if (nsnull == aNativeParent) {
|
|
|
|
rv = NS_ERROR_NULL_POINTER;
|
|
|
|
goto done;
|
|
|
|
}
|
1999-08-09 18:30:32 +04:00
|
|
|
*/
|
1998-07-23 08:24:36 +04:00
|
|
|
// Create a document loader...
|
1999-11-30 07:32:09 +03:00
|
|
|
nsCOMPtr<nsIWebShell> webShellParent(do_QueryInterface(mParent));
|
|
|
|
if (webShellParent) {
|
1998-07-23 08:24:36 +04:00
|
|
|
nsIDocumentLoader* parentLoader;
|
|
|
|
|
|
|
|
// Create a child document loader...
|
1999-11-30 07:32:09 +03:00
|
|
|
rv = webShellParent->GetDocumentLoader(parentLoader);
|
1999-01-08 03:32:55 +03:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
1998-07-23 08:24:36 +04:00
|
|
|
rv = parentLoader->CreateDocumentLoader(&mDocLoader);
|
|
|
|
NS_RELEASE(parentLoader);
|
|
|
|
}
|
|
|
|
} else {
|
1999-09-21 00:53:31 +04:00
|
|
|
NS_WITH_SERVICE(nsIDocumentLoader, docLoaderService, kDocLoaderServiceCID, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-01-17 14:48:58 +03:00
|
|
|
|
1999-09-21 01:09:16 +04:00
|
|
|
|
1999-09-21 00:53:31 +04:00
|
|
|
rv = docLoaderService->CreateDocumentLoader(&mDocLoader);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1998-07-23 08:24:36 +04:00
|
|
|
}
|
1999-01-14 09:44:23 +03:00
|
|
|
|
|
|
|
// Set the webshell as the default IContentViewerContainer for the loader...
|
1999-11-15 10:29:23 +03:00
|
|
|
mDocLoader->SetContainer(NS_STATIC_CAST(nsIContentViewerContainer*, this));
|
1999-01-14 09:44:23 +03:00
|
|
|
|
1998-08-12 08:56:40 +04:00
|
|
|
//Register ourselves as an observer for the new doc loader
|
|
|
|
mDocLoader->AddObserver((nsIDocumentLoaderObserver*)this);
|
1998-07-23 08:24:36 +04:00
|
|
|
|
1999-08-09 18:30:32 +04:00
|
|
|
|
|
|
|
/* this is the old code, commented out for the new code below while I figure this out -- dwc0001
|
1998-07-19 01:43:02 +04:00
|
|
|
// Create device context
|
1999-03-09 12:44:27 +03:00
|
|
|
rv = nsComponentManager::CreateInstance(kDeviceContextCID, nsnull,
|
1998-07-19 01:43:02 +04:00
|
|
|
kIDeviceContextIID,
|
|
|
|
(void **)&mDeviceContext);
|
1999-01-08 03:32:55 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
1998-07-19 01:43:02 +04:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
mDeviceContext->Init(aNativeParent);
|
1998-08-27 09:05:03 +04:00
|
|
|
float dev2twip;
|
|
|
|
mDeviceContext->GetDevUnitsToTwips(dev2twip);
|
|
|
|
mDeviceContext->SetDevUnitsToAppUnits(dev2twip);
|
|
|
|
float twip2dev;
|
|
|
|
mDeviceContext->GetTwipsToDevUnits(twip2dev);
|
|
|
|
mDeviceContext->SetAppUnitsToDevUnits(twip2dev);
|
1998-07-30 20:07:18 +04:00
|
|
|
// mDeviceContext->SetGamma(1.7f);
|
|
|
|
mDeviceContext->SetGamma(1.0f);
|
1998-07-19 01:43:02 +04:00
|
|
|
|
|
|
|
// Create a Native window for the shell container...
|
1999-03-09 12:44:27 +03:00
|
|
|
rv = nsComponentManager::CreateInstance(kChildCID, nsnull, kIWidgetIID, (void**)&mWindow);
|
1999-09-21 00:53:31 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1998-10-07 02:33:13 +04:00
|
|
|
|
|
|
|
widgetInit.clipChildren = PR_FALSE;
|
1999-07-27 08:27:17 +04:00
|
|
|
widgetInit.mWindowType = eWindowType_child;
|
1998-11-11 23:17:09 +03:00
|
|
|
//widgetInit.mBorderStyle = aIsSunkenBorder ? eBorderStyle_3DChildWindow : eBorderStyle_none;
|
1998-10-07 02:33:13 +04:00
|
|
|
mWindow->Create(aNativeParent, aBounds, nsWebShell::HandleEvent,
|
|
|
|
mDeviceContext, nsnull, nsnull, &widgetInit);
|
1999-08-09 18:30:32 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
// Create device context
|
|
|
|
if (nsnull != aNativeParent) {
|
|
|
|
rv = nsComponentManager::CreateInstance(kDeviceContextCID, nsnull,
|
1999-09-21 00:53:31 +04:00
|
|
|
kIDeviceContextIID,
|
|
|
|
(void **)&mDeviceContext);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-08-09 18:30:32 +04:00
|
|
|
mDeviceContext->Init(aNativeParent);
|
|
|
|
float dev2twip;
|
|
|
|
mDeviceContext->GetDevUnitsToTwips(dev2twip);
|
|
|
|
mDeviceContext->SetDevUnitsToAppUnits(dev2twip);
|
|
|
|
float twip2dev;
|
|
|
|
mDeviceContext->GetTwipsToDevUnits(twip2dev);
|
|
|
|
mDeviceContext->SetAppUnitsToDevUnits(twip2dev);
|
1999-09-21 00:53:31 +04:00
|
|
|
// mDeviceContext->SetGamma(1.7f);
|
1999-08-09 18:30:32 +04:00
|
|
|
mDeviceContext->SetGamma(1.0f);
|
|
|
|
|
|
|
|
// Create a Native window for the shell container...
|
|
|
|
rv = nsComponentManager::CreateInstance(kChildCID, nsnull, kIWidgetIID, (void**)&mWindow);
|
1999-09-21 00:53:31 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-08-09 18:30:32 +04:00
|
|
|
|
|
|
|
widgetInit.clipChildren = PR_FALSE;
|
|
|
|
widgetInit.mWindowType = eWindowType_child;
|
|
|
|
//widgetInit.mBorderStyle = aIsSunkenBorder ? eBorderStyle_3DChildWindow : eBorderStyle_none;
|
|
|
|
mWindow->Create(aNativeParent, aBounds, nsWebShell::HandleEvent,
|
|
|
|
mDeviceContext, nsnull, nsnull, &widgetInit);
|
|
|
|
} else {
|
|
|
|
// we need a deviceContext
|
|
|
|
|
|
|
|
rv = nsComponentManager::CreateInstance(kDeviceContextCID, nsnull,kIDeviceContextIID,(void **)&mDeviceContext);
|
1999-09-21 00:53:31 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-08-09 18:30:32 +04:00
|
|
|
mDeviceContext->Init(aNativeParent);
|
|
|
|
float dev2twip;
|
|
|
|
mDeviceContext->GetDevUnitsToTwips(dev2twip);
|
|
|
|
mDeviceContext->SetDevUnitsToAppUnits(dev2twip);
|
|
|
|
float twip2dev;
|
|
|
|
mDeviceContext->GetTwipsToDevUnits(twip2dev);
|
|
|
|
mDeviceContext->SetAppUnitsToDevUnits(twip2dev);
|
|
|
|
mDeviceContext->SetGamma(1.0f);
|
|
|
|
|
|
|
|
widgetInit.clipChildren = PR_FALSE;
|
1999-09-07 02:59:11 +04:00
|
|
|
widgetInit.mWindowType = eWindowType_child;
|
1999-08-09 18:30:32 +04:00
|
|
|
}
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1999-09-13 22:38:02 +04:00
|
|
|
// Set the language portion of the user agent. :)
|
1999-09-21 00:53:31 +04:00
|
|
|
NS_WITH_SERVICE(nsILocaleService, localeServ, kLocaleServiceCID, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-09-13 22:38:02 +04:00
|
|
|
|
|
|
|
PRUnichar *UALang;
|
|
|
|
rv = localeServ->GetLocaleComponentForUserAgent(&UALang);
|
1999-09-21 00:53:31 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-09-13 22:38:02 +04:00
|
|
|
|
1999-09-21 00:53:31 +04:00
|
|
|
NS_WITH_SERVICE(nsIIOService, ioServ, kIOServiceCID, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-09-13 22:38:02 +04:00
|
|
|
|
|
|
|
rv = ioServ->SetLanguage(UALang);
|
|
|
|
nsAllocator::Free(UALang);
|
1998-07-19 01:43:02 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-07-15 18:22:06 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::IsBusy(PRBool& aResult)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (mDocLoader!=nsnull) {
|
|
|
|
mDocLoader->IsBusy(aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IMETHODIMP
|
1998-08-15 03:08:54 +04:00
|
|
|
nsWebShell::GetBounds(PRInt32 &x, PRInt32 &y, PRInt32 &w, PRInt32 &h)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
1999-11-27 05:14:40 +03:00
|
|
|
return GetPositionAndSize(&x, &y, &w, &h);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-08-15 03:08:54 +04:00
|
|
|
nsWebShell::SetBounds(PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
1999-11-27 05:14:40 +03:00
|
|
|
return SetPositionAndSize(x, y, w, h, PR_FALSE);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-09-04 02:41:56 +04:00
|
|
|
nsWebShell::SizeToContent()
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// get the presentation shell
|
|
|
|
nsCOMPtr<nsIContentViewer> cv;
|
|
|
|
GetContentViewer(getter_AddRefs(cv));
|
|
|
|
if (cv) {
|
|
|
|
nsCOMPtr<nsIDocumentViewer> dv = do_QueryInterface(cv);
|
|
|
|
if (dv) {
|
|
|
|
nsCOMPtr<nsIPresContext> pcx;
|
|
|
|
dv->GetPresContext(*getter_AddRefs(pcx));
|
|
|
|
if (pcx) {
|
|
|
|
nsCOMPtr<nsIPresShell> pshell;
|
|
|
|
pcx->GetShell(getter_AddRefs(pshell));
|
|
|
|
|
|
|
|
// whew! so resize the presentation shell
|
|
|
|
if (pshell) {
|
|
|
|
nsRect shellArea;
|
|
|
|
PRInt32 width, height;
|
|
|
|
float pixelScale;
|
|
|
|
|
|
|
|
rv = pshell->ResizeReflow(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
|
|
|
|
|
|
|
// so how big is it?
|
|
|
|
pcx->GetVisibleArea(shellArea);
|
|
|
|
pcx->GetTwipsToPixels(&pixelScale);
|
|
|
|
width = PRInt32((float)shellArea.width*pixelScale);
|
|
|
|
height = PRInt32((float)shellArea.height*pixelScale);
|
|
|
|
|
|
|
|
// if we're the outermost webshell for this window, size the window
|
|
|
|
if (mContainer) {
|
|
|
|
nsCOMPtr<nsIBrowserWindow> browser = do_QueryInterface(mContainer);
|
|
|
|
if (browser) {
|
|
|
|
nsCOMPtr<nsIWebShell> browserWebShell;
|
|
|
|
PRInt32 oldX, oldY, oldWidth, oldHeight,
|
|
|
|
widthDelta, heightDelta;
|
|
|
|
nsRect windowBounds;
|
|
|
|
|
|
|
|
GetBounds(oldX, oldY, oldWidth, oldHeight);
|
|
|
|
widthDelta = width - oldWidth;
|
|
|
|
heightDelta = height - oldHeight;
|
|
|
|
browser->GetWindowBounds(windowBounds);
|
1999-09-07 02:59:11 +04:00
|
|
|
browser->SizeWindowTo(windowBounds.width + widthDelta,
|
1999-09-04 02:41:56 +04:00
|
|
|
windowBounds.height + heightDelta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-07-19 01:43:02 +04:00
|
|
|
nsWebShell::MoveTo(PRInt32 aX, PRInt32 aY)
|
|
|
|
{
|
1999-11-27 05:14:40 +03:00
|
|
|
return SetPosition(aX, aY);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::Show()
|
|
|
|
{
|
1999-11-27 05:14:40 +03:00
|
|
|
return SetVisibility(PR_TRUE);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::Hide()
|
|
|
|
{
|
1999-11-27 05:14:40 +03:00
|
|
|
return SetVisibility(PR_FALSE);
|
1998-09-16 01:31:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::RemoveFocus()
|
|
|
|
{
|
1999-08-09 18:30:32 +04:00
|
|
|
/*
|
|
|
|
--dwc0001
|
1998-09-16 01:31:58 +04:00
|
|
|
NS_PRECONDITION(nsnull != mWindow, "null window");
|
1999-08-09 18:30:32 +04:00
|
|
|
*/
|
1998-09-16 01:31:58 +04:00
|
|
|
|
|
|
|
if (nsnull != mWindow) {
|
|
|
|
nsIWidget *parentWidget = mWindow->GetParent();
|
|
|
|
if (nsnull != parentWidget) {
|
|
|
|
parentWidget->SetFocus();
|
|
|
|
NS_RELEASE(parentWidget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-08-09 11:43:22 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetContentViewer(nsIContentViewer* aViewer)
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mContentViewer);
|
|
|
|
mContentViewer = aViewer;
|
|
|
|
NS_IF_ADDREF(aViewer);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
// uri dispatching change.....if you set a container for a webshell
|
|
|
|
// and that container is a content listener itself....then use
|
|
|
|
// it as our parent container.
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIURIContentListener> contentListener = do_QueryInterface(mContainer, &rv);
|
|
|
|
if (NS_SUCCEEDED(rv) && contentListener)
|
|
|
|
SetParentURIContentListener(contentListener);
|
|
|
|
|
|
|
|
// if the container is getting set to null, then our parent must be going away
|
|
|
|
// so clear out our knowledge of the content listener represented by the container
|
|
|
|
if (!aContainer)
|
|
|
|
SetParentURIContentListener(nsnull);
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-06-15 02:11:47 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetSessionHistory(nsISessionHistory* aSHist)
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mSHist);
|
|
|
|
mSHist = aSHist;
|
|
|
|
NS_IF_ADDREF(aSHist);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetSessionHistory(nsISessionHistory *& aResult)
|
|
|
|
{
|
|
|
|
aResult = mSHist;
|
|
|
|
NS_IF_ADDREF(mSHist);
|
|
|
|
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-07-31 10:02:06 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetPrefs(nsIPref*& aPrefs)
|
|
|
|
{
|
|
|
|
aPrefs = mPrefs;
|
|
|
|
NS_IF_ADDREF(aPrefs);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-07-23 08:24:36 +04:00
|
|
|
|
1998-10-02 22:44:56 +04:00
|
|
|
NS_IMETHODIMP
|
1998-07-19 05:18:40 +04:00
|
|
|
nsWebShell::GetRootWebShell(nsIWebShell*& aResult)
|
|
|
|
{
|
|
|
|
nsIWebShell* top = this;
|
1998-08-09 11:43:22 +04:00
|
|
|
NS_ADDREF(this);
|
1998-07-19 05:18:40 +04:00
|
|
|
for (;;) {
|
|
|
|
nsIWebShell* parent;
|
|
|
|
top->GetParent(parent);
|
|
|
|
if (nsnull == parent) {
|
|
|
|
break;
|
|
|
|
}
|
1998-08-09 11:43:22 +04:00
|
|
|
NS_RELEASE(top);
|
1998-07-19 05:18:40 +04:00
|
|
|
top = parent;
|
|
|
|
}
|
|
|
|
aResult = top;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-16 23:06:12 +03:00
|
|
|
void
|
|
|
|
nsWebShell::GetRootWebShellEvenIfChrome(nsIWebShell** aResult)
|
1999-04-16 12:15:04 +04:00
|
|
|
{
|
1999-11-16 23:06:12 +03:00
|
|
|
nsCOMPtr<nsIWebShell> top(this);
|
|
|
|
nsCOMPtr<nsIWebShell> parent;
|
|
|
|
for(top = this; top; top = parent)
|
|
|
|
{
|
|
|
|
top->GetParentEvenIfChrome(*getter_AddRefs(parent));
|
|
|
|
if(!parent)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
*aResult = top;
|
|
|
|
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-11-30 07:32:09 +03:00
|
|
|
mParent = do_QueryInterface(aParent);
|
|
|
|
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-11-30 07:32:09 +03:00
|
|
|
nsCOMPtr<nsIWebShell> webShellParent(do_QueryInterface(mParent));
|
1999-09-07 02:59:11 +04:00
|
|
|
if (mWebShellType == nsWebShellContent)
|
|
|
|
{
|
|
|
|
// We cannot return our parent if it is a chrome webshell.
|
|
|
|
nsWebShellType parentType;
|
1999-11-30 07:32:09 +03:00
|
|
|
if (webShellParent)
|
1999-09-07 02:59:11 +04:00
|
|
|
{
|
1999-11-30 07:32:09 +03:00
|
|
|
webShellParent->GetWebShellType(parentType);
|
1999-09-07 02:59:11 +04:00
|
|
|
if (parentType == nsWebShellChrome)
|
|
|
|
{
|
|
|
|
aParent = nsnull; // Just return null.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-04-16 12:15:04 +04:00
|
|
|
|
1999-11-30 07:32:09 +03:00
|
|
|
aParent = webShellParent;
|
|
|
|
NS_IF_ADDREF(aParent);
|
1999-04-16 12:15:04 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetParentEvenIfChrome(nsIWebShell*& aParent)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
1999-11-30 07:32:09 +03:00
|
|
|
if(mParent)
|
|
|
|
mParent->QueryInterface(NS_GET_IID(nsIWebShell), (void**)&aParent);
|
|
|
|
else
|
|
|
|
aParent = nsnull;
|
1998-07-19 01:43:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-10-26 02:20:10 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetReferrer(nsIURI **aReferrer)
|
|
|
|
{
|
|
|
|
return NS_NewURI(aReferrer, mReferrer, nsnull);
|
|
|
|
}
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetChildCount(PRInt32& aResult)
|
|
|
|
{
|
|
|
|
aResult = mChildren.Count();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-07-19 05:18:40 +04:00
|
|
|
nsWebShell::AddChild(nsIWebShell* aChild)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
1999-11-30 07:32:09 +03:00
|
|
|
NS_ENSURE_ARG(aChild);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShell> docShellChild(do_QueryInterface(aChild));
|
|
|
|
|
|
|
|
mChildren.AppendElement(docShellChild);
|
|
|
|
docShellChild->SetParent(this);
|
1999-11-19 10:35:27 +03:00
|
|
|
PRUnichar *defaultCharset=nsnull;
|
|
|
|
PRUnichar *forceCharset=nsnull;
|
|
|
|
nsCOMPtr<nsIContentViewer> cv;
|
|
|
|
NS_ENSURE_SUCCESS(GetContentViewer(getter_AddRefs(cv)), NS_ERROR_FAILURE);
|
|
|
|
if (cv)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIMarkupDocumentViewer> muDV = do_QueryInterface(cv);
|
|
|
|
if (muDV)
|
|
|
|
{
|
|
|
|
NS_ENSURE_SUCCESS(muDV->GetDefaultCharacterSet (&defaultCharset), NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_SUCCESS(muDV->GetForceCharacterSet (&forceCharset), NS_ERROR_FAILURE);
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIContentViewer> childCV;
|
1999-11-30 07:32:09 +03:00
|
|
|
NS_ENSURE_SUCCESS(docShellChild->GetContentViewer(getter_AddRefs(childCV)), NS_ERROR_FAILURE);
|
1999-11-19 10:35:27 +03:00
|
|
|
if (childCV)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIMarkupDocumentViewer> childmuDV = do_QueryInterface(cv);
|
|
|
|
if (childmuDV)
|
|
|
|
{
|
|
|
|
childmuDV->SetDefaultCharacterSet(defaultCharset);
|
|
|
|
childmuDV->SetForceCharacterSet(forceCharset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_ADDREF(aChild);
|
1999-04-16 12:15:04 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-05 04:23:51 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::RemoveChild(nsIWebShell* aChild)
|
|
|
|
{
|
1999-11-30 07:32:09 +03:00
|
|
|
NS_ENSURE_ARG(aChild);
|
|
|
|
nsCOMPtr<nsIDocShell> docShellChild(do_QueryInterface(aChild));
|
|
|
|
mChildren.RemoveElement(docShellChild);
|
|
|
|
docShellChild->SetParent(nsnull);
|
1999-05-05 04:23:51 +04:00
|
|
|
NS_RELEASE(aChild);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::ChildAt(PRInt32 aIndex, nsIWebShell*& aResult)
|
|
|
|
{
|
1999-11-30 07:32:09 +03:00
|
|
|
nsIDocShell* element;
|
1998-07-19 01:43:02 +04:00
|
|
|
if (PRUint32(aIndex) >= PRUint32(mChildren.Count())) {
|
|
|
|
aResult = nsnull;
|
|
|
|
}
|
|
|
|
else {
|
1999-11-30 07:32:09 +03:00
|
|
|
element = (nsIDocShell*) mChildren.ElementAt(aIndex);
|
|
|
|
element->QueryInterface(NS_GET_IID(nsIWebShell), (void**)&aResult);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-30 07:32:09 +03:00
|
|
|
nsWebShell::GetName(const PRUnichar** aName)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
1999-11-30 07:32:09 +03:00
|
|
|
*aName = mName.GetUnicode();
|
|
|
|
return NS_OK;
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
1999-06-15 02:11:47 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetURL(const PRUnichar** aURL)
|
|
|
|
{
|
1999-10-12 08:37:43 +04:00
|
|
|
// XXX This is wrong unless the parameter is marked "shared".
|
|
|
|
// It should otherwise be copied and freed by the caller.
|
1999-06-15 02:11:47 +04:00
|
|
|
*aURL = mURL.GetUnicode();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetURL(const PRUnichar* aURL)
|
|
|
|
{
|
|
|
|
mURL = aURL;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-07 02:59:11 +04:00
|
|
|
NS_IMETHODIMP
|
1999-06-15 02:11:47 +04:00
|
|
|
nsWebShell::GetIsInSHist(PRBool& aResult)
|
|
|
|
{
|
|
|
|
aResult = mIsInSHist;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetIsInSHist(PRBool aIsInSHist)
|
1999-09-07 02:59:11 +04:00
|
|
|
{
|
1999-06-15 02:11:47 +04:00
|
|
|
mIsInSHist = aIsInSHist;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IMETHODIMP
|
1998-08-15 03:08:54 +04:00
|
|
|
nsWebShell::FindChildWithName(const PRUnichar* aName1,
|
1998-07-19 01:43:02 +04:00
|
|
|
nsIWebShell*& aResult)
|
|
|
|
{
|
|
|
|
aResult = nsnull;
|
1998-08-15 03:08:54 +04:00
|
|
|
nsString aName(aName1);
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1999-11-30 07:32:09 +03:00
|
|
|
nsXPIDLString childName;
|
1998-07-19 01:43:02 +04:00
|
|
|
PRInt32 i, n = mChildren.Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
1999-11-30 07:32:09 +03:00
|
|
|
nsIDocShell* child = (nsIDocShell*) mChildren.ElementAt(i);
|
|
|
|
nsCOMPtr<nsIWebShell> webShellChild(do_QueryInterface(child));
|
1998-07-19 01:43:02 +04:00
|
|
|
if (nsnull != child) {
|
1999-11-30 07:32:09 +03:00
|
|
|
child->GetName(getter_Copies(childName));
|
1998-08-15 03:08:54 +04:00
|
|
|
if (aName.Equals(childName)) {
|
1999-11-30 07:32:09 +03:00
|
|
|
aResult = webShellChild;
|
|
|
|
NS_ADDREF(aResult);
|
1998-07-19 01:43:02 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// See if child contains the shell with the given name
|
1999-11-30 07:32:09 +03:00
|
|
|
nsresult rv = webShellChild->FindChildWithName(aName.GetUnicode(), aResult);
|
1999-01-08 03:32:55 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
1998-07-19 01:43:02 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
if (nsnull != aResult) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-16 12:15:04 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetWebShellType(nsWebShellType& aWebShellType)
|
|
|
|
{
|
1999-09-07 02:59:11 +04:00
|
|
|
aWebShellType = mWebShellType;
|
|
|
|
return NS_OK;
|
1999-04-16 12:15:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetWebShellType(nsWebShellType aWebShellType)
|
|
|
|
{
|
1999-09-07 02:59:11 +04:00
|
|
|
if (aWebShellType != nsWebShellChrome && aWebShellType != nsWebShellContent)
|
1999-04-16 12:15:04 +04:00
|
|
|
{
|
1999-09-07 02:59:11 +04:00
|
|
|
NS_ERROR("Attempt to set bogus webshell type: values should be content or chrome.");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
mWebShellType = aWebShellType;
|
|
|
|
return NS_OK;
|
1999-04-16 12:15:04 +04:00
|
|
|
}
|
|
|
|
|
1999-05-28 01:05:27 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-23 12:57:47 +03:00
|
|
|
nsWebShell::GetChromeEventHandler(nsIChromeEventHandler** aChromeEventHandler)
|
1999-05-28 01:05:27 +04:00
|
|
|
{
|
1999-11-23 12:57:47 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aChromeEventHandler);
|
|
|
|
|
|
|
|
NS_IF_ADDREF(mChromeEventHandler);
|
|
|
|
*aChromeEventHandler = mChromeEventHandler;
|
|
|
|
return NS_OK;
|
1999-05-28 01:05:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-23 12:57:47 +03:00
|
|
|
nsWebShell::SetChromeEventHandler(nsIChromeEventHandler* aChromeEventHandler)
|
1999-05-28 01:05:27 +04:00
|
|
|
{
|
1999-11-23 12:57:47 +03:00
|
|
|
// Weak reference. Don't addref.
|
|
|
|
mChromeEventHandler = aChromeEventHandler;
|
|
|
|
return NS_OK;
|
1999-05-28 01:05:27 +04:00
|
|
|
}
|
|
|
|
|
1998-11-10 02:30:16 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetScrolling(PRInt32& aScrolling)
|
|
|
|
{
|
1999-04-10 01:09:00 +04:00
|
|
|
aScrolling = mScrolling[1];
|
1998-11-10 02:30:16 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-04-10 01:09:00 +04:00
|
|
|
nsWebShell::SetScrolling(PRInt32 aScrolling, PRBool aSetCurrentAndInitial)
|
1998-11-10 02:30:16 +03:00
|
|
|
{
|
1999-04-10 01:09:00 +04:00
|
|
|
mScrolling[1] = aScrolling;
|
|
|
|
if (aSetCurrentAndInitial) {
|
|
|
|
mScrolling[0] = aScrolling;
|
|
|
|
}
|
1998-11-10 02:30:16 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-01-20 02:14:31 +03:00
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
#define FILE_PROTOCOL "file:///"
|
|
|
|
|
1998-12-15 04:34:36 +03:00
|
|
|
static void convertFileToURL(const nsString &aIn, nsString &aOut)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
1998-08-15 03:08:54 +04:00
|
|
|
#ifdef XP_PC
|
|
|
|
char szFile[1000];
|
|
|
|
aIn.ToCString(szFile, sizeof(szFile));
|
|
|
|
if (PL_strchr(szFile, '\\')) {
|
|
|
|
PRInt32 len = strlen(szFile);
|
|
|
|
PRInt32 sum = len + sizeof(FILE_PROTOCOL);
|
1999-03-11 08:45:52 +03:00
|
|
|
char* lpszFileURL = (char *)PR_Malloc(sum + 1);
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
// Translate '\' to '/'
|
|
|
|
for (PRInt32 i = 0; i < len; i++) {
|
|
|
|
if (szFile[i] == '\\') {
|
|
|
|
szFile[i] = '/';
|
|
|
|
}
|
|
|
|
if (szFile[i] == ':') {
|
|
|
|
szFile[i] = '|';
|
|
|
|
}
|
|
|
|
}
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
// Build the file URL
|
|
|
|
PR_snprintf(lpszFileURL, sum, "%s%s", FILE_PROTOCOL, szFile);
|
|
|
|
aOut = lpszFileURL;
|
1999-03-11 08:45:52 +03:00
|
|
|
PR_Free((void *)lpszFileURL);
|
1998-08-15 03:08:54 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
aOut = aIn;
|
|
|
|
}
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-08-15 03:08:54 +04:00
|
|
|
nsWebShell::LoadURL(const PRUnichar *aURLSpec,
|
1999-08-04 00:51:41 +04:00
|
|
|
nsIInputStream* aPostDataStream,
|
1998-08-20 03:01:52 +04:00
|
|
|
PRBool aModifyHistory,
|
1999-07-01 23:30:20 +04:00
|
|
|
nsLoadFlags aType,
|
1999-09-03 01:39:01 +04:00
|
|
|
const PRUint32 aLocalIP,
|
1999-09-17 08:26:02 +04:00
|
|
|
nsISupports * aHistoryState,
|
|
|
|
const PRUnichar* aReferrer)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
1999-04-10 01:09:00 +04:00
|
|
|
// Initialize margnwidth, marginheight. Put scrolling back the way it was
|
|
|
|
// before the last document was loaded.
|
1999-09-23 07:27:53 +04:00
|
|
|
|
|
|
|
InitFrameData(PR_FALSE);
|
1999-09-17 08:26:02 +04:00
|
|
|
|
1999-09-16 18:15:16 +04:00
|
|
|
const char *cmd = mViewSource ? "view-source" : "view" ;
|
|
|
|
mViewSource = PR_FALSE; // reset it
|
1999-09-21 04:04:31 +04:00
|
|
|
return LoadURL(aURLSpec, cmd, aPostDataStream,
|
1999-09-17 08:26:02 +04:00
|
|
|
aModifyHistory,aType, aLocalIP, aHistoryState,
|
|
|
|
aReferrer);
|
1998-11-11 23:31:45 +03:00
|
|
|
}
|
|
|
|
|
1999-10-15 07:50:47 +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;
|
|
|
|
}
|
|
|
|
|
1999-02-12 20:32:17 +03:00
|
|
|
nsresult
|
1999-09-08 07:59:21 +04:00
|
|
|
nsWebShell::DoLoadURL(nsIURI * aUri,
|
1999-02-12 20:32:17 +03:00
|
|
|
const char* aCommand,
|
1999-08-04 00:51:41 +04:00
|
|
|
nsIInputStream* aPostDataStream,
|
1999-07-01 23:30:20 +04:00
|
|
|
nsLoadFlags aType,
|
1999-09-17 08:26:02 +04:00
|
|
|
const PRUint32 aLocalIP,
|
1999-11-18 10:06:39 +03:00
|
|
|
const PRUnichar* aReferrer,
|
|
|
|
PRBool aKickOffLoad)
|
1999-02-12 20:32:17 +03:00
|
|
|
{
|
1999-09-08 07:59:21 +04:00
|
|
|
if (!aUri)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
1999-10-13 14:24:12 +04:00
|
|
|
// This should probably get saved in mHistoryService or something...
|
1999-08-05 09:14:45 +04:00
|
|
|
// Ugh. It sucks that we have to hack webshell like this. Forgive me, Father.
|
|
|
|
do {
|
|
|
|
nsresult rv;
|
|
|
|
NS_WITH_SERVICE(nsIGlobalHistory, history, "component://netscape/browser/global-history", &rv);
|
|
|
|
if (NS_FAILED(rv)) break;
|
|
|
|
|
1999-09-08 07:59:21 +04:00
|
|
|
rv = history->AddPage(nsCAutoString(mURL), nsnull /* referrer */, PR_Now());
|
1999-08-05 09:14:45 +04:00
|
|
|
if (NS_FAILED(rv)) break;
|
|
|
|
} while (0);
|
|
|
|
|
1999-09-08 07:59:21 +04:00
|
|
|
nsXPIDLCString urlSpec;
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
rv = aUri->GetSpec(getter_Copies(urlSpec));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-10-05 08:49:58 +04:00
|
|
|
|
1999-02-12 20:32:17 +03:00
|
|
|
// If it's a normal reload that uses the cache, look at the destination anchor
|
|
|
|
// and see if it's an element within the current document
|
1999-09-07 02:59:11 +04:00
|
|
|
// We don't have a reload loadtype yet in necko. So, check for just history
|
|
|
|
// loadtype
|
1999-10-12 08:37:43 +04:00
|
|
|
if ((aType == nsISessionHistory::LOAD_HISTORY || aType == nsIChannel::LOAD_NORMAL) && (nsnull != mContentViewer) &&
|
1999-09-07 02:59:11 +04:00
|
|
|
(nsnull == aPostDataStream))
|
1999-06-28 14:35:57 +04:00
|
|
|
{
|
1999-02-12 20:32:17 +03:00
|
|
|
nsCOMPtr<nsIDocumentViewer> docViewer;
|
|
|
|
if (NS_SUCCEEDED(mContentViewer->QueryInterface(kIDocumentViewerIID,
|
|
|
|
getter_AddRefs(docViewer)))) {
|
|
|
|
// Get the document object
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
docViewer->GetDocument(*getter_AddRefs(doc));
|
|
|
|
|
|
|
|
// Get the URL for the document
|
1999-06-23 07:29:44 +04:00
|
|
|
nsCOMPtr<nsIURI> docURL = nsDontAddRef<nsIURI>(doc->GetDocumentURL());
|
1999-02-12 20:32:17 +03:00
|
|
|
|
1999-09-08 07:59:21 +04:00
|
|
|
if (aUri && docURL && EqualBaseURLs(docURL, aUri)) {
|
1999-07-08 05:40:50 +04:00
|
|
|
// See if there's a destination anchor
|
1999-09-08 07:59:21 +04:00
|
|
|
nsXPIDLCString ref;
|
|
|
|
nsCOMPtr<nsIURL> aUrl = do_QueryInterface(aUri);
|
|
|
|
if (aUrl)
|
|
|
|
rv = aUrl->GetRef(getter_Copies(ref));
|
|
|
|
|
1999-07-03 05:14:51 +04:00
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
rv = docViewer->GetPresShell(*getter_AddRefs(presShell));
|
1999-02-12 20:32:17 +03:00
|
|
|
|
1999-07-03 05:14:51 +04:00
|
|
|
if (NS_SUCCEEDED(rv) && presShell) {
|
1999-10-29 00:29:43 +04:00
|
|
|
/* Pass OnStartDocument notifications to the docloaderobserver
|
|
|
|
* so that urlbar, forward/back buttons will
|
|
|
|
* behave properly when going to named anchors
|
|
|
|
*/
|
1999-10-15 07:50:47 +04:00
|
|
|
nsCOMPtr<nsIChannel> dummyChannel;
|
|
|
|
rv = NS_OpenURI(getter_AddRefs(dummyChannel), aUri, nsnull);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
if (nsnull != (const char *) ref) {
|
1999-10-18 23:09:27 +04:00
|
|
|
rv = OnStartDocumentLoad(mDocLoader, aUri, "load");
|
|
|
|
// Go to the anchor in the current document
|
|
|
|
rv = presShell->GoToAnchor(nsAutoString(ref));
|
1999-11-30 03:09:00 +03:00
|
|
|
mProcessedEndDocumentLoad = PR_FALSE;
|
1999-11-23 00:42:00 +03:00
|
|
|
// Set the URL & referrer if the anchor was successfully visited
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
mURL = urlSpec;
|
|
|
|
mReferrer = aReferrer;
|
|
|
|
}
|
1999-10-18 23:09:27 +04:00
|
|
|
// Pass on status of scrolling/anchor visit to docloaderobserver
|
|
|
|
rv = OnEndDocumentLoad(mDocLoader, dummyChannel, rv, this);
|
|
|
|
return rv;
|
1999-10-15 07:50:47 +04:00
|
|
|
}
|
|
|
|
else if (aType == nsISessionHistory::LOAD_HISTORY)
|
|
|
|
{
|
1999-10-18 23:09:27 +04:00
|
|
|
rv = OnStartDocumentLoad(mDocLoader, aUri, "load");
|
1999-10-15 07:50:47 +04:00
|
|
|
// Go to the top of the current document
|
|
|
|
nsCOMPtr<nsIViewManager> viewMgr;
|
|
|
|
rv = presShell->GetViewManager(getter_AddRefs(viewMgr));
|
|
|
|
if (NS_SUCCEEDED(rv) && viewMgr) {
|
|
|
|
nsIScrollableView* view;
|
|
|
|
rv = viewMgr->GetRootScrollableView(&view);
|
1999-10-18 23:09:27 +04:00
|
|
|
if (NS_SUCCEEDED(rv) && view)
|
1999-11-23 00:42:00 +03:00
|
|
|
rv = view->ScrollTo(0, 0, NS_VMREFRESH_IMMEDIATE);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
mURL = urlSpec;
|
|
|
|
mReferrer = aReferrer;
|
|
|
|
}
|
1999-10-18 23:09:27 +04:00
|
|
|
mProcessedEndDocumentLoad = PR_FALSE;
|
|
|
|
// Pass on status of scrolling/anchor visit to docloaderobserver
|
|
|
|
rv = OnEndDocumentLoad(mDocLoader, dummyChannel, rv, this);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#if 0
|
1999-10-15 07:50:47 +04:00
|
|
|
mProcessedEndDocumentLoad = PR_FALSE;
|
|
|
|
// Pass on status of scrolling/anchor visit to docloaderobserver
|
|
|
|
rv = OnEndDocumentLoad(mDocLoader, dummyChannel, rv, this);
|
|
|
|
return rv;
|
1999-10-18 23:09:27 +04:00
|
|
|
#endif /* 0 */
|
1999-10-15 07:50:47 +04:00
|
|
|
} // NS_SUCCEEDED(rv) && presShell
|
1999-07-03 05:14:51 +04:00
|
|
|
} // EqualBaseURLs(docURL, url)
|
1999-02-12 20:32:17 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stop loading the current document (if any...). This call may result in
|
|
|
|
// firing an EndLoadURL notification for the old document...
|
1999-11-30 03:09:00 +03:00
|
|
|
if (aKickOffLoad)
|
|
|
|
StopBeforeRequestingURL();
|
1999-11-18 10:06:39 +03:00
|
|
|
|
1999-04-07 01:01:04 +04:00
|
|
|
|
1999-02-12 20:32:17 +03:00
|
|
|
// Tell web-shell-container we are loading a new url
|
|
|
|
if (nsnull != mContainer) {
|
1999-09-08 07:59:21 +04:00
|
|
|
nsAutoString uniSpec (urlSpec);
|
1999-09-15 01:49:21 +04:00
|
|
|
rv = mContainer->BeginLoadURL(this, uniSpec.GetUnicode());
|
1999-02-12 20:32:17 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
1999-04-07 01:01:04 +04:00
|
|
|
|
1999-05-04 03:04:50 +04:00
|
|
|
mProcessedEndDocumentLoad = PR_FALSE;
|
|
|
|
|
1999-10-20 02:27:20 +04:00
|
|
|
#ifdef MOZ_PERF_METRICS
|
1999-09-24 11:13:39 +04:00
|
|
|
{
|
|
|
|
char* url;
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
rv = aUri->GetSpec(&url);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
1999-11-10 06:41:09 +03:00
|
|
|
MOZ_TIMER_LOG(("*** Timing layout processes on url: '%s', webshell: %p\n", url, this));
|
1999-09-24 11:13:39 +04:00
|
|
|
delete [] url;
|
|
|
|
}
|
|
|
|
}
|
1999-11-10 06:41:09 +03:00
|
|
|
|
|
|
|
MOZ_TIMER_DEBUGLOG(("Reset and start: nsWebShell::DoLoadURL(), this=%p\n", this));
|
|
|
|
MOZ_TIMER_RESET(mTotalTime);
|
|
|
|
MOZ_TIMER_START(mTotalTime);
|
1999-09-24 11:13:39 +04:00
|
|
|
#endif
|
|
|
|
|
1999-04-07 01:01:04 +04:00
|
|
|
/* WebShell was primarily passing the buck when it came to streamObserver.
|
|
|
|
* So, pass on the observer which is already a streamObserver to DocLoder.
|
|
|
|
*/
|
1999-11-18 10:06:39 +03:00
|
|
|
if (aKickOffLoad)
|
|
|
|
rv = mDocLoader->LoadDocument(aUri, // URL string
|
1999-08-04 00:51:41 +04:00
|
|
|
aCommand, // Command
|
1999-11-15 10:29:23 +03:00
|
|
|
NS_STATIC_CAST(nsIContentViewerContainer*, this),// Container
|
1999-08-04 00:51:41 +04:00
|
|
|
aPostDataStream, // Post Data
|
|
|
|
nsnull, // Extra Info...
|
|
|
|
aType, // reload type
|
1999-09-17 08:26:02 +04:00
|
|
|
aLocalIP, // load attributes.
|
|
|
|
aReferrer); // referrer
|
1999-11-05 01:09:46 +03:00
|
|
|
|
1999-11-18 10:06:39 +03:00
|
|
|
// Fix for bug 1646. Change the notion of current url and referrer only after
|
1999-11-05 01:09:46 +03:00
|
|
|
// the document load succeeds.
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
mURL = urlSpec;
|
|
|
|
mReferrer = aReferrer;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
1999-02-12 20:32:17 +03:00
|
|
|
}
|
|
|
|
|
1999-11-18 10:06:39 +03:00
|
|
|
// nsIURIContentListener support
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler **aProtocolHandler)
|
|
|
|
{
|
|
|
|
// ask our parent if they want to use a particular handler...
|
|
|
|
if (mParentContentListener)
|
|
|
|
return mParentContentListener->GetProtocolHandler(aURI, aProtocolHandler);
|
|
|
|
else
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::CanHandleContent(const char * aContentType,
|
|
|
|
const char * aCommand,
|
|
|
|
const char * aWindowTarget,
|
|
|
|
char ** aDesiredContentType,
|
|
|
|
PRBool * aCanHandleContent)
|
|
|
|
|
|
|
|
{
|
|
|
|
// the webshell knows nothing about content policy....pass this
|
|
|
|
// up to our parent content handler...
|
|
|
|
nsCOMPtr<nsIURIContentListener> parentListener;
|
|
|
|
nsresult rv = GetParentURIContentListener(getter_AddRefs(parentListener));
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
rv = parentListener->CanHandleContent(aContentType, aCommand, aWindowTarget, aDesiredContentType,
|
|
|
|
aCanHandleContent);
|
|
|
|
else
|
1999-12-01 03:16:25 +03:00
|
|
|
// i'm going to try something interesting...if we don't have a parent to dictate whether we
|
|
|
|
// can handle the content, let's say that we CAN handle the content instead of saying that we
|
|
|
|
// can't. I was running into the scenario where we were running a chrome url to bring up the first window
|
|
|
|
// in the top level webshell. We didn't have a parent content listener yet because it was too early in
|
|
|
|
// the start up process...so we'd fail to load the url....
|
|
|
|
*aCanHandleContent = PR_TRUE;
|
1999-11-18 10:06:39 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-08 07:59:21 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-18 10:06:39 +03:00
|
|
|
nsWebShell::DoContent(const char * aContentType,
|
|
|
|
const char * aCommand,
|
|
|
|
const char * aWindowTarget,
|
|
|
|
nsIChannel * aOpenedChannel,
|
|
|
|
nsIStreamListener ** aContentHandler,
|
|
|
|
PRBool * aAbortProcess)
|
|
|
|
{
|
|
|
|
if (aAbortProcess)
|
|
|
|
*aAbortProcess = PR_FALSE;
|
|
|
|
|
|
|
|
// first, run any uri preparation stuff that we would have run normally
|
|
|
|
// had we gone through OpenURI
|
|
|
|
nsCOMPtr<nsIURI> aUri;
|
|
|
|
aOpenedChannel->GetURI(getter_AddRefs(aUri));
|
|
|
|
PrepareToLoadURI(aUri, aCommand, nsnull, PR_TRUE, nsIChannel::LOAD_NORMAL, 0, nsnull, nsnull);
|
|
|
|
// mscott: when I called DoLoadURL I found that we ran into problems because
|
|
|
|
// we currently don't have channel retargeting yet. Basically, what happens is that
|
|
|
|
// DoLoadURL calls StopBeforeRequestingURL and this cancels the current load group
|
|
|
|
// however since we can't retarget yet, we were basically canceling our very
|
|
|
|
// own load group!!! So the request would get canceled out from under us...
|
|
|
|
// after retargeting we may be able to safely call DoLoadURL.
|
1999-11-30 03:09:00 +03:00
|
|
|
DoLoadURL(aUri, aCommand, nsnull, nsIChannel::LOAD_NORMAL, 0, nsnull, PR_FALSE);
|
1999-11-18 10:06:39 +03:00
|
|
|
return mDocLoader->LoadOpenedDocument(aOpenedChannel,
|
|
|
|
aCommand,
|
|
|
|
this,
|
|
|
|
nsnull,
|
|
|
|
nsnull,
|
|
|
|
aContentHandler);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsWebShell::PrepareToLoadURI(nsIURI * aUri,
|
|
|
|
const char * aCommand,
|
|
|
|
nsIInputStream * aPostStream,
|
|
|
|
PRBool aModifyHistory,
|
|
|
|
nsLoadFlags aType,
|
|
|
|
const PRUint32 aLocalIP,
|
|
|
|
nsISupports * aHistoryState,
|
|
|
|
const PRUnichar * aReferrer)
|
1998-11-11 23:31:45 +03:00
|
|
|
{
|
1998-07-19 01:43:02 +04:00
|
|
|
nsresult rv;
|
1999-08-04 01:48:40 +04:00
|
|
|
CancelRefreshURITimers();
|
1999-09-08 07:59:21 +04:00
|
|
|
nsXPIDLCString scheme, CUriSpec;
|
1999-01-09 05:00:42 +03:00
|
|
|
|
1999-10-13 14:24:12 +04:00
|
|
|
if (!aUri) return NS_ERROR_NULL_POINTER;
|
1999-09-29 02:11:26 +04:00
|
|
|
|
1999-09-08 07:59:21 +04:00
|
|
|
rv = aUri->GetScheme(getter_Copies(scheme));
|
1999-08-05 01:18:24 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-09-08 07:59:21 +04:00
|
|
|
rv = aUri->GetSpec(getter_Copies(CUriSpec));
|
1999-08-05 01:18:24 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
nsAutoString uriSpec(CUriSpec);
|
|
|
|
|
1999-09-08 07:59:21 +04:00
|
|
|
nsXPIDLCString spec;
|
|
|
|
rv = aUri->GetSpec(getter_Copies(spec));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-08-05 01:18:24 +04:00
|
|
|
|
|
|
|
nsString* url = new nsString(uriSpec);
|
1998-08-13 08:36:42 +04:00
|
|
|
if (aModifyHistory) {
|
|
|
|
// Discard part of history that is no longer reachable
|
|
|
|
PRInt32 i, n = mHistory.Count();
|
|
|
|
i = mHistoryIndex + 1;
|
|
|
|
while (--n >= i) {
|
|
|
|
nsString* u = (nsString*) mHistory.ElementAt(n);
|
|
|
|
delete u;
|
|
|
|
mHistory.RemoveElementAt(n);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tack on new url
|
|
|
|
mHistory.AppendElement(url);
|
|
|
|
mHistoryIndex++;
|
|
|
|
}
|
|
|
|
else {
|
1999-10-29 00:29:43 +04:00
|
|
|
|
1998-08-13 08:36:42 +04:00
|
|
|
// Replace the current history index with this URL
|
|
|
|
nsString* u = (nsString*) mHistory.ElementAt(mHistoryIndex);
|
|
|
|
if (nsnull != u) {
|
|
|
|
delete u;
|
|
|
|
}
|
|
|
|
mHistory.ReplaceElementAt(url, mHistoryIndex);
|
|
|
|
}
|
1998-07-19 01:43:02 +04:00
|
|
|
ShowHistory();
|
|
|
|
|
1999-06-16 03:29:38 +04:00
|
|
|
// Give web-shell-container right of refusal
|
|
|
|
if (nsnull != mContainer) {
|
1999-09-17 10:54:58 +04:00
|
|
|
nsAutoString str(spec);
|
|
|
|
rv = mContainer->WillLoadURL(this, str.GetUnicode(), nsLoadURL);
|
1999-06-16 03:29:38 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1999-11-18 10:06:39 +03:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-06-16 03:29:38 +04:00
|
|
|
|
1999-11-18 10:06:39 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::LoadURI(nsIURI * aUri,
|
|
|
|
const char * aCommand,
|
|
|
|
nsIInputStream* aPostDataStream,
|
|
|
|
PRBool aModifyHistory,
|
|
|
|
nsLoadFlags aType,
|
|
|
|
const PRUint32 aLocalIP,
|
|
|
|
nsISupports * aHistoryState,
|
|
|
|
const PRUnichar* aReferrer)
|
|
|
|
{
|
|
|
|
nsresult rv = PrepareToLoadURI(aUri, aCommand, aPostDataStream,
|
|
|
|
aModifyHistory, aType, aLocalIP,
|
|
|
|
aHistoryState, aReferrer);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
rv = DoLoadURL(aUri, aCommand, aPostDataStream, aType, aLocalIP, aReferrer);
|
|
|
|
return rv;
|
1999-09-08 07:59:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::LoadURL(const PRUnichar *aURLSpec,
|
|
|
|
const char* aCommand,
|
|
|
|
nsIInputStream* aPostDataStream,
|
|
|
|
PRBool aModifyHistory,
|
|
|
|
nsLoadFlags aType,
|
|
|
|
const PRUint32 aLocalIP,
|
1999-09-17 08:26:02 +04:00
|
|
|
nsISupports * aHistoryState,
|
|
|
|
const PRUnichar* aReferrer)
|
1999-09-08 07:59:21 +04:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
1999-10-13 14:24:12 +04:00
|
|
|
/*
|
|
|
|
TODO This doesnt belong here... The app should be doing all this
|
|
|
|
URL play. The webshell should not have a clue about whats "mailto"
|
|
|
|
If you insist that this should be here, then put in URL parsing
|
|
|
|
optimizations here. -Gagan
|
|
|
|
*/
|
1999-09-08 07:59:21 +04:00
|
|
|
nsAutoString urlStr(aURLSpec);
|
|
|
|
// first things first. try to create a uri out of the string.
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
1999-10-05 08:49:58 +04:00
|
|
|
nsXPIDLCString spec;
|
1999-09-08 07:59:21 +04:00
|
|
|
rv = NS_NewURI(getter_AddRefs(uri), urlStr, nsnull);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
// no dice.
|
|
|
|
nsAutoString urlSpec;
|
|
|
|
urlStr.Trim(" ", PR_TRUE, PR_TRUE);
|
|
|
|
|
|
|
|
// see if we've got a file url.
|
|
|
|
convertFileToURL(urlStr, urlSpec);
|
|
|
|
rv = NS_NewURI(getter_AddRefs(uri), urlSpec, nsnull);
|
|
|
|
if (NS_FAILED(rv)) {
|
1999-11-11 06:26:18 +03:00
|
|
|
// KEYWORDS
|
1999-11-02 07:00:07 +03:00
|
|
|
// keyword failover
|
|
|
|
// we kick the following cases to the keyword server:
|
|
|
|
// * starts with a '?'
|
|
|
|
// * contains a space
|
1999-11-11 06:26:18 +03:00
|
|
|
// * (windows only) is a single word (contains no dots or scheme) XXX: this breaks
|
|
|
|
// intranet host lookups. This latter case needs to be handled by
|
|
|
|
// dns notifications rather than string interrogation.
|
|
|
|
if (
|
|
|
|
#ifdef XP_PC
|
|
|
|
// This is windows only because windows is the only platform that utilizes
|
|
|
|
// WINS resolution (a DNS fallback) which can take several minutes to
|
|
|
|
// fail a resolve call if the host does not exist. Thus, this forces us
|
|
|
|
// to bypass DNS/WINS altogether on windows.
|
|
|
|
(urlStr.FindChar('.') == -1) ||
|
|
|
|
#endif // XP_PC
|
|
|
|
(urlStr.First() == '?') || (urlStr.FindChar(' ') > -1) ) {
|
1999-11-02 07:00:07 +03:00
|
|
|
nsAutoString keywordSpec("keyword:");
|
|
|
|
keywordSpec.Append(aURLSpec);
|
|
|
|
rv = NS_NewURI(getter_AddRefs(uri), keywordSpec, nsnull);
|
|
|
|
}
|
1999-09-08 07:59:21 +04:00
|
|
|
|
1999-11-02 07:22:12 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
PRInt32 colon, fSlash = urlSpec.FindChar('/');
|
|
|
|
PRUnichar port;
|
|
|
|
// if no scheme (protocol) is found, assume http.
|
|
|
|
if ( ((colon=urlSpec.FindChar(':')) == -1) // no colon at all
|
|
|
|
|| ( (fSlash > -1) && (colon > fSlash) ) // the only colon comes after the first slash
|
|
|
|
|| ( (colon < urlSpec.Length()-1) // the first char after the first colon is a digit (i.e. a port)
|
|
|
|
&& ((port=urlSpec.CharAt(colon+1)) <= '9')
|
|
|
|
&& (port > '0') )) {
|
|
|
|
// find host name
|
|
|
|
PRInt32 hostPos = urlSpec.FindCharInSet("./:");
|
|
|
|
if (hostPos == -1) {
|
|
|
|
hostPos = urlSpec.Length();
|
|
|
|
}
|
1999-09-08 07:59:21 +04:00
|
|
|
|
1999-11-02 07:22:12 +03:00
|
|
|
// extract host name
|
|
|
|
nsAutoString hostSpec;
|
|
|
|
urlSpec.Left(hostSpec, hostPos);
|
1999-09-08 07:59:21 +04:00
|
|
|
|
1999-11-02 07:22:12 +03:00
|
|
|
// insert url spec corresponding to host name
|
|
|
|
if (hostSpec.EqualsIgnoreCase("ftp")) {
|
|
|
|
urlSpec.Insert("ftp://", 0, 6);
|
|
|
|
} else {
|
|
|
|
urlSpec.Insert("http://", 0, 7);
|
|
|
|
}
|
|
|
|
} // end if colon
|
|
|
|
rv = NS_NewURI(getter_AddRefs(uri), urlSpec, nsnull);
|
1999-09-15 23:33:46 +04:00
|
|
|
|
1999-11-02 07:22:12 +03:00
|
|
|
nsAutoString url(aURLSpec);
|
|
|
|
if (((url.Find("mailto:", PR_TRUE))<0) && (NS_FAILED(rv))) {
|
|
|
|
// no dice, even more tricks?
|
|
|
|
return rv;
|
|
|
|
}
|
1999-09-08 07:59:21 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-10-08 03:29:13 +04:00
|
|
|
if (!uri) // we were unable to create a uri
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
//Take care of mailto: url
|
1999-09-15 23:33:46 +04:00
|
|
|
PRBool isMail= PR_FALSE;
|
1999-10-05 08:49:58 +04:00
|
|
|
rv = uri->GetSpec(getter_Copies(spec));
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
1999-09-15 23:33:46 +04:00
|
|
|
|
1999-10-05 08:49:58 +04:00
|
|
|
nsAutoString urlAStr(spec);
|
1999-09-15 23:33:46 +04:00
|
|
|
if ((urlAStr.Find("mailto", PR_TRUE)) >= 0) {
|
|
|
|
isMail = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
1999-10-05 08:49:58 +04:00
|
|
|
// Get hold of Root webshell
|
1999-09-15 23:33:46 +04:00
|
|
|
nsCOMPtr<nsIWebShell> root;
|
1999-10-05 08:49:58 +04:00
|
|
|
nsCOMPtr<nsISessionHistory> shist;
|
1999-11-04 01:30:44 +03:00
|
|
|
PRBool isLoadingHistory=PR_FALSE; // Is SH currently loading an entry from history?
|
1999-09-15 23:33:46 +04:00
|
|
|
rv = GetRootWebShell(*getter_AddRefs(root));
|
1999-10-05 08:49:58 +04:00
|
|
|
// Get hold of session History
|
|
|
|
if (NS_SUCCEEDED(rv) && root) {
|
|
|
|
root->GetSessionHistory(*getter_AddRefs(shist));
|
|
|
|
}
|
1999-11-04 01:30:44 +03:00
|
|
|
if (shist)
|
|
|
|
shist->GetLoadingFlag(&isLoadingHistory);
|
1999-09-15 23:33:46 +04:00
|
|
|
|
|
|
|
|
1999-10-29 00:29:43 +04:00
|
|
|
/*
|
|
|
|
* Save the history state for the current index iff this loadurl() request
|
|
|
|
* is not from SH. When the request comes from SH, aModifyHistory will
|
|
|
|
* be false and nsSessionHistory.cpp takes of this.
|
1999-10-05 08:49:58 +04:00
|
|
|
*/
|
1999-10-29 00:29:43 +04:00
|
|
|
if (shist) {
|
|
|
|
PRInt32 indix;
|
|
|
|
shist->GetCurrentIndex(&indix);
|
|
|
|
if (indix >= 0 && (aModifyHistory)) {
|
|
|
|
nsCOMPtr<nsISupports> historyState;
|
|
|
|
rv = GetHistoryState(getter_AddRefs(historyState));
|
|
|
|
if (NS_SUCCEEDED(rv) && historyState)
|
|
|
|
shist->SetHistoryObjectForIndex(indix, historyState);
|
|
|
|
}
|
|
|
|
}
|
1999-10-05 08:49:58 +04:00
|
|
|
/* Set the History state object for the current page in the
|
|
|
|
* presentation shell. If it is a new page being visited,
|
|
|
|
* aHistoryState is null. If the load is coming from
|
|
|
|
* session History, it will be set to the cached history object by
|
|
|
|
* session History.
|
|
|
|
*/
|
1999-11-02 00:47:54 +03:00
|
|
|
SetHistoryState(aHistoryState);
|
1999-10-05 08:49:58 +04:00
|
|
|
|
|
|
|
/* Add the page to session history */
|
|
|
|
if (aModifyHistory && shist) {
|
|
|
|
PRInt32 ret;
|
1999-11-04 01:30:44 +03:00
|
|
|
ret = shist->Add(spec, this);
|
1999-10-05 08:49:58 +04:00
|
|
|
}
|
|
|
|
|
1999-11-04 01:30:44 +03:00
|
|
|
nsCOMPtr<nsIWebShell> parent;
|
|
|
|
nsresult res = GetParent(*getter_AddRefs(parent));
|
|
|
|
nsAutoString urlstr;
|
|
|
|
|
|
|
|
if ((isLoadingHistory)) {
|
|
|
|
/* if LoadURL() got called from SH, AND If we are going "Back/Forward"
|
|
|
|
* to a frame page,SH will change the mURL to the right value
|
|
|
|
* for smoother redraw. So, create a new nsIURI based on mURL,
|
|
|
|
* so that it will work right in such situations.
|
|
|
|
*/
|
|
|
|
urlstr = mURL;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
/* If the call is not from SH, use the url passed by the caller
|
|
|
|
* so that things like JS will work right. This is for bug # 1646.
|
|
|
|
* May regress in other situations.
|
|
|
|
* What a hack
|
|
|
|
*/
|
|
|
|
urlstr=spec;
|
|
|
|
}
|
|
|
|
|
1999-10-05 08:49:58 +04:00
|
|
|
nsCOMPtr<nsIURI> newURI;
|
1999-11-04 01:30:44 +03:00
|
|
|
res = NS_NewURI(getter_AddRefs(newURI), urlstr, nsnull);
|
1999-10-05 08:49:58 +04:00
|
|
|
|
1999-11-04 01:30:44 +03:00
|
|
|
if (NS_SUCCEEDED(res)) {
|
1999-10-05 08:49:58 +04:00
|
|
|
// now that we have a uri, call the REAL LoadURI method which requires a nsIURI.
|
|
|
|
return LoadURI(newURI, aCommand, aPostDataStream, aModifyHistory, aType, aLocalIP, aHistoryState, aReferrer);
|
|
|
|
}
|
|
|
|
return rv;
|
1999-09-15 23:33:46 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
1999-09-03 01:39:01 +04:00
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
NS_IMETHODIMP nsWebShell::Stop(void)
|
|
|
|
{
|
1998-11-26 21:06:47 +03:00
|
|
|
if (nsnull != mContentViewer) {
|
|
|
|
mContentViewer->Stop();
|
|
|
|
}
|
|
|
|
|
1998-09-26 02:25:21 +04:00
|
|
|
// Cancel any timers that were set for this loader.
|
1999-08-04 01:48:40 +04:00
|
|
|
CancelRefreshURITimers();
|
1998-09-26 02:25:21 +04:00
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
if (mDocLoader) {
|
|
|
|
// Stop any documents that are currently being loaded...
|
|
|
|
mDocLoader->Stop();
|
|
|
|
}
|
1998-09-26 02:25:21 +04:00
|
|
|
|
|
|
|
// Stop the documents being loaded by children too...
|
|
|
|
PRInt32 i, n = mChildren.Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
1999-11-30 07:32:09 +03:00
|
|
|
nsIDocShell* shell = (nsIDocShell*) mChildren.ElementAt(i);
|
|
|
|
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(shell));
|
|
|
|
webShell->Stop();
|
1998-09-26 02:25:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
1998-08-15 03:08:54 +04:00
|
|
|
}
|
|
|
|
|
1999-07-07 14:47:35 +04:00
|
|
|
// This "stops" the current document load enough so that the document loader
|
|
|
|
// can be used to load a new URL.
|
1999-11-30 07:32:09 +03:00
|
|
|
NS_IMETHODIMP
|
1999-07-07 14:47:35 +04:00
|
|
|
nsWebShell::StopBeforeRequestingURL()
|
|
|
|
{
|
|
|
|
if (mDocLoader) {
|
|
|
|
// Stop any documents that are currently being loaded...
|
|
|
|
mDocLoader->Stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Recurse down the webshell hierarchy.
|
|
|
|
PRInt32 i, n = mChildren.Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
1999-11-30 07:32:09 +03:00
|
|
|
nsIDocShell* shell = (nsIDocShell*) mChildren.ElementAt(i);
|
|
|
|
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(shell));
|
|
|
|
webShell->StopBeforeRequestingURL();
|
1999-07-07 14:47:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This "stops" the current document load completely and is called once
|
|
|
|
// it has been determined that the new URL is valid and ready to be thrown
|
|
|
|
// at us from netlib.
|
1999-11-30 07:32:09 +03:00
|
|
|
NS_IMETHODIMP
|
1999-07-07 14:47:35 +04:00
|
|
|
nsWebShell::StopAfterURLAvailable()
|
|
|
|
{
|
|
|
|
if (nsnull != mContentViewer) {
|
|
|
|
mContentViewer->Stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Cancel any timers that were set for this loader.
|
1999-08-04 01:48:40 +04:00
|
|
|
CancelRefreshURITimers();
|
1999-07-07 14:47:35 +04:00
|
|
|
|
|
|
|
// Recurse down the webshell hierarchy.
|
|
|
|
PRInt32 i, n = mChildren.Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
1999-11-30 07:32:09 +03:00
|
|
|
nsIDocShell* shell = (nsIDocShell*) mChildren.ElementAt(i);
|
|
|
|
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(shell));
|
|
|
|
webShell->StopAfterURLAvailable();
|
1999-07-07 14:47:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-01 23:30:20 +04:00
|
|
|
NS_IMETHODIMP nsWebShell::Reload(nsLoadFlags aType)
|
1998-08-13 08:36:42 +04:00
|
|
|
{
|
1998-08-13 08:49:16 +04:00
|
|
|
nsString* s = (nsString*) mHistory.ElementAt(mHistoryIndex);
|
|
|
|
if (nsnull != s) {
|
|
|
|
// XXX What about the post data?
|
1999-09-17 10:54:58 +04:00
|
|
|
|
|
|
|
// Allocate since mReferrer will change beneath us
|
|
|
|
PRUnichar* str = mReferrer.ToNewUnicode();
|
|
|
|
return LoadURL(s->GetUnicode(), nsnull, PR_FALSE,
|
|
|
|
aType, 0, nsnull, str);
|
|
|
|
Recycle(str);
|
1998-08-13 08:49:16 +04:00
|
|
|
}
|
1999-09-17 10:54:58 +04:00
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
1999-10-12 08:37:43 +04:00
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
}
|
1998-08-13 08:49:16 +04:00
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
// History methods
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::Back(void)
|
|
|
|
{
|
|
|
|
return GoTo(mHistoryIndex - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::CanBack(void)
|
|
|
|
{
|
1999-10-29 00:29:43 +04:00
|
|
|
return ((mHistoryIndex-1) > - 1 ? NS_OK : NS_COMFALSE);
|
1998-08-15 03:08:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::Forward(void)
|
|
|
|
{
|
|
|
|
return GoTo(mHistoryIndex + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::CanForward(void)
|
|
|
|
{
|
|
|
|
return (mHistoryIndex < mHistory.Count() - 1 ? NS_OK : NS_COMFALSE);
|
1998-08-13 08:36:42 +04:00
|
|
|
}
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IMETHODIMP
|
1998-07-22 15:24:50 +04:00
|
|
|
nsWebShell::GoTo(PRInt32 aHistoryIndex)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
|
|
|
nsresult rv = NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
if ((aHistoryIndex >= 0) &&
|
1998-08-15 03:08:54 +04:00
|
|
|
(aHistoryIndex < mHistory.Count())) {
|
1998-07-19 01:43:02 +04:00
|
|
|
nsString* s = (nsString*) mHistory.ElementAt(aHistoryIndex);
|
|
|
|
|
|
|
|
// Give web-shell-container right of refusal
|
|
|
|
nsAutoString urlSpec(*s);
|
|
|
|
if (nsnull != mContainer) {
|
1999-04-22 04:05:59 +04:00
|
|
|
rv = mContainer->WillLoadURL(this, urlSpec.GetUnicode(), nsLoadHistory);
|
1999-01-08 03:32:55 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
1998-07-19 01:43:02 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
1999-04-07 01:01:04 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
printf("Goto %d\n", aHistoryIndex);
|
|
|
|
mHistoryIndex = aHistoryIndex;
|
|
|
|
ShowHistory();
|
|
|
|
|
1999-09-08 07:59:21 +04:00
|
|
|
// convert the uri spec into a url and then pass it to DoLoadURL
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
rv = NS_NewURI(getter_AddRefs(uri), urlSpec, nsnull);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
rv = DoLoadURL(uri, // URL string
|
1999-02-12 20:32:17 +03:00
|
|
|
"view", // Command
|
|
|
|
nsnull, // Post Data
|
1999-10-12 08:37:43 +04:00
|
|
|
nsISessionHistory::LOAD_HISTORY, // the reload type
|
1999-09-17 08:26:02 +04:00
|
|
|
0, // load attributes
|
|
|
|
nsnull); // referrer
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
return rv;
|
1999-08-09 04:03:12 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
1999-01-29 02:13:48 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetHistoryLength(PRInt32& aResult)
|
|
|
|
{
|
|
|
|
aResult = mHistory.Count();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetHistoryIndex(PRInt32& aResult)
|
|
|
|
{
|
|
|
|
aResult = mHistoryIndex;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-23 03:40:54 +04:00
|
|
|
NS_IMETHODIMP
|
1999-02-14 09:35:01 +03:00
|
|
|
nsWebShell::GetURL(PRInt32 aHistoryIndex, const PRUnichar** aURLResult)
|
1998-07-23 03:40:54 +04:00
|
|
|
{
|
|
|
|
nsresult rv = NS_ERROR_ILLEGAL_VALUE;
|
1999-10-12 08:37:43 +04:00
|
|
|
|
1999-09-21 09:27:35 +04:00
|
|
|
// XXX Ownership rules for the string passed back from this
|
|
|
|
// method are not XPCOM compliant. If they were correct,
|
|
|
|
// the caller would deallocate the string.
|
1998-07-23 03:40:54 +04:00
|
|
|
if ((aHistoryIndex >= 0) &&
|
|
|
|
(aHistoryIndex <= mHistory.Count() - 1)) {
|
|
|
|
nsString* s = (nsString*) mHistory.ElementAt(aHistoryIndex);
|
|
|
|
if (nsnull != s) {
|
1999-04-22 04:05:59 +04:00
|
|
|
*aURLResult = s->GetUnicode();
|
1998-07-23 03:40:54 +04:00
|
|
|
}
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
void
|
|
|
|
nsWebShell::ShowHistory()
|
|
|
|
{
|
1999-10-12 08:37:43 +04:00
|
|
|
#if defined(NS_DEBUG)
|
1998-07-19 01:43:02 +04:00
|
|
|
if (WEB_LOG_TEST(gLogModule, WEB_TRACE_HISTORY)) {
|
|
|
|
PRInt32 i, n = mHistory.Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
if (i == mHistoryIndex) {
|
|
|
|
printf("**");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf(" ");
|
|
|
|
}
|
|
|
|
nsString* u = (nsString*) mHistory.ElementAt(i);
|
|
|
|
fputs(*u, stdout);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-08-15 03:08:54 +04:00
|
|
|
nsWebShell::WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
1999-03-13 06:31:55 +03:00
|
|
|
nsresult rv = NS_OK;
|
1998-07-19 01:43:02 +04:00
|
|
|
if (nsnull != mContainer) {
|
1999-03-13 06:31:55 +03:00
|
|
|
rv = mContainer->WillLoadURL(aShell, aURL, aReason);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
1999-03-13 06:31:55 +03:00
|
|
|
return rv;
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-08-15 03:08:54 +04:00
|
|
|
nsWebShell::BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
|
|
|
if (nsnull != mContainer) {
|
1998-08-20 10:17:47 +04:00
|
|
|
// XXX: do not propagate this notification up from any frames...
|
1999-04-07 01:01:04 +04:00
|
|
|
return mContainer->BeginLoadURL(aShell, aURL);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-09-07 02:59:11 +04:00
|
|
|
nsWebShell::ProgressLoadURL(nsIWebShell* aShell,
|
|
|
|
const PRUnichar* aURL,
|
|
|
|
PRInt32 aProgress,
|
1998-08-15 03:08:54 +04:00
|
|
|
PRInt32 aProgressMax)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
1999-03-13 06:31:55 +03:00
|
|
|
nsresult rv = NS_OK;
|
1998-07-19 01:43:02 +04:00
|
|
|
if (nsnull != mContainer) {
|
1999-03-13 06:31:55 +03:00
|
|
|
rv = mContainer->ProgressLoadURL(aShell, aURL, aProgress, aProgressMax);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
1999-03-13 06:31:55 +03:00
|
|
|
return rv;
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
NS_IMETHODIMP
|
1999-08-05 05:28:30 +04:00
|
|
|
nsWebShell::EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsresult aStatus)
|
1998-08-15 03:08:54 +04:00
|
|
|
{
|
1999-03-13 06:31:55 +03:00
|
|
|
nsresult rv = NS_OK;
|
1998-08-15 03:08:54 +04:00
|
|
|
if (nsnull != mContainer) {
|
1998-08-20 10:17:47 +04:00
|
|
|
// XXX: do not propagate this notification up from any frames...
|
1999-01-27 06:50:10 +03:00
|
|
|
return mContainer->EndLoadURL(aShell, aURL, aStatus);
|
1998-08-15 03:08:54 +04:00
|
|
|
}
|
1999-03-13 06:31:55 +03:00
|
|
|
return rv;
|
1998-08-15 03:08:54 +04:00
|
|
|
}
|
|
|
|
|
1999-04-07 01:01:04 +04:00
|
|
|
|
1998-08-20 01:00:51 +04:00
|
|
|
NS_IMETHODIMP
|
1998-12-08 05:39:48 +03:00
|
|
|
nsWebShell::NewWebShell(PRUint32 aChromeMask,
|
|
|
|
PRBool aVisible,
|
|
|
|
nsIWebShell *&aNewWebShell)
|
1998-08-20 01:00:51 +04:00
|
|
|
{
|
|
|
|
if (nsnull != mContainer) {
|
1998-12-08 05:39:48 +03:00
|
|
|
return mContainer->NewWebShell(aChromeMask, aVisible, aNewWebShell);
|
1998-08-20 01:00:51 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-20 01:08:44 +04:00
|
|
|
NS_IMETHODIMP
|
1999-05-05 03:34:10 +04:00
|
|
|
nsWebShell::ContentShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode)
|
1999-04-20 01:08:44 +04:00
|
|
|
{
|
|
|
|
if (nsnull != mContainer) {
|
1999-05-05 03:34:10 +04:00
|
|
|
return mContainer->ContentShellAdded(aChildShell, frameNode);
|
1999-04-20 01:08:44 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-15 02:40:03 +04:00
|
|
|
NS_IMETHODIMP
|
1999-09-07 02:59:11 +04:00
|
|
|
nsWebShell::CreatePopup(nsIDOMElement* aElement, nsIDOMElement* aPopupContent,
|
|
|
|
PRInt32 aXPos, PRInt32 aYPos,
|
|
|
|
const nsString& aPopupType, const nsString& anAnchorAlignment,
|
1999-06-09 12:36:06 +04:00
|
|
|
const nsString& aPopupAlignment,
|
1999-07-01 04:07:41 +04:00
|
|
|
nsIDOMWindow* aWindow, nsIDOMWindow** outPopup)
|
1999-05-15 02:40:03 +04:00
|
|
|
{
|
|
|
|
if (nsnull != mContainer) {
|
1999-09-07 02:59:11 +04:00
|
|
|
return mContainer->CreatePopup(aElement, aPopupContent, aXPos, aYPos, aPopupType,
|
1999-06-09 12:36:06 +04:00
|
|
|
anAnchorAlignment, aPopupAlignment,
|
1999-07-01 04:07:41 +04:00
|
|
|
aWindow, outPopup);
|
1999-05-15 02:40:03 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-18 04:35:55 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult)
|
|
|
|
{
|
|
|
|
if (nsnull != mContainer) {
|
|
|
|
return mContainer->FindWebShellWithName(aName, aResult);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-08-15 03:08:54 +04:00
|
|
|
|
1998-11-06 04:30:07 +03:00
|
|
|
NS_IMETHODIMP
|
1999-04-13 01:25:08 +04:00
|
|
|
nsWebShell::FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken)
|
1998-11-06 04:30:07 +03:00
|
|
|
{
|
1999-03-02 22:19:24 +03:00
|
|
|
//If the WebShell with focus is us, pass this up to container
|
|
|
|
if (this == aFocusedWebShell && nsnull != mContainer) {
|
1999-04-13 01:25:08 +04:00
|
|
|
mContainer->FocusAvailable(this, aFocusTaken);
|
1999-03-02 22:19:24 +03:00
|
|
|
}
|
|
|
|
|
1999-11-30 07:32:09 +03:00
|
|
|
nsIDocShell* shell = nsnull;
|
1999-03-02 22:19:24 +03:00
|
|
|
|
|
|
|
//Other wise, check children and move focus to next one
|
|
|
|
PRInt32 i, n = mChildren.Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
1999-11-30 07:32:09 +03:00
|
|
|
shell = (nsIDocShell*)mChildren.ElementAt(i);
|
|
|
|
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(shell));
|
|
|
|
if (webShell.get() == aFocusedWebShell) {
|
1999-03-02 22:19:24 +03:00
|
|
|
if (++i < n) {
|
1999-11-30 07:32:09 +03:00
|
|
|
shell = (nsIDocShell*)mChildren.ElementAt(i);
|
|
|
|
nsCOMPtr<nsIBaseWindow> shellWin(do_QueryInterface(shell));
|
|
|
|
shellWin->SetFocus();
|
1999-03-02 22:19:24 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (nsnull != mContainer) {
|
1999-04-13 01:25:08 +04:00
|
|
|
mContainer->FocusAvailable(this, aFocusTaken);
|
1999-03-02 22:19:24 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1998-11-06 04:30:07 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-05-06 05:58:48 +04:00
|
|
|
|
1999-08-31 02:45:46 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetHistoryState(nsISupports** aLayoutHistoryState)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
// XXX Need to think about what to do for framesets.
|
1999-09-07 02:59:11 +04:00
|
|
|
// For now, return an error if this webshell
|
1999-08-31 02:45:46 +04:00
|
|
|
// contains a frame or a frameset document.
|
1999-09-07 02:59:11 +04:00
|
|
|
// The main content area will always have a parent. It is
|
1999-09-03 01:39:01 +04:00
|
|
|
// enough to check the children count to verify frames.
|
|
|
|
if (mChildren.Count() > 0) {
|
1999-08-31 02:45:46 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ask the pres shell for the history state
|
|
|
|
if (mContentViewer) {
|
|
|
|
nsCOMPtr<nsIDocumentViewer> docv = do_QueryInterface(mContentViewer);
|
|
|
|
if (nsnull != docv) {
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
rv = docv->GetPresShell(*getter_AddRefs(shell));
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = shell->GetHistoryState((nsILayoutHistoryState**) aLayoutHistoryState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
1999-05-06 05:58:48 +04:00
|
|
|
|
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 )
|
|
|
|
{
|
|
|
|
nsAutoString inputCharSet(aCharset);
|
|
|
|
muDV->SetHintCharacterSet(inputCharSet.GetUnicode());
|
|
|
|
muDV->SetHintCharacterSetSource((PRInt32)aSource);
|
|
|
|
if(eCharsetReloadRequested != mCharsetReloadState)
|
|
|
|
{
|
|
|
|
mCharsetReloadState = eCharsetReloadRequested;
|
|
|
|
nsAutoString url(aURL);
|
|
|
|
LoadURL(url.GetUnicode());
|
|
|
|
}
|
|
|
|
}
|
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,
|
1999-09-16 18:15:16 +04:00
|
|
|
nsCharsetSource aSource,
|
|
|
|
const char* aCmd)
|
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 )
|
|
|
|
{
|
|
|
|
nsAutoString inputCharSet(aCharset);
|
|
|
|
muDV->SetHintCharacterSet(inputCharSet.GetUnicode());
|
|
|
|
muDV->SetHintCharacterSetSource((PRInt32)aSource);
|
|
|
|
mViewSource = (0==PL_strcmp("view-source", aCmd));
|
|
|
|
if(eCharsetReloadRequested != mCharsetReloadState)
|
|
|
|
{
|
|
|
|
mCharsetReloadState = eCharsetReloadRequested;
|
|
|
|
return Reload(nsIChannel::LOAD_NORMAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// Find the web shell in the entire tree that we can reach that the
|
|
|
|
// link click should go to.
|
|
|
|
|
|
|
|
// XXX This doesn't yet know how to target other windows with their
|
|
|
|
// own tree
|
|
|
|
nsIWebShell*
|
1998-08-15 03:08:54 +04:00
|
|
|
nsWebShell::GetTarget(const PRUnichar* aName)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
1998-10-03 02:56:52 +04:00
|
|
|
nsAutoString name(aName);
|
1998-07-19 01:43:02 +04:00
|
|
|
nsIWebShell* target = nsnull;
|
|
|
|
|
1998-10-03 02:56:52 +04:00
|
|
|
if (0 == name.Length()) {
|
1998-10-07 16:15:48 +04:00
|
|
|
NS_ADDREF_THIS();
|
1998-10-03 02:56:52 +04:00
|
|
|
return this;
|
|
|
|
}
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
if (name.EqualsIgnoreCase("_blank")) {
|
1998-08-20 01:00:51 +04:00
|
|
|
nsIWebShell *shell;
|
1998-12-08 05:39:48 +03:00
|
|
|
if (NS_OK == NewWebShell(PRUint32(~0), PR_TRUE, shell))
|
1998-08-20 01:00:51 +04:00
|
|
|
target = shell;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//don't know what to do here? MMP
|
|
|
|
NS_ASSERTION(PR_FALSE, "unable to get new webshell");
|
|
|
|
}
|
1999-09-07 02:59:11 +04:00
|
|
|
}
|
1998-08-15 03:08:54 +04:00
|
|
|
else if (name.EqualsIgnoreCase("_self")) {
|
1998-07-19 01:43:02 +04:00
|
|
|
target = this;
|
1998-07-19 05:18:40 +04:00
|
|
|
NS_ADDREF(target);
|
1999-09-07 02:59:11 +04:00
|
|
|
}
|
1998-08-15 03:08:54 +04:00
|
|
|
else if (name.EqualsIgnoreCase("_parent")) {
|
1999-07-02 12:05:52 +04:00
|
|
|
GetParent(target);
|
|
|
|
if (target == nsnull) {
|
1998-07-19 01:43:02 +04:00
|
|
|
target = this;
|
1999-07-02 12:05:52 +04:00
|
|
|
NS_ADDREF(target);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
}
|
1998-08-15 03:08:54 +04:00
|
|
|
else if (name.EqualsIgnoreCase("_top")) {
|
1999-09-07 02:59:11 +04:00
|
|
|
GetRootWebShell(target); // this addrefs, which is OK
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
1999-06-27 04:35:21 +04:00
|
|
|
else if (name.EqualsIgnoreCase("_content")) {
|
|
|
|
// a kind of special case: only the window can answer this question
|
|
|
|
NS_ASSERTION(mContainer, "null container in WebShell::GetTarget");
|
|
|
|
if (nsnull != mContainer)
|
|
|
|
mContainer->FindWebShellWithName(aName, target);
|
|
|
|
// (and don't SetName())
|
|
|
|
// else target remains nsnull, which would be bad
|
|
|
|
}
|
1998-07-19 01:43:02 +04:00
|
|
|
else {
|
|
|
|
// Look from the top of the tree downward
|
1999-06-27 04:35:21 +04:00
|
|
|
NS_ASSERTION(mContainer, "null container in WebShell::GetTarget");
|
1998-09-18 04:35:55 +04:00
|
|
|
if (nsnull != mContainer) {
|
|
|
|
mContainer->FindWebShellWithName(aName, target);
|
|
|
|
if (nsnull == target) {
|
1999-08-11 01:36:38 +04:00
|
|
|
mContainer->NewWebShell(NS_CHROME_ALL_CHROME, PR_TRUE, target);
|
1998-09-18 04:35:55 +04:00
|
|
|
}
|
|
|
|
if (nsnull != target) {
|
1999-09-07 02:59:11 +04:00
|
|
|
target->SetName(aName);
|
1998-09-18 04:35:55 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
target = this;
|
|
|
|
NS_ADDREF(target);
|
|
|
|
}
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
}
|
1998-07-19 05:18:40 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
return target;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
1998-11-14 03:21:19 +03:00
|
|
|
nsAutoString target(aTargetSpec);
|
|
|
|
|
1999-08-05 02:46:49 +04:00
|
|
|
|
1998-11-14 03:21:19 +03:00
|
|
|
switch(aVerb) {
|
|
|
|
case eLinkVerb_New:
|
|
|
|
target.SetString("_blank");
|
|
|
|
// Fall into replace case
|
1999-09-07 02:59:11 +04:00
|
|
|
case eLinkVerb_Replace:
|
1998-11-14 03:21:19 +03:00
|
|
|
{
|
|
|
|
nsIWebShell* shell = GetTarget(target.GetUnicode());
|
|
|
|
if (nsnull != shell) {
|
1999-09-17 10:54:58 +04:00
|
|
|
// Allocate since mURL may change beneath us
|
|
|
|
PRUnichar* str = mURL.ToNewUnicode();
|
1999-09-17 08:26:02 +04:00
|
|
|
(void)shell->LoadURL(aURLSpec, aPostDataStream,
|
|
|
|
PR_TRUE, nsIChannel::LOAD_NORMAL,
|
1999-09-17 10:54:58 +04:00
|
|
|
0, nsnull, str);
|
|
|
|
Recycle(str);
|
1998-11-14 03:21:19 +03:00
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case eLinkVerb_Embed:
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
// XXX Need to do this
|
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
|
|
|
{
|
1998-08-15 03:08:54 +04:00
|
|
|
if (!mOverURL.Equals(aURLSpec) || !mOverTarget.Equals(aTargetSpec)) {
|
1998-11-26 21:06:47 +03:00
|
|
|
#ifdef NOISY_LINKS
|
1999-09-07 02:59:11 +04:00
|
|
|
fputs("Was '", stdout);
|
|
|
|
fputs(mOverURL, stdout);
|
|
|
|
fputs("' '", stdout);
|
|
|
|
fputs(mOverTarget, stdout);
|
|
|
|
fputs("'\n", stdout);
|
1998-07-19 01:43:02 +04:00
|
|
|
fputs("Over link '", stdout);
|
|
|
|
fputs(aURLSpec, stdout);
|
|
|
|
fputs("' '", stdout);
|
|
|
|
fputs(aTargetSpec, stdout);
|
|
|
|
fputs("'\n", stdout);
|
1998-10-02 22:44:56 +04:00
|
|
|
#endif /* NS_DEBUG */
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
mOverURL = aURLSpec;
|
|
|
|
mOverTarget = aTargetSpec;
|
1998-08-07 08:45:03 +04:00
|
|
|
|
1998-09-09 05:19:11 +04:00
|
|
|
// Get the browser window and setStatus
|
1998-10-02 22:44:56 +04:00
|
|
|
nsIBrowserWindow *browserWindow;
|
|
|
|
|
|
|
|
browserWindow = GetBrowserWindow();
|
|
|
|
if (nsnull != browserWindow) {
|
|
|
|
browserWindow->SetStatus(aURLSpec);
|
|
|
|
NS_RELEASE(browserWindow);
|
1998-09-09 05:19:11 +04:00
|
|
|
}
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-08-24 22:20:30 +04:00
|
|
|
nsWebShell::GetLinkState(const PRUnichar* aURLSpec, nsLinkState& aState)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
|
|
|
aState = eLinkState_Unvisited;
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1999-05-18 09:21:37 +04:00
|
|
|
nsresult rv;
|
|
|
|
|
1999-06-08 01:26:10 +04:00
|
|
|
// XXX: GlobalHistory is going to be moved out of the webshell into a more appropriate place.
|
1999-08-24 22:20:30 +04:00
|
|
|
if ((nsnull == mHistoryService) && !mFailedToLoadHistoryService) {
|
1999-06-08 01:26:10 +04:00
|
|
|
rv = nsServiceManager::GetService(kGlobalHistoryCID,
|
|
|
|
nsIGlobalHistory::GetIID(),
|
|
|
|
(nsISupports**) &mHistoryService);
|
1999-05-18 09:21:37 +04:00
|
|
|
|
1999-08-24 22:20:30 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
mFailedToLoadHistoryService = PR_TRUE;
|
|
|
|
}
|
1999-05-19 11:22:57 +04:00
|
|
|
}
|
1999-05-18 09:21:37 +04:00
|
|
|
|
1999-08-24 22:20:30 +04:00
|
|
|
if (mHistoryService) {
|
|
|
|
// XXX aURLSpec should really be a char*, not a PRUnichar*.
|
|
|
|
nsAutoString urlStr(aURLSpec);
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1999-08-24 22:20:30 +04:00
|
|
|
char buf[256];
|
|
|
|
char* url = buf;
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1999-08-24 22:20:30 +04:00
|
|
|
if (urlStr.Length() >= PRInt32(sizeof buf)) {
|
|
|
|
url = new char[urlStr.Length() + 1];
|
|
|
|
}
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1999-08-24 22:20:30 +04:00
|
|
|
PRInt64 lastVisitDate;
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1999-08-24 22:20:30 +04:00
|
|
|
if (url) {
|
|
|
|
urlStr.ToCString(url, urlStr.Length() + 1);
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1999-08-24 22:20:30 +04:00
|
|
|
rv = mHistoryService->GetLastVisitDate(url, &lastVisitDate);
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1999-08-24 22:20:30 +04:00
|
|
|
if (url != buf)
|
|
|
|
delete[] url;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1999-08-24 22:20:30 +04:00
|
|
|
//XXX: Moved to destructor nsServiceManager::ReleaseService(kGlobalHistoryCID, mHistoryService);
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1999-08-24 22:20:30 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1999-08-24 22:20:30 +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
|
|
|
|
1999-08-24 22:20:30 +04:00
|
|
|
// XXX how to tell if eLinkState_OutOfDate?
|
1999-05-19 11:22:57 +04:00
|
|
|
}
|
1999-05-18 09:21:37 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
1998-10-02 22:44:56 +04:00
|
|
|
nsIBrowserWindow* nsWebShell::GetBrowserWindow()
|
|
|
|
{
|
1999-11-16 23:06:12 +03:00
|
|
|
nsCOMPtr<nsIWebShell> rootWebShell;
|
1998-10-02 22:44:56 +04:00
|
|
|
nsIBrowserWindow *browserWindow = nsnull;
|
|
|
|
|
1999-11-16 23:06:12 +03:00
|
|
|
GetRootWebShellEvenIfChrome(getter_AddRefs(rootWebShell));
|
1998-10-02 22:44:56 +04:00
|
|
|
|
1999-11-16 23:06:12 +03:00
|
|
|
if (rootWebShell) {
|
1998-10-02 22:44:56 +04:00
|
|
|
nsIWebShellContainer *rootContainer;
|
|
|
|
rootWebShell->GetContainer(rootContainer);
|
|
|
|
if (nsnull != rootContainer) {
|
|
|
|
rootContainer->QueryInterface(kIBrowserWindowIID, (void**)&browserWindow);
|
|
|
|
NS_RELEASE(rootContainer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return browserWindow;
|
|
|
|
}
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1998-11-23 11:09:11 +03:00
|
|
|
nsresult
|
|
|
|
nsWebShell::CreateScriptEnvironment()
|
1998-07-21 08:46:55 +04:00
|
|
|
{
|
|
|
|
nsresult res = NS_OK;
|
|
|
|
|
|
|
|
if (nsnull == mScriptGlobal) {
|
|
|
|
res = NS_NewScriptGlobalObject(&mScriptGlobal);
|
1999-01-08 03:32:55 +03:00
|
|
|
if (NS_FAILED(res)) {
|
1998-07-21 08:46:55 +04:00
|
|
|
return res;
|
|
|
|
}
|
1998-08-07 08:45:03 +04:00
|
|
|
mScriptGlobal->SetWebShell(this);
|
|
|
|
}
|
1998-07-21 08:46:55 +04:00
|
|
|
|
1998-08-07 08:45:03 +04:00
|
|
|
if (nsnull == mScriptContext) {
|
1999-08-09 23:14:49 +04:00
|
|
|
res = NS_CreateScriptContext(mScriptGlobal, &mScriptContext);
|
1999-09-09 03:16:49 +04:00
|
|
|
if (NS_SUCCEEDED(res)) {
|
|
|
|
mScriptContext->SetOwner(this);
|
|
|
|
}
|
1998-07-21 08:46:55 +04:00
|
|
|
}
|
|
|
|
|
1998-11-23 11:09:11 +03:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
1999-09-07 02:59:11 +04:00
|
|
|
nsresult
|
1998-11-23 11:09:11 +03:00
|
|
|
nsWebShell::GetScriptContext(nsIScriptContext** aContext)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aContext, "null arg");
|
|
|
|
nsresult res = NS_OK;
|
|
|
|
|
|
|
|
res = CreateScriptEnvironment();
|
|
|
|
|
1999-01-08 03:32:55 +03:00
|
|
|
if (NS_SUCCEEDED(res)) {
|
1998-11-23 11:09:11 +03:00
|
|
|
*aContext = mScriptContext;
|
|
|
|
NS_ADDREF(mScriptContext);
|
|
|
|
}
|
1998-07-21 08:46:55 +04:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
1999-09-07 02:59:11 +04:00
|
|
|
nsresult
|
1998-07-24 09:07:51 +04:00
|
|
|
nsWebShell::GetScriptGlobalObject(nsIScriptGlobalObject** aGlobal)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aGlobal, "null arg");
|
|
|
|
nsresult res = NS_OK;
|
|
|
|
|
1998-11-23 11:09:11 +03:00
|
|
|
res = CreateScriptEnvironment();
|
1998-07-25 05:53:54 +04:00
|
|
|
|
1999-01-08 03:32:55 +03:00
|
|
|
if (NS_SUCCEEDED(res)) {
|
1998-11-23 11:09:11 +03:00
|
|
|
*aGlobal = mScriptGlobal;
|
|
|
|
NS_IF_ADDREF(mScriptGlobal);
|
|
|
|
}
|
1998-07-24 09:07:51 +04:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
1999-09-07 02:59:11 +04:00
|
|
|
nsresult
|
1998-07-21 08:46:55 +04:00
|
|
|
nsWebShell::ReleaseScriptContext(nsIScriptContext *aContext)
|
|
|
|
{
|
|
|
|
// XXX Is this right? Why are we passing in a context?
|
|
|
|
NS_IF_RELEASE(aContext);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-09 03:16:49 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::ReportScriptError(const char* aErrorString,
|
|
|
|
const char* aFileName,
|
|
|
|
PRInt32 aLineNo,
|
|
|
|
const char* aLineBuf)
|
|
|
|
{
|
|
|
|
// XXX To be implemented by scc. The following implementation
|
|
|
|
// is temporary.
|
|
|
|
|
1999-09-17 08:26:02 +04:00
|
|
|
nsAutoString error;
|
|
|
|
error.SetString("JavaScript Error: ");
|
|
|
|
error.Append(aErrorString);
|
1999-09-09 03:16:49 +04:00
|
|
|
error += "\n";
|
|
|
|
|
|
|
|
if (aFileName) {
|
|
|
|
error += "URL: ";
|
|
|
|
error += aFileName;
|
|
|
|
error += "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if(aLineNo) {
|
|
|
|
error += "LineNo: ";
|
|
|
|
error.Append(aLineNo, 10);
|
|
|
|
error += "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if(aLineBuf) {
|
|
|
|
error += "Line text: '";
|
|
|
|
error += aLineBuf;
|
|
|
|
error += "'\n";
|
|
|
|
}
|
|
|
|
|
1999-09-17 08:26:02 +04:00
|
|
|
// XXX Ughhh...allocation
|
|
|
|
char* errorStr = error.ToNewCString();
|
|
|
|
if (errorStr) {
|
|
|
|
printf("%s\n", errorStr);
|
|
|
|
Recycle(errorStr);
|
|
|
|
}
|
1999-09-09 03:16:49 +04:00
|
|
|
|
1999-09-21 04:04:31 +04:00
|
|
|
// XXX Turn it off for now...there should be an Error method too
|
|
|
|
//Alert(error.GetUnicode());
|
1999-09-17 08:26:02 +04:00
|
|
|
|
1999-09-09 03:16:49 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
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::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
|
|
|
nsIDocumentViewer* docViewer;
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
1999-05-06 07:54:40 +04:00
|
|
|
|
1999-05-18 02:14:16 +04:00
|
|
|
if ((nsnull != mScriptGlobal) &&
|
|
|
|
(loader == mDocLoader)) {
|
1999-09-07 02:59:11 +04:00
|
|
|
if (nsnull != mContentViewer &&
|
1999-03-30 03:01:13 +04:00
|
|
|
NS_OK == mContentViewer->QueryInterface(kIDocumentViewerIID, (void**)&docViewer)) {
|
|
|
|
nsIPresContext *presContext;
|
|
|
|
if (NS_OK == docViewer->GetPresContext(presContext)) {
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
|
|
|
nsMouseEvent event;
|
|
|
|
event.eventStructType = NS_EVENT;
|
|
|
|
event.message = NS_PAGE_UNLOAD;
|
1999-11-24 09:03:41 +03:00
|
|
|
rv = mScriptGlobal->HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
|
1999-03-30 03:01:13 +04:00
|
|
|
|
|
|
|
NS_RELEASE(presContext);
|
|
|
|
}
|
|
|
|
NS_RELEASE(docViewer);
|
|
|
|
}
|
|
|
|
}
|
1999-04-07 01:01:04 +04:00
|
|
|
|
1999-09-15 01:49:21 +04:00
|
|
|
if (loader == mDocLoader) {
|
|
|
|
nsCOMPtr<nsIDocumentLoaderObserver> dlObserver;
|
|
|
|
|
|
|
|
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<nsIWebShell> root;
|
|
|
|
nsresult res = GetRootWebShell(*getter_AddRefs(root));
|
1999-04-07 01:01:04 +04:00
|
|
|
|
1999-09-15 01:49:21 +04:00
|
|
|
if (NS_SUCCEEDED(res) && root)
|
1999-11-30 00:15:32 +03:00
|
|
|
root->GetDocLoaderObserver(getter_AddRefs(dlObserver));
|
1999-09-15 01:49:21 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dlObserver = do_QueryInterface(mDocLoaderObserver); // we need this to addref
|
|
|
|
}
|
|
|
|
/*
|
1999-10-13 14:24:12 +04:00
|
|
|
* Fire the OnStartDocumentLoad of the webshell observer
|
1999-09-15 01:49:21 +04:00
|
|
|
*/
|
|
|
|
if ((nsnull != mContainer) && (nsnull != dlObserver))
|
1999-09-17 08:26:02 +04:00
|
|
|
{
|
1999-09-15 01:49:21 +04:00
|
|
|
dlObserver->OnStartDocumentLoad(mDocLoader, aURL, aCommand);
|
1999-09-17 08:26:02 +04:00
|
|
|
}
|
1999-09-15 01:49:21 +04:00
|
|
|
}
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1999-03-30 03:01:13 +04:00
|
|
|
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-08-05 05:28:30 +04:00
|
|
|
nsresult aStatus,
|
1999-09-07 02:59:11 +04:00
|
|
|
nsIDocumentLoaderObserver * aWebShell)
|
1999-03-29 13:21:01 +04:00
|
|
|
{
|
1999-10-20 02:27:20 +04:00
|
|
|
#ifdef MOZ_PERF_METRICS
|
1999-11-10 06:41:09 +03:00
|
|
|
MOZ_TIMER_DEBUGLOG(("Stop: nsWebShell::OnEndDocumentLoad(), this=%p\n", this));
|
|
|
|
MOZ_TIMER_STOP(mTotalTime);
|
|
|
|
MOZ_TIMER_LOG(("Total (Layout + Page Load) Time (webshell=%p): ", this));
|
|
|
|
MOZ_TIMER_PRINT(mTotalTime);
|
1999-09-24 11:13:39 +04:00
|
|
|
#endif
|
|
|
|
|
1999-06-28 14:35:57 +04:00
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
1999-09-15 04:23:40 +04:00
|
|
|
if (!channel) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-06-28 14:35:57 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> aURL;
|
|
|
|
rv = channel->GetURI(getter_AddRefs(aURL));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
1999-08-27 02:45:55 +04:00
|
|
|
//if (!mProcessedEndDocumentLoad) {
|
|
|
|
if (loader == mDocLoader) {
|
1999-09-07 02:59:11 +04:00
|
|
|
mProcessedEndDocumentLoad = PR_TRUE;
|
1999-05-04 03:04:50 +04:00
|
|
|
|
|
|
|
if (nsnull != mScriptGlobal) {
|
|
|
|
nsIDocumentViewer* docViewer;
|
1999-09-07 02:59:11 +04:00
|
|
|
if (nsnull != mContentViewer &&
|
1999-05-04 03:04:50 +04:00
|
|
|
NS_OK == mContentViewer->QueryInterface(kIDocumentViewerIID, (void**)&docViewer)) {
|
|
|
|
nsIPresContext *presContext;
|
|
|
|
if (NS_OK == docViewer->GetPresContext(presContext)) {
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
|
|
|
nsMouseEvent event;
|
|
|
|
event.eventStructType = NS_EVENT;
|
|
|
|
event.message = NS_PAGE_LOAD;
|
1999-11-24 09:03:41 +03:00
|
|
|
rv = mScriptGlobal->HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
|
1999-05-04 03:04:50 +04:00
|
|
|
|
|
|
|
NS_RELEASE(presContext);
|
|
|
|
}
|
|
|
|
NS_RELEASE(docViewer);
|
1999-04-07 01:01:04 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-05-04 03:04:50 +04:00
|
|
|
// Fire the EndLoadURL of the web shell container
|
|
|
|
if (nsnull != aURL) {
|
|
|
|
nsAutoString urlString;
|
1999-06-28 14:35:57 +04:00
|
|
|
char* spec;
|
1999-05-04 03:04:50 +04:00
|
|
|
rv = aURL->GetSpec(&spec);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
urlString = spec;
|
|
|
|
if (nsnull != mContainer) {
|
|
|
|
rv = mContainer->EndLoadURL(this, urlString.GetUnicode(), 0);
|
1999-09-07 02:59:11 +04:00
|
|
|
}
|
1999-06-28 14:35:57 +04:00
|
|
|
nsCRT::free(spec);
|
1999-05-04 03:04:50 +04:00
|
|
|
}
|
|
|
|
}
|
1999-04-07 01:01:04 +04:00
|
|
|
|
1999-06-22 02:17:14 +04:00
|
|
|
|
1999-09-07 02:59:11 +04:00
|
|
|
nsCOMPtr<nsIDocumentLoaderObserver> dlObserver;
|
1999-06-22 02:17:14 +04:00
|
|
|
|
1999-06-15 02:11:47 +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
|
|
|
|
*/
|
1999-06-20 02:06:35 +04:00
|
|
|
nsCOMPtr<nsIWebShell> root;
|
1999-06-22 02:17:14 +04:00
|
|
|
nsresult res = GetRootWebShell(*getter_AddRefs(root));
|
1999-09-07 02:59:11 +04:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(res) && root)
|
1999-11-30 00:15:32 +03:00
|
|
|
root->GetDocLoaderObserver(getter_AddRefs(dlObserver));
|
1999-06-15 02:11:47 +04:00
|
|
|
}
|
|
|
|
else
|
1999-06-20 02:06:35 +04:00
|
|
|
{
|
1999-09-07 02:59:11 +04:00
|
|
|
/* Take care of the Trailing slash situation */
|
|
|
|
if (mSHist)
|
|
|
|
CheckForTrailingSlash(aURL);
|
|
|
|
dlObserver = do_QueryInterface(mDocLoaderObserver); // we need this to addref
|
1999-06-20 02:06:35 +04:00
|
|
|
}
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1999-05-04 03:04:50 +04:00
|
|
|
/*
|
|
|
|
* Fire the OnEndDocumentLoad of the DocLoaderobserver
|
|
|
|
*/
|
1999-06-20 02:06:35 +04:00
|
|
|
if (dlObserver && (nsnull != aURL)) {
|
1999-06-28 14:35:57 +04:00
|
|
|
dlObserver->OnEndDocumentLoad(mDocLoader, channel, aStatus, aWebShell);
|
1999-05-04 03:04:50 +04:00
|
|
|
}
|
1999-06-15 02:11:47 +04:00
|
|
|
|
1999-11-11 06:26:18 +03:00
|
|
|
if ( (mDocLoader == loader) && (aStatus == NS_ERROR_UNKNOWN_HOST) ) {
|
|
|
|
// KEYWORDS
|
|
|
|
// if a lookup failed, check to see if it was non-qualified.
|
|
|
|
// if it was, kick it to the keyword server. the keyword server
|
|
|
|
// now handles the www.*.com trick.
|
|
|
|
char *host = nsnull;
|
|
|
|
rv = aURL->GetHost(&host);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
if(!host) return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
char *tmp = host;
|
|
|
|
while (*tmp && (*tmp != '.')) tmp++;
|
|
|
|
if (!*tmp) {
|
|
|
|
nsAutoString keywordSpec("keyword:");
|
|
|
|
keywordSpec.Append(host);
|
|
|
|
rv = LoadURL(keywordSpec.GetUnicode(), "view");
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
// if we couldn't load the keyword munged URL do
|
|
|
|
// our own www.*.com trick.
|
|
|
|
nsAllocator::Free(host);
|
|
|
|
nsCAutoString hostStr;
|
|
|
|
rv = aURL->GetHost(&host);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
hostStr.SetString(host);
|
|
|
|
PRInt32 dotLoc = -1;
|
|
|
|
dotLoc = hostStr.FindChar('.');
|
|
|
|
PRBool retry = PR_FALSE;
|
|
|
|
if (-1 == dotLoc) {
|
|
|
|
hostStr.Insert("www.", 0, 4);
|
|
|
|
hostStr.Append(".com");
|
|
|
|
retry = PR_TRUE;
|
|
|
|
} else if ( (hostStr.Length() - dotLoc) == 3) {
|
|
|
|
hostStr.Insert("www.", 0, 4);
|
|
|
|
retry = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (retry) {
|
|
|
|
rv = aURL->SetHost(hostStr.GetBuffer());
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
char *aSpec = nsnull;
|
|
|
|
rv = aURL->GetSpec(&aSpec);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
nsAutoString newURL(aSpec);
|
|
|
|
nsAllocator::Free(aSpec);
|
|
|
|
// reload the url
|
|
|
|
rv = LoadURL(newURL.GetUnicode(), "view");
|
|
|
|
} // retry
|
|
|
|
} // end keyword load failure
|
|
|
|
} // end !*tmp
|
|
|
|
nsAllocator::Free(host);
|
|
|
|
} // unknown host
|
1999-06-15 02:11:47 +04:00
|
|
|
} //!mProcessedEndDocumentLoad
|
1999-05-04 03:04:50 +04:00
|
|
|
else {
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-07 01:01:04 +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,
|
|
|
|
nsIChannel* channel,
|
1999-01-14 09:44:23 +03:00
|
|
|
nsIContentViewer* aViewer)
|
|
|
|
{
|
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.
|
1999-07-08 05:23:56 +04:00
|
|
|
nsXPIDLCString url;
|
|
|
|
aURL->GetSpec(getter_Copies(url));
|
1999-07-07 14:47:35 +04:00
|
|
|
if (0 == PL_strcmp(url, mURL.GetBuffer()))
|
|
|
|
StopAfterURLAvailable();
|
|
|
|
|
1999-04-07 01:01:04 +04:00
|
|
|
/*
|
|
|
|
*Fire the OnStartDocumentLoad of the webshell observer
|
|
|
|
*/
|
|
|
|
if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver))
|
|
|
|
{
|
1999-07-16 15:14:36 +04:00
|
|
|
mDocLoaderObserver->OnStartURLLoad(mDocLoader, channel, aViewer);
|
1999-04-07 01:01:04 +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
|
|
|
|
const char* spec;
|
|
|
|
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-09-23 07:27:53 +04:00
|
|
|
if(eCharsetReloadRequested == mCharsetReloadState)
|
|
|
|
mCharsetReloadState = eCharsetReloadStopOrigional;
|
|
|
|
else
|
|
|
|
mCharsetReloadState = eCharsetReloadInit;
|
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-08-19 03:25:17 +04:00
|
|
|
/* For use with redirect/refresh url api */
|
1999-09-07 02:59:11 +04:00
|
|
|
class refreshData : public nsITimerCallback
|
1998-09-26 02:25:21 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
refreshData();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
// nsITimerCallback interface
|
|
|
|
virtual void Notify(nsITimer *timer);
|
|
|
|
|
|
|
|
nsIWebShell* mShell;
|
|
|
|
nsString mUrlSpec;
|
|
|
|
PRBool mRepeat;
|
|
|
|
PRInt32 mDelay;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~refreshData();
|
1998-08-19 03:25:17 +04:00
|
|
|
};
|
|
|
|
|
1998-09-26 02:25:21 +04:00
|
|
|
refreshData::refreshData()
|
|
|
|
{
|
|
|
|
NS_INIT_REFCNT();
|
|
|
|
|
|
|
|
mShell = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
refreshData::~refreshData()
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mShell);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS(refreshData, kITimerCallbackIID);
|
|
|
|
|
|
|
|
void refreshData::Notify(nsITimer *aTimer)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION((nsnull != mShell), "Null pointer...");
|
|
|
|
if (nsnull != mShell) {
|
1999-06-28 14:35:57 +04:00
|
|
|
mShell->LoadURL(mUrlSpec.GetUnicode(), nsnull, PR_TRUE, nsIChannel::LOAD_NORMAL);
|
1998-09-26 02:25:21 +04:00
|
|
|
}
|
1999-09-07 02:59:11 +04:00
|
|
|
/*
|
1998-09-26 02:25:21 +04:00
|
|
|
* LoadURL(...) will cancel all refresh timers... This causes the Timer and
|
|
|
|
* its refreshData instance to be released...
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-08-19 03:25:17 +04:00
|
|
|
NS_IMETHODIMP
|
1999-08-04 01:48:40 +04:00
|
|
|
nsWebShell::RefreshURI(nsIURI* aURI, PRInt32 millis, PRBool repeat)
|
1999-05-29 01:32:29 +04:00
|
|
|
{
|
1999-09-07 02:59:11 +04:00
|
|
|
|
1999-05-29 01:32:29 +04:00
|
|
|
nsresult rv = NS_OK;
|
1999-08-04 01:48:40 +04:00
|
|
|
if (nsnull == aURI) {
|
|
|
|
NS_PRECONDITION((aURI != nsnull), "Null pointer");
|
1999-05-29 01:32:29 +04:00
|
|
|
rv = NS_ERROR_NULL_POINTER;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
1999-06-28 14:35:57 +04:00
|
|
|
char* spec;
|
1999-08-04 01:48:40 +04:00
|
|
|
aURI->GetSpec(&spec);
|
1999-05-29 01:32:29 +04:00
|
|
|
rv = RefreshURL(spec, millis, repeat);
|
1999-06-28 14:35:57 +04:00
|
|
|
nsCRT::free(spec);
|
1999-09-15 04:23:40 +04:00
|
|
|
|
1999-05-29 01:32:29 +04:00
|
|
|
done:
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-08-04 01:48:40 +04:00
|
|
|
nsWebShell::RefreshURL(const char* aURI, PRInt32 millis, PRBool repeat)
|
1998-08-19 03:25:17 +04:00
|
|
|
{
|
1998-09-26 02:25:21 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsITimer *timer=nsnull;
|
|
|
|
refreshData *data;
|
|
|
|
|
1999-08-04 01:48:40 +04:00
|
|
|
if (nsnull == aURI) {
|
|
|
|
NS_PRECONDITION((aURI != nsnull), "Null pointer");
|
1998-09-26 02:25:21 +04:00
|
|
|
rv = NS_ERROR_NULL_POINTER;
|
|
|
|
goto done;
|
|
|
|
}
|
1998-08-19 03:25:17 +04:00
|
|
|
|
1998-09-26 02:25:21 +04:00
|
|
|
NS_NEWXPCOM(data, refreshData);
|
|
|
|
if (nsnull == data) {
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
goto done;
|
|
|
|
}
|
1998-08-19 03:25:17 +04:00
|
|
|
|
1998-09-26 02:25:21 +04:00
|
|
|
// Set the reference count to one...
|
|
|
|
NS_ADDREF(data);
|
1998-08-19 03:25:17 +04:00
|
|
|
|
1998-09-26 02:25:21 +04:00
|
|
|
data->mShell = this;
|
|
|
|
NS_ADDREF(data->mShell);
|
|
|
|
|
1999-08-04 01:48:40 +04:00
|
|
|
data->mUrlSpec = aURI;
|
1998-09-26 02:25:21 +04:00
|
|
|
data->mDelay = millis;
|
|
|
|
data->mRepeat = repeat;
|
|
|
|
|
|
|
|
/* Create the timer. */
|
|
|
|
if (NS_OK == NS_NewTimer(&timer)) {
|
|
|
|
/* Add the timer to our array. */
|
|
|
|
NS_LOCK_INSTANCE();
|
|
|
|
mRefreshments.AppendElement(timer);
|
|
|
|
timer->Init(data, millis);
|
|
|
|
NS_UNLOCK_INSTANCE();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_RELEASE(data);
|
|
|
|
|
|
|
|
done:
|
|
|
|
return rv;
|
1998-08-19 03:25:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-08-04 01:48:40 +04:00
|
|
|
nsWebShell::CancelRefreshURITimers(void)
|
1999-05-07 23:25:58 +04:00
|
|
|
{
|
|
|
|
PRInt32 i;
|
1998-09-26 02:25:21 +04:00
|
|
|
nsITimer* timer;
|
1998-08-19 03:25:17 +04:00
|
|
|
|
1998-09-26 02:25:21 +04:00
|
|
|
/* Right now all we can do is cancel all the timers for this webshell. */
|
|
|
|
NS_LOCK_INSTANCE();
|
1998-08-19 03:25:17 +04:00
|
|
|
|
1998-09-26 02:25:21 +04:00
|
|
|
/* Walk the list backwards to avoid copying the array as it shrinks.. */
|
1999-05-07 23:25:58 +04:00
|
|
|
for (i = mRefreshments.Count()-1; (0 <= i); i--) {
|
|
|
|
timer=(nsITimer*)mRefreshments.ElementAt(i);
|
1998-09-26 02:25:21 +04:00
|
|
|
/* Remove the entry from the list before releasing the timer.*/
|
1999-05-07 23:25:58 +04:00
|
|
|
mRefreshments.RemoveElementAt(i);
|
1998-08-19 03:25:17 +04:00
|
|
|
|
1998-09-26 02:25:21 +04:00
|
|
|
if (timer) {
|
|
|
|
timer->Cancel();
|
|
|
|
NS_RELEASE(timer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_UNLOCK_INSTANCE();
|
1998-08-20 10:17:47 +04:00
|
|
|
|
1998-09-26 02:25:21 +04:00
|
|
|
return NS_OK;
|
1998-08-19 03:25:17 +04:00
|
|
|
}
|
|
|
|
|
1999-03-18 04:07:22 +03:00
|
|
|
|
1998-07-21 08:46:55 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1999-03-18 04:07:22 +03:00
|
|
|
/*
|
|
|
|
* There are cases where netlib does things like add a trailing slash
|
|
|
|
* to the url being retrieved. We need to watch out for such
|
|
|
|
* changes and update the currently loading url's entry in the history
|
|
|
|
* list. UpdateHistoryEntry() does this.
|
|
|
|
*
|
1999-09-07 02:59:11 +04:00
|
|
|
* Assumptions:
|
1999-03-18 04:07:22 +03:00
|
|
|
*
|
|
|
|
* 1) aURL is the URL that was inserted into the history list in LoadURL()
|
|
|
|
* 2) The load of aURL is in progress and this function is being called
|
|
|
|
* from one of the functions in nsIStreamListener implemented by nsWebShell.
|
|
|
|
*/
|
1999-06-23 07:29:44 +04:00
|
|
|
nsresult nsWebShell::CheckForTrailingSlash(nsIURI* aURL)
|
1999-03-18 04:07:22 +03:00
|
|
|
{
|
1999-06-16 03:29:38 +04:00
|
|
|
|
1999-06-22 02:17:14 +04:00
|
|
|
PRInt32 curIndex=0;
|
1999-08-29 03:51:12 +04:00
|
|
|
nsresult rv;
|
1999-06-22 02:17:14 +04:00
|
|
|
|
|
|
|
/* Get current history index and url for it */
|
1999-10-12 08:37:43 +04:00
|
|
|
rv = mSHist->GetCurrentIndex(&curIndex);
|
1999-06-22 02:17:14 +04:00
|
|
|
|
|
|
|
/* Get the url that netlib passed us */
|
1999-06-28 14:35:57 +04:00
|
|
|
char* spec;
|
1999-06-22 02:17:14 +04:00
|
|
|
aURL->GetSpec(&spec);
|
1999-10-23 00:48:07 +04:00
|
|
|
|
1999-10-12 08:37:43 +04:00
|
|
|
//Set it in session history
|
1999-11-27 05:14:40 +03:00
|
|
|
if (NS_SUCCEEDED(rv) && !mTitle.IsEmpty()) {
|
|
|
|
mSHist->SetTitleForIndex(curIndex, mTitle.GetUnicode());
|
1999-09-07 02:59:11 +04:00
|
|
|
// Replace the top most history entry with the new url
|
1999-10-23 00:48:07 +04:00
|
|
|
mSHist->SetURLForIndex(curIndex, spec);
|
1999-06-22 02:17:14 +04:00
|
|
|
}
|
1999-10-23 00:48:07 +04:00
|
|
|
nsCRT::free(spec);
|
1999-09-21 05:02:29 +04:00
|
|
|
|
1999-10-12 08:37:43 +04:00
|
|
|
|
1999-03-18 04:07:22 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-03 11:03:22 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1999-07-01 23:30:20 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::Alert(const PRUnichar *text)
|
1998-11-03 11:03:22 +03:00
|
|
|
{
|
1999-09-21 04:04:31 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIPrompt> prompter;
|
|
|
|
|
|
|
|
if (mContainer) {
|
|
|
|
prompter = do_QueryInterface(mContainer);
|
|
|
|
if (prompter) {
|
|
|
|
rv = prompter->Alert(text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
1998-11-03 11:03:22 +03:00
|
|
|
}
|
|
|
|
|
1999-07-01 23:30:20 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::Confirm(const PRUnichar *text,
|
|
|
|
PRBool *result)
|
1998-11-03 11:03:22 +03:00
|
|
|
{
|
1999-09-21 04:04:31 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIPrompt> prompter;
|
|
|
|
|
|
|
|
if (mContainer) {
|
|
|
|
prompter = do_QueryInterface(mContainer);
|
|
|
|
if (prompter) {
|
|
|
|
rv = prompter->Confirm(text, result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
1998-11-03 11:03:22 +03:00
|
|
|
}
|
|
|
|
|
1999-08-06 04:29:10 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::ConfirmYN(const PRUnichar *text,
|
|
|
|
PRBool *result)
|
|
|
|
{
|
1999-09-21 04:04:31 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIPrompt> prompter;
|
|
|
|
|
|
|
|
if (mContainer) {
|
|
|
|
prompter = do_QueryInterface(mContainer);
|
|
|
|
if (prompter) {
|
|
|
|
rv = prompter->ConfirmYN(text, result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
1999-08-06 04:29:10 +04:00
|
|
|
}
|
|
|
|
|
1999-07-01 23:30:20 +04:00
|
|
|
NS_IMETHODIMP
|
1999-09-07 02:59:11 +04:00
|
|
|
nsWebShell::ConfirmCheck(const PRUnichar *text,
|
|
|
|
const PRUnichar *checkMsg,
|
|
|
|
PRBool *checkValue,
|
1999-07-01 23:30:20 +04:00
|
|
|
PRBool *result)
|
|
|
|
{
|
1999-09-21 04:04:31 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIPrompt> prompter;
|
|
|
|
|
|
|
|
if (mContainer) {
|
|
|
|
prompter = do_QueryInterface(mContainer);
|
|
|
|
if (prompter) {
|
|
|
|
rv = prompter->ConfirmCheck(text, checkMsg, checkValue, result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
1999-07-01 23:30:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-09-07 02:59:11 +04:00
|
|
|
nsWebShell::ConfirmCheckYN(const PRUnichar *text,
|
|
|
|
const PRUnichar *checkMsg,
|
|
|
|
PRBool *checkValue,
|
1999-08-06 04:29:10 +04:00
|
|
|
PRBool *result)
|
|
|
|
{
|
1999-09-21 04:04:31 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIPrompt> prompter;
|
|
|
|
|
|
|
|
if (mContainer) {
|
|
|
|
prompter = do_QueryInterface(mContainer);
|
|
|
|
if (prompter) {
|
|
|
|
rv = prompter->ConfirmCheckYN(text, checkMsg, checkValue, result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
1999-08-06 04:29:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-07-01 23:30:20 +04:00
|
|
|
nsWebShell::Prompt(const PRUnichar *text,
|
1999-09-07 02:59:11 +04:00
|
|
|
const PRUnichar *defaultText,
|
1999-07-01 23:30:20 +04:00
|
|
|
PRUnichar **result,
|
|
|
|
PRBool *_retval)
|
1998-11-03 11:03:22 +03:00
|
|
|
{
|
1999-09-21 04:04:31 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIPrompt> prompter;
|
|
|
|
|
|
|
|
if (mContainer) {
|
|
|
|
prompter = do_QueryInterface(mContainer);
|
|
|
|
if (prompter) {
|
|
|
|
rv = prompter->Prompt(text, defaultText, result, _retval);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
1998-11-03 11:03:22 +03:00
|
|
|
}
|
|
|
|
|
1999-07-01 23:30:20 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::PromptUsernameAndPassword(const PRUnichar *text,
|
|
|
|
PRUnichar **user,
|
|
|
|
PRUnichar **pwd,
|
|
|
|
PRBool *_retval)
|
1998-11-03 11:03:22 +03:00
|
|
|
{
|
1999-09-21 04:04:31 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIPrompt> prompter;
|
|
|
|
|
|
|
|
if (mContainer) {
|
|
|
|
prompter = do_QueryInterface(mContainer);
|
|
|
|
if (prompter) {
|
|
|
|
rv = prompter->PromptUsernameAndPassword(text, user, pwd, _retval);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
1998-11-03 11:03:22 +03:00
|
|
|
}
|
|
|
|
|
1999-07-01 23:30:20 +04:00
|
|
|
NS_IMETHODIMP
|
1999-09-07 02:59:11 +04:00
|
|
|
nsWebShell::PromptPassword(const PRUnichar *text,
|
|
|
|
PRUnichar **pwd,
|
1999-07-01 23:30:20 +04:00
|
|
|
PRBool *_retval)
|
1998-11-03 11:03:22 +03:00
|
|
|
{
|
1999-09-21 04:04:31 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIPrompt> prompter;
|
|
|
|
|
|
|
|
if (mContainer) {
|
|
|
|
prompter = do_QueryInterface(mContainer);
|
|
|
|
if (prompter) {
|
|
|
|
rv = prompter->PromptPassword(text, pwd, _retval);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
1998-11-03 11:03:22 +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;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMSelection> selection;
|
|
|
|
rv = presShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
|
|
|
|
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,
|
|
|
|
nsIDOMRange::GetIID(),
|
|
|
|
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-10-13 14:24:12 +04:00
|
|
|
// Methods from nsIProgressEventSink
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::OnProgress(nsIChannel* channel, nsISupports* ctxt,
|
|
|
|
PRUint32 aProgress,
|
|
|
|
PRUint32 aProgressMax)
|
|
|
|
{
|
|
|
|
if (nsnull != mDocLoaderObserver)
|
|
|
|
{
|
|
|
|
return mDocLoaderObserver->OnProgressURLLoad(
|
|
|
|
mDocLoader,
|
|
|
|
channel,
|
|
|
|
aProgress,
|
|
|
|
aProgressMax);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::OnStatus(nsIChannel* channel, nsISupports* ctxt,
|
|
|
|
const PRUnichar* aMsg)
|
|
|
|
{
|
|
|
|
if (nsnull != mDocLoaderObserver)
|
|
|
|
{
|
|
|
|
nsAutoString temp(aMsg);
|
|
|
|
#ifdef DEBUG_gagan
|
|
|
|
|
|
|
|
#ifdef XP_UNIX
|
|
|
|
printf("\033[33m"); // Start yellow
|
|
|
|
#endif
|
|
|
|
|
|
|
|
char* tmp = temp.ToNewCString();
|
|
|
|
printf("%s\n",tmp);
|
|
|
|
CRTFREEIF(tmp);
|
|
|
|
#ifdef XP_UNIX
|
|
|
|
printf("\033[0m"); // End colors
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // DEBUG_gagan
|
|
|
|
nsresult rv = mDocLoaderObserver->OnStatusURLLoad(
|
|
|
|
mDocLoader,
|
|
|
|
channel,
|
|
|
|
temp);
|
|
|
|
|
|
|
|
#ifndef BUG_16273_FIXED
|
|
|
|
//free the message-
|
1999-10-13 16:16:08 +04:00
|
|
|
PRUnichar* tempChar = (PRUnichar*) aMsg;
|
|
|
|
CRTFREEIF(tempChar);
|
1999-10-13 14:24:12 +04:00
|
|
|
#endif
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-10-24 00:47:57 +04:00
|
|
|
|
1999-09-19 04:54:55 +04:00
|
|
|
nsresult nsWebShell::GetViewManager(nsIViewManager* *viewManager)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
*viewManager = nsnull;
|
|
|
|
do {
|
|
|
|
if (nsnull == mContentViewer) break;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocumentViewer> docViewer;
|
|
|
|
rv = mContentViewer->QueryInterface(kIDocumentViewerIID,
|
|
|
|
getter_AddRefs(docViewer));
|
|
|
|
if (NS_FAILED(rv)) break;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPresContext> context;
|
|
|
|
rv = docViewer->GetPresContext(*getter_AddRefs(context));
|
|
|
|
if (NS_FAILED(rv)) break;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
rv = context->GetShell(getter_AddRefs(shell));
|
|
|
|
if (NS_FAILED(rv)) break;
|
|
|
|
|
|
|
|
rv = shell->GetViewManager(viewManager);
|
|
|
|
} while (0);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-11-27 05:14:40 +03:00
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// nsWebShell::nsIBaseWindow
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::InitWindow(nativeWindow parentNativeWindow,
|
|
|
|
nsIWidget* parentWidget, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)
|
|
|
|
{
|
|
|
|
NS_WARN_IF_FALSE(PR_FALSE, "NOT IMPLEMENTED");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::Create()
|
|
|
|
{
|
|
|
|
NS_WARN_IF_FALSE(PR_FALSE, "NOT IMPLEMENTED");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::Destroy()
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
//Fire unload event before we blow anything away.
|
|
|
|
if (nsnull != mScriptGlobal) {
|
|
|
|
nsIDocumentViewer* docViewer;
|
|
|
|
if (nsnull != mContentViewer &&
|
|
|
|
NS_OK == mContentViewer->QueryInterface(kIDocumentViewerIID, (void**)&docViewer)) {
|
|
|
|
nsIPresContext *presContext;
|
|
|
|
if (NS_OK == 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stop any URLs that are currently being loaded...
|
|
|
|
Stop();
|
|
|
|
mDocLoader->Destroy();
|
|
|
|
|
|
|
|
SetContainer(nsnull);
|
|
|
|
SetDocLoaderObserver(nsnull);
|
|
|
|
|
|
|
|
// Remove this webshell from its parent's child list
|
1999-11-30 07:32:09 +03:00
|
|
|
nsCOMPtr<nsIWebShell> webShellParent(do_QueryInterface(mParent));
|
|
|
|
|
|
|
|
if (webShellParent) {
|
|
|
|
webShellParent->RemoveChild(this);
|
1999-11-27 05:14:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nsnull != mDocLoader) {
|
|
|
|
mDocLoader->SetContainer(nsnull);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IF_RELEASE(mContentViewer);
|
|
|
|
|
|
|
|
// Destroy our child web shells and release references to them
|
|
|
|
DestroyChildren();
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::SetPosition(PRInt32 aX, PRInt32 aY)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != mWindow, "null window");
|
|
|
|
|
|
|
|
if(mWindow)
|
|
|
|
mWindow->Move(aX, aY);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::GetPosition(PRInt32* aX, PRInt32* aY)
|
|
|
|
{
|
|
|
|
PRInt32 dummyHolder;
|
|
|
|
|
|
|
|
return GetPositionAndSize(aX, aY, &dummyHolder, &dummyHolder);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::SetSize(PRInt32 aCX, PRInt32 aCY, PRBool aRepaint)
|
|
|
|
{
|
|
|
|
PRInt32 x = 0, y = 0;
|
|
|
|
GetPosition(&x, &y);
|
|
|
|
return SetPositionAndSize(x, y, aCX, aCY, aRepaint);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::GetSize(PRInt32* aCX, PRInt32* aCY)
|
|
|
|
{
|
|
|
|
PRInt32 dummyHolder;
|
|
|
|
|
|
|
|
return GetPositionAndSize(&dummyHolder, &dummyHolder, aCX, aCY);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::SetPositionAndSize(PRInt32 x, PRInt32 y, PRInt32 cx,
|
|
|
|
PRInt32 cy, PRBool fRepaint)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
--dwc0001
|
|
|
|
NS_PRECONDITION(nsnull != mWindow, "null window");
|
|
|
|
*/
|
|
|
|
|
|
|
|
PRInt32 borderWidth = 0;
|
|
|
|
PRInt32 borderHeight = 0;
|
|
|
|
if (nsnull != mWindow) {
|
|
|
|
mWindow->GetBorderSize(borderWidth, borderHeight);
|
|
|
|
// Don't have the widget repaint. Layout will generate repaint requests
|
|
|
|
// during reflow
|
|
|
|
mWindow->Resize(x, y, cx, cy, fRepaint);
|
|
|
|
}
|
|
|
|
|
|
|
|
mBounds.SetRect(x,y,cx,cy); // set the webshells bounds --dwc0001
|
|
|
|
|
|
|
|
// Set the size of the content area, which is the size of the window
|
|
|
|
// minus the borders
|
|
|
|
if (nsnull != mContentViewer) {
|
|
|
|
nsRect rr(0, 0, cx-(borderWidth*2), cy-(borderHeight*2));
|
|
|
|
mContentViewer->SetBounds(rr);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::GetPositionAndSize(PRInt32* aX, PRInt32* aY,
|
|
|
|
PRInt32* aCX, PRInt32* aCY)
|
|
|
|
{
|
|
|
|
nsRect result;
|
|
|
|
|
|
|
|
if(mWindow)
|
|
|
|
mWindow->GetClientBounds(result);
|
|
|
|
else
|
|
|
|
result = mBounds;
|
|
|
|
|
|
|
|
*aX = result.x;
|
|
|
|
*aY = result.y;
|
|
|
|
*aCX = result.width;
|
|
|
|
*aCY = result.height;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::Repaint(PRBool aForce)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
--dwc0001
|
|
|
|
NS_PRECONDITION(nsnull != mWindow, "null window");
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (nsnull != mWindow) {
|
|
|
|
mWindow->Invalidate(aForce);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (nsnull != mWindow) {
|
|
|
|
mWindow->Invalidate(aForce);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
#else
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIViewManager> viewManager;
|
|
|
|
rv = GetViewManager(getter_AddRefs(viewManager));
|
|
|
|
if (NS_SUCCEEDED(rv) && viewManager) {
|
|
|
|
rv = viewManager->UpdateAllViews(0);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::GetParentWidget(nsIWidget** parentWidget)
|
|
|
|
{
|
|
|
|
NS_WARN_IF_FALSE(PR_FALSE, "NOT IMPLEMENTED");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::SetParentWidget(nsIWidget* parentWidget)
|
|
|
|
{
|
|
|
|
NS_WARN_IF_FALSE(PR_FALSE, "NOT IMPLEMENTED");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::GetParentNativeWindow(nativeWindow* parentNativeWindow)
|
|
|
|
{
|
|
|
|
NS_WARN_IF_FALSE(PR_FALSE, "NOT IMPLEMENTED");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::SetParentNativeWindow(nativeWindow parentNativeWindow)
|
|
|
|
{
|
|
|
|
NS_WARN_IF_FALSE(PR_FALSE, "NOT IMPLEMENTED");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::GetVisibility(PRBool* aVisibility)
|
|
|
|
{
|
|
|
|
NS_WARN_IF_FALSE(PR_FALSE, "NOT IMPLEMENTED");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::SetVisibility(PRBool aVisibility)
|
|
|
|
{
|
|
|
|
if(mWindow)
|
|
|
|
mWindow->Show(aVisibility);
|
|
|
|
|
|
|
|
if(aVisibility)
|
|
|
|
{
|
|
|
|
if(mContentViewer)
|
|
|
|
mContentViewer->Show();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(mContentViewer)
|
|
|
|
mContentViewer->Hide();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::GetMainWidget(nsIWidget** mainWidget)
|
|
|
|
{
|
|
|
|
NS_WARN_IF_FALSE(PR_FALSE, "NOT IMPLEMENTED");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::SetFocus()
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
--dwc0001
|
|
|
|
NS_PRECONDITION(nsnull != mWindow, "null window");
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (nsnull != mWindow) {
|
|
|
|
mWindow->SetFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::GetTitle(PRUnichar** aTitle)
|
|
|
|
{
|
|
|
|
*aTitle = mTitle.ToNewUnicode();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::SetTitle(const PRUnichar* aTitle)
|
|
|
|
{
|
|
|
|
// Record local title
|
|
|
|
mTitle = aTitle;
|
|
|
|
|
|
|
|
// Title's set on the top level web-shell are passed ont to the container
|
|
|
|
nsIWebShell* parent;
|
|
|
|
GetParent(parent);
|
|
|
|
if (nsnull == parent) {
|
|
|
|
nsIBrowserWindow *browserWindow = GetBrowserWindow();
|
|
|
|
if (nsnull != browserWindow) {
|
|
|
|
browserWindow->SetTitle(aTitle);
|
|
|
|
NS_RELEASE(browserWindow);
|
|
|
|
|
|
|
|
// Oh this hack sucks. But there isn't any other way that I can
|
|
|
|
// reliably get the title text. Sorry.
|
|
|
|
do {
|
|
|
|
nsresult rv;
|
|
|
|
NS_WITH_SERVICE(nsIGlobalHistory, history, "component://netscape/browser/global-history", &rv);
|
|
|
|
if (NS_FAILED(rv)) break;
|
|
|
|
|
|
|
|
rv = history->SetPageTitle(nsCAutoString(mURL), aTitle);
|
|
|
|
if (NS_FAILED(rv)) break;
|
|
|
|
} while (0);
|
|
|
|
}
|
|
|
|
} else {
|
1999-11-30 07:32:09 +03:00
|
|
|
nsCOMPtr<nsIBaseWindow> parentWin(do_QueryInterface(parent));
|
|
|
|
parentWin->SetTitle(aTitle);
|
1999-11-27 05:14:40 +03:00
|
|
|
NS_RELEASE(parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-30 07:32:09 +03:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsWebShell::nsIDocShell
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::LoadURI(nsIURI* aUri,
|
|
|
|
nsIPresContext* presContext)
|
|
|
|
{
|
|
|
|
//NS_ENSURE_ARG(aUri); // Done in LoadURIVia for us.
|
|
|
|
|
|
|
|
return LoadURIVia(aUri, presContext, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::LoadURIVia(nsIURI* aUri,
|
|
|
|
nsIPresContext* aPresContext, PRUint32 aAdapterBinding)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG(aUri);
|
|
|
|
NS_WARN_IF_FALSE(PR_FALSE, "Not Implemented");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
/* nsCOMPtr<nsIURILoader> uriLoader = do_CreateInstance(NS_URI_LOADER_PROGID);
|
|
|
|
NS_ENSURE_TRUE(uriLoader, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(uriLoader->OpenURI(aUri, nsnull, nsnull, this,
|
|
|
|
nsnull, nsnull, getter_AddRefs(mLoadCookie)), NS_ERROR_FAILURE); */
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::GetDocument(nsIDOMDocument** aDocument)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aDocument);
|
|
|
|
NS_ENSURE_STATE(mContentViewer);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
NS_ENSURE_SUCCESS(GetPresShell(getter_AddRefs(presShell)), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument>doc;
|
|
|
|
NS_ENSURE_SUCCESS(presShell->GetDocument(getter_AddRefs(doc)), NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_TRUE(doc, NS_ERROR_NULL_POINTER);
|
|
|
|
|
|
|
|
// the result's addref comes from this QueryInterface call
|
1999-12-01 02:50:01 +03:00
|
|
|
NS_ENSURE_SUCCESS(CallQueryInterface(doc.get(), aDocument), NS_ERROR_FAILURE);
|
1999-11-30 07:32:09 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::GetCurrentURI(nsIURI** aURI)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aURI);
|
|
|
|
|
|
|
|
NS_WARN_IF_FALSE(PR_FALSE, "Not yet implemented");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
nsIDocumentLoaderFactory::GetIID(),
|
|
|
|
(void**)getter_AddRefs(docFactory)),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDOMDoc);
|
|
|
|
if (!doc) { return NS_ERROR_NULL_POINTER; }
|
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(docFactory->CreateInstanceForDocument(NS_STATIC_CAST(nsIContentViewerContainer*, this),
|
|
|
|
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.)
|
|
|
|
NS_ENSURE_SUCCESS(Embed(documentViewer, "view", nsnull), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
// XXX: It would be great to get rid of this dummy channel!
|
|
|
|
const nsAutoString uriString = "about:blank";
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
NS_ENSURE_SUCCESS(NS_NewURI(getter_AddRefs(uri), uriString), NS_ERROR_FAILURE);
|
|
|
|
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
|
|
|
|
nsIStreamListener* outStreamListener=nsnull; // a valid pointer is required for the returned stream listener
|
|
|
|
NS_ENSURE_SUCCESS(doc->StartDocumentLoad("view", dummyChannel, nsnull, NS_STATIC_CAST(nsIContentViewerContainer*, this),
|
|
|
|
&outStreamListener),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
NS_IF_RELEASE(outStreamListener);
|
|
|
|
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; }
|
|
|
|
NS_ENSURE_SUCCESS(rootContent->SetDocument(doc, PR_FALSE), NS_ERROR_FAILURE);
|
|
|
|
doc->SetRootContent(rootContent);
|
|
|
|
rootContent->SetDocument(doc, PR_TRUE);
|
|
|
|
|
|
|
|
// (6) reflow the document
|
|
|
|
SetScrolling(-1, PR_FALSE);
|
|
|
|
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;
|
|
|
|
GetBounds(r.x, r.y, r.width, r.height);
|
|
|
|
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) {
|
|
|
|
vm->EnableRefresh();
|
|
|
|
}
|
|
|
|
NS_ENSURE_SUCCESS(vm->SetWindowDimensions(NSToCoordRound(r.width * p2t),
|
|
|
|
NSToCoordRound(r.height * p2t)),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// (7) fire end document load notification
|
|
|
|
mProcessedEndDocumentLoad = PR_FALSE;
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
NS_ENSURE_SUCCESS(OnEndDocumentLoad(mDocLoader, dummyChannel, rv, this), NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); // test the resulting out-param separately
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::GetName(PRUnichar** aName)
|
|
|
|
{
|
|
|
|
*aName = mName.ToNewUnicode();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::SetName(const PRUnichar* aName)
|
|
|
|
{
|
|
|
|
mName = aName;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::GetPresContext(nsIPresContext** aPresContext)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPresContext);
|
|
|
|
|
|
|
|
NS_WARN_IF_FALSE(PR_FALSE, "Not yet implemented");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::GetPresShell(nsIPresShell** aPresShell)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPresShell);
|
|
|
|
|
|
|
|
NS_WARN_IF_FALSE(PR_FALSE, "Not yet implemented");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::GetContentViewer(nsIContentViewer** aContentViewer)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aContentViewer);
|
|
|
|
|
|
|
|
*aContentViewer = mContentViewer;
|
|
|
|
NS_IF_ADDREF(*aContentViewer);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::GetParent(nsIDocShell** parent)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(parent);
|
|
|
|
|
|
|
|
*parent = mParent;
|
|
|
|
NS_IF_ADDREF(*parent);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::SetParent(nsIDocShell* aParent)
|
|
|
|
{
|
|
|
|
mParent = aParent;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::GetParentURIContentListener(nsIURIContentListener**
|
|
|
|
aParent)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aParent);
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
if (mParentContentListener)
|
|
|
|
{
|
|
|
|
*aParent = mParentContentListener;
|
|
|
|
NS_ADDREF(*aParent);
|
|
|
|
}
|
1999-12-01 03:16:25 +03:00
|
|
|
else
|
|
|
|
rv = NS_ERROR_NULL_POINTER;
|
1999-11-30 07:32:09 +03:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::SetParentURIContentListener(nsIURIContentListener*
|
|
|
|
aParent)
|
|
|
|
{
|
|
|
|
mParentContentListener = aParent;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::GetPrefs(nsIPref** aPrefs)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPrefs);
|
|
|
|
|
|
|
|
*aPrefs = mPrefs;
|
|
|
|
NS_IF_ADDREF(*aPrefs);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::SetPrefs(nsIPref* aPrefs)
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mPrefs);
|
|
|
|
mPrefs = aPrefs;
|
|
|
|
NS_IF_ADDREF(mPrefs);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::GetRootDocShell(nsIDocShell** aRootDocShell)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aRootDocShell);
|
|
|
|
*aRootDocShell = NS_STATIC_CAST(nsIDocShell*, this);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShell> parent;
|
|
|
|
NS_ENSURE_TRUE(GetParent(getter_AddRefs(parent)), NS_ERROR_FAILURE);
|
|
|
|
while (parent)
|
|
|
|
{
|
|
|
|
*aRootDocShell = parent;
|
|
|
|
NS_ENSURE_TRUE(GetParent(getter_AddRefs(parent)), NS_ERROR_FAILURE);
|
|
|
|
}
|
|
|
|
NS_IF_ADDREF(*aRootDocShell);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::GetZoom(float* aZoom)
|
|
|
|
{
|
|
|
|
*aZoom = mZoom;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWebShell::SetZoom(float aZoom)
|
|
|
|
{
|
|
|
|
mZoom = aZoom;
|
|
|
|
|
|
|
|
if (mDeviceContext)
|
|
|
|
mDeviceContext->SetZoom(mZoom);
|
|
|
|
|
|
|
|
if (mContentViewer) {
|
|
|
|
nsIDocumentViewer* docv = nsnull;
|
|
|
|
mContentViewer->QueryInterface(kIDocumentViewerIID, (void**) &docv);
|
|
|
|
if (nsnull != docv) {
|
|
|
|
nsIPresContext* cx = nsnull;
|
|
|
|
docv->GetPresContext(cx);
|
|
|
|
if (nsnull != cx) {
|
|
|
|
nsIPresShell *shell = nsnull;
|
|
|
|
cx->GetShell(&shell);
|
|
|
|
if (nsnull != shell) {
|
|
|
|
nsIViewManager *vm = nsnull;
|
|
|
|
shell->GetViewManager(&vm);
|
|
|
|
if (nsnull != vm) {
|
|
|
|
nsIView *rootview = nsnull;
|
|
|
|
nsIScrollableView *sv = nsnull;
|
|
|
|
vm->GetRootScrollableView(&sv);
|
|
|
|
if (nsnull != sv)
|
|
|
|
sv->ComputeScrollOffsets();
|
|
|
|
vm->GetRootView(rootview);
|
|
|
|
if (nsnull != rootview)
|
|
|
|
vm->UpdateView(rootview, 0);
|
|
|
|
NS_RELEASE(vm);
|
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
NS_RELEASE(cx);
|
|
|
|
}
|
|
|
|
NS_RELEASE(docv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetDocLoaderObserver(nsIDocumentLoaderObserver * *aDocLoaderObserver)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aDocLoaderObserver);
|
|
|
|
|
|
|
|
*aDocLoaderObserver = mDocLoaderObserver;
|
|
|
|
NS_IF_ADDREF(mDocLoaderObserver);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetDocLoaderObserver(nsIDocumentLoaderObserver * aDocLoaderObserver)
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mDocLoaderObserver);
|
|
|
|
|
|
|
|
mDocLoaderObserver = aDocLoaderObserver;
|
|
|
|
NS_IF_ADDREF(mDocLoaderObserver);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetMarginWidth(PRInt32* aWidth)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aWidth);
|
|
|
|
|
|
|
|
*aWidth = mMarginWidth;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetMarginWidth(PRInt32 aWidth)
|
|
|
|
{
|
|
|
|
mMarginWidth = aWidth;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetMarginHeight(PRInt32* aHeight)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aHeight);
|
|
|
|
|
|
|
|
*aHeight = mMarginHeight;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetMarginHeight(PRInt32 aHeight)
|
|
|
|
{
|
|
|
|
mMarginHeight = aHeight;
|
|
|
|
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
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
// 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:
|
1998-08-21 02:28:52 +04:00
|
|
|
// XXX TEMPORARY placeholder for starting up some
|
|
|
|
// services in lieu of a service manager.
|
|
|
|
static void StartServices();
|
|
|
|
|
|
|
|
static PRBool mStartedServices;
|
1998-07-19 01:43:02 +04:00
|
|
|
nsrefcnt mRefCnt;
|
1998-07-19 05:18:40 +04:00
|
|
|
};
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1998-08-21 02:28:52 +04:00
|
|
|
PRBool nsWebShellFactory::mStartedServices = PR_FALSE;
|
|
|
|
|
|
|
|
void
|
|
|
|
nsWebShellFactory::StartServices()
|
|
|
|
{
|
|
|
|
mStartedServices = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
1998-07-19 05:18:40 +04:00
|
|
|
nsWebShellFactory::nsWebShellFactory()
|
|
|
|
{
|
1998-08-21 02:28:52 +04:00
|
|
|
if (!mStartedServices) {
|
|
|
|
StartServices();
|
|
|
|
}
|
1998-07-19 01:43:02 +04:00
|
|
|
mRefCnt = 0;
|
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;
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
if (aResult == NULL) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
*aResult = NULL;
|
1998-07-19 05:18:40 +04:00
|
|
|
if (nsnull != aOuter) {
|
|
|
|
rv = NS_ERROR_NO_AGGREGATION;
|
|
|
|
goto done;
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
1998-09-18 01:27:22 +04:00
|
|
|
NS_NEWXPCOM(inst, nsWebShell);
|
1998-07-19 01:43:02 +04:00
|
|
|
if (inst == NULL) {
|
1998-07-19 05:18:40 +04:00
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
goto done;
|
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
|
|
|
done:
|
|
|
|
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;
|
|
|
|
}
|