1998-07-15 23:42:14 +00:00
|
|
|
/* -*- 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"
|
1998-09-24 21:37:45 +00:00
|
|
|
#include "nsIHTMLContent.h"
|
1998-07-18 21:47:56 +00:00
|
|
|
#include "nsIWebShell.h"
|
1998-07-15 23:42:14 +00:00
|
|
|
#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"
|
1998-09-09 23:30:30 +00:00
|
|
|
#include "nsStyleConsts.h"
|
1998-07-15 23:42:14 +00:00
|
|
|
#include "nsIDocumentLoader.h"
|
1998-07-31 05:58:41 +00:00
|
|
|
#include "nsIPref.h"
|
1998-09-10 17:23:31 +00:00
|
|
|
#include "nsFrameSetFrame.h"
|
1998-09-10 00:39:38 +00:00
|
|
|
#include "nsIDOMHTMLFrameElement.h"
|
|
|
|
#include "nsIDOMHTMLIFrameElement.h"
|
1998-09-05 04:00:06 +00:00
|
|
|
#include "nsGenericHTMLElement.h"
|
1998-07-15 23:42:14 +00:00
|
|
|
class nsHTMLFrame;
|
|
|
|
|
1998-08-20 06:16:32 +00:00
|
|
|
static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID);
|
1998-07-15 23:42:14 +00:00
|
|
|
static NS_DEFINE_IID(kIStreamObserverIID, NS_ISTREAMOBSERVER_IID);
|
1998-07-18 21:47:56 +00:00
|
|
|
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
|
|
|
|
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
|
1998-07-15 23:42:14 +00:00
|
|
|
static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID);
|
|
|
|
static NS_DEFINE_IID(kCViewCID, NS_VIEW_CID);
|
|
|
|
static NS_DEFINE_IID(kCChildCID, NS_CHILD_CID);
|
1998-09-09 23:30:30 +00:00
|
|
|
static NS_DEFINE_IID(kIDOMHTMLFrameElementIID, NS_IDOMHTMLFRAMEELEMENT_IID);
|
|
|
|
static NS_DEFINE_IID(kIDOMHTMLIFrameElementIID, NS_IDOMHTMLIFRAMEELEMENT_IID);
|
1998-07-15 23:42:14 +00:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 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);
|
1998-12-16 05:40:20 +00:00
|
|
|
NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax);
|
|
|
|
NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg);
|
|
|
|
NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg);
|
1998-07-15 23:42:14 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
1998-09-03 01:16:27 +00:00
|
|
|
|
1998-07-15 23:42:14 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFrameOuterFrame
|
|
|
|
******************************************************************************/
|
|
|
|
class nsHTMLFrameOuterFrame : public nsHTMLContainerFrame {
|
|
|
|
|
|
|
|
public:
|
1998-12-03 06:31:43 +00:00
|
|
|
nsHTMLFrameOuterFrame();
|
1998-07-15 23:42:14 +00:00
|
|
|
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHOD GetFrameName(nsString& aResult) const;
|
1998-07-27 05:59:37 +00:00
|
|
|
|
1998-07-15 23:42:14 +00:00
|
|
|
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 15:54:23 +00:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer);
|
1998-07-15 23:42:14 +00:00
|
|
|
|
1998-10-02 04:10:00 +00:00
|
|
|
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
1998-10-02 21:59:59 +00:00
|
|
|
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aChild,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
PRInt32 aHint);
|
1998-08-03 18:12:13 +00:00
|
|
|
NS_IMETHOD VerifyTree() const;
|
1998-07-15 23:42:14 +00:00
|
|
|
nscoord GetBorderWidth(nsIPresContext& aPresContext);
|
|
|
|
PRBool IsInline();
|
|
|
|
|
|
|
|
protected:
|
1998-09-03 01:16:27 +00:00
|
|
|
virtual ~nsHTMLFrameOuterFrame();
|
1998-07-15 23:42:14 +00:00
|
|
|
virtual void GetDesiredSize(nsIPresContext* aPresContext,
|
1998-10-02 04:10:00 +00:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-10-01 04:46:11 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize);
|
1998-07-15 23:42:14 +00:00
|
|
|
virtual PRIntn GetSkipSides() const;
|
1998-09-09 23:30:30 +00:00
|
|
|
PRBool *mIsInline;
|
1998-07-15 23:42:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFrameInnerFrame
|
|
|
|
******************************************************************************/
|
1998-08-11 18:52:35 +00:00
|
|
|
class nsHTMLFrameInnerFrame : public nsLeafFrame {
|
1998-07-15 23:42:14 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
1998-12-03 06:31:43 +00:00
|
|
|
nsHTMLFrameInnerFrame();
|
1998-07-15 23:42:14 +00:00
|
|
|
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHOD GetFrameName(nsString& aResult) const;
|
1998-07-27 05:59:37 +00:00
|
|
|
|
1998-07-15 23:42:14 +00:00
|
|
|
/**
|
|
|
|
* @see nsIFrame::Paint
|
|
|
|
*/
|
|
|
|
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 15:54:23 +00:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer);
|
1998-07-15 23:42:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @see nsIFrame::Reflow
|
|
|
|
*/
|
1998-10-02 04:10:00 +00:00
|
|
|
NS_IMETHOD Reflow(nsIPresContext& aCX,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
1998-07-15 23:42:14 +00:00
|
|
|
|
|
|
|
NS_IMETHOD MoveTo(nscoord aX, nscoord aY);
|
|
|
|
NS_IMETHOD SizeTo(nscoord aWidth, nscoord aHeight);
|
|
|
|
|
1998-09-09 23:30:30 +00:00
|
|
|
NS_IMETHOD GetParentContent(nsIContent*& aContent);
|
|
|
|
PRBool GetURL(nsIContent* aContent, nsString& aResult);
|
|
|
|
PRBool GetName(nsIContent* aContent, nsString& aResult);
|
1998-11-09 23:30:16 +00:00
|
|
|
PRInt32 GetScrolling(nsIContent* aContent, PRBool aStandardMode);
|
1998-09-09 23:30:30 +00:00
|
|
|
nsFrameborder GetFrameBorder(PRBool aStandardMode);
|
|
|
|
PRInt32 GetMarginWidth(nsIPresContext* aPresContext, nsIContent* aContent);
|
|
|
|
PRInt32 GetMarginHeight(nsIPresContext* aPresContext, nsIContent* aContent);
|
1998-10-02 21:59:59 +00:00
|
|
|
|
|
|
|
nsresult ReloadURL();
|
|
|
|
|
1998-07-15 23:42:14 +00:00
|
|
|
protected:
|
1998-07-18 21:47:56 +00:00
|
|
|
nsresult CreateWebShell(nsIPresContext& aPresContext, const nsSize& aSize);
|
1998-07-15 23:42:14 +00:00
|
|
|
|
|
|
|
virtual ~nsHTMLFrameInnerFrame();
|
|
|
|
|
|
|
|
virtual void GetDesiredSize(nsIPresContext* aPresContext,
|
1998-10-02 04:10:00 +00:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-10-01 04:46:11 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize);
|
1998-07-15 23:42:14 +00:00
|
|
|
|
1998-07-18 21:47:56 +00:00
|
|
|
nsIWebShell* mWebShell;
|
1998-07-15 23:42:14 +00:00
|
|
|
PRBool mCreatingViewer;
|
|
|
|
|
|
|
|
// XXX fix these
|
|
|
|
TempObserver* mTempObserver;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFrameOuterFrame
|
|
|
|
******************************************************************************/
|
1998-12-03 06:31:43 +00:00
|
|
|
nsHTMLFrameOuterFrame::nsHTMLFrameOuterFrame()
|
|
|
|
: nsHTMLContainerFrame()
|
1998-07-15 23:42:14 +00:00
|
|
|
{
|
1998-09-09 23:30:30 +00:00
|
|
|
mIsInline = nsnull;
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
|
|
|
|
1998-09-03 01:16:27 +00:00
|
|
|
nsHTMLFrameOuterFrame::~nsHTMLFrameOuterFrame()
|
|
|
|
{
|
|
|
|
//printf("nsHTMLFrameOuterFrame destructor %X \n", this);
|
1998-09-09 23:30:30 +00:00
|
|
|
if (mIsInline) {
|
|
|
|
delete mIsInline;
|
|
|
|
}
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
|
|
|
|
1998-07-15 23:42:14 +00:00
|
|
|
nscoord
|
|
|
|
nsHTMLFrameOuterFrame::GetBorderWidth(nsIPresContext& aPresContext)
|
|
|
|
{
|
1998-07-27 05:59:37 +00:00
|
|
|
if (IsInline()) {
|
1998-10-23 17:52:45 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
1998-07-27 05:59:37 +00:00
|
|
|
}
|
|
|
|
}
|
1998-07-15 23:42:14 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRIntn
|
|
|
|
nsHTMLFrameOuterFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHTMLFrameOuterFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
1998-10-02 04:10:00 +00:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-10-01 04:46:11 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
1998-07-15 23:42:14 +00:00
|
|
|
{
|
1998-07-21 23:20:04 +00:00
|
|
|
// <frame> processing does not use this routine, only <iframe>
|
1998-11-14 01:52:27 +00:00
|
|
|
float p2t;
|
|
|
|
aPresContext->GetScaledPixelsToTwips(p2t);
|
1998-07-15 23:42:14 +00:00
|
|
|
|
1998-07-21 23:20:04 +00:00
|
|
|
// XXX this needs to be changed from (200,200) to a better default for inline frames
|
1998-11-01 01:29:00 +00:00
|
|
|
if (aReflowState.HaveFixedContentWidth()) {
|
1998-12-30 17:50:00 +00:00
|
|
|
aDesiredSize.width = aReflowState.computedWidth;
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
1998-10-12 17:00:32 +00:00
|
|
|
else {
|
|
|
|
aDesiredSize.width = NSIntPixelsToTwips(200, p2t);
|
|
|
|
}
|
1998-11-01 01:29:00 +00:00
|
|
|
if (aReflowState.HaveFixedContentHeight()) {
|
1998-12-30 17:50:00 +00:00
|
|
|
aDesiredSize.height = aReflowState.computedHeight;
|
1998-10-12 17:00:32 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
aDesiredSize.height = NSIntPixelsToTwips(200, p2t);
|
1998-07-21 23:20:04 +00:00
|
|
|
}
|
1998-07-15 23:42:14 +00:00
|
|
|
aDesiredSize.ascent = aDesiredSize.height;
|
|
|
|
aDesiredSize.descent = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsHTMLFrameOuterFrame::IsInline()
|
|
|
|
{
|
1998-09-09 23:30:30 +00:00
|
|
|
if (nsnull == mIsInline) {
|
|
|
|
nsIDOMHTMLFrameElement* frame = nsnull;
|
|
|
|
mContent->QueryInterface(kIDOMHTMLIFrameElementIID, (void**) &frame);
|
|
|
|
if (nsnull != frame) {
|
|
|
|
mIsInline = new PRBool(PR_TRUE);
|
|
|
|
NS_RELEASE(frame);
|
|
|
|
} else {
|
|
|
|
mIsInline = new PRBool(PR_FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return *mIsInline;
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLFrameOuterFrame::Paint(nsIPresContext& aPresContext,
|
1998-12-18 15:54:23 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer)
|
1998-07-15 23:42:14 +00:00
|
|
|
{
|
1998-09-03 01:16:27 +00:00
|
|
|
//printf("outer paint %X (%d,%d,%d,%d) \n", this, aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
|
1998-07-15 23:42:14 +00:00
|
|
|
if (nsnull != mFirstChild) {
|
1998-12-18 15:54:23 +00:00
|
|
|
mFirstChild->Paint(aPresContext, aRenderingContext, aDirtyRect,
|
|
|
|
aWhichLayer);
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
1998-07-27 05:59:37 +00:00
|
|
|
if (IsInline()) {
|
1998-12-18 15:54:23 +00:00
|
|
|
return nsHTMLContainerFrame::Paint(aPresContext, aRenderingContext,
|
|
|
|
aDirtyRect, aWhichLayer);
|
1998-07-27 05:59:37 +00:00
|
|
|
} else {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHODIMP nsHTMLFrameOuterFrame::GetFrameName(nsString& aResult) const
|
1998-07-27 05:59:37 +00:00
|
|
|
{
|
1998-11-19 17:22:29 +00:00
|
|
|
return MakeFrameName("FrameOuter", aResult);
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-10-02 04:10:00 +00:00
|
|
|
nsHTMLFrameOuterFrame::Reflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-07-15 23:42:14 +00:00
|
|
|
{
|
1999-01-05 23:31:18 +00:00
|
|
|
//printf("OuterFrame::Reflow %X (%d,%d) \n", this, aReflowState.availableWidth, aReflowState.availableHeight);
|
1998-07-27 18:05:11 +00:00
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("enter nsHTMLFrameOuterFrame::Reflow: maxSize=%d,%d reason=%d",
|
1999-01-05 23:31:18 +00:00
|
|
|
aReflowState.availableWidth, aReflowState.availableHeight, aReflowState.reason));
|
1998-07-27 18:05:11 +00:00
|
|
|
|
1998-07-21 23:20:04 +00:00
|
|
|
if (IsInline()) {
|
|
|
|
GetDesiredSize(&aPresContext, aReflowState, aDesiredSize);
|
|
|
|
} else {
|
1999-01-05 23:31:18 +00:00
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
|
|
|
aDesiredSize.height = aReflowState.availableHeight;
|
1998-07-21 23:20:04 +00:00
|
|
|
}
|
1998-07-15 23:42:14 +00:00
|
|
|
|
|
|
|
if (nsnull == mFirstChild) {
|
1998-12-03 06:31:43 +00:00
|
|
|
mFirstChild = new nsHTMLFrameInnerFrame;
|
1998-07-18 21:47:56 +00:00
|
|
|
// XXX temporary! use style system to get correct style!
|
1998-12-29 03:38:16 +00:00
|
|
|
mFirstChild->Init(aPresContext, mContent, this, this, mStyleContext);
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
1998-07-27 05:59:37 +00:00
|
|
|
|
|
|
|
// nsContainerFrame::PaintBorder has some problems, kludge it here
|
1998-07-15 23:42:14 +00:00
|
|
|
nscoord borderWidth = GetBorderWidth(aPresContext);
|
1998-07-27 05:59:37 +00:00
|
|
|
nscoord kludge = borderWidth/2;
|
|
|
|
nsSize innerSize(aDesiredSize.width - borderWidth - kludge, aDesiredSize.height - borderWidth - kludge);
|
1998-07-15 23:42:14 +00:00
|
|
|
|
|
|
|
// Reflow the child and get its desired size
|
1998-10-01 04:46:11 +00:00
|
|
|
nsHTMLReflowMetrics kidMetrics(aDesiredSize.maxElementSize);
|
1998-10-12 14:48:02 +00:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState,
|
|
|
|
innerSize);
|
1998-10-01 04:46:11 +00:00
|
|
|
nsIHTMLReflow* htmlReflow;
|
|
|
|
|
|
|
|
if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
1998-10-06 00:27:22 +00:00
|
|
|
ReflowChild(mFirstChild, aPresContext, kidMetrics, kidReflowState, aStatus);
|
1998-10-01 04:46:11 +00:00
|
|
|
NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status");
|
1998-07-15 23:42:14 +00:00
|
|
|
|
1998-10-01 04:46:11 +00:00
|
|
|
// Place and size the child
|
|
|
|
nsRect rect(borderWidth, borderWidth, innerSize.width, innerSize.height);
|
|
|
|
mFirstChild->SetRect(rect);
|
|
|
|
}
|
1998-07-15 23:42:14 +00: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;
|
|
|
|
}
|
|
|
|
|
1998-07-27 18:05:11 +00:00
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("exit nsHTMLFrameOuterFrame::Reflow: size=%d,%d status=%x",
|
|
|
|
aDesiredSize.width, aDesiredSize.height, aStatus));
|
|
|
|
|
1998-07-15 23:42:14 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-08-03 18:12:13 +00:00
|
|
|
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-02 21:59:59 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLFrameOuterFrame::AttributeChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aChild,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
PRInt32 aHint)
|
|
|
|
{
|
|
|
|
if (nsHTMLAtoms::src == aAttribute) {
|
|
|
|
printf("got a request\n");
|
|
|
|
if (nsnull != mFirstChild) {
|
|
|
|
((nsHTMLFrameInnerFrame*)mFirstChild)->ReloadURL();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-09 23:30:30 +00:00
|
|
|
nsresult
|
1998-12-03 06:31:43 +00:00
|
|
|
NS_NewHTMLFrameOuterFrame(nsIFrame*& aResult)
|
1998-09-09 23:30:30 +00:00
|
|
|
{
|
1998-12-03 06:31:43 +00:00
|
|
|
nsIFrame* frame = new nsHTMLFrameOuterFrame;
|
1998-09-09 23:30:30 +00:00
|
|
|
if (nsnull == frame) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
aResult = frame;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-15 23:42:14 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFrameInnerFrame
|
|
|
|
******************************************************************************/
|
1998-12-03 06:31:43 +00:00
|
|
|
nsHTMLFrameInnerFrame::nsHTMLFrameInnerFrame()
|
|
|
|
: nsLeafFrame()
|
1998-07-15 23:42:14 +00:00
|
|
|
{
|
1998-07-18 21:47:56 +00:00
|
|
|
mWebShell = nsnull;
|
1998-07-15 23:42:14 +00:00
|
|
|
mCreatingViewer = PR_FALSE;
|
|
|
|
mTempObserver = new TempObserver();
|
|
|
|
NS_ADDREF(mTempObserver);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsHTMLFrameInnerFrame::~nsHTMLFrameInnerFrame()
|
|
|
|
{
|
1998-11-26 18:13:13 +00:00
|
|
|
//printf("nsHTMLFrameInnerFrame destructor %X \n", this);
|
1998-08-20 06:16:32 +00:00
|
|
|
if (nsnull != mWebShell) {
|
1998-11-26 18:13:13 +00:00
|
|
|
mWebShell->Destroy();
|
1998-08-20 06:16:32 +00:00
|
|
|
NS_RELEASE(mWebShell);
|
|
|
|
}
|
1998-07-15 23:42:14 +00:00
|
|
|
NS_RELEASE(mTempObserver);
|
|
|
|
}
|
|
|
|
|
1998-09-09 23:30:30 +00:00
|
|
|
PRBool nsHTMLFrameInnerFrame::GetURL(nsIContent* aContent, nsString& aResult)
|
1998-07-15 23:42:14 +00:00
|
|
|
{
|
1998-09-09 23:30:30 +00:00
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
nsIHTMLContent* content = nsnull;
|
|
|
|
aContent->QueryInterface(kIHTMLContentIID, (void**) &content);
|
|
|
|
if (nsnull != content) {
|
|
|
|
nsHTMLValue value;
|
1998-12-20 01:21:23 +00:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::src, value))) {
|
1998-09-09 23:30:30 +00:00
|
|
|
if (eHTMLUnit_String == value.GetUnit()) {
|
|
|
|
value.GetStringValue(aResult);
|
1998-11-23 17:37:46 +00:00
|
|
|
if (aResult.Length() > 0) {
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
|
|
|
}
|
1998-09-09 23:30:30 +00:00
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
if (PR_FALSE == result) {
|
|
|
|
aResult.SetLength(0);
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
1998-09-09 23:30:30 +00:00
|
|
|
return result;
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
|
|
|
|
1998-09-09 23:30:30 +00:00
|
|
|
PRBool nsHTMLFrameInnerFrame::GetName(nsIContent* aContent, nsString& aResult)
|
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
nsIHTMLContent* content = nsnull;
|
|
|
|
aContent->QueryInterface(kIHTMLContentIID, (void**) &content);
|
|
|
|
if (nsnull != content) {
|
|
|
|
nsHTMLValue value;
|
1998-12-20 01:21:23 +00:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::name, value))) {
|
1998-09-09 23:30:30 +00:00
|
|
|
if (eHTMLUnit_String == value.GetUnit()) {
|
|
|
|
value.GetStringValue(aResult);
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
if (PR_FALSE == result) {
|
|
|
|
aResult.SetLength(0);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-11-09 23:30:16 +00:00
|
|
|
PRInt32 nsHTMLFrameInnerFrame::GetScrolling(nsIContent* aContent, PRBool aStandardMode)
|
1998-09-09 23:30:30 +00:00
|
|
|
{
|
|
|
|
nsIHTMLContent* content = nsnull;
|
|
|
|
aContent->QueryInterface(kIHTMLContentIID, (void**) &content);
|
|
|
|
if (nsnull != content) {
|
|
|
|
nsHTMLValue value;
|
1998-12-20 01:21:23 +00:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::scrolling, value))) {
|
1998-09-09 23:30:30 +00:00
|
|
|
if (eHTMLUnit_Enumerated == value.GetUnit()) {
|
1998-11-09 23:30:16 +00:00
|
|
|
PRInt32 returnValue;
|
1998-09-09 23:30:30 +00: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-09 23:30:16 +00:00
|
|
|
} else if ((NS_STYLE_FRAME_OFF == intValue) || (NS_STYLE_FRAME_NOSCROLL == intValue)) {
|
1998-09-09 23:30:30 +00:00
|
|
|
intValue = NS_STYLE_FRAME_NO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (NS_STYLE_FRAME_YES == intValue) {
|
1998-11-09 23:30:16 +00: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-09 23:30:30 +00:00
|
|
|
}
|
1998-11-09 23:30:16 +00:00
|
|
|
NS_RELEASE(content);
|
|
|
|
return returnValue;
|
1998-09-09 23:30:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
1998-11-09 23:30:16 +00:00
|
|
|
return -1;
|
1998-09-09 23:30:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsFrameborder nsHTMLFrameInnerFrame::GetFrameBorder(PRBool aStandardMode)
|
|
|
|
{
|
|
|
|
nsIHTMLContent* content = nsnull;
|
|
|
|
mContent->QueryInterface(kIHTMLContentIID, (void**) &content);
|
|
|
|
if (nsnull != content) {
|
|
|
|
nsHTMLValue value;
|
1998-12-20 01:21:23 +00:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::frameborder, value))) {
|
1998-09-09 23:30:30 +00: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 17:30:41 +00:00
|
|
|
if (NS_SUCCEEDED(mContent->QueryInterface(kIHTMLContentIID, (void**) &content))) {
|
1998-11-14 01:52:27 +00:00
|
|
|
float p2t;
|
|
|
|
aPresContext->GetScaledPixelsToTwips(p2t);
|
1998-09-09 23:30:30 +00:00
|
|
|
nsHTMLValue value;
|
1998-12-20 01:21:23 +00:00
|
|
|
content->GetHTMLAttribute(nsHTMLAtoms::marginwidth, value);
|
1998-09-09 23:30:30 +00: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 17:30:41 +00:00
|
|
|
if (NS_SUCCEEDED(mContent->QueryInterface(kIHTMLContentIID, (void**) &content))) {
|
1998-11-14 01:52:27 +00:00
|
|
|
float p2t;
|
|
|
|
aPresContext->GetScaledPixelsToTwips(p2t);
|
1998-09-09 23:30:30 +00:00
|
|
|
nsHTMLValue value;
|
1998-12-20 01:21:23 +00:00
|
|
|
content->GetHTMLAttribute(nsHTMLAtoms::marginheight, value);
|
1998-09-09 23:30:30 +00:00
|
|
|
if (eHTMLUnit_Pixel == value.GetUnit()) {
|
|
|
|
marginHeight = NSIntPixelsToTwips(value.GetPixelValue(), p2t);
|
|
|
|
if (marginHeight < 0) {
|
|
|
|
marginHeight = 0;
|
|
|
|
}
|
|
|
|
}
|
1998-11-21 17:30:41 +00:00
|
|
|
NS_RELEASE(content);
|
1998-09-09 23:30:30 +00:00
|
|
|
}
|
|
|
|
return marginHeight;
|
|
|
|
}
|
1998-07-15 23:42:14 +00:00
|
|
|
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHODIMP nsHTMLFrameInnerFrame::GetFrameName(nsString& aResult) const
|
1998-07-27 05:59:37 +00:00
|
|
|
{
|
1998-11-19 17:22:29 +00:00
|
|
|
return MakeFrameName("FrameInner", aResult);
|
1998-07-27 05:59:37 +00:00
|
|
|
}
|
|
|
|
|
1998-07-15 23:42:14 +00:00
|
|
|
NS_METHOD
|
|
|
|
nsHTMLFrameInnerFrame::MoveTo(nscoord aX, nscoord aY)
|
|
|
|
{
|
|
|
|
return nsLeafFrame::MoveTo(aX, aY);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD
|
|
|
|
nsHTMLFrameInnerFrame::SizeTo(nscoord aWidth, nscoord aHeight)
|
|
|
|
{
|
1998-07-27 05:59:37 +00:00
|
|
|
return nsLeafFrame::SizeTo(aWidth, aHeight);
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLFrameInnerFrame::Paint(nsIPresContext& aPresContext,
|
1998-12-18 15:54:23 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer)
|
1998-07-15 23:42:14 +00:00
|
|
|
{
|
1998-09-03 01:16:27 +00:00
|
|
|
//printf("inner paint %X (%d,%d,%d,%d) \n", this, aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
|
1998-07-15 23:42:14 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-09-09 23:30:30 +00:00
|
|
|
nsHTMLFrameInnerFrame::GetParentContent(nsIContent*& aContent)
|
1998-07-15 23:42:14 +00:00
|
|
|
{
|
|
|
|
nsHTMLFrameOuterFrame* parent;
|
|
|
|
GetGeometricParent((nsIFrame*&)parent);
|
|
|
|
return parent->GetContent((nsIContent*&)aContent);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-01-06 18:43:39 +00:00
|
|
|
PRIVATE
|
1998-07-15 23:42:14 +00:00
|
|
|
void TempMakeAbsURL(nsIContent* aContent, nsString& aRelURL, nsString& aAbsURL)
|
|
|
|
{
|
|
|
|
nsIURL* docURL = nsnull;
|
|
|
|
nsIDocument* doc = nsnull;
|
|
|
|
aContent->GetDocument(doc);
|
|
|
|
if (nsnull != doc) {
|
|
|
|
docURL = doc->GetDocumentURL();
|
|
|
|
NS_RELEASE(doc);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString base;
|
1998-12-20 01:21:23 +00:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE != aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, base)) {
|
|
|
|
base.Truncate();
|
1998-11-24 02:01:45 +00:00
|
|
|
}
|
1998-07-15 23:42:14 +00:00
|
|
|
nsresult rv = NS_MakeAbsoluteURL(docURL, base, aRelURL, aAbsURL);
|
|
|
|
NS_IF_RELEASE(docURL);
|
|
|
|
}
|
|
|
|
|
1998-07-17 06:30:00 +00:00
|
|
|
|
1998-07-18 21:47:56 +00:00
|
|
|
nsresult
|
|
|
|
nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext& aPresContext,
|
|
|
|
const nsSize& aSize)
|
1998-07-15 23:42:14 +00:00
|
|
|
{
|
|
|
|
nsresult rv;
|
1998-09-09 23:30:30 +00:00
|
|
|
nsIContent* content;
|
1998-07-15 23:42:14 +00:00
|
|
|
GetParentContent(content);
|
|
|
|
|
1998-09-01 00:26:28 +00:00
|
|
|
rv = nsRepository::CreateInstance(kWebShellCID, nsnull, kIWebShellIID,
|
1998-07-18 21:47:56 +00:00
|
|
|
(void**)&mWebShell);
|
1998-07-15 23:42:14 +00:00
|
|
|
if (NS_OK != rv) {
|
|
|
|
NS_ASSERTION(0, "could not create web widget");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-11-09 23:30:16 +00:00
|
|
|
// pass along marginwidth, marginheight, scrolling so sub document can use it
|
1998-09-09 23:30:30 +00:00
|
|
|
mWebShell->SetMarginWidth(GetMarginWidth(&aPresContext, content));
|
|
|
|
mWebShell->SetMarginHeight(GetMarginHeight(&aPresContext, content));
|
1998-11-09 23:30:16 +00:00
|
|
|
nsCompatibility mode;
|
|
|
|
aPresContext.GetCompatibilityMode(mode);
|
|
|
|
mWebShell->SetScrolling(GetScrolling(content, mode));
|
1998-08-10 01:01:27 +00:00
|
|
|
|
1998-07-15 23:42:14 +00:00
|
|
|
nsString frameName;
|
1998-09-09 23:30:30 +00:00
|
|
|
if (GetName(content, frameName)) {
|
1998-07-18 21:47:56 +00:00
|
|
|
mWebShell->SetName(frameName);
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
|
|
|
|
1998-07-18 21:47:56 +00: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;
|
|
|
|
aPresContext.GetContainer(&container);
|
|
|
|
if (nsnull != container) {
|
|
|
|
nsIWebShell* outerShell = nsnull;
|
|
|
|
container->QueryInterface(kIWebShellIID, (void**) &outerShell);
|
|
|
|
if (nsnull != outerShell) {
|
|
|
|
outerShell->AddChild(mWebShell);
|
1998-08-20 06:16:32 +00:00
|
|
|
|
|
|
|
// connect the container...
|
|
|
|
nsIWebShellContainer* outerContainer = nsnull;
|
|
|
|
container->QueryInterface(kIWebShellContainerIID, (void**) &outerContainer);
|
|
|
|
if (nsnull != outerContainer) {
|
|
|
|
mWebShell->SetContainer(outerContainer);
|
|
|
|
NS_RELEASE(outerContainer);
|
|
|
|
}
|
|
|
|
|
1998-07-31 05:58:41 +00:00
|
|
|
nsIPref* outerPrefs = nsnull; // connect the prefs
|
|
|
|
outerShell->GetPrefs(outerPrefs);
|
|
|
|
if (nsnull != outerPrefs) {
|
|
|
|
mWebShell->SetPrefs(outerPrefs);
|
|
|
|
NS_RELEASE(outerPrefs);
|
|
|
|
}
|
1998-07-18 21:47:56 +00:00
|
|
|
NS_RELEASE(outerShell);
|
|
|
|
}
|
|
|
|
NS_RELEASE(container);
|
|
|
|
}
|
1998-07-15 23:42:14 +00:00
|
|
|
|
1998-07-18 21:47:56 +00:00
|
|
|
float t2p = aPresContext.GetTwipsToPixels();
|
|
|
|
nsIPresShell *presShell = aPresContext.GetShell();
|
1998-07-15 23:42:14 +00:00
|
|
|
|
|
|
|
// create, init, set the parent of the view
|
|
|
|
nsIView* view;
|
1998-09-01 00:26:28 +00:00
|
|
|
rv = nsRepository::CreateInstance(kCViewCID, nsnull, kIViewIID,
|
1998-07-15 23:42:14 +00:00
|
|
|
(void **)&view);
|
|
|
|
if (NS_OK != rv) {
|
1998-07-30 17:39:41 +00:00
|
|
|
NS_ASSERTION(0, "Could not create view for nsHTMLFrame");
|
1998-07-15 23:42:14 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIView* parView;
|
|
|
|
nsPoint origin;
|
|
|
|
GetOffsetFromView(origin, parView);
|
|
|
|
nsRect viewBounds(origin.x, origin.y, aSize.width, aSize.height);
|
|
|
|
|
1998-07-30 17:39:41 +00:00
|
|
|
nsIViewManager* viewMan = presShell->GetViewManager();
|
1998-07-30 21:25:35 +00:00
|
|
|
NS_RELEASE(presShell);
|
1998-11-04 04:14:10 +00:00
|
|
|
rv = view->Init(viewMan, viewBounds, parView);
|
1998-07-15 23:42:14 +00:00
|
|
|
viewMan->InsertChild(parView, view, 0);
|
1998-11-04 04:14:10 +00:00
|
|
|
rv = view->CreateWidget(kCChildCID);
|
1998-07-15 23:42:14 +00:00
|
|
|
NS_RELEASE(viewMan);
|
|
|
|
SetView(view);
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
nsIWidget* widget;
|
|
|
|
view->GetWidget(widget);
|
1998-07-31 23:34:45 +00:00
|
|
|
nsRect webBounds(0, 0, NSToCoordRound(aSize.width * t2p),
|
|
|
|
NSToCoordRound(aSize.height * t2p));
|
1998-07-18 21:47:56 +00:00
|
|
|
|
1998-08-14 23:08:54 +00:00
|
|
|
mWebShell->Init(widget->GetNativeData(NS_NATIVE_WIDGET),
|
|
|
|
webBounds.x, webBounds.y,
|
1998-11-09 23:30:16 +00:00
|
|
|
webBounds.width, webBounds.height);
|
|
|
|
//GetScrolling(content, PR_FALSE));
|
1998-07-15 23:42:14 +00:00
|
|
|
NS_RELEASE(content);
|
|
|
|
NS_RELEASE(widget);
|
|
|
|
|
1998-07-22 11:19:54 +00:00
|
|
|
mWebShell->SetObserver(mTempObserver);
|
1998-07-18 21:47:56 +00:00
|
|
|
mWebShell->Show();
|
1998-07-15 23:42:14 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-10-02 04:10:00 +00:00
|
|
|
nsHTMLFrameInnerFrame::Reflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-07-15 23:42:14 +00:00
|
|
|
{
|
1998-07-27 18:05:11 +00:00
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("enter nsHTMLFrameInnerFrame::Reflow: maxSize=%d,%d reason=%d",
|
1999-01-05 23:31:18 +00:00
|
|
|
aReflowState.availableWidth,
|
|
|
|
aReflowState.availableHeight,
|
1998-07-27 18:05:11 +00:00
|
|
|
aReflowState.reason));
|
|
|
|
|
1998-07-15 23:42:14 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
// use the max size set in aReflowState by the nsHTMLFrameOuterFrame as our size
|
1998-07-17 06:30:00 +00:00
|
|
|
if (!mCreatingViewer) {
|
1998-09-09 23:30:30 +00:00
|
|
|
nsIContent* content;
|
1998-07-15 23:42:14 +00:00
|
|
|
GetParentContent(content);
|
|
|
|
|
|
|
|
nsAutoString url;
|
1998-11-23 17:37:46 +00:00
|
|
|
PRBool hasURL = GetURL(content, url);
|
1998-07-15 23:42:14 +00:00
|
|
|
nsSize size;
|
|
|
|
|
1998-11-23 17:37:46 +00:00
|
|
|
// if the size is not 0 and there is a src, create the web shell
|
1999-01-05 23:31:18 +00:00
|
|
|
if ((aReflowState.availableWidth >= 0) && (aReflowState.availableHeight >= 0) && hasURL) {
|
1998-11-23 17:37:46 +00:00
|
|
|
if (nsnull == mWebShell) {
|
1999-01-05 23:31:18 +00:00
|
|
|
nsSize maxSize(aReflowState.availableWidth, aReflowState.availableHeight);
|
|
|
|
rv = CreateWebShell(aPresContext, maxSize);
|
1998-11-23 17:37:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nsnull != mWebShell) {
|
|
|
|
mCreatingViewer=PR_TRUE;
|
1998-07-15 23:42:14 +00:00
|
|
|
|
1998-11-23 17:37:46 +00:00
|
|
|
// load the document
|
|
|
|
nsString absURL;
|
|
|
|
TempMakeAbsURL(content, url, absURL);
|
1998-07-15 23:42:14 +00:00
|
|
|
|
1998-11-23 17:37:46 +00:00
|
|
|
rv = mWebShell->LoadURL(absURL); // URL string with a default nsnull value for post Data
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mCreatingViewer = PR_TRUE;
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
|
1999-01-05 23:31:18 +00:00
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
|
|
|
aDesiredSize.height = aReflowState.availableHeight;
|
1998-07-15 23:42:14 +00:00
|
|
|
aDesiredSize.ascent = aDesiredSize.height;
|
|
|
|
aDesiredSize.descent = 0;
|
|
|
|
|
1998-07-27 05:59:37 +00:00
|
|
|
// resize the sub document
|
1998-11-23 17:37:46 +00:00
|
|
|
if (mWebShell) {
|
|
|
|
float t2p = aPresContext.GetTwipsToPixels();
|
|
|
|
nsRect subBounds;
|
1998-08-05 22:24:56 +00:00
|
|
|
|
1998-11-23 17:37:46 +00:00
|
|
|
mWebShell->GetBounds(subBounds.x, subBounds.y,
|
1998-08-14 23:08:54 +00:00
|
|
|
subBounds.width, subBounds.height);
|
1998-11-23 17:37:46 +00:00
|
|
|
subBounds.width = NSToCoordRound(aDesiredSize.width * t2p);
|
|
|
|
subBounds.height = NSToCoordRound(aDesiredSize.height * t2p);
|
|
|
|
mWebShell->SetBounds(subBounds.x, subBounds.y,
|
1998-08-14 23:08:54 +00:00
|
|
|
subBounds.width, subBounds.height);
|
1998-11-23 17:37:46 +00:00
|
|
|
mWebShell->Repaint(PR_TRUE);
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-07-27 18:05:11 +00:00
|
|
|
|
1998-11-23 17:37:46 +00:00
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("exit nsHTMLFrameInnerFrame::Reflow: size=%d,%d rv=%x",
|
1998-07-27 18:05:11 +00:00
|
|
|
aDesiredSize.width, aDesiredSize.height, aStatus));
|
1998-11-23 17:37:46 +00:00
|
|
|
}
|
|
|
|
|
1998-07-15 23:42:14 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-10-02 21:59:59 +00:00
|
|
|
nsresult
|
|
|
|
nsHTMLFrameInnerFrame::ReloadURL()
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsIContent* content;
|
|
|
|
GetParentContent(content);
|
|
|
|
if (nsnull != content) {
|
|
|
|
|
|
|
|
nsAutoString url;
|
|
|
|
GetURL(content, url);
|
|
|
|
|
1998-11-23 17:37:46 +00:00
|
|
|
// load a new url if the size is not 0
|
|
|
|
if ((mRect.width > 0) && (mRect.height > 0)) {
|
|
|
|
if (nsnull != mWebShell) {
|
|
|
|
mCreatingViewer=PR_TRUE;
|
1998-10-02 21:59:59 +00:00
|
|
|
|
1998-11-23 17:37:46 +00:00
|
|
|
// load the document
|
|
|
|
nsString absURL;
|
|
|
|
TempMakeAbsURL(content, url, absURL);
|
1998-10-02 21:59:59 +00:00
|
|
|
|
1998-11-23 17:37:46 +00:00
|
|
|
rv = mWebShell->LoadURL(absURL); // URL string with a default nsnull value for post Data
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mCreatingViewer = PR_TRUE;
|
1998-10-02 21:59:59 +00:00
|
|
|
}
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-07-15 23:42:14 +00:00
|
|
|
void
|
|
|
|
nsHTMLFrameInnerFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
1998-10-02 04:10:00 +00:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-10-01 04:46:11 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
1998-07-15 23:42:14 +00: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);
|
|
|
|
|
|
|
|
// XXX temp implementation
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF(TempObserver);
|
|
|
|
NS_IMPL_RELEASE(TempObserver);
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* TempObserver
|
|
|
|
******************************************************************************/
|
|
|
|
nsresult
|
|
|
|
TempObserver::QueryInterface(const nsIID& aIID,
|
|
|
|
void** aInstancePtrResult)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
|
|
|
|
if (nsnull == aInstancePtrResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
if (aIID.Equals(kIStreamObserverIID)) {
|
|
|
|
*aInstancePtrResult = (void*) ((nsIStreamObserver*)this);
|
|
|
|
AddRef();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
if (aIID.Equals(kISupportsIID)) {
|
|
|
|
*aInstancePtrResult = (void*) ((nsISupports*)((nsIDocumentObserver*)this));
|
|
|
|
AddRef();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-12-16 05:40:20 +00:00
|
|
|
TempObserver::OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax)
|
1998-07-15 23:42:14 +00:00
|
|
|
{
|
1998-07-21 23:20:04 +00:00
|
|
|
#if 0
|
1998-07-15 23:42:14 +00:00
|
|
|
fputs("[progress ", stdout);
|
|
|
|
fputs(mURL, stdout);
|
|
|
|
printf(" %d %d ", aProgress, aProgressMax);
|
1998-07-24 10:02:50 +00:00
|
|
|
fputs("]\n", stdout);
|
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-12-16 05:40:20 +00:00
|
|
|
TempObserver::OnStatus(nsIURL* aURL, const PRUnichar* aMsg)
|
1998-07-24 10:02:50 +00:00
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
fputs("[status ", stdout);
|
|
|
|
fputs(mURL, stdout);
|
1998-07-15 23:42:14 +00:00
|
|
|
fputs(aMsg, stdout);
|
|
|
|
fputs("]\n", stdout);
|
1998-07-21 23:20:04 +00:00
|
|
|
#endif
|
1998-07-15 23:42:14 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TempObserver::OnStartBinding(nsIURL* aURL, const char *aContentType)
|
|
|
|
{
|
1998-07-21 23:20:04 +00:00
|
|
|
#if 0
|
1998-07-15 23:42:14 +00:00
|
|
|
fputs("Loading ", stdout);
|
|
|
|
fputs(mURL, stdout);
|
|
|
|
fputs("\n", stdout);
|
1998-07-21 23:20:04 +00:00
|
|
|
#endif
|
1998-07-15 23:42:14 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-12-16 05:40:20 +00:00
|
|
|
TempObserver::OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg)
|
1998-07-15 23:42:14 +00:00
|
|
|
{
|
1998-07-21 23:20:04 +00:00
|
|
|
#if 0
|
1998-07-15 23:42:14 +00:00
|
|
|
fputs("Done loading ", stdout);
|
|
|
|
fputs(mURL, stdout);
|
|
|
|
fputs("\n", stdout);
|
1998-07-21 23:20:04 +00:00
|
|
|
#endif
|
1998-07-15 23:42:14 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|