/* -*- 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.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/NPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * * Contributor(s): */ #include "nsCOMPtr.h" #include "nsLeafFrame.h" #include "nsHTMLContainerFrame.h" #include "nsIHTMLContent.h" #include "nsIWebShell.h" #include "nsIBaseWindow.h" #include "nsIContentViewer.h" #include "nsIMarkupDocumentViewer.h" #include "nsIPresContext.h" #include "nsIPresShell.h" #include "nsHTMLIIDs.h" #include "nsIComponentManager.h" #include "nsIStreamListener.h" #include "nsIURL.h" #include "nsNetUtil.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" #include "nsLayoutAtoms.h" #include "nsIChromeEventHandler.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); /******************************************************************************* * FrameLoadingInfo ******************************************************************************/ class FrameLoadingInfo : public nsISupports { public: FrameLoadingInfo(const nsSize& aSize); // nsISupports interface... NS_DECL_ISUPPORTS protected: virtual ~FrameLoadingInfo() {} public: nsSize mFrameSize; }; /******************************************************************************* * nsHTMLFrameOuterFrame ******************************************************************************/ #define nsHTMLFrameOuterFrameSuper nsHTMLContainerFrame class nsHTMLFrameOuterFrame : public nsHTMLFrameOuterFrameSuper { public: nsHTMLFrameOuterFrame(); #ifdef DEBUG NS_IMETHOD GetFrameName(nsString& aResult) const; #endif NS_IMETHOD GetFrameType(nsIAtom** aType) const; NS_IMETHOD Paint(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect, nsFramePaintLayer aWhichLayer); NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, nsIStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Reflow(nsIPresContext* aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext, nsIContent* aChild, PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aHint); NS_IMETHOD VerifyTree() const; PRBool HasBorder(); 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(); #ifdef DEBUG NS_IMETHOD GetFrameName(nsString& aResult) const; #endif NS_IMETHOD GetFrameType(nsIAtom** aType) const; /** * @see nsIFrame::Paint */ NS_IMETHOD Paint(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect, nsFramePaintLayer aWhichLayer); /** * @see nsIFrame::Reflow */ NS_IMETHOD Reflow(nsIPresContext* aCX, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); NS_IMETHOD DidReflow(nsIPresContext* aPresContext, nsDidReflowStatus aStatus); NS_IMETHOD GetParentContent(nsIContent*& aContent); PRBool GetURL(nsIContent* aContent, nsString& aResult); PRBool GetName(nsIContent* aContent, nsString& aResult); PRInt32 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); nsCOMPtr mWebShell; PRBool mCreatingViewer; }; /******************************************************************************* * nsHTMLFrameOuterFrame ******************************************************************************/ nsHTMLFrameOuterFrame::nsHTMLFrameOuterFrame() : nsHTMLContainerFrame() { mIsInline = PR_FALSE; } nsHTMLFrameOuterFrame::~nsHTMLFrameOuterFrame() { //printf("nsHTMLFrameOuterFrame destructor %X \n", this); } NS_IMETHODIMP nsHTMLFrameOuterFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, nsIStyleContext* aContext, nsIFrame* aPrevInFlow) { // determine if we are a or