diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 933bff373ef..5de1fbabe8f 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -1053,11 +1053,23 @@ HTMLContentSink::StartLayout() } } - // If the document we are loading has a reference, disable the - // scroll bars on the views. + // If the document we are loading has a reference or it is a top level + // frameset document, disable the scroll bars on the views. const char* ref = mDocumentURL->GetRef(); if (nsnull != ref) { mRef = new nsString(ref); + } + PRBool topLevelFrameset = PR_FALSE; + if (mFrameset && mWebShell) { + nsIWebShell* rootWebShell; + mWebShell->GetRootWebShell(rootWebShell); + if (mWebShell == rootWebShell) { + topLevelFrameset = PR_TRUE; + } + NS_IF_RELEASE(rootWebShell); + } + + if ((nsnull != ref) || topLevelFrameset) { // XXX support more than one presentation-shell here // Get initial scroll preference and save it away; disable the @@ -1073,7 +1085,9 @@ HTMLContentSink::StartLayout() nsIScrollableView* sview = nsnull; rootView->QueryInterface(kIScrollableViewIID, (void**) &sview); if (nsnull != sview) { - mOriginalScrollPreference = sview->GetScrollPreference(); + mOriginalScrollPreference = (topLevelFrameset) + ? nsScrollPreference_kNeverScroll + : sview->GetScrollPreference(); sview->SetScrollPreference(nsScrollPreference_kNeverScroll); NS_RELEASE(sview); } @@ -2109,7 +2123,7 @@ HTMLContentSink::ProcessFRAMESETTag(nsIHTMLContent** aInstancePtrResult, nsAutoString tmp("FRAMESET"); nsIAtom* atom = NS_NewAtom(tmp); - nsresult rv = NS_NewHTMLIFrame(aInstancePtrResult, atom, mWebShell); + nsresult rv = NS_NewHTMLFrameset(aInstancePtrResult, atom, mWebShell); NS_RELEASE(atom); return rv; diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index f283da3868f..9ec49fa5da8 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -175,6 +175,8 @@ protected: nsString mOverURL; nsString mOverTarget; + nsScrollPreference mScrollPref; + void ReleaseChildren(); }; @@ -208,7 +210,7 @@ nsWebShell::nsWebShell() { NS_INIT_REFCNT(); mHistoryIndex = -1; - + mScrollPref = nsScrollPreference_kAuto; mScriptGlobal = nsnull; mScriptContext = nsnull; } @@ -327,7 +329,8 @@ nsWebShell::Embed(nsIContentViewer* aContentViewer, bounds.x = bounds.y = 0; rv = mContentViewer->Init(mWindow->GetNativeData(NS_NATIVE_WIDGET), mDeviceContext, - bounds); + bounds, + mScrollPref); if (NS_OK == rv) { mContentViewer->Show(); } @@ -343,6 +346,8 @@ nsWebShell::Init(nsNativeWidget aNativeParent, const nsRect& aBounds, nsScrollPreference aScrolling) { + mScrollPref = aScrolling; + WEB_TRACE(WEB_TRACE_CALLS, ("nsWebShell::Init: this=%p", this)); diff --git a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp index 933bff373ef..5de1fbabe8f 100644 --- a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp @@ -1053,11 +1053,23 @@ HTMLContentSink::StartLayout() } } - // If the document we are loading has a reference, disable the - // scroll bars on the views. + // If the document we are loading has a reference or it is a top level + // frameset document, disable the scroll bars on the views. const char* ref = mDocumentURL->GetRef(); if (nsnull != ref) { mRef = new nsString(ref); + } + PRBool topLevelFrameset = PR_FALSE; + if (mFrameset && mWebShell) { + nsIWebShell* rootWebShell; + mWebShell->GetRootWebShell(rootWebShell); + if (mWebShell == rootWebShell) { + topLevelFrameset = PR_TRUE; + } + NS_IF_RELEASE(rootWebShell); + } + + if ((nsnull != ref) || topLevelFrameset) { // XXX support more than one presentation-shell here // Get initial scroll preference and save it away; disable the @@ -1073,7 +1085,9 @@ HTMLContentSink::StartLayout() nsIScrollableView* sview = nsnull; rootView->QueryInterface(kIScrollableViewIID, (void**) &sview); if (nsnull != sview) { - mOriginalScrollPreference = sview->GetScrollPreference(); + mOriginalScrollPreference = (topLevelFrameset) + ? nsScrollPreference_kNeverScroll + : sview->GetScrollPreference(); sview->SetScrollPreference(nsScrollPreference_kNeverScroll); NS_RELEASE(sview); } @@ -2109,7 +2123,7 @@ HTMLContentSink::ProcessFRAMESETTag(nsIHTMLContent** aInstancePtrResult, nsAutoString tmp("FRAMESET"); nsIAtom* atom = NS_NewAtom(tmp); - nsresult rv = NS_NewHTMLIFrame(aInstancePtrResult, atom, mWebShell); + nsresult rv = NS_NewHTMLFrameset(aInstancePtrResult, atom, mWebShell); NS_RELEASE(atom); return rv; diff --git a/mozilla/layout/html/document/src/nsHTMLFrame.cpp b/mozilla/layout/html/document/src/nsHTMLFrame.cpp index 21af1188285..e420d3d92e8 100644 --- a/mozilla/layout/html/document/src/nsHTMLFrame.cpp +++ b/mozilla/layout/html/document/src/nsHTMLFrame.cpp @@ -102,6 +102,8 @@ class nsHTMLFrameOuterFrame : public nsHTMLContainerFrame { public: nsHTMLFrameOuterFrame(nsIContent* aContent, nsIFrame* aParent); + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; + NS_IMETHOD Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); @@ -129,6 +131,8 @@ public: nsHTMLFrameInnerFrame(nsIContent* aContent, nsIFrame* aParentFrame); + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; + NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); /** @@ -184,6 +188,7 @@ public: PRBool GetURL(nsString& aURLSpec); PRBool GetName(nsString& aName); + virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; nsScrollPreference GetScrolling(); virtual void MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext); @@ -219,17 +224,16 @@ nsHTMLFrameOuterFrame::nsHTMLFrameOuterFrame(nsIContent* aContent, nsIFrame* aPa nscoord nsHTMLFrameOuterFrame::GetBorderWidth(nsIPresContext& aPresContext) { - if (nsnull == mStyleContext) {// make sure the style context is set - GetStyleContext(&aPresContext, mStyleContext); - } - 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(); - } + if (IsInline()) { + const nsStyleSpacing* spacing = + (const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing); + nsStyleCoord leftBorder; + spacing->mBorder.GetLeft(leftBorder); + nsStyleUnit unit = leftBorder.GetUnit(); + if (eStyleUnit_Coord == unit) { + return leftBorder.GetCoordValue(); + } + } return 0; } @@ -274,11 +278,22 @@ nsHTMLFrameOuterFrame::Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect) { -//printf("outer paint %d (%d,%d,%d,%d) ", this, aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height); + //printf("outer paint %d (%d,%d,%d,%d) ", this, aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height); if (nsnull != mFirstChild) { mFirstChild->Paint(aPresContext, aRenderingContext, aDirtyRect); } - return nsHTMLContainerFrame::Paint(aPresContext, aRenderingContext, aDirtyRect); + if (IsInline()) { + return nsHTMLContainerFrame::Paint(aPresContext, aRenderingContext, aDirtyRect); + } else { + return NS_OK; + } +} + +NS_IMETHODIMP nsHTMLFrameOuterFrame::List(FILE* out, PRInt32 aIndent) const +{ + for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out); // Indent + fprintf(out, "%X OUTER \n", this); + return nsHTMLContainerFrame::List(out, aIndent); } NS_IMETHODIMP @@ -300,17 +315,17 @@ nsHTMLFrameOuterFrame::Reflow(nsIPresContext& aPresContext, mFirstChild->SetStyleContext(&aPresContext, mStyleContext); mChildCount = 1; } - + + // nsContainerFrame::PaintBorder has some problems, kludge it here nscoord borderWidth = GetBorderWidth(aPresContext); - nscoord borderWidth2 = 2 * borderWidth; - nsSize innerSize(aDesiredSize.width - borderWidth2, aDesiredSize.height - borderWidth2); + nscoord kludge = borderWidth/2; + nsSize innerSize(aDesiredSize.width - borderWidth - kludge, aDesiredSize.height - borderWidth - kludge); // Reflow the child and get its desired size + nsReflowMetrics kidMetrics(aDesiredSize.maxElementSize); nsReflowState kidReflowState(mFirstChild, aReflowState, innerSize); mFirstChild->WillReflow(aPresContext); - aStatus = ReflowChild(mFirstChild, &aPresContext, aDesiredSize, kidReflowState); -// nsReflowMetrics ignore(nsnull); -// aStatus = ReflowChild(mFirstChild, &aPresContext, ignore, kidReflowState); + aStatus = ReflowChild(mFirstChild, &aPresContext, kidMetrics, kidReflowState); NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); // Place and size the child @@ -326,7 +341,6 @@ nsHTMLFrameOuterFrame::Reflow(nsIPresContext& aPresContext, aDesiredSize.maxElementSize->height = aDesiredSize.height; } - return NS_OK; } @@ -401,6 +415,13 @@ float nsHTMLFrameInnerFrame::GetTwipsToPixels() #endif +NS_IMETHODIMP nsHTMLFrameInnerFrame::List(FILE* out, PRInt32 aIndent) const +{ + for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out); // Indent + fprintf(out, "%X INNER \n", this); + return nsFrame::List(out, aIndent); +} + NS_METHOD nsHTMLFrameInnerFrame::MoveTo(nscoord aX, nscoord aY) { @@ -410,7 +431,7 @@ nsHTMLFrameInnerFrame::MoveTo(nscoord aX, nscoord aY) NS_METHOD nsHTMLFrameInnerFrame::SizeTo(nscoord aWidth, nscoord aHeight) { - return nsLeafFrame::SizeTo(aWidth, aWidth); + return nsLeafFrame::SizeTo(aWidth, aHeight); } NS_IMETHODIMP @@ -418,7 +439,7 @@ nsHTMLFrameInnerFrame::Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect) { -//printf("inner paint %d (%d,%d,%d,%d) ", this, aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height); + //printf("inner paint %d (%d,%d,%d,%d) ", this, aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height); if (nsnull != mWebShell) { //mWebShell->Show(); } @@ -566,6 +587,14 @@ nsHTMLFrameInnerFrame::Reflow(nsIPresContext& aPresContext, aDesiredSize.ascent = aDesiredSize.height; aDesiredSize.descent = 0; + // resize the sub document + float t2p = aPresContext.GetTwipsToPixels(); + nsRect subBounds; + mWebShell->GetBounds(subBounds); + subBounds.width = NS_TO_INT_ROUND(aDesiredSize.width * t2p); + subBounds.height = NS_TO_INT_ROUND(aDesiredSize.height * t2p); + mWebShell->SetBounds(subBounds); + aStatus = NS_FRAME_COMPLETE; return rv; } @@ -596,6 +625,18 @@ nsHTMLFrame::~nsHTMLFrame() mParentWebWidget = nsnull; } +void nsHTMLFrame::List(FILE* out, PRInt32 aIndent) const +{ + for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out); // Indent + fprintf(out, "%X ", this); + if (mInline) { + fprintf(out, "INLINE \n", this); + } else { + fprintf(out, "\n"); + } + nsHTMLContent::List(out, aIndent); +} + void nsHTMLFrame::SetAttribute(nsIAtom* aAttribute, const nsString& aString) { nsHTMLValue val; @@ -606,11 +647,11 @@ void nsHTMLFrame::SetAttribute(nsIAtom* aAttribute, const nsString& aString) nsHTMLContainer::SetAttribute(aAttribute, aString); } + void nsHTMLFrame::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { MapImagePropertiesInto(aContext, aPresContext); - MapImageBorderInto(aContext, aPresContext, nsnull); } nsresult diff --git a/mozilla/layout/html/document/src/nsHTMLFrameset.cpp b/mozilla/layout/html/document/src/nsHTMLFrameset.cpp index 4d586e20618..1a8a99b9e56 100644 --- a/mozilla/layout/html/document/src/nsHTMLFrameset.cpp +++ b/mozilla/layout/html/document/src/nsHTMLFrameset.cpp @@ -56,10 +56,37 @@ static NS_DEFINE_IID(kIContentViewerContainerIID, static NS_DEFINE_IID(kIDocumentLoaderIID, NS_IDOCUMENTLOADER_IID); +/******************************************************************************* + * nsHTMLFramesetBorderFrame + ******************************************************************************/ +class nsHTMLFramesetBorderFrame : public nsLeafFrame { + +public: + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; + + NS_IMETHOD Paint(nsIPresContext& aPresContext, + nsIRenderingContext& aRenderingContext, + const nsRect& aDirtyRect); + + NS_IMETHOD Reflow(nsIPresContext& aPresContext, + nsReflowMetrics& aDesiredSize, + const nsReflowState& aReflowState, + nsReflowStatus& aStatus); + +protected: + nsHTMLFramesetBorderFrame(nsIContent* aContent, nsIFrame* aParentFrame, PRBool aVertical); + virtual ~nsHTMLFramesetBorderFrame(); + virtual void GetDesiredSize(nsIPresContext* aPresContext, + const nsReflowState& aReflowState, + nsReflowMetrics& aDesiredSize); + PRBool mVertical; + friend class nsHTMLFramesetFrame; +}; + /******************************************************************************* * nsHTMLFramesetFrame ******************************************************************************/ -PRInt32 nsHTMLFramesetFrame::gMaxNumRowColSpecs = 100; +PRInt32 nsHTMLFramesetFrame::gMaxNumRowColSpecs = 25; nsHTMLFramesetFrame::nsHTMLFramesetFrame(nsIContent* aContent, nsIFrame* aParent) : nsHTMLContainerFrame(aContent, aParent) @@ -230,6 +257,12 @@ void nsHTMLFramesetFrame::CalculateRowCol(nsIPresContext* aPresContext, nscoord } } +PRInt32 nsHTMLFramesetFrame::GetBorderWidth(nsIPresContext* aPresContext) +{ + float p2t = aPresContext->GetPixelsToTwips(); + return NS_TO_INT_ROUND(p2t * 6); +} + PRIntn nsHTMLFramesetFrame::GetSkipSides() const { @@ -275,6 +308,7 @@ nsHTMLFramesetFrame* nsHTMLFramesetFrame::GetFramesetParent(nsIFrame* aChild) return parent; } +// only valid for non border children void nsHTMLFramesetFrame::GetSizeOfChildAt(PRInt32 aIndexInParent, nsSize& aSize, nsPoint& aCellIndex) { PRInt32 row = aIndexInParent / mNumCols; @@ -289,7 +323,7 @@ void nsHTMLFramesetFrame::GetSizeOfChildAt(PRInt32 aIndexInParent, nsSize& aSize } } - +// only valid for non border children void nsHTMLFramesetFrame::GetSizeOfChild(nsIFrame* aChild, nsSize& aSize) { @@ -300,6 +334,7 @@ void nsHTMLFramesetFrame::GetSizeOfChild(nsIFrame* aChild, if (aChild == child) { nsPoint ignore; GetSizeOfChildAt(i, aSize, ignore); + return; } i++; } @@ -307,6 +342,12 @@ void nsHTMLFramesetFrame::GetSizeOfChild(nsIFrame* aChild, aSize.height = 0; } +NS_IMETHODIMP nsHTMLFramesetFrame::List(FILE* out, PRInt32 aIndent) const +{ + for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out); // Indent + fprintf(out, "%X \n", this); + return nsHTMLContainerFrame::List(out, aIndent); +} NS_IMETHODIMP @@ -314,7 +355,7 @@ nsHTMLFramesetFrame::Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect) { -//printf("frameset paint %d (%d,%d,%d,%d) ", this, aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height); + //printf("frameset paint %d (%d,%d,%d,%d) ", this, aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height); return nsHTMLContainerFrame::Paint(aPresContext, aRenderingContext, aDirtyRect); } @@ -411,6 +452,29 @@ nsHTMLFramesetFrame::ParseRowColSpec(nsString& aSpec, PRInt32 aMaxNumValues, return count; } + +void +nsHTMLFramesetFrame::ReflowPlaceChild(nsIFrame* aChild, + nsIPresContext& aPresContext, + const nsReflowState& aReflowState, + nsPoint& aOffset, + nsSize& aSize) +{ + nsReflowState reflowState(aChild, aReflowState, aSize); + aChild->WillReflow(aPresContext); + nsReflowMetrics metrics(nsnull); + metrics.width = aSize.width; + metrics.height= aSize.height; + nsReflowStatus status = ReflowChild(aChild, &aPresContext, metrics, reflowState); + NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "bad status"); + + // Place and size the child + nsRect rect(aOffset.x, aOffset.y, aSize.width, aSize.height); + aChild->SetRect(rect); + aChild->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED); +} + + NS_IMETHODIMP nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, nsReflowMetrics& aDesiredSize, @@ -435,18 +499,24 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, ? aDesiredSize.width : aReflowState.maxSize.width; nscoord height = (aDesiredSize.height <= aReflowState.maxSize.height) ? aDesiredSize.height : aReflowState.maxSize.height; + // subtract out the width of all of the potential borders. There are + // only borders between s. There are none on the edges (e.g the + // leftmost has no left border). + PRInt32 borderWidth = GetBorderWidth(&aPresContext); + width -= (mNumCols - 1) * borderWidth; + height -= (mNumRows - 1) * borderWidth; CalculateRowCol(&aPresContext, width, mNumCols, mColSpecs, mColSizes); CalculateRowCol(&aPresContext, height, mNumRows, mRowSpecs, mRowSizes); - // create the children frames; skip those which aren't frameset or frame + // create the children frames; skip content which isn't