Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends
nsDocShell Class Reference

#include <nsDocShell.h>

Inheritance diagram for nsDocShell:
Inheritance graph
[legend]
Collaboration diagram for nsDocShell:
Collaboration graph
[legend]

List of all members.

Classes

class  InterfaceRequestorProxy

Public Member Functions

 nsDocShell ()
virtual nsresult Init ()
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOCSHELL
NS_DECL_NSIDOCSHELL_MOZILLA_1_8_BRANCH
NS_DECL_NSIDOCSHELL_MOZILLA_1_8_BRANCH2
NS_DECL_NSIDOCSHELL_MOZILLA_1_8_BRANCH3
NS_DECL_NSIDOCSHELLTREEITEM
NS_DECL_NSIDOCSHELLTREENODE
NS_DECL_NSIDOCSHELLHISTORY
NS_DECL_NSIWEBNAVIGATION
NS_DECL_NSIBASEWINDOW
NS_DECL_NSISCROLLABLE
NS_DECL_NSITEXTSCROLL
NS_DECL_NSIDOCCHARSET
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSIREFRESHURI
NS_DECL_NSICONTENTVIEWERCONTAINER
NS_DECL_NSIEDITORDOCSHELL
NS_DECL_NSIWEBPAGEDESCRIPTOR
NS_DECL_NSIAUTHPROMPTPROVIDER
NS_IMETHOD 
Stop ()
nsDocShellInfoLoadType ConvertLoadTypeToDocShellLoadInfo (PRUint32 aLoadType)
PRUint32 ConvertDocShellLoadInfoToLoadType (nsDocShellInfoLoadType aDocShellLoadType)
virtual nsIScriptGlobalObjectGetScriptGlobalObject ()
 Returns the script global object.
nsresult RestoreFromHistory ()
 NS_DEFINE_STATIC_IID_ACCESSOR (NS_THIS_DOCLOADER_IMPL_CID)
NS_DECL_ISUPPORTS
NS_DECL_NSIDOCUMENTLOADER
NS_DECL_NSIPROGRESSEVENTSINK
NS_DECL_NSISECURITYEVENTSINK
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSIWEBPROGRESS
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSICHANNELEVENTSINK
NS_DECL_NSISUPPORTSPRIORITY
nsresult 
RemoveChildLoader (nsDocLoader *aChild)
nsresult AddChildLoader (nsDocLoader *aChild)
nsDocLoaderGetParent () const
void stop ()
void onStartRequest (in nsIRequest aRequest, in nsISupports aContext)
 Called to signify the beginning of an asynchronous request.
void onStopRequest (in nsIRequest aRequest, in nsISupports aContext, in nsresult aStatusCode)
 Called to signify the end of an asynchronous request.
void onProgress (in nsIRequest aRequest, in nsISupports aContext, in unsigned long long aProgress, in unsigned long long aProgressMax)
 Called to notify the event sink that progress has occurred for the given request.
void onStatus (in nsIRequest aRequest, in nsISupports aContext, in nsresult aStatus, in wstring aStatusArg)
 Called to notify the event sink with a status message for the given request.
void addProgressListener (in nsIWebProgressListener aListener, in unsigned long aNotifyMask)
 Registers a listener to receive web progress events.
void removeProgressListener (in nsIWebProgressListener aListener)
 Removes a previously registered listener of progress events.
void getInterface (in nsIIDRef uuid,[iid_is(uuid), retval] out nsQIResult result)
 Retrieves the specified interface pointer.
void onChannelRedirect (in nsIChannel oldChannel, in nsIChannel newChannel, in unsigned long flags)
 Called when a redirect occurs.
void onSecurityChange (in nsISupports i_Context, in unsigned long state)
 Fired when a security change occurs due to page transitions, or end document load.
void adjustPriority (in long delta)
 This method adjusts the priority attribute by a given delta.
void loadURI (in nsIURI uri, in nsIDocShellLoadInfo loadInfo, in unsigned long aLoadFlags, in boolean firstParty)
 Loads a given URI.
void loadStream (in nsIInputStream aStream, in nsIURI aURI, in ACString aContentType, in ACString aContentCharset, in nsIDocShellLoadInfo aLoadInfo)
 Loads a given stream.
void internalLoad (in nsIURI aURI, in nsIURI aReferrer, in nsISupports aOwner, in PRUint32 aFlags, in wstring aWindowTarget, in string aTypeHint, in nsIInputStream aPostDataStream, in nsIInputStream aHeadersStream, in unsigned long aLoadFlags, in nsISHEntry aSHEntry, in boolean firstParty, out nsIDocShell aDocShell, out nsIRequest aRequest)
 Loads the given URI.
void createLoadInfo (out nsIDocShellLoadInfo loadInfo)
 Creates a DocShellLoadInfo object that you can manipulate and then pass to loadURI.
void prepareForNewContentModel ()
 Reset state to a new content model within the current document and the document viewer.
void setCurrentURI (in nsIURI aURI)
 For editors and suchlike who wish to change the URI associated with the document.
void firePageHideNotification (in boolean isUnload)
 Notify the associated content viewer and all child docshells that they are about to be hidden.
nsISimpleEnumerator getDocShellEnumerator (in long aItemType, in long aDirection)
void tabToTreeOwner (in boolean forward, out boolean tookFocus)
boolean isBeingDestroyed ()
void suspendRefreshURIs ()
 Cancel the XPCOM timers for each meta-refresh URI in this docshell, and this docshell's children, recursively.
void resumeRefreshURIs ()
 Restart the XPCOM timers for each meta-refresh URI in this docshell, and this docshell's children, recursively.
void beginRestore (in nsIContentViewer viewer, in boolean top)
 Begin firing WebProgressListener notifications for restoring a page presentation.
void finishRestore ()
 Finish firing WebProgressListener notifications and DOM events for restoring a page presentation.
void historyPurged (in long numEntries)
 Notification that entries have been removed from the beginning of a nsSHistory which has this as its rootDocShell.
nsIDOMStorage getSessionStorageForURI (in nsIURI uri)
void addSessionStorage (in ACString aDomain, in nsIDOMStorage storage)
boolean nameEquals (in wstring name)
 Compares the provided name against the item's name and returns the appropriate result.
nsIDocShellTreeItem findItemWithName (in wstring name, in nsISupports aRequestor, in nsIDocShellTreeItem aOriginalRequestor)
void setTreeOwner (in nsIDocShellTreeOwner treeOwner)
void addChild (in nsIDocShellTreeItem child)
void removeChild (in nsIDocShellTreeItem child)
nsIDocShellTreeItem getChildAt (in long index)
nsIDocShellTreeItem findChildWithName (in wstring aName, in boolean aRecurse, in boolean aSameType, in nsIDocShellTreeItem aRequestor, in nsIDocShellTreeItem aOriginalRequestor)
nsISHEntry getChildSHEntry (in long aChildOffset)
 Get the SHEntry associated with a child docshell.
void addChildSHEntry (in nsISHEntry aCloneReference, in nsISHEntry aHistoryEntry, in long aChildOffset)
 Add a Child SHEntry for a frameset page.
void goBack ()
 Tells the object to navigate to the previous session history item.
void goForward ()
 Tells the object to navigate to the next session history item.
void gotoIndex (in long index)
 Tells the object to navigate to the session history item at a given index.
void loadURI (in wstring aURI, in unsigned long aLoadFlags, in nsIURI aReferrer, in nsIInputStream aPostData, in nsIInputStream aHeaders)
 Loads a given URI.
void reload (in unsigned long aReloadFlags)
 Tells the Object to reload the current page.
void stop (in unsigned long aStopFlags)
 Stops a load of a URI.
void initWindow (in nativeWindow parentNativeWindow, in nsIWidget parentWidget, in long x, in long y, in long cx, in long cy)
void create ()
void destroy ()
void setPosition (in long x, in long y)
void getPosition (out long x, out long y)
void setSize (in long cx, in long cy, in boolean fRepaint)
void getSize (out long cx, out long cy)
void setPositionAndSize (in long x, in long y, in long cx, in long cy, in boolean fRepaint)
void getPositionAndSize (out long x, out long y, out long cx, out long cy)
void repaint (in boolean force)
 Tell the window to repaint itself.
void setFocus ()
 Give the window focus.
long getCurScrollPos (in long scrollOrientation)
void setCurScrollPos (in long scrollOrientation, in long curPos)
void setCurScrollPosEx (in long curHorizontalPos, in long curVerticalPos)
void getScrollRange (in long scrollOrientation, out long minPos, out long maxPos)
void setScrollRange (in long scrollOrientation, in long minPos, in long maxPos)
void setScrollRangeEx (in long minHorizontalPos, in long maxHorizontalPos, in long minVerticalPos, in long maxVerticalPos)
long getDefaultScrollbarPreferences (in long scrollOrientation)
void setDefaultScrollbarPreferences (in long scrollOrientation, in long scrollbarPref)
void getScrollbarVisibility (out boolean verticalVisible, out boolean horizontalVisible)
void scrollByLines (in long numLines)
 Scroll the view up or down by aNumLines lines.
void scrollByPages (in long numPages)
 Scroll the view up or down by numPages pages.
void embed (in nsIContentViewer aDocViewer, in string aCommand, in nsISupports aExtraInfo)
void setIsPrinting (in boolean aIsPrinting)
 Allows the PrintEngine to make this call on an internal interface to the DocShell.
void refreshURI (in nsIURI aURI, in long aMillis, in boolean aRepeat, in boolean aMetaRefresh)
 Load a uri after waiting for aMillis milliseconds.
void setupRefreshURI (in nsIChannel aChannel)
 Checks the passed in channel to see if there is a refresh header, if there is, will setup a timer to refresh the uri found in the header.
void setupRefreshURIFromHeader (in nsIURI aBaseURI, in ACString aHeader)
 Parses the passed in header string and sets up a refreshURI if a "refresh" header is found.
void cancelRefreshURITimers ()
 Cancels all timer loads.
void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long aStateFlags, in nsresult aStatus)
 Notification indicating the state has changed for one of the requests associated with aWebProgress.
void onProgressChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aCurSelfProgress, in long aMaxSelfProgress, in long aCurTotalProgress, in long aMaxTotalProgress)
 Notification that the progress has changed for one of the requests associated with aWebProgress.
void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI aLocation)
 Called when the location of the window being watched changes.
void onStatusChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsresult aStatus, in wstring aMessage)
 Notification that the status of a request has changed.
void onSecurityChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long aState)
 Notification called for security progress.
void makeEditable (in boolean inWaitForUriLoad)
 Make this docShell editable, setting a flag that causes an editor to get created, either immediately, or after a url has been loaded.
void loadPage (in nsISupports aPageDescriptor, in unsigned long aDisplayType)
 Tells the object to load the page specified by the page descriptor.
nsIAuthPrompt getAuthPrompt (in PRUint32 aPromptReason)
 Request a nsIAuthPrompt interface for the given prompt reason;.

Static Public Member Functions

static already_AddRefed
< nsDocLoader
GetAsDocLoader (nsISupports *aSupports)
static nsISupports * GetAsSupports (nsDocLoader *aDocLoader)
static nsresult AddDocLoaderAsChildOfRoot (nsDocLoader *aDocLoader)

Public Attributes

readonly attribute nsISupports container
readonly attribute nsILoadGroup loadGroup
readonly attribute nsIChannel documentChannel
const unsigned long NOTIFY_STATE_REQUEST = 0x00000001
 The following flags may be combined to form the aNotifyMask parameter for the addProgressListener method.
const unsigned long NOTIFY_STATE_DOCUMENT = 0x00000002
const unsigned long NOTIFY_STATE_NETWORK = 0x00000004
const unsigned long NOTIFY_STATE_WINDOW = 0x00000008
const unsigned long NOTIFY_STATE_ALL = 0x0000000f
const unsigned long NOTIFY_PROGRESS = 0x00000010
 These flags indicate the other events to observe, corresponding to the other four methods defined on nsIWebProgressListener.
const unsigned long NOTIFY_STATUS = 0x00000020
const unsigned long NOTIFY_SECURITY = 0x00000040
const unsigned long NOTIFY_LOCATION = 0x00000080
const unsigned long NOTIFY_ALL = 0x000000ff
 This flag enables all notifications.
readonly attribute nsIDOMWindow DOMWindow
 The DOM window associated with this nsIWebProgress instance.
readonly attribute PRBool isLoadingDocument
 Indicates whether or not a document is currently being loaded in the context of this nsIWebProgress instance.
const unsigned long REDIRECT_TEMPORARY = 1 << 0
 This is a temporary redirect.
const unsigned long REDIRECT_PERMANENT = 1 << 1
 This is a permanent redirect.
const unsigned long REDIRECT_INTERNAL = 1 << 2
 This is an internal redirect, i.e.
const long PRIORITY_HIGHEST = -20
 Typical priority values.
const long PRIORITY_HIGH = -10
const long PRIORITY_NORMAL = 0
const long PRIORITY_LOW = 10
const long PRIORITY_LOWEST = 20
attribute long priority
 This attribute may be modified to change the priority of this object.
const long INTERNAL_LOAD_FLAGS_NONE = 0x0
const long INTERNAL_LOAD_FLAGS_INHERIT_OWNER = 0x1
const long INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER = 0x2
const long INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 0x4
const long INTERNAL_LOAD_FLAGS_FIRST_LOAD = 0x8
readonly attribute nsPresContext presContext
 Presentation context for the currently loaded document.
readonly attribute nsIPresShell presShell
 Presentation shell for the currently loaded document.
readonly attribute nsIPresShell eldestPresShell
 Presentation shell for the oldest document, if this docshell is currently transitioning between documents.
readonly attribute nsIContentViewer contentViewer
 Content Viewer that is currently loaded for this DocShell.
attribute nsIChromeEventHandler chromeEventHandler
 This attribute allows chrome to tie in to handle DOM events that may be of interest to chrome.
attribute nsIDocumentCharsetInfo documentCharsetInfo
 The document charset info.
attribute boolean allowPlugins
 Whether to allow plugin execution.
attribute boolean allowJavascript
 Whether to allow Javascript execution.
attribute boolean allowMetaRedirects
 Attribute stating if refresh based redirects can be allowed.
attribute boolean allowSubframes
 Attribute stating if it should allow subframes (framesets/iframes) or not.
attribute boolean allowImages
 Attribute stating whether or not images should be loaded.
const long ENUMERATE_FORWARDS = 0
 Get an enumerator over this docShell and its children.
const long ENUMERATE_BACKWARDS = 1
const unsigned long APP_TYPE_UNKNOWN = 0
 The type of application that created this window.
const unsigned long APP_TYPE_MAIL = 1
const unsigned long APP_TYPE_EDITOR = 2
attribute unsigned long appType
attribute boolean allowAuth
 certain dochshells (like the message pane) should not throw up auth dialogs because it can act as a password trojan
attribute float zoom
 Set/Get the document scale factor.
attribute long marginWidth
attribute long marginHeight
attribute boolean hasFocus
attribute boolean canvasHasFocus
const unsigned long BUSY_FLAGS_NONE = 0
 Current busy state for DocShell.
const unsigned long BUSY_FLAGS_BUSY = 1
const unsigned long BUSY_FLAGS_BEFORE_PAGE_LOAD = 2
const unsigned long BUSY_FLAGS_PAGE_LOADING = 4
const unsigned long LOAD_CMD_NORMAL = 0x1
 Load commands for the document.
const unsigned long LOAD_CMD_RELOAD = 0x2
const unsigned long LOAD_CMD_HISTORY = 0x4
readonly attribute unsigned long busyFlags
attribute unsigned long loadType
readonly attribute boolean isExecutingOnLoadHandler
attribute nsILayoutHistoryState layoutHistoryState
readonly attribute boolean shouldSaveLayoutState
attribute nsISecureBrowserUI securityUI
 The SecureBrowserUI object for this docshell.
readonly attribute boolean restoringDocument
attribute boolean useErrorPages
readonly attribute long previousTransIndex
 Keeps track of the previous SHTransaction index and the current SHTransaction index at the time that the doc shell begins to load.
readonly attribute long loadedTransIndex
readonly attribute nsIChannel currentDocumentChannel
 Gets the channel for the currently loaded document, if any.
readonly attribute boolean isInUnload
 Find out whether the docshell is currently in the middle of a page transition (after the onunload event has fired, but before the new document has been set up)
readonly attribute boolean channelIsUnsafe
 Find out if the currently loaded document came from a suspicious channel (such as a JAR channel where the server-returned content type isn't a known JAR type).
attribute wstring name
const long typeChrome = 0
const long typeContent = 1
const long typeContentWrapper = 2
const long typeChromeWrapper = 3
const long typeAll = 0x7FFFFFFF
attribute long itemType
readonly attribute
nsIDocShellTreeItem 
parent
readonly attribute
nsIDocShellTreeItem 
sameTypeParent
readonly attribute
nsIDocShellTreeItem 
rootTreeItem
readonly attribute
nsIDocShellTreeItem 
sameTypeRootTreeItem
readonly attribute
nsIDocShellTreeOwner 
treeOwner
attribute long childOffset
readonly attribute long childCount
attribute boolean useGlobalHistory
readonly attribute boolean canGoBack
 Indicates if the object can go back.
readonly attribute boolean canGoForward
 Indicates if the object can go forward.
const unsigned long LOAD_FLAGS_MASK = 0xffff
 This flags defines the range of bits that may be specified.
const unsigned long LOAD_FLAGS_NONE = 0x0000
 This is the default value for the load flags parameter.
const unsigned long LOAD_FLAGS_IS_REFRESH = 0x0010
 This flag specifies that the load should have the semantics of an HTML META refresh (i.e., that the cache should be validated).
const unsigned long LOAD_FLAGS_IS_LINK = 0x0020
 This flag specifies that the load should have the semantics of a link click.
const unsigned long LOAD_FLAGS_BYPASS_HISTORY = 0x0040
 This flag specifies that history should not be updated.
const unsigned long LOAD_FLAGS_REPLACE_HISTORY = 0x0080
 This flag specifies that any existing history entry should be replaced.
const unsigned long LOAD_FLAGS_BYPASS_CACHE = 0x0100
 This flag specifies that the local web cache should be bypassed, but an intermediate proxy cache could still be used to satisfy the load.
const unsigned long LOAD_FLAGS_BYPASS_PROXY = 0x0200
 This flag specifies that any intermediate proxy caches should be bypassed (i.e., that the content should be loaded from the origin server).
const unsigned long LOAD_FLAGS_CHARSET_CHANGE = 0x0400
 This flag specifies that a reload was triggered as a result of detecting an incorrect character encoding while parsing a previously loaded document.
const unsigned long LOAD_FLAGS_STOP_CONTENT = 0x0800
 If this flag is set, Stop() will be called before the load starts and will stop both content and network activity (the default is to only stop network activity).
const unsigned long LOAD_FLAGS_FROM_EXTERNAL = 0x1000
 A hint this load was prompted by an external program: take care!
const unsigned long LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 0x2000
 This flag specifies that the URI may be submitted to a third-party server for correction.
const unsigned long LOAD_FLAGS_FIRST_LOAD = 0x4000
 This flag specifies that this is the first load in this object.
const unsigned long STOP_NETWORK = 0x01
 This flag specifies that all network activity should be stopped.
const unsigned long STOP_CONTENT = 0x02
 This flag specifies that all content activity should be stopped.
const unsigned long STOP_ALL = 0x03
 This flag specifies that all activity should be stopped.
readonly attribute nsIDOMDocument document
 Retrieves the current DOM document for the frame, or lazily creates a blank document if there is none.
readonly attribute nsIURI currentURI
 The currently loaded URI or null.
readonly attribute nsIURI referringURI
 The referring URI for the currently loaded URI or null.
attribute nsISHistory sessionHistory
 The session history object used by this web navigation instance.
attribute nsIWidget parentWidget
attribute nativeWindow parentNativeWindow
attribute boolean visibility
attribute boolean enabled
attribute boolean blurSuppression
 set blurSuppression to true to suppress handling of blur events.
readonly attribute nsIWidget mainWidget
attribute wstring title
const long ScrollOrientation_X = 1
const long ScrollOrientation_Y = 2
const long Scrollbar_Auto = 1
const long Scrollbar_Never = 2
const long Scrollbar_Always = 3
attribute string charset
 Get/sets the encoding (converter) used to read the document.
const unsigned long STATE_START = 0x00000001
 State Transition Flags.
const unsigned long STATE_REDIRECTING = 0x00000002
const unsigned long STATE_TRANSFERRING = 0x00000004
const unsigned long STATE_NEGOTIATING = 0x00000008
const unsigned long STATE_STOP = 0x00000010
const unsigned long STATE_IS_REQUEST = 0x00010000
 State Type Flags.
const unsigned long STATE_IS_DOCUMENT = 0x00020000
const unsigned long STATE_IS_NETWORK = 0x00040000
const unsigned long STATE_IS_WINDOW = 0x00080000
const unsigned long STATE_RESTORING = 0x01000000
 State Modifier Flags.
const unsigned long STATE_IS_INSECURE = 0x00000004
 State Security Flags.
const unsigned long STATE_IS_BROKEN = 0x00000001
const unsigned long STATE_IS_SECURE = 0x00000002
const unsigned long STATE_SECURE_HIGH = 0x00040000
 Security Strength Flags.
const unsigned long STATE_SECURE_MED = 0x00010000
const unsigned long STATE_SECURE_LOW = 0x00020000
attribute nsIEditor editor
readonly attribute boolean editable
readonly attribute boolean hasEditingSession
const unsigned long DISPLAY_AS_SOURCE = 0x0001
const unsigned long DISPLAY_NORMAL = 0x0002
readonly attribute nsISupports currentDescriptor
 Retrieves the page descriptor for the curent document.
const PRUint32 PROMPT_NORMAL = 0
 Normal (non-proxy) prompt request.
const PRUint32 PROMPT_PROXY = 1
 Proxy auth request.

Protected Types

typedef nsresult(* WalkHistoryEntriesFunc )(nsISHEntry *aEntry, nsDocShell *aShell, PRInt32 aChildIndex, void *aData)

Protected Member Functions

virtual ~nsDocShell ()
virtual void DestroyChildren ()
NS_IMETHOD EnsureContentViewer ()
NS_IMETHOD EnsureDeviceContext ()
nsresult CreateAboutBlankContentViewer ()
NS_IMETHOD CreateContentViewer (const char *aContentType, nsIRequest *request, nsIStreamListener **aContentHandler)
NS_IMETHOD NewContentViewerObj (const char *aContentType, nsIRequest *request, nsILoadGroup *aLoadGroup, nsIStreamListener **aContentHandler, nsIContentViewer **aViewer)
NS_IMETHOD SetupNewViewer (nsIContentViewer *aNewViewer)
void SetupReferrerFromChannel (nsIChannel *aChannel)
NS_IMETHOD GetEldestPresContext (nsPresContext **aPresContext)
nsIPrincipalGetInheritedPrincipal (PRBool aConsiderCurrentDocument)
virtual nsresult DoURILoad (nsIURI *aURI, nsIURI *aReferrer, PRBool aSendReferrer, nsISupports *aOwner, const char *aTypeHint, nsIInputStream *aPostData, nsIInputStream *aHeadersData, PRBool firstParty, nsIDocShell **aDocShell, nsIRequest **aRequest, PRBool aIsNewWindowTarget)
NS_IMETHOD AddHeadersToChannel (nsIInputStream *aHeadersData, nsIChannel *aChannel)
virtual nsresult DoChannelLoad (nsIChannel *aChannel, nsIURILoader *aURILoader)
NS_IMETHOD ScrollIfAnchor (nsIURI *aURI, PRBool *aWasAnchor, PRUint32 aLoadType, nscoord *cx, nscoord *cy)
PRBool OnLoadingSite (nsIChannel *aChannel, PRBool aFireOnLocationChange, PRBool aAddToGlobalHistory=PR_TRUE)
PRBool OnNewURI (nsIURI *aURI, nsIChannel *aChannel, PRUint32 aLoadType, PRBool aFireOnLocationChange, PRBool aAddToGlobalHistory=PR_TRUE)
virtual void SetReferrerURI (nsIURI *aURI)
virtual PRBool ShouldAddToSessionHistory (nsIURI *aURI)
virtual nsresult AddToSessionHistory (nsIURI *aURI, nsIChannel *aChannel, nsISHEntry **aNewEntry)
nsresult DoAddChildSHEntry (nsISHEntry *aNewEntry, PRInt32 aChildOffset)
NS_IMETHOD LoadHistoryEntry (nsISHEntry *aEntry, PRUint32 aLoadType)
NS_IMETHOD PersistLayoutHistoryState ()
nsresult GetRootSessionHistory (nsISHistory **aReturn)
nsresult GetHttpChannel (nsIChannel *aChannel, nsIHttpChannel **aReturn)
PRBool ShouldDiscardLayoutState (nsIHttpChannel *aChannel)
PRBool HasHistoryEntry (nsISHEntry *aEntry) const
void SwapHistoryEntries (nsISHEntry *aOldEntry, nsISHEntry *aNewEntry)
void SetHistoryEntry (nsCOMPtr< nsISHEntry > *aPtr, nsISHEntry *aEntry)
virtual void OnRedirectStateChange (nsIChannel *aOldChannel, nsIChannel *aNewChannel, PRUint32 aRedirectFlags, PRUint32 aStateFlags)
nsresult AddToGlobalHistory (nsIURI *aURI, PRBool aRedirect, nsIChannel *aChannel)
NS_IMETHOD GetPromptAndStringBundle (nsIPrompt **aPrompt, nsIStringBundle **aStringBundle)
NS_IMETHOD GetChildOffset (nsIDOMNode *aChild, nsIDOMNode *aParent, PRInt32 *aOffset)
NS_IMETHOD GetRootScrollableView (nsIScrollableView **aOutScrollView)
NS_IMETHOD EnsureScriptEnvironment ()
NS_IMETHOD EnsureEditorData ()
nsresult EnsureTransferableHookData ()
NS_IMETHOD EnsureFind ()
nsresult RefreshURIFromQueue ()
NS_IMETHOD DisplayLoadError (nsresult aError, nsIURI *aURI, const PRUnichar *aURL, nsIChannel *aFailedChannel=nsnull)
NS_IMETHOD LoadErrorPage (nsIURI *aURI, const PRUnichar *aURL, const PRUnichar *aPage, const PRUnichar *aDescription, nsIChannel *aFailedChannel)
PRBool IsNavigationAllowed (PRBool aDisplayPrintErrorDialog=PR_TRUE)
PRBool IsPrintingOrPP (PRBool aDisplayErrorDialog=PR_TRUE)
nsresult SetBaseUrlForWyciwyg (nsIContentViewer *aContentViewer)
PRBool IsFrame ()
virtual nsresult EndPageLoad (nsIWebProgress *aProgress, nsIChannel *aChannel, nsresult aResult)
nsresult CheckLoadingPermissions ()
PRBool SetCurrentURI (nsIURI *aURI, nsIRequest *aRequest, PRBool aFireOnLocationChange)
PRBool CanSavePresentation (PRUint32 aLoadType, nsIRequest *aNewRequest, nsIDocument *aNewDocument)
nsresult CaptureState ()
nsresult RestorePresentation (nsISHEntry *aSHEntry, PRBool *aRestoring)
nsresult BeginRestoreChildren ()
virtual nsresult SetDocLoaderParent (nsDocLoader *aLoader)
void DocLoaderIsEmpty ()
PRBool IsBusy ()
void Destroy ()
nsIDocumentLoaderChildAt (PRInt32 i)
nsIDocumentLoaderSafeChildAt (PRInt32 i)
void FireOnProgressChange (nsDocLoader *aLoadInitiator, nsIRequest *request, PRInt64 aProgress, PRInt64 aProgressMax, PRInt64 aProgressDelta, PRInt64 aTotalProgress, PRInt64 aMaxTotalProgress)
void FireOnStateChange (nsIWebProgress *aProgress, nsIRequest *request, PRInt32 aStateFlags, nsresult aStatus)
void FireOnStatusChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus, const PRUnichar *aMessage)
void FireOnLocationChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *aUri)
void doStartDocumentLoad ()
void doStartURLLoad (nsIRequest *request)
void doStopURLLoad (nsIRequest *request, nsresult aStatus)
void doStopDocumentLoad (nsIRequest *request, nsresult aStatus)

Static Protected Member Functions

static nsresult CloneAndReplace (nsISHEntry *aSrcEntry, nsDocShell *aSrcShell, PRUint32 aCloneID, nsISHEntry *aReplaceEntry, nsISHEntry **aDestEntry)
static nsresult CloneAndReplaceChild (nsISHEntry *aEntry, nsDocShell *aShell, PRInt32 aChildIndex, void *aData)
static nsresult SetChildHistoryEntry (nsISHEntry *aEntry, nsDocShell *aShell, PRInt32 aEntryIndex, void *aData)
static nsresult WalkHistoryEntries (nsISHEntry *aRootEntry, nsDocShell *aRootShell, WalkHistoryEntriesFunc aCallback, void *aData)
static PRUint32 PRTimeToSeconds (PRTime t_usec)
static PRBool CanAccessItem (nsIDocShellTreeItem *aTargetItem, nsIDocShellTreeItem *aAccessingItem, PRBool aConsiderOpener=PR_TRUE)
static PRBool ValidateOrigin (nsIDocShellTreeItem *aOriginTreeItem, nsIDocShellTreeItem *aTargetTreeItem)
static PRBool IsAboutBlank (nsIURI *aURI)

Protected Attributes

PRPackedBool mAllowSubframes
PRPackedBool mAllowPlugins
PRPackedBool mAllowJavascript
PRPackedBool mAllowMetaRedirects
PRPackedBool mAllowImages
PRPackedBool mFocusDocFirst
PRPackedBool mHasFocus
PRPackedBool mCreatingDocument
PRPackedBool mUseErrorPages
PRPackedBool mAllowAuth
PRPackedBool mAllowKeywordFixup
PRPackedBool mFiredUnloadEvent
PRPackedBool mEODForCurrentDocument
PRPackedBool mURIResultedInDocument
PRPackedBool mIsBeingDestroyed
PRPackedBool mIsExecutingOnLoadHandler
PRPackedBool mIsPrintingOrPP
PRPackedBool mSavingOldViewer
PRUint32 mAppType
PRInt32 mChildOffset
PRUint32 mBusyFlags
PRInt32 mMarginWidth
PRInt32 mMarginHeight
PRInt32 mItemType
PRUint32 mLoadType
nsString mName
nsString mTitle
nsCString mContentTypeHint
 Content-Type Hint of the most-recently initiated load.
nsCOMPtr< nsISupportsArraymRefreshURIList
nsCOMPtr< nsISupportsArraymSavedRefreshURIList
nsRefPtr< nsDSURIContentListenermContentListener
nsRect mBounds
nsCOMPtr< nsIContentViewermContentViewer
nsCOMPtr< nsIDocumentCharsetInfomDocumentCharsetInfo
nsCOMPtr< nsIDeviceContextmDeviceContext
nsCOMPtr< nsIWidgetmParentWidget
nsCOMPtr< nsIPrefBranchmPrefs
nsCOMPtr< nsIURImCurrentURI
nsCOMPtr< nsIURImReferrerURI
nsCOMPtr< nsIScriptGlobalObjectmScriptGlobal
nsCOMPtr< nsISHistorymSessionHistory
nsCOMPtr< nsIGlobalHistory2mGlobalHistory
nsCOMPtr< nsIWebBrowserFindmFind
nsPoint mDefaultScrollbarPref
nsCOMPtr< nsISHEntrymOSHE
nsCOMPtr< nsISHEntrymLSHE
nsInterfaceHashtable
< nsCStringHashKey,
nsIDOMStorage
mStorages
PRInt32 mPreviousTransIndex
PRInt32 mLoadedTransIndex
nsDocShellEditorDatamEditorData
nsCOMPtr
< nsIClipboardDragDropHookList
mTransferableHookData
nsCOMPtr< nsISecureBrowserUImSecurityUI
nsIDocShellTreeOwnermTreeOwner
nsIChromeEventHandlermChromeEventHandler
nsCOMPtr< nsIRequestmDocumentRequest
nsDocLoadermParent
nsVoidArray mListenerInfoList
PRBool mIsLoadingDocument
nsCOMPtr< nsILoadGroupmLoadGroup
nsVoidArray mChildList
PRInt32 mProgressStateFlags
nsInt64 mCurrentSelfProgress
nsInt64 mMaxSelfProgress
nsInt64 mCurrentTotalProgress
nsInt64 mMaxTotalProgress
PLDHashTable mRequestInfoHash
PRBool mIsRestoringDocument

Static Protected Attributes

static nsIURIFixupsURIFixup = 0

Friends

class nsDSURIContentListener

Detailed Description

Definition at line 142 of file nsDocShell.h.


Member Typedef Documentation

typedef nsresult(* nsDocShell::WalkHistoryEntriesFunc)(nsISHEntry *aEntry, nsDocShell *aShell, PRInt32 aChildIndex, void *aData) [protected]

Definition at line 337 of file nsDocShell.h.


Constructor & Destructor Documentation

Definition at line 252 of file nsDocShell.cpp.

Here is the call graph for this function:

nsDocShell::~nsDocShell ( ) [protected, virtual]

Definition at line 304 of file nsDocShell.cpp.

{
    nsDocShellFocusController* dsfc = nsDocShellFocusController::GetInstance();
    if (dsfc) {
      dsfc->ClosingDown(this);
    }
    Destroy();

    if (--gDocShellCount == 0) {
        NS_IF_RELEASE(sURIFixup);
    }

#ifdef PR_LOGGING
    if (gDocShellLeakLog)
        PR_LOG(gDocShellLeakLog, PR_LOG_DEBUG, ("DOCSHELL %p destroyed\n", this));
#endif
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 682 of file nsDocLoader.cpp.

{
  nsresult rv = mChildList.AppendElement(aChild) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
  if (NS_SUCCEEDED(rv)) {
    aChild->SetDocLoaderParent(this);
  }
  return rv;
}

Here is the call graph for this function:

void nsIDocShellHistory::addChildSHEntry ( in nsISHEntry  aCloneReference,
in nsISHEntry  aHistoryEntry,
in long  aChildOffset 
) [inherited]

Add a Child SHEntry for a frameset page.

nsresult nsDocLoader::AddDocLoaderAsChildOfRoot ( nsDocLoader aDocLoader) [static, inherited]

Definition at line 278 of file nsDocLoader.cpp.

{
  nsresult rv;
  nsCOMPtr<nsIDocumentLoader> docLoaderService =
    do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  nsRefPtr<nsDocLoader> rootDocLoader = GetAsDocLoader(docLoaderService);
  NS_ENSURE_TRUE(rootDocLoader, NS_ERROR_UNEXPECTED);

  return rootDocLoader->AddChildLoader(aDocLoader);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsDocShell::AddHeadersToChannel ( nsIInputStream aHeadersData,
nsIChannel aChannel 
) [protected]

Definition at line 7179 of file nsDocShell.cpp.

{
    nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aGenericChannel);
    NS_ENSURE_STATE(httpChannel);

    PRUint32 numRead;
    nsCAutoString headersString;
    nsresult rv = aHeadersData->ReadSegments(AppendSegmentToString,
                                             &headersString,
                                             PR_UINT32_MAX,
                                             &numRead);
    NS_ENSURE_SUCCESS(rv, rv);

    // used during the manipulation of the String from the InputStream
    nsCAutoString headerName;
    nsCAutoString headerValue;
    PRInt32 crlf;
    PRInt32 colon;

    //
    // Iterate over the headersString: for each "\r\n" delimited chunk,
    // add the value as a header to the nsIHttpChannel
    //

    static const char kWhitespace[] = "\b\t\r\n ";
    while (PR_TRUE) {
        crlf = headersString.Find("\r\n");
        if (crlf == kNotFound)
            return NS_OK;

        const nsCSubstring &oneHeader = StringHead(headersString, crlf);

        colon = oneHeader.FindChar(':');
        if (colon == kNotFound)
            return NS_ERROR_UNEXPECTED;

        headerName = StringHead(oneHeader, colon);
        headerValue = Substring(oneHeader, colon + 1);

        headerName.Trim(kWhitespace);
        headerValue.Trim(kWhitespace);

        headersString.Cut(0, crlf + 2);

        //
        // FINALLY: we can set the header!
        // 

        rv = httpChannel->SetRequestHeader(headerName, headerValue, PR_TRUE);
        NS_ENSURE_SUCCESS(rv, rv);
    }

    NS_NOTREACHED("oops");
    return NS_ERROR_UNEXPECTED;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIWebProgress::addProgressListener ( in nsIWebProgressListener  aListener,
in unsigned long  aNotifyMask 
) [inherited]

Registers a listener to receive web progress events.

Parameters:
aListenerThe listener interface to be called when a progress event occurs. This object must also implement nsISupportsWeakReference.
aNotifyMaskThe types of notifications to receive.
Exceptions:
NS_ERROR_INVALID_ARGIndicates that aListener was either null or that it does not support weak references.
NS_ERROR_FAILUREIndicates that aListener was already registered.
void nsIDocShell_MOZILLA_1_8_BRANCH::addSessionStorage ( in ACString  aDomain,
in nsIDOMStorage  storage 
) [inherited]
nsresult nsDocShell::AddToGlobalHistory ( nsIURI aURI,
PRBool  aRedirect,
nsIChannel aChannel 
) [protected]

Definition at line 8417 of file nsDocShell.cpp.

{
    if (mItemType != typeContent || !mGlobalHistory)
        return NS_OK;

    PRBool visited;
    nsresult rv = mGlobalHistory->IsVisited(aURI, &visited);
    if (NS_FAILED(rv))
        return rv;

    // Get referrer from the channel. We have to check for a property on a
    // property bag because the referrer may be empty for security reasons (for
    // example, when loading a http page with a https referrer).
    nsCOMPtr<nsIURI> referrer;
    nsCOMPtr<nsIPropertyBag2> props(do_QueryInterface(aChannel));
    if (props) {
        props->GetPropertyAsInterface(NS_LITERAL_STRING("docshell.internalReferrer"),
                                      NS_GET_IID(nsIURI),
                                      getter_AddRefs(referrer));
    }

    rv = mGlobalHistory->AddURI(aURI, aRedirect, !IsFrame(), referrer);
    if (NS_FAILED(rv))
        return rv;

    if (!visited) {
        nsCOMPtr<nsIObserverService> obsService =
            do_GetService("@mozilla.org/observer-service;1");
        if (obsService) {
            obsService->NotifyObservers(aURI, NS_LINK_VISITED_EVENT_TOPIC, nsnull);
        }
    }

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsDocShell::AddToSessionHistory ( nsIURI aURI,
nsIChannel aChannel,
nsISHEntry **  aNewEntry 
) [protected, virtual]

Definition at line 7734 of file nsDocShell.cpp.

{
#if defined(PR_LOGGING) && defined(DEBUG)
    if (PR_LOG_TEST(gDocShellLog, PR_LOG_DEBUG)) {
        nsCAutoString spec;
        aURI->GetSpec(spec);

        nsCAutoString chanName;
        if (aChannel)
            aChannel->GetName(chanName);
        else
            chanName.AssignLiteral("<no channel>");

        PR_LOG(gDocShellLog, PR_LOG_DEBUG,
               ("nsDocShell[%p]::AddToSessionHistory(\"%s\", [%s])\n", this, spec.get(),
                chanName.get()));
    }
#endif

    nsresult rv = NS_OK;
    nsCOMPtr<nsISHEntry_MOZILLA_1_8_BRANCH> entry;
    PRBool shouldPersist;

    shouldPersist = ShouldAddToSessionHistory(aURI);

    // Get a handle to the root docshell 
    nsCOMPtr<nsIDocShellTreeItem> root;
    GetSameTypeRootTreeItem(getter_AddRefs(root));     
    /*
     * If this is a LOAD_FLAGS_REPLACE_HISTORY in a subframe, we use
     * the existing SH entry in the page and replace the url and
     * other vitalities.
     */
    if (LOAD_TYPE_HAS_FLAGS(mLoadType, LOAD_FLAGS_REPLACE_HISTORY) &&
        root != NS_STATIC_CAST(nsIDocShellTreeItem *, this)) {
        // This is a subframe 
        entry = do_QueryInterface(mOSHE);
        nsCOMPtr<nsISHContainer> shContainer(do_QueryInterface(entry));
        if (shContainer) {
            PRInt32 childCount = 0;
            shContainer->GetChildCount(&childCount);
            // Remove all children of this entry 
            for (PRInt32 i = childCount - 1; i >= 0; i--) {
                nsCOMPtr<nsISHEntry> child;
                shContainer->GetChildAt(i, getter_AddRefs(child));
                shContainer->RemoveChild(child);
            }  // for
        }  // shContainer
    }

    // Create a new entry if necessary.
    if (!entry) {
        entry = do_CreateInstance(NS_SHENTRY_CONTRACTID);

        if (!entry) {
            return NS_ERROR_OUT_OF_MEMORY;
        }
    }

    // Get the post data & referrer
    nsCOMPtr<nsIInputStream> inputStream;
    nsCOMPtr<nsIURI> referrerURI;
    nsCOMPtr<nsISupports> cacheKey;
    nsCOMPtr<nsISupports> cacheToken;
    nsCOMPtr<nsISupports> owner;
    PRBool expired = PR_FALSE;
    PRBool discardLayoutState = PR_FALSE;
    if (aChannel) {
        nsCOMPtr<nsICachingChannel>
            cacheChannel(do_QueryInterface(aChannel));
        /* If there is a caching channel, get the Cache Key  and store it 
         * in SH.
         */
        if (cacheChannel) {
            cacheChannel->GetCacheKey(getter_AddRefs(cacheKey));
            cacheChannel->GetCacheToken(getter_AddRefs(cacheToken));
        }
        nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aChannel));
        
        // Check if the httpChannel is hiding under a multipartChannel
        if (!httpChannel) {
            GetHttpChannel(aChannel, getter_AddRefs(httpChannel));
        }
        if (httpChannel) {
            nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(httpChannel));
            if (uploadChannel) {
                uploadChannel->GetUploadStream(getter_AddRefs(inputStream));
            }
            httpChannel->GetReferrer(getter_AddRefs(referrerURI));

            discardLayoutState = ShouldDiscardLayoutState(httpChannel);
        }
        aChannel->GetOwner(getter_AddRefs(owner));
    }

    //Title is set in nsDocShell::SetTitle()
    entry->Create_MOZILLA_1_8_BRANCH(aURI,              // uri
                                     EmptyString(),     // Title
                                     inputStream,       // Post data stream
                                     nsnull,            // LayoutHistory state
                                     cacheKey,          // CacheKey
                                     mContentTypeHint,  // Content-type
                                     owner);            // Channel owner
    entry->SetReferrerURI(referrerURI);
    /* If cache got a 'no-store', ask SH not to store
     * HistoryLayoutState. By default, SH will set this
     * flag to PR_TRUE and save HistoryLayoutState.
     */    
    if (discardLayoutState) {
        entry->SetSaveLayoutStateFlag(PR_FALSE);
    }
    if (cacheToken) {
        // Check if the page has expired from cache 
        nsCOMPtr<nsICacheEntryInfo> cacheEntryInfo(do_QueryInterface(cacheToken));
        if (cacheEntryInfo) {        
            PRUint32 expTime;         
            cacheEntryInfo->GetExpirationTime(&expTime);         
            PRUint32 now = PRTimeToSeconds(PR_Now());                  
            if (expTime <=  now)            
                expired = PR_TRUE;         
         
        }
    }
    if (expired == PR_TRUE)
        entry->SetExpirationStatus(PR_TRUE);


    if (root == NS_STATIC_CAST(nsIDocShellTreeItem *, this) && mSessionHistory) {
        // This is the root docshell
        if (LOAD_TYPE_HAS_FLAGS(mLoadType, LOAD_FLAGS_REPLACE_HISTORY)) {            
            // Replace current entry in session history.
            PRInt32  index = 0;   
            mSessionHistory->GetIndex(&index);
            nsCOMPtr<nsISHistoryInternal>   shPrivate(do_QueryInterface(mSessionHistory));
            // Replace the current entry with the new entry
            if (shPrivate)
                rv = shPrivate->ReplaceEntry(index, entry);          
        }
        else {
            // Add to session history
            nsCOMPtr<nsISHistoryInternal>
                shPrivate(do_QueryInterface(mSessionHistory));
            NS_ENSURE_TRUE(shPrivate, NS_ERROR_FAILURE);
            mSessionHistory->GetIndex(&mPreviousTransIndex);
            rv = shPrivate->AddEntry(entry, shouldPersist);
            mSessionHistory->GetIndex(&mLoadedTransIndex);
#ifdef DEBUG_PAGE_CACHE
            printf("Previous index: %d, Loaded index: %d\n\n",
                   mPreviousTransIndex, mLoadedTransIndex);
#endif
        }
    }
    else {  
        // This is a subframe.
        if (!mOSHE || !LOAD_TYPE_HAS_FLAGS(mLoadType,
                                           LOAD_FLAGS_REPLACE_HISTORY))
            rv = DoAddChildSHEntry(entry, mChildOffset);
    }

    // Return the new SH entry...
    if (aNewEntry) {
        *aNewEntry = nsnull;
        if (NS_SUCCEEDED(rv)) {
            *aNewEntry = entry;
            NS_ADDREF(*aNewEntry);
        }
    }

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

This method adjusts the priority attribute by a given delta.

It helps reduce the amount of coding required to increment or decrement the value of the priority attribute.

void nsIDocShell::beginRestore ( in nsIContentViewer  viewer,
in boolean  top 
) [inherited]

Begin firing WebProgressListener notifications for restoring a page presentation.

|viewer| is the content viewer whose document we are starting to load. If null, it defaults to the docshell's current content viewer, creating one if necessary. |top| should be true for the toplevel docshell that is being restored; it will be set to false when this method is called for child docshells. This method will post an event to complete the simulated load after returning to the event loop.

Definition at line 5294 of file nsDocShell.cpp.

{
    PRInt32 n = mChildList.Count();
    for (PRInt32 i = 0; i < n; ++i) {
        nsCOMPtr<nsIDocShell> child = do_QueryInterface(ChildAt(i));
        if (child) {
            nsresult rv = child->BeginRestore(nsnull, PR_FALSE);
            NS_ENSURE_SUCCESS(rv, rv);
        }
    }
    return NS_OK;
}

Here is the call graph for this function:

PRBool nsDocShell::CanAccessItem ( nsIDocShellTreeItem aTargetItem,
nsIDocShellTreeItem aAccessingItem,
PRBool  aConsiderOpener = PR_TRUE 
) [static, protected]

Definition at line 1990 of file nsDocShell.cpp.

{
    NS_PRECONDITION(aTargetItem, "Must have target item!");

    if (!gValidateOrigin || !aAccessingItem) {
        // Good to go
        return PR_TRUE;
    }

    // XXXbz should we care if aAccessingItem or the document therein is
    // chrome?  Should those get extra privileges?

    // Now do a security check
    // Bug 13871: Prevent frameset spoofing
    //     See BugSplat 336170, 338737 and XP_FindNamedContextInList in
    //     the classic codebase
    //     Nav's behaviour was:
    //         - pref controlled: "browser.frame.validate_origin" 
    //           (gValidateOrigin)
    //         - allow load if host of target or target's parent is same
    //           as host of origin
    //         - allow load if target is a top level window
    
    //     We are going to be a little more restrictive, with the
    //     following algorithm:
    //         - pref controlled in the same way
    //         - allow access if the two treeitems are in the same tree
    //         - allow access if the aTargetItem or one of its ancestors
    //           has the same origin as aAccessingItem
    //         - allow access if the target is a toplevel window and we can
    //           access its opener.  Note that we only allow one level of
    //           recursion there.

    nsCOMPtr<nsIDocShellTreeItem> targetRoot;
    aTargetItem->GetSameTypeRootTreeItem(getter_AddRefs(targetRoot));

    nsCOMPtr<nsIDocShellTreeItem> accessingRoot;
    aAccessingItem->GetSameTypeRootTreeItem(getter_AddRefs(accessingRoot));

    if (targetRoot == accessingRoot) {
        return PR_TRUE;
    }

    nsCOMPtr<nsIDocShellTreeItem> target = aTargetItem;
    do {
        if (ValidateOrigin(aAccessingItem, target)) {
            return PR_TRUE;
        }
            
        nsCOMPtr<nsIDocShellTreeItem> parent;
        target->GetSameTypeParent(getter_AddRefs(parent));
        parent.swap(target);
    } while (target);

    if (aTargetItem != targetRoot) {
        // target is a subframe, not in accessor's frame hierarchy, and all its
        // ancestors have origins different from that of the accessor. Don't
        // allow access.
        return PR_FALSE;
    }

    if (!aConsiderOpener) {
        // All done here
        return PR_FALSE;
    }

    nsCOMPtr<nsIDOMWindow> targetWindow(do_GetInterface(aTargetItem));
    nsCOMPtr<nsIDOMWindowInternal> targetInternal(do_QueryInterface(targetWindow));
    if (!targetInternal) {
        NS_ERROR("This should not happen, really");
        return PR_FALSE;
    }

    nsCOMPtr<nsIDOMWindowInternal> targetOpener;
    targetInternal->GetOpener(getter_AddRefs(targetOpener));
    nsCOMPtr<nsIWebNavigation> openerWebNav(do_GetInterface(targetOpener));
    nsCOMPtr<nsIDocShellTreeItem> openerItem(do_QueryInterface(openerWebNav));

    if (!openerItem) {
        return PR_FALSE;
    }

    return CanAccessItem(openerItem, aAccessingItem, PR_FALSE);    
}

Here is the call graph for this function:

Cancels all timer loads.

PRBool nsDocShell::CanSavePresentation ( PRUint32  aLoadType,
nsIRequest aNewRequest,
nsIDocument aNewDocument 
) [protected]

Definition at line 5082 of file nsDocShell.cpp.

{
    if (!mOSHE)
        return PR_FALSE; // no entry to save into

    // Only save presentation for "normal" loads and link loads.  Anything else
    // probably wants to refetch the page, so caching the old presentation
    // would be incorrect.
    if (aLoadType != LOAD_NORMAL &&
        aLoadType != LOAD_HISTORY &&
        aLoadType != LOAD_LINK &&
        aLoadType != LOAD_STOP_CONTENT &&
        aLoadType != LOAD_STOP_CONTENT_AND_REPLACE &&
        aLoadType != LOAD_ERROR_PAGE)
        return PR_FALSE;

    // If the session history entry has the saveLayoutState flag set to false,
    // then we should not cache the presentation.
    PRBool canSaveState;
    mOSHE->GetSaveLayoutStateFlag(&canSaveState);
    if (canSaveState == PR_FALSE)
        return PR_FALSE;

    // If the document is not done loading, don't cache it.
    nsCOMPtr<nsPIDOMWindow> pWin = do_QueryInterface(mScriptGlobal);
    if (!pWin || pWin->IsLoading())
        return PR_FALSE;

    if (pWin->WouldReuseInnerWindow(aNewDocument))
        return PR_FALSE;

    // Avoid doing the work of saving the presentation state in the case where
    // the content viewer cache is disabled.
    nsCOMPtr<nsISHistory> rootSH;
    GetRootSessionHistory(getter_AddRefs(rootSH));
    if (rootSH) {
      nsCOMPtr<nsISHistoryInternal> shistInt(do_QueryInterface(rootSH));
      PRInt32 maxViewers;
      shistInt->GetHistoryMaxTotalViewers(&maxViewers);
      if (maxViewers == 0)
        return PR_FALSE;
    }

    // Don't cache the content viewer if we're in a subframe and the subframe
    // pref is disabled.
    PRBool cacheFrames = PR_FALSE;
    mPrefs->GetBoolPref("browser.sessionhistory.cache_subframes",
                        &cacheFrames);
    if (!cacheFrames) {
        nsCOMPtr<nsIDocShellTreeItem> root;
        GetSameTypeParent(getter_AddRefs(root));
        if (root && root != this) {
            return PR_FALSE;  // this is a subframe load
        }
    }

    // If the document does not want its presentation cached, then don't.
    nsCOMPtr<nsIDocument> doc = do_QueryInterface(pWin->GetExtantDocument());
    if (!doc || !doc->CanSavePresentation(aNewRequest))
        return PR_FALSE;

    return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 5149 of file nsDocShell.cpp.

{
    if (!mOSHE || mOSHE == mLSHE) {
        // No entry to save into, or we're replacing the existing entry.
        return NS_ERROR_FAILURE;
    }

    nsCOMPtr<nsPIDOMWindow> privWin = do_QueryInterface(mScriptGlobal);
    if (!privWin)
        return NS_ERROR_FAILURE;

    nsCOMPtr<nsISupports> windowState;
    nsresult rv = privWin->SaveWindowState(getter_AddRefs(windowState));
    NS_ENSURE_SUCCESS(rv, rv);

#ifdef DEBUG_PAGE_CACHE
    nsCOMPtr<nsIURI> uri;
    mOSHE->GetURI(getter_AddRefs(uri));
    nsCAutoString spec;
    if (uri)
        uri->GetSpec(spec);
    printf("Saving presentation into session history\n");
    printf("  SH URI: %s\n", spec.get());
#endif

    rv = mOSHE->SetWindowState(windowState);
    NS_ENSURE_SUCCESS(rv, rv);

    // Suspend refresh URIs and save off the timer queue
    rv = mOSHE->SetRefreshURIList(mSavedRefreshURIList);
    NS_ENSURE_SUCCESS(rv, rv);

    // Capture the current content viewer bounds.
    nsCOMPtr<nsIPresShell> shell;
    nsDocShell::GetPresShell(getter_AddRefs(shell));
    if (shell) {
        nsIViewManager *vm = shell->GetViewManager();
        if (vm) {
            nsIView *rootView = nsnull;
            vm->GetRootView(rootView);
            if (rootView) {
                nsIWidget *widget = rootView->GetWidget();
                if (widget) {
                    nsRect bounds(0, 0, 0, 0);
                    widget->GetBounds(bounds);
                    rv = mOSHE->SetViewerBounds(bounds);
                }
            }
        }
    }

    // Capture the docshell hierarchy.
    mOSHE->ClearChildShells();

    PRInt32 childCount = mChildList.Count();
    for (PRInt32 i = 0; i < childCount; ++i) {
        nsCOMPtr<nsIDocShellTreeItem> childShell = do_QueryInterface(ChildAt(i));
        NS_ASSERTION(childShell, "null child shell");

        mOSHE->AddChildShell(childShell);
    }

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 6232 of file nsDocShell.cpp.

{
    // This method checks whether the caller may load content into
    // this docshell. Even though we've done our best to hide windows
    // from code that doesn't have the right to access them, it's
    // still possible for an evil site to open a window and access
    // frames in the new window through window.frames[] (which is
    // allAccess for historic reasons), so we still need to do this
    // check on load.
    nsresult rv = NS_OK, sameOrigin = NS_OK;

    if (!gValidateOrigin || !IsFrame()) {
        // Origin validation was turned off, or we're not a frame.
        // Permit all loads.

        return rv;
    }

    // We're a frame. Check that the caller has write permission to
    // the parent before allowing it to load anything into this
    // docshell.

    nsCOMPtr<nsIScriptSecurityManager> securityManager =
        do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
    NS_ENSURE_SUCCESS(rv, rv);

    PRBool ubwEnabled = PR_FALSE;
    rv = securityManager->IsCapabilityEnabled("UniversalBrowserWrite",
                                              &ubwEnabled);
    if (NS_FAILED(rv) || ubwEnabled) {
        return rv;
    }

    nsCOMPtr<nsIPrincipal> subjPrincipal;
    rv = securityManager->GetSubjectPrincipal(getter_AddRefs(subjPrincipal));
    NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && subjPrincipal, rv);

    // Check if the caller is from the same origin as this docshell,
    // or any of it's ancestors.
    nsCOMPtr<nsIDocShellTreeItem> item(this);
    do {
        nsCOMPtr<nsIScriptGlobalObject> sgo(do_GetInterface(item));
        nsCOMPtr<nsIScriptObjectPrincipal> sop(do_QueryInterface(sgo));

        nsIPrincipal *p;
        if (!sop || !(p = sop->GetPrincipal())) {
            return NS_ERROR_UNEXPECTED;
        }

        // Compare origins
        sameOrigin =
            securityManager->CheckSameOriginPrincipal(subjPrincipal, p);
        if (NS_SUCCEEDED(sameOrigin)) {
            // Same origin, permit load

            return sameOrigin;
        }

        nsCOMPtr<nsIDocShellTreeItem> tmp;
        item->GetSameTypeParent(getter_AddRefs(tmp));
        item.swap(tmp);
    } while (item);

    // The caller is not from the same origin as this item, or any if
    // this items ancestors. Only permit loading content if both are
    // part of the same window, assuming we can find the window of the
    // caller.

    nsCOMPtr<nsIJSContextStack> stack =
        do_GetService("@mozilla.org/js/xpc/ContextStack;1");
    if (!stack) {
        // No context stack available. Should never happen, but in
        // case it does, return the sameOrigin error from the security
        // check above.

        return sameOrigin;
    }

    JSContext *cx = nsnull;
    stack->Peek(&cx);

    if (!cx) {
        // No caller docshell reachable, return the sameOrigin error
        // from the security check above.

        return sameOrigin;
    }

    nsIScriptContext *currentCX = GetScriptContextFromJSContext(cx);
    nsCOMPtr<nsIDocShellTreeItem> callerTreeItem;
    nsIScriptGlobalObject *sgo;
    if (currentCX &&
        (sgo = currentCX->GetGlobalObject()) &&
        (callerTreeItem = do_QueryInterface(sgo->GetDocShell()))) {
        nsCOMPtr<nsIDocShellTreeItem> callerRoot;
        callerTreeItem->GetSameTypeRootTreeItem(getter_AddRefs(callerRoot));

        nsCOMPtr<nsIDocShellTreeItem> ourRoot;
        GetSameTypeRootTreeItem(getter_AddRefs(ourRoot));

        if (ourRoot == callerRoot) {
            // The running JS is in the same window as the target
            // frame, permit load.
            sameOrigin = NS_OK;
        }
    }

    return sameOrigin;
}

Here is the call graph for this function:

nsIDocumentLoader* nsDocLoader::ChildAt ( PRInt32  i) [inline, protected, inherited]

Definition at line 146 of file nsDocLoader.h.

Here is the caller graph for this function:

nsresult nsDocShell::CloneAndReplace ( nsISHEntry aSrcEntry,
nsDocShell aSrcShell,
PRUint32  aCloneID,
nsISHEntry aReplaceEntry,
nsISHEntry **  aDestEntry 
) [static, protected]

Definition at line 8159 of file nsDocShell.cpp.

{
    NS_ENSURE_ARG_POINTER(aResultEntry);
    NS_ENSURE_TRUE(aReplaceEntry, NS_ERROR_FAILURE);

    CloneAndReplaceData data(aCloneID, aReplaceEntry, nsnull);
    nsresult rv = CloneAndReplaceChild(aSrcEntry, aSrcShell, 0, &data);

    data.resultEntry.swap(*aResultEntry);
    return rv;
}

Here is the call graph for this function:

nsresult nsDocShell::CloneAndReplaceChild ( nsISHEntry aEntry,
nsDocShell aShell,
PRInt32  aChildIndex,
void aData 
) [static, protected]

Definition at line 8112 of file nsDocShell.cpp.

{
    nsresult result = NS_OK;
    nsCOMPtr<nsISHEntry> dest;

    CloneAndReplaceData *data = NS_STATIC_CAST(CloneAndReplaceData*, aData);
    PRUint32 cloneID = data->cloneID;
    nsISHEntry *replaceEntry = data->replaceEntry;

    PRUint32 srcID;
    aEntry->GetID(&srcID);

    if (srcID == cloneID) {
        // Just replace the entry, and don't walk the children.
        dest = replaceEntry;
        dest->SetIsSubFrame(PR_TRUE);
    } else {
        // Clone the SHEntry...
        result = aEntry->Clone(getter_AddRefs(dest));
        if (NS_FAILED(result))
            return result;

        // This entry is for a subframe navigation
        dest->SetIsSubFrame(PR_TRUE);

        // Walk the children
        CloneAndReplaceData childData(cloneID, replaceEntry, dest);
        result = WalkHistoryEntries(aEntry, aShell,
                                    CloneAndReplaceChild, &childData);
        if (NS_FAILED(result))
            return result;

        if (aShell)
            aShell->SwapHistoryEntries(aEntry, dest);
    }

    nsCOMPtr<nsISHContainer> container =
        do_QueryInterface(data->destTreeParent);
    if (container)
        container->AddChild(dest, aEntryIndex);

    data->resultEntry = dest;
    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 518 of file nsDocShell.cpp.

{
    PRUint32 loadType = LOAD_NORMAL;

    switch (aDocShellLoadType) {
    case nsIDocShellLoadInfo::loadNormal:
        loadType = LOAD_NORMAL;
        break;
    case nsIDocShellLoadInfo::loadNormalReplace:
        loadType = LOAD_NORMAL_REPLACE;
        break;
    case nsIDocShellLoadInfo::loadNormalExternal:
        loadType = LOAD_NORMAL_EXTERNAL;
        break;
    case nsIDocShellLoadInfo::loadHistory:
        loadType = LOAD_HISTORY;
        break;
    case nsIDocShellLoadInfo::loadReloadNormal:
        loadType = LOAD_RELOAD_NORMAL;
        break;
    case nsIDocShellLoadInfo::loadReloadCharsetChange:
        loadType = LOAD_RELOAD_CHARSET_CHANGE;
        break;
    case nsIDocShellLoadInfo::loadReloadBypassCache:
        loadType = LOAD_RELOAD_BYPASS_CACHE;
        break;
    case nsIDocShellLoadInfo::loadReloadBypassProxy:
        loadType = LOAD_RELOAD_BYPASS_PROXY;
        break;
    case nsIDocShellLoadInfo::loadReloadBypassProxyAndCache:
        loadType = LOAD_RELOAD_BYPASS_PROXY_AND_CACHE;
        break;
    case nsIDocShellLoadInfo::loadLink:
        loadType = LOAD_LINK;
        break;
    case nsIDocShellLoadInfo::loadRefresh:
        loadType = LOAD_REFRESH;
        break;
    case nsIDocShellLoadInfo::loadBypassHistory:
        loadType = LOAD_BYPASS_HISTORY;
        break;
    case nsIDocShellLoadInfo::loadStopContent:
        loadType = LOAD_STOP_CONTENT;
        break;
    case nsIDocShellLoadInfo::loadStopContentAndReplace:
        loadType = LOAD_STOP_CONTENT_AND_REPLACE;
        break;
    }

    return loadType;
}

Definition at line 572 of file nsDocShell.cpp.

{
    nsDocShellInfoLoadType docShellLoadType = nsIDocShellLoadInfo::loadNormal;
    switch (aLoadType) {
    case LOAD_NORMAL:
        docShellLoadType = nsIDocShellLoadInfo::loadNormal;
        break;
    case LOAD_NORMAL_REPLACE:
        docShellLoadType = nsIDocShellLoadInfo::loadNormalReplace;
        break;
    case LOAD_NORMAL_EXTERNAL:
        docShellLoadType = nsIDocShellLoadInfo::loadNormalExternal;
        break;
    case LOAD_HISTORY:
        docShellLoadType = nsIDocShellLoadInfo::loadHistory;
        break;
    case LOAD_RELOAD_NORMAL:
        docShellLoadType = nsIDocShellLoadInfo::loadReloadNormal;
        break;
    case LOAD_RELOAD_CHARSET_CHANGE:
        docShellLoadType = nsIDocShellLoadInfo::loadReloadCharsetChange;
        break;
    case LOAD_RELOAD_BYPASS_CACHE:
        docShellLoadType = nsIDocShellLoadInfo::loadReloadBypassCache;
        break;
    case LOAD_RELOAD_BYPASS_PROXY:
        docShellLoadType = nsIDocShellLoadInfo::loadReloadBypassProxy;
        break;
    case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
        docShellLoadType = nsIDocShellLoadInfo::loadReloadBypassProxyAndCache;
        break;
    case LOAD_LINK:
        docShellLoadType = nsIDocShellLoadInfo::loadLink;
        break;
    case LOAD_REFRESH:
        docShellLoadType = nsIDocShellLoadInfo::loadRefresh;
        break;
    case LOAD_BYPASS_HISTORY:
    case LOAD_ERROR_PAGE:
        docShellLoadType = nsIDocShellLoadInfo::loadBypassHistory;
        break;
    case LOAD_STOP_CONTENT:
        docShellLoadType = nsIDocShellLoadInfo::loadStopContent;
        break;
    case LOAD_STOP_CONTENT_AND_REPLACE:
        docShellLoadType = nsIDocShellLoadInfo::loadStopContentAndReplace;
        break;
    }

    return docShellLoadType;
}                                                                               
void nsIBaseWindow::create ( ) [inherited]

Definition at line 4991 of file nsDocShell.cpp.

{
  nsCOMPtr<nsIDocument> blankDoc;
  nsCOMPtr<nsIContentViewer> viewer;
  nsresult rv = NS_ERROR_FAILURE;

  /* mCreatingDocument should never be true at this point. However, it's
     a theoretical possibility. We want to know about it and make it stop,
     and this sounds like a job for an assertion. */
  NS_ASSERTION(!mCreatingDocument, "infinite(?) loop creating document averted");
  if (mCreatingDocument)
    return NS_ERROR_FAILURE;

  mCreatingDocument = PR_TRUE;

  // mContentViewer->PermitUnload may release |this| docshell.
  nsCOMPtr<nsIDocShell> kungFuDeathGrip(this);
  
  if (mContentViewer) {
    // We've got a content viewer already. Make sure the user
    // permits us to discard the current document and replace it
    // with about:blank. And also ensure we fire the unload events
    // in the current document.

    PRBool okToUnload;
    rv = mContentViewer->PermitUnload(&okToUnload);

    if (NS_SUCCEEDED(rv) && !okToUnload) {
      // The user chose not to unload the page, interrupt the load.
      return NS_ERROR_FAILURE;
    }

    mSavingOldViewer = CanSavePresentation(LOAD_NORMAL, nsnull, nsnull);

    // Notify the current document that it is about to be unloaded!!
    //
    // It is important to fire the unload() notification *before* any state
    // is changed within the DocShell - otherwise, javascript will get the
    // wrong information :-(
    //
    (void) FirePageHideNotification(!mSavingOldViewer);
  }

  // Now make sure we don't think we're in the middle of firing unload after
  // this point.  This will make us fire unload when the about:blank document
  // unloads... but that's ok, more or less.  Would be nice if it fired load
  // too, of course.
  mFiredUnloadEvent = PR_FALSE;

  // one helper factory, please
  nsCOMPtr<nsICategoryManager> catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
  if (!catMan)
    return NS_ERROR_FAILURE;

  nsXPIDLCString contractId;
  rv = catMan->GetCategoryEntry("Gecko-Content-Viewers", "text/html", getter_Copies(contractId));
  if (NS_FAILED(rv))
    return rv;

  nsCOMPtr<nsIDocumentLoaderFactory> docFactory(do_GetService(contractId));
  if (docFactory) {
    // generate (about:blank) document to load
    docFactory->CreateBlankDocument(mLoadGroup, getter_AddRefs(blankDoc));
    if (blankDoc) {
      blankDoc->SetContainer(NS_STATIC_CAST(nsIDocShell *, this));

      // create a content viewer for us and the new document
      docFactory->CreateInstanceForDocument(NS_ISUPPORTS_CAST(nsIDocShell *, this),
                    blankDoc, "view", getter_AddRefs(viewer));

      // hook 'em up
      if (viewer) {
        viewer->SetContainer(NS_STATIC_CAST(nsIContentViewerContainer *,this));
        nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(blankDoc));
        Embed(viewer, "", 0);
        viewer->SetDOMDocument(domdoc);

        SetCurrentURI(blankDoc->GetDocumentURI(), nsnull, PR_TRUE);
        rv = NS_OK;
      }
    }
  }
  mCreatingDocument = PR_FALSE;

  // The transient about:blank viewer doesn't have a session history entry.
  SetHistoryEntry(&mOSHE, nsnull);

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsDocShell::CreateContentViewer ( const char *  aContentType,
nsIRequest request,
nsIStreamListener **  aContentHandler 
) [protected]

XXX: Need to do this eventually Stop();

Definition at line 5786 of file nsDocShell.cpp.

{
    *aContentHandler = nsnull;

    // Can we check the content type of the current content viewer
    // and reuse it without destroying it and re-creating it?

    NS_ASSERTION(mLoadGroup, "Someone ignored return from Init()?");

    // Instantiate the content viewer object
    nsCOMPtr<nsIContentViewer> viewer;
    nsresult rv = NewContentViewerObj(aContentType, request, mLoadGroup,
                                      aContentHandler, getter_AddRefs(viewer));

    if (NS_FAILED(rv))
        return NS_ERROR_FAILURE;

    // Notify the current document that it is about to be unloaded!!
    //
    // It is important to fire the unload() notification *before* any state
    // is changed within the DocShell - otherwise, javascript will get the
    // wrong information :-(
    //

    if (mSavingOldViewer) {
        // We determined that it was safe to cache the document presentation
        // at the time we initiated the new load.  We need to check whether
        // it's still safe to do so, since there may have been DOM mutations
        // or new requests initiated.
        nsCOMPtr<nsIDOMDocument> domDoc;
        viewer->GetDOMDocument(getter_AddRefs(domDoc));
        nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
        mSavingOldViewer = CanSavePresentation(mLoadType, request, doc);
    }

    FirePageHideNotification(!mSavingOldViewer);

    // Set mFiredUnloadEvent = PR_FALSE so that the unload handler for the
    // *new* document will fire.
    mFiredUnloadEvent = PR_FALSE;

    // we've created a new document so go ahead and call
    // OnLoadingSite(), but don't fire OnLocationChange()
    // notifications before we've called Embed(). See bug 284993.
    mURIResultedInDocument = PR_TRUE;

    nsCOMPtr<nsIChannel> aOpenedChannel = do_QueryInterface(request);

    PRBool onLocationChangeNeeded = OnLoadingSite(aOpenedChannel, PR_FALSE);

    // let's try resetting the load group if we need to...
    nsCOMPtr<nsILoadGroup> currentLoadGroup;
    NS_ENSURE_SUCCESS(aOpenedChannel->
                      GetLoadGroup(getter_AddRefs(currentLoadGroup)),
                      NS_ERROR_FAILURE);

    if (currentLoadGroup != mLoadGroup) {
        nsLoadFlags loadFlags = 0;

        //Cancel any URIs that are currently loading...
        //
        // Retarget the document to this loadgroup...
        //
        /* First attach the channel to the right loadgroup
         * and then remove from the old loadgroup. This 
         * puts the notifications in the right order and
         * we don't null-out mLSHE in OnStateChange() for 
         * all redirected urls
         */
        aOpenedChannel->SetLoadGroup(mLoadGroup);

        // Mark the channel as being a document URI...
        aOpenedChannel->GetLoadFlags(&loadFlags);
        loadFlags |= nsIChannel::LOAD_DOCUMENT_URI;

        aOpenedChannel->SetLoadFlags(loadFlags);

        mLoadGroup->AddRequest(request, nsnull);
        if (currentLoadGroup)
            currentLoadGroup->RemoveRequest(request, nsnull,
                                            NS_BINDING_RETARGETED);

        // Update the notification callbacks, so that progress and
        // status information are sent to the right docshell...
        aOpenedChannel->SetNotificationCallbacks(this);
    }

    NS_ENSURE_SUCCESS(Embed(viewer, "", (nsISupports *) nsnull),
                      NS_ERROR_FAILURE);

    mSavedRefreshURIList = nsnull;
    mSavingOldViewer = PR_FALSE;
    mEODForCurrentDocument = PR_FALSE;

    // if this document is part of a multipart document,
    // the ID can be used to distinguish it from the other parts.
    nsCOMPtr<nsIMultiPartChannel> multiPartChannel(do_QueryInterface(request));
    if (multiPartChannel) {
      nsCOMPtr<nsIPresShell> shell;
      rv = GetPresShell(getter_AddRefs(shell));
      if (NS_SUCCEEDED(rv) && shell) {
        nsIDocument *doc = shell->GetDocument();
        if (doc) {
          PRUint32 partID;
          multiPartChannel->GetPartID(&partID);
          doc->SetPartID(partID);
        }
      }
    }

    // Give hint to native plevent dispatch mechanism. If a document
    // is loading the native plevent dispatch mechanism should favor
    // performance over normal native event dispatch priorities.
    if (++gNumberOfDocumentsLoading == 1) {
      // Hint to favor performance for the plevent notification mechanism.
      // We want the pages to load as fast as possible even if its means 
      // native messages might be starved.
      PL_FavorPerformanceHint(PR_TRUE, NS_EVENT_STARVATION_DELAY_HINT);
    }

    if (onLocationChangeNeeded) {
      FireOnLocationChange(this, request, mCurrentURI);
    }
  
    return NS_OK;
}

Here is the call graph for this function:

Creates a DocShellLoadInfo object that you can manipulate and then pass to loadURI.

void nsIBaseWindow::destroy ( ) [inherited]
void nsDocLoader::Destroy ( void  ) [protected, inherited]

Definition at line 391 of file nsDocLoader.cpp.

{
  Stop();

  // Remove the document loader from the parent list of loaders...
  if (mParent) 
  {
    mParent->RemoveChildLoader(this);
  }

  // Release all the information about network requests...
  ClearRequestInfoHash();

  // Release all the information about registered listeners...
  PRInt32 count = mListenerInfoList.Count();
  for(PRInt32 i = 0; i < count; i++) {
    nsListenerInfo *info =
      NS_STATIC_CAST(nsListenerInfo*, mListenerInfoList.ElementAt(i));

    delete info;
  }

  mListenerInfoList.Clear();
  mListenerInfoList.Compact();

  mDocumentRequest = 0;

  if (mLoadGroup)
    mLoadGroup->SetGroupObserver(nsnull);

  DestroyChildren();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsDocShell::DestroyChildren ( ) [protected, virtual]

Reimplemented from nsDocLoader.

Definition at line 360 of file nsDocShell.cpp.

{
    nsCOMPtr<nsIDocShellTreeItem> shell;
    PRInt32 n = mChildList.Count();
    for (PRInt32 i = 0; i < n; i++) {
        shell = do_QueryInterface(ChildAt(i));
        NS_WARN_IF_FALSE(shell, "docshell has null child");

        if (shell) {
            shell->SetTreeOwner(nsnull);
        }
    }

    nsDocLoader::DestroyChildren();
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsDocShell::DisplayLoadError ( nsresult  aError,
nsIURI aURI,
const PRUnichar aURL,
nsIChannel aFailedChannel = nsnull 
) [protected]

Definition at line 2982 of file nsDocShell.cpp.

{
    // Get prompt and string bundle servcies
    nsCOMPtr<nsIPrompt> prompter;
    nsCOMPtr<nsIStringBundle> stringBundle;
    GetPromptAndStringBundle(getter_AddRefs(prompter),
                             getter_AddRefs(stringBundle));

    NS_ENSURE_TRUE(stringBundle, NS_ERROR_FAILURE);
    NS_ENSURE_TRUE(prompter, NS_ERROR_FAILURE);

    nsAutoString error;
    const PRUint32 kMaxFormatStrArgs = 2;
    nsAutoString formatStrs[kMaxFormatStrArgs];
    PRUint32 formatStrCount = 0;
    nsresult rv = NS_OK;

    // Turn the error code into a human readable error message.
    if (NS_ERROR_UNKNOWN_PROTOCOL == aError) {
        NS_ENSURE_ARG_POINTER(aURI);
        // extract the scheme
        nsCAutoString scheme;
        aURI->GetScheme(scheme);
        CopyASCIItoUCS2(scheme, formatStrs[0]);
        formatStrCount = 1;
        error.AssignLiteral("protocolNotFound");
    }
    else if (NS_ERROR_FILE_NOT_FOUND == aError) {
        NS_ENSURE_ARG_POINTER(aURI);
        nsCAutoString spec;
        aURI->GetPath(spec);
        nsCAutoString charset;
        // unescape and convert from origin charset
        aURI->GetOriginCharset(charset);
        nsCOMPtr<nsITextToSubURI> textToSubURI(
                do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv));
        if (NS_SUCCEEDED(rv))
            // UnEscapeURIForUI always succeeds 
            textToSubURI->UnEscapeURIForUI(charset, spec, formatStrs[0]);
        else 
            CopyUTF8toUTF16(spec, formatStrs[0]);
        rv = NS_OK;
        formatStrCount = 1;
        error.AssignLiteral("fileNotFound");
    }
    else if (NS_ERROR_UNKNOWN_HOST == aError) {
        NS_ENSURE_ARG_POINTER(aURI);
        // Get the host
        nsCAutoString host;
        aURI->GetHost(host);
        CopyUTF8toUTF16(host, formatStrs[0]);
        formatStrCount = 1;
        error.AssignLiteral("dnsNotFound");
    }
    else if(NS_ERROR_CONNECTION_REFUSED == aError) {
        NS_ENSURE_ARG_POINTER(aURI);
        // Build up the host:port string.
        nsCAutoString hostport;
        aURI->GetHostPort(hostport);
        CopyUTF8toUTF16(hostport, formatStrs[0]);
        formatStrCount = 1;
        error.AssignLiteral("connectionFailure");
    }
    else if(NS_ERROR_NET_INTERRUPT == aError) {
        NS_ENSURE_ARG_POINTER(aURI);
        // Build up the host:port string.
        nsCAutoString hostport;
        aURI->GetHostPort(hostport);
        CopyUTF8toUTF16(hostport, formatStrs[0]);
        formatStrCount = 1;
        error.AssignLiteral("netInterrupt");
    }
    else if (NS_ERROR_NET_TIMEOUT == aError) {
        NS_ENSURE_ARG_POINTER(aURI);
        // Get the host
        nsCAutoString host;
        aURI->GetHost(host);
        CopyUTF8toUTF16(host, formatStrs[0]);
        formatStrCount = 1;
        error.AssignLiteral("netTimeout");
    }
    else {
        // Errors requiring simple formatting
        switch (aError) {
        case NS_ERROR_MALFORMED_URI:
            // URI is malformed
            error.AssignLiteral("malformedURI");
            break;
        case NS_ERROR_REDIRECT_LOOP:
            // Doc failed to load because the server generated too many redirects
            error.AssignLiteral("redirectLoop");
            break;
        case NS_ERROR_UNKNOWN_SOCKET_TYPE:
            // Doc failed to load because PSM is not installed
            error.AssignLiteral("unknownSocketType");
            break;
        case NS_ERROR_NET_RESET:
            // Doc failed to load because the server kept reseting the connection
            // before we could read any data from it
            error.AssignLiteral("netReset");
            break;
        case NS_ERROR_DOCUMENT_NOT_CACHED:
            // Doc falied to load because we are offline and the cache does not
            // contain a copy of the document.
            error.AssignLiteral("netOffline");
            break;
        case NS_ERROR_DOCUMENT_IS_PRINTMODE:
            // Doc navigation attempted while Printing or Print Preview
            error.AssignLiteral("isprinting");
            break;
        case NS_ERROR_PORT_ACCESS_NOT_ALLOWED:
            // Port blocked for security reasons
            error.AssignLiteral("deniedPortAccess");
            break;
        case NS_ERROR_UNKNOWN_PROXY_HOST:
            // Proxy hostname could not be resolved.
            error.AssignLiteral("proxyResolveFailure");
            break;
        case NS_ERROR_PROXY_CONNECTION_REFUSED:
            // Proxy connection was refused.
            error.AssignLiteral("proxyConnectFailure");
            break;
        case NS_ERROR_UNSAFE_CONTENT_TYPE:
            // XXX: We can't add new strings on the branch, abuse
            // malformedURI
            error.AssignLiteral("malformedURI");
            break;
        }
    }

    // Test if the error should be displayed
    if (error.IsEmpty()) {
        return NS_OK;
    }

    // Test if the error needs to be formatted
    nsAutoString messageStr;
    if (formatStrCount > 0) {
        const PRUnichar *strs[kMaxFormatStrArgs];
        for (PRUint32 i = 0; i < formatStrCount; i++) {
            strs[i] = formatStrs[i].get();
        }
        nsXPIDLString str;
        rv = stringBundle->FormatStringFromName(
            error.get(),
            strs, formatStrCount, getter_Copies(str));
        NS_ENSURE_SUCCESS(rv, rv);
        messageStr.Assign(str.get());
    }
    else
    {
        nsXPIDLString str;
        rv = stringBundle->GetStringFromName(
                error.get(),
                getter_Copies(str));
        NS_ENSURE_SUCCESS(rv, rv);
        messageStr.Assign(str.get());
    }

    // Display the error as a page or an alert prompt
    NS_ENSURE_FALSE(messageStr.IsEmpty(), NS_ERROR_FAILURE);
    // Note: For now, display an alert instead of an error page if we have no
    // URI object. Missing URI objects are handled badly by session history.
    if (mUseErrorPages && aURI && aFailedChannel) {
        // Display an error page
        LoadErrorPage(aURI, aURL, error.get(), messageStr.get(),
                      aFailedChannel);
    } 
    else
    {
        // Display a message box
        prompter->Alert(nsnull, messageStr.get());
    }

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsDocShell::DoAddChildSHEntry ( nsISHEntry aNewEntry,
PRInt32  aChildOffset 
) [protected]

Definition at line 2748 of file nsDocShell.cpp.

{
    /* You will get here when you are in a subframe and
     * a new url has been loaded on you. 
     * The mOSHE in this subframe will be the previous url's
     * mOSHE. This mOSHE will be used as the identification
     * for this subframe in the  CloneAndReplace function.
     */

    // In this case, we will end up calling AddEntry, which increases the
    // current index by 1
    nsCOMPtr<nsISHistory> rootSH;
    GetRootSessionHistory(getter_AddRefs(rootSH));
    if (rootSH) {
        rootSH->GetIndex(&mPreviousTransIndex);
    }

    nsresult rv;
    nsCOMPtr<nsIDocShellHistory> parent =
        do_QueryInterface(GetAsSupports(mParent), &rv);
    if (parent) {
        rv = parent->AddChildSHEntry(mOSHE, aNewEntry, aChildOffset);
    }


    if (rootSH) {
        rootSH->GetIndex(&mLoadedTransIndex);
#ifdef DEBUG_PAGE_CACHE
        printf("Previous index: %d, Loaded index: %d\n\n", mPreviousTransIndex,
               mLoadedTransIndex);
#endif
    }

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsDocShell::DoChannelLoad ( nsIChannel aChannel,
nsIURILoader aURILoader 
) [protected, virtual]

Definition at line 7236 of file nsDocShell.cpp.

{
    nsresult rv;
    // Mark the channel as being a document URI and allow content sniffing...
    nsLoadFlags loadFlags = 0;
    (void) aChannel->GetLoadFlags(&loadFlags);
    loadFlags |= nsIChannel::LOAD_DOCUMENT_URI |
                 nsIChannel::LOAD_CALL_CONTENT_SNIFFERS;

    // Load attributes depend on load type...
    switch (mLoadType) {
    case LOAD_HISTORY:
        loadFlags |= nsIRequest::VALIDATE_NEVER;
        break;

    case LOAD_RELOAD_CHARSET_CHANGE:
        loadFlags |= nsIRequest::LOAD_FROM_CACHE;
        break;
    
    case LOAD_RELOAD_NORMAL:
    case LOAD_REFRESH:
        loadFlags |= nsIRequest::VALIDATE_ALWAYS;
        break;

    case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
        loadFlags |= nsIRequest::LOAD_BYPASS_CACHE;
        break;

    case LOAD_NORMAL:
    case LOAD_LINK:
        // Set cache checking flags
        PRInt32 prefSetting;
        if (NS_SUCCEEDED
            (mPrefs->
             GetIntPref("browser.cache.check_doc_frequency",
                        &prefSetting))) {
            switch (prefSetting) {
            case 0:
                loadFlags |= nsIRequest::VALIDATE_ONCE_PER_SESSION;
                break;
            case 1:
                loadFlags |= nsIRequest::VALIDATE_ALWAYS;
                break;
            case 2:
                loadFlags |= nsIRequest::VALIDATE_NEVER;
                break;
            }
        }
        break;
    }

    (void) aChannel->SetLoadFlags(loadFlags);

    rv = aURILoader->OpenURI(aChannel,
                             (mLoadType == LOAD_LINK),
                             this);
    
    return rv;
}

Here is the caller graph for this function:

void nsDocLoader::DocLoaderIsEmpty ( ) [protected, inherited]

Definition at line 702 of file nsDocLoader.cpp.

{
  if (mIsLoadingDocument) {
    /* In the unimagineably rude circumstance that onload event handlers
       triggered by this function actually kill the window ... ok, it's
       not unimagineable; it's happened ... this deathgrip keeps this object
       alive long enough to survive this function call. */
    nsCOMPtr<nsIDocumentLoader> kungFuDeathGrip(this);

    if (!IsBusy()) {
      PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, 
             ("DocLoader:%p: Is now idle...\n", this));

      nsCOMPtr<nsIRequest> docRequest = mDocumentRequest;

      NS_ASSERTION(mDocumentRequest, "No Document Request!");
      mDocumentRequest = 0;
      mIsLoadingDocument = PR_FALSE;

      // Update the progress status state - the document is done
      mProgressStateFlags = nsIWebProgressListener::STATE_STOP;


      nsresult loadGroupStatus = NS_OK; 
      mLoadGroup->GetStatus(&loadGroupStatus);

      // 
      // New code to break the circular reference between 
      // the load group and the docloader... 
      // 
      mLoadGroup->SetDefaultLoadRequest(nsnull); 

      //
      // Do nothing after firing the OnEndDocumentLoad(...). The document
      // loader may be loading a *new* document - if LoadDocument()
      // was called from a handler!
      //
      doStopDocumentLoad(docRequest, loadGroupStatus);

      if (mParent) {
        mParent->DocLoaderIsEmpty();
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsDocLoader::doStartDocumentLoad ( void  ) [protected, inherited]

Definition at line 748 of file nsDocLoader.cpp.

{

#if defined(DEBUG)
  nsCAutoString buffer;

  GetURIStringFromRequest(mDocumentRequest, buffer);
  PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, 
         ("DocLoader:%p: ++ Firing OnStateChange for start document load (...)."
          "\tURI: %s \n",
          this, buffer.get()));
#endif /* DEBUG */

  // Fire an OnStatus(...) notification STATE_START.  This indicates
  // that the document represented by mDocumentRequest has started to
  // load...
  FireOnStateChange(this,
                    mDocumentRequest,
                    nsIWebProgressListener::STATE_START |
                    nsIWebProgressListener::STATE_IS_DOCUMENT |
                    nsIWebProgressListener::STATE_IS_REQUEST |
                    nsIWebProgressListener::STATE_IS_WINDOW |
                    nsIWebProgressListener::STATE_IS_NETWORK,
                    NS_OK);
}

Here is the call graph for this function:

void nsDocLoader::doStartURLLoad ( nsIRequest request) [protected, inherited]

Definition at line 774 of file nsDocLoader.cpp.

{
#if defined(DEBUG)
  nsCAutoString buffer;

  GetURIStringFromRequest(request, buffer);
    PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, 
          ("DocLoader:%p: ++ Firing OnStateChange start url load (...)."
           "\tURI: %s\n",
            this, buffer.get()));
#endif /* DEBUG */

  FireOnStateChange(this,
                    request,
                    nsIWebProgressListener::STATE_START |
                    nsIWebProgressListener::STATE_IS_REQUEST,
                    NS_OK);
}

Here is the call graph for this function:

void nsDocLoader::doStopDocumentLoad ( nsIRequest request,
nsresult  aStatus 
) [protected, inherited]

Definition at line 812 of file nsDocLoader.cpp.

{
#if defined(DEBUG)
  nsCAutoString buffer;

  GetURIStringFromRequest(request, buffer);
  PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, 
         ("DocLoader:%p: ++ Firing OnStateChange for end document load (...)."
         "\tURI: %s Status=%x\n",
          this, buffer.get(), aStatus));
#endif /* DEBUG */

  //
  // Fire an OnStateChange(...) notification indicating the the
  // current document has finished loading...
  //
  FireOnStateChange(this,
                    request,
                    nsIWebProgressListener::STATE_STOP |
                    nsIWebProgressListener::STATE_IS_DOCUMENT,
                    aStatus);

  //
  // Fire a final OnStateChange(...) notification indicating the the
  // current document has finished loading...
  //
  FireOnStateChange(this,
                    request,
                    nsIWebProgressListener::STATE_STOP |
                    nsIWebProgressListener::STATE_IS_WINDOW |
                    nsIWebProgressListener::STATE_IS_NETWORK,
                    aStatus);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsDocLoader::doStopURLLoad ( nsIRequest request,
nsresult  aStatus 
) [protected, inherited]

Definition at line 793 of file nsDocLoader.cpp.

{
#if defined(DEBUG)
  nsCAutoString buffer;

  GetURIStringFromRequest(request, buffer);
    PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, 
          ("DocLoader:%p: ++ Firing OnStateChange for end url load (...)."
           "\tURI: %s status=%x\n",
            this, buffer.get(), aStatus));
#endif /* DEBUG */

  FireOnStateChange(this,
                    request,
                    nsIWebProgressListener::STATE_STOP |
                    nsIWebProgressListener::STATE_IS_REQUEST,
                    aStatus);
}

Here is the call graph for this function:

nsresult nsDocShell::DoURILoad ( nsIURI aURI,
nsIURI aReferrer,
PRBool  aSendReferrer,
nsISupports *  aOwner,
const char *  aTypeHint,
nsIInputStream aPostData,
nsIInputStream aHeadersData,
PRBool  firstParty,
nsIDocShell **  aDocShell,
nsIRequest **  aRequest,
PRBool  aIsNewWindowTarget 
) [protected, virtual]

Definition at line 6953 of file nsDocShell.cpp.

{
    nsresult rv;
    nsCOMPtr<nsIURILoader> uriLoader;

    uriLoader = do_GetService(NS_URI_LOADER_CONTRACTID, &rv);
    if (NS_FAILED(rv)) return rv;

    nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL;
    if (aFirstParty) {
        // tag first party URL loads
        loadFlags |= nsIChannel::LOAD_INITIAL_DOCUMENT_URI;
    }

    if (mLoadType == LOAD_ERROR_PAGE) {
        // Error pages are LOAD_BACKGROUND
        loadFlags |= nsIChannel::LOAD_BACKGROUND;
    }

    // open a channel for the url
    nsCOMPtr<nsIChannel> channel;

    rv = NS_NewChannel(getter_AddRefs(channel),
                       aURI,
                       nsnull,
                       nsnull,
                       NS_STATIC_CAST(nsIInterfaceRequestor *, this),
                       loadFlags);
    if (NS_FAILED(rv)) {
        if (rv == NS_ERROR_UNKNOWN_PROTOCOL) {
            // This is a uri with a protocol scheme we don't know how
            // to handle.  Embedders might still be interested in
            // handling the load, though, so we fire a notification
            // before throwing the load away.
            PRBool abort = PR_FALSE;
            nsresult rv2 = mContentListener->OnStartURIOpen(aURI, &abort);
            if (NS_SUCCEEDED(rv2) && abort) {
                // Hey, they're handling the load for us!  How convenient!
                return NS_OK;
            }
        }
            
        return rv;
    }

    // Make sure to give the caller a channel if we managed to create one
    // This is important for correct error page/session history interaction
    if (aRequest)
        NS_ADDREF(*aRequest = channel);

    channel->SetOriginalURI(aURI);
    if (aTypeHint && *aTypeHint) {
        channel->SetContentType(nsDependentCString(aTypeHint));
        mContentTypeHint = aTypeHint;
    }
    else {
        mContentTypeHint.Truncate();
    }
    
    //hack
    nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
    nsCOMPtr<nsIHttpChannelInternal> httpChannelInternal(do_QueryInterface(channel));
    if (httpChannelInternal) {
      if (aFirstParty) {
        httpChannelInternal->SetDocumentURI(aURI);
      } else {
        httpChannelInternal->SetDocumentURI(aReferrerURI);
      }
    }

    nsCOMPtr<nsIWritablePropertyBag2> props(do_QueryInterface(channel));
    if (props)
    {
      // save true referrer for those who need it (e.g. xpinstall whitelisting)
      // Currently only http and ftp channels support this.
      props->SetPropertyAsInterface(NS_LITERAL_STRING("docshell.internalReferrer"),
                                    aReferrerURI);
    }

    //
    // If this is a HTTP channel, then set up the HTTP specific information
    // (ie. POST data, referrer, ...)
    //
    if (httpChannel) {
        nsCOMPtr<nsICachingChannel>  cacheChannel(do_QueryInterface(httpChannel));
        /* Get the cache Key from SH */
        nsCOMPtr<nsISupports> cacheKey;
        if (mLSHE) {
            mLSHE->GetCacheKey(getter_AddRefs(cacheKey));
        }
        else if (mOSHE)          // for reload cases
            mOSHE->GetCacheKey(getter_AddRefs(cacheKey));

        // figure out if we need to set the post data stream on the channel...
        // right now, this is only done for http channels.....
        if (aPostData) {
            // XXX it's a bit of a hack to rewind the postdata stream here but
            // it has to be done in case the post data is being reused multiple
            // times.
            nsCOMPtr<nsISeekableStream>
                postDataSeekable(do_QueryInterface(aPostData));
            if (postDataSeekable) {
                rv = postDataSeekable->Seek(nsISeekableStream::NS_SEEK_SET, 0);
                NS_ENSURE_SUCCESS(rv, rv);
            }

            nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(httpChannel));
            NS_ASSERTION(uploadChannel, "http must support nsIUploadChannel");

            // we really need to have a content type associated with this stream!!
            uploadChannel->SetUploadStream(aPostData, EmptyCString(), -1);
            /* If there is a valid postdata *and* it is a History Load,
             * set up the cache key on the channel, to retrieve the
             * data *only* from the cache. If it is a normal reload, the 
             * cache is free to go to the server for updated postdata. 
             */
            if (cacheChannel && cacheKey) {
                if (mLoadType == LOAD_HISTORY || mLoadType == LOAD_RELOAD_CHARSET_CHANGE) {
                    cacheChannel->SetCacheKey(cacheKey);
                    PRUint32 loadFlags;
                    if (NS_SUCCEEDED(channel->GetLoadFlags(&loadFlags)))
                        channel->SetLoadFlags(loadFlags | nsICachingChannel::LOAD_ONLY_FROM_CACHE);
                }
                else if (mLoadType == LOAD_RELOAD_NORMAL)
                    cacheChannel->SetCacheKey(cacheKey);
            }         
        }
        else {
            /* If there is no postdata, set the cache key on the channel, and
             * do not set the LOAD_ONLY_FROM_CACHE flag, so that the channel
             * will be free to get it from net if it is not found in cache.
             * New cache may use it creatively on CGI pages with GET
             * method and even on those that say "no-cache"
             */
            if (mLoadType == LOAD_HISTORY || mLoadType == LOAD_RELOAD_NORMAL 
                || mLoadType == LOAD_RELOAD_CHARSET_CHANGE) {
                if (cacheChannel && cacheKey)
                    cacheChannel->SetCacheKey(cacheKey);
            }
        }
        if (aHeadersData) {
            rv = AddHeadersToChannel(aHeadersData, httpChannel);
        }
        // Set the referrer explicitly
        if (aReferrerURI && aSendReferrer) {
            // Referrer is currenly only set for link clicks here.
            httpChannel->SetReferrer(aReferrerURI);
        }
    }
    //
    // Set the owner of the channel - only for javascript and data channels.
    //
    // XXX: Is seems wrong that the owner is ignored - even if one is
    //      supplied) unless the URI is javascript or data or about:blank.
    // XXX: If this is ever changed, check all callers for what owners they're
    //      passing in.  In particular, see the code and comments in LoadURI
    //      where we fall back on inheriting the owner if called
    //      from chrome.  That would be very wrong if this code changed
    //      anything but channels that can't provide their own security context!
    //
    //      (Currently chrome URIs set the owner when they are created!
    //      So setting a NULL owner would be bad!)
    //
    PRBool isJSOrData = PR_FALSE;
    aURI->SchemeIs("javascript", &isJSOrData);
    if (!isJSOrData) {
      aURI->SchemeIs("data", &isJSOrData);
    }
    if (isJSOrData || IsAboutBlank(aURI)) {
        channel->SetOwner(aOwner);
    }

    if (aIsNewWindowTarget) {
        nsCOMPtr<nsIWritablePropertyBag2> props = do_QueryInterface(channel);
        if (props) {
            props->SetPropertyAsBool(
                NS_LITERAL_STRING("docshell.newWindowTarget"),
                PR_TRUE);
        }
    }

    rv = DoChannelLoad(channel, uriLoader);
    
    //
    // If the channel load failed, we failed and nsIWebProgress just ain't
    // gonna happen.
    //
    if (NS_SUCCEEDED(rv)) {
        if (aDocShell) {
          *aDocShell = this;
          NS_ADDREF(*aDocShell);
        }
    }

    return rv;
}

Here is the call graph for this function:

void nsIContentViewerContainer::embed ( in nsIContentViewer  aDocViewer,
in string  aCommand,
in nsISupports  aExtraInfo 
) [inherited]
nsresult nsDocShell::EndPageLoad ( nsIWebProgress aProgress,
nsIChannel aChannel,
nsresult  aResult 
) [protected, virtual]

Reimplemented in nsWebShell.

Definition at line 4855 of file nsDocShell.cpp.

{
    //
    // one of many safeguards that prevent death and destruction if
    // someone is so very very rude as to bring this window down
    // during this load handler.
    //
    nsCOMPtr<nsIDocShell> kungFuDeathGrip(this);
    //
    // Notify the ContentViewer that the Document has finished loading...
    //
    // This will cause any OnLoad(...) handlers to fire, if it is a HTML
    // document...
    //
    if (!mEODForCurrentDocument && mContentViewer) {
        mIsExecutingOnLoadHandler = PR_TRUE;
        mContentViewer->LoadComplete(aStatus);
        mIsExecutingOnLoadHandler = PR_FALSE;

        mEODForCurrentDocument = PR_TRUE;

        // If all documents have completed their loading
        // favor native event dispatch priorities
        // over performance
        if (--gNumberOfDocumentsLoading == 0) {
          // Hint to use normal native event dispatch priorities 
          PL_FavorPerformanceHint(PR_FALSE, NS_EVENT_STARVATION_DELAY_HINT);
        }
    }
    /* Check if the httpChannel has any cache-control related response headers,
     * like no-store, no-cache. If so, update SHEntry so that 
     * when a user goes back/forward to this page, we appropriately do 
     * form value restoration or load from server.
     */
    nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aChannel));
    if (!httpChannel) // HttpChannel could be hiding underneath a Multipart channel.    
        GetHttpChannel(aChannel, getter_AddRefs(httpChannel));

    if (httpChannel) {
        // figure out if SH should be saving layout state.
        PRBool discardLayoutState = ShouldDiscardLayoutState(httpChannel);       
        if (mLSHE && discardLayoutState && (mLoadType & LOAD_CMD_NORMAL) &&
            (mLoadType != LOAD_BYPASS_HISTORY) && (mLoadType != LOAD_ERROR_PAGE))
            mLSHE->SetSaveLayoutStateFlag(PR_FALSE);            
    }

    // Clear mLSHE after calling the onLoadHandlers. This way, if the
    // onLoadHandler tries to load something different in
    // itself or one of its children, we can deal with it appropriately.
    if (mLSHE) {
        mLSHE->SetLoadType(nsIDocShellLoadInfo::loadHistory);

        // Clear the mLSHE reference to indicate document loading is done one
        // way or another.
        SetHistoryEntry(&mLSHE, nsnull);
    }
    // if there's a refresh header in the channel, this method
    // will set it up for us. 
    RefreshURIFromQueue();

    return NS_OK;
}

Here is the call graph for this function:

Definition at line 4925 of file nsDocShell.cpp.

{
    if (mContentViewer)
        return NS_OK;
    if (mIsBeingDestroyed)
        return NS_ERROR_FAILURE;

    nsIPrincipal* principal = nsnull;

    nsCOMPtr<nsPIDOMWindow_MOZILLA_1_8_BRANCH2> piDOMWindow =
      do_QueryInterface(mScriptGlobal);
    if (piDOMWindow) {
        principal = piDOMWindow->GetOpenerScriptPrincipal();
    }

    if (!principal) {
        principal = GetInheritedPrincipal(PR_FALSE);
    }

    nsresult rv = CreateAboutBlankContentViewer();

    if (NS_SUCCEEDED(rv)) {
        nsCOMPtr<nsIDOMDocument> domDoc;
        mContentViewer->GetDOMDocument(getter_AddRefs(domDoc));
        nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
        nsCOMPtr<nsIDocument_MOZILLA_1_8_BRANCH2> doc_MOZILLA_1_8_BRANCH2 =
            do_QueryInterface(domDoc);
        NS_ASSERTION(doc && doc_MOZILLA_1_8_BRANCH2,
                     "Should have doc if CreateAboutBlankContentViewer "
                     "succeeded!");

        doc_MOZILLA_1_8_BRANCH2->SetIsInitialDocument(PR_TRUE);

        if (principal) {
            doc->SetPrincipal(principal);
        }
    }

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4967 of file nsDocShell.cpp.

{
    if (mDeviceContext)
        return NS_OK;

    mDeviceContext = do_CreateInstance(kDeviceContextCID);
    NS_ENSURE_TRUE(mDeviceContext, NS_ERROR_FAILURE);

    nsCOMPtr<nsIWidget> widget;
    GetMainWidget(getter_AddRefs(widget));
    NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);

    mDeviceContext->Init(widget->GetNativeData(NS_NATIVE_WIDGET));
    float dev2twip;
    dev2twip = mDeviceContext->DevUnitsToTwips();
    mDeviceContext->SetDevUnitsToAppUnits(dev2twip);
    float twip2dev;
    twip2dev = mDeviceContext->TwipsToDevUnits();
    mDeviceContext->SetAppUnitsToDevUnits(twip2dev);

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 8597 of file nsDocShell.cpp.

{
    nsresult rv;
    if (!mFind)
    {
        mFind = do_CreateInstance("@mozilla.org/embedcomp/find;1", &rv);
        if (NS_FAILED(rv)) return rv;
    }
    
    // we promise that the nsIWebBrowserFind that we return has been set
    // up to point to the focused, or content window, so we have to
    // set that up each time.

    nsIScriptGlobalObject* scriptGO = GetScriptGlobalObject();
    NS_ENSURE_TRUE(scriptGO, NS_ERROR_UNEXPECTED);

    // default to our window
    nsCOMPtr<nsIDOMWindow> rootWindow = do_QueryInterface(scriptGO);
    nsCOMPtr<nsIDOMWindow> windowToSearch = rootWindow;

    // if we can, search the focused window
    nsCOMPtr<nsPIDOMWindow> ourWindow = do_QueryInterface(scriptGO);
    nsIFocusController *focusController = nsnull;
    if (ourWindow)
        focusController = ourWindow->GetRootFocusController();
    if (focusController)
    {
        nsCOMPtr<nsIDOMWindowInternal> focusedWindow;
        focusController->GetFocusedWindow(getter_AddRefs(focusedWindow));
        if (focusedWindow)
            windowToSearch = focusedWindow;
    }

    nsCOMPtr<nsIWebBrowserFindInFrames> findInFrames = do_QueryInterface(mFind);
    if (!findInFrames) return NS_ERROR_NO_INTERFACE;
    
    rv = findInFrames->SetRootSearchFrame(rootWindow);
    if (NS_FAILED(rv)) return rv;
    rv = findInFrames->SetCurrentSearchFrame(windowToSearch);
    if (NS_FAILED(rv)) return rv;
    
    return NS_OK;
}

Here is the call graph for this function:

Definition at line 8540 of file nsDocShell.cpp.

{
    if (mScriptGlobal)
        return NS_OK;

    if (mIsBeingDestroyed) {
        return NS_ERROR_NOT_AVAILABLE;
    }

    nsCOMPtr<nsIDOMScriptObjectFactory> factory =
        do_GetService(kDOMScriptObjectFactoryCID);
    NS_ENSURE_TRUE(factory, NS_ERROR_FAILURE);

    factory->NewScriptGlobalObject(mItemType == typeChrome,
                                   getter_AddRefs(mScriptGlobal));
    NS_ENSURE_TRUE(mScriptGlobal, NS_ERROR_FAILURE);

    mScriptGlobal->SetDocShell(NS_STATIC_CAST(nsIDocShell *, this));
    mScriptGlobal->
        SetGlobalObjectOwner(NS_STATIC_CAST
                             (nsIScriptGlobalObjectOwner *, this));

    nsCOMPtr<nsIScriptContext> context;
    factory->NewScriptContext(mScriptGlobal, getter_AddRefs(context));
    NS_ENSURE_TRUE(context, NS_ERROR_FAILURE);

    // Note that mScriptGlobal has taken a reference to the script
    // context, so we don't have to.

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIDocShellTreeItem nsIDocShellTreeNode::findChildWithName ( in wstring  aName,
in boolean  aRecurse,
in boolean  aSameType,
in nsIDocShellTreeItem  aRequestor,
in nsIDocShellTreeItem  aOriginalRequestor 
) [inherited]
nsIDocShellTreeItem nsIDocShellTreeItem::findItemWithName ( in wstring  name,
in nsISupports  aRequestor,
in nsIDocShellTreeItem  aOriginalRequestor 
) [inherited]

Finish firing WebProgressListener notifications and DOM events for restoring a page presentation.

This should only be called via beginRestore().

void nsDocLoader::FireOnLocationChange ( nsIWebProgress aWebProgress,
nsIRequest aRequest,
nsIURI aUri 
) [protected, inherited]

Definition at line 1224 of file nsDocLoader.cpp.

{
  /*                                                                           
   * First notify any listeners of the new state info...
   *
   * Operate the elements from back to front so that if items get
   * get removed from the list it won't affect our iteration
   */
  nsCOMPtr<nsIWebProgressListener> listener;
  PRInt32 count = mListenerInfoList.Count();

  while (--count >= 0) {
    nsListenerInfo *info;

    info = NS_STATIC_CAST(nsListenerInfo*,mListenerInfoList.SafeElementAt(count));
    if (!info || !(info->mNotifyMask & nsIWebProgress::NOTIFY_LOCATION)) {
      continue;
    }

    listener = do_QueryReferent(info->mWeakListener);
    if (!listener) {
      // the listener went away. gracefully pull it out of the list.
      mListenerInfoList.RemoveElementAt(count);
      delete info;
      continue;
    }

    listener->OnLocationChange(aWebProgress, aRequest, aUri);
  }

  mListenerInfoList.Compact();

  // Pass the notification up to the parent...
  if (mParent) {
    mParent->FireOnLocationChange(aWebProgress, aRequest, aUri);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsDocLoader::FireOnProgressChange ( nsDocLoader aLoadInitiator,
nsIRequest request,
PRInt64  aProgress,
PRInt64  aProgressMax,
PRInt64  aProgressDelta,
PRInt64  aTotalProgress,
PRInt64  aMaxTotalProgress 
) [protected, inherited]

Definition at line 1084 of file nsDocLoader.cpp.

{
  if (mIsLoadingDocument) {
    mCurrentTotalProgress += aProgressDelta;
    mMaxTotalProgress = GetMaxTotalProgress();

    aTotalProgress    = mCurrentTotalProgress;
    aMaxTotalProgress = mMaxTotalProgress;
  }

#if defined(DEBUG)
  nsCAutoString buffer;

  GetURIStringFromRequest(request, buffer);
  PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, 
         ("DocLoader:%p: Progress (%s): curSelf: %d maxSelf: %d curTotal: %d maxTotal %d\n",
          this, buffer.get(), aProgress, aProgressMax, aTotalProgress, aMaxTotalProgress));
#endif /* DEBUG */

  /*
   * First notify any listeners of the new progress info...
   *
   * Operate the elements from back to front so that if items get
   * get removed from the list it won't affect our iteration
   */
  nsCOMPtr<nsIWebProgressListener> listener;
  PRInt32 count = mListenerInfoList.Count();

  while (--count >= 0) {
    nsListenerInfo *info;

    info = NS_STATIC_CAST(nsListenerInfo*,mListenerInfoList.SafeElementAt(count));
    if (!info || !(info->mNotifyMask & nsIWebProgress::NOTIFY_PROGRESS)) {
      continue;
    }

    listener = do_QueryReferent(info->mWeakListener);
    if (!listener) {
      // the listener went away. gracefully pull it out of the list.
      mListenerInfoList.RemoveElementAt(count);
      delete info;
      continue;
    }

    // XXX truncates 64-bit to 32-bit
    listener->OnProgressChange(aLoadInitiator,request,
                               PRInt32(aProgress), PRInt32(aProgressMax),
                               PRInt32(aTotalProgress), PRInt32(aMaxTotalProgress));
  }

  mListenerInfoList.Compact();

  // Pass the notification up to the parent...
  if (mParent) {
    mParent->FireOnProgressChange(aLoadInitiator, request,
                                  aProgress, aProgressMax,
                                  aProgressDelta,
                                  aTotalProgress, aMaxTotalProgress);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsDocLoader::FireOnStateChange ( nsIWebProgress aProgress,
nsIRequest request,
PRInt32  aStateFlags,
nsresult  aStatus 
) [protected, inherited]

Definition at line 1152 of file nsDocLoader.cpp.

{
  //
  // Remove the STATE_IS_NETWORK bit if necessary.
  //
  // The rule is to remove this bit, if the notification has been passed
  // up from a child WebProgress, and the current WebProgress is already
  // active...
  //
  if (mIsLoadingDocument &&
      (aStateFlags & nsIWebProgressListener::STATE_IS_NETWORK) && 
      (this != aProgress)) {
    aStateFlags &= ~nsIWebProgressListener::STATE_IS_NETWORK;
  }

  // Add the STATE_RESTORING bit if necessary.
  if (mIsRestoringDocument)
    aStateFlags |= nsIWebProgressListener::STATE_RESTORING;

#if defined(DEBUG)
  nsCAutoString buffer;

  GetURIStringFromRequest(aRequest, buffer);
  PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, 
         ("DocLoader:%p: Status (%s): code: %x\n",
         this, buffer.get(), aStateFlags));
#endif /* DEBUG */

  NS_ASSERTION(aRequest, "Firing OnStateChange(...) notification with a NULL request!");

  /*                                                                           
   * First notify any listeners of the new state info...
   *
   * Operate the elements from back to front so that if items get
   * get removed from the list it won't affect our iteration
   */
  nsCOMPtr<nsIWebProgressListener> listener;
  PRInt32 count = mListenerInfoList.Count();

  while (--count >= 0) {
    nsListenerInfo *info;

    info = NS_STATIC_CAST(nsListenerInfo*,mListenerInfoList.SafeElementAt(count));
    if (!info || !(info->mNotifyMask & (aStateFlags >>16))) {
      continue;
    }

    listener = do_QueryReferent(info->mWeakListener);
    if (!listener) {
      // the listener went away. gracefully pull it out of the list.
      mListenerInfoList.RemoveElementAt(count);
      delete info;
      continue;
    }

    listener->OnStateChange(aProgress, aRequest, aStateFlags, aStatus);
  }

  mListenerInfoList.Compact();

  // Pass the notification up to the parent...
  if (mParent) {
    mParent->FireOnStateChange(aProgress, aRequest, aStateFlags, aStatus);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsDocLoader::FireOnStatusChange ( nsIWebProgress aWebProgress,
nsIRequest aRequest,
nsresult  aStatus,
const PRUnichar aMessage 
) [protected, inherited]

Definition at line 1265 of file nsDocLoader.cpp.

{
  /*                                                                           
   * First notify any listeners of the new state info...
   *
   * Operate the elements from back to front so that if items get
   * get removed from the list it won't affect our iteration
   */
  nsCOMPtr<nsIWebProgressListener> listener;
  PRInt32 count = mListenerInfoList.Count();

  while (--count >= 0) {
    nsListenerInfo *info;

    info = NS_STATIC_CAST(nsListenerInfo*,mListenerInfoList.SafeElementAt(count));
    if (!info || !(info->mNotifyMask & nsIWebProgress::NOTIFY_STATUS)) {
      continue;
    }

    listener = do_QueryReferent(info->mWeakListener);
    if (!listener) {
      // the listener went away. gracefully pull it out of the list.
      mListenerInfoList.RemoveElementAt(count);
      delete info;
      continue;
    }

    listener->OnStatusChange(aWebProgress, aRequest, aStatus, aMessage);
  }
  mListenerInfoList.Compact();
  
  // Pass the notification up to the parent...
  if (mParent) {
    mParent->FireOnStatusChange(aWebProgress, aRequest, aStatus, aMessage);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Notify the associated content viewer and all child docshells that they are about to be hidden.

If |isUnload| is true, then the document is being unloaded as well.

already_AddRefed< nsDocLoader > nsDocLoader::GetAsDocLoader ( nsISupports *  aSupports) [static, inherited]

Definition at line 265 of file nsDocLoader.cpp.

{
  if (!aSupports) {
    return nsnull;
  }
  
  nsDocLoader* ptr;
  CallQueryInterface(aSupports, &ptr);
  return ptr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsISupports* nsDocLoader::GetAsSupports ( nsDocLoader aDocLoader) [inline, static, inherited]

Definition at line 98 of file nsDocLoader.h.

                                                               {
        return NS_STATIC_CAST(nsIDocumentLoader*, aDocLoader);
    }

Here is the caller graph for this function:

Request a nsIAuthPrompt interface for the given prompt reason;.

Exceptions:
NS_ERROR_NOT_AVAILABLEif no prompt is allowed or available for the given reason.
Parameters:
aPromptReasonThe reason for the auth prompt; one of or
Returns:
a nsIAuthPrompt interface, or throws NS_ERROR_NOT_AVAILABLE
NS_IMETHODIMP nsDocShell::GetChildOffset ( nsIDOMNode aChild,
nsIDOMNode aParent,
PRInt32 aOffset 
) [protected]

Definition at line 2384 of file nsDocShell.cpp.

{
    NS_ENSURE_ARG_POINTER(aChildOffset);
    *aChildOffset = mChildOffset;
    return NS_OK;
}
nsISHEntry nsIDocShellHistory::getChildSHEntry ( in long  aChildOffset) [inherited]

Get the SHEntry associated with a child docshell.

long nsIScrollable::getCurScrollPos ( in long  scrollOrientation) [inherited]
long nsIScrollable::getDefaultScrollbarPreferences ( in long  scrollOrientation) [inherited]
nsISimpleEnumerator nsIDocShell::getDocShellEnumerator ( in long  aItemType,
in long  aDirection 
) [inherited]

Definition at line 1153 of file nsDocShell.cpp.

{
    nsresult rv = NS_OK;

    NS_ENSURE_ARG_POINTER(aPresContext);
    *aPresContext = nsnull;

    nsCOMPtr<nsIContentViewer> viewer = mContentViewer;
    while (viewer) {
        nsCOMPtr<nsIContentViewer> prevViewer;
        viewer->GetPreviousViewer(getter_AddRefs(prevViewer));
        if (prevViewer)
            viewer = prevViewer;
        else {
            nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(viewer));
            if (docv)
                rv = docv->GetPresContext(aPresContext);
            break;
        }
    }

    return rv;
}

Here is the call graph for this function:

nsresult nsDocShell::GetHttpChannel ( nsIChannel aChannel,
nsIHttpChannel **  aReturn 
) [protected]

Definition at line 8326 of file nsDocShell.cpp.

{
    NS_ENSURE_ARG_POINTER(aReturn);
    if (!aChannel)
        return NS_ERROR_FAILURE;

    nsCOMPtr<nsIMultiPartChannel>  multiPartChannel(do_QueryInterface(aChannel));
    if (multiPartChannel) {
        nsCOMPtr<nsIChannel> baseChannel;
        multiPartChannel->GetBaseChannel(getter_AddRefs(baseChannel));
        nsCOMPtr<nsIHttpChannel>  httpChannel(do_QueryInterface(baseChannel));
        *aReturn = httpChannel;
        NS_IF_ADDREF(*aReturn);
    }
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIPrincipal * nsDocShell::GetInheritedPrincipal ( PRBool  aConsiderCurrentDocument) [protected]

Definition at line 6906 of file nsDocShell.cpp.

{
    nsCOMPtr<nsIDocument> document;

    if (aConsiderCurrentDocument && mContentViewer) {
        nsCOMPtr<nsIDocumentViewer>
            docViewer(do_QueryInterface(mContentViewer));
        if (!docViewer)
            return nsnull;
        docViewer->GetDocument(getter_AddRefs(document));
    }

    if (!document) {
        nsCOMPtr<nsIDocShellTreeItem> parentItem;
        GetSameTypeParent(getter_AddRefs(parentItem));
        if (parentItem) {
            nsCOMPtr<nsIDOMDocument> parentDomDoc(do_GetInterface(parentItem));
            document = do_QueryInterface(parentDomDoc);
        }
    }

    if (!document) {
        if (!aConsiderCurrentDocument) {
            return nsnull;
        }

        // Make sure we end up with _something_ as the principal no matter
        // what.
        EnsureContentViewer();  // If this fails, we'll just get a null
                                // docViewer and bail.

        nsCOMPtr<nsIDocumentViewer>
            docViewer(do_QueryInterface(mContentViewer));
        if (!docViewer)
            return nsnull;
        docViewer->GetDocument(getter_AddRefs(document));
    }

    //-- Get the document's principal
    if (document) {
        return document->GetPrincipal();
    }

    return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIInterfaceRequestor::getInterface ( in nsIIDRef  uuid,
[iid_is(uuid), retval] out nsQIResult  result 
) [inherited]

Retrieves the specified interface pointer.

Parameters:
uuidThe IID of the interface being requested.
result[out] The interface pointer to be filled in if the interface is accessible.
Returns:
NS_OK - interface was successfully returned. NS_NOINTERFACE - interface not accessible. NS_ERROR* - method failure.
nsDocLoader* nsDocLoader::GetParent ( ) const [inline, inherited]

Definition at line 129 of file nsDocLoader.h.

{ return mParent; }
void nsIBaseWindow::getPosition ( out long  x,
out long  y 
) [inherited]
void nsIBaseWindow::getPositionAndSize ( out long  x,
out long  y,
out long  cx,
out long  cy 
) [inherited]
NS_IMETHODIMP nsDocShell::GetPromptAndStringBundle ( nsIPrompt **  aPrompt,
nsIStringBundle **  aStringBundle 
) [protected]

Definition at line 8475 of file nsDocShell.cpp.

{
    NS_ENSURE_SUCCESS(GetInterface(NS_GET_IID(nsIPrompt), (void **) aPrompt),
                      NS_ERROR_FAILURE);

    nsCOMPtr<nsIStringBundleService>
        stringBundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID));
    NS_ENSURE_TRUE(stringBundleService, NS_ERROR_FAILURE);

    NS_ENSURE_SUCCESS(stringBundleService->
                      CreateBundle(DIALOG_STRING_URI,
                                   aStringBundle),
                      NS_ERROR_FAILURE);

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 8522 of file nsDocShell.cpp.

{
    NS_ENSURE_ARG_POINTER(aOutScrollView);

    nsCOMPtr<nsIPresShell> shell;
    NS_ENSURE_SUCCESS(GetPresShell(getter_AddRefs(shell)), NS_ERROR_FAILURE);
    NS_ENSURE_TRUE(shell, NS_ERROR_NULL_POINTER);

    NS_ENSURE_SUCCESS(shell->GetViewManager()->GetRootScrollableView(aOutScrollView),
                      NS_ERROR_FAILURE);

    if (*aOutScrollView == nsnull) {
        return NS_ERROR_FAILURE;
    }
    return NS_OK;
}

Here is the call graph for this function:

Definition at line 8309 of file nsDocShell.cpp.

{
    nsresult rv;

    nsCOMPtr<nsIDocShellTreeItem> root;
    //Get the root docshell
    rv = GetSameTypeRootTreeItem(getter_AddRefs(root));
    // QI to nsIWebNavigation
    nsCOMPtr<nsIWebNavigation> rootAsWebnav(do_QueryInterface(root));
    if (rootAsWebnav) {
        // Get the handle to SH from the root docshell
        rv = rootAsWebnav->GetSessionHistory(aReturn);
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the script global object.

Implements nsIScriptGlobalObjectOwner.

Definition at line 4236 of file nsDocShell.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIScrollable::getScrollbarVisibility ( out boolean  verticalVisible,
out boolean  horizontalVisible 
) [inherited]
void nsIScrollable::getScrollRange ( in long  scrollOrientation,
out long  minPos,
out long  maxPos 
) [inherited]
void nsIBaseWindow::getSize ( out long  cx,
out long  cy 
) [inherited]
void nsIWebNavigation::goBack ( ) [inherited]

Tells the object to navigate to the previous session history item.

When a page is loaded from session history, all content is loaded from the cache (if available) and page state (such as form values and scroll position) is restored.

Exceptions:
NS_ERROR_UNEXPECTEDIndicates that the call was unexpected at this time, which implies that canGoBack is false.

Tells the object to navigate to the next session history item.

When a page is loaded from session history, all content is loaded from the cache (if available) and page state (such as form values and scroll position) is restored.

Exceptions:
NS_ERROR_UNEXPECTEDIndicates that the call was unexpected at this time, which implies that canGoForward is false.
void nsIWebNavigation::gotoIndex ( in long  index) [inherited]

Tells the object to navigate to the session history item at a given index.

Exceptions:
NS_ERROR_UNEXPECTEDIndicates that the call was unexpected at this time, which implies that session history entry at the given index does not exist.
PRBool nsDocShell::HasHistoryEntry ( nsISHEntry aEntry) const [inline, protected]

Definition at line 315 of file nsDocShell.h.

    {
        return aEntry && (aEntry == mOSHE || aEntry == mLSHE);
    }

Here is the caller graph for this function:

void nsIDocShell::historyPurged ( in long  numEntries) [inherited]

Notification that entries have been removed from the beginning of a nsSHistory which has this as its rootDocShell.

Parameters:
numEntries- The number of entries removed
nsresult nsDocShell::Init ( void  ) [virtual]

Reimplemented from nsDocLoader.

Definition at line 323 of file nsDocShell.cpp.

{
    nsresult rv = nsDocLoader::Init();
    NS_ENSURE_SUCCESS(rv, rv);

    NS_ASSERTION(mLoadGroup, "Something went wrong!");

    mContentListener = new nsDSURIContentListener(this);
    NS_ENSURE_TRUE(mContentListener, NS_ERROR_OUT_OF_MEMORY);

    rv = mContentListener->Init();
    NS_ENSURE_SUCCESS(rv, rv);

    if (!mStorages.Init())
        return NS_ERROR_OUT_OF_MEMORY;

    // We want to hold a strong ref to the loadgroup, so it better hold a weak
    // ref to us...  use an InterfaceRequestorProxy to do this.
    nsCOMPtr<InterfaceRequestorProxy> proxy =
        new InterfaceRequestorProxy(NS_STATIC_CAST(nsIInterfaceRequestor*,
                                                   this));
    NS_ENSURE_TRUE(proxy, NS_ERROR_OUT_OF_MEMORY);
    mLoadGroup->SetNotificationCallbacks(proxy);

    rv = nsDocLoader::AddDocLoaderAsChildOfRoot(this);
    NS_ENSURE_SUCCESS(rv, rv);
    
    // Add as |this| a progress listener to itself.  A little weird, but
    // simpler than reproducing all the listener-notification logic in
    // overrides of the various methods via which nsDocLoader can be
    // notified.   Note that this holds an nsWeakPtr to ourselves, so it's ok.
    return AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_DOCUMENT |
                                     nsIWebProgress::NOTIFY_STATE_NETWORK);
    
}

Here is the call graph for this function:

void nsIBaseWindow::initWindow ( in nativeWindow  parentNativeWindow,
in nsIWidget  parentWidget,
in long  x,
in long  y,
in long  cx,
in long  cy 
) [inherited]
void nsIDocShell::internalLoad ( in nsIURI  aURI,
in nsIURI  aReferrer,
in nsISupports  aOwner,
in PRUint32  aFlags,
in wstring  aWindowTarget,
in string  aTypeHint,
in nsIInputStream  aPostDataStream,
in nsIInputStream  aHeadersStream,
in unsigned long  aLoadFlags,
in nsISHEntry  aSHEntry,
in boolean  firstParty,
out nsIDocShell  aDocShell,
out nsIRequest  aRequest 
) [inherited]

Loads the given URI.

This method is identical to loadURI(...) except that its parameter list is broken out instead of being packaged inside of an nsIDocShellLoadInfo object...

Parameters:
aURI- The URI to load.
aReferrer- Referring URI
aOwner- Owner (security principal)
aInheritOwner- Flag indicating whether the owner of the current document should be inherited if aOwner is null.
aStopActiveDoc- Flag indicating whether loading the current document should be stopped.
aWindowTarget- Window target for the load.
aTypeHint- A hint as to the content-type of the resulting data. May be null or empty if no hint.
aPostDataStream- Post data stream (if POSTing)
aHeadersStream- Stream containing "extra" request headers...
aLoadFlags- Flags to modify load behaviour. Flags are defined in nsIWebNavigation.
aSHEntry- Active Session History entry (if loading from SH)
PRBool nsDocShell::IsAboutBlank ( nsIURI aURI) [static, protected]

Definition at line 8984 of file nsDocShell.cpp.

{
    NS_PRECONDITION(aURI, "Must have URI");
    
    // GetSpec can be expensive for some URIs, so check the scheme first.
    PRBool isAbout = PR_FALSE;
    if (NS_FAILED(aURI->SchemeIs("about", &isAbout)) || !isAbout) {
        return PR_FALSE;
    }
    
    nsCAutoString str;
    aURI->GetSpec(str);
    return str.EqualsLiteral("about:blank");
}

Here is the caller graph for this function:

PRBool nsDocLoader::IsBusy ( ) [protected, inherited]

Definition at line 330 of file nsDocLoader.cpp.

{
  nsresult rv;

  //
  // A document loader is busy if either:
  //
  //   1. It is currently loading a document (ie. one or more URIs)
  //   2. One of it's child document loaders is busy...
  //

  /* Is this document loader busy? */
  if (mIsLoadingDocument) {
    PRBool busy;
    rv = mLoadGroup->IsPending(&busy);
    if (NS_FAILED(rv))
      return PR_FALSE;
    if (busy)
      return PR_TRUE;
  }

  /* Otherwise, check its child document loaders... */
  PRInt32 count, i;

  count = mChildList.Count();

  for (i=0; i < count; i++) {
    nsIDocumentLoader* loader = ChildAt(i);

    // This is a safe cast, because we only put nsDocLoader objects into the
    // array
    if (loader && NS_STATIC_CAST(nsDocLoader*, loader)->IsBusy())
        return PR_TRUE;
  }

  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsDocShell::IsFrame ( ) [protected]

Definition at line 8642 of file nsDocShell.cpp.

{
    nsCOMPtr<nsIDocShellTreeItem> parent =
        do_QueryInterface(GetAsSupports(mParent));
    if (parent) {
        PRInt32 parentType = ~mItemType;        // Not us
        parent->GetItemType(&parentType);
        if (parentType == mItemType)    // This is a frame
            return PR_TRUE;
    }

    return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsDocShell::IsNavigationAllowed ( PRBool  aDisplayPrintErrorDialog = PR_TRUE) [protected]

Definition at line 2823 of file nsDocShell.cpp.

{
    return !IsPrintingOrPP(aDisplayPrintErrorDialog) && !mFiredUnloadEvent;
}

Here is the call graph for this function:

PRBool nsDocShell::IsPrintingOrPP ( PRBool  aDisplayErrorDialog = PR_TRUE) [protected]

Definition at line 2813 of file nsDocShell.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsDocShell::LoadErrorPage ( nsIURI aURI,
const PRUnichar aURL,
const PRUnichar aPage,
const PRUnichar aDescription,
nsIChannel aFailedChannel 
) [protected]

Definition at line 3163 of file nsDocShell.cpp.

{
#if defined(PR_LOGGING) && defined(DEBUG)
    if (PR_LOG_TEST(gDocShellLog, PR_LOG_DEBUG)) {
        nsCAutoString spec;
        aURI->GetSpec(spec);

        nsCAutoString chanName;
        if (aFailedChannel)
            aFailedChannel->GetName(chanName);
        else
            chanName.AssignLiteral("<no channel>");

        PR_LOG(gDocShellLog, PR_LOG_DEBUG,
               ("nsDocShell[%p]::LoadErrorPage(\"%s\", \"%s\", {...}, [%s])\n", this,
                spec.get(), NS_ConvertUTF16toUTF8(aURL).get(), chanName.get()));
    }
#endif
    // Create an shistory entry for the old load, if we have a channel
    if (aFailedChannel) {
        mURIResultedInDocument = PR_TRUE;
        OnLoadingSite(aFailedChannel, PR_TRUE, PR_FALSE);
    } else if (aURI) {
        mURIResultedInDocument = PR_TRUE;
        OnNewURI(aURI, nsnull, mLoadType, PR_TRUE, PR_FALSE);
    }

    nsCAutoString url;
    nsCAutoString charset;
    if (aURI)
    {
        // Set our current URI
        SetCurrentURI(aURI);

        nsresult rv = aURI->GetSpec(url);
        rv |= aURI->GetOriginCharset(charset);
        NS_ENSURE_SUCCESS(rv, rv);
    }
    else if (aURL)
    {
        CopyUTF16toUTF8(aURL, url);
    }
    else
    {
        return NS_ERROR_INVALID_POINTER;
    }

    // Create a URL to pass all the error information through to the page.

    char *escapedUrl = nsEscape(url.get(), url_Path);
    char *escapedCharset = nsEscape(charset.get(), url_Path);
    char *escapedError = nsEscape(NS_ConvertUTF16toUTF8(aErrorType).get(), url_Path);
    char *escapedDescription = nsEscape(NS_ConvertUTF16toUTF8(aDescription).get(), url_Path);

    nsCString errorPageUrl("about:neterror?e=");

    errorPageUrl.AppendASCII(escapedError);
    errorPageUrl.AppendLiteral("&u=");
    errorPageUrl.AppendASCII(escapedUrl);
    errorPageUrl.AppendLiteral("&c=");
    errorPageUrl.AppendASCII(escapedCharset);
    errorPageUrl.AppendLiteral("&d=");
    errorPageUrl.AppendASCII(escapedDescription);

    nsMemory::Free(escapedDescription);
    nsMemory::Free(escapedError);
    nsMemory::Free(escapedUrl);
    nsMemory::Free(escapedCharset);

    nsCOMPtr<nsIURI> errorPageURI;
    nsresult rv = NS_NewURI(getter_AddRefs(errorPageURI), errorPageUrl);
    NS_ENSURE_SUCCESS(rv, rv);

    return InternalLoad(errorPageURI, nsnull, nsnull, PR_TRUE, nsnull, nsnull,
                        nsnull, nsnull, LOAD_ERROR_PAGE,
                        nsnull, PR_TRUE, nsnull, nsnull);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsDocShell::LoadHistoryEntry ( nsISHEntry aEntry,
PRUint32  aLoadType 
) [protected]

Definition at line 7908 of file nsDocShell.cpp.

{
    nsresult rv;
    nsCOMPtr<nsIURI> uri;
    nsCOMPtr<nsIInputStream> postData;
    nsCOMPtr<nsIURI> referrerURI;
    nsCAutoString contentType;
    nsCOMPtr<nsISupports> owner;

    NS_ENSURE_TRUE(aEntry, NS_ERROR_FAILURE);

    NS_ENSURE_SUCCESS(aEntry->GetURI(getter_AddRefs(uri)), NS_ERROR_FAILURE);
    NS_ENSURE_SUCCESS(aEntry->GetReferrerURI(getter_AddRefs(referrerURI)),
                      NS_ERROR_FAILURE);
    NS_ENSURE_SUCCESS(aEntry->GetPostData(getter_AddRefs(postData)),
                      NS_ERROR_FAILURE);
    NS_ENSURE_SUCCESS(aEntry->GetContentType(contentType), NS_ERROR_FAILURE);

    nsCOMPtr<nsISHEntry_MOZILLA_1_8_BRANCH> branchEntry =
        do_QueryInterface(aEntry);
    NS_ENSURE_TRUE(branchEntry, NS_ERROR_UNEXPECTED);
    NS_ENSURE_SUCCESS(branchEntry->GetOwner(getter_AddRefs(owner)),
                      NS_ERROR_FAILURE);
    

    PRBool isJavaScript, isViewSource, isData;
    // Calling CreateAboutBlankContentViewer can set mOSHE to null, and if
    // that's the only thing holding a ref to aEntry that will cause aEntry to
    // die while we're loading it.  So hold a strong ref to aEntry here, just
    // in case.
    nsCOMPtr<nsISHEntry> kungFuDeathGrip(aEntry);
    if ((NS_SUCCEEDED(uri->SchemeIs("javascript", &isJavaScript)) &&
         isJavaScript) ||
        (NS_SUCCEEDED(uri->SchemeIs("view-source", &isViewSource)) &&
         isViewSource) ||
        (NS_SUCCEEDED(uri->SchemeIs("data", &isData)) && isData)) {
        // We're loading a javascript: or data: URL from session
        // history. Replace the current document with about:blank to
        // prevent anything from the current document from leaking
        // into any JavaScript code in the URL.
        rv = CreateAboutBlankContentViewer();

        if (NS_FAILED(rv)) {
            // The creation of the intermittent about:blank content
            // viewer failed for some reason (potentially because the
            // user prevented it). Interrupt the history load.
            return NS_OK;
        }

        if (!owner) {
            // Ensure that we have an owner, just to make sure that nothing
            // reuses the principal of the about:blank page that just got
            // created.
            nsCOMPtr<nsIScriptSecurityManager> secMan = 
                do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
            NS_ENSURE_SUCCESS(rv, rv);

            nsCOMPtr<nsIPrincipal> prin;
            secMan->GetCodebasePrincipal(uri, getter_AddRefs(prin));
            owner = prin;
            NS_ENSURE_TRUE(owner, NS_ERROR_OUT_OF_MEMORY);
        }
    }

    /* If there is a valid postdata *and* the user pressed
     * reload or shift-reload, take user's permission before we  
     * repost the data to the server.
     */
    if ((aLoadType & LOAD_CMD_RELOAD) && postData) {

      nsCOMPtr<nsIPrompt> prompter;
      PRBool repost;
      nsCOMPtr<nsIStringBundle> stringBundle;
      GetPromptAndStringBundle(getter_AddRefs(prompter), 
                                getter_AddRefs(stringBundle));
 
      if (stringBundle && prompter) {
        nsXPIDLString messageStr;
        nsresult rv = stringBundle->GetStringFromName(NS_LITERAL_STRING("repostConfirm").get(), 
                                                      getter_Copies(messageStr));
          
        if (NS_SUCCEEDED(rv) && messageStr) {
          prompter->Confirm(nsnull, messageStr, &repost);
          /* If the user pressed cancel in the dialog, return.  We're
           * done here.
           */
          if (!repost)
            return NS_BINDING_ABORTED;  
        }
      }
    }

    rv = InternalLoad(uri,
                      referrerURI,
                      owner,
                      INTERNAL_LOAD_FLAGS_NONE, // Do not inherit owner from document (security-critical!)
                      nsnull,            // No window target
                      contentType.get(), // Type hint
                      postData,          // Post data stream
                      nsnull,            // No headers stream
                      aLoadType,         // Load type
                      aEntry,            // SHEntry
                      PR_TRUE,
                      nsnull,            // No nsIDocShell
                      nsnull);           // No nsIRequest
    return rv;
}

Here is the call graph for this function:

void nsIWebPageDescriptor::loadPage ( in nsISupports  aPageDescriptor,
in unsigned long  aDisplayType 
) [inherited]

Tells the object to load the page specified by the page descriptor.

Returns:
NS_OK - NS_ERROR_FAILURE -
void nsIDocShell::loadStream ( in nsIInputStream  aStream,
in nsIURI  aURI,
in ACString  aContentType,
in ACString  aContentCharset,
in nsIDocShellLoadInfo  aLoadInfo 
) [inherited]

Loads a given stream.

This will give priority to loading the requested stream in the object implementing this interface. If it can't be loaded here however, the URL dispatched will go through its normal process of content loading.

Parameters:
aStream- The input stream that provides access to the data to be loaded. This must be a blocking, threadsafe stream implementation.
aURI- The URI representing the stream, or null.
aContentType- The type (MIME) of data being loaded (empty if unknown).
aContentCharset- The charset of the data being loaded (empty if unknown).
aLoadInfo- This is the extended load info for this load. This most often will be null, but if you need to do additional setup for this load you can get a loadInfo object by calling createLoadInfo. Once you have this object you can set the needed properties on it and then pass it to loadStream.
void nsIDocShell::loadURI ( in nsIURI  uri,
in nsIDocShellLoadInfo  loadInfo,
in unsigned long  aLoadFlags,
in boolean  firstParty 
) [inherited]

Loads a given URI.

This will give priority to loading the requested URI in the object implementing this interface. If it can't be loaded here however, the URL dispatcher will go through its normal process of content loading.

Parameters:
uri- The URI to load.
loadInfo- This is the extended load info for this load. This most often will be null, but if you need to do additional setup for this load you can get a loadInfo object by calling createLoadInfo. Once you have this object you can set the needed properties on it and then pass it to loadURI.
aLoadFlags- Flags to modify load behaviour. Flags are defined in nsIWebNavigation.
void nsIWebNavigation::loadURI ( in wstring  aURI,
in unsigned long  aLoadFlags,
in nsIURI  aReferrer,
in nsIInputStream  aPostData,
in nsIInputStream  aHeaders 
) [inherited]

Loads a given URI.

This will give priority to loading the requested URI in the object implementing this interface. If it can't be loaded here however, the URI dispatcher will go through its normal process of content loading.

Parameters:
aURIThe URI string to load. For HTTP and FTP URLs and possibly others, characters above U+007F will be converted to UTF-8 and then URL- escaped per the rules of RFC 2396.
aLoadFlagsFlags modifying load behaviour. This parameter is a bitwise combination of the load flags defined above. (Undefined bits are reserved for future use.) Generally you will pass LOAD_FLAGS_NONE for this parameter.
aReferrerThe referring URI. If this argument is null, then the referring URI will be inferred internally.
aPostDataIf the URI corresponds to a HTTP request, then this stream is appended directly to the HTTP request headers. It may be prefixed with additional HTTP headers. This stream must contain a "\r\n" sequence separating any HTTP headers from the HTTP request body. This parameter is optional and may be null.
aHeadersIf the URI corresponds to a HTTP request, then any HTTP headers contained in this stream are set on the HTTP request. The HTTP header stream is formatted as: ( HEADER "\r\n" )* This parameter is optional and may be null.
void nsIEditorDocShell::makeEditable ( in boolean  inWaitForUriLoad) [inherited]

Make this docShell editable, setting a flag that causes an editor to get created, either immediately, or after a url has been loaded.

Parameters:
inWaitForUriLoadtrue to wait for a URI before creating the editor.
boolean nsIDocShellTreeItem::nameEquals ( in wstring  name) [inherited]

Compares the provided name against the item's name and returns the appropriate result.

Returns:
PR_TRUE if names match; PR_FALSE otherwise.
nsresult nsDocShell::NewContentViewerObj ( const char *  aContentType,
nsIRequest request,
nsILoadGroup aLoadGroup,
nsIStreamListener **  aContentHandler,
nsIContentViewer **  aViewer 
) [protected]

Definition at line 5917 of file nsDocShell.cpp.

{
    nsCOMPtr<nsIChannel> aOpenedChannel = do_QueryInterface(request);

    nsresult rv;
    nsCOMPtr<nsICategoryManager> catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
    if (NS_FAILED(rv))
      return rv;
    
    nsXPIDLCString contractId;
    rv = catMan->GetCategoryEntry("Gecko-Content-Viewers", aContentType, getter_Copies(contractId));

    // Create an instance of the document-loader-factory
    nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory;
    if (NS_SUCCEEDED(rv))
        docLoaderFactory = do_GetService(contractId.get());

    if (!docLoaderFactory) {
        return NS_ERROR_FAILURE;
    }

    // Now create an instance of the content viewer
    // nsLayoutDLF makes the determination if it should be a "view-source" instead of "view"
    NS_ENSURE_SUCCESS(docLoaderFactory->CreateInstance("view",
                                                       aOpenedChannel,
                                                       aLoadGroup, aContentType,
                                                       NS_STATIC_CAST
                                                       (nsIContentViewerContainer
                                                        *, this), nsnull,
                                                       aContentHandler,
                                                       aViewer),
                      NS_ERROR_FAILURE);

    (*aViewer)->SetContainer(NS_STATIC_CAST(nsIContentViewerContainer *, this));
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIChannelEventSink::onChannelRedirect ( in nsIChannel  oldChannel,
in nsIChannel  newChannel,
in unsigned long  flags 
) [inherited]

Called when a redirect occurs.

This may happen due to an HTTP 3xx status code.

Parameters:
oldChannelThe channel that's being redirected.
newChannelThe new channel. This channel is not opened yet.
flagsFlags indicating the type of redirect. A bitmask consisting of flags from above. One of REDIRECT_TEMPORARY and REDIRECT_PERMANENT will always be set.
Exceptions:
<any>Throwing an exception will cancel the load. No network request for the new channel will be made.
PRBool nsDocShell::OnLoadingSite ( nsIChannel aChannel,
PRBool  aFireOnLocationChange,
PRBool  aAddToGlobalHistory = PR_TRUE 
) [protected]

Definition at line 7677 of file nsDocShell.cpp.

{
    nsCOMPtr<nsIURI> uri;
    // If this a redirect, use the final url (uri)
    // else use the original url
    //
    // Note that this should match what documents do (see nsDocument::Reset).
    nsLoadFlags loadFlags = 0;
    aChannel->GetLoadFlags(&loadFlags);
    if (loadFlags & nsIChannel::LOAD_REPLACE)
        aChannel->GetURI(getter_AddRefs(uri));
    else
        aChannel->GetOriginalURI(getter_AddRefs(uri));
    NS_ENSURE_TRUE(uri, PR_FALSE);

    return OnNewURI(uri, aChannel, mLoadType, aFireOnLocationChange,
                    aAddToGlobalHistory);

}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIWebProgressListener::onLocationChange ( in nsIWebProgress  aWebProgress,
in nsIRequest  aRequest,
in nsIURI  aLocation 
) [inherited]

Called when the location of the window being watched changes.

This is not when a load is requested, but rather once it is verified that the load is going to occur in the given window. For instance, a load that starts in a window might send progress and status messages for the new site, but it will not send the onLocationChange until we are sure that we are loading this new page here.

Parameters:
aWebProgressThe nsIWebProgress instance that fired the notification.
aRequestThe associated nsIRequest. This may be null in some cases.
aLocationThe URI of the location that is being loaded.
PRBool nsDocShell::OnNewURI ( nsIURI aURI,
nsIChannel aChannel,
PRUint32  aLoadType,
PRBool  aFireOnLocationChange,
PRBool  aAddToGlobalHistory = PR_TRUE 
) [protected]

Definition at line 7514 of file nsDocShell.cpp.

{
    NS_ASSERTION(aURI, "uri is null");
#if defined(PR_LOGGING) && defined(DEBUG)
    if (PR_LOG_TEST(gDocShellLog, PR_LOG_DEBUG)) {
        nsCAutoString spec;
        aURI->GetSpec(spec);

        nsCAutoString chanName;
        if (aChannel)
            aChannel->GetName(chanName);
        else
            chanName.AssignLiteral("<no channel>");

        PR_LOG(gDocShellLog, PR_LOG_DEBUG,
               ("nsDocShell[%p]::OnNewURI(\"%s\", [%s], 0x%x)\n", this, spec.get(),
                chanName.get(), aLoadType));
    }
#endif

    PRBool updateHistory = PR_TRUE;
    PRBool equalUri = PR_FALSE;
    PRBool shAvailable = PR_TRUE;  

    // Get the post data from the channel
    nsCOMPtr<nsIInputStream> inputStream;
    if (aChannel) {
        nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aChannel));
        
        // Check if the HTTPChannel is hiding under a multiPartChannel
        if (!httpChannel)  {
            GetHttpChannel(aChannel, getter_AddRefs(httpChannel));
        }

        if (httpChannel) {
            nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(httpChannel));
            if (uploadChannel) {
                uploadChannel->GetUploadStream(getter_AddRefs(inputStream));
            }
        }
    }
    /* Create SH Entry (mLSHE) only if there is a  SessionHistory object (mSessionHistory) in
     * the current frame or in the root docshell
     */
    nsCOMPtr<nsISHistory> rootSH = mSessionHistory;
    if (!rootSH) {
        // Get the handle to SH from the root docshell          
        GetRootSessionHistory(getter_AddRefs(rootSH));
        if (!rootSH)
            shAvailable = PR_FALSE;
    }  // rootSH


    // Determine if this type of load should update history.
    if (aLoadType == LOAD_BYPASS_HISTORY ||
        aLoadType == LOAD_ERROR_PAGE ||
        aLoadType & LOAD_CMD_HISTORY ||
        aLoadType & LOAD_CMD_RELOAD)
        updateHistory = PR_FALSE;

    // Check if the url to be loaded is the same as the one already loaded. 
    if (mCurrentURI)
        aURI->Equals(mCurrentURI, &equalUri);

#ifdef DEBUG
    PR_LOG(gDocShellLog, PR_LOG_DEBUG,
           ("  shAvailable=%i updateHistory=%i equalURI=%i\n",
            shAvailable, updateHistory, equalUri));
#endif

    /* If the url to be loaded is the same as the one already there,
     * and the original loadType is LOAD_NORMAL, LOAD_LINK, or
     * LOAD_STOP_CONTENT, set loadType to LOAD_NORMAL_REPLACE so that
     * AddToSessionHistory() won't mess with the current SHEntry and
     * if this page has any frame children, it also will be handled
     * properly. see bug 83684
     *
     * XXX Hopefully changing the loadType at this time will not hurt  
     *  anywhere. The other way to take care of sequentially repeating
     *  frameset pages is to add new methods to nsIDocShellTreeItem.
     * Hopefully I don't have to do that. 
     */
    if (equalUri &&
        (mLoadType == LOAD_NORMAL ||
         mLoadType == LOAD_LINK ||
         mLoadType == LOAD_STOP_CONTENT) &&
        !inputStream)
    {
        mLoadType = LOAD_NORMAL_REPLACE;
    }

    // If this is a refresh to the currently loaded url, we don't
    // have to update session or global history.
    if (mLoadType == LOAD_REFRESH && !inputStream && equalUri) {
        SetHistoryEntry(&mLSHE, mOSHE);
    }


    /* If the user pressed shift-reload, cache will create a new cache key
     * for the page. Save the new cacheKey in Session History. 
     * see bug 90098
     */
    if (aChannel && aLoadType == LOAD_RELOAD_BYPASS_CACHE ||
        aLoadType == LOAD_RELOAD_BYPASS_PROXY ||
        aLoadType == LOAD_RELOAD_BYPASS_PROXY_AND_CACHE) {                 
        NS_ASSERTION(!updateHistory,
                     "We shouldn't be updating history for forced reloads!");
        
        nsCOMPtr<nsICachingChannel> cacheChannel(do_QueryInterface(aChannel));
        nsCOMPtr<nsISupports>  cacheKey;
        // Get the Cache Key  and store it in SH.         
        if (cacheChannel) 
            cacheChannel->GetCacheKey(getter_AddRefs(cacheKey));
        // If we already have a loading history entry, store the new cache key
        // in it.  Otherwise, since we're doing a reload and won't be updating
        // our history entry, store the cache key in our current history entry.
        if (mLSHE)
            mLSHE->SetCacheKey(cacheKey);
        else if (mOSHE)
            mOSHE->SetCacheKey(cacheKey);
    }

    if (updateHistory && shAvailable) { 
        // Update session history if necessary...
        if (!mLSHE && (mItemType == typeContent) && mURIResultedInDocument) {
            /* This is  a fresh page getting loaded for the first time
             *.Create a Entry for it and add it to SH, if this is the
             * rootDocShell
             */
            (void) AddToSessionHistory(aURI, aChannel, getter_AddRefs(mLSHE));
        }

        // Update Global history
        if (aAddToGlobalHistory) {
            // Get the referrer uri from the channel
            AddToGlobalHistory(aURI, PR_FALSE, aChannel);
        }
    }

    // If this was a history load, update the index in 
    // SH. 
    if (rootSH && (mLoadType & LOAD_CMD_HISTORY)) {
        nsCOMPtr<nsISHistoryInternal> shInternal(do_QueryInterface(rootSH));
        if (shInternal) {
            rootSH->GetIndex(&mPreviousTransIndex);
            shInternal->UpdateIndex();
            rootSH->GetIndex(&mLoadedTransIndex);
#ifdef DEBUG_PAGE_CACHE
            printf("Previous index: %d, Loaded index: %d\n\n",
                   mPreviousTransIndex, mLoadedTransIndex);
#endif
        }
    }
    PRBool onLocationChangeNeeded = SetCurrentURI(aURI, aChannel,
                                                  aFireOnLocationChange);
    // Make sure to store the referrer from the channel, if any
    SetupReferrerFromChannel(aChannel);
    return onLocationChangeNeeded;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIProgressEventSink::onProgress ( in nsIRequest  aRequest,
in nsISupports  aContext,
in unsigned long long  aProgress,
in unsigned long long  aProgressMax 
) [inherited]

Called to notify the event sink that progress has occurred for the given request.

Parameters:
aRequestthe request being observed (may QI to nsIChannel).
aContextif aRequest is a channel, then this parameter is the listener context passed to nsIChannel::asyncOpen.
aProgressnumeric value in the range 0 to aProgressMax indicating the number of bytes transfered thus far.
aProgressMaxnumeric value indicating maximum number of bytes that will be transfered (or 0xFFFFFFFFFFFFFFFF if total is unknown).
void nsIWebProgressListener::onProgressChange ( in nsIWebProgress  aWebProgress,
in nsIRequest  aRequest,
in long  aCurSelfProgress,
in long  aMaxSelfProgress,
in long  aCurTotalProgress,
in long  aMaxTotalProgress 
) [inherited]

Notification that the progress has changed for one of the requests associated with aWebProgress.

Progress totals are reset to zero when all requests in aWebProgress complete (corresponding to onStateChange being called with aStateFlags including the STATE_STOP and STATE_IS_WINDOW flags).

Parameters:
aWebProgressThe nsIWebProgress instance that fired the notification.
aRequestThe nsIRequest that has new progress.
aCurSelfProgressThe current progress for aRequest.
aMaxSelfProgressThe maximum progress for aRequest.
aCurTotalProgressThe current progress for all requests associated with aWebProgress.
aMaxTotalProgressThe total progress for all requests associated with aWebProgress.

NOTE: If any progress value is unknown, or if its value would exceed the maximum value of type long, then its value is replaced with -1.

NOTE: If the object also implements nsIWebProgressListener2 and the caller knows about that interface, this function will not be called. Instead, nsIWebProgressListener2::onProgressChange64 will be called.

void nsDocShell::OnRedirectStateChange ( nsIChannel aOldChannel,
nsIChannel aNewChannel,
PRUint32  aRedirectFlags,
PRUint32  aStateFlags 
) [protected, virtual]

Reimplemented from nsDocLoader.

Definition at line 4805 of file nsDocShell.cpp.

{
    NS_ASSERTION(aStateFlags & STATE_REDIRECTING,
                 "Calling OnRedirectStateChange when there is no redirect");
    if (!(aStateFlags & STATE_IS_DOCUMENT))
        return; // not a toplevel document

    nsCOMPtr<nsIGlobalHistory3> history3(do_QueryInterface(mGlobalHistory));
    nsresult result = NS_ERROR_NOT_IMPLEMENTED;
    if (history3) {
        // notify global history of this redirect
        result = history3->AddDocumentRedirect(aOldChannel, aNewChannel,
                                               aRedirectFlags, !IsFrame());
    }

    if (result == NS_ERROR_NOT_IMPLEMENTED) {
        // when there is no GlobalHistory3, or it doesn't implement
        // AddToplevelRedirect, we fall back to GlobalHistory2.  Just notify
        // that the redirecting page was a redirect so it will be link colored
        // but not visible.
        nsCOMPtr<nsIURI> oldURI;
        aOldChannel->GetURI(getter_AddRefs(oldURI));
        if (! oldURI)
            return; // nothing to tell anybody about
        AddToGlobalHistory(oldURI, PR_TRUE, aOldChannel);
    }
}

Here is the call graph for this function:

void nsISecurityEventSink::onSecurityChange ( in nsISupports  i_Context,
in unsigned long  state 
) [inherited]

Fired when a security change occurs due to page transitions, or end document load.

This interface should be called by a security package (eg Netscape Personal Security Manager) to notify nsIWebProgressListeners that security state has changed. State flags are in nsIWebProgressListener.idl

void nsIWebProgressListener::onSecurityChange ( in nsIWebProgress  aWebProgress,
in nsIRequest  aRequest,
in unsigned long  aState 
) [inherited]

Notification called for security progress.

This method will be called on security transitions (eg HTTP -> HTTPS, HTTPS -> HTTP, FOO -> HTTPS) and after document load completion. It might also be called if an error occurs during network loading.

Parameters:
aWebProgressThe nsIWebProgress instance that fired the notification.
aRequestThe nsIRequest that has new security state.
aStateA value composed of the Security State Flags and the Security Strength Flags listed above. Any undefined bits are reserved for future use.

NOTE: These notifications will only occur if a security package is installed.

void nsIRequestObserver::onStartRequest ( in nsIRequest  aRequest,
in nsISupports  aContext 
) [inherited]

Called to signify the beginning of an asynchronous request.

Parameters:
aRequestrequest being observed
aContextuser defined context

An exception thrown from onStartRequest has the side-effect of causing the request to be canceled.

Here is the caller graph for this function:

void nsIWebProgressListener::onStateChange ( in nsIWebProgress  aWebProgress,
in nsIRequest  aRequest,
in unsigned long  aStateFlags,
in nsresult  aStatus 
) [inherited]

Notification indicating the state has changed for one of the requests associated with aWebProgress.

Parameters:
aWebProgressThe nsIWebProgress instance that fired the notification
aRequestThe nsIRequest that has changed state.
aStateFlagsFlags indicating the new state. This value is a combination of one of the State Transition Flags and one or more of the State Type Flags defined above. Any undefined bits are reserved for future use.
aStatusError status code associated with the state change. This parameter should be ignored unless aStateFlags includes the STATE_STOP bit. The status code indicates success or failure of the request associated with the state change. NOTE: aStatus may be a success code even for server generated errors, such as the HTTP 404 error. In such cases, the request itself should be queried for extended error information (e.g., for HTTP requests see nsIHttpChannel).
void nsIProgressEventSink::onStatus ( in nsIRequest  aRequest,
in nsISupports  aContext,
in nsresult  aStatus,
in wstring  aStatusArg 
) [inherited]

Called to notify the event sink with a status message for the given request.

Parameters:
aRequestthe request being observed (may QI to nsIChannel).
aContextif aRequest is a channel, then this parameter is the listener context passed to nsIChannel::asyncOpen.
aStatusstatus code (not necessarily an error code) indicating the state of the channel (usually the state of the underlying transport). see nsISocketTransport for socket specific status codes.
aStatusArgstatus code argument to be used with the string bundle service to convert the status message into localized, human readable text. the meaning of this parameter is specific to the value of the status code. for socket status codes, this parameter indicates the host:port associated with the status code.
void nsIWebProgressListener::onStatusChange ( in nsIWebProgress  aWebProgress,
in nsIRequest  aRequest,
in nsresult  aStatus,
in wstring  aMessage 
) [inherited]

Notification that the status of a request has changed.

The status message is intended to be displayed to the user (e.g., in the status bar of the browser).

Parameters:
aWebProgressThe nsIWebProgress instance that fired the notification.
aRequestThe nsIRequest that has new status.
aStatusThis value is not an error code. Instead, it is a numeric value that indicates the current status of the request. This interface does not define the set of possible status codes. NOTE: Some status values are defined by nsITransport and nsISocketTransport.
aMessageLocalized text corresponding to aStatus.
void nsIRequestObserver::onStopRequest ( in nsIRequest  aRequest,
in nsISupports  aContext,
in nsresult  aStatusCode 
) [inherited]

Called to signify the end of an asynchronous request.

This call is always preceded by a call to onStartRequest.

Parameters:
aRequestrequest being observed
aContextuser defined context
aStatusCodereason for stopping (NS_OK if completed successfully)

An exception thrown from onStopRequest is generally ignored.

Here is the caller graph for this function:

Definition at line 8028 of file nsDocShell.cpp.

{
    nsresult  rv = NS_OK;
    
    if (mOSHE) {
        PRBool shouldSave;
        GetShouldSaveLayoutState(&shouldSave);
        if (!shouldSave)
            return NS_OK;

        nsCOMPtr<nsIPresShell> shell;
        rv = GetPresShell(getter_AddRefs(shell));
        if (NS_SUCCEEDED(rv) && shell) {
            nsCOMPtr<nsILayoutHistoryState> layoutState;
            rv = shell->CaptureHistoryState(getter_AddRefs(layoutState),
                                            PR_TRUE);
        }
    }

    return rv;
}

Here is the call graph for this function:

Reset state to a new content model within the current document and the document viewer.

Called by the document before initiating an out of band document.write().

static PRUint32 nsDocShell::PRTimeToSeconds ( PRTime  t_usec) [inline, static, protected]

Definition at line 385 of file nsDocShell.h.

    {
      PRTime usec_per_sec;
      PRUint32 t_sec;
      LL_I2L(usec_per_sec, PR_USEC_PER_SEC);
      LL_DIV(t_usec, t_usec, usec_per_sec);
      LL_L2I(t_sec, t_usec);
      return t_sec;
    }

Here is the caller graph for this function:

void nsIRefreshURI::refreshURI ( in nsIURI  aURI,
in long  aMillis,
in boolean  aRepeat,
in boolean  aMetaRefresh 
) [inherited]

Load a uri after waiting for aMillis milliseconds.

If the docshell is busy loading a page currently, the refresh request will be queued and executed when the current load finishes.

Parameters:
aUriThe uri to refresh.
aMillisThe number of milliseconds to wait.
aRepeatFlag to indicate if the uri is to be repeatedly refreshed every aMillis milliseconds. aMetaRefresh Flag to indicate if this is a Meta refresh.

Definition at line 4616 of file nsDocShell.cpp.

{
    if (!mRefreshURIList)
        return NS_OK;
    PRUint32 n = 0;
    mRefreshURIList->Count(&n);

    while (n) {
        nsCOMPtr<nsISupports> element;
        mRefreshURIList->GetElementAt(--n, getter_AddRefs(element));
        nsCOMPtr<nsRefreshTimer> refreshInfo(do_QueryInterface(element));

        if (refreshInfo) {   
            // This is the nsRefreshTimer object, waiting to be
            // setup in a timer object and fired.                         
            // Create the timer and  trigger it.
            PRUint32 delay = refreshInfo->GetDelay();
            nsCOMPtr<nsITimer> timer = do_CreateInstance("@mozilla.org/timer;1");
            if (timer) {    
                // Replace the nsRefreshTimer element in the queue with
                // its corresponding timer object, so that in case another
                // load comes through before the timer can go off, the timer will
                // get cancelled in CancelRefreshURITimer()
                mRefreshURIList->ReplaceElementAt(timer, n);
                timer->InitWithCallback(refreshInfo, delay, nsITimer::TYPE_ONE_SHOT);
            }           
        }        
    }  // while
 
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIWebNavigation::reload ( in unsigned long  aReloadFlags) [inherited]

Tells the Object to reload the current page.

There may be cases where the user will be asked to confirm the reload (for example, when it is determined that the request is non-idempotent).

Parameters:
aReloadFlagsFlags modifying load behaviour. This parameter is a bitwise combination of the Load Flags defined above. (Undefined bits are reserved for future use.) Generally you will pass LOAD_FLAGS_NONE for this parameter.
Exceptions:
NS_BINDING_ABORTEDIndicating that the user canceled the reload.

Definition at line 673 of file nsDocLoader.cpp.

{
  nsresult rv = mChildList.RemoveElement(aChild) ? NS_OK : NS_ERROR_FAILURE;
  if (NS_SUCCEEDED(rv)) {
    aChild->SetDocLoaderParent(nsnull);
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Removes a previously registered listener of progress events.

Parameters:
aListenerThe listener interface previously registered with a call to addProgressListener.
Exceptions:
NS_ERROR_FAILUREIndicates that aListener was not registered.
void nsIBaseWindow::repaint ( in boolean  force) [inherited]

Tell the window to repaint itself.

Parameters:
aForce- if true, repaint immediately if false, the window may defer repainting as it sees fit.

Definition at line 5433 of file nsDocShell.cpp.

{
    // This section of code follows the same ordering as CreateContentViewer.
    if (!mLSHE)
        return NS_ERROR_FAILURE;

    nsCOMPtr<nsIContentViewer> viewer;
    mLSHE->GetContentViewer(getter_AddRefs(viewer));
    if (!viewer)
        return NS_ERROR_FAILURE;

    if (mSavingOldViewer) {
        // We determined that it was safe to cache the document presentation
        // at the time we initiated the new load.  We need to check whether
        // it's still safe to do so, since there may have been DOM mutations
        // or new requests initiated.
        nsCOMPtr<nsIDOMDocument> domDoc;
        viewer->GetDOMDocument(getter_AddRefs(domDoc));
        nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
        nsIRequest *request = nsnull;
        if (doc)
            request = doc->GetChannel();
        mSavingOldViewer = CanSavePresentation(mLoadType, request, doc);
    }

    nsCOMPtr<nsIMarkupDocumentViewer> oldMUDV(do_QueryInterface(mContentViewer));
    nsCOMPtr<nsIMarkupDocumentViewer> newMUDV(do_QueryInterface(viewer));
    float zoom = 1.0;
    if (oldMUDV && newMUDV)
        oldMUDV->GetTextZoom(&zoom);

    // Protect against mLSHE going away via a load triggered from
    // pagehide or unload.
    nsCOMPtr<nsISHEntry> origLSHE = mLSHE;

    // Notify the old content viewer that it's being hidden.
    FirePageHideNotification(!mSavingOldViewer);

    // If mLSHE was changed as a result of the pagehide event, then
    // something else was loaded.  Don't finish restoring.
    if (mLSHE != origLSHE)
      return NS_OK;

    // Set mFiredUnloadEvent = PR_FALSE so that the unload handler for the
    // *new* document will fire.
    mFiredUnloadEvent = PR_FALSE;

    mURIResultedInDocument = PR_TRUE;
    nsCOMPtr<nsISHistory> rootSH;
    GetRootSessionHistory(getter_AddRefs(rootSH));
    if (rootSH) {
        nsCOMPtr<nsISHistoryInternal> hist = do_QueryInterface(rootSH);
        rootSH->GetIndex(&mPreviousTransIndex);
        hist->UpdateIndex();
        rootSH->GetIndex(&mLoadedTransIndex);
#ifdef DEBUG_PAGE_CACHE
        printf("Previous index: %d, Loaded index: %d\n\n", mPreviousTransIndex,
                   mLoadedTransIndex);
#endif
    }

    // Rather than call Embed(), we will retrieve the viewer from the session
    // history entry and swap it in.
    // XXX can we refactor this so that we can just call Embed()?
    // XXX PersistLayoutHistoryState() ?
    nsresult rv;
    if (mContentViewer) {
        if (mSavingOldViewer && NS_FAILED(CaptureState())) {
            if (mOSHE) {
                mOSHE->SyncPresentationState();
            }
            mSavingOldViewer = PR_FALSE;
        }
    }

    mSavedRefreshURIList = nsnull;

    // In cases where we use a transient about:blank viewer between loads,
    // we never show the transient viewer, so _its_ previous viewer is never
    // unhooked from the view hierarchy.  Destroy any such previous viewer now,
    // before we grab the root view sibling, so that we don't grab a view
    // that's about to go away.

    if (mContentViewer) {
        nsCOMPtr<nsIContentViewer> previousViewer;
        mContentViewer->GetPreviousViewer(getter_AddRefs(previousViewer));
        if (previousViewer) {
            mContentViewer->SetPreviousViewer(nsnull);
            previousViewer->Destroy();
        }
    }

    // Save off the root view's parent and sibling so that we can insert the
    // new content viewer's root view at the same position.  Also save the
    // bounds of the root view's widget.

    nsIView *rootViewSibling = nsnull, *rootViewParent = nsnull;
    nsRect newBounds(0, 0, 0, 0);

    nsCOMPtr<nsIPresShell> oldPresShell;
    nsDocShell::GetPresShell(getter_AddRefs(oldPresShell));
    if (oldPresShell) {
        nsIViewManager *vm = oldPresShell->GetViewManager();
        if (vm) {
            nsIView *oldRootView = nsnull;
            vm->GetRootView(oldRootView);

            if (oldRootView) {
                rootViewSibling = oldRootView->GetNextSibling();
                rootViewParent = oldRootView->GetParent();

                nsIWidget *widget = oldRootView->GetWidget();
                if (widget) {
                    widget->GetBounds(newBounds);
                }
            }
        }
    }

    // Transfer ownership to mContentViewer.  By ensuring that either the
    // docshell or the session history, but not both, have references to the
    // content viewer, we prevent the viewer from being torn down after
    // Destroy() is called.

    if (mContentViewer) {
        mContentViewer->Close(mSavingOldViewer ? mOSHE.get() : nsnull);
        viewer->SetPreviousViewer(mContentViewer);
    }

    mContentViewer.swap(viewer);
    viewer = nsnull; // force a release to complete ownership transfer

    // Grab all of the related presentation from the SHEntry now.
    // mLSHE may be cleared before we need this data.
    nsCOMPtr<nsISupports> windowState;
    mLSHE->GetWindowState(getter_AddRefs(windowState));
    mLSHE->SetWindowState(nsnull);

    PRBool sticky;
    mLSHE->GetSticky(&sticky);

    nsCOMPtr<nsIDOMDocument> domDoc;
    mContentViewer->GetDOMDocument(getter_AddRefs(domDoc));

    // get the previous content viewer size
    nsRect oldBounds(0, 0, 0, 0);
    mLSHE->GetViewerBounds(oldBounds);

    nsCOMPtr<nsISupportsArray> refreshURIList;
    mLSHE->GetRefreshURIList(getter_AddRefs(refreshURIList));
    mLSHE->SetRefreshURIList(nsnull);

    // Reattach to the window object.
    nsCOMPtr<nsIContentViewer_MOZILLA_1_8_BRANCH> cv18 =
        do_QueryInterface(mContentViewer);
    rv = cv18->OpenWithEntry(windowState, mLSHE);

    // Now that we're done calling OpenWithEntry, we can grab the child
    // shell list off of mLSHE as well.
    nsCOMArray<nsIDocShellTreeItem> childShells;
    PRInt32 i = 0;
    nsCOMPtr<nsIDocShellTreeItem> child;
    while (NS_SUCCEEDED(mLSHE->ChildShellAt(i++, getter_AddRefs(child))) &&
           child) {
        childShells.AppendObject(child);
    }
    mLSHE->ClearChildShells();

    // Now remove it from the cached presentation.
    mLSHE->SetContentViewer(nsnull);
    mEODForCurrentDocument = PR_FALSE;

    // Restore the sticky state of the viewer.  The viewer has set this state
    // on the history entry in Destroy() just before marking itself non-sticky,
    // to avoid teardown of the presentation.
    mContentViewer->SetSticky(sticky);

    // Now that we have switched documents, forget all of our children.
    DestroyChildren();
    NS_ENSURE_SUCCESS(rv, rv);

    // mLSHE is now our currently-loaded document.
    SetHistoryEntry(&mOSHE, mLSHE);
    
    // XXX special wyciwyg handling in Embed()?

    // We aren't going to restore any items from the LayoutHistoryState,
    // but we don't want them to stay around in case the page is reloaded.
    SetLayoutHistoryState(nsnull);

    // This is the end of our Embed() replacement

    mSavingOldViewer = PR_FALSE;
    mEODForCurrentDocument = PR_FALSE;

    // Tell the event loop to favor plevents over user events, see comments
    // in CreateContentViewer.
    if (++gNumberOfDocumentsLoading == 1)
        PL_FavorPerformanceHint(PR_TRUE, NS_EVENT_STARVATION_DELAY_HINT);


    if (oldMUDV && newMUDV)
        newMUDV->SetTextZoom(zoom);

    nsCOMPtr<nsIDocument> document = do_QueryInterface(domDoc);
    if (document) {
        // Use the uri from the mLSHE we had when we entered this function
        // (which need not match the document's URI if anchors are involved),
        // since that's the history entry we're loading.  Note that if we use
        // origLSHE we don't have to worry about whether the entry in question
        // is still mLSHE or whether it's now mOSHE.
        nsCOMPtr<nsIURI> uri;
        origLSHE->GetURI(getter_AddRefs(uri));
        SetCurrentURI(uri, document->GetChannel(), PR_TRUE);
    }

    // This is the end of our CreateContentViewer() replacement.
    // Now we simulate a load.  First, we restore the state of the javascript
    // window object.
    nsCOMPtr<nsPIDOMWindow> privWin =
        do_GetInterface(NS_STATIC_CAST(nsIInterfaceRequestor*, this));
    NS_ASSERTION(privWin, "could not get nsPIDOMWindow interface");

    rv = privWin->RestoreWindowState(windowState);
    NS_ENSURE_SUCCESS(rv, rv);

    // Now, dispatch a title change event which would happed as the
    // <head> is parsed.
    nsCOMPtr<nsIDOMNSDocument> nsDoc = do_QueryInterface(document);
    if (nsDoc) {
        const nsAFlatString &title = document->GetDocumentTitle();
        nsDoc->SetTitle(title);
    }

    // Now we simulate appending child docshells for subframes.
    for (i = 0; i < childShells.Count(); ++i) {
        nsIDocShellTreeItem *childItem = childShells.ObjectAt(i);
        nsCOMPtr<nsIDocShell> childShell = do_QueryInterface(childItem);

        // Make sure to not clobber the state of the child.  Since AddChild
        // always clobbers it, save it off first.
        PRBool allowPlugins;
        childShell->GetAllowPlugins(&allowPlugins);

        PRBool allowJavascript;
        childShell->GetAllowJavascript(&allowJavascript);

        PRBool allowRedirects;
        childShell->GetAllowMetaRedirects(&allowRedirects);

        PRBool allowSubframes;
        childShell->GetAllowSubframes(&allowSubframes);

        PRBool allowImages;
        childShell->GetAllowImages(&allowImages);
        
        AddChild(childItem);

        childShell->SetAllowPlugins(allowPlugins);
        childShell->SetAllowJavascript(allowJavascript);
        childShell->SetAllowMetaRedirects(allowRedirects);
        childShell->SetAllowSubframes(allowSubframes);
        childShell->SetAllowImages(allowImages);

        rv = childShell->BeginRestore(nsnull, PR_FALSE);
        NS_ENSURE_SUCCESS(rv, rv);
    }

    nsCOMPtr<nsIPresShell> shell;
    nsDocShell::GetPresShell(getter_AddRefs(shell));

    nsIViewManager *newVM = shell ? shell->GetViewManager() : nsnull;
    nsIView *newRootView = nsnull;
    if (newVM)
        newVM->GetRootView(newRootView);

    // Insert the new root view at the correct location in the view tree.
    if (rootViewParent) {
        nsIViewManager *parentVM = rootViewParent->GetViewManager();

        if (parentVM && newRootView) {
            // InsertChild(parent, child, sib, PR_TRUE) inserts the child after
            // sib in content order, which is before sib in view order. BUT
            // when sib is null it inserts at the end of the the document
            // order, i.e., first in view order.  But when oldRootSibling is
            // null, the old root as at the end of the view list --- last in
            // content order --- and we want to call InsertChild(parent, child,
            // nsnull, PR_FALSE) in that case.
            parentVM->InsertChild(rootViewParent, newRootView,
                                  rootViewSibling,
                                  rootViewSibling ? PR_TRUE : PR_FALSE);

            NS_ASSERTION(newRootView->GetNextSibling() == rootViewSibling,
                         "error in InsertChild");
        }
    }

    // Now that all of the child docshells have been put into place, we can
    // restart the timers for the window and all of the child frames.
    privWin->ResumeTimeouts();

    // Restore the refresh URI list.  The refresh timers will be restarted
    // when EndPageLoad() is called.
    mRefreshURIList = refreshURIList;

    // Meta-refresh timers have been restarted for this shell, but not
    // for our children.  Walk the child shells and restart their timers.
    PRInt32 n = mChildList.Count();
    for (i = 0; i < n; ++i) {
        nsCOMPtr<nsIDocShell> child = do_QueryInterface(ChildAt(i));
        if (child)
            child->ResumeRefreshURIs();
    }

    // Make sure this presentation is the same size as the previous
    // presentation.  If this is not the same size we showed it at last time,
    // then we need to resize the widget.

    // XXXbryner   This interacts poorly with Firefox's infobar.  If the old
    // presentation had the infobar visible, then we will resize the new
    // presentation to that smaller size.  However, firing the locationchanged
    // event will hide the infobar, which will immediately resize the window
    // back to the larger size.  A future optimization might be to restore
    // the presentation at the "wrong" size, then fire the locationchanged
    // event and check whether the docshell's new size is the same as the
    // cached viewer size (skipping the resize if they are equal).

    if (newRootView) {
        nsIWidget *widget = newRootView->GetWidget();
        if (widget && !newBounds.IsEmpty() && newBounds != oldBounds) {
#ifdef DEBUG_PAGE_CACHE
            printf("resize widget(%d, %d, %d, %d)\n", newBounds.x,
                   newBounds.y, newBounds.width, newBounds.height);
#endif

            widget->Resize(newBounds.x, newBounds.y, newBounds.width,
                           newBounds.height, PR_FALSE);
        }
    }

    // Simulate the completion of the load.
    nsDocShell::FinishRestore();

    // Restart plugins, and paint the content.
    if (shell)
        shell->Thaw();

    nsCOMPtr<nsPIDOMWindow_MOZILLA_1_8_BRANCH> win18 = do_QueryInterface(privWin);
    NS_ENSURE_STATE(win18);
    return win18->FireDelayedDOMEvents();
}

Here is the call graph for this function:

nsresult nsDocShell::RestorePresentation ( nsISHEntry aSHEntry,
PRBool aRestoring 
) [protected]

Definition at line 5351 of file nsDocShell.cpp.

{
    NS_ASSERTION(mLoadType & LOAD_CMD_HISTORY,
                 "RestorePresentation should only be called for history loads");

    nsCOMPtr<nsIContentViewer> viewer;
    aSHEntry->GetContentViewer(getter_AddRefs(viewer));

#ifdef DEBUG_PAGE_CACHE
    nsCOMPtr<nsIURI> uri;
    aSHEntry->GetURI(getter_AddRefs(uri));

    nsCAutoString spec;
    if (uri)
        uri->GetSpec(spec);
#endif

    *aRestoring = PR_FALSE;

    if (!viewer) {
#ifdef DEBUG_PAGE_CACHE
        printf("no saved presentation for uri: %s\n", spec.get());
#endif
        return NS_OK;
    }

    // We need to make sure the content viewer's container is this docshell.
    // In subframe navigation, it's possible for the docshell that the
    // content viewer was originally loaded into to be replaced with a
    // different one.  We don't currently support restoring the presentation
    // in that case.

    nsCOMPtr<nsISupports> container;
    viewer->GetContainer(getter_AddRefs(container));
    if (!::SameCOMIdentity(container, GetAsSupports(this))) {
#ifdef DEBUG_PAGE_CACHE
        printf("No valid container, clearing presentation\n");
#endif
        aSHEntry->SetContentViewer(nsnull);
        return NS_ERROR_FAILURE;
    }

    NS_ASSERTION(mContentViewer != viewer, "Restoring existing presentation");

#ifdef DEBUG_PAGE_CACHE
    printf("restoring presentation from session history: %s\n", spec.get());
#endif

    SetHistoryEntry(&mLSHE, aSHEntry);

    // Add the request to our load group.  We do this before swapping out
    // the content viewers so that consumers of STATE_START can access
    // the old document.  We only deal with the toplevel load at this time --
    // to be consistent with normal document loading, subframes cannot start
    // loading until after data arrives, which is after STATE_START completes.

    BeginRestore(viewer, PR_TRUE);

    // Post a PLEvent that will remove the request after we've returned
    // to the event loop.  This mimics the way it is called by nsIChannel
    // implementations.

    nsCOMPtr<nsIEventQueue> uiThreadQueue;
    NS_GetMainEventQ(getter_AddRefs(uiThreadQueue));
    NS_ENSURE_TRUE(uiThreadQueue, NS_ERROR_UNEXPECTED);

    PLEvent *evt = new RestorePresentationEvent(this);
    NS_ENSURE_TRUE(evt, NS_ERROR_OUT_OF_MEMORY);

    nsresult rv = uiThreadQueue->PostEvent(evt);
    if (NS_SUCCEEDED(rv)) {
        // The rest of the restore processing will happen on our PLEvent
        // callback.
        *aRestoring = PR_TRUE;
    } else {
        PL_DestroyEvent(evt);
    }

    return NS_OK;
}

Here is the call graph for this function:

Restart the XPCOM timers for each meta-refresh URI in this docshell, and this docshell's children, recursively.

If the timers are already running, this has no effect.

nsIDocumentLoader* nsDocLoader::SafeChildAt ( PRInt32  i) [inline, protected, inherited]

Definition at line 150 of file nsDocLoader.h.

                                              {
        return NS_STATIC_CAST(nsDocLoader*, mChildList.SafeElementAt(i));
    }
void nsITextScroll::scrollByLines ( in long  numLines) [inherited]

Scroll the view up or down by aNumLines lines.

positive values move down in the view. Prevents scrolling off the end of the view.

Parameters:
numLinesnumber of lines to scroll the view by
void nsITextScroll::scrollByPages ( in long  numPages) [inherited]

Scroll the view up or down by numPages pages.

a page is considered to be the amount displayed by the clip view. positive values move down in the view. Prevents scrolling off the end of the view.

Parameters:
numPagesnumber of pages to scroll the view by
NS_IMETHODIMP nsDocShell::ScrollIfAnchor ( nsIURI aURI,
PRBool aWasAnchor,
PRUint32  aLoadType,
nscoord cx,
nscoord cy 
) [protected]

Definition at line 7298 of file nsDocShell.cpp.

{
    NS_ASSERTION(aURI, "null uri arg");
    NS_ASSERTION(aWasAnchor, "null anchor arg");

    if (aURI == nsnull || aWasAnchor == nsnull) {
        return NS_ERROR_FAILURE;
    }

    *aWasAnchor = PR_FALSE;

    if (!mCurrentURI) {
        return NS_OK;
    }

    nsCOMPtr<nsIPresShell> shell;
    nsresult rv = GetPresShell(getter_AddRefs(shell));
    if (NS_FAILED(rv) || !shell) {
        // If we failed to get the shell, or if there is no shell,
        // nothing left to do here.
        
        return rv;
    }

    // NOTE: we assume URIs are absolute for comparison purposes

    nsCAutoString currentSpec;
    NS_ENSURE_SUCCESS(mCurrentURI->GetSpec(currentSpec),
                      NS_ERROR_FAILURE);

    nsCAutoString newSpec;
    NS_ENSURE_SUCCESS(aURI->GetSpec(newSpec), NS_ERROR_FAILURE);

    // Search for hash marks in the current URI and the new URI and
    // take a copy of everything to the left of the hash for
    // comparison.

    const char kHash = '#';

    // Split the new URI into a left and right part
    // (assume we're parsing it out right
    nsACString::const_iterator urlStart, urlEnd, refStart, refEnd;
    newSpec.BeginReading(urlStart);
    newSpec.EndReading(refEnd);
    
    PRInt32 hashNew = newSpec.FindChar(kHash);
    if (hashNew == 0) {
        return NS_OK;           // Strange URI
    }

    if (hashNew > 0) {
        // found it
        urlEnd = urlStart;
        urlEnd.advance(hashNew);
        
        refStart = urlEnd;
        ++refStart;             // advanced past '#'
        
    }
    else {
        // no hash at all
        urlEnd = refStart = refEnd;
    }
    const nsACString& sNewLeft = Substring(urlStart, urlEnd);
    const nsACString& sNewRef =  Substring(refStart, refEnd);
                                          
    // Split the current URI in a left and right part
    nsACString::const_iterator currentLeftStart, currentLeftEnd;
    currentSpec.BeginReading(currentLeftStart);

    PRInt32 hashCurrent = currentSpec.FindChar(kHash);
    if (hashCurrent == 0) {
        return NS_OK;           // Strange URI 
    }

    if (hashCurrent > 0) {
        currentLeftEnd = currentLeftStart;
        currentLeftEnd.advance(hashCurrent);
    }
    else {
        currentSpec.EndReading(currentLeftEnd);
    }

    // If we have no new anchor, we do not want to scroll, unless there is a
    // current anchor and we are doing a history load.  So return if we have no
    // new anchor, and there is no current anchor or the load is not a history
    // load.
    NS_ASSERTION(hashNew != 0 && hashCurrent != 0,
                 "What happened to the early returns above?");
    if (hashNew == kNotFound &&
        (hashCurrent == kNotFound || aLoadType != LOAD_HISTORY)) {
        return NS_OK;
    }

    // Compare the URIs.
    //
    // NOTE: this is a case sensitive comparison because some parts of the
    // URI are case sensitive, and some are not. i.e. the domain name
    // is case insensitive but the the paths are not.
    //
    // This means that comparing "http://www.ABC.com/" to "http://www.abc.com/"
    // will fail this test.

    if (!Substring(currentLeftStart, currentLeftEnd).Equals(sNewLeft)) {
        return NS_OK;           // URIs not the same
    }

    // Now we know we are dealing with an anchor
    *aWasAnchor = PR_TRUE;

    // Both the new and current URIs refer to the same page. We can now
    // browse to the hash stored in the new URI.
    //
    // But first let's capture positions of scroller(s) that can
    // (and usually will) be modified by GoToAnchor() call.

    GetCurScrollPos(ScrollOrientation_X, cx);
    GetCurScrollPos(ScrollOrientation_Y, cy);

    if (!sNewRef.IsEmpty()) {
        // anchor is there, but if it's a load from history,
        // we don't have any anchor jumping to do
        PRBool scroll = aLoadType != LOAD_HISTORY &&
                        aLoadType != LOAD_RELOAD_NORMAL;

        char *str = ToNewCString(sNewRef);
        if (!str) {
            return NS_ERROR_OUT_OF_MEMORY;
        }

        // nsUnescape modifies the string that is passed into it.
        nsUnescape(str);

        // We assume that the bytes are in UTF-8, as it says in the
        // spec:
        // http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.1

        // We try the UTF-8 string first, and then try the document's
        // charset (see below).  If the string is not UTF-8,
        // conversion will fail and give us an empty Unicode string.
        // In that case, we should just fall through to using the
        // page's charset.
        rv = NS_ERROR_FAILURE;
        NS_ConvertUTF8toUCS2 uStr(str);
        if (!uStr.IsEmpty()) {
            rv = shell->GoToAnchor(NS_ConvertUTF8toUCS2(str), scroll);
        }
        nsMemory::Free(str);

        // Above will fail if the anchor name is not UTF-8.  Need to
        // convert from document charset to unicode.
        if (NS_FAILED(rv)) {
                
            // Get a document charset
            NS_ENSURE_TRUE(mContentViewer, NS_ERROR_FAILURE);
            nsCOMPtr<nsIDocumentViewer>
                docv(do_QueryInterface(mContentViewer));
            NS_ENSURE_TRUE(docv, NS_ERROR_FAILURE);
            nsCOMPtr<nsIDocument> doc;
            rv = docv->GetDocument(getter_AddRefs(doc));
            NS_ENSURE_SUCCESS(rv, rv);
            const nsACString &aCharset = doc->GetDocumentCharacterSet();

            nsCOMPtr<nsITextToSubURI> textToSubURI =
                do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv);
            NS_ENSURE_SUCCESS(rv, rv);

            // Unescape and convert to unicode
            nsXPIDLString uStr;

            rv = textToSubURI->UnEscapeAndConvert(PromiseFlatCString(aCharset).get(),
                                                  PromiseFlatCString(sNewRef).get(),
                                                  getter_Copies(uStr));
            NS_ENSURE_SUCCESS(rv, rv);

            // Ignore return value of GoToAnchor, since it will return an error
            // if there is no such anchor in the document, which is actually a
            // success condition for us (we want to update the session history
            // with the new URI no matter whether we actually scrolled
            // somewhere).
            shell->GoToAnchor(uStr, scroll);
        }
    }
    else {

        // Tell the shell it's at an anchor, without scrolling.
        shell->GoToAnchor(EmptyString(), PR_FALSE);
        
        // An empty anchor was found, but if it's a load from history,
        // we don't have to jump to the top of the page. Scrollbar 
        // position will be restored by the caller, based on positions
        // stored in session history.
        if (aLoadType == LOAD_HISTORY || aLoadType == LOAD_RELOAD_NORMAL)
            return rv;
        //An empty anchor. Scroll to the top of the page.
        rv = SetCurScrollPosEx(0, 0);
    }

    return rv;
}

Here is the call graph for this function:

nsresult nsDocShell::SetBaseUrlForWyciwyg ( nsIContentViewer aContentViewer) [protected]

Definition at line 8927 of file nsDocShell.cpp.

{
    if (!aContentViewer)
        return NS_ERROR_FAILURE;

    nsCOMPtr<nsIURI> baseURI;
    nsCOMPtr<nsIDocument> document;
    nsresult rv = NS_ERROR_NOT_AVAILABLE;

    if (sURIFixup)
        rv = sURIFixup->CreateExposableURI(mCurrentURI,
                                           getter_AddRefs(baseURI));

    // Get the current document and set the base uri
    if (baseURI) {
        nsCOMPtr<nsIDocumentViewer> docViewer(do_QueryInterface(aContentViewer));
        if (docViewer) {
            rv = docViewer->GetDocument(getter_AddRefs(document));
            if (document)
                rv = document->SetBaseURI(baseURI);
        }
    }
    return rv;
}

Here is the call graph for this function:

nsresult nsDocShell::SetChildHistoryEntry ( nsISHEntry aEntry,
nsDocShell aShell,
PRInt32  aEntryIndex,
void aData 
) [static, protected]

Definition at line 8197 of file nsDocShell.cpp.

{
    SwapEntriesData *data = NS_STATIC_CAST(SwapEntriesData*, aData);
    nsDocShell *ignoreShell = data->ignoreShell;

    if (!aShell || aShell == ignoreShell)
        return NS_OK;

    nsISHEntry *destTreeRoot = data->destTreeRoot;

    nsCOMPtr<nsISHEntry> destEntry;
    nsCOMPtr<nsISHContainer> container =
        do_QueryInterface(data->destTreeParent);

    if (container) {
        // aEntry is a clone of some child of destTreeParent, but since the
        // trees aren't necessarily in sync, we'll have to locate it.
        // Note that we could set aShell's entry to null if we don't find a
        // corresponding entry under destTreeParent.

        PRUint32 targetID, id;
        aEntry->GetID(&targetID);

        // First look at the given index, since this is the common case.
        nsCOMPtr<nsISHEntry> entry;
        container->GetChildAt(aEntryIndex, getter_AddRefs(entry));
        if (entry && NS_SUCCEEDED(entry->GetID(&id)) && id == targetID) {
            destEntry.swap(entry);
        } else {
            PRInt32 childCount;
            container->GetChildCount(&childCount);
            for (PRInt32 i = 0; i < childCount; ++i) {
                container->GetChildAt(i, getter_AddRefs(entry));
                if (!entry)
                    continue;

                entry->GetID(&id);
                if (id == targetID) {
                    destEntry.swap(entry);
                    break;
                }
            }
        }
    } else {
        destEntry = destTreeRoot;
    }

    aShell->SwapHistoryEntries(aEntry, destEntry);

    // Now handle the children of aEntry.
    SwapEntriesData childData = { ignoreShell, destTreeRoot, destEntry };
    return WalkHistoryEntries(aEntry, aShell,
                              SetChildHistoryEntry, &childData);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIDocShell::setCurrentURI ( in nsIURI  aURI) [inherited]

For editors and suchlike who wish to change the URI associated with the document.

Note if you want to get the current URI, use the read-only property on nsIWebNavigation.

PRBool nsDocShell::SetCurrentURI ( nsIURI aURI,
nsIRequest aRequest,
PRBool  aFireOnLocationChange 
) [protected]

Definition at line 1266 of file nsDocShell.cpp.

{
    SetCurrentURI(aURI, nsnull, PR_TRUE);
    return NS_OK;
}

Here is the caller graph for this function:

void nsIScrollable::setCurScrollPos ( in long  scrollOrientation,
in long  curPos 
) [inherited]
void nsIScrollable::setCurScrollPosEx ( in long  curHorizontalPos,
in long  curVerticalPos 
) [inherited]
void nsIScrollable::setDefaultScrollbarPreferences ( in long  scrollOrientation,
in long  scrollbarPref 
) [inherited]
nsresult nsDocShell::SetDocLoaderParent ( nsDocLoader aLoader) [protected, virtual]

Reimplemented from nsDocLoader.

Definition at line 1891 of file nsDocShell.cpp.

{
    nsDocLoader::SetDocLoaderParent(aParent);

    // Curse ambiguous nsISupports inheritance!
    nsISupports* parent = GetAsSupports(aParent);

    // If parent is another docshell, we inherit all their flags for
    // allowing plugins, scripting etc.
    nsCOMPtr<nsIDocShell> parentAsDocShell(do_QueryInterface(parent));
    if (parentAsDocShell)
    {
        PRBool value;
        if (NS_SUCCEEDED(parentAsDocShell->GetAllowPlugins(&value)))
        {
            SetAllowPlugins(value);
        }
        if (NS_SUCCEEDED(parentAsDocShell->GetAllowJavascript(&value)))
        {
            SetAllowJavascript(value);
        }
        if (NS_SUCCEEDED(parentAsDocShell->GetAllowMetaRedirects(&value)))
        {
            SetAllowMetaRedirects(value);
        }
        if (NS_SUCCEEDED(parentAsDocShell->GetAllowSubframes(&value)))
        {
            SetAllowSubframes(value);
        }
        if (NS_SUCCEEDED(parentAsDocShell->GetAllowImages(&value)))
        {
            SetAllowImages(value);
        }
    }

    nsCOMPtr<nsIURIContentListener> parentURIListener(do_GetInterface(parent));
    if (parentURIListener)
        mContentListener->SetParentContentListener(parentURIListener);
    return NS_OK;
}

Here is the call graph for this function:

void nsIBaseWindow::setFocus ( ) [inherited]

Give the window focus.

void nsDocShell::SetHistoryEntry ( nsCOMPtr< nsISHEntry > *  aPtr,
nsISHEntry aEntry 
) [protected]

Definition at line 8269 of file nsDocShell.cpp.

{
    // We need to sync up the docshell and session history trees for
    // subframe navigation.  If the load was in a subframe, we forward up to
    // the root docshell, which will then recursively sync up all docshells
    // to their corresponding entries in the new session history tree.
    // If we don't do this, then we can cache a content viewer on the wrong
    // cloned entry, and subsequently restore it at the wrong time.

    nsISHEntry *newRootEntry = GetRootSHEntry(aEntry);
    if (newRootEntry) {
        // newRootEntry is now the new root entry.
        // Find the old root entry as well.

        // Need a strong ref. on |oldRootEntry| so it isn't destroyed when
        // SetChildHistoryEntry() does SwapHistoryEntries() (bug 304639).
        nsCOMPtr<nsISHEntry> oldRootEntry = GetRootSHEntry(*aPtr);
        if (oldRootEntry) {
            nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
            GetSameTypeParent(getter_AddRefs(parentAsItem));
            nsCOMPtr<nsIDocShell> rootShell = do_QueryInterface(parentAsItem);
            if (rootShell) { // if we're the root just set it, nothing to swap
                SwapEntriesData data = { this, newRootEntry };
                nsIDocShell *rootIDocShell =
                    NS_STATIC_CAST(nsIDocShell*, rootShell);
                nsDocShell *rootDocShell = NS_STATIC_CAST(nsDocShell*,
                                                          rootIDocShell);

                nsresult rv = SetChildHistoryEntry(oldRootEntry, rootDocShell,
                                                   0, &data);
                NS_ASSERTION(NS_SUCCEEDED(rv), "SetChildHistoryEntry failed");
            }
        }
    }

    *aPtr = aEntry;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Allows the PrintEngine to make this call on an internal interface to the DocShell.

void nsIBaseWindow::setPosition ( in long  x,
in long  y 
) [inherited]
void nsIBaseWindow::setPositionAndSize ( in long  x,
in long  y,
in long  cx,
in long  cy,
in boolean  fRepaint 
) [inherited]
void nsDocShell::SetReferrerURI ( nsIURI aURI) [protected, virtual]

Definition at line 7699 of file nsDocShell.cpp.

{
    mReferrerURI = aURI;        // This assigment addrefs
}

Here is the caller graph for this function:

void nsIScrollable::setScrollRange ( in long  scrollOrientation,
in long  minPos,
in long  maxPos 
) [inherited]
void nsIScrollable::setScrollRangeEx ( in long  minHorizontalPos,
in long  maxHorizontalPos,
in long  minVerticalPos,
in long  maxVerticalPos 
) [inherited]
void nsIBaseWindow::setSize ( in long  cx,
in long  cy,
in boolean  fRepaint 
) [inherited]

Definition at line 5958 of file nsDocShell.cpp.

{
    //
    // Copy content viewer state from previous or parent content viewer.
    //
    // The following logic is mirrored in nsHTMLDocument::StartDocumentLoad!
    //
    // Do NOT to maintain a reference to the old content viewer outside
    // of this "copying" block, or it will not be destroyed until the end of
    // this routine and all <SCRIPT>s and event handlers fail! (bug 20315)
    //
    // In this block of code, if we get an error result, we return it
    // but if we get a null pointer, that's perfectly legal for parent
    // and parentContentViewer.
    //

    PRInt32 x = 0;
    PRInt32 y = 0;
    PRInt32 cx = 0;
    PRInt32 cy = 0;

    // This will get the size from the current content viewer or from the
    // Init settings
    GetPositionAndSize(&x, &y, &cx, &cy);

    nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
    NS_ENSURE_SUCCESS(GetSameTypeParent(getter_AddRefs(parentAsItem)),
                      NS_ERROR_FAILURE);
    nsCOMPtr<nsIDocShell> parent(do_QueryInterface(parentAsItem));

    nsCAutoString defaultCharset;
    nsCAutoString forceCharset;
    nsCAutoString hintCharset;
    PRInt32 hintCharsetSource;
    nsCAutoString prevDocCharset;
    float textZoom;
    PRBool styleDisabled;
    // |newMUDV| also serves as a flag to set the data from the above vars
    nsCOMPtr<nsIMarkupDocumentViewer> newMUDV;

    if (mContentViewer || parent) {
        nsCOMPtr<nsIMarkupDocumentViewer> oldMUDV;
        if (mContentViewer) {
            // Get any interesting state from old content viewer
            // XXX: it would be far better to just reuse the document viewer ,
            //      since we know we're just displaying the same document as before
            oldMUDV = do_QueryInterface(mContentViewer);

            // Tell the old content viewer to hibernate in session history when
            // it is destroyed.

            if (mSavingOldViewer && NS_FAILED(CaptureState())) {
                if (mOSHE) {
                    mOSHE->SyncPresentationState();
                }
                mSavingOldViewer = PR_FALSE;
            }
        }
        else {
            // No old content viewer, so get state from parent's content viewer
            nsCOMPtr<nsIContentViewer> parentContentViewer;
            parent->GetContentViewer(getter_AddRefs(parentContentViewer));
            oldMUDV = do_QueryInterface(parentContentViewer);
        }

        if (oldMUDV) {
            nsresult rv;

            newMUDV = do_QueryInterface(aNewViewer,&rv);
            if (newMUDV) {
                NS_ENSURE_SUCCESS(oldMUDV->
                                  GetDefaultCharacterSet(defaultCharset),
                                  NS_ERROR_FAILURE);
                NS_ENSURE_SUCCESS(oldMUDV->
                                  GetForceCharacterSet(forceCharset),
                                  NS_ERROR_FAILURE);
                NS_ENSURE_SUCCESS(oldMUDV->
                                  GetHintCharacterSet(hintCharset),
                                  NS_ERROR_FAILURE);
                NS_ENSURE_SUCCESS(oldMUDV->
                                  GetHintCharacterSetSource(&hintCharsetSource),
                                  NS_ERROR_FAILURE);
                NS_ENSURE_SUCCESS(oldMUDV->
                                  GetTextZoom(&textZoom),
                                  NS_ERROR_FAILURE);
                NS_ENSURE_SUCCESS(oldMUDV->
                                  GetAuthorStyleDisabled(&styleDisabled),
                                  NS_ERROR_FAILURE);
                NS_ENSURE_SUCCESS(oldMUDV->
                                  GetPrevDocCharacterSet(prevDocCharset),
                                  NS_ERROR_FAILURE);
            }
        }
    }

    // It is necessary to obtain the focus controller to utilize its ability
    // to suppress focus.  This is necessary to fix Win32-only bugs related to
    // a loss of focus when mContentViewer is set to null.  The internal window
    // is destroyed, and the OS focuses the parent window.  This call ends up
    // notifying the focus controller that the outer window should focus
    // and this hoses us on any link traversal.
    //
    // Please do not touch any of the focus controller code here without
    // testing bugs #28580 and 50509.  These are immensely important bugs,
    // so PLEASE take care not to regress them if you decide to alter this 
    // code later              -- hyatt
    nsIFocusController *focusController = nsnull;
    if (mScriptGlobal) {
        nsCOMPtr<nsPIDOMWindow> ourWindow = do_QueryInterface(mScriptGlobal);
        focusController = ourWindow->GetRootFocusController();
        if (focusController) {
            // Suppress the command dispatcher.
            focusController->SetSuppressFocus(PR_TRUE,
                                              "Win32-Only Link Traversal Issue");
            // Remove focus from the element that has it
            nsCOMPtr<nsIDOMWindowInternal> focusedWindow;
            focusController->GetFocusedWindow(getter_AddRefs(focusedWindow));

            // We want to null out the last focused element if the document containing
            // it is going away.  If the last focused element is in a descendent
            // window of our domwindow, its document will be destroyed when we
            // destroy our children.  So, check for this case and null out the
            // last focused element.  See bug 70484.

            PRBool isSubWindow = PR_FALSE;
            nsCOMPtr<nsIDOMWindow> curwin;
            if (focusedWindow)
              focusedWindow->GetParent(getter_AddRefs(curwin));
            while (curwin) {
              if (curwin == ourWindow) {
                isSubWindow = PR_TRUE;
                break;
              }

              // don't use nsCOMPtr here to avoid extra addref
              // when assigning to curwin
              nsIDOMWindow* temp;
              curwin->GetParent(&temp);
              if (curwin == temp) {
                NS_RELEASE(temp);
                break;
              }
              curwin = dont_AddRef(temp);
            }

            if (ourWindow == focusedWindow || isSubWindow)
              focusController->ResetElementFocus();
        }
    }

    nscolor bgcolor = NS_RGBA(0, 0, 0, 0);
    PRBool bgSet = PR_FALSE;

    // Ensure that the content viewer is destroyed *after* the GC - bug 71515
    nsCOMPtr<nsIContentViewer> kungfuDeathGrip = mContentViewer;
    if (mContentViewer) {
        // Stop any activity that may be happening in the old document before
        // releasing it...
        mContentViewer->Stop();

        // Try to extract the default background color from the old
        // view manager, so we can use it for the next document.
        nsCOMPtr<nsIDocumentViewer> docviewer =
        do_QueryInterface(mContentViewer);

        if (docviewer) {
            nsCOMPtr<nsIPresShell> shell;
            docviewer->GetPresShell(getter_AddRefs(shell));

            if (shell) {
                nsIViewManager* vm = shell->GetViewManager();

                if (vm) {
                    vm->GetDefaultBackgroundColor(&bgcolor);
                    // If the background color is not known, don't propagate it.
                    bgSet = NS_GET_A(bgcolor) != 0;
                }
            }
        }

        mContentViewer->Close(mSavingOldViewer ? mOSHE.get() : nsnull);
        aNewViewer->SetPreviousViewer(mContentViewer);

        mContentViewer = nsnull;
    }

    mContentViewer = aNewViewer;

    nsCOMPtr<nsIWidget> widget;
    NS_ENSURE_SUCCESS(GetMainWidget(getter_AddRefs(widget)), NS_ERROR_FAILURE);

    if (widget) {
        NS_ENSURE_SUCCESS(EnsureDeviceContext(), NS_ERROR_FAILURE);
    }

    nsRect bounds(x, y, cx, cy);

    if (NS_FAILED(mContentViewer->Init(widget, mDeviceContext, bounds))) {
        mContentViewer = nsnull;
        NS_ERROR("ContentViewer Initialization failed");
        return NS_ERROR_FAILURE;
    }

    // If we have old state to copy, set the old state onto the new content
    // viewer
    if (newMUDV) {
        NS_ENSURE_SUCCESS(newMUDV->SetDefaultCharacterSet(defaultCharset),
                          NS_ERROR_FAILURE);
        NS_ENSURE_SUCCESS(newMUDV->SetForceCharacterSet(forceCharset),
                          NS_ERROR_FAILURE);
        NS_ENSURE_SUCCESS(newMUDV->SetHintCharacterSet(hintCharset),
                          NS_ERROR_FAILURE);
        NS_ENSURE_SUCCESS(newMUDV->
                          SetHintCharacterSetSource(hintCharsetSource),
                          NS_ERROR_FAILURE);
        NS_ENSURE_SUCCESS(newMUDV->SetPrevDocCharacterSet(prevDocCharset),
                          NS_ERROR_FAILURE);
        NS_ENSURE_SUCCESS(newMUDV->SetTextZoom(textZoom),
                          NS_ERROR_FAILURE);
        NS_ENSURE_SUCCESS(newMUDV->SetAuthorStyleDisabled(styleDisabled),
                          NS_ERROR_FAILURE);
    }

    // End copying block (Don't mess with the old content/document viewer
    // beyond here!!)

    // See the book I wrote above regarding why the focus controller is 
    // being used here.  -- hyatt

    /* Note it's important that focus suppression be turned off no earlier
       because in cases where the docshell is lazily creating an about:blank
       document, mContentViewer->Init finally puts a reference to that
       document into the DOM window, which prevents an infinite recursion
       attempting to lazily create the document as focus is unsuppressed
       (bug 110856). */
    if (focusController)
        focusController->SetSuppressFocus(PR_FALSE,
                                          "Win32-Only Link Traversal Issue");

    if (bgSet && widget) {
        // Stuff the bgcolor from the last view manager into the new
        // view manager. This improves page load continuity.
        nsCOMPtr<nsIDocumentViewer> docviewer =
            do_QueryInterface(mContentViewer);

        if (docviewer) {
            nsCOMPtr<nsIPresShell> shell;
            docviewer->GetPresShell(getter_AddRefs(shell));

            if (shell) {
                nsIViewManager* vm = shell->GetViewManager();

                if (vm) {
                    vm->SetDefaultBackgroundColor(bgcolor);
                }
            }
        }
    }

// XXX: It looks like the LayoutState gets restored again in Embed()
//      right after the call to SetupNewViewer(...)

    // We don't show the mContentViewer yet, since we want to draw the old page
    // until we have enough of the new page to show.  Just return with the new
    // viewer still set to hidden.

    // Now that we have switched documents, forget all of our children
    DestroyChildren();

    return NS_OK;
}

Here is the call graph for this function:

Definition at line 7501 of file nsDocShell.cpp.

{
    nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aChannel));
    if (httpChannel) {
        nsCOMPtr<nsIURI> referrer;
        nsresult rv = httpChannel->GetReferrer(getter_AddRefs(referrer));
        if (NS_SUCCEEDED(rv)) {
            SetReferrerURI(referrer);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIRefreshURI::setupRefreshURI ( in nsIChannel  aChannel) [inherited]

Checks the passed in channel to see if there is a refresh header, if there is, will setup a timer to refresh the uri found in the header.

If docshell is busy loading a page currently, the request will be queued and executed when the current page finishes loading.

Returns the NS_REFRESHURI_HEADER_FOUND success code if a refresh header was found and successfully setup.

Parameters:
aChannelThe channel to be parsed.
void nsIRefreshURI::setupRefreshURIFromHeader ( in nsIURI  aBaseURI,
in ACString  aHeader 
) [inherited]

Parses the passed in header string and sets up a refreshURI if a "refresh" header is found.

If docshell is busy loading a page currently, the request will be queued and executed when the current page finishes loading.

Parameters:
aBaseURIbase URI to resolve refresh uri with.
aHeaderThe meta refresh header string.
PRBool nsDocShell::ShouldAddToSessionHistory ( nsIURI aURI) [protected, virtual]

Definition at line 7708 of file nsDocShell.cpp.

{
    // I believe none of the about: urls should go in the history. But then
    // that could just be me... If the intent is only deny about:blank then we
    // should just do a spec compare, rather than two gets of the scheme and
    // then the path.  -Gagan
    nsresult rv;
    nsCAutoString buf;

    rv = aURI->GetScheme(buf);
    if (NS_FAILED(rv))
        return PR_FALSE;

    if (buf.Equals("about")) {
        rv = aURI->GetPath(buf);
        if (NS_FAILED(rv))
            return PR_FALSE;

        if (buf.Equals("blank")) {
            return PR_FALSE;
        }
    }
    return PR_TRUE;
}

Here is the caller graph for this function:

Definition at line 8344 of file nsDocShell.cpp.

{    
    // By default layout State will be saved. 
    if (!aChannel)
        return PR_FALSE;

    // figure out if SH should be saving layout state 
    nsCOMPtr<nsISupports> securityInfo;
    PRBool noStore = PR_FALSE, noCache = PR_FALSE;
    aChannel->GetSecurityInfo(getter_AddRefs(securityInfo));
    aChannel->IsNoStoreResponse(&noStore);
    aChannel->IsNoCacheResponse(&noCache);

    return (noStore || (noCache && securityInfo));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIDocumentLoader::stop ( ) [inherited]

Definition at line 193 of file nsDocShell.h.

                      {
        // Need this here because otherwise nsIWebNavigation::Stop
        // overrides the docloader's Stop()
        return nsDocLoader::Stop();
    }
void nsIWebNavigation::stop ( in unsigned long  aStopFlags) [inherited]

Stops a load of a URI.

Parameters:
aStopFlagsThis parameter is one of the stop flags defined above.

Cancel the XPCOM timers for each meta-refresh URI in this docshell, and this docshell's children, recursively.

The meta-refresh timers can be restarted using resumeRefreshURIs(). If the timers are already suspended, this has no effect.

void nsDocShell::SwapHistoryEntries ( nsISHEntry aOldEntry,
nsISHEntry aNewEntry 
) [protected]

Definition at line 8177 of file nsDocShell.cpp.

{
    if (aOldEntry == mOSHE)
        mOSHE = aNewEntry;

    if (aOldEntry == mLSHE)
        mLSHE = aNewEntry;
}

Here is the caller graph for this function:

void nsIDocShell::tabToTreeOwner ( in boolean  forward,
out boolean  tookFocus 
) [inherited]