/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "NPL"); you may not use this file except in * compliance with the NPL. You may obtain a copy of the NPL at * http://www.mozilla.org/NPL/ * * Software distributed under the NPL is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL * for the specific language governing rights and limitations under the * NPL. * * The Initial Developer of this code under the NPL is Netscape * Communications Corporation. Portions created by Netscape are * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. */ #include "nsLeafFrame.h" #include "nsHTMLContainerFrame.h" #include "nsIHTMLContent.h" #include "nsIWebShell.h" #include "nsIPresContext.h" #include "nsIPresShell.h" #include "nsHTMLIIDs.h" #include "nsRepository.h" #include "nsIStreamListener.h" #include "nsIURL.h" #include "nsIDocument.h" #include "nsIView.h" #include "nsIViewManager.h" #include "nsWidgetsCID.h" #include "nsViewsCID.h" #include "nsHTMLAtoms.h" #include "nsIScrollableView.h" #include "nsStyleCoord.h" #include "nsIStyleContext.h" #include "nsStyleConsts.h" #include "nsIDocumentLoader.h" #include "nsIPref.h" #include "nsFrameSetFrame.h" #include "nsIDOMHTMLFrameElement.h" #include "nsIDOMHTMLIFrameElement.h" #include "nsGenericHTMLElement.h" class nsHTMLFrame; static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID); static NS_DEFINE_IID(kIStreamObserverIID, NS_ISTREAMOBSERVER_IID); static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID); static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID); static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID); static NS_DEFINE_IID(kCViewCID, NS_VIEW_CID); static NS_DEFINE_IID(kCChildCID, NS_CHILD_CID); static NS_DEFINE_IID(kIDOMHTMLFrameElementIID, NS_IDOMHTMLFRAMEELEMENT_IID); static NS_DEFINE_IID(kIDOMHTMLIFrameElementIID, NS_IDOMHTMLIFRAMEELEMENT_IID); /******************************************************************************* * TempObserver XXX temporary until doc manager/loader is in place ******************************************************************************/ class TempObserver : public nsIStreamObserver { public: TempObserver() { NS_INIT_REFCNT(); } ~TempObserver() {} // nsISupports NS_DECL_ISUPPORTS // nsIStreamObserver NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg); NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg); protected: nsString mURL; nsString mOverURL; nsString mOverTarget; }; /******************************************************************************* * FrameLoadingInfo ******************************************************************************/ class FrameLoadingInfo : public nsISupports { public: FrameLoadingInfo(const nsSize& aSize); // nsISupports interface... NS_DECL_ISUPPORTS protected: virtual ~FrameLoadingInfo() {} public: nsSize mFrameSize; }; /******************************************************************************* * nsHTMLFrameOuterFrame ******************************************************************************/ class nsHTMLFrameOuterFrame : public nsHTMLContainerFrame { public: nsHTMLFrameOuterFrame(nsIContent* aContent, nsIFrame* aParent); NS_IMETHOD ListTag(FILE* out = stdout) const; NS_IMETHOD Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); NS_IMETHOD Reflow(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext, nsIContent* aChild, nsIAtom* aAttribute, PRInt32 aHint); NS_IMETHOD VerifyTree() const; nscoord GetBorderWidth(nsIPresContext& aPresContext); PRBool IsInline(); protected: virtual ~nsHTMLFrameOuterFrame(); virtual void GetDesiredSize(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsHTMLReflowMetrics& aDesiredSize); virtual PRIntn GetSkipSides() const; PRBool *mIsInline; }; /******************************************************************************* * nsHTMLFrameInnerFrame ******************************************************************************/ class nsHTMLFrameInnerFrame : public nsLeafFrame { public: nsHTMLFrameInnerFrame(nsIContent* aContent, nsIFrame* aParentFrame); NS_IMETHOD ListTag(FILE* out = stdout) const; /** * @see nsIFrame::Paint */ NS_IMETHOD Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); /** * @see nsIFrame::Reflow */ NS_IMETHOD Reflow(nsIPresContext& aCX, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); NS_IMETHOD MoveTo(nscoord aX, nscoord aY); NS_IMETHOD SizeTo(nscoord aWidth, nscoord aHeight); NS_IMETHOD GetParentContent(nsIContent*& aContent); PRBool GetURL(nsIContent* aContent, nsString& aResult); PRBool GetName(nsIContent* aContent, nsString& aResult); nsScrollPreference GetScrolling(nsIContent* aContent, PRBool aStandardMode); nsFrameborder GetFrameBorder(PRBool aStandardMode); PRInt32 GetMarginWidth(nsIPresContext* aPresContext, nsIContent* aContent); PRInt32 GetMarginHeight(nsIPresContext* aPresContext, nsIContent* aContent); nsresult ReloadURL(); protected: nsresult CreateWebShell(nsIPresContext& aPresContext, const nsSize& aSize); virtual ~nsHTMLFrameInnerFrame(); virtual void GetDesiredSize(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsHTMLReflowMetrics& aDesiredSize); nsIWebShell* mWebShell; PRBool mCreatingViewer; // XXX fix these TempObserver* mTempObserver; }; /******************************************************************************* * nsHTMLFrameOuterFrame ******************************************************************************/ nsHTMLFrameOuterFrame::nsHTMLFrameOuterFrame(nsIContent* aContent, nsIFrame* aParent) : nsHTMLContainerFrame(aContent, aParent) { mIsInline = nsnull; } nsHTMLFrameOuterFrame::~nsHTMLFrameOuterFrame() { //printf("nsHTMLFrameOuterFrame destructor %X \n", this); if (mIsInline) { delete mIsInline; } } nscoord nsHTMLFrameOuterFrame::GetBorderWidth(nsIPresContext& aPresContext) { if (IsInline()) { if (nsnull != mFirstChild) { if (eFrameborder_No != ((nsHTMLFrameInnerFrame*)mFirstChild)->GetFrameBorder(eCompatibility_Standard)) { const nsStyleSpacing* spacing = (const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing); nsStyleCoord leftBorder; spacing->mBorder.GetLeft(leftBorder); nsStyleUnit unit = leftBorder.GetUnit(); if (eStyleUnit_Coord == unit) { return leftBorder.GetCoordValue(); } } } } return 0; } PRIntn nsHTMLFrameOuterFrame::GetSkipSides() const { return 0; } void nsHTMLFrameOuterFrame::GetDesiredSize(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsHTMLReflowMetrics& aDesiredSize) { // processing does not use this routine, only