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 or + nsIFrame* lastChild = nsnull; if (firstTime) { mChildCount = 0; - nsIFrame* lastFrame = nsnull; nsHTMLFrameset* content = (nsHTMLFrameset*)mContent; PRInt32 numChildren = content->ChildCount(); - for (int i = 0; i < numChildren; i++) { - nsHTMLTagContent* child = (nsHTMLTagContent*)(content->ChildAt(i)); + for (int childX = 0; childX < numChildren; childX++) { + nsHTMLTagContent* child = (nsHTMLTagContent*)(content->ChildAt(childX)); if (nsnull == child) { continue; } @@ -458,47 +528,70 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, if (NS_OK != result) { return result; } - if (nsnull == lastFrame) { + if (nsnull == lastChild) { mFirstChild = frame; } else { - lastFrame->SetNextSibling(frame); + lastChild->SetNextSibling(frame); } - lastFrame = frame; + lastChild = frame; mChildCount++; } } + mNonBorderChildCount = mChildCount; } // reflow the children PRInt32 lastRow = 0; - PRInt32 i = 0; + PRInt32 borderX = mNonBorderChildCount; // index of border children + nsIFrame* borderFrame = nsnull; nsPoint offset(0,0); - for (nsIFrame* child = mFirstChild; child; child->GetNextSibling(child)) { - nsSize size; - nsPoint cellIndex; - GetSizeOfChildAt(i, size, cellIndex); - nsReflowState reflowState(child, aReflowState, size); - child->WillReflow(aPresContext); - nsReflowMetrics metrics(nsnull); - metrics.width = size.width; - metrics.height= size.height; - aStatus = ReflowChild(child, &aPresContext, metrics, reflowState); - NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); - - // Place and size the child - nsRect rect(offset.x, offset.y, size.width, size.height); - child->SetRect(rect); - child->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED); + nsSize size, lastSize; + nsIFrame* child = mFirstChild; + for (PRInt32 childX = 0; childX < mNonBorderChildCount; childX++) { + nsPoint cellIndex; + GetSizeOfChildAt(childX, size, cellIndex); if (lastRow != cellIndex.y) { // changed to next row + if (firstTime) { // create horizontal border + borderFrame = new nsHTMLFramesetBorderFrame(mContent, this, PR_FALSE); + mChildCount++; + lastChild->SetNextSibling(borderFrame); + lastChild = borderFrame; + } else { + ChildAt(borderX, borderFrame); + borderX++; + } offset.x = 0; - offset.y += metrics.height; - } else { // in same row - offset.x += metrics.width; + offset.y += lastSize.height; + nsSize borderSize(size.width, borderWidth); + ReflowPlaceChild(borderFrame, aPresContext, aReflowState, offset, borderSize); + offset.y += borderWidth; + } else { + if (cellIndex.x > 0) { // moved to next col + if (0 == cellIndex.y) { // in 1st row + if (firstTime) { // create vertical border + borderFrame = new nsHTMLFramesetBorderFrame(mContent, this, PR_TRUE); + mChildCount++; + lastChild->SetNextSibling(borderFrame); + lastChild = borderFrame; + } else { + ChildAt(borderX, borderFrame); + borderX++; + } + nsSize borderSize(borderWidth, size.height); + ReflowPlaceChild(borderFrame, aPresContext, aReflowState, offset, borderSize); + } + offset.x += borderWidth; + } } - lastRow = cellIndex.y; - i++; + + ReflowPlaceChild(child, aPresContext, aReflowState, offset, size); + + lastRow = cellIndex.y; + lastSize = size; + offset.x += size.width; + child->GetNextSibling(child); } if (nsnull != aDesiredSize.maxElementSize) { @@ -523,6 +616,13 @@ nsHTMLFrameset::~nsHTMLFrameset() mParentWebShell = nsnull; } +void nsHTMLFrameset::List(FILE* out, PRInt32 aIndent) const +{ + for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out); // Indent + fprintf(out, "%X \n", this); + nsHTMLContainer::List(out, aIndent); +} + void nsHTMLFrameset::SetAttribute(nsIAtom* aAttribute, const nsString& aString) { nsHTMLValue val; @@ -572,5 +672,71 @@ NS_NewHTMLFrameset(nsIHTMLContent** aInstancePtrResult, return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } +/******************************************************************************* + * nsHTMLFramesetBorderFrame + ******************************************************************************/ +nsHTMLFramesetBorderFrame::nsHTMLFramesetBorderFrame(nsIContent* aContent, nsIFrame* aParent, PRBool aVertical) + : nsLeafFrame(aContent, aParent), mVertical(aVertical) +{ +} +nsHTMLFramesetBorderFrame::~nsHTMLFramesetBorderFrame() +{ +} + +void nsHTMLFramesetBorderFrame::GetDesiredSize(nsIPresContext* aPresContext, + const nsReflowState& aReflowState, + nsReflowMetrics& aDesiredSize) +{ + aDesiredSize.width = aReflowState.maxSize.width; + aDesiredSize.height = aReflowState.maxSize.height; + aDesiredSize.ascent = aDesiredSize.width; + aDesiredSize.descent = 0; +} + +NS_IMETHODIMP +nsHTMLFramesetBorderFrame::Reflow(nsIPresContext& aPresContext, + nsReflowMetrics& aDesiredSize, + const nsReflowState& aReflowState, + nsReflowStatus& aStatus) +{ + GetDesiredSize(&aPresContext, aReflowState, aDesiredSize); + aStatus = NS_FRAME_COMPLETE; + return NS_OK; +} + +NS_METHOD +nsHTMLFramesetBorderFrame::Paint(nsIPresContext& aPresContext, + nsIRenderingContext& aRenderingContext, + const nsRect& aDirtyRect) +{ + static PRInt32 colors[6] = {160, 255, 160, 160, 75, 0}; + + float p2t = aPresContext.GetPixelsToTwips(); + nscoord x0 = 0; + nscoord y0 = 0; + nscoord x1 = (mVertical) ? x0 : mRect.width; + nscoord y1 = (mVertical) ? mRect.height : x0; + + for (int i = 0; i < 6; i++) { + nscolor color = NS_RGB(colors[i], colors[i], colors[i]); + aRenderingContext.SetColor (color); + aRenderingContext.DrawLine (x0, y0, x1, y1); + if (mVertical) { + x0 += nscoord(p2t + 0.5); + x1 = x0; + } else { + y0 += nscoord(p2t + 0.5); + y1 = y0; + } + } + return NS_OK; +} + +NS_IMETHODIMP nsHTMLFramesetBorderFrame::List(FILE* out, PRInt32 aIndent) const +{ + for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out); // Indent + fprintf(out, "%X BORDER \n", this); + return nsLeafFrame::List(out, aIndent); +} diff --git a/mozilla/layout/html/document/src/nsHTMLFrameset.h b/mozilla/layout/html/document/src/nsHTMLFrameset.h index 0bef05e077c..e35beff5e2b 100644 --- a/mozilla/layout/html/document/src/nsHTMLFrameset.h +++ b/mozilla/layout/html/document/src/nsHTMLFrameset.h @@ -63,6 +63,8 @@ public: static nsHTMLFramesetFrame* GetFramesetParent(nsIFrame* aChild); + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; + NS_IMETHOD Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); @@ -80,6 +82,8 @@ protected: const nsReflowState& aReflowState, nsReflowMetrics& aDesiredSize); + PRInt32 GetBorderWidth(nsIPresContext* aPresContext); + virtual PRIntn GetSkipSides() const; void ParseRowCol(nsIAtom* aAttrType, PRInt32& aNumSpecs, nsFramesetSpec** aSpecs); @@ -87,12 +91,18 @@ protected: PRInt32 ParseRowColSpec(nsString& aSpec, PRInt32 aMaxNumValues, nsFramesetSpec* aSpecs); + void ReflowPlaceChild(nsIFrame* aChild, + nsIPresContext& aPresContext, + const nsReflowState& aReflowState, + nsPoint& aOffset, + nsSize& aSize); PRInt32 mNumRows; nsFramesetSpec* mRowSpecs; // parsed, non-computed dimensions nscoord* mRowSizes; // currently computed row sizes PRInt32 mNumCols; nsFramesetSpec* mColSpecs; // parsed, non-computed dimensions nscoord* mColSizes; // currently computed col sizes + PRInt32 mNonBorderChildCount; }; /******************************************************************************* @@ -106,6 +116,7 @@ public: nsIStyleContext* aStyleContext, nsIFrame*& aResult); + virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; virtual void MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext); virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); diff --git a/mozilla/layout/html/document/src/ua.css b/mozilla/layout/html/document/src/ua.css index d210facdd8b..82afe1afa55 100644 --- a/mozilla/layout/html/document/src/ua.css +++ b/mozilla/layout/html/document/src/ua.css @@ -340,7 +340,7 @@ WBR { } IFRAME { display: inline; - border: 1px solid black; + border: 2px solid black; } INPUT { vertical-align: bottom; diff --git a/mozilla/layout/style/ua.css b/mozilla/layout/style/ua.css index d210facdd8b..82afe1afa55 100644 --- a/mozilla/layout/style/ua.css +++ b/mozilla/layout/style/ua.css @@ -340,7 +340,7 @@ WBR { } IFRAME { display: inline; - border: 1px solid black; + border: 2px solid black; } INPUT { vertical-align: bottom; diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index f283da3868f..9ec49fa5da8 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/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/webshell/tests/viewer/Makefile b/mozilla/webshell/tests/viewer/Makefile index 72ec6e2d7a3..e8a093b5d33 100644 --- a/mozilla/webshell/tests/viewer/Makefile +++ b/mozilla/webshell/tests/viewer/Makefile @@ -125,6 +125,7 @@ install:: $(TARGETS) $(INSTALL) samples/test8tab.html $(DIST)/bin/res/samples $(INSTALL) samples/test9.html $(DIST)/bin/res/samples $(INSTALL) samples/test9a.html $(DIST)/bin/res/samples + $(INSTALL) samples/test9b.html $(DIST)/bin/res/samples $(INSTALL) samples/raptor.jpg $(DIST)/bin/res/samples $(INSTALL) samples/Anieyes.gif $(DIST)/bin/res/samples $(INSTALL) samples/gear1.gif $(DIST)/bin/res/samples @@ -161,6 +162,7 @@ clobber:: rm -f $(DIST)/bin/res/samples/test8tab.html rm -f $(DIST)/bin/res/samples/test9.html rm -f $(DIST)/bin/res/samples/test9a.html + rm -f $(DIST)/bin/res/samples/test9b.html rm -f $(DIST)/bin/res/samples/raptor.jpg rm -f $(DIST)/bin/res/samples/Anieyes.gif rm -f $(DIST)/bin/res/samples/gear1.gif diff --git a/mozilla/webshell/tests/viewer/makefile.win b/mozilla/webshell/tests/viewer/makefile.win index 456100df6c1..e6bbbf286d3 100644 --- a/mozilla/webshell/tests/viewer/makefile.win +++ b/mozilla/webshell/tests/viewer/makefile.win @@ -94,6 +94,7 @@ install:: $(PROGRAM) $(MAKE_INSTALL) samples\test_ed.html $(DIST)\bin\res\samples $(MAKE_INSTALL) samples\test9.html $(DIST)\bin\res\samples $(MAKE_INSTALL) samples\test9a.html $(DIST)\bin\res\samples + $(MAKE_INSTALL) samples\test9b.html $(DIST)\bin\res\samples $(MAKE_INSTALL) samples\raptor.jpg $(DIST)\bin\res\samples $(MAKE_INSTALL) samples\Anieyes.gif $(DIST)\bin\res\samples $(MAKE_INSTALL) samples\gear1.gif $(DIST)\bin\res\samples @@ -131,6 +132,7 @@ clobber:: rm -f $(DIST)\bin\res\samples\test_ed.html rm -f $(DIST)\bin\res\samples\test9.html rm -f $(DIST)\bin\res\samples\test9a.html + rm -f $(DIST)\bin\res\samples\test9b.html rm -f $(DIST)\bin\res\samples\raptor.jpg rm -f $(DIST)\bin\res\samples\Anieyes.gif rm -f $(DIST)\bin\res\samples\gear1.gif diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index 677a559df5b..39c2f1662d8 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -962,25 +962,43 @@ nsBrowserWindow::DumpFrames(FILE* out) } } +void +DumpViewsRecurse(nsBrowserWindow* aBrowser, nsIWebShell* aWebShell, FILE* out) +{ + if (nsnull != aWebShell) { + nsIPresShell* shell = aBrowser->GetPresShell(); + if (nsnull != shell) { + nsIViewManager* vm = shell->GetViewManager(); + if (nsnull != vm) { + nsIView* root = vm->GetRootView(); + if (nsnull != root) { + root->List(out); + NS_RELEASE(root); + } + NS_RELEASE(vm); + } + NS_RELEASE(shell); + } + else { + fputs("null pres shell\n", out); + } + // dump the views of the sub documents + PRInt32 i, n; + aWebShell->GetChildCount(n); + for (i = 0; i < n; i++) { + nsIWebShell* child; + aWebShell->ChildAt(i, child); + if (nsnull != child) { + DumpViewsRecurse(aBrowser, child, out); + } + } + } +} + void nsBrowserWindow::DumpViews(FILE* out) { - nsIPresShell* shell = GetPresShell(); - if (nsnull != shell) { - nsIViewManager* vm = shell->GetViewManager(); - if (nsnull != vm) { - nsIView* root = vm->GetRootView(); - if (nsnull != root) { - root->List(out); - NS_RELEASE(root); - } - NS_RELEASE(vm); - } - NS_RELEASE(shell); - } - else { - fputs("null pres shell\n", out); - } + DumpViewsRecurse(this, mWebShell, out); } static void DumpAWebShell(nsIWebShell* aShell, FILE* out, PRInt32 aIndent) diff --git a/mozilla/webshell/tests/viewer/samples/test9.html b/mozilla/webshell/tests/viewer/samples/test9.html index 96d2a18b79b..89bef6a15ac 100644 --- a/mozilla/webshell/tests/viewer/samples/test9.html +++ b/mozilla/webshell/tests/viewer/samples/test9.html @@ -2,38 +2,11 @@ Example 9: Frames - - -

Example 9: Frames

-Put test6.html in frame1, - frame2, - frame3, - frame3.1, - self, - parent, - top -
-Put test9a.html in frame1, - frame2, - frame3, - frame3.1, - self, - parent, - top -
-
-frame1              -                -                -         -frame2 -
- -  - -
-frame3 -
- - + + + + + + + diff --git a/mozilla/webshell/tests/viewer/samples/test9a.html b/mozilla/webshell/tests/viewer/samples/test9a.html index 8735ae70027..f3d97fdd50f 100644 --- a/mozilla/webshell/tests/viewer/samples/test9a.html +++ b/mozilla/webshell/tests/viewer/samples/test9a.html @@ -1,16 +1,39 @@ + +Example 9: Frames + -Put test5.html in frame1, - frame2, - frame3, - frame3.1, - self, - parent, - top + +

Example 9: Frames

+Put test6.html in frame1, + frame2, + frame3, + frame3.1, + self, + parent, + top +
+Put test9b.html in frame1, + frame2, + frame3, + frame3.1, + self, + parent, + top

-frame3.1 +frame1              +                +                +         +frame2
- + +  + +
+frame3 +
+ diff --git a/mozilla/webshell/tests/viewer/samples/test9b.html b/mozilla/webshell/tests/viewer/samples/test9b.html new file mode 100644 index 00000000000..fa79ef11fb1 --- /dev/null +++ b/mozilla/webshell/tests/viewer/samples/test9b.html @@ -0,0 +1,16 @@ + + +Put test5.html in frame1, + frame2, + frame3, + frame3.1, + self, + parent, + top +
+
+frame3.1 +
+ + +