1998-07-19 01:43:02 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS"
|
|
|
|
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
|
|
|
* the License for the specific language governing rights and limitations
|
|
|
|
* under the License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape Communications
|
|
|
|
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
|
|
|
* Netscape Communications Corporation. All Rights Reserved.
|
|
|
|
*/
|
|
|
|
#include "nsIWebShell.h"
|
|
|
|
#include "nsIDocumentLoader.h"
|
|
|
|
#include "nsIContentViewer.h"
|
1998-08-12 08:56:40 +04:00
|
|
|
#include "nsIDocumentViewer.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"
|
1998-11-03 11:03:22 +03:00
|
|
|
#include "nsINetSupport.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"
|
|
|
|
#include "nsDOMEvent.h"
|
|
|
|
#include "nsIPresContext.h"
|
1999-03-09 12:44:27 +03:00
|
|
|
#include "nsIComponentManager.h"
|
1999-01-05 12:46:33 +03:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIEventQueueService.h"
|
1998-07-19 01:43:02 +04:00
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "nsVoidArray.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsWidgetsCID.h"
|
|
|
|
#include "nsGfxCIID.h"
|
|
|
|
#include "plevent.h"
|
1998-08-15 03:08:54 +04:00
|
|
|
#include "prprf.h"
|
1998-07-28 03:08:52 +04:00
|
|
|
#include "nsIPluginHost.h"
|
1998-08-02 02:19:05 +04:00
|
|
|
#include "nsplugin.h"
|
1999-02-04 03:03:18 +03:00
|
|
|
//#include "nsPluginsCID.h"
|
|
|
|
#include "nsIPluginManager.h"
|
1998-07-31 10:02:06 +04:00
|
|
|
#include "nsIPref.h"
|
1998-08-19 03:25:17 +04:00
|
|
|
#include "nsIRefreshUrl.h"
|
|
|
|
#include "nsITimer.h"
|
1998-09-26 02:25:21 +04:00
|
|
|
#include "nsITimerCallback.h"
|
1998-08-21 02:28:52 +04:00
|
|
|
#include "jsurl.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-04-07 01:01:04 +04:00
|
|
|
#include "nsIStreamObserver.h"
|
1999-05-06 05:58:48 +04:00
|
|
|
#include "nsIWebShellServices.h"
|
1999-05-18 09:21:37 +04:00
|
|
|
#include "nsIGlobalHistory.h"
|
1998-07-27 22:17:07 +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
|
|
|
|
1998-08-20 10:17:47 +04:00
|
|
|
//XXX used for nsIStreamObserver implementation. This sould be replaced by DocLoader
|
|
|
|
// notifications...
|
|
|
|
#include "nsIURL.h"
|
|
|
|
|
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
|
|
|
|
#else
|
|
|
|
#undef NOISY_LINKS
|
|
|
|
#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
|
|
|
|
|
|
|
|
#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.
|
|
|
|
* It is still lurking around for Motif
|
|
|
|
*/
|
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);
|
|
|
|
|
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,
|
1998-08-20 10:17:47 +04:00
|
|
|
public nsIRefreshUrl,
|
1998-11-03 11:03:22 +03:00
|
|
|
public nsINetSupport,
|
1999-04-07 01:01:04 +04:00
|
|
|
// public nsIStreamObserver,
|
1998-11-04 11:48:22 +03:00
|
|
|
public nsIClipboardCommands
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsWebShell();
|
|
|
|
virtual ~nsWebShell();
|
|
|
|
|
1999-02-26 23:02:06 +03:00
|
|
|
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
1998-07-19 01:43:02 +04:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
// nsIContentViewerContainer
|
|
|
|
NS_IMETHOD QueryCapability(const nsIID &aIID, void** aResult);
|
|
|
|
NS_IMETHOD Embed(nsIContentViewer* aDocViewer,
|
|
|
|
const char* aCommand,
|
|
|
|
nsISupports* aExtraInfo);
|
1999-01-14 09:44:23 +03:00
|
|
|
NS_IMETHOD GetContentViewer(nsIContentViewer** aResult);
|
1998-07-19 01:43:02 +04:00
|
|
|
|
|
|
|
// 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-07-29 14:49:01 +04:00
|
|
|
NS_IMETHOD Destroy(void);
|
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);
|
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 SetFocus();
|
|
|
|
NS_IMETHOD RemoveFocus();
|
1998-08-15 03:08:54 +04:00
|
|
|
NS_IMETHOD Repaint(PRBool aForce);
|
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-04-16 12:15:04 +04:00
|
|
|
NS_IMETHOD SetObserver(nsIStreamObserver* anObserver);
|
1998-07-22 15:24:50 +04:00
|
|
|
NS_IMETHOD GetObserver(nsIStreamObserver*& aResult);
|
1999-04-07 01:01:04 +04:00
|
|
|
NS_IMETHOD SetDocLoaderObserver(nsIDocumentLoaderObserver* anObserver);
|
|
|
|
NS_IMETHOD GetDocLoaderObserver(nsIDocumentLoaderObserver*& aResult);
|
1998-07-31 10:02:06 +04:00
|
|
|
NS_IMETHOD SetPrefs(nsIPref* aPrefs);
|
|
|
|
NS_IMETHOD GetPrefs(nsIPref*& aPrefs);
|
1998-07-19 05:18:40 +04:00
|
|
|
NS_IMETHOD GetRootWebShell(nsIWebShell*& aResult);
|
1999-04-16 12:15:04 +04:00
|
|
|
NS_IMETHOD GetRootWebShellEvenIfChrome(nsIWebShell*& aResult);
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IMETHOD SetParent(nsIWebShell* aParent);
|
|
|
|
NS_IMETHOD GetParent(nsIWebShell*& aParent);
|
1999-04-16 12:15:04 +04:00
|
|
|
NS_IMETHOD GetParentEvenIfChrome(nsIWebShell*& aParent);
|
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 SetName(const PRUnichar* aName);
|
|
|
|
NS_IMETHOD FindChildWithName(const PRUnichar* aName,
|
1998-07-19 01:43:02 +04:00
|
|
|
nsIWebShell*& aResult);
|
1999-04-16 12:15:04 +04:00
|
|
|
|
|
|
|
NS_IMETHOD SetWebShellType(nsWebShellType aWebShellType);
|
1999-05-28 01:05:27 +04:00
|
|
|
NS_IMETHOD GetWebShellType(nsWebShellType& aWebShellType);
|
|
|
|
NS_IMETHOD GetContainingChromeShell(nsIWebShell** aResult);
|
|
|
|
NS_IMETHOD SetContainingChromeShell(nsIWebShell* aChromeShell);
|
1999-04-16 12:15:04 +04:00
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
NS_IMETHOD GetMarginWidth (PRInt32& aWidth);
|
|
|
|
NS_IMETHOD SetMarginWidth (PRInt32 aWidth);
|
|
|
|
NS_IMETHOD GetMarginHeight(PRInt32& aWidth);
|
|
|
|
NS_IMETHOD SetMarginHeight(PRInt32 aHeight);
|
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-01-20 02:14:31 +03:00
|
|
|
NS_IMETHOD GetIsFrame(PRBool& aIsFrame);
|
|
|
|
NS_IMETHOD SetIsFrame(PRBool aIsFrame);
|
1999-04-16 08:25:17 +04:00
|
|
|
NS_IMETHOD SetZoom(float aZoom);
|
|
|
|
NS_IMETHOD GetZoom(float *aZoom);
|
1998-08-15 03:08:54 +04:00
|
|
|
|
|
|
|
// Document load api's
|
|
|
|
NS_IMETHOD GetDocumentLoader(nsIDocumentLoader*& aResult);
|
|
|
|
NS_IMETHOD LoadURL(const PRUnichar *aURLSpec,
|
1998-08-13 08:36:42 +04:00
|
|
|
nsIPostData* aPostData=nsnull,
|
1998-08-20 03:01:52 +04:00
|
|
|
PRBool aModifyHistory=PR_TRUE,
|
1998-10-10 08:33:29 +04:00
|
|
|
nsURLReloadType aType = nsURLReload,
|
1998-09-16 04:40:20 +04:00
|
|
|
const PRUint32 localIP = 0);
|
1998-11-11 23:31:45 +03:00
|
|
|
NS_IMETHOD LoadURL(const PRUnichar *aURLSpec,
|
|
|
|
const char* aCommand,
|
|
|
|
nsIPostData* aPostData=nsnull,
|
|
|
|
PRBool aModifyHistory=PR_TRUE,
|
|
|
|
nsURLReloadType aType = nsURLReload,
|
|
|
|
const PRUint32 localIP = 0);
|
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
NS_IMETHOD Stop(void);
|
1998-10-10 08:33:29 +04:00
|
|
|
NS_IMETHOD Reload(nsURLReloadType aType);
|
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
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
// Chrome api's
|
|
|
|
NS_IMETHOD SetTitle(const PRUnichar* aTitle);
|
1999-02-14 09:35:01 +03:00
|
|
|
NS_IMETHOD GetTitle(const PRUnichar** aResult);
|
1998-08-10 05:01:27 +04:00
|
|
|
|
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);
|
|
|
|
NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 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-05-15 02:40:03 +04:00
|
|
|
NS_IMETHOD CreatePopup(nsIDOMElement* aElement, nsIDOMElement* aPopupContent,
|
|
|
|
PRInt32 aXPos, PRInt32 aYPos,
|
1999-06-09 12:36:06 +04:00
|
|
|
const nsString& aPopupType, const nsString& anAnchorAlignment,
|
|
|
|
const nsString& aPopupAlignment,
|
1999-05-16 11:52:02 +04:00
|
|
|
nsIDOMWindow* aWindow);
|
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);
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1999-05-06 05:58:48 +04:00
|
|
|
// nsIWebShellServices
|
1999-05-06 07:54:40 +04:00
|
|
|
NS_IMETHOD LoadDocument(const char* aURL,
|
1999-05-19 04:23:03 +04:00
|
|
|
const char* aCharset= nsnull ,
|
|
|
|
nsCharsetSource aSource = kCharsetUninitialized);
|
|
|
|
NS_IMETHOD ReloadDocument(const char* aCharset= nsnull ,
|
|
|
|
nsCharsetSource aSource = kCharsetUninitialized);
|
1999-05-06 05:58:48 +04:00
|
|
|
NS_IMETHOD StopDocumentLoad(void);
|
|
|
|
NS_IMETHOD SetRendering(PRBool aRender);
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
// nsILinkHandler
|
1998-11-14 03:21:19 +03:00
|
|
|
NS_IMETHOD OnLinkClick(nsIContent* aContent,
|
|
|
|
nsLinkVerb aVerb,
|
1998-08-15 03:08:54 +04:00
|
|
|
const PRUnichar* aURLSpec,
|
|
|
|
const PRUnichar* aTargetSpec,
|
1998-07-19 01:43:02 +04:00
|
|
|
nsIPostData* aPostData = 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
|
|
|
|
NS_IMETHOD GetScriptContext(nsIScriptContext **aContext);
|
1998-07-24 09:07:51 +04:00
|
|
|
NS_IMETHOD GetScriptGlobalObject(nsIScriptGlobalObject **aGlobal);
|
1998-07-21 08:46:55 +04:00
|
|
|
NS_IMETHOD ReleaseScriptContext(nsIScriptContext *aContext);
|
|
|
|
|
1998-08-12 08:56:40 +04:00
|
|
|
// nsIDocumentLoaderObserver
|
1999-04-28 10:47:40 +04:00
|
|
|
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader,
|
|
|
|
nsIURL* aURL,
|
|
|
|
const char* aCommand);
|
|
|
|
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader,
|
|
|
|
nsIURL* aURL,
|
|
|
|
PRInt32 aStatus);
|
|
|
|
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader,
|
|
|
|
nsIURL* aURL, const char* aContentType,
|
1999-01-14 09:44:23 +03:00
|
|
|
nsIContentViewer* aViewer);
|
1999-04-28 10:47:40 +04:00
|
|
|
NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader,
|
|
|
|
nsIURL* aURL, PRUint32 aProgress,
|
1999-03-29 13:21:01 +04:00
|
|
|
PRUint32 aProgressMax);
|
1999-04-28 10:47:40 +04:00
|
|
|
NS_IMETHOD OnStatusURLLoad(nsIDocumentLoader* loader,
|
|
|
|
nsIURL* aURL, nsString& aMsg);
|
|
|
|
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader,
|
|
|
|
nsIURL* aURL, PRInt32 aStatus);
|
|
|
|
NS_IMETHOD HandleUnknownContentType(nsIDocumentLoader* loader,
|
|
|
|
nsIURL* aURL,
|
|
|
|
const char *aContentType,
|
|
|
|
const char *aCommand );
|
1999-04-07 01:01:04 +04:00
|
|
|
// NS_IMETHOD OnConnectionsComplete();
|
1998-08-12 08:56:40 +04:00
|
|
|
|
1998-08-19 03:25:17 +04:00
|
|
|
// nsIRefreshURL interface methods...
|
|
|
|
NS_IMETHOD RefreshURL(nsIURL* aURL, PRInt32 millis, PRBool repeat);
|
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
|
|
|
NS_IMETHOD CancelRefreshURLTimers(void);
|
|
|
|
|
1999-04-07 01:01:04 +04:00
|
|
|
|
|
|
|
#if 0
|
1998-08-20 10:17:47 +04:00
|
|
|
// nsIStreamObserver
|
|
|
|
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType);
|
1998-12-16 08:40:20 +03:00
|
|
|
NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax);
|
|
|
|
NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg);
|
|
|
|
NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg);
|
1999-04-07 01:01:04 +04:00
|
|
|
#endif /* 0 */
|
|
|
|
|
1998-08-19 03:25:17 +04:00
|
|
|
|
1998-11-03 11:03:22 +03:00
|
|
|
// nsINetSupport interface methods
|
|
|
|
NS_IMETHOD_(void) Alert(const nsString &aText);
|
|
|
|
NS_IMETHOD_(PRBool) Confirm(const nsString &aText);
|
|
|
|
NS_IMETHOD_(PRBool) Prompt(const nsString &aText,
|
|
|
|
const nsString &aDefault,
|
|
|
|
nsString &aResult);
|
|
|
|
NS_IMETHOD_(PRBool) PromptUserAndPassword(const nsString &aText,
|
|
|
|
nsString &aUser,
|
|
|
|
nsString &aPassword);
|
|
|
|
NS_IMETHOD_(PRBool) PromptPassword(const nsString &aText,
|
|
|
|
nsString &aPassword);
|
|
|
|
|
1998-11-04 11:48:22 +03:00
|
|
|
// nsIClipboardCommands
|
|
|
|
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);
|
|
|
|
|
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,
|
1998-07-19 01:43:02 +04:00
|
|
|
nsIPostData* aPostDat = 0);
|
|
|
|
|
|
|
|
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-03-23 01:21:22 +03:00
|
|
|
NS_IMETHOD GetDefaultCharacterSet (const PRUnichar** aDefaultCharacterSet);
|
|
|
|
NS_IMETHOD SetDefaultCharacterSet (const PRUnichar* aDefaultCharacterSet);
|
|
|
|
|
1999-05-28 05:31:55 +04:00
|
|
|
NS_IMETHOD GetForceCharacterSet (const PRUnichar** aForceCharacterSet);
|
|
|
|
NS_IMETHOD SetForceCharacterSet (const PRUnichar* aForceCharacterSet);
|
|
|
|
|
1999-05-19 04:23:03 +04:00
|
|
|
NS_IMETHOD GetCharacterSetHint (const PRUnichar** oHintCharset, nsCharsetSource* oSource);
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
protected:
|
1999-04-10 01:09:00 +04:00
|
|
|
void InitFrameData(PRBool aCompleteInitScrolling);
|
1999-03-18 04:07:22 +03:00
|
|
|
nsresult CheckForTrailingSlash(nsIURL* aURL);
|
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;
|
|
|
|
|
1999-04-07 01:01:04 +04:00
|
|
|
nsIStreamObserver * mObserver;
|
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-11-03 11:03:22 +03:00
|
|
|
nsINetSupport* mNetSupport;
|
1998-07-19 01:43:02 +04:00
|
|
|
|
|
|
|
nsIWebShell* mParent;
|
|
|
|
nsVoidArray mChildren;
|
|
|
|
nsString mName;
|
1999-03-23 01:21:22 +03:00
|
|
|
nsString mDefaultCharacterSet;
|
1998-07-19 01:43:02 +04:00
|
|
|
|
|
|
|
nsVoidArray mHistory;
|
|
|
|
PRInt32 mHistoryIndex;
|
1999-06-08 01:26:10 +04:00
|
|
|
nsIGlobalHistory* mHistoryService;
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1998-07-19 05:18:40 +04:00
|
|
|
nsString mTitle;
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
nsString mOverURL;
|
|
|
|
nsString mOverTarget;
|
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
nsScrollPreference mScrollPref;
|
1998-08-10 05:01:27 +04:00
|
|
|
PRInt32 mMarginWidth;
|
|
|
|
PRInt32 mMarginHeight;
|
1999-04-10 01:09:00 +04:00
|
|
|
PRInt32 mScrolling[2];
|
1999-01-20 02:14:31 +03:00
|
|
|
PRBool mIsFrame;
|
1998-08-19 03:25:17 +04:00
|
|
|
nsVoidArray mRefreshments;
|
1998-07-27 09:59:37 +04:00
|
|
|
|
1999-04-16 12:15:04 +04:00
|
|
|
nsWebShellType mWebShellType;
|
1999-05-28 01:05:27 +04:00
|
|
|
nsIWebShell* mChromeShell; // Weak reference.
|
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-02-12 20:32:17 +03:00
|
|
|
nsresult DoLoadURL(const nsString& aUrlSpec,
|
|
|
|
const char* aCommand,
|
|
|
|
nsIPostData* aPostData,
|
|
|
|
nsURLReloadType aType,
|
|
|
|
const PRUint32 aLocalIP);
|
1998-07-28 03:08:52 +04:00
|
|
|
|
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-05-19 04:23:03 +04:00
|
|
|
|
|
|
|
// XXX store mHintCharset and mHintCharsetSource here untill we find out a good cood path
|
|
|
|
nsString mHintCharset;
|
|
|
|
nsCharsetSource mHintCharsetSource;
|
1999-05-28 05:31:55 +04:00
|
|
|
nsString mForceCharacterSet;
|
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
|
|
|
|
1999-04-07 01:01:04 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
// IID's
|
|
|
|
static NS_DEFINE_IID(kIContentViewerContainerIID,
|
|
|
|
NS_ICONTENT_VIEWER_CONTAINER_IID);
|
1998-09-26 02:25:21 +04:00
|
|
|
static NS_DEFINE_IID(kIDocumentLoaderObserverIID,
|
|
|
|
NS_IDOCUMENT_LOADER_OBSERVER_IID);
|
|
|
|
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);
|
1998-09-26 02:25:21 +04:00
|
|
|
static NS_DEFINE_IID(kIStreamObserverIID, NS_ISTREAMOBSERVER_IID);
|
1999-05-07 23:25:58 +04:00
|
|
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
1998-11-03 11:03:22 +03:00
|
|
|
static NS_DEFINE_IID(kINetSupportIID, NS_INETSUPPORT_IID);
|
1998-09-26 02:25:21 +04:00
|
|
|
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
|
1999-05-06 05:58:48 +04:00
|
|
|
static NS_DEFINE_IID(kIWebShellServicesIID, NS_IWEB_SHELL_SERVICES_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(kCPluginHostCID, NS_PLUGIN_HOST_CID);
|
|
|
|
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(kRefreshURLIID, NS_IREFRESHURL_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);
|
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,
|
|
|
|
(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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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()
|
|
|
|
{
|
|
|
|
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-05-05 03:34:10 +04:00
|
|
|
mThreadEventQueue = nsnull;
|
1999-04-10 01:09:00 +04:00
|
|
|
InitFrameData(PR_TRUE);
|
1999-01-20 02:14:31 +03:00
|
|
|
mIsFrame = PR_FALSE;
|
1999-04-16 12:15:04 +04:00
|
|
|
mWebShellType = nsWebShellContent;
|
1999-05-28 01:05:27 +04:00
|
|
|
mChromeShell = nsnull;
|
|
|
|
|
1999-04-26 22:05:18 +04:00
|
|
|
// XXX we should get such mDefaultCharacterSet from pref laster...
|
|
|
|
mDefaultCharacterSet = "ISO-8859-1";
|
1999-05-04 03:04:50 +04:00
|
|
|
mProcessedEndDocumentLoad = PR_FALSE;
|
1999-05-19 04:23:03 +04:00
|
|
|
mHintCharset = "";
|
|
|
|
mHintCharsetSource = kCharsetUninitialized;
|
1999-05-28 05:31:55 +04:00
|
|
|
mForceCharacterSet = "";
|
1999-06-08 01:26:10 +04:00
|
|
|
mHistoryService = 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.
|
|
|
|
CancelRefreshURLTimers();
|
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
|
|
|
|
|
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-07-22 15:24:50 +04:00
|
|
|
NS_IF_RELEASE(mObserver);
|
1998-11-03 11:03:22 +03:00
|
|
|
NS_IF_RELEASE(mNetSupport);
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1998-08-07 08:45:03 +04:00
|
|
|
if (nsnull != mScriptGlobal) {
|
|
|
|
mScriptGlobal->SetWebShell(nsnull);
|
|
|
|
NS_RELEASE(mScriptGlobal);
|
|
|
|
}
|
1998-07-25 05:53:54 +04:00
|
|
|
NS_IF_RELEASE(mScriptContext);
|
|
|
|
|
1999-04-10 01:09:00 +04:00
|
|
|
InitFrameData(PR_TRUE);
|
1999-01-20 02:14:31 +03:00
|
|
|
mIsFrame = PR_FALSE;
|
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
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
DestroyPluginHost();
|
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-05-10 06:34:17 +04:00
|
|
|
mMarginWidth = -1;
|
|
|
|
mMarginHeight = -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++) {
|
|
|
|
nsIWebShell* shell = (nsIWebShell*) mChildren.ElementAt(i);
|
|
|
|
shell->SetParent(nsnull);
|
1998-08-09 11:43:22 +04:00
|
|
|
|
|
|
|
//Break circular reference of webshell to contentviewer
|
|
|
|
shell->SetContentViewer(nsnull);
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
mChildren.Clear();
|
|
|
|
}
|
|
|
|
|
1998-11-22 06:11:26 +03:00
|
|
|
void
|
|
|
|
nsWebShell::DestroyChildren()
|
|
|
|
{
|
|
|
|
PRInt32 i, n = mChildren.Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
nsIWebShell* shell = (nsIWebShell*) mChildren.ElementAt(i);
|
|
|
|
shell->SetParent(nsnull);
|
|
|
|
shell->Destroy();
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
mChildren.Clear();
|
|
|
|
}
|
|
|
|
|
1998-09-19 11:06:07 +04:00
|
|
|
NS_IMPL_THREADSAFE_ADDREF(nsWebShell)
|
|
|
|
NS_IMPL_THREADSAFE_RELEASE(nsWebShell)
|
1998-07-19 01:43:02 +04:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsWebShell::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|
|
|
{
|
1998-09-19 11:06:07 +04:00
|
|
|
nsresult rv = NS_NOINTERFACE;
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-05-06 05:58:48 +04:00
|
|
|
if (aIID.Equals(kIWebShellServicesIID)) {
|
|
|
|
*aInstancePtr = (void*)(nsIWebShellServices*)this;
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-07-19 01:43:02 +04:00
|
|
|
if (aIID.Equals(kIWebShellIID)) {
|
|
|
|
*aInstancePtr = (void*)(nsIWebShell*)this;
|
1998-09-18 01:27:22 +04:00
|
|
|
NS_ADDREF_THIS();
|
1998-07-19 01:43:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
if (aIID.Equals(kIContentViewerContainerIID)) {
|
|
|
|
*aInstancePtr = (void*)(nsIContentViewerContainer*)this;
|
1998-09-18 01:27:22 +04:00
|
|
|
NS_ADDREF_THIS();
|
1998-07-19 01:43:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-07-21 08:46:55 +04:00
|
|
|
if (aIID.Equals(kIScriptContextOwnerIID)) {
|
|
|
|
*aInstancePtr = (void*)(nsIScriptContextOwner*)this;
|
1998-09-18 01:27:22 +04:00
|
|
|
NS_ADDREF_THIS();
|
1998-07-21 08:46:55 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-08-12 08:56:40 +04:00
|
|
|
if (aIID.Equals(kIDocumentLoaderObserverIID)) {
|
|
|
|
*aInstancePtr = (void*)(nsIDocumentLoaderObserver*)this;
|
1998-09-18 01:27:22 +04:00
|
|
|
NS_ADDREF_THIS();
|
1998-08-12 08:56:40 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-08-20 10:17:47 +04:00
|
|
|
if (aIID.Equals(kIWebShellContainerIID)) {
|
|
|
|
*aInstancePtr = (void*)(nsIWebShellContainer*)this;
|
1998-09-18 01:27:22 +04:00
|
|
|
NS_ADDREF_THIS();
|
1998-08-20 10:17:47 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-08-20 01:00:51 +04:00
|
|
|
if (aIID.Equals(kILinkHandlerIID)) {
|
|
|
|
//I added this for plugin support of jumping
|
|
|
|
//through links. maybe there is a better way... MMP
|
|
|
|
*aInstancePtr = (void*)(nsILinkHandler*)this;
|
1998-09-18 01:27:22 +04:00
|
|
|
NS_ADDREF_THIS();
|
1998-07-19 01:43:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-08-19 03:25:17 +04:00
|
|
|
if (aIID.Equals(kRefreshURLIID)) {
|
|
|
|
*aInstancePtr = (void*)(nsIRefreshUrl*)this;
|
1998-09-18 01:27:22 +04:00
|
|
|
NS_ADDREF_THIS();
|
1998-08-19 03:25:17 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-11-03 11:03:22 +03:00
|
|
|
if (aIID.Equals(kINetSupportIID)) {
|
|
|
|
*aInstancePtr = (void*) ((nsINetSupport*)this);
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-11-04 11:48:22 +03:00
|
|
|
if (aIID.Equals(kIClipboardCommandsIID)) {
|
|
|
|
*aInstancePtr = (void*) ((nsIClipboardCommands*)this);
|
|
|
|
NS_ADDREF_THIS();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-08-20 01:00:51 +04:00
|
|
|
if (aIID.Equals(kISupportsIID)) {
|
|
|
|
*aInstancePtr = (void*)(nsISupports*)(nsIWebShell*)this;
|
1998-09-18 01:27:22 +04:00
|
|
|
NS_ADDREF_THIS();
|
1998-08-20 01:00:51 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-09-19 11:06:07 +04:00
|
|
|
|
|
|
|
#if defined(NS_DEBUG)
|
|
|
|
/*
|
|
|
|
* Check for the debug-only interface indicating thread-safety
|
|
|
|
*/
|
|
|
|
static NS_DEFINE_IID(kIsThreadsafeIID, NS_ISTHREADSAFE_IID);
|
|
|
|
if (aIID.Equals(kIsThreadsafeIID)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif /* NS_DEBUG */
|
|
|
|
|
|
|
|
return rv;
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::QueryCapability(const nsIID &aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
if (nsnull == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aIID.Equals(kILinkHandlerIID)) {
|
|
|
|
*aInstancePtr = (void*) ((nsILinkHandler*)this);
|
1998-09-18 01:27:22 +04:00
|
|
|
NS_ADDREF_THIS();
|
1998-07-19 01:43:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-07-21 08:46:55 +04:00
|
|
|
if (aIID.Equals(kIScriptContextOwnerIID)) {
|
|
|
|
*aInstancePtr = (void*) ((nsIScriptContextOwner*)this);
|
1998-09-18 01:27:22 +04:00
|
|
|
NS_ADDREF_THIS();
|
1998-07-21 08:46:55 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-07-28 03:08:52 +04:00
|
|
|
|
|
|
|
//XXX this seems a little wrong. MMP
|
|
|
|
if (nsnull != mPluginManager)
|
|
|
|
return mPluginManager->QueryInterface(aIID, aInstancePtr);
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::Embed(nsIContentViewer* aContentViewer,
|
|
|
|
const char* aCommand,
|
|
|
|
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));
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
1998-11-05 00:41:26 +03:00
|
|
|
mWindow->GetClientBounds(bounds);
|
1998-07-19 01:43:02 +04:00
|
|
|
bounds.x = bounds.y = 0;
|
|
|
|
rv = mContentViewer->Init(mWindow->GetNativeData(NS_NATIVE_WIDGET),
|
|
|
|
mDeviceContext,
|
1998-07-31 10:02:06 +04:00
|
|
|
mPrefs,
|
1998-07-27 09:59:37 +04:00
|
|
|
bounds,
|
|
|
|
mScrollPref);
|
1999-01-08 03:32:55 +03:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
1998-07-19 01:43:02 +04:00
|
|
|
mContentViewer->Show();
|
|
|
|
}
|
|
|
|
|
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-01-14 09:44:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetContentViewer(nsIContentViewer** aResult)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
rv = NS_ERROR_NULL_POINTER;
|
|
|
|
} else {
|
|
|
|
*aResult = mContentViewer;
|
|
|
|
NS_IF_ADDREF(mContentViewer);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-04-08 08:21:15 +04:00
|
|
|
NS_IMETHODIMP
|
1999-04-28 10:47:40 +04:00
|
|
|
nsWebShell::HandleUnknownContentType(nsIDocumentLoader* loader,
|
|
|
|
nsIURL* aURL,
|
|
|
|
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-04-28 10:47:40 +04:00
|
|
|
return mDocLoaderObserver ? mDocLoaderObserver->HandleUnknownContentType( mDocLoader, aURL, 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
|
|
|
|
// will be associated with the current thread...
|
|
|
|
//
|
|
|
|
nsIEventQueueService* eventService;
|
|
|
|
rv = nsServiceManager::GetService(kEventQueueServiceCID,
|
|
|
|
kIEventQueueServiceIID,
|
|
|
|
(nsISupports **)&eventService);
|
1999-01-08 03:32:55 +03:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
1999-01-05 12:46:33 +03:00
|
|
|
// XXX: What if this fails?
|
|
|
|
rv = eventService->GetThreadEventQueue(PR_GetCurrentThread(),
|
|
|
|
&mThreadEventQueue);
|
|
|
|
nsServiceManager::ReleaseService(kEventQueueServiceCID, eventService);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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);
|
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));
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1998-07-23 08:24:36 +04:00
|
|
|
// Create a document loader...
|
|
|
|
if (nsnull != mParent) {
|
|
|
|
nsIDocumentLoader* parentLoader;
|
|
|
|
|
|
|
|
// Create a child document loader...
|
1999-01-08 03:32:55 +03:00
|
|
|
rv = mParent->GetDocumentLoader(parentLoader);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
1998-07-23 08:24:36 +04:00
|
|
|
rv = parentLoader->CreateDocumentLoader(&mDocLoader);
|
|
|
|
NS_RELEASE(parentLoader);
|
|
|
|
}
|
|
|
|
} else {
|
1999-01-17 14:48:58 +03:00
|
|
|
nsIDocumentLoader* docLoaderService;
|
|
|
|
|
|
|
|
// Get the global document loader service...
|
|
|
|
rv = nsServiceManager::GetService(kDocLoaderServiceCID,
|
1998-07-23 08:24:36 +04:00
|
|
|
kIDocumentLoaderIID,
|
1999-01-17 14:48:58 +03:00
|
|
|
(nsISupports **)&docLoaderService);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = docLoaderService->CreateDocumentLoader(&mDocLoader);
|
|
|
|
nsServiceManager::ReleaseService(kDocLoaderServiceCID, docLoaderService);
|
|
|
|
}
|
1998-07-23 08:24:36 +04:00
|
|
|
}
|
1999-01-08 03:32:55 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
1998-07-23 08:24:36 +04:00
|
|
|
goto done;
|
|
|
|
}
|
1999-01-14 09:44:23 +03:00
|
|
|
|
|
|
|
// Set the webshell as the default IContentViewerContainer for the loader...
|
|
|
|
mDocLoader->SetContainer(this);
|
|
|
|
|
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
|
|
|
|
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-01-08 03:32:55 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
1998-07-19 01:43:02 +04:00
|
|
|
goto done;
|
|
|
|
}
|
1998-10-07 02:33:13 +04:00
|
|
|
|
|
|
|
widgetInit.clipChildren = PR_FALSE;
|
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);
|
1998-07-19 01:43:02 +04:00
|
|
|
|
|
|
|
done:
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-07-29 14:49:01 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::Destroy()
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
1999-05-14 03:51:25 +04:00
|
|
|
//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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-07-29 14:49:01 +04:00
|
|
|
// Stop any URLs that are currently being loaded...
|
1998-09-26 02:25:21 +04:00
|
|
|
Stop();
|
1998-08-14 00:08:19 +04:00
|
|
|
|
1998-07-29 14:49:01 +04:00
|
|
|
SetContainer(nsnull);
|
|
|
|
SetObserver(nsnull);
|
1999-04-07 01:01:04 +04:00
|
|
|
SetDocLoaderObserver(nsnull);
|
1998-07-29 14:49:01 +04:00
|
|
|
|
1999-05-05 04:23:51 +04:00
|
|
|
// Remove this webshell from its parent's child list
|
|
|
|
if (nsnull != mParent) {
|
|
|
|
mParent->RemoveChild(this);
|
|
|
|
}
|
|
|
|
|
1999-01-14 09:44:23 +03:00
|
|
|
if (nsnull != mDocLoader) {
|
|
|
|
mDocLoader->SetContainer(nsnull);
|
|
|
|
}
|
|
|
|
|
1998-07-29 14:49:01 +04:00
|
|
|
NS_IF_RELEASE(mContentViewer);
|
|
|
|
|
1998-11-22 06:11:26 +03:00
|
|
|
// Destroy our child web shells and release references to them
|
|
|
|
DestroyChildren();
|
1998-07-29 14:49:01 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
1998-08-15 03:08:54 +04:00
|
|
|
nsRect aResult;
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_PRECONDITION(nsnull != mWindow, "null window");
|
|
|
|
aResult.SetRect(0, 0, 0, 0);
|
|
|
|
if (nsnull != mWindow) {
|
1998-11-05 00:41:26 +03:00
|
|
|
mWindow->GetClientBounds(aResult);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
1998-08-15 03:08:54 +04:00
|
|
|
x = aResult.x;
|
|
|
|
y = aResult.y;
|
|
|
|
w = aResult.width;
|
|
|
|
h = aResult.height;
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != mWindow, "null window");
|
1998-08-15 03:08:54 +04:00
|
|
|
|
1998-11-05 00:41:26 +03:00
|
|
|
PRInt32 borderWidth = 0;
|
|
|
|
PRInt32 borderHeight = 0;
|
1998-07-19 01:43:02 +04:00
|
|
|
if (nsnull != mWindow) {
|
1998-11-05 00:41:26 +03:00
|
|
|
mWindow->GetBorderSize(borderWidth, borderHeight);
|
1998-07-19 01:43:02 +04:00
|
|
|
// Don't have the widget repaint. Layout will generate repaint requests
|
|
|
|
// during reflow
|
1999-04-30 04:09:52 +04:00
|
|
|
mWindow->Resize(x, y, w, h, PR_FALSE);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
1999-04-30 04:09:52 +04:00
|
|
|
// Set the size of the content area, which is the size of the window
|
|
|
|
// minus the borders
|
1998-07-19 01:43:02 +04:00
|
|
|
if (nsnull != mContentViewer) {
|
1998-11-05 00:41:26 +03:00
|
|
|
nsRect rr(0, 0, w-(borderWidth*2), h-(borderHeight*2));
|
1998-07-19 01:43:02 +04:00
|
|
|
mContentViewer->SetBounds(rr);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::MoveTo(PRInt32 aX, PRInt32 aY)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != mWindow, "null window");
|
|
|
|
|
|
|
|
if (nsnull != mWindow) {
|
|
|
|
mWindow->Move(aX, aY);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::Show()
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != mWindow, "null window");
|
|
|
|
|
|
|
|
if (nsnull != mWindow) {
|
|
|
|
mWindow->Show(PR_TRUE);
|
|
|
|
}
|
|
|
|
if (nsnull != mContentViewer) {
|
|
|
|
mContentViewer->Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::Hide()
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != mWindow, "null window");
|
|
|
|
|
|
|
|
if (nsnull != mWindow) {
|
|
|
|
mWindow->Show(PR_FALSE);
|
|
|
|
}
|
|
|
|
if (nsnull != mContentViewer) {
|
|
|
|
mContentViewer->Hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-16 01:31:58 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetFocus()
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != mWindow, "null window");
|
|
|
|
|
|
|
|
if (nsnull != mWindow) {
|
|
|
|
mWindow->SetFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::RemoveFocus()
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != mWindow, "null window");
|
|
|
|
|
|
|
|
if (nsnull != mWindow) {
|
|
|
|
nsIWidget *parentWidget = mWindow->GetParent();
|
|
|
|
if (nsnull != parentWidget) {
|
|
|
|
parentWidget->SetFocus();
|
|
|
|
NS_RELEASE(parentWidget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::Repaint(PRBool aForce)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != mWindow, "null window");
|
|
|
|
|
|
|
|
if (nsnull != mWindow) {
|
|
|
|
mWindow->Invalidate(aForce);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
NS_IF_ADDREF(aContainer);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetContainer(nsIWebShellContainer*& aResult)
|
|
|
|
{
|
|
|
|
aResult = mContainer;
|
|
|
|
NS_IF_ADDREF(mContainer);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsEventStatus PR_CALLBACK
|
|
|
|
nsWebShell::HandleEvent(nsGUIEvent *aEvent)
|
|
|
|
{
|
|
|
|
return nsEventStatus_eIgnore;
|
|
|
|
}
|
|
|
|
|
1998-07-22 15:24:50 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetObserver(nsIStreamObserver* anObserver)
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mObserver);
|
1998-11-03 11:03:22 +03:00
|
|
|
NS_IF_RELEASE(mNetSupport);
|
|
|
|
|
1998-07-22 15:24:50 +04:00
|
|
|
mObserver = anObserver;
|
1998-11-03 11:03:22 +03:00
|
|
|
if (nsnull != mObserver) {
|
|
|
|
mObserver->QueryInterface(kINetSupportIID, (void **) &mNetSupport);
|
|
|
|
NS_ADDREF(mObserver);
|
|
|
|
}
|
1998-07-22 15:24:50 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetObserver(nsIStreamObserver*& aResult)
|
|
|
|
{
|
|
|
|
aResult = mObserver;
|
|
|
|
NS_IF_ADDREF(mObserver);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-04-07 01:01:04 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetDocLoaderObserver(nsIDocumentLoaderObserver* anObserver)
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mDocLoaderObserver);
|
|
|
|
|
|
|
|
mDocLoaderObserver = anObserver;
|
|
|
|
NS_IF_ADDREF(mDocLoaderObserver);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetDocLoaderObserver(nsIDocumentLoaderObserver*& aResult)
|
|
|
|
{
|
|
|
|
aResult = mDocLoaderObserver;
|
|
|
|
NS_IF_ADDREF(mDocLoaderObserver);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-07-31 10:02:06 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetPrefs(nsIPref* aPrefs)
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mPrefs);
|
|
|
|
mPrefs = aPrefs;
|
|
|
|
NS_IF_ADDREF(mPrefs);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
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-04-16 12:15:04 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetRootWebShellEvenIfChrome(nsIWebShell*& aResult)
|
|
|
|
{
|
|
|
|
nsIWebShell* top = this;
|
|
|
|
NS_ADDREF(this);
|
|
|
|
for (;;) {
|
|
|
|
nsIWebShell* parent;
|
|
|
|
top->GetParentEvenIfChrome(parent);
|
|
|
|
if (nsnull == parent) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
NS_RELEASE(top);
|
|
|
|
top = parent;
|
|
|
|
}
|
|
|
|
aResult = top;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetParent(nsIWebShell* aParent)
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mParent);
|
|
|
|
mParent = aParent;
|
|
|
|
NS_IF_ADDREF(aParent);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetParent(nsIWebShell*& aParent)
|
1999-04-16 12:15:04 +04:00
|
|
|
{
|
|
|
|
if (mWebShellType == nsWebShellContent)
|
|
|
|
{
|
|
|
|
// We cannot return our parent if it is a chrome webshell.
|
|
|
|
nsWebShellType parentType;
|
|
|
|
if (mParent)
|
|
|
|
{
|
|
|
|
mParent->GetWebShellType(parentType);
|
|
|
|
if (parentType == nsWebShellChrome)
|
|
|
|
{
|
|
|
|
aParent = nsnull; // Just return null.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aParent = mParent;
|
|
|
|
NS_IF_ADDREF(mParent);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetParentEvenIfChrome(nsIWebShell*& aParent)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
|
|
|
aParent = mParent;
|
|
|
|
NS_IF_ADDREF(mParent);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aChild, "null ptr");
|
|
|
|
if (nsnull == aChild) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
mChildren.AppendElement(aChild);
|
|
|
|
aChild->SetParent(this);
|
1999-05-04 10:38:37 +04:00
|
|
|
aChild->SetDefaultCharacterSet(mDefaultCharacterSet.GetUnicode());
|
1999-05-28 05:31:55 +04:00
|
|
|
aChild->SetForceCharacterSet(mForceCharacterSet.GetUnicode());
|
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)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aChild, "nsWebShell::RemoveChild(): null ptr");
|
|
|
|
if (nsnull == aChild) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
mChildren.RemoveElement(aChild);
|
|
|
|
aChild->SetParent(nsnull);
|
|
|
|
NS_RELEASE(aChild);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::ChildAt(PRInt32 aIndex, nsIWebShell*& aResult)
|
|
|
|
{
|
|
|
|
if (PRUint32(aIndex) >= PRUint32(mChildren.Count())) {
|
|
|
|
aResult = nsnull;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aResult = (nsIWebShell*) mChildren.ElementAt(aIndex);
|
|
|
|
NS_IF_ADDREF(aResult);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-02-14 09:35:01 +03:00
|
|
|
nsWebShell::GetName(const PRUnichar** aName)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
1999-04-22 04:05:59 +04:00
|
|
|
*aName = mName.GetUnicode();
|
1998-07-19 01:43:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-08-15 03:08:54 +04:00
|
|
|
nsWebShell::SetName(const PRUnichar* aName)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
|
|
|
mName = aName;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
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-02-14 09:35:01 +03:00
|
|
|
const PRUnichar *childName;
|
1998-07-19 01:43:02 +04:00
|
|
|
PRInt32 i, n = mChildren.Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
nsIWebShell* child = (nsIWebShell*) mChildren.ElementAt(i);
|
|
|
|
if (nsnull != child) {
|
1998-08-15 03:08:54 +04:00
|
|
|
child->GetName(&childName);
|
|
|
|
if (aName.Equals(childName)) {
|
1998-07-19 01:43:02 +04:00
|
|
|
aResult = child;
|
|
|
|
NS_ADDREF(child);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// See if child contains the shell with the given name
|
1999-04-22 04:05:59 +04:00
|
|
|
nsresult rv = child->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)
|
|
|
|
{
|
|
|
|
aWebShellType = mWebShellType;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetWebShellType(nsWebShellType aWebShellType)
|
|
|
|
{
|
|
|
|
if (aWebShellType != nsWebShellChrome &&
|
|
|
|
aWebShellType != nsWebShellContent)
|
|
|
|
{
|
|
|
|
NS_ERROR("Attempt to set bogus webshell type: values should be content or chrome.");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
mWebShellType = aWebShellType;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-28 01:05:27 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetContainingChromeShell(nsIWebShell** aResult)
|
|
|
|
{
|
|
|
|
NS_IF_ADDREF(mChromeShell);
|
|
|
|
*aResult = mChromeShell;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetContainingChromeShell(nsIWebShell* aChromeShell)
|
|
|
|
{
|
|
|
|
// Weak reference. Don't addref.
|
|
|
|
mChromeShell = aChromeShell;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-08-10 05:01:27 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetMarginWidth(PRInt32& aWidth)
|
|
|
|
{
|
|
|
|
aWidth = mMarginWidth;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetMarginWidth(PRInt32 aWidth)
|
|
|
|
{
|
|
|
|
mMarginWidth = aWidth;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetMarginHeight(PRInt32& aHeight)
|
|
|
|
{
|
|
|
|
aHeight = mMarginHeight;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetMarginHeight(PRInt32 aHeight)
|
|
|
|
{
|
|
|
|
mMarginHeight = aHeight;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetIsFrame(PRBool& aIsFrame)
|
|
|
|
{
|
|
|
|
aIsFrame = mIsFrame;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetIsFrame(PRBool aIsFrame)
|
|
|
|
{
|
|
|
|
mIsFrame = aIsFrame;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-16 08:25:17 +04:00
|
|
|
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, nsnull, 0);
|
|
|
|
NS_RELEASE(vm);
|
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
NS_RELEASE(cx);
|
|
|
|
}
|
|
|
|
NS_RELEASE(docv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetZoom(float *aZoom)
|
|
|
|
{
|
|
|
|
*aZoom = mZoom;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-01-20 02:14:31 +03:00
|
|
|
|
1998-08-15 03:08:54 +04:00
|
|
|
/**
|
|
|
|
* Document Load methods
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
|
|
|
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);
|
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] = '|';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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,
|
1998-08-13 08:36:42 +04:00
|
|
|
nsIPostData* aPostData,
|
1998-08-20 03:01:52 +04:00
|
|
|
PRBool aModifyHistory,
|
1998-10-10 08:33:29 +04:00
|
|
|
nsURLReloadType aType,
|
1998-09-16 04:40:20 +04:00
|
|
|
const PRUint32 aLocalIP)
|
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.
|
|
|
|
InitFrameData(PR_FALSE);
|
1998-11-11 23:31:45 +03:00
|
|
|
|
|
|
|
return LoadURL(aURLSpec,"view",aPostData,aModifyHistory,aType, aLocalIP);
|
|
|
|
}
|
|
|
|
|
1999-02-12 20:32:17 +03:00
|
|
|
nsresult
|
|
|
|
nsWebShell::DoLoadURL(const nsString& aUrlSpec,
|
|
|
|
const char* aCommand,
|
|
|
|
nsIPostData* aPostData,
|
|
|
|
nsURLReloadType aType,
|
|
|
|
const PRUint32 aLocalIP)
|
|
|
|
|
|
|
|
|
|
|
|
{
|
1999-04-07 01:01:04 +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
|
|
|
|
if ((aType == nsURLReload) && (nsnull != mContentViewer)) {
|
|
|
|
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
|
|
|
|
nsCOMPtr<nsIURL> docURL = nsDontAddRef<nsIURL>(doc->GetDocumentURL());
|
|
|
|
|
|
|
|
// See if they're the same
|
|
|
|
nsCOMPtr<nsIURL> url;
|
|
|
|
NS_NewURL(getter_AddRefs(url), aUrlSpec);
|
|
|
|
|
|
|
|
if ((PRBool)docURL->Equals(url)) {
|
|
|
|
// See if there's a destination anchor
|
|
|
|
const char* ref;
|
|
|
|
url->GetRef(&ref);
|
|
|
|
|
|
|
|
if (nsnull != ref) {
|
|
|
|
// Get the pres shell object
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
docViewer->GetPresShell(*getter_AddRefs(presShell));
|
|
|
|
|
|
|
|
presShell->GoToAnchor(nsAutoString(ref));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stop loading the current document (if any...). This call may result in
|
|
|
|
// firing an EndLoadURL notification for the old document...
|
|
|
|
Stop();
|
|
|
|
|
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-04-22 04:05:59 +04:00
|
|
|
nsresult rv = mContainer->BeginLoadURL(this, aUrlSpec.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-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.
|
|
|
|
* - Radha
|
|
|
|
*/
|
|
|
|
|
1999-02-12 20:32:17 +03:00
|
|
|
return mDocLoader->LoadDocument(aUrlSpec, // URL string
|
|
|
|
aCommand, // Command
|
|
|
|
this, // Container
|
|
|
|
aPostData, // Post Data
|
|
|
|
nsnull, // Extra Info...
|
1999-04-07 01:01:04 +04:00
|
|
|
mObserver, // Observer
|
1999-02-12 20:32:17 +03:00
|
|
|
aType, // reload type
|
|
|
|
aLocalIP); // load attributes.
|
|
|
|
}
|
|
|
|
|
1998-11-11 23:31:45 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::LoadURL(const PRUnichar *aURLSpec,
|
|
|
|
const char* aCommand,
|
|
|
|
nsIPostData* aPostData,
|
|
|
|
PRBool aModifyHistory,
|
|
|
|
nsURLReloadType aType,
|
|
|
|
const PRUint32 aLocalIP)
|
|
|
|
{
|
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
nsresult rv;
|
1998-08-10 01:22:18 +04:00
|
|
|
PRInt32 colon, fSlash;
|
|
|
|
PRUnichar port;
|
1998-08-15 03:08:54 +04:00
|
|
|
nsAutoString urlSpec;
|
|
|
|
convertFileToURL(nsString(aURLSpec), urlSpec);
|
1998-08-10 01:22:18 +04:00
|
|
|
|
|
|
|
fSlash=urlSpec.Find('/');
|
1998-07-19 01:43:02 +04:00
|
|
|
|
1998-08-10 01:22:18 +04:00
|
|
|
// if no scheme (protocol) is found, assume http.
|
|
|
|
if ( ((colon=urlSpec.Find(':')) == -1) // no colon at all
|
1999-01-09 05:00:42 +03:00
|
|
|
|| ( (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
|
|
|
|
int hostPos = urlSpec.FindCharInSet("./:");
|
|
|
|
if (hostPos == -1) {
|
|
|
|
hostPos = urlSpec.Length();
|
|
|
|
}
|
|
|
|
|
|
|
|
// extract host name
|
|
|
|
nsAutoString hostSpec;
|
|
|
|
urlSpec.Left(hostSpec, hostPos);
|
|
|
|
|
|
|
|
// insert url spec corresponding to host name
|
|
|
|
if (hostSpec.EqualsIgnoreCase("www")) {
|
|
|
|
nsString ftpDef("http://");
|
|
|
|
urlSpec.Insert(ftpDef, 0, 7);
|
|
|
|
} else if (hostSpec.EqualsIgnoreCase("ftp")) {
|
|
|
|
nsString ftpDef("ftp://");
|
|
|
|
urlSpec.Insert(ftpDef, 0, 6);
|
|
|
|
} else {
|
|
|
|
nsString httpDef("http://");
|
|
|
|
urlSpec.Insert(httpDef, 0, 7);
|
|
|
|
}
|
1998-08-10 01:22:18 +04:00
|
|
|
}
|
1998-08-15 03:08:54 +04:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
// Give web-shell-container right of refusal
|
|
|
|
if (nsnull != mContainer) {
|
1999-04-22 04:05:59 +04:00
|
|
|
rv = mContainer->WillLoadURL(this, urlSpec.GetUnicode(), nsLoadURL);
|
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
|
|
|
nsString* url = new nsString(urlSpec);
|
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 {
|
|
|
|
// 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-02-12 20:32:17 +03:00
|
|
|
return DoLoadURL(urlSpec, aCommand, aPostData, aType, aLocalIP);
|
1998-07-19 01:43:02 +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.
|
|
|
|
CancelRefreshURLTimers();
|
|
|
|
|
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++) {
|
|
|
|
nsIWebShell* shell = (nsIWebShell*) mChildren.ElementAt(i);
|
|
|
|
shell->Stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
1998-08-15 03:08:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-10 08:33:29 +04:00
|
|
|
NS_IMETHODIMP nsWebShell::Reload(nsURLReloadType 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-04-22 04:05:59 +04:00
|
|
|
return LoadURL(s->GetUnicode(), nsnull, PR_FALSE, aType);
|
1998-08-13 08:49:16 +04:00
|
|
|
}
|
1998-08-15 03:08:54 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
return (mHistoryIndex > 0 ? NS_OK : NS_COMFALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
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-02-12 20:32:17 +03:00
|
|
|
rv = DoLoadURL(urlSpec, // URL string
|
|
|
|
"view", // Command
|
|
|
|
nsnull, // Post Data
|
|
|
|
nsURLReload, // the reload type
|
|
|
|
0); // load attributes
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
1998-07-19 05:18:40 +04:00
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
// Chrome API's
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-08-15 03:08:54 +04:00
|
|
|
nsWebShell::SetTitle(const PRUnichar* aTitle)
|
1998-07-19 05:18:40 +04:00
|
|
|
{
|
|
|
|
// Record local title
|
|
|
|
mTitle = aTitle;
|
|
|
|
|
|
|
|
// Title's set on the top level web-shell are passed ont to the container
|
1998-10-26 21:37:04 +03:00
|
|
|
nsIWebShell* parent;
|
|
|
|
GetParent(parent);
|
|
|
|
if (nsnull == parent) {
|
|
|
|
nsIBrowserWindow *browserWindow = GetBrowserWindow();
|
|
|
|
if (nsnull != browserWindow) {
|
|
|
|
browserWindow->SetTitle(aTitle);
|
|
|
|
NS_RELEASE(browserWindow);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
NS_RELEASE(parent);
|
1998-07-19 05:18:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-02-14 09:35:01 +03:00
|
|
|
nsWebShell::GetTitle(const PRUnichar** aResult)
|
1998-07-19 05:18:40 +04:00
|
|
|
{
|
1999-04-22 04:05:59 +04:00
|
|
|
*aResult = mTitle.GetUnicode();
|
1998-07-19 05:18:40 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
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
|
1998-08-15 03:08:54 +04:00
|
|
|
nsWebShell::ProgressLoadURL(nsIWebShell* aShell,
|
|
|
|
const PRUnichar* aURL,
|
|
|
|
PRInt32 aProgress,
|
|
|
|
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
|
|
|
|
nsWebShell::EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus)
|
|
|
|
{
|
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
|
|
|
|
nsWebShell::CreatePopup(nsIDOMElement* aElement, nsIDOMElement* aPopupContent,
|
|
|
|
PRInt32 aXPos, PRInt32 aYPos,
|
1999-06-09 12:36:06 +04:00
|
|
|
const nsString& aPopupType, const nsString& anAnchorAlignment,
|
|
|
|
const nsString& aPopupAlignment,
|
1999-05-16 11:52:02 +04:00
|
|
|
nsIDOMWindow* aWindow)
|
1999-05-15 02:40:03 +04:00
|
|
|
{
|
|
|
|
if (nsnull != mContainer) {
|
1999-06-09 12:36:06 +04:00
|
|
|
return mContainer->CreatePopup(aElement, aPopupContent, aXPos, aYPos, aPopupType,
|
|
|
|
anAnchorAlignment, aPopupAlignment,
|
1999-05-16 11:52:02 +04:00
|
|
|
aWindow);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
nsIWebShell* shell = nsnull;
|
|
|
|
|
|
|
|
//Other wise, check children and move focus to next one
|
|
|
|
PRInt32 i, n = mChildren.Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
shell = (nsIWebShell*)mChildren.ElementAt(i);
|
|
|
|
if (shell == aFocusedWebShell) {
|
|
|
|
if (++i < n) {
|
|
|
|
shell = (nsIWebShell*)mChildren.ElementAt(i);
|
|
|
|
shell->SetFocus();
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-06 04:30:07 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-05-06 05:58:48 +04:00
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Web Shell Services API
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-05-06 07:54:40 +04:00
|
|
|
nsWebShell::LoadDocument(const char* aURL,
|
|
|
|
const char* aCharset,
|
|
|
|
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
|
|
|
|
mHintCharset = aCharset;
|
|
|
|
mHintCharsetSource = aSource;
|
|
|
|
|
1999-05-07 04:21:57 +04:00
|
|
|
nsAutoString url(aURL);
|
|
|
|
LoadURL(url.GetUnicode());
|
1999-05-06 05:58:48 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-19 04:23:03 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::ReloadDocument(const char* aCharset,
|
|
|
|
nsCharsetSource aSource)
|
|
|
|
{
|
|
|
|
// XXX hack. kee the aCharset and aSource wait to pick it up
|
|
|
|
mHintCharset = aCharset;
|
|
|
|
mHintCharsetSource= aSource;
|
|
|
|
|
1999-05-29 01:32:29 +04:00
|
|
|
nsString* s = (nsString*) mHistory.ElementAt(mHistoryIndex);
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
if(s) {
|
|
|
|
char* url = s->ToNewCString();
|
|
|
|
if(url) {
|
|
|
|
mHistoryIndex--;
|
|
|
|
rv = this->RefreshURL((const char*)url,0,PR_FALSE);
|
|
|
|
delete [] url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
1999-05-19 04:23:03 +04:00
|
|
|
}
|
|
|
|
|
1999-05-06 05:58:48 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::StopDocumentLoad(void)
|
|
|
|
{
|
1999-05-06 07:54:40 +04:00
|
|
|
Stop();
|
1999-05-06 05:58:48 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetRendering(PRBool aRender)
|
|
|
|
{
|
1999-05-07 23:25:58 +04:00
|
|
|
if (mContentViewer) {
|
|
|
|
mContentViewer->SetEnableRendering(aRender);
|
|
|
|
}
|
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,
|
1998-08-15 03:08:54 +04:00
|
|
|
const PRUnichar* aTargetSpec, nsIPostData* aPostData = 0);
|
1998-07-19 01:43:02 +04:00
|
|
|
~OnLinkClickEvent();
|
|
|
|
|
|
|
|
void HandleEvent() {
|
1999-04-22 04:05:59 +04:00
|
|
|
mHandler->HandleLinkClickEvent(mContent, mVerb, mURLSpec->GetUnicode(), mTargetSpec->GetUnicode(), mPostData);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsWebShell* mHandler;
|
|
|
|
nsString* mURLSpec;
|
|
|
|
nsString* mTargetSpec;
|
|
|
|
nsIPostData* mPostData;
|
1998-11-14 03:21:19 +03:00
|
|
|
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,
|
1998-07-19 01:43:02 +04:00
|
|
|
nsIPostData* aPostData)
|
|
|
|
{
|
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);
|
|
|
|
mPostData = aPostData;
|
|
|
|
NS_IF_ADDREF(mPostData);
|
1998-11-14 03:21:19 +03:00
|
|
|
mContent = aContent;
|
|
|
|
NS_IF_ADDREF(mContent);
|
|
|
|
mVerb = aVerb;
|
|
|
|
|
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-05-05 03:34:10 +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);
|
|
|
|
NS_IF_RELEASE(mPostData);
|
|
|
|
if (nsnull != mURLSpec) delete mURLSpec;
|
|
|
|
if (nsnull != mTargetSpec) delete mTargetSpec;
|
1998-11-14 03:21:19 +03:00
|
|
|
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-11-14 03:21:19 +03:00
|
|
|
nsWebShell::OnLinkClick(nsIContent* aContent,
|
|
|
|
nsLinkVerb aVerb,
|
1998-08-15 03:08:54 +04:00
|
|
|
const PRUnichar* aURLSpec,
|
|
|
|
const PRUnichar* aTargetSpec,
|
1998-07-19 01:43:02 +04:00
|
|
|
nsIPostData* aPostData)
|
|
|
|
{
|
1998-07-25 01:03:33 +04:00
|
|
|
OnLinkClickEvent* ev;
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
1998-11-14 03:21:19 +03:00
|
|
|
ev = new OnLinkClickEvent(this, aContent, aVerb, aURLSpec,
|
|
|
|
aTargetSpec, aPostData);
|
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;
|
|
|
|
}
|
|
|
|
|
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");
|
|
|
|
}
|
1998-07-19 01:43:02 +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);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
1998-08-15 03:08:54 +04:00
|
|
|
else if (name.EqualsIgnoreCase("_parent")) {
|
1998-07-19 01:43:02 +04:00
|
|
|
if (nsnull == mParent) {
|
|
|
|
target = this;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
target = mParent;
|
|
|
|
}
|
1998-07-19 05:18:40 +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")) {
|
1998-07-19 05:18:40 +04:00
|
|
|
GetRootWebShell(target);
|
1998-07-19 01:43:02 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Look from the top of the tree downward
|
1998-09-18 04:35:55 +04:00
|
|
|
if (nsnull != mContainer) {
|
|
|
|
mContainer->FindWebShellWithName(aName, target);
|
|
|
|
if (nsnull == target) {
|
1998-12-08 05:39:48 +03:00
|
|
|
mContainer->NewWebShell(PRUint32(~0), PR_TRUE, target);
|
1998-09-18 04:35:55 +04:00
|
|
|
}
|
|
|
|
if (nsnull != target) {
|
|
|
|
target->SetName(aName);
|
|
|
|
}
|
|
|
|
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");
|
|
|
|
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,
|
1998-07-19 01:43:02 +04:00
|
|
|
nsIPostData* aPostData)
|
|
|
|
{
|
1998-11-14 03:21:19 +03:00
|
|
|
nsAutoString target(aTargetSpec);
|
|
|
|
|
|
|
|
switch(aVerb) {
|
|
|
|
case eLinkVerb_New:
|
|
|
|
target.SetString("_blank");
|
|
|
|
// Fall into replace case
|
|
|
|
case eLinkVerb_Replace:
|
|
|
|
{
|
|
|
|
nsIWebShell* shell = GetTarget(target.GetUnicode());
|
|
|
|
if (nsnull != shell) {
|
|
|
|
shell->LoadURL(aURLSpec, aPostData);
|
|
|
|
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
|
1998-10-02 22:44:56 +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
|
1998-08-15 03:08:54 +04:00
|
|
|
nsWebShell:: GetLinkState(const PRUnichar* aURLSpec, nsLinkState& aState)
|
1998-07-19 01:43:02 +04:00
|
|
|
{
|
1998-08-15 03:08:54 +04:00
|
|
|
nsString URLSpec(aURLSpec);
|
1998-07-19 01:43:02 +04:00
|
|
|
aState = eLinkState_Unvisited;
|
1999-05-19 11:22:57 +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.
|
|
|
|
if (nsnull == mHistoryService) {
|
|
|
|
rv = nsServiceManager::GetService(kGlobalHistoryCID,
|
|
|
|
nsIGlobalHistory::GetIID(),
|
|
|
|
(nsISupports**) &mHistoryService);
|
|
|
|
}
|
1999-05-18 09:21:37 +04:00
|
|
|
|
1999-05-19 11:22:57 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return NS_OK; // XXX Okay, we couldn't color the link. Big deal.
|
|
|
|
|
|
|
|
// XXX aURLSpec should really be a char*, not a PRUnichar*.
|
|
|
|
nsAutoString urlStr(aURLSpec);
|
|
|
|
|
|
|
|
char buf[256];
|
|
|
|
char* url = buf;
|
|
|
|
|
|
|
|
if (urlStr.Length() >= sizeof(buf)) {
|
|
|
|
url = new char[urlStr.Length() + 1];
|
|
|
|
}
|
1999-05-18 09:21:37 +04:00
|
|
|
|
1999-05-19 11:22:57 +04:00
|
|
|
PRInt64 lastVisitDate;
|
|
|
|
|
|
|
|
if (url) {
|
1999-05-18 09:21:37 +04:00
|
|
|
urlStr.ToCString(url, urlStr.Length() + 1);
|
|
|
|
|
1999-06-08 01:26:10 +04:00
|
|
|
rv = mHistoryService->GetLastVisitDate(url, &lastVisitDate);
|
1999-05-18 09:21:37 +04:00
|
|
|
|
|
|
|
if (url != buf)
|
|
|
|
delete[] url;
|
1999-05-19 11:22:57 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-18 09:21:37 +04:00
|
|
|
|
1999-06-08 01:26:10 +04:00
|
|
|
//XXX: Moved to destructor nsServiceManager::ReleaseService(kGlobalHistoryCID, mHistoryService);
|
1999-05-18 09:21:37 +04:00
|
|
|
|
1999-05-19 11:22:57 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-05-18 09:21:37 +04:00
|
|
|
|
1999-05-19 11:22:57 +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;
|
|
|
|
|
|
|
|
// XXX how to tell if eLinkState_OutOfDate?
|
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()
|
|
|
|
{
|
|
|
|
nsIBrowserWindow *browserWindow = nsnull;
|
|
|
|
nsIWebShell *rootWebShell;
|
|
|
|
|
1999-04-16 12:15:04 +04:00
|
|
|
GetRootWebShellEvenIfChrome(rootWebShell);
|
1998-10-02 22:44:56 +04:00
|
|
|
|
|
|
|
if (nsnull != rootWebShell) {
|
|
|
|
nsIWebShellContainer *rootContainer;
|
|
|
|
rootWebShell->GetContainer(rootContainer);
|
|
|
|
if (nsnull != rootContainer) {
|
|
|
|
rootContainer->QueryInterface(kIBrowserWindowIID, (void**)&browserWindow);
|
|
|
|
NS_RELEASE(rootContainer);
|
|
|
|
}
|
|
|
|
NS_RELEASE(rootWebShell);
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
1998-07-21 08:46:55 +04:00
|
|
|
res = NS_CreateContext(mScriptGlobal, &mScriptContext);
|
|
|
|
}
|
|
|
|
|
1998-11-23 11:09:11 +03:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1998-07-24 09:07:51 +04:00
|
|
|
nsresult
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1998-07-21 08:46:55 +04:00
|
|
|
nsresult
|
|
|
|
nsWebShell::ReleaseScriptContext(nsIScriptContext *aContext)
|
|
|
|
{
|
|
|
|
// XXX Is this right? Why are we passing in a context?
|
|
|
|
NS_IF_RELEASE(aContext);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-07 01:01:04 +04:00
|
|
|
|
1999-03-29 13:21:01 +04:00
|
|
|
NS_IMETHODIMP
|
1999-04-28 10:47:40 +04:00
|
|
|
nsWebShell::OnStartDocumentLoad(nsIDocumentLoader* loader,
|
|
|
|
nsIURL* aURL,
|
|
|
|
const char* aCommand)
|
1999-03-29 13:21:01 +04:00
|
|
|
{
|
1999-05-04 03:04:50 +04:00
|
|
|
#if DEBUG_nisheeth
|
|
|
|
const char* spec;
|
|
|
|
aURL->GetSpec(&spec);
|
|
|
|
printf("nsWebShell::OnStartDocumentLoad:%p: loader=%p url=%s command=%s\n", this, loader, spec, aCommand);
|
|
|
|
#endif
|
|
|
|
|
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-03-30 03:01:13 +04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
1999-04-07 01:01:04 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
*Fire the OnStartDocumentLoad of the webshell observer
|
|
|
|
*/
|
|
|
|
if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver))
|
|
|
|
{
|
1999-04-28 10:47:40 +04:00
|
|
|
mDocLoaderObserver->OnStartDocumentLoad(mDocLoader, aURL, aCommand);
|
1999-04-07 01:01:04 +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-04-28 10:47:40 +04:00
|
|
|
nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader,
|
|
|
|
nsIURL* aURL,
|
|
|
|
PRInt32 aStatus)
|
1999-03-29 13:21:01 +04:00
|
|
|
{
|
1999-05-04 03:04:50 +04:00
|
|
|
#if DEBUG_nisheeth
|
1999-04-30 04:09:52 +04:00
|
|
|
const char* spec;
|
|
|
|
aURL->GetSpec(&spec);
|
|
|
|
printf("nsWebShell::OnEndDocumentLoad:%p: loader=%p url=%s status=%d\n", this, loader, spec, aStatus);
|
1999-05-04 03:04:50 +04:00
|
|
|
#endif
|
1999-04-07 01:01:04 +04:00
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
|
1999-05-04 03:04:50 +04:00
|
|
|
if (!mProcessedEndDocumentLoad) {
|
|
|
|
mProcessedEndDocumentLoad = PR_TRUE;
|
|
|
|
|
|
|
|
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_LOAD;
|
|
|
|
rv = mScriptGlobal->HandleDOMEvent(*presContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
|
|
|
|
|
|
|
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;
|
|
|
|
const char* spec;
|
|
|
|
rv = aURL->GetSpec(&spec);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
urlString = spec;
|
|
|
|
if (nsnull != mContainer) {
|
|
|
|
rv = mContainer->EndLoadURL(this, urlString.GetUnicode(), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-04-07 01:01:04 +04:00
|
|
|
|
1999-05-04 03:04:50 +04:00
|
|
|
/*
|
|
|
|
* Fire the OnEndDocumentLoad of the DocLoaderobserver
|
|
|
|
*/
|
|
|
|
if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver) && (nsnull != aURL)){
|
|
|
|
mDocLoaderObserver->OnEndDocumentLoad(mDocLoader, aURL, aStatus);
|
|
|
|
}
|
1999-04-07 01:01:04 +04:00
|
|
|
}
|
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-04-28 10:47:40 +04:00
|
|
|
nsWebShell::OnStartURLLoad(nsIDocumentLoader* loader,
|
|
|
|
nsIURL* aURL,
|
|
|
|
const char* aContentType,
|
1999-01-14 09:44:23 +03:00
|
|
|
nsIContentViewer* aViewer)
|
|
|
|
{
|
1999-04-07 01:01:04 +04:00
|
|
|
|
1999-04-08 08:08:49 +04:00
|
|
|
// XXX This is a temporary hack for meeting the M4 milestone
|
|
|
|
// for seamonkey. I think Netlib should send a message to all stream listeners
|
|
|
|
// when it changes the URL like this. That would mean adding a new method
|
|
|
|
// to nsIStreamListener. Need to talk to Rick, Kipp, Gagan about this.
|
|
|
|
CheckForTrailingSlash(aURL);
|
|
|
|
|
1999-04-07 01:01:04 +04:00
|
|
|
/*
|
|
|
|
*Fire the OnStartDocumentLoad of the webshell observer
|
|
|
|
*/
|
|
|
|
if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver))
|
|
|
|
{
|
1999-04-28 10:47:40 +04:00
|
|
|
mDocLoaderObserver->OnStartURLLoad(mDocLoader, aURL, aContentType, 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-04-28 10:47:40 +04:00
|
|
|
nsWebShell::OnProgressURLLoad(nsIDocumentLoader* loader,
|
|
|
|
nsIURL* aURL,
|
|
|
|
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-04-28 10:47:40 +04:00
|
|
|
mDocLoaderObserver->OnProgressURLLoad(mDocLoader, aURL, aProgress, aProgressMax);
|
1999-04-07 01:01:04 +04:00
|
|
|
}
|
|
|
|
|
1999-03-29 13:21:01 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-04-28 10:47:40 +04:00
|
|
|
nsWebShell::OnStatusURLLoad(nsIDocumentLoader* loader,
|
|
|
|
nsIURL* aURL,
|
|
|
|
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-04-28 10:47:40 +04:00
|
|
|
mDocLoaderObserver->OnStatusURLLoad(mDocLoader, aURL, aMsg);
|
1999-04-07 01:01:04 +04:00
|
|
|
}
|
|
|
|
|
1999-03-29 13:21:01 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-04-28 10:47:40 +04:00
|
|
|
nsWebShell::OnEndURLLoad(nsIDocumentLoader* loader,
|
|
|
|
nsIURL* aURL,
|
|
|
|
PRInt32 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
|
|
|
/*
|
|
|
|
*Fire the OnStartDocumentLoad of the webshell observer
|
|
|
|
*/
|
|
|
|
if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver))
|
|
|
|
{
|
1999-04-28 10:47:40 +04:00
|
|
|
mDocLoaderObserver->OnEndURLLoad(mDocLoader, aURL, aStatus);
|
1999-04-07 01:01:04 +04:00
|
|
|
}
|
|
|
|
|
1999-03-29 13:21:01 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-01-14 09:44:23 +03:00
|
|
|
|
1998-08-19 03:25:17 +04:00
|
|
|
/* For use with redirect/refresh url api */
|
1998-09-26 02:25:21 +04:00
|
|
|
class refreshData : public nsITimerCallback
|
|
|
|
{
|
|
|
|
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-04-22 04:05:59 +04:00
|
|
|
mShell->LoadURL(mUrlSpec.GetUnicode(), nsnull, PR_TRUE, nsURLReload);
|
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
|
|
|
|
nsWebShell::RefreshURL(nsIURL* aURL, PRInt32 millis, PRBool repeat)
|
1999-05-29 01:32:29 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
if (nsnull == aURL) {
|
|
|
|
NS_PRECONDITION((aURL != nsnull), "Null pointer");
|
|
|
|
rv = NS_ERROR_NULL_POINTER;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* spec;
|
|
|
|
aURL->GetSpec(&spec);
|
|
|
|
rv = RefreshURL(spec, millis, repeat);
|
|
|
|
done:
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::RefreshURL(const char* aURL, 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;
|
|
|
|
|
|
|
|
if (nsnull == aURL) {
|
1998-08-19 03:25:17 +04:00
|
|
|
NS_PRECONDITION((aURL != 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-05-29 01:32:29 +04:00
|
|
|
data->mUrlSpec = aURL;
|
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-05-07 23:25:58 +04:00
|
|
|
nsWebShell::CancelRefreshURLTimers(void)
|
|
|
|
{
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
nsresult nsWebShell::CheckForTrailingSlash(nsIURL* aURL)
|
|
|
|
{
|
|
|
|
nsString* historyURL = (nsString*) mHistory.ElementAt(mHistoryIndex);
|
|
|
|
const char* spec;
|
|
|
|
aURL->GetSpec(&spec);
|
|
|
|
nsString* newURL = (nsString*) new nsString(spec);
|
|
|
|
|
1999-03-23 00:53:58 +03:00
|
|
|
if (newURL && newURL->Last() == '/' && !historyURL->Equals(*newURL)) {
|
1999-03-18 04:07:22 +03:00
|
|
|
// Replace the top most history entry with the new url
|
|
|
|
if (nsnull != historyURL) {
|
|
|
|
delete historyURL;
|
|
|
|
}
|
|
|
|
mHistory.ReplaceElementAt(newURL, mHistoryIndex);
|
1999-03-23 00:53:58 +03:00
|
|
|
} else
|
|
|
|
delete newURL;
|
1999-03-18 04:07:22 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-07 01:01:04 +04:00
|
|
|
#if 0
|
1998-08-20 10:17:47 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::OnStartBinding(nsIURL* aURL, const char *aContentType)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
if (nsnull != mObserver) {
|
|
|
|
rv = mObserver->OnStartBinding(aURL, aContentType);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-12-16 08:40:20 +03:00
|
|
|
nsWebShell::OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax)
|
1998-08-20 10:17:47 +04:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
if (nsnull != mObserver) {
|
|
|
|
rv = mObserver->OnProgress(aURL, aProgress, aProgressMax);
|
|
|
|
}
|
|
|
|
|
1998-10-02 22:44:56 +04:00
|
|
|
// Pass status messages out to the nsIBrowserWindow...
|
|
|
|
nsIBrowserWindow *browserWindow;
|
|
|
|
|
|
|
|
browserWindow = GetBrowserWindow();
|
|
|
|
if (nsnull != browserWindow) {
|
|
|
|
browserWindow->SetProgress(aProgress, aProgressMax);
|
|
|
|
NS_RELEASE(browserWindow);
|
|
|
|
}
|
|
|
|
|
1998-08-20 10:17:47 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-12-16 08:40:20 +03:00
|
|
|
nsWebShell::OnStatus(nsIURL* aURL, const PRUnichar* aMsg)
|
1998-08-20 10:17:47 +04:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
if (nsnull != mObserver) {
|
|
|
|
rv = mObserver->OnStatus(aURL, aMsg);
|
|
|
|
}
|
1998-10-02 22:44:56 +04:00
|
|
|
|
|
|
|
// Pass status messages out to the nsIBrowserWindow...
|
|
|
|
nsIBrowserWindow *browserWindow;
|
|
|
|
|
|
|
|
browserWindow = GetBrowserWindow();
|
|
|
|
if (nsnull != browserWindow) {
|
|
|
|
browserWindow->SetStatus(aMsg);
|
|
|
|
NS_RELEASE(browserWindow);
|
|
|
|
}
|
|
|
|
|
1998-08-20 10:17:47 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-12-16 08:40:20 +03:00
|
|
|
nsWebShell::OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg)
|
1998-08-20 10:17:47 +04:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
if (nsnull != mObserver) {
|
|
|
|
rv = mObserver->OnStopBinding(aURL, aStatus, aMsg);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
1999-04-07 01:01:04 +04:00
|
|
|
#endif /* 0 */
|
|
|
|
|
1998-08-20 10:17:47 +04:00
|
|
|
|
1998-11-03 11:03:22 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(void)
|
|
|
|
nsWebShell::Alert(const nsString &aText)
|
|
|
|
{
|
|
|
|
if (nsnull != mNetSupport) {
|
|
|
|
mNetSupport->Alert(aText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(PRBool)
|
|
|
|
nsWebShell::Confirm(const nsString &aText)
|
|
|
|
{
|
|
|
|
PRBool bResult = PR_FALSE;
|
|
|
|
|
|
|
|
if (nsnull != mNetSupport) {
|
|
|
|
bResult = mNetSupport->Confirm(aText);
|
|
|
|
}
|
|
|
|
return bResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(PRBool)
|
|
|
|
nsWebShell::Prompt(const nsString &aText,
|
|
|
|
const nsString &aDefault,
|
|
|
|
nsString &aResult)
|
|
|
|
{
|
|
|
|
PRBool bResult = PR_FALSE;
|
|
|
|
|
|
|
|
if (nsnull != mNetSupport) {
|
|
|
|
bResult = mNetSupport->Prompt(aText, aDefault, aResult);
|
|
|
|
}
|
|
|
|
return bResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(PRBool)
|
|
|
|
nsWebShell::PromptUserAndPassword(const nsString &aText,
|
|
|
|
nsString &aUser,
|
|
|
|
nsString &aPassword)
|
|
|
|
{
|
|
|
|
PRBool bResult = PR_FALSE;
|
|
|
|
|
|
|
|
if (nsnull != mNetSupport) {
|
|
|
|
bResult = mNetSupport->PromptUserAndPassword(aText, aUser, aPassword);
|
|
|
|
}
|
|
|
|
return bResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(PRBool)
|
|
|
|
nsWebShell::PromptPassword(const nsString &aText,
|
|
|
|
nsString &aPassword)
|
|
|
|
{
|
|
|
|
PRBool bResult = PR_FALSE;
|
|
|
|
|
|
|
|
if (nsnull != mNetSupport) {
|
|
|
|
bResult = mNetSupport->PromptPassword(aText, aPassword);
|
|
|
|
}
|
|
|
|
return bResult;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
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-03-23 01:21:22 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetDefaultCharacterSet (const PRUnichar** aDefaultCharacterSet)
|
|
|
|
{
|
1999-04-22 04:05:59 +04:00
|
|
|
*aDefaultCharacterSet = mDefaultCharacterSet.GetUnicode();
|
1999-03-23 01:21:22 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetDefaultCharacterSet (const PRUnichar* aDefaultCharacterSet)
|
|
|
|
{
|
|
|
|
mDefaultCharacterSet = aDefaultCharacterSet;
|
1999-04-29 03:59:08 +04:00
|
|
|
PRInt32 i, n = mChildren.Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
nsIWebShell* child = (nsIWebShell*) mChildren.ElementAt(i);
|
|
|
|
if (nsnull != child) {
|
|
|
|
child->SetDefaultCharacterSet(aDefaultCharacterSet);
|
|
|
|
}
|
|
|
|
}
|
1999-03-23 01:21:22 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-28 05:31:55 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::GetForceCharacterSet (const PRUnichar** aForceCharacterSet)
|
|
|
|
{
|
|
|
|
nsString emptyStr = "";
|
|
|
|
if (mForceCharacterSet.Equals(emptyStr)) {
|
|
|
|
*aForceCharacterSet = nsnull;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*aForceCharacterSet = mForceCharacterSet.GetUnicode();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShell::SetForceCharacterSet (const PRUnichar* aForceCharacterSet)
|
|
|
|
{
|
|
|
|
mForceCharacterSet = aForceCharacterSet;
|
|
|
|
PRInt32 i, n = mChildren.Count();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
nsIWebShell* child = (nsIWebShell*) mChildren.ElementAt(i);
|
|
|
|
if (nsnull != child) {
|
|
|
|
child->SetForceCharacterSet(aForceCharacterSet);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-19 04:23:03 +04:00
|
|
|
NS_IMETHODIMP nsWebShell::GetCharacterSetHint (const PRUnichar** oHintCharset, nsCharsetSource* oSource)
|
|
|
|
{
|
|
|
|
*oSource = mHintCharsetSource;
|
|
|
|
if(kCharsetUninitialized == mHintCharsetSource) {
|
|
|
|
*oHintCharset = nsnull;
|
|
|
|
} else {
|
|
|
|
*oHintCharset = mHintCharset.GetUnicode();
|
|
|
|
// clean up after we access it.
|
|
|
|
mHintCharsetSource = kCharsetUninitialized;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
// XXX TEMPORARY Till we have real pluggable protocol handlers
|
|
|
|
NET_InitJavaScriptProtocol();
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
|
|
|
|
}
|
1998-07-19 01:43:02 +04:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsWebShellFactory::QueryInterface(const nsIID &aIID, void **aResult)
|
|
|
|
{
|
|
|
|
if (aResult == NULL) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Always NULL result, in case of failure
|
|
|
|
*aResult = NULL;
|
|
|
|
|
|
|
|
if (aIID.Equals(kISupportsIID)) {
|
|
|
|
*aResult = (void *)(nsISupports*)this;
|
|
|
|
} else if (aIID.Equals(kIFactoryIID)) {
|
|
|
|
*aResult = (void *)(nsIFactory*)this;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*aResult == NULL) {
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
1998-09-18 01:27:22 +04:00
|
|
|
NS_ADDREF_THIS(); // Increase reference count for caller
|
1998-07-19 01:43:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt
|
|
|
|
nsWebShellFactory::AddRef()
|
|
|
|
{
|
|
|
|
return ++mRefCnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt
|
|
|
|
nsWebShellFactory::Release()
|
|
|
|
{
|
|
|
|
if (--mRefCnt == 0) {
|
|
|
|
delete this;
|
|
|
|
return 0; // Don't access mRefCnt after deleting!
|
|
|
|
}
|
|
|
|
return mRefCnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|