Bug 200382, reduce content's dependencies on webshell, r=adamlock, sr=jst.

This commit is contained in:
heikki%netscape.com 2003-04-03 18:57:33 +00:00
parent d36e03ff94
commit b6ee57a69a
27 changed files with 53 additions and 78 deletions

View File

@ -86,7 +86,6 @@
#include "nsIPrefLocalizedString.h"
#include "nsIPageSequenceFrame.h"
#include "nsIURL.h"
#include "nsIWebShell.h"
#include "nsIContentViewerEdit.h"
#include "nsIContentViewerFile.h"
#include "nsIMarkupDocumentViewer.h"

View File

@ -2041,7 +2041,7 @@ nsGenericElement::SetContentID(PRUint32 aID)
}
NS_IMETHODIMP
nsGenericElement::MaybeTriggerAutoLink(nsIWebShell *aShell)
nsGenericElement::MaybeTriggerAutoLink(nsIDocShell *aShell)
{
return NS_OK;
}

View File

@ -421,7 +421,7 @@ public:
PRInt32 aModType, nsChangeHint& aHint) const;
// nsIXMLContent interface methods
NS_IMETHOD MaybeTriggerAutoLink(nsIWebShell *aShell);
NS_IMETHOD MaybeTriggerAutoLink(nsIDocShell *aShell);
NS_IMETHOD GetXMLBaseURI(nsIURI **aURI);
// nsIHTMLContent interface methods

View File

@ -147,7 +147,6 @@ static const char* kPrintingPromptService = "@mozilla.org/embedcomp/printingprom
#include "nsIPrefBranch.h"
#include "nsIPageSequenceFrame.h"
#include "nsIURL.h"
#include "nsIWebShell.h"
#include "nsIContentViewerEdit.h"
#include "nsIContentViewerFile.h"
#include "nsIMarkupDocumentViewer.h"

View File

@ -76,7 +76,7 @@ nsresult
NS_NewXBLContentSink(nsIXMLContentSink** aResult,
nsIDocument* aDoc,
nsIURI* aURL,
nsIWebShell* aWebShell);
nsISupports* aContainer);
class nsSyncLoadService : public nsISyncLoadDOMService
{

View File

@ -39,7 +39,6 @@ REQUIRES = xpcom \
caps \
xpconnect \
docshell \
webshell \
pref \
htmlparser \
view \

View File

@ -63,7 +63,6 @@
#include "nsImageMapUtils.h"
#include "nsIHTMLDocument.h"
#include "nsINameSpaceManager.h"
#include "nsIWebShell.h"
#include "nsIBaseWindow.h"
#include "nsIScrollableView.h"
#include "nsISelection.h"

View File

@ -51,7 +51,6 @@
#include "nsIHTMLStyleSheet.h"
#include "nsIHTMLCSSStyleSheet.h"
#include "nsICSSStyleRule.h"
#include "nsIWebShell.h"
#include "nsIContentViewer.h"
#include "nsIMarkupDocumentViewer.h"
#include "nsHTMLAttributes.h"

View File

@ -59,7 +59,6 @@
#include "nsIServiceManager.h"
#include "nsNetUtil.h"
#include "nsContentUtils.h"
#include "nsIWebShell.h"
#include "nsIFrame.h"
#include "nsIImageFrame.h"
#include "nsLayoutAtoms.h"

View File

@ -35,7 +35,6 @@ REQUIRES = xpcom \
widget \
locale \
dom \
webshell \
necko \
htmlparser \
unicharutil \

View File

@ -38,8 +38,7 @@ REQUIRES = xpcom \
view \
pref \
necko \
xpconnect \
webshell
xpconnect
CPPSRCS = \
nsSVGAnimatedLength.cpp \

View File

@ -133,7 +133,7 @@ public:
// NS_IMETHOD SetBindingParent(nsIContent* aParent);
// nsIXMLContent
// NS_IMETHOD MaybeTriggerAutoLink(nsIWebShell *aShell);
// NS_IMETHOD MaybeTriggerAutoLink(nsIDocShell *aShell);
// nsIStyledContent
NS_IMETHOD GetID(nsIAtom*& aResult) const;

View File

@ -34,7 +34,6 @@ REQUIRES = content \
string \
gfx \
dom \
webshell \
htmlparser \
lwbrk \
necko \

View File

@ -62,7 +62,7 @@ nsresult
NS_NewXBLContentSink(nsIXMLContentSink** aResult,
nsIDocument* aDoc,
nsIURI* aURL,
nsIWebShell* aWebShell)
nsISupports* aContainer)
{
NS_ENSURE_ARG_POINTER(aResult);
@ -71,7 +71,7 @@ NS_NewXBLContentSink(nsIXMLContentSink** aResult,
NS_ENSURE_TRUE(it, NS_ERROR_OUT_OF_MEMORY);
nsCOMPtr<nsIXMLContentSink> kungFuDeathGrip = it;
nsresult rv = it->Init(aDoc, aURL, aWebShell);
nsresult rv = it->Init(aDoc, aURL, aContainer);
NS_ENSURE_SUCCESS(rv, rv);
return CallQueryInterface(it, aResult);
@ -100,7 +100,7 @@ nsXBLContentSink::~nsXBLContentSink()
nsresult
nsXBLContentSink::Init(nsIDocument* aDoc,
nsIURI* aURL,
nsIWebShell* aContainer)
nsISupports* aContainer)
{
nsresult rv;
rv = nsXMLContentSink::Init(aDoc, aURL, aContainer, nsnull);

View File

@ -85,7 +85,7 @@ public:
nsresult Init(nsIDocument* aDoc,
nsIURI* aURL,
nsIWebShell* aContainer);
nsISupports* aContainer);
// nsIContentSink overrides
NS_IMETHOD HandleStartElement(const PRUnichar *aName,
@ -158,5 +158,5 @@ nsresult
NS_NewXBLContentSink(nsIXMLContentSink** aResult,
nsIDocument* aDoc,
nsIURI* aURL,
nsIWebShell* aWebShell);
nsISupports* aContainer);
#endif // nsXBLContentSink_h__

View File

@ -45,7 +45,7 @@
class nsINameSpace;
class nsINodeInfo;
class nsIWebShell;
class nsIDocShell;
class nsIURI;
#define NS_IXMLCONTENT_IID \
@ -64,7 +64,7 @@ public:
* automatically when loaded. If the element was an autoloading link
* and it was succesfully handled, we will throw special nsresult values.
*
* @param aShell the current web shell (to possibly load the link on)
* @param aShell the current doc shell (to possibly load the link on)
* @throws NS_OK if nothing happened
* @throws NS_XML_AUTOLINK_EMBED if the caller is loading the link embedded
* @throws NS_XML_AUTOLINK_NEW if the caller is loading the link in a new
@ -74,7 +74,7 @@ public:
* @throws NS_XML_AUTOLINK_UNDEFINED if it is loading in any other way--in
* which case, the caller should stop parsing as well.
*/
NS_IMETHOD MaybeTriggerAutoLink(nsIWebShell *aShell) = 0;
NS_IMETHOD MaybeTriggerAutoLink(nsIDocShell *aShell) = 0;
/**
* Get the XML Base URI for this element (http://www.w3.org/TR/xmlbase/)

View File

@ -43,7 +43,7 @@
#include "nsIDocument.h"
#include "nsIAtom.h"
#include "nsIEventListenerManager.h"
#include "nsIWebShell.h"
#include "nsIDocShell.h"
#include "nsIEventStateManager.h"
#include "nsIDOMEvent.h"
#include "nsINameSpace.h"
@ -306,7 +306,7 @@ nsXMLElement::SetAttr(nsINodeInfo *aNodeInfo,
return nsGenericContainerElement::SetAttr(aNodeInfo, aValue, aNotify);
}
static nsresult WebShellToPresContext(nsIWebShell *aShell,
static nsresult DocShellToPresContext(nsIDocShell *aShell,
nsIPresContext **aPresContext)
{
*aPresContext = nsnull;
@ -368,7 +368,7 @@ static inline nsresult SpecialAutoLoadReturn(nsresult aRv, nsLinkVerb aVerb)
}
NS_IMETHODIMP
nsXMLElement::MaybeTriggerAutoLink(nsIWebShell *aShell)
nsXMLElement::MaybeTriggerAutoLink(nsIDocShell *aShell)
{
NS_ENSURE_ARG_POINTER(aShell);
@ -454,7 +454,7 @@ nsXMLElement::MaybeTriggerAutoLink(nsIWebShell *aShell)
rv = CheckLoadURI(base,value,getter_AddRefs(uri));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIPresContext> pc;
rv = WebShellToPresContext(aShell,getter_AddRefs(pc));
rv = DocShellToPresContext(aShell,getter_AddRefs(pc));
if (NS_SUCCEEDED(rv)) {
rv = TriggerLink(pc, verb, base, value,
NS_LITERAL_STRING(""), PR_TRUE);

View File

@ -49,7 +49,7 @@
class nsIEventListenerManager;
class nsIURI;
class nsIWebShell;
class nsIDocShell;
class nsXMLElement : public nsGenericContainerElement,
public nsIDOMElement
@ -68,7 +68,7 @@ public:
NS_FORWARD_NSIDOMELEMENT(nsGenericContainerElement::)
// nsIXMLContent
NS_IMETHOD MaybeTriggerAutoLink(nsIWebShell *aShell);
NS_IMETHOD MaybeTriggerAutoLink(nsIDocShell *aShell);
NS_IMETHOD GetXMLBaseURI(nsIURI **aURI);
// nsIStyledContent

View File

@ -44,7 +44,6 @@
class nsIDocument;
class nsIURI;
class nsIWebShell;
class nsIChannel;
#define NS_IXMLCONTENT_SINK_IID \
@ -83,7 +82,7 @@ public:
nsresult
NS_NewXMLContentSink(nsIXMLContentSink** aInstancePtrResult, nsIDocument* aDoc,
nsIURI* aURL, nsIWebShell* aWebShell,
nsIURI* aURL, nsISupports* aContainer,
nsIChannel *aChannel);
#endif // nsIXMLContentSink_h___

View File

@ -52,8 +52,6 @@
#include "nsIURL.h"
#include "nsIRefreshURI.h"
#include "nsNetUtil.h"
#include "nsIWebShell.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIContent.h"
#include "nsITextContent.h"
@ -187,7 +185,7 @@ nsresult
NS_NewXMLContentSink(nsIXMLContentSink** aResult,
nsIDocument* aDoc,
nsIURI* aURL,
nsIWebShell* aWebShell,
nsISupports* aContainer,
nsIChannel* aChannel)
{
NS_PRECONDITION(nsnull != aResult, "null ptr");
@ -201,7 +199,7 @@ NS_NewXMLContentSink(nsIXMLContentSink** aResult,
}
nsCOMPtr<nsIXMLContentSink> kungFuDeathGrip = it;
nsresult rv = it->Init(aDoc, aURL, aWebShell, aChannel);
nsresult rv = it->Init(aDoc, aURL, aContainer, aChannel);
NS_ENSURE_SUCCESS(rv, rv);
return CallQueryInterface(it, aResult);
@ -213,7 +211,6 @@ nsXMLContentSink::nsXMLContentSink()
mDocument = nsnull;
mDocumentURL = nsnull;
mDocumentBaseURL = nsnull;
mWebShell = nsnull;
mParser = nsnull;
mDocElement = nsnull;
mContentStack = nsnull;
@ -236,7 +233,6 @@ nsXMLContentSink::~nsXMLContentSink()
NS_IF_RELEASE(mDocument);
NS_IF_RELEASE(mDocumentURL);
NS_IF_RELEASE(mDocumentBaseURL);
NS_IF_RELEASE(mWebShell);
NS_IF_RELEASE(mParser);
NS_IF_RELEASE(mDocElement);
if (nsnull != mNameSpaceStack) {
@ -257,7 +253,7 @@ nsXMLContentSink::~nsXMLContentSink()
nsresult
nsXMLContentSink::Init(nsIDocument* aDoc,
nsIURI* aURL,
nsIWebShell* aContainer,
nsISupports* aContainer,
nsIChannel* aChannel)
{
NS_PRECONDITION(nsnull != aDoc, "null ptr");
@ -272,9 +268,8 @@ nsXMLContentSink::Init(nsIDocument* aDoc,
NS_ADDREF(aURL);
mDocumentBaseURL = aURL;
NS_ADDREF(aURL);
mWebShell = aContainer;
NS_IF_ADDREF(mWebShell);
if (!mWebShell) {
mDocShell = do_QueryInterface(aContainer);
if (!mDocShell) {
mPrettyPrintXML = PR_FALSE;
}
@ -456,10 +451,9 @@ nsXMLContentSink::DidBuildModel(PRInt32 aQualityLevel)
#if 0 /* Disable until this works for XML */
// Scroll to Anchor only if the document was *not* loaded through history means.
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mWebShell));
if (docShell) {
if (mDocShell) {
PRUint32 documentLoadType = 0;
docShell->GetLoadType(&documentLoadType);
mDocShell->GetLoadType(&documentLoadType);
ScrollToRef(!(documentLoadType & nsIDocShell::LOAD_CMD_HISTORY));
}
#else
@ -488,9 +482,8 @@ nsXMLContentSink::OnDocumentCreated(nsIDOMDocument* aResultDocument)
{
NS_ENSURE_ARG(aResultDocument);
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mWebShell));
nsCOMPtr<nsIContentViewer> contentViewer;
docShell->GetContentViewer(getter_AddRefs(contentViewer));
mDocShell->GetContentViewer(getter_AddRefs(contentViewer));
if (contentViewer) {
contentViewer->SetDOMDocument(aResultDocument);
}
@ -504,9 +497,8 @@ nsXMLContentSink::OnTransformDone(nsresult aResult,
NS_ASSERTION(NS_FAILED(aResult) || aResultDocument,
"Don't notify about transform success without a document.");
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mWebShell));
nsCOMPtr<nsIContentViewer> contentViewer;
docShell->GetContentViewer(getter_AddRefs(contentViewer));
mDocShell->GetContentViewer(getter_AddRefs(contentViewer));
if (NS_FAILED(aResult) && contentViewer) {
// Transform failed.
@ -825,8 +817,8 @@ nsXMLContentSink::ProcessStyleLink(nsIContent* aElement,
// don't load alternate XSLT
return NS_OK;
}
// LoadXSLStyleSheet needs a mWebShell.
if (!mWebShell)
// LoadXSLStyleSheet needs a mDocShell.
if (!mDocShell)
return NS_OK;
nsCOMPtr<nsIURI> url;
@ -1092,26 +1084,24 @@ nsXMLContentSink::ProcessHeaderData(nsIAtom* aHeader,const nsAString& aValue,nsI
mDocument->SetHeaderData(aHeader, aValue);
if (!mDocShell) return NS_ERROR_FAILURE;
// see if we have a refresh "header".
if (aHeader == nsHTMLAtoms::refresh) {
// first get our baseURI
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(mWebShell, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIURI> baseURI;
nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(docShell);
nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(mDocShell);
rv = webNav->GetCurrentURI(getter_AddRefs(baseURI));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRefreshURI> reefer = do_QueryInterface(mWebShell);
nsCOMPtr<nsIRefreshURI> reefer = do_QueryInterface(mDocShell);
if (reefer) {
rv = reefer->SetupRefreshURIFromHeader(baseURI, NS_ConvertUCS2toUTF8(aValue));
if (NS_FAILED(rv)) return rv;
}
} // END refresh
else if (aHeader == nsHTMLAtoms::setcookie) {
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(mWebShell, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsICookieService> cookieServ = do_GetService(NS_COOKIESERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
@ -1367,7 +1357,7 @@ nsXMLContentSink::StartLayout()
{
// Reset scrolling to default settings for this shell.
// This must happen before the initial reflow, when we create the root frame
nsCOMPtr<nsIScrollable> scrollableContainer(do_QueryInterface(mWebShell));
nsCOMPtr<nsIScrollable> scrollableContainer(do_QueryInterface(mDocShell));
if (scrollableContainer) {
scrollableContainer->ResetScrollbarPreferences();
}
@ -1411,7 +1401,7 @@ nsXMLContentSink::StartLayout()
}
PRBool topLevelFrameset = PR_FALSE;
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mWebShell));
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
if (docShellAsItem) {
nsCOMPtr<nsIDocShellTreeItem> root;
docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(root));
@ -1520,9 +1510,8 @@ nsresult
nsXMLContentSink::RefreshIfEnabled(nsIViewManager* vm)
{
if (vm) {
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mWebShell));
nsCOMPtr<nsIContentViewer> contentViewer;
nsresult rv = docShell->GetContentViewer(getter_AddRefs(contentViewer));
nsresult rv = mDocShell->GetContentViewer(getter_AddRefs(contentViewer));
if (NS_SUCCEEDED(rv) && contentViewer) {
PRBool enabled;
contentViewer->GetEnableRendering(&enabled);
@ -2216,10 +2205,10 @@ nsXMLContentSink::AddAttributes(const PRUnichar** aAtts,
}
// Give autoloading links a chance to fire
if (mWebShell) {
if (mDocShell) {
nsCOMPtr<nsIXMLContent> xmlcontent(do_QueryInterface(aContent));
if (xmlcontent) {
nsresult rv = xmlcontent->MaybeTriggerAutoLink(mWebShell);
nsresult rv = xmlcontent->MaybeTriggerAutoLink(mDocShell);
if (rv == NS_XML_AUTOLINK_REPLACE ||
rv == NS_XML_AUTOLINK_UNDEFINED) {
// If we do not terminate the parse, we just keep generating link trigger

View File

@ -56,11 +56,11 @@
#include "nsSupportsArray.h"
#include "nsIExpatSink.h"
#include "nsIDocumentTransformer.h"
#include "nsIDocShell.h"
class nsICSSStyleSheet;
class nsIDocument;
class nsIURI;
class nsIWebShell;
class nsIContent;
class nsAutoVoidArray;
class nsIXMLDocument;
@ -91,7 +91,7 @@ public:
nsresult Init(nsIDocument* aDoc,
nsIURI* aURL,
nsIWebShell* aContainer,
nsISupports* aContainer,
nsIChannel* aChannel);
// nsISupports
@ -176,7 +176,7 @@ protected:
nsIDocument* mDocument;
nsIURI* mDocumentURL;
nsIURI* mDocumentBaseURL; // can be set via HTTP headers
nsIWebShell* mWebShell;
nsCOMPtr<nsIDocShell> mDocShell;
nsIParser* mParser;
nsIContent* mDocElement;
nsAutoVoidArray* mNameSpaceStack;

View File

@ -48,7 +48,6 @@
#include "nsIContent.h"
#include "nsIContentViewerContainer.h"
#include "nsIContentViewer.h"
#include "nsIWebShell.h"
#include "nsIDocShell.h"
#include "nsIMarkupDocumentViewer.h"
#include "nsIDocumentLoader.h"
@ -633,13 +632,12 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
sink = do_QueryInterface(aSink);
}
else {
// This is silly, aContainer should be an nsIWebShell
nsCOMPtr<nsIWebShell> webShell;
nsCOMPtr<nsIDocShell> docShell;
if (aContainer) {
webShell = do_QueryInterface(aContainer);
NS_ENSURE_TRUE(webShell, NS_ERROR_FAILURE);
docShell = do_QueryInterface(aContainer);
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
}
rv = NS_NewXMLContentSink(getter_AddRefs(sink), this, aUrl, webShell,
rv = NS_NewXMLContentSink(getter_AddRefs(sink), this, aUrl, docShell,
aChannel);
NS_ENSURE_SUCCESS(rv, rv);
}

View File

@ -149,7 +149,7 @@
#include "nsITimelineService.h"
#include "nsIFrame.h"
class nsIWebShell;
class nsIDocShell;
// Global object maintenance
nsICSSParser* nsXULPrototypeElement::sCSSParser = nsnull;
@ -1595,7 +1595,7 @@ nsXULElement::GetElementsByAttribute(const nsAString& aAttribute,
// nsIXMLContent interface
NS_IMETHODIMP
nsXULElement::MaybeTriggerAutoLink(nsIWebShell *aShell)
nsXULElement::MaybeTriggerAutoLink(nsIDocShell *aShell)
{
return NS_OK;
}

View File

@ -91,7 +91,7 @@ class nsRDFDOMNodeList;
class nsString;
class nsXULAttributes;
class nsVoidArray;
class nsIWebShell;
class nsIDocShell;
class nsIObjectInputStream;
class nsIObjectOutputStream;
@ -460,7 +460,7 @@ public:
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aResult);
// nsIXMLContent
NS_IMETHOD MaybeTriggerAutoLink(nsIWebShell *aShell);
NS_IMETHOD MaybeTriggerAutoLink(nsIDocShell *aShell);
NS_IMETHOD GetXMLBaseURI(nsIURI **aURI);
// nsIStyledContent

View File

@ -486,14 +486,14 @@ XULContentSinkImpl::DidBuildModel(PRInt32 aQualityLevel)
NS_IMETHODIMP
XULContentSinkImpl::WillInterrupt(void)
{
// XXX Notify the webshell, if necessary
// XXX Notify the docshell, if necessary
return NS_OK;
}
NS_IMETHODIMP
XULContentSinkImpl::WillResume(void)
{
// XXX Notify the webshell, if necessary
// XXX Notify the docshell, if necessary
return NS_OK;
}

View File

@ -86,7 +86,6 @@
#include "nsIPrefLocalizedString.h"
#include "nsIPageSequenceFrame.h"
#include "nsIURL.h"
#include "nsIWebShell.h"
#include "nsIContentViewerEdit.h"
#include "nsIContentViewerFile.h"
#include "nsIMarkupDocumentViewer.h"

View File

@ -147,7 +147,6 @@ static const char* kPrintingPromptService = "@mozilla.org/embedcomp/printingprom
#include "nsIPrefBranch.h"
#include "nsIPageSequenceFrame.h"
#include "nsIURL.h"
#include "nsIWebShell.h"
#include "nsIContentViewerEdit.h"
#include "nsIContentViewerFile.h"
#include "nsIMarkupDocumentViewer.h"