зеркало из https://github.com/mozilla/pjs.git
Removed mPresShell and mPresContext from the base class. Added internal getter function GetPresShell to retrieve presShell objects. Added a pointer to mContentViewer. Changed LoadURI* to take a presContext. Changed SetDocument to take a presContext. Changed the attribute presContext to be read only.
This commit is contained in:
Родитель
66c3fae066
Коммит
4a83671b62
|
@ -20,9 +20,11 @@
|
|||
* Travis Bogard <travis@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsDocShellBase.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDocumentViewer.h"
|
||||
|
||||
#include "nsDocShellBase.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsDocShellBase: Object Management
|
||||
|
@ -54,23 +56,16 @@ NS_IMPL_ISUPPORTS6(nsDocShellBase, nsIDocShell, nsIDocShellEdit,
|
|||
// nsDocShellBase::nsIDocShell
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP nsDocShellBase::LoadURI(const PRUnichar* uri)
|
||||
NS_IMETHODIMP nsDocShellBase::LoadURI(const PRUnichar* uri,
|
||||
nsIPresContext* presContext)
|
||||
{
|
||||
NS_ENSURE_ARG(uri);
|
||||
//XXX First Check
|
||||
/*
|
||||
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.
|
||||
//NS_ENSURE_ARG(uri); // Done in LoadURIVia for us.
|
||||
|
||||
@param uri - The URI to load.
|
||||
*/
|
||||
return NS_ERROR_FAILURE;
|
||||
return LoadURIVia(uri, presContext, 0);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellBase::LoadURIVia(const PRUnichar* uri,
|
||||
PRUint32 adapterBinding)
|
||||
nsIPresContext* presContext, PRUint32 adapterBinding)
|
||||
{
|
||||
NS_ENSURE_ARG(uri);
|
||||
//XXX First Check
|
||||
|
@ -89,10 +84,13 @@ NS_IMETHODIMP nsDocShellBase::LoadURIVia(const PRUnichar* uri,
|
|||
NS_IMETHODIMP nsDocShellBase::GetDocument(nsIDOMDocument** aDocument)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDocument);
|
||||
NS_ENSURE_STATE(mPresShell);
|
||||
NS_ENSURE_STATE(mContentViewer);
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
NS_ENSURE_SUCCESS(GetPresShell(getter_AddRefs(presShell)), NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDocument>doc;
|
||||
NS_ENSURE_SUCCESS(mPresShell->GetDocument(getter_AddRefs(doc)), NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(presShell->GetDocument(getter_AddRefs(doc)), NS_ERROR_FAILURE);
|
||||
NS_ENSURE(doc, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// the result's addref comes from this QueryInterface call
|
||||
|
@ -102,7 +100,8 @@ NS_IMETHODIMP nsDocShellBase::GetDocument(nsIDOMDocument** aDocument)
|
|||
}
|
||||
|
||||
// SetDocument is only meaningful for doc shells that support DOM documents. Not all do.
|
||||
NS_IMETHODIMP nsDocShellBase::SetDocument(nsIDOMDocument* aDocument)
|
||||
NS_IMETHODIMP nsDocShellBase::SetDocument(nsIDOMDocument* aDocument,
|
||||
nsIPresContext* presContext)
|
||||
{
|
||||
NS_WARN_IF_FALSE(PR_FALSE, "Subclasses should override this method!!!!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
@ -135,21 +134,20 @@ NS_IMETHODIMP nsDocShellBase::GetPresContext(nsIPresContext** aPresContext)
|
|||
{
|
||||
NS_ENSURE_ARG_POINTER(aPresContext);
|
||||
|
||||
*aPresContext = mPresContext;
|
||||
NS_IF_ADDREF(*aPresContext);
|
||||
if(!mContentViewer)
|
||||
{
|
||||
*aPresContext = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(mContentViewer));
|
||||
NS_ENSURE(docv, NS_ERROR_FAILURE);
|
||||
|
||||
NS_ENSURE_SUCCESS(docv->GetPresContext(*aPresContext), NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellBase::SetPresContext(nsIPresContext* aPresContext)
|
||||
{
|
||||
// null aPresContext is ok
|
||||
mPresContext = aPresContext; // this assignment does an addref
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDocShellBase::GetParent(nsIDocShell** parent)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(parent);
|
||||
|
@ -250,10 +248,12 @@ NS_IMETHODIMP nsDocShellBase::GetSearchable(PRBool* aSearchable)
|
|||
|
||||
NS_IMETHODIMP nsDocShellBase::ClearSelection()
|
||||
{
|
||||
NS_ENSURE_STATE(mPresShell);
|
||||
NS_ENSURE_STATE(mContentViewer);
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
NS_ENSURE_SUCCESS(GetPresShell(getter_AddRefs(presShell)), NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
NS_ENSURE_SUCCESS(mPresShell->GetSelection(SELECTION_NORMAL,
|
||||
NS_ENSURE_SUCCESS(presShell->GetSelection(SELECTION_NORMAL,
|
||||
getter_AddRefs(selection)), NS_ERROR_FAILURE);
|
||||
|
||||
NS_ENSURE_SUCCESS(selection->ClearSelection(), NS_ERROR_FAILURE);
|
||||
|
@ -269,10 +269,12 @@ NS_IMETHODIMP nsDocShellBase::SelectAll()
|
|||
|
||||
NS_IMETHODIMP nsDocShellBase::CopySelection()
|
||||
{
|
||||
NS_ENSURE_STATE(mPresShell);
|
||||
NS_ENSURE_STATE(mContentViewer);
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
NS_ENSURE_SUCCESS(GetPresShell(getter_AddRefs(presShell)), NS_ERROR_FAILURE);
|
||||
|
||||
// the pres shell knows how to copy, so let it do the work
|
||||
NS_ENSURE_SUCCESS(mPresShell->DoCopy(), NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(presShell->DoCopy(), NS_ERROR_FAILURE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -283,10 +285,12 @@ NS_IMETHODIMP nsDocShellBase::GetCopyable(PRBool *aCopyable)
|
|||
{
|
||||
NS_ENSURE_ARG_POINTER(aCopyable);
|
||||
|
||||
NS_ENSURE_STATE(mPresShell);
|
||||
NS_ENSURE_STATE(mContentViewer);
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
NS_ENSURE_SUCCESS(GetPresShell(getter_AddRefs(presShell)), NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
NS_ENSURE_SUCCESS(mPresShell->GetSelection(SELECTION_NORMAL,
|
||||
NS_ENSURE_SUCCESS(presShell->GetSelection(SELECTION_NORMAL,
|
||||
getter_AddRefs(selection)), NS_ERROR_FAILURE);
|
||||
|
||||
if(!selection)
|
||||
|
@ -1019,4 +1023,64 @@ nsresult nsDocShellBase::GetRootScrollableView(nsIScrollableView** aOutScrollVie
|
|||
NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult nsDocShellBase::GetPresShell(nsIPresShell** aPresShell)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPresShell);
|
||||
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
NS_ENSURE_SUCCESS(GetPresContext(getter_AddRefs(presContext)),
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
NS_ENSURE_SUCCESS(presContext->GetShell(aPresShell), NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
// null result aPresContext is legal
|
||||
NS_IMETHODIMP nsDocShellBase::GetPresContext(nsIPresContext** aPresContext)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPresContext);
|
||||
|
||||
nsCOMPtr<nsIContentViewer> cv;
|
||||
NS_ENSURE_SUCCESS(GetContentViewer(getter_AddRefs(cv)));
|
||||
// null content viewer is legal
|
||||
|
||||
if (cv)
|
||||
{
|
||||
nsIDocumentViewer* docv = nsnull;
|
||||
cv->QueryInterface(kIDocumentViewerIID, (void**) &docv);
|
||||
if (docv)
|
||||
{
|
||||
nsIPresContext* cx;
|
||||
NS_ENSURE_SUCCESS(docv->GetPresContext(aPresContext));
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDocShellBase::GetDocument(nsIDOMDocument** aDocument)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDocument);
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
NS_ENSURE_SUCCESS(GetPresShell(getter_AddRefs(presShell)));
|
||||
NS_ENSURE(presShell, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDocument>doc;
|
||||
NS_ENSURE_SUCCESS(PresShell->GetDocument(getter_AddRefs(doc)), NS_ERROR_FAILURE);
|
||||
NS_ENSURE(doc, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// the result's addref comes from this QueryInterface call
|
||||
NS_ENSURE_SUCCESS(CallQueryInterface(doc, aDocument), NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
*/
|
|
@ -29,6 +29,7 @@
|
|||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIScrollableView.h"
|
||||
#include "nsIContentViewer.h"
|
||||
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellEdit.h"
|
||||
|
@ -70,15 +71,15 @@ protected:
|
|||
nsresult GetChildOffset(nsIDOMNode* aChild, nsIDOMNode* aParent,
|
||||
PRInt32* aOffset);
|
||||
nsresult GetRootScrollableView(nsIScrollableView** aOutScrollView);
|
||||
nsresult GetPresShell(nsIPresShell** aPresShell);
|
||||
|
||||
protected:
|
||||
PRBool mCreated;
|
||||
nsString mName;
|
||||
nsDocShellInitInfo* mBaseInitInfo;
|
||||
nsCOMPtr<nsIContentViewer> mContentViewer;
|
||||
nsCOMPtr<nsIDocShell> mParent;
|
||||
nsCOMPtr<nsIPresContext> mPresContext;
|
||||
nsCOMPtr<nsIWidget> mParentWidget;
|
||||
nsCOMPtr<nsIPresShell> mPresShell;
|
||||
nsCOMPtr<nsIPref> mPrefs;
|
||||
};
|
||||
|
||||
|
|
|
@ -58,8 +58,10 @@ interface nsIDocShell : nsISupports
|
|||
loading.
|
||||
|
||||
@param uri - The URI to load.
|
||||
@param presContext - Presentation Context to use for the new URL. This
|
||||
may be null.
|
||||
*/
|
||||
void LoadURI(in wstring uri);
|
||||
[noscript]void LoadURI(in wstring uri, in nsIPresContext presContext);
|
||||
|
||||
/*
|
||||
Loads a given URI through the specified adapter. This will give priority
|
||||
|
@ -68,15 +70,26 @@ interface nsIDocShell : nsISupports
|
|||
normal process of content loading.
|
||||
|
||||
@param uri - The URI to load.
|
||||
@param presContext - Presentation Context to use for the new URL. This
|
||||
may be null.
|
||||
@param adapterBinding - The local IP address of the adapter to bind to.
|
||||
*/
|
||||
void LoadURIVia(in wstring uri, in unsigned long adapterBinding);
|
||||
[noscript]void LoadURIVia(in wstring uri, in nsIPresContext presContext,
|
||||
in unsigned long adapterBinding);
|
||||
|
||||
/*
|
||||
The current document that is loaded in the DocShell. When setting this it
|
||||
will will simulate the normal load process.
|
||||
Sets the current document to the one being passed in. This will simulate
|
||||
a load.
|
||||
|
||||
@param document - The document to load.
|
||||
@param
|
||||
*/
|
||||
attribute nsIDOMDocument document;
|
||||
[noscript]void SetDocument(in nsIDOMDocument document, in nsIPresContext presContext);
|
||||
|
||||
/*
|
||||
The current document that is loaded in the DocShell.
|
||||
*/
|
||||
readonly attribute nsIDOMDocument document;
|
||||
|
||||
/*
|
||||
name of the DocShell
|
||||
|
@ -84,9 +97,9 @@ interface nsIDocShell : nsISupports
|
|||
attribute wstring name;
|
||||
|
||||
/*
|
||||
Presentation context
|
||||
Presentation context for the currently loaded document. This may be null.
|
||||
*/
|
||||
attribute nsIPresContext presContext;
|
||||
readonly attribute nsIPresContext presContext;
|
||||
|
||||
/*
|
||||
Parent DocShell
|
||||
|
|
Загрузка…
Ссылка в новой задаче