1998-09-10 21:23:31 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* 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/
|
1998-09-10 21:23:31 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* 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.
|
1998-09-10 21:23:31 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-09-10 21:23:31 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:40:37 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-09-10 21:23:31 +04:00
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1998-09-10 21:23:31 +04:00
|
|
|
#include "nsLeafFrame.h"
|
|
|
|
#include "nsHTMLContainerFrame.h"
|
1998-09-25 01:37:45 +04:00
|
|
|
#include "nsIHTMLContent.h"
|
1998-09-10 21:23:31 +04:00
|
|
|
#include "nsIWebShell.h"
|
1999-11-27 06:06:59 +03:00
|
|
|
#include "nsIBaseWindow.h"
|
1999-11-19 10:35:27 +03:00
|
|
|
#include "nsIContentViewer.h"
|
|
|
|
#include "nsIMarkupDocumentViewer.h"
|
1998-09-10 21:23:31 +04:00
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsHTMLIIDs.h"
|
1999-03-09 12:44:27 +03:00
|
|
|
#include "nsIComponentManager.h"
|
1998-09-10 21:23:31 +04:00
|
|
|
#include "nsIStreamListener.h"
|
|
|
|
#include "nsIURL.h"
|
1999-11-30 07:50:42 +03:00
|
|
|
#include "nsNetUtil.h"
|
1998-09-10 21:23:31 +04:00
|
|
|
#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"
|
1999-05-11 02:49:39 +04:00
|
|
|
#include "nsLayoutAtoms.h"
|
1999-11-23 12:57:47 +03:00
|
|
|
#include "nsIChromeEventHandler.h"
|
1999-05-11 02:49:39 +04:00
|
|
|
|
1998-09-10 21:23:31 +04:00
|
|
|
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
|
|
|
|
******************************************************************************/
|
1999-04-27 22:21:30 +04:00
|
|
|
#define nsHTMLFrameOuterFrameSuper nsHTMLContainerFrame
|
|
|
|
|
|
|
|
class nsHTMLFrameOuterFrame : public nsHTMLFrameOuterFrameSuper {
|
1998-09-10 21:23:31 +04:00
|
|
|
|
|
|
|
public:
|
1998-12-03 09:31:43 +03:00
|
|
|
nsHTMLFrameOuterFrame();
|
1998-09-10 21:23:31 +04:00
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHOD GetFrameName(nsString& aResult) const;
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1998-09-10 21:23:31 +04:00
|
|
|
|
1999-05-11 02:49:39 +04:00
|
|
|
NS_IMETHOD GetFrameType(nsIAtom** aType) const;
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD Paint(nsIPresContext* aPresContext,
|
1998-09-10 21:23:31 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer);
|
1998-09-10 21:23:31 +04:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD Init(nsIPresContext* aPresContext,
|
1999-04-27 22:21:30 +04:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow);
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
1999-05-11 02:49:39 +04:00
|
|
|
|
1998-10-03 01:59:59 +04:00
|
|
|
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aChild,
|
1999-10-16 03:16:45 +04:00
|
|
|
PRInt32 aNameSpaceID,
|
1998-10-03 01:59:59 +04:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
PRInt32 aHint);
|
1998-09-10 21:23:31 +04:00
|
|
|
NS_IMETHOD VerifyTree() const;
|
1999-03-03 03:37:55 +03:00
|
|
|
PRBool HasBorder();
|
1998-09-10 21:23:31 +04:00
|
|
|
PRBool IsInline();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~nsHTMLFrameOuterFrame();
|
|
|
|
virtual void GetDesiredSize(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize);
|
1998-09-10 21:23:31 +04:00
|
|
|
virtual PRIntn GetSkipSides() const;
|
1999-04-27 22:21:30 +04:00
|
|
|
PRBool mIsInline;
|
1998-09-10 21:23:31 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFrameInnerFrame
|
|
|
|
******************************************************************************/
|
|
|
|
class nsHTMLFrameInnerFrame : public nsLeafFrame {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
1998-12-03 09:31:43 +03:00
|
|
|
nsHTMLFrameInnerFrame();
|
1998-09-10 21:23:31 +04:00
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHOD GetFrameName(nsString& aResult) const;
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1998-09-10 21:23:31 +04:00
|
|
|
|
1999-05-11 02:49:39 +04:00
|
|
|
NS_IMETHOD GetFrameType(nsIAtom** aType) const;
|
|
|
|
|
1998-09-10 21:23:31 +04:00
|
|
|
/**
|
|
|
|
* @see nsIFrame::Paint
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD Paint(nsIPresContext* aPresContext,
|
1998-09-10 21:23:31 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer);
|
1998-09-10 21:23:31 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @see nsIFrame::Reflow
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD Reflow(nsIPresContext* aCX,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
1998-09-10 21:23:31 +04:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD DidReflow(nsIPresContext* aPresContext,
|
1999-05-20 02:14:11 +04:00
|
|
|
nsDidReflowStatus aStatus);
|
|
|
|
|
1998-09-10 21:23:31 +04:00
|
|
|
NS_IMETHOD GetParentContent(nsIContent*& aContent);
|
|
|
|
PRBool GetURL(nsIContent* aContent, nsString& aResult);
|
|
|
|
PRBool GetName(nsIContent* aContent, nsString& aResult);
|
1998-11-10 02:30:16 +03:00
|
|
|
PRInt32 GetScrolling(nsIContent* aContent, PRBool aStandardMode);
|
1998-09-10 21:23:31 +04:00
|
|
|
nsFrameborder GetFrameBorder(PRBool aStandardMode);
|
|
|
|
PRInt32 GetMarginWidth(nsIPresContext* aPresContext, nsIContent* aContent);
|
|
|
|
PRInt32 GetMarginHeight(nsIPresContext* aPresContext, nsIContent* aContent);
|
1998-10-03 01:59:59 +04:00
|
|
|
|
|
|
|
nsresult ReloadURL();
|
|
|
|
|
1998-09-10 21:23:31 +04:00
|
|
|
protected:
|
1999-11-24 09:03:41 +03:00
|
|
|
nsresult CreateWebShell(nsIPresContext* aPresContext, const nsSize& aSize);
|
1998-09-10 21:23:31 +04:00
|
|
|
|
|
|
|
virtual ~nsHTMLFrameInnerFrame();
|
|
|
|
|
|
|
|
virtual void GetDesiredSize(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize);
|
1998-09-10 21:23:31 +04:00
|
|
|
|
1999-11-27 06:06:59 +03:00
|
|
|
nsCOMPtr<nsIWebShell> mWebShell;
|
1998-09-10 21:23:31 +04:00
|
|
|
PRBool mCreatingViewer;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFrameOuterFrame
|
|
|
|
******************************************************************************/
|
1998-12-03 09:31:43 +03:00
|
|
|
nsHTMLFrameOuterFrame::nsHTMLFrameOuterFrame()
|
|
|
|
: nsHTMLContainerFrame()
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
1999-04-27 22:21:30 +04:00
|
|
|
mIsInline = PR_FALSE;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsHTMLFrameOuterFrame::~nsHTMLFrameOuterFrame()
|
|
|
|
{
|
|
|
|
//printf("nsHTMLFrameOuterFrame destructor %X \n", this);
|
1999-04-27 22:21:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLFrameOuterFrame::Init(nsIPresContext* aPresContext,
|
1999-04-27 22:21:30 +04:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
// determine if we are a <frame> or <iframe>
|
|
|
|
if (aContent) {
|
1999-10-14 14:58:04 +04:00
|
|
|
nsCOMPtr<nsIDOMHTMLFrameElement> frameElem = do_QueryInterface(aContent);
|
|
|
|
mIsInline = frameElem ? PR_FALSE : PR_TRUE;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
1999-04-27 22:21:30 +04:00
|
|
|
return nsHTMLFrameOuterFrameSuper::Init(aPresContext, aContent, aParent,
|
|
|
|
aContext, aPrevInFlow);
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
1999-04-27 22:21:30 +04:00
|
|
|
|
1999-03-03 03:37:55 +03:00
|
|
|
PRBool
|
|
|
|
nsHTMLFrameOuterFrame::HasBorder()
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
|
|
|
if (IsInline()) {
|
1999-01-16 01:53:39 +03:00
|
|
|
nsIFrame* firstChild = mFrames.FirstChild();
|
1999-01-16 02:47:23 +03:00
|
|
|
if (nsnull != firstChild) {
|
1999-01-16 01:53:39 +03:00
|
|
|
if (eFrameborder_No != ((nsHTMLFrameInnerFrame*)firstChild)->GetFrameBorder(eCompatibility_Standard)) {
|
1999-03-03 03:37:55 +03:00
|
|
|
return PR_TRUE;
|
1998-10-23 21:52:45 +04:00
|
|
|
}
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
1999-03-03 03:37:55 +03:00
|
|
|
}
|
|
|
|
return PR_FALSE;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
1999-03-03 03:37:55 +03:00
|
|
|
|
1998-09-10 21:23:31 +04:00
|
|
|
PRIntn
|
|
|
|
nsHTMLFrameOuterFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHTMLFrameOuterFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
|
|
|
// <frame> processing does not use this routine, only <iframe>
|
1998-11-14 04:52:27 +03:00
|
|
|
float p2t;
|
1999-02-12 20:45:58 +03:00
|
|
|
aPresContext->GetScaledPixelsToTwips(&p2t);
|
1998-09-10 21:23:31 +04:00
|
|
|
|
1999-03-22 23:47:21 +03:00
|
|
|
// XXX this needs to be changed from (200,200) to a better default
|
|
|
|
// for inline frames
|
1999-07-20 07:41:03 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedWidth) {
|
|
|
|
aDesiredSize.width = aReflowState.mComputedWidth;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
1998-10-12 21:00:32 +04:00
|
|
|
else {
|
|
|
|
aDesiredSize.width = NSIntPixelsToTwips(200, p2t);
|
|
|
|
}
|
1999-07-20 07:41:03 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) {
|
|
|
|
aDesiredSize.height = aReflowState.mComputedHeight;
|
1998-10-12 21:00:32 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
aDesiredSize.height = NSIntPixelsToTwips(200, p2t);
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
aDesiredSize.ascent = aDesiredSize.height;
|
|
|
|
aDesiredSize.descent = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsHTMLFrameOuterFrame::IsInline()
|
|
|
|
{
|
1999-04-27 22:21:30 +04:00
|
|
|
return mIsInline;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLFrameOuterFrame::Paint(nsIPresContext* aPresContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer)
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
|
|
|
//printf("outer paint %X (%d,%d,%d,%d) \n", this, aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
|
1999-01-16 01:53:39 +03:00
|
|
|
nsIFrame* firstChild = mFrames.FirstChild();
|
|
|
|
if (nsnull != firstChild) {
|
|
|
|
firstChild->Paint(aPresContext, aRenderingContext, aDirtyRect,
|
|
|
|
aWhichLayer);
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
if (IsInline()) {
|
1998-12-18 18:54:23 +03:00
|
|
|
return nsHTMLContainerFrame::Paint(aPresContext, aRenderingContext,
|
|
|
|
aDirtyRect, aWhichLayer);
|
1998-09-10 21:23:31 +04:00
|
|
|
} else {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP nsHTMLFrameOuterFrame::GetFrameName(nsString& aResult) const
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
1998-11-19 20:22:29 +03:00
|
|
|
return MakeFrameName("FrameOuter", aResult);
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1998-09-10 21:23:31 +04:00
|
|
|
|
1999-05-11 02:49:39 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLFrameOuterFrame::GetFrameType(nsIAtom** aType) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
|
|
|
*aType = nsLayoutAtoms::htmlFrameOuterFrame;
|
|
|
|
NS_ADDREF(*aType);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-10 21:23:31 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLFrameOuterFrame::Reflow(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
1999-01-06 02:31:18 +03:00
|
|
|
//printf("OuterFrame::Reflow %X (%d,%d) \n", this, aReflowState.availableWidth, aReflowState.availableHeight);
|
1998-09-10 21:23:31 +04:00
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("enter nsHTMLFrameOuterFrame::Reflow: maxSize=%d,%d reason=%d",
|
1999-01-06 02:31:18 +03:00
|
|
|
aReflowState.availableWidth, aReflowState.availableHeight, aReflowState.reason));
|
1998-09-10 21:23:31 +04:00
|
|
|
|
|
|
|
if (IsInline()) {
|
1999-11-24 09:03:41 +03:00
|
|
|
GetDesiredSize(aPresContext, aReflowState, aDesiredSize);
|
1998-09-10 21:23:31 +04:00
|
|
|
} else {
|
1999-01-06 02:31:18 +03:00
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
|
|
|
aDesiredSize.height = aReflowState.availableHeight;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
1999-01-16 01:53:39 +03:00
|
|
|
nsIFrame* firstChild = mFrames.FirstChild();
|
|
|
|
if (nsnull == firstChild) {
|
1999-12-05 02:49:50 +03:00
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(shell));
|
|
|
|
firstChild = new (shell.get()) nsHTMLFrameInnerFrame;
|
1999-01-16 01:53:39 +03:00
|
|
|
mFrames.SetFrames(firstChild);
|
1998-09-10 21:23:31 +04:00
|
|
|
// XXX temporary! use style system to get correct style!
|
1999-02-25 06:27:57 +03:00
|
|
|
firstChild->Init(aPresContext, mContent, this, mStyleContext, nsnull);
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
1999-03-03 03:37:55 +03:00
|
|
|
|
|
|
|
nsSize innerSize(aDesiredSize.width, aDesiredSize.height);
|
|
|
|
nsPoint offset(0,0);
|
|
|
|
if (IsInline() && HasBorder()) {
|
|
|
|
const nsStyleSpacing* spacing =
|
|
|
|
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
|
|
|
nsMargin border;
|
|
|
|
spacing->CalcBorderFor(this, border);
|
|
|
|
offset.x = border.left;
|
|
|
|
offset.y = border.right;
|
1999-05-10 01:46:24 +04:00
|
|
|
// XXX Don't subtract the border!!! The size we are given does not include our
|
|
|
|
// border! -EDV
|
|
|
|
//innerSize.width -= border.left + border.right;
|
|
|
|
//innerSize.height -= border.top + border.bottom;
|
|
|
|
|
|
|
|
// we now need to add our border in. -EDV
|
|
|
|
aDesiredSize.width += border.left + border.right;
|
|
|
|
aDesiredSize.height += border.top + border.bottom;
|
1999-03-03 03:37:55 +03:00
|
|
|
}
|
1998-09-10 21:23:31 +04:00
|
|
|
|
|
|
|
// Reflow the child and get its desired size
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics kidMetrics(aDesiredSize.maxElementSize);
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, firstChild,
|
1998-10-12 18:48:02 +04:00
|
|
|
innerSize);
|
1999-11-19 18:33:29 +03:00
|
|
|
ReflowChild(firstChild, aPresContext, kidMetrics, kidReflowState,
|
|
|
|
offset.x, offset.y, 0, aStatus);
|
1999-10-30 06:52:11 +04:00
|
|
|
NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status");
|
1998-09-10 21:23:31 +04:00
|
|
|
|
1999-10-30 06:52:11 +04:00
|
|
|
// Place and size the child
|
1999-11-19 18:33:29 +03:00
|
|
|
FinishReflowChild(firstChild, aPresContext, kidMetrics, offset.x, offset.y, 0);
|
1998-09-10 21:23:31 +04:00
|
|
|
|
|
|
|
// XXX what should the max-element-size of an iframe be? Shouldn't
|
|
|
|
// iframe's normally shrink wrap around their content when they
|
|
|
|
// don't have a specified width/height?
|
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize->width = aDesiredSize.width;
|
|
|
|
aDesiredSize.maxElementSize->height = aDesiredSize.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("exit nsHTMLFrameOuterFrame::Reflow: size=%d,%d status=%x",
|
|
|
|
aDesiredSize.width, aDesiredSize.height, aStatus));
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLFrameOuterFrame::VerifyTree() const
|
|
|
|
{
|
|
|
|
// XXX Completely disabled for now; once pseud-frames are reworked
|
|
|
|
// then we can turn it back on.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-03 01:59:59 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLFrameOuterFrame::AttributeChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aChild,
|
1999-10-16 03:16:45 +04:00
|
|
|
PRInt32 aNameSpaceID,
|
1998-10-03 01:59:59 +04:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
PRInt32 aHint)
|
|
|
|
{
|
|
|
|
if (nsHTMLAtoms::src == aAttribute) {
|
|
|
|
printf("got a request\n");
|
1999-01-16 01:53:39 +03:00
|
|
|
nsIFrame* firstChild = mFrames.FirstChild();
|
|
|
|
if (nsnull != firstChild) {
|
|
|
|
((nsHTMLFrameInnerFrame*)firstChild)->ReloadURL();
|
1998-10-03 01:59:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-10 21:23:31 +04:00
|
|
|
nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewHTMLFrameOuterFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-05 02:49:50 +03:00
|
|
|
nsHTMLFrameOuterFrame* it = new (aPresShell) nsHTMLFrameOuterFrame;
|
1999-05-12 02:03:29 +04:00
|
|
|
if (!it) {
|
1998-09-10 21:23:31 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-12 02:03:29 +04:00
|
|
|
*aNewFrame = it;
|
1998-09-10 21:23:31 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFrameInnerFrame
|
|
|
|
******************************************************************************/
|
1998-12-03 09:31:43 +03:00
|
|
|
nsHTMLFrameInnerFrame::nsHTMLFrameInnerFrame()
|
|
|
|
: nsLeafFrame()
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
|
|
|
mCreatingViewer = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsHTMLFrameInnerFrame::~nsHTMLFrameInnerFrame()
|
|
|
|
{
|
1999-11-27 06:06:59 +03:00
|
|
|
//printf("nsHTMLFrameInnerFrame destructor %X \n", this);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIBaseWindow> webShellWin(do_QueryInterface(mWebShell));
|
|
|
|
if(webShellWin)
|
|
|
|
webShellWin->Destroy();
|
|
|
|
mWebShell = nsnull; // This is the location it was released before...
|
|
|
|
// Not sure if there is ordering depending on this.
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsHTMLFrameInnerFrame::GetURL(nsIContent* aContent, nsString& aResult)
|
|
|
|
{
|
1999-10-14 14:58:04 +04:00
|
|
|
aResult.SetLength(0);
|
|
|
|
|
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == (aContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::src, aResult))) {
|
|
|
|
if (aResult.Length() > 0) {
|
|
|
|
return PR_TRUE;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
}
|
1999-10-14 14:58:04 +04:00
|
|
|
|
|
|
|
return PR_FALSE;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsHTMLFrameInnerFrame::GetName(nsIContent* aContent, nsString& aResult)
|
|
|
|
{
|
1999-10-14 14:58:04 +04:00
|
|
|
aResult.SetLength(0);
|
|
|
|
|
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == (aContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::name, aResult))) {
|
|
|
|
if (aResult.Length() > 0) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
1999-10-14 14:58:04 +04:00
|
|
|
|
|
|
|
return PR_FALSE;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
1998-11-10 02:30:16 +03:00
|
|
|
PRInt32 nsHTMLFrameInnerFrame::GetScrolling(nsIContent* aContent, PRBool aStandardMode)
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
|
|
|
nsIHTMLContent* content = nsnull;
|
|
|
|
aContent->QueryInterface(kIHTMLContentIID, (void**) &content);
|
|
|
|
if (nsnull != content) {
|
|
|
|
nsHTMLValue value;
|
1998-12-20 04:21:23 +03:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::scrolling, value))) {
|
1998-09-10 21:23:31 +04:00
|
|
|
if (eHTMLUnit_Enumerated == value.GetUnit()) {
|
1998-11-10 02:30:16 +03:00
|
|
|
PRInt32 returnValue;
|
1998-09-10 21:23:31 +04:00
|
|
|
PRInt32 intValue;
|
|
|
|
intValue = value.GetIntValue();
|
|
|
|
if (!aStandardMode) {
|
|
|
|
if ((NS_STYLE_FRAME_ON == intValue) || (NS_STYLE_FRAME_SCROLL == intValue)) {
|
|
|
|
intValue = NS_STYLE_FRAME_YES;
|
1998-11-10 02:30:16 +03:00
|
|
|
} else if ((NS_STYLE_FRAME_OFF == intValue) || (NS_STYLE_FRAME_NOSCROLL == intValue)) {
|
1998-09-10 21:23:31 +04:00
|
|
|
intValue = NS_STYLE_FRAME_NO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (NS_STYLE_FRAME_YES == intValue) {
|
1998-11-10 02:30:16 +03:00
|
|
|
returnValue = NS_STYLE_OVERFLOW_SCROLL;
|
|
|
|
} else if (NS_STYLE_FRAME_NO == intValue) {
|
|
|
|
returnValue = NS_STYLE_OVERFLOW_HIDDEN;
|
|
|
|
} else if (NS_STYLE_FRAME_AUTO == intValue) {
|
|
|
|
returnValue = NS_STYLE_OVERFLOW_AUTO;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
1998-11-10 02:30:16 +03:00
|
|
|
NS_RELEASE(content);
|
|
|
|
return returnValue;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
1998-11-10 02:30:16 +03:00
|
|
|
return -1;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsFrameborder nsHTMLFrameInnerFrame::GetFrameBorder(PRBool aStandardMode)
|
|
|
|
{
|
|
|
|
nsIHTMLContent* content = nsnull;
|
|
|
|
mContent->QueryInterface(kIHTMLContentIID, (void**) &content);
|
|
|
|
if (nsnull != content) {
|
|
|
|
nsHTMLValue value;
|
1998-12-20 04:21:23 +03:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::frameborder, value))) {
|
1998-09-10 21:23:31 +04:00
|
|
|
if (eHTMLUnit_Enumerated == value.GetUnit()) {
|
|
|
|
PRInt32 intValue;
|
|
|
|
intValue = value.GetIntValue();
|
|
|
|
if (!aStandardMode) {
|
|
|
|
if (NS_STYLE_FRAME_YES == intValue) {
|
|
|
|
intValue = NS_STYLE_FRAME_0;
|
|
|
|
}
|
|
|
|
else if (NS_STYLE_FRAME_NO == intValue) {
|
|
|
|
intValue = NS_STYLE_FRAME_1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (NS_STYLE_FRAME_0 == intValue) {
|
|
|
|
NS_RELEASE(content);
|
|
|
|
return eFrameborder_No;
|
|
|
|
}
|
|
|
|
else if (NS_STYLE_FRAME_1 == intValue) {
|
|
|
|
NS_RELEASE(content);
|
|
|
|
return eFrameborder_Yes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
// XXX if we get here, check for nsIDOMFRAMESETElement interface
|
|
|
|
return eFrameborder_Notset;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PRInt32 nsHTMLFrameInnerFrame::GetMarginWidth(nsIPresContext* aPresContext, nsIContent* aContent)
|
|
|
|
{
|
|
|
|
PRInt32 marginWidth = -1;
|
|
|
|
nsIHTMLContent* content = nsnull;
|
1998-11-21 20:30:41 +03:00
|
|
|
if (NS_SUCCEEDED(mContent->QueryInterface(kIHTMLContentIID, (void**) &content))) {
|
1998-11-14 04:52:27 +03:00
|
|
|
float p2t;
|
1999-02-12 20:45:58 +03:00
|
|
|
aPresContext->GetScaledPixelsToTwips(&p2t);
|
1998-09-10 21:23:31 +04:00
|
|
|
nsHTMLValue value;
|
1998-12-20 04:21:23 +03:00
|
|
|
content->GetHTMLAttribute(nsHTMLAtoms::marginwidth, value);
|
1998-09-10 21:23:31 +04:00
|
|
|
if (eHTMLUnit_Pixel == value.GetUnit()) {
|
|
|
|
marginWidth = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
|
|
|
|
if (marginWidth < 0) {
|
|
|
|
marginWidth = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
return marginWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 nsHTMLFrameInnerFrame::GetMarginHeight(nsIPresContext* aPresContext, nsIContent* aContent)
|
|
|
|
{
|
|
|
|
PRInt32 marginHeight = -1;
|
|
|
|
nsIHTMLContent* content = nsnull;
|
1998-11-21 20:30:41 +03:00
|
|
|
if (NS_SUCCEEDED(mContent->QueryInterface(kIHTMLContentIID, (void**) &content))) {
|
1998-11-14 04:52:27 +03:00
|
|
|
float p2t;
|
1999-02-12 20:45:58 +03:00
|
|
|
aPresContext->GetScaledPixelsToTwips(&p2t);
|
1998-09-10 21:23:31 +04:00
|
|
|
nsHTMLValue value;
|
1998-12-20 04:21:23 +03:00
|
|
|
content->GetHTMLAttribute(nsHTMLAtoms::marginheight, value);
|
1998-09-10 21:23:31 +04:00
|
|
|
if (eHTMLUnit_Pixel == value.GetUnit()) {
|
|
|
|
marginHeight = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
|
|
|
|
if (marginHeight < 0) {
|
|
|
|
marginHeight = 0;
|
|
|
|
}
|
|
|
|
}
|
1998-11-21 20:30:41 +03:00
|
|
|
NS_RELEASE(content);
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
return marginHeight;
|
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP nsHTMLFrameInnerFrame::GetFrameName(nsString& aResult) const
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
1998-11-19 20:22:29 +03:00
|
|
|
return MakeFrameName("FrameInner", aResult);
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1998-09-10 21:23:31 +04:00
|
|
|
|
1999-05-11 02:49:39 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLFrameInnerFrame::GetFrameType(nsIAtom** aType) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
|
|
|
*aType = nsLayoutAtoms::htmlFrameInnerFrame;
|
|
|
|
NS_ADDREF(*aType);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-10 21:23:31 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLFrameInnerFrame::Paint(nsIPresContext* aPresContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1999-04-27 22:21:30 +04:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer)
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
|
|
|
//printf("inner paint %X (%d,%d,%d,%d) \n", this, aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
|
1999-04-28 01:05:32 +04:00
|
|
|
// if there is not web shell paint based on our background color,
|
|
|
|
// otherwise let the web shell paint the sub document
|
1999-04-27 22:21:30 +04:00
|
|
|
if (!mWebShell) {
|
1999-04-28 01:05:32 +04:00
|
|
|
const nsStyleColor* color =
|
|
|
|
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
|
|
|
|
aRenderingContext.SetColor(color->mBackgroundColor);
|
1999-04-27 22:21:30 +04:00
|
|
|
aRenderingContext.FillRect(mRect);
|
|
|
|
}
|
1998-09-10 21:23:31 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLFrameInnerFrame::GetParentContent(nsIContent*& aContent)
|
|
|
|
{
|
|
|
|
nsHTMLFrameOuterFrame* parent;
|
1999-02-10 04:36:30 +03:00
|
|
|
GetParent((nsIFrame**)&parent);
|
1999-02-10 03:42:56 +03:00
|
|
|
|
|
|
|
nsIContent* content;
|
|
|
|
nsresult rv = parent->GetContent(&content);
|
|
|
|
aContent = content;
|
|
|
|
return rv;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-04-02 00:39:30 +04:00
|
|
|
static
|
1998-09-10 21:23:31 +04:00
|
|
|
void TempMakeAbsURL(nsIContent* aContent, nsString& aRelURL, nsString& aAbsURL)
|
|
|
|
{
|
1999-06-23 07:29:44 +04:00
|
|
|
nsIURI* baseURL = nsnull;
|
1999-01-15 05:07:46 +03:00
|
|
|
nsIHTMLContent* htmlContent;
|
|
|
|
if (NS_SUCCEEDED(aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent))) {
|
|
|
|
htmlContent->GetBaseURL(baseURL);
|
|
|
|
NS_RELEASE(htmlContent);
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
1999-01-15 05:07:46 +03:00
|
|
|
else {
|
|
|
|
nsIDocument* doc;
|
|
|
|
if (NS_SUCCEEDED(aContent->GetDocument(doc))) {
|
|
|
|
doc->GetBaseURL(baseURL);
|
|
|
|
NS_RELEASE(doc);
|
|
|
|
}
|
1998-11-24 05:01:45 +03:00
|
|
|
}
|
1999-01-15 05:07:46 +03:00
|
|
|
|
|
|
|
nsString empty;
|
1999-07-07 12:08:40 +04:00
|
|
|
nsresult rv = NS_MakeAbsoluteURI(aRelURL, baseURL, aAbsURL);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "XXX make this function return an nsresult, like it should!");
|
1999-01-15 05:07:46 +03:00
|
|
|
NS_IF_RELEASE(baseURL);
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
1999-05-20 02:14:11 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLFrameInnerFrame::DidReflow(nsIPresContext* aPresContext,
|
1999-05-20 02:14:11 +04:00
|
|
|
nsDidReflowStatus aStatus)
|
|
|
|
{
|
|
|
|
nsresult rv = nsLeafFrame::DidReflow(aPresContext, aStatus);
|
|
|
|
|
|
|
|
|
|
|
|
// The view is created hidden; once we have reflowed it and it has been
|
|
|
|
// positioned then we show it.
|
|
|
|
if (NS_FRAME_REFLOW_FINISHED == aStatus) {
|
|
|
|
nsIView* view = nsnull;
|
1999-11-24 09:03:41 +03:00
|
|
|
GetView(aPresContext, &view);
|
1999-06-03 08:34:49 +04:00
|
|
|
if (view) {
|
|
|
|
const nsStyleDisplay* display;
|
|
|
|
GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display));
|
1999-09-29 07:36:16 +04:00
|
|
|
nsViewVisibility newVis = NS_STYLE_VISIBILITY_VISIBLE == display->mVisible ? nsViewVisibility_kShow : nsViewVisibility_kHide;
|
1999-06-03 08:34:49 +04:00
|
|
|
nsViewVisibility oldVis;
|
|
|
|
// only change if different.
|
|
|
|
view->GetVisibility(oldVis);
|
|
|
|
if (newVis != oldVis)
|
|
|
|
view->SetVisibility(newVis);
|
|
|
|
}
|
1999-05-20 02:14:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
1998-09-10 21:23:31 +04:00
|
|
|
|
|
|
|
nsresult
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext,
|
1998-09-10 21:23:31 +04:00
|
|
|
const nsSize& aSize)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsIContent* content;
|
|
|
|
GetParentContent(content);
|
|
|
|
|
1999-11-27 06:06:59 +03:00
|
|
|
mWebShell = do_CreateInstance(kWebShellCID);
|
|
|
|
NS_ENSURE_TRUE(mWebShell, NS_ERROR_FAILURE);
|
1999-05-05 03:29:06 +04:00
|
|
|
|
1998-11-10 02:30:16 +03:00
|
|
|
// pass along marginwidth, marginheight, scrolling so sub document can use it
|
1999-11-24 09:03:41 +03:00
|
|
|
mWebShell->SetMarginWidth(GetMarginWidth(aPresContext, content));
|
|
|
|
mWebShell->SetMarginHeight(GetMarginHeight(aPresContext, content));
|
1998-11-10 02:30:16 +03:00
|
|
|
nsCompatibility mode;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetCompatibilityMode(&mode);
|
1998-11-10 02:30:16 +03:00
|
|
|
mWebShell->SetScrolling(GetScrolling(content, mode));
|
1998-09-10 21:23:31 +04:00
|
|
|
nsString frameName;
|
|
|
|
if (GetName(content, frameName)) {
|
1999-04-22 03:43:11 +04:00
|
|
|
mWebShell->SetName(frameName.GetUnicode());
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// If our container is a web-shell, inform it that it has a new
|
|
|
|
// child. If it's not a web-shell then some things will not operate
|
|
|
|
// properly.
|
|
|
|
nsISupports* container;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetContainer(&container);
|
1998-09-10 21:23:31 +04:00
|
|
|
if (nsnull != container) {
|
|
|
|
nsIWebShell* outerShell = nsnull;
|
|
|
|
container->QueryInterface(kIWebShellIID, (void**) &outerShell);
|
|
|
|
if (nsnull != outerShell) {
|
|
|
|
outerShell->AddChild(mWebShell);
|
|
|
|
|
1999-04-20 05:56:07 +04:00
|
|
|
// connect the container...
|
|
|
|
nsIWebShellContainer* outerContainer = nsnull;
|
|
|
|
container->QueryInterface(kIWebShellContainerIID, (void**) &outerContainer);
|
|
|
|
if (nsnull != outerContainer) {
|
|
|
|
mWebShell->SetContainer(outerContainer);
|
|
|
|
NS_RELEASE(outerContainer);
|
|
|
|
}
|
|
|
|
|
1999-04-21 04:19:30 +04:00
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
nsWebShellType parentType;
|
|
|
|
outerShell->GetWebShellType(parentType);
|
|
|
|
nsIAtom* typeAtom = NS_NewAtom("type");
|
1999-06-27 01:48:29 +04:00
|
|
|
nsAutoString value, valuePiece;
|
|
|
|
PRBool isContent;
|
|
|
|
|
|
|
|
isContent = PR_FALSE;
|
|
|
|
if (NS_SUCCEEDED(content->GetAttribute(kNameSpaceID_None, typeAtom, value))) {
|
|
|
|
|
|
|
|
// we accept "content" and "content-xxx" values.
|
|
|
|
// at time of writing, we expect "xxx" to be "primary", but
|
|
|
|
// someday it might be an integer expressing priority
|
|
|
|
value.Left(valuePiece, 7);
|
|
|
|
if (valuePiece.EqualsIgnoreCase("content") &&
|
|
|
|
(value.Length() == 7 ||
|
|
|
|
value.Mid(valuePiece, 7, 1) == 1 && valuePiece.Equals("-")))
|
|
|
|
isContent = PR_TRUE;
|
1999-04-21 04:19:30 +04:00
|
|
|
}
|
1999-06-27 01:48:29 +04:00
|
|
|
if (isContent) {
|
|
|
|
// The web shell's type is content.
|
|
|
|
mWebShell->SetWebShellType(nsWebShellContent);
|
|
|
|
nsCOMPtr<nsIWebShellContainer> shellAsContainer;
|
|
|
|
shellAsContainer = do_QueryInterface(mWebShell);
|
|
|
|
shellAsContainer->ContentShellAdded(mWebShell, content);
|
|
|
|
} else {
|
1999-04-21 04:19:30 +04:00
|
|
|
// Inherit our type from our parent webshell. If it is
|
1999-06-27 01:48:29 +04:00
|
|
|
// chrome, we'll be chrome. If it is content, we'll be
|
|
|
|
// content.
|
|
|
|
mWebShell->SetWebShellType(parentType);
|
1999-04-21 04:19:30 +04:00
|
|
|
}
|
1999-05-28 01:04:52 +04:00
|
|
|
|
1999-09-21 05:03:00 +04:00
|
|
|
// Make sure all shells have links back to the content element in the
|
|
|
|
// nearest enclosing chrome shell.
|
1999-05-29 02:26:48 +04:00
|
|
|
|
1999-11-23 12:57:47 +03:00
|
|
|
nsCOMPtr<nsIChromeEventHandler> chromeEventHandler;
|
1999-12-03 12:24:22 +03:00
|
|
|
if (parentType == nsWebShellChrome) {
|
1999-09-21 05:03:00 +04:00
|
|
|
// Our parent shell is a chrome shell. It is therefore our nearest
|
1999-11-23 12:57:47 +03:00
|
|
|
// enclosing chrome shell.
|
|
|
|
chromeEventHandler = do_QueryInterface(mContent);
|
|
|
|
NS_WARN_IF_FALSE(chromeEventHandler, "This mContent should implement this.");
|
1999-09-21 05:03:00 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Our parent shell is a content shell. Get the chrome info from
|
|
|
|
// it and use that for our shell as well.
|
1999-11-23 12:57:47 +03:00
|
|
|
outerShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler));
|
1999-09-21 05:03:00 +04:00
|
|
|
}
|
1999-06-27 01:48:29 +04:00
|
|
|
|
1999-11-23 12:57:47 +03:00
|
|
|
mWebShell->SetChromeEventHandler(chromeEventHandler);
|
1999-05-28 01:04:52 +04:00
|
|
|
|
1999-04-23 07:51:39 +04:00
|
|
|
#endif // INCLUDE_XUL
|
1999-04-21 04:19:30 +04:00
|
|
|
|
1999-04-20 05:56:07 +04:00
|
|
|
nsIPref* outerPrefs = nsnull; // connect the prefs
|
|
|
|
outerShell->GetPrefs(outerPrefs);
|
|
|
|
if (nsnull != outerPrefs) {
|
|
|
|
mWebShell->SetPrefs(outerPrefs);
|
|
|
|
NS_RELEASE(outerPrefs);
|
1999-04-23 07:51:39 +04:00
|
|
|
}
|
1998-09-10 21:23:31 +04:00
|
|
|
NS_RELEASE(outerShell);
|
|
|
|
}
|
|
|
|
NS_RELEASE(container);
|
|
|
|
}
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
float t2p;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetTwipsToPixels(&t2p);
|
1999-02-12 20:45:58 +03:00
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
1998-09-10 21:23:31 +04:00
|
|
|
|
|
|
|
// create, init, set the parent of the view
|
|
|
|
nsIView* view;
|
1999-03-09 12:44:27 +03:00
|
|
|
rv = nsComponentManager::CreateInstance(kCViewCID, nsnull, kIViewIID,
|
1998-09-10 21:23:31 +04:00
|
|
|
(void **)&view);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
NS_ASSERTION(0, "Could not create view for nsHTMLFrame");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIView* parView;
|
|
|
|
nsPoint origin;
|
1999-11-24 09:03:41 +03:00
|
|
|
GetOffsetFromView(aPresContext, origin, &parView);
|
1998-09-10 21:23:31 +04:00
|
|
|
nsRect viewBounds(origin.x, origin.y, aSize.width, aSize.height);
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
nsCOMPtr<nsIViewManager> viewMan;
|
|
|
|
presShell->GetViewManager(getter_AddRefs(viewMan));
|
1998-11-04 07:14:10 +03:00
|
|
|
rv = view->Init(viewMan, viewBounds, parView);
|
1998-09-10 21:23:31 +04:00
|
|
|
viewMan->InsertChild(parView, view, 0);
|
1998-11-04 07:14:10 +03:00
|
|
|
rv = view->CreateWidget(kCChildCID);
|
1999-11-24 09:03:41 +03:00
|
|
|
SetView(aPresContext, view);
|
1998-09-10 21:23:31 +04:00
|
|
|
|
1999-04-24 01:55:15 +04:00
|
|
|
// if the visibility is hidden, reflect that in the view
|
|
|
|
const nsStyleDisplay* display;
|
|
|
|
GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display));
|
1999-09-29 07:36:16 +04:00
|
|
|
if (NS_STYLE_VISIBILITY_VISIBLE != display->mVisible) {
|
1999-04-24 01:55:15 +04:00
|
|
|
view->SetVisibility(nsViewVisibility_kHide);
|
|
|
|
}
|
|
|
|
|
1999-11-27 06:06:59 +03:00
|
|
|
nsCOMPtr<nsIBaseWindow> webShellWin(do_QueryInterface(mWebShell));
|
|
|
|
NS_ENSURE_TRUE(webShellWin, NS_ERROR_FAILURE);
|
|
|
|
nsCOMPtr<nsIWidget> widget;
|
|
|
|
view->GetWidget(*getter_AddRefs(widget));
|
1998-09-10 21:23:31 +04:00
|
|
|
nsRect webBounds(0, 0, NSToCoordRound(aSize.width * t2p),
|
|
|
|
NSToCoordRound(aSize.height * t2p));
|
|
|
|
|
|
|
|
mWebShell->Init(widget->GetNativeData(NS_NATIVE_WIDGET),
|
|
|
|
webBounds.x, webBounds.y,
|
1998-11-10 02:30:16 +03:00
|
|
|
webBounds.width, webBounds.height);
|
|
|
|
//GetScrolling(content, PR_FALSE));
|
1998-09-10 21:23:31 +04:00
|
|
|
NS_RELEASE(content);
|
|
|
|
|
1999-11-27 06:06:59 +03:00
|
|
|
webShellWin->SetVisibility(PR_TRUE);
|
1998-09-10 21:23:31 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-20 02:14:11 +04:00
|
|
|
|
1998-09-10 21:23:31 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLFrameInnerFrame::Reflow(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("enter nsHTMLFrameInnerFrame::Reflow: maxSize=%d,%d reason=%d",
|
1999-01-06 02:31:18 +03:00
|
|
|
aReflowState.availableWidth,
|
|
|
|
aReflowState.availableHeight,
|
1998-09-10 21:23:31 +04:00
|
|
|
aReflowState.reason));
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
// use the max size set in aReflowState by the nsHTMLFrameOuterFrame as our size
|
|
|
|
if (!mCreatingViewer) {
|
|
|
|
nsIContent* content;
|
|
|
|
GetParentContent(content);
|
|
|
|
|
|
|
|
nsAutoString url;
|
1998-11-23 20:37:46 +03:00
|
|
|
PRBool hasURL = GetURL(content, url);
|
1998-09-10 21:23:31 +04:00
|
|
|
|
1998-11-23 20:37:46 +03:00
|
|
|
// if the size is not 0 and there is a src, create the web shell
|
1999-01-06 02:31:18 +03:00
|
|
|
if ((aReflowState.availableWidth >= 0) && (aReflowState.availableHeight >= 0) && hasURL) {
|
1999-11-27 06:06:59 +03:00
|
|
|
if (!mWebShell) {
|
1999-01-06 02:31:18 +03:00
|
|
|
nsSize maxSize(aReflowState.availableWidth, aReflowState.availableHeight);
|
|
|
|
rv = CreateWebShell(aPresContext, maxSize);
|
1999-04-21 03:32:43 +04:00
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
// The URL can be destructively altered when a content shell is made.
|
|
|
|
// Refetch it to ensure we have the actual URL to load.
|
|
|
|
hasURL = GetURL(content, url);
|
|
|
|
#endif // INCLUDE_XUL
|
1998-11-23 20:37:46 +03:00
|
|
|
}
|
|
|
|
|
1999-11-27 06:06:59 +03:00
|
|
|
if (mWebShell) {
|
1998-11-23 20:37:46 +03:00
|
|
|
mCreatingViewer=PR_TRUE;
|
1998-09-10 21:23:31 +04:00
|
|
|
|
1998-11-23 20:37:46 +03:00
|
|
|
// load the document
|
|
|
|
nsString absURL;
|
|
|
|
TempMakeAbsURL(content, url, absURL);
|
1998-09-10 21:23:31 +04:00
|
|
|
|
1999-04-22 03:43:11 +04:00
|
|
|
rv = mWebShell->LoadURL(absURL.GetUnicode()); // URL string with a default nsnull value for post Data
|
1999-11-19 10:35:27 +03:00
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
{ // tell the content viewer that it's an HTML frame
|
|
|
|
nsCOMPtr<nsIContentViewer> cv;
|
|
|
|
mWebShell->GetContentViewer(getter_AddRefs(cv));
|
|
|
|
if (cv)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIMarkupDocumentViewer> muCV = do_QueryInterface(cv);
|
|
|
|
if (muCV) {
|
|
|
|
muCV->SetIsFrame(PR_TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-11-23 20:37:46 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mCreatingViewer = PR_TRUE;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
|
1999-01-06 02:31:18 +03:00
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
|
|
|
aDesiredSize.height = aReflowState.availableHeight;
|
1998-09-10 21:23:31 +04:00
|
|
|
aDesiredSize.ascent = aDesiredSize.height;
|
|
|
|
aDesiredSize.descent = 0;
|
1999-07-03 01:05:20 +04:00
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize->width = aDesiredSize.width;
|
|
|
|
aDesiredSize.maxElementSize->height = aDesiredSize.height;
|
|
|
|
}
|
1998-09-10 21:23:31 +04:00
|
|
|
|
1999-04-28 01:05:32 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
1998-09-10 21:23:31 +04:00
|
|
|
// resize the sub document
|
1999-11-27 06:06:59 +03:00
|
|
|
nsCOMPtr<nsIBaseWindow> webShellWin(do_QueryInterface(mWebShell));
|
|
|
|
if(webShellWin) {
|
1999-02-12 20:45:58 +03:00
|
|
|
float t2p;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetTwipsToPixels(&t2p);
|
1998-11-23 20:37:46 +03:00
|
|
|
nsRect subBounds;
|
1998-09-10 21:23:31 +04:00
|
|
|
|
1999-11-27 06:06:59 +03:00
|
|
|
webShellWin->GetPositionAndSize(&subBounds.x, &subBounds.y,
|
|
|
|
&subBounds.width, &subBounds.height);
|
1998-11-23 20:37:46 +03:00
|
|
|
subBounds.width = NSToCoordRound(aDesiredSize.width * t2p);
|
|
|
|
subBounds.height = NSToCoordRound(aDesiredSize.height * t2p);
|
1999-11-27 06:06:59 +03:00
|
|
|
webShellWin->SetPositionAndSize(subBounds.x, subBounds.y,
|
|
|
|
subBounds.width, subBounds.height, PR_FALSE);
|
1998-09-10 21:23:31 +04:00
|
|
|
|
1998-11-23 20:37:46 +03:00
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("exit nsHTMLFrameInnerFrame::Reflow: size=%d,%d rv=%x",
|
1998-09-10 21:23:31 +04:00
|
|
|
aDesiredSize.width, aDesiredSize.height, aStatus));
|
1998-11-23 20:37:46 +03:00
|
|
|
}
|
|
|
|
|
1998-09-10 21:23:31 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-10-03 01:59:59 +04:00
|
|
|
nsresult
|
|
|
|
nsHTMLFrameInnerFrame::ReloadURL()
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsIContent* content;
|
|
|
|
GetParentContent(content);
|
|
|
|
if (nsnull != content) {
|
|
|
|
|
|
|
|
nsAutoString url;
|
|
|
|
GetURL(content, url);
|
|
|
|
|
1998-11-23 20:37:46 +03:00
|
|
|
// load a new url if the size is not 0
|
|
|
|
if ((mRect.width > 0) && (mRect.height > 0)) {
|
1999-11-27 06:06:59 +03:00
|
|
|
if (mWebShell) {
|
1998-11-23 20:37:46 +03:00
|
|
|
mCreatingViewer=PR_TRUE;
|
1998-10-03 01:59:59 +04:00
|
|
|
|
1998-11-23 20:37:46 +03:00
|
|
|
// load the document
|
|
|
|
nsString absURL;
|
|
|
|
TempMakeAbsURL(content, url, absURL);
|
1998-10-03 01:59:59 +04:00
|
|
|
|
1999-04-22 03:43:11 +04:00
|
|
|
rv = mWebShell->LoadURL(absURL.GetUnicode()); // URL string with a default nsnull value for post Data
|
1998-11-23 20:37:46 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mCreatingViewer = PR_TRUE;
|
1998-10-03 01:59:59 +04:00
|
|
|
}
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-09-10 21:23:31 +04:00
|
|
|
void
|
|
|
|
nsHTMLFrameInnerFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
|
|
|
// it must be defined, but not called
|
|
|
|
NS_ASSERTION(0, "this should never be called");
|
|
|
|
aDesiredSize.width = 0;
|
|
|
|
aDesiredSize.height = 0;
|
|
|
|
aDesiredSize.ascent = 0;
|
|
|
|
aDesiredSize.descent = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* FrameLoadingInfo
|
|
|
|
******************************************************************************/
|
|
|
|
FrameLoadingInfo::FrameLoadingInfo(const nsSize& aSize)
|
|
|
|
{
|
|
|
|
NS_INIT_REFCNT();
|
|
|
|
|
|
|
|
mFrameSize = aSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Implementation of ISupports methods...
|
|
|
|
*/
|
|
|
|
NS_IMPL_ISUPPORTS(FrameLoadingInfo,kISupportsIID);
|
|
|
|
|