From 86392df9da67e6d75065793a79caf81a9c9e93b5 Mon Sep 17 00:00:00 2001 From: "evaughan%netscape.com" Date: Mon, 12 Jun 2000 23:23:00 +0000 Subject: [PATCH] Fixes for tree on grid work. #30511 -r hyatt git-svn-id: svn://10.0.0.236/trunk@72064 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsCSSFrameConstructor.cpp | 13 +- .../html/style/src/nsCSSFrameConstructor.cpp | 13 +- .../layout/xul/base/src/nsGroupBoxFrame.cpp | 152 ++++-------------- .../layout/xul/base/src/nsMonumentLayout.cpp | 89 ++++++++-- .../layout/xul/base/src/nsMonumentLayout.h | 13 +- .../layout/xul/base/src/nsObeliskLayout.cpp | 71 +++++++- .../layout/xul/base/src/nsTempleLayout.cpp | 10 ++ mozilla/layout/xul/base/src/nsTempleLayout.h | 1 + mozilla/layout/xul/base/src/nsTitleFrame.cpp | 40 ----- mozilla/layout/xul/base/src/nsTitleFrame.h | 9 +- .../layout/xul/base/src/nsTitledBoxFrame.cpp | 152 ++++-------------- mozilla/xpfe/global/resources/content/xul.css | 22 +++ .../global/resources/content/xulBindings.xml | 28 ++++ mozilla/xpfe/global/resources/skin/xul.css | 17 ++ 14 files changed, 302 insertions(+), 328 deletions(-) diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index b8e8b9d617b..607a25e7175 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -75,7 +75,6 @@ #include "nsIAttributeContent.h" #include "nsIPref.h" #include "nsLegendFrame.h" -#include "nsTitleFrame.h" #include "nsIContentIterator.h" #include "nsBoxLayoutState.h" #include "nsIBindingManager.h" @@ -209,9 +208,6 @@ NS_NewTextBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame ); nsresult NS_NewTitledBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame ); -nsresult -NS_NewTitledBoxInnerFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame ); - nsresult NS_NewTitleFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame ); @@ -4565,6 +4561,7 @@ nsCSSFrameConstructor::ConstructTitledBoxFrame(nsIPresShell* aPresShell, nsIStyleContext* aStyleContext, nsIFrame*& aNewFrame) { + /* nsIFrame * newFrame; nsresult rv = NS_NewTitledBoxFrame(aPresShell, &newFrame); if (!NS_SUCCEEDED(rv)) { @@ -4637,7 +4634,7 @@ nsCSSFrameConstructor::ConstructTitledBoxFrame(nsIPresShell* aPresShell, // our new frame retured is the top frame which is the list frame. aNewFrame = newFrame; - +*/ return NS_OK; } @@ -5811,8 +5808,10 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, else if (aTag == nsXULAtoms::titledbox) { - ConstructTitledBoxFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, aTag, aStyleContext, newFrame); - processChildren = PR_FALSE; + rv = NS_NewTitledBoxFrame(aPresShell, &newFrame); + + //ConstructTitledBoxFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, aTag, aStyleContext, newFrame); + processChildren = PR_TRUE; isReplaced = PR_TRUE; const nsStyleDisplay* display = (const nsStyleDisplay*) diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index b8e8b9d617b..607a25e7175 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -75,7 +75,6 @@ #include "nsIAttributeContent.h" #include "nsIPref.h" #include "nsLegendFrame.h" -#include "nsTitleFrame.h" #include "nsIContentIterator.h" #include "nsBoxLayoutState.h" #include "nsIBindingManager.h" @@ -209,9 +208,6 @@ NS_NewTextBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame ); nsresult NS_NewTitledBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame ); -nsresult -NS_NewTitledBoxInnerFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame ); - nsresult NS_NewTitleFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame ); @@ -4565,6 +4561,7 @@ nsCSSFrameConstructor::ConstructTitledBoxFrame(nsIPresShell* aPresShell, nsIStyleContext* aStyleContext, nsIFrame*& aNewFrame) { + /* nsIFrame * newFrame; nsresult rv = NS_NewTitledBoxFrame(aPresShell, &newFrame); if (!NS_SUCCEEDED(rv)) { @@ -4637,7 +4634,7 @@ nsCSSFrameConstructor::ConstructTitledBoxFrame(nsIPresShell* aPresShell, // our new frame retured is the top frame which is the list frame. aNewFrame = newFrame; - +*/ return NS_OK; } @@ -5811,8 +5808,10 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, else if (aTag == nsXULAtoms::titledbox) { - ConstructTitledBoxFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, aTag, aStyleContext, newFrame); - processChildren = PR_FALSE; + rv = NS_NewTitledBoxFrame(aPresShell, &newFrame); + + //ConstructTitledBoxFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, aTag, aStyleContext, newFrame); + processChildren = PR_TRUE; isReplaced = PR_TRUE; const nsStyleDisplay* display = (const nsStyleDisplay*) diff --git a/mozilla/layout/xul/base/src/nsGroupBoxFrame.cpp b/mozilla/layout/xul/base/src/nsGroupBoxFrame.cpp index 6a353a6615e..58f3c0501ab 100644 --- a/mozilla/layout/xul/base/src/nsGroupBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsGroupBoxFrame.cpp @@ -22,30 +22,6 @@ // YY need to pass isMultiple before create called -/* -//#include "nsFormControlFrame.h" -#include "nsHTMLContainerFrame.h" -#include "nsLegendFrame.h" -#include "nsIDOMNode.h" -#include "nsIDOMHTMLFieldSetElement.h" -#include "nsIDOMHTMLLegendElement.h" -//#include "nsIDOMHTMLCollection.h" -#include "nsIContent.h" -#include "nsIFrame.h" -#include "nsISupports.h" -#include "nsIAtom.h" -#include "nsIPresContext.h" -#include "nsIHTMLContent.h" -#include "nsHTMLIIDs.h" -#include "nsHTMLParts.h" -#include "nsHTMLAtoms.h" -#include "nsIStyleContext.h" -#include "nsStyleConsts.h" -#include "nsStyleUtil.h" -#include "nsFont.h" -#include "nsCOMPtr.h" -*/ - #include "nsCSSRendering.h" #include "nsIStyleContext.h" #include "nsBoxFrame.h" @@ -55,10 +31,6 @@ public: nsTitledBoxFrame(nsIPresShell* aShell); - NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext, - nsIAtom* aListName, - nsIFrame* aChildList); - NS_IMETHOD GetBorderAndPadding(nsMargin& aBorderAndPadding); @@ -67,17 +39,6 @@ public: const nsRect& aDirtyRect, nsFramePaintLayer aWhichLayer); - NS_IMETHOD AppendFrames(nsIPresContext* aPresContext, - nsIPresShell& aPresShell, - nsIAtom* aListName, - nsIFrame* aFrameList); - - NS_IMETHOD InsertFrames(nsIPresContext* aPresContext, - nsIPresShell& aPresShell, - nsIAtom* aListName, - nsIFrame* aPrevFrame, - nsIFrame* aFrameList); - #ifdef DEBUG NS_IMETHOD GetFrameName(nsString& aResult) const { return MakeFrameName("GroupBoxFrame", aResult); @@ -92,11 +53,10 @@ public: virtual PRBool GetInitialVAlignment(Valignment& aValign) { aValign = vAlign_Top; return PR_TRUE; } virtual PRBool GetInitialAutoStretch(PRBool& aStretch) { aStretch = PR_TRUE; return PR_TRUE; } - nsIFrame* GetTitleFrame(nsIPresContext* aPresContext, nsRect& aRect); - nsIFrame* GetContentFrame(nsIPresContext* aPresContext); - + nsIBox* GetTitleBox(nsIPresContext* aPresContext, nsRect& aRect); }; +/* class nsTitledBoxInnerFrame : public nsBoxFrame { public: @@ -113,22 +73,7 @@ public: virtual PRBool GetDefaultFlex(PRInt32& aFlex) { aFlex = 1; return PR_TRUE; } }; - -nsresult -NS_NewTitledBoxInnerFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) -{ - NS_PRECONDITION(aNewFrame, "null OUT ptr"); - if (nsnull == aNewFrame) { - return NS_ERROR_NULL_POINTER; - } - nsTitledBoxInnerFrame* it = new (aPresShell) nsTitledBoxInnerFrame(aPresShell); - if (!it) { - return NS_ERROR_OUT_OF_MEMORY; - } - - *aNewFrame = it; - return NS_OK; -} +*/ nsresult NS_NewTitledBoxFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) @@ -151,15 +96,6 @@ nsTitledBoxFrame::nsTitledBoxFrame(nsIPresShell* aShell):nsBoxFrame(aShell) } -NS_IMETHODIMP -nsTitledBoxFrame::SetInitialChildList(nsIPresContext* aPresContext, - nsIAtom* aListName, - nsIFrame* aChildList) -{ - // Queue up the frames for the content frame - return nsBoxFrame::SetInitialChildList(aPresContext, nsnull, aChildList); -} - // this is identical to nsHTMLContainerFrame::Paint except for the background and border. NS_IMETHODIMP nsTitledBoxFrame::Paint(nsIPresContext* aPresContext, @@ -187,9 +123,12 @@ nsTitledBoxFrame::Paint(nsIPresContext* aPresContext, nscoord yoff = 0; nsRect titleRect; - nsIFrame* titleFrame = GetTitleFrame(aPresContext, titleRect); + nsIBox* titleBox = GetTitleBox(aPresContext, titleRect); + + if (titleBox) { + nsIFrame* titleFrame; + titleBox->GetFrame(&titleFrame); - if (titleFrame) { // if the border is smaller than the legend. Move the border down // to be centered on the legend. const nsStyleSpacing* titleSpacing; @@ -210,7 +149,7 @@ nsTitledBoxFrame::Paint(nsIPresContext* aPresContext, aDirtyRect, rect, *color, *spacing, 0, 0); - if (titleFrame) { + if (titleBox) { // we should probably use PaintBorderEdges to do this but for now just use clipping // to achieve the same effect. @@ -284,26 +223,33 @@ nsTitledBoxFrame::Paint(nsIPresContext* aPresContext, return NS_OK; } -nsIFrame* -nsTitledBoxFrame::GetTitleFrame(nsIPresContext* aPresContext, nsRect& aTitleRect) +nsIBox* +nsTitledBoxFrame::GetTitleBox(nsIPresContext* aPresContext, nsRect& aTitleRect) { - // if we only have one child fail - nsIFrame* frame = mFrames.FirstChild(); - nsIFrame* next = nsnull; - frame->GetNextSibling(&next); - if (!next) - return nsnull; + // first child is out titled area + nsIBox* box; + GetChildBox(&box); - // if we have more than one child. The first is our baby. - // then get the first child inside. - nsIFrame* child; - frame->FirstChild(aPresContext, nsnull, &child); + // no area fail. + if (!box) + return nsnull; + + // get the first child in the titled area that is the title + box->GetChildBox(&box); + + // nothing in the area? fail + if (!box) + return nsnull; + + // now get the title itself. It is in the title frame. + nsIBox* child = nsnull; + box->GetChildBox(&child); if (child) { // convert to our coordinates. nsRect parentRect; - frame->GetRect(parentRect); - child->GetRect(aTitleRect); + box->GetBounds(parentRect); + child->GetBounds(aTitleRect); aTitleRect.x += parentRect.x; aTitleRect.y += parentRect.y; } @@ -311,20 +257,6 @@ nsTitledBoxFrame::GetTitleFrame(nsIPresContext* aPresContext, nsRect& aTitleRect return child; } -nsIFrame* -nsTitledBoxFrame::GetContentFrame(nsIPresContext* aPresContext) -{ - // the content frame is always our second frame. The title frame - // is the first. - nsIFrame* frame = mFrames.FirstChild(); - nsIFrame* next = nsnull; - frame->GetNextSibling(&next); - if (!next) - return frame; - else - return next; -} - NS_IMETHODIMP nsTitledBoxFrame::GetBorderAndPadding(nsMargin& aBorderAndPadding) { @@ -332,27 +264,3 @@ nsTitledBoxFrame::GetBorderAndPadding(nsMargin& aBorderAndPadding) return NS_OK; } -NS_IMETHODIMP -nsTitledBoxFrame::InsertFrames(nsIPresContext* aPresContext, - nsIPresShell& aPresShell, - nsIAtom* aListName, - nsIFrame* aPrevFrame, - nsIFrame* aFrameList) -{ - nsIFrame* content = GetContentFrame(aPresContext); - NS_ASSERTION(content, "ERROR TitledBoxFrame has no content!!!"); - return content->InsertFrames(aPresContext, aPresShell, aListName, aPrevFrame, aFrameList); -} - - -NS_IMETHODIMP -nsTitledBoxFrame::AppendFrames(nsIPresContext* aPresContext, - nsIPresShell& aPresShell, - nsIAtom* aListName, - nsIFrame* aFrameList) -{ - nsIFrame* content = GetContentFrame(aPresContext); - NS_ASSERTION(content, "ERROR TitledBoxFrame has no content!!!"); - return content->AppendFrames(aPresContext, aPresShell, aListName, aFrameList); -} - diff --git a/mozilla/layout/xul/base/src/nsMonumentLayout.cpp b/mozilla/layout/xul/base/src/nsMonumentLayout.cpp index 8d937acceb5..d3b17e165d1 100644 --- a/mozilla/layout/xul/base/src/nsMonumentLayout.cpp +++ b/mozilla/layout/xul/base/src/nsMonumentLayout.cpp @@ -35,7 +35,7 @@ // ----- Monument Iterator ----- -nsLayoutIterator::nsLayoutIterator(nsIBox* aBox):mBox(nsnull),mStartBox(aBox),mScrollFrameCount(0) +nsLayoutIterator::nsLayoutIterator(nsIBox* aBox):mBox(nsnull),mStartBox(aBox),mParentCount(0) { } @@ -46,47 +46,76 @@ nsLayoutIterator::Reset() } PRBool -nsLayoutIterator::GetNextLayout(nsIBoxLayout** aLayout) +nsLayoutIterator::GetNextLayout(nsIBoxLayout** aLayout, PRBool aSearchChildren) { if (mBox == nsnull) { mBox = mStartBox; } else { - mBox->GetNextBox(&mBox); + if (aSearchChildren) { + mParents[mParentCount++] = mBox; + NS_ASSERTION(mParentCount < PARENT_STACK_SIZE, "Stack overflow!!"); + mBox->GetChildBox(&mBox); + } else { + mBox->GetNextBox(&mBox); + } } - if (!mBox) { + return DigDeep(aLayout, aSearchChildren); +} - if (mScrollFrameCount > 0) { - mBox = mScrollFrames[--mScrollFrameCount]; - return GetNextLayout(aLayout); +PRBool +nsLayoutIterator::DigDeep(nsIBoxLayout** aLayout, PRBool aSearchChildren) +{ + // if our box is null. See if we have any parents on the stack + // if so pop them off and continue. + if (!mBox) { + if (mParentCount > 0) { + mBox = mParents[--mParentCount]; + mBox->GetNextBox(&mBox); + return DigDeep(aLayout, aSearchChildren); } *aLayout = nsnull; return PR_FALSE; } + // if its a scrollframe. Then continue down into the scrolled frame nsresult rv = NS_OK; nsCOMPtr scrollFrame = do_QueryInterface(mBox, &rv); if (scrollFrame) { nsIFrame* scrolledFrame = nsnull; scrollFrame->GetScrolledFrame(nsnull, scrolledFrame); NS_ASSERTION(scrolledFrame,"Error no scroll frame!!"); - mScrollFrames[mScrollFrameCount++] = mBox; + mParents[mParentCount++] = mBox; + NS_ASSERTION(mParentCount < PARENT_STACK_SIZE, "Stack overflow!!"); nsCOMPtr b = do_QueryInterface(scrolledFrame); mBox = b; } + // get the layout manager nsCOMPtr layout; - + mBox->GetLayoutManager(getter_AddRefs(layout)); + // if we are supposed to search our children. And the layout manager + // was null. Then dig into the children. + if (aSearchChildren && !layout) + { + mParents[mParentCount++] = mBox; + NS_ASSERTION(mParentCount < PARENT_STACK_SIZE, "Stack overflow!!"); + mBox->GetChildBox(&mBox); + return DigDeep(aLayout, aSearchChildren); + } + *aLayout = layout; NS_IF_ADDREF(*aLayout); - - return PR_TRUE; - + if (layout) + return PR_TRUE; + else + return PR_FALSE; } + // ---- Monument Iterator ----- nsMonumentIterator::nsMonumentIterator(nsIBox* aBox):nsLayoutIterator(aBox) @@ -94,11 +123,11 @@ nsMonumentIterator::nsMonumentIterator(nsIBox* aBox):nsLayoutIterator(aBox) } PRBool -nsMonumentIterator::GetNextMonument(nsIMonument** aMonument) +nsMonumentIterator::GetNextMonument(nsIMonument** aMonument, PRBool aSearchChildren) { nsCOMPtr layout; - while(GetNextLayout(getter_AddRefs(layout))) { + while(GetNextLayout(getter_AddRefs(layout), aSearchChildren)) { if (layout) { nsresult rv = NS_OK; @@ -115,6 +144,38 @@ nsMonumentIterator::GetNextMonument(nsIMonument** aMonument) return PR_FALSE; } +PRBool +nsMonumentIterator::GetNextObelisk(nsObeliskLayout** aObelisk, PRBool aSearchChildren) +{ + nsCOMPtr monument; + PRBool searchChildren = aSearchChildren; + + while(GetNextMonument(getter_AddRefs(monument), searchChildren)) { + + searchChildren = aSearchChildren; + if (monument) + { + *aObelisk = nsnull; + monument->CastToObelisk(aObelisk); + + if (*aObelisk) { + return PR_TRUE; + } + + // ok we found another grid. Don't enter it. + nsGridLayout* grid = nsnull; + monument->CastToGrid(&grid); + if (grid) { + searchChildren = PR_FALSE; + } + } + } + + *aObelisk = nsnull; + + return PR_FALSE; +} + //------ nsInfoListNodeImpl ---- diff --git a/mozilla/layout/xul/base/src/nsMonumentLayout.h b/mozilla/layout/xul/base/src/nsMonumentLayout.h index 1a8505cf626..0f08c2e0ea4 100644 --- a/mozilla/layout/xul/base/src/nsMonumentLayout.h +++ b/mozilla/layout/xul/base/src/nsMonumentLayout.h @@ -37,27 +37,30 @@ class nsGridLayout; class nsBoxLayoutState; class nsIPresShell; +#define PARENT_STACK_SIZE 100 + class nsLayoutIterator { public: nsLayoutIterator(nsIBox* aBox); virtual void Reset(); - virtual PRBool GetNextLayout(nsIBoxLayout** aLayout); + virtual PRBool GetNextLayout(nsIBoxLayout** aLayout, PRBool aSearchChildren = PR_FALSE); virtual void GetBox(nsIBox** aBox) { *aBox = mBox; } + virtual PRBool DigDeep(nsIBoxLayout** aLayout, PRBool aSearchChildren); protected: nsIBox* mBox; nsIBox* mStartBox; - PRInt32 mScrollFrameCount; - nsIBox* mScrollFrames[100]; + PRInt32 mParentCount; + nsIBox* mParents[PARENT_STACK_SIZE]; }; class nsMonumentIterator: public nsLayoutIterator { public: nsMonumentIterator(nsIBox* aBox); - virtual PRBool GetNextMonument(nsIMonument** aMonument); - + virtual PRBool GetNextMonument(nsIMonument** aMonument, PRBool aSearchChildren = PR_FALSE); + virtual PRBool GetNextObelisk(nsObeliskLayout** aObelisk, PRBool aSearchChildren = PR_FALSE); }; class nsBoxSizeListNodeImpl : public nsBoxSizeList diff --git a/mozilla/layout/xul/base/src/nsObeliskLayout.cpp b/mozilla/layout/xul/base/src/nsObeliskLayout.cpp index 2657a2184d3..1578b651b63 100644 --- a/mozilla/layout/xul/base/src/nsObeliskLayout.cpp +++ b/mozilla/layout/xul/base/src/nsObeliskLayout.cpp @@ -120,15 +120,76 @@ nsObeliskLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSi NS_IMETHODIMP nsObeliskLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSize) { - nsresult rv = nsMonumentLayout::GetMinSize(aBox, aState, aSize); + //nsresult rv = nsMonumentLayout::GetMinSize(aBox, aState, aSize); + + PRBool isHorizontal = PR_FALSE; + aBox->GetOrientation(isHorizontal); + + aSize.width = 0; + aSize.height = 0; + + // run through all the children and get there min, max, and preferred sizes + // return us the size of the box + + nsIBox* child = nsnull; + aBox->GetChildBox(&child); + + // our flexes are determined by the other temple. So in getting out min size we need to + // iterator over our temples obelisks. + + nsTempleLayout* temple = nsnull; + nsIBox* aTempleBox = nsnull; + GetOtherTemple(aBox, &temple, &aTempleBox); + + nsMonumentIterator it(aTempleBox); + + while (child) + { + // ignore collapsed children + //PRBool isCollapsed = PR_FALSE; + //aBox->IsCollapsed(aState, isCollapsed); + + //if (!isCollapsed) + //{ + nsSize min(0,0); + nsSize pref(0,0); + nscoord flex = 0; + + child->GetMinSize(aState, min); + + // get the next obelisk and use its flex. + nsObeliskLayout* obelisk; + it.GetNextObelisk(&obelisk, PR_TRUE); + nsIBox* obeliskBox = nsnull; + it.GetBox(&obeliskBox); + + if (obeliskBox) { + obeliskBox->GetFlex(aState, flex); + } else { + child->GetFlex(aState, flex); + } + + // if the child is not flexible then + // its min size is its pref size. + if (flex == 0) { + child->GetPrefSize(aState, pref); + if (isHorizontal) + min.width = pref.width; + else + min.height = pref.height; + } + + AddMargin(child, min); + AddLargestSize(aSize, min, isHorizontal); + //} + + child->GetNextBox(&child); + } UpdateMonuments(aBox, aState); nsBoxSizeList* node = mOtherMonumentList; - PRBool isHorizontal = PR_FALSE; - aBox->GetOrientation(isHorizontal); - if (node) { // if the infos pref width is greater than aSize's use it. // if the infos min width is greater than aSize's use it. @@ -151,7 +212,7 @@ nsObeliskLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSiz s2 = s; } - return rv; + return NS_OK; } NS_IMETHODIMP diff --git a/mozilla/layout/xul/base/src/nsTempleLayout.cpp b/mozilla/layout/xul/base/src/nsTempleLayout.cpp index a701f5564b0..7bee9d11a41 100644 --- a/mozilla/layout/xul/base/src/nsTempleLayout.cpp +++ b/mozilla/layout/xul/base/src/nsTempleLayout.cpp @@ -234,3 +234,13 @@ nsTempleLayout::DesecrateMonuments(nsIBox* aBox, nsBoxLayoutState& aState) return NS_OK; } +// redefined because the normal GetMinSize in sprocket looks at flex +// if the child is not flexible then its min size is its pref size. +// but in this case its up to the column. The column's flex is the +// flex thats used. +NS_IMETHODIMP +nsTempleLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSize) +{ + return nsSprocketLayout::GetMinSize(aBox, aState, aSize); +} + diff --git a/mozilla/layout/xul/base/src/nsTempleLayout.h b/mozilla/layout/xul/base/src/nsTempleLayout.h index c40f3287755..1525f7e33b5 100644 --- a/mozilla/layout/xul/base/src/nsTempleLayout.h +++ b/mozilla/layout/xul/base/src/nsTempleLayout.h @@ -46,6 +46,7 @@ public: NS_IMETHOD ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList); NS_IMETHOD DesecrateMonuments(nsIBox* aBox, nsBoxLayoutState& aState); NS_IMETHOD EnscriptionChanged(nsBoxLayoutState& aState, PRInt32 aIndex); + NS_IMETHOD GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize); protected: diff --git a/mozilla/layout/xul/base/src/nsTitleFrame.cpp b/mozilla/layout/xul/base/src/nsTitleFrame.cpp index 41b658dfa5c..d07b7a5e81f 100644 --- a/mozilla/layout/xul/base/src/nsTitleFrame.cpp +++ b/mozilla/layout/xul/base/src/nsTitleFrame.cpp @@ -23,25 +23,6 @@ // YY need to pass isMultiple before create called #include "nsTitleFrame.h" - -/* -#include "nsTitleFrame.h" -#include "nsIContent.h" -#include "nsIFrame.h" -#include "nsISupports.h" -#include "nsIAtom.h" -#include "nsIHTMLContent.h" -#include "nsHTMLIIDs.h" -#include "nsHTMLParts.h" -#include "nsHTMLAtoms.h" -#include "nsIStyleContext.h" -#include "nsStyleConsts.h" -#include "nsStyleUtil.h" -#include "nsFont.h" -#include "nsFormControlFrame.h" -*/ - -static NS_DEFINE_IID(kTitleFrameCID, NS_TITLE_FRAME_CID); nsresult NS_NewTitleFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) @@ -62,27 +43,6 @@ nsTitleFrame::nsTitleFrame(nsIPresShell* aPresShell):nsBoxFrame(aPresShell) { } -nsTitleFrame::~nsTitleFrame() -{ -} - -// Frames are not refcounted, no need to AddRef -NS_IMETHODIMP -nsTitleFrame::QueryInterface(REFNSIID aIID, void** aInstancePtrResult) -{ - NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer"); - if (nsnull == aInstancePtrResult) { - return NS_ERROR_NULL_POINTER; - } - if (aIID.Equals(kTitleFrameCID)) { - *aInstancePtrResult = (void*) ((nsTitleFrame*)this); - return NS_OK; - } - return nsBoxFrame::QueryInterface(aIID, aInstancePtrResult); -} - - - #ifdef NS_DEBUG NS_IMETHODIMP nsTitleFrame::GetFrameName(nsString& aResult) const diff --git a/mozilla/layout/xul/base/src/nsTitleFrame.h b/mozilla/layout/xul/base/src/nsTitleFrame.h index d0a617c3972..279d9eb7358 100644 --- a/mozilla/layout/xul/base/src/nsTitleFrame.h +++ b/mozilla/layout/xul/base/src/nsTitleFrame.h @@ -25,16 +25,10 @@ #include "nsBoxFrame.h" -#define NS_TITLE_FRAME_CID \ -{ 0x73801d40, 0x5a22, 0x12d2, { 0x80, 0x46, 0x0, 0x60, 0x2, 0x14, 0xa7, 0x90 } } - class nsTitleFrame : public nsBoxFrame { public: nsTitleFrame(nsIPresShell* aShell); - virtual ~nsTitleFrame(); - - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); // we are always a vertical box. virtual PRBool GetInitialOrientation(PRBool& aIsHorizontal) { aIsHorizontal = PR_FALSE; return PR_TRUE; } @@ -42,6 +36,9 @@ public: // never autostretch we align out children. virtual PRBool GetInitialAutoStretch(PRBool& aStretch) { aStretch = PR_FALSE; return PR_TRUE; } + // we are always flexible + virtual PRBool GetDefaultFlex(PRInt32& aFlex) { aFlex = 1; return PR_TRUE; } + #ifdef NS_DEBUG NS_IMETHOD GetFrameName(nsString& aResult) const; #endif diff --git a/mozilla/layout/xul/base/src/nsTitledBoxFrame.cpp b/mozilla/layout/xul/base/src/nsTitledBoxFrame.cpp index 6a353a6615e..58f3c0501ab 100644 --- a/mozilla/layout/xul/base/src/nsTitledBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsTitledBoxFrame.cpp @@ -22,30 +22,6 @@ // YY need to pass isMultiple before create called -/* -//#include "nsFormControlFrame.h" -#include "nsHTMLContainerFrame.h" -#include "nsLegendFrame.h" -#include "nsIDOMNode.h" -#include "nsIDOMHTMLFieldSetElement.h" -#include "nsIDOMHTMLLegendElement.h" -//#include "nsIDOMHTMLCollection.h" -#include "nsIContent.h" -#include "nsIFrame.h" -#include "nsISupports.h" -#include "nsIAtom.h" -#include "nsIPresContext.h" -#include "nsIHTMLContent.h" -#include "nsHTMLIIDs.h" -#include "nsHTMLParts.h" -#include "nsHTMLAtoms.h" -#include "nsIStyleContext.h" -#include "nsStyleConsts.h" -#include "nsStyleUtil.h" -#include "nsFont.h" -#include "nsCOMPtr.h" -*/ - #include "nsCSSRendering.h" #include "nsIStyleContext.h" #include "nsBoxFrame.h" @@ -55,10 +31,6 @@ public: nsTitledBoxFrame(nsIPresShell* aShell); - NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext, - nsIAtom* aListName, - nsIFrame* aChildList); - NS_IMETHOD GetBorderAndPadding(nsMargin& aBorderAndPadding); @@ -67,17 +39,6 @@ public: const nsRect& aDirtyRect, nsFramePaintLayer aWhichLayer); - NS_IMETHOD AppendFrames(nsIPresContext* aPresContext, - nsIPresShell& aPresShell, - nsIAtom* aListName, - nsIFrame* aFrameList); - - NS_IMETHOD InsertFrames(nsIPresContext* aPresContext, - nsIPresShell& aPresShell, - nsIAtom* aListName, - nsIFrame* aPrevFrame, - nsIFrame* aFrameList); - #ifdef DEBUG NS_IMETHOD GetFrameName(nsString& aResult) const { return MakeFrameName("GroupBoxFrame", aResult); @@ -92,11 +53,10 @@ public: virtual PRBool GetInitialVAlignment(Valignment& aValign) { aValign = vAlign_Top; return PR_TRUE; } virtual PRBool GetInitialAutoStretch(PRBool& aStretch) { aStretch = PR_TRUE; return PR_TRUE; } - nsIFrame* GetTitleFrame(nsIPresContext* aPresContext, nsRect& aRect); - nsIFrame* GetContentFrame(nsIPresContext* aPresContext); - + nsIBox* GetTitleBox(nsIPresContext* aPresContext, nsRect& aRect); }; +/* class nsTitledBoxInnerFrame : public nsBoxFrame { public: @@ -113,22 +73,7 @@ public: virtual PRBool GetDefaultFlex(PRInt32& aFlex) { aFlex = 1; return PR_TRUE; } }; - -nsresult -NS_NewTitledBoxInnerFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) -{ - NS_PRECONDITION(aNewFrame, "null OUT ptr"); - if (nsnull == aNewFrame) { - return NS_ERROR_NULL_POINTER; - } - nsTitledBoxInnerFrame* it = new (aPresShell) nsTitledBoxInnerFrame(aPresShell); - if (!it) { - return NS_ERROR_OUT_OF_MEMORY; - } - - *aNewFrame = it; - return NS_OK; -} +*/ nsresult NS_NewTitledBoxFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) @@ -151,15 +96,6 @@ nsTitledBoxFrame::nsTitledBoxFrame(nsIPresShell* aShell):nsBoxFrame(aShell) } -NS_IMETHODIMP -nsTitledBoxFrame::SetInitialChildList(nsIPresContext* aPresContext, - nsIAtom* aListName, - nsIFrame* aChildList) -{ - // Queue up the frames for the content frame - return nsBoxFrame::SetInitialChildList(aPresContext, nsnull, aChildList); -} - // this is identical to nsHTMLContainerFrame::Paint except for the background and border. NS_IMETHODIMP nsTitledBoxFrame::Paint(nsIPresContext* aPresContext, @@ -187,9 +123,12 @@ nsTitledBoxFrame::Paint(nsIPresContext* aPresContext, nscoord yoff = 0; nsRect titleRect; - nsIFrame* titleFrame = GetTitleFrame(aPresContext, titleRect); + nsIBox* titleBox = GetTitleBox(aPresContext, titleRect); + + if (titleBox) { + nsIFrame* titleFrame; + titleBox->GetFrame(&titleFrame); - if (titleFrame) { // if the border is smaller than the legend. Move the border down // to be centered on the legend. const nsStyleSpacing* titleSpacing; @@ -210,7 +149,7 @@ nsTitledBoxFrame::Paint(nsIPresContext* aPresContext, aDirtyRect, rect, *color, *spacing, 0, 0); - if (titleFrame) { + if (titleBox) { // we should probably use PaintBorderEdges to do this but for now just use clipping // to achieve the same effect. @@ -284,26 +223,33 @@ nsTitledBoxFrame::Paint(nsIPresContext* aPresContext, return NS_OK; } -nsIFrame* -nsTitledBoxFrame::GetTitleFrame(nsIPresContext* aPresContext, nsRect& aTitleRect) +nsIBox* +nsTitledBoxFrame::GetTitleBox(nsIPresContext* aPresContext, nsRect& aTitleRect) { - // if we only have one child fail - nsIFrame* frame = mFrames.FirstChild(); - nsIFrame* next = nsnull; - frame->GetNextSibling(&next); - if (!next) - return nsnull; + // first child is out titled area + nsIBox* box; + GetChildBox(&box); - // if we have more than one child. The first is our baby. - // then get the first child inside. - nsIFrame* child; - frame->FirstChild(aPresContext, nsnull, &child); + // no area fail. + if (!box) + return nsnull; + + // get the first child in the titled area that is the title + box->GetChildBox(&box); + + // nothing in the area? fail + if (!box) + return nsnull; + + // now get the title itself. It is in the title frame. + nsIBox* child = nsnull; + box->GetChildBox(&child); if (child) { // convert to our coordinates. nsRect parentRect; - frame->GetRect(parentRect); - child->GetRect(aTitleRect); + box->GetBounds(parentRect); + child->GetBounds(aTitleRect); aTitleRect.x += parentRect.x; aTitleRect.y += parentRect.y; } @@ -311,20 +257,6 @@ nsTitledBoxFrame::GetTitleFrame(nsIPresContext* aPresContext, nsRect& aTitleRect return child; } -nsIFrame* -nsTitledBoxFrame::GetContentFrame(nsIPresContext* aPresContext) -{ - // the content frame is always our second frame. The title frame - // is the first. - nsIFrame* frame = mFrames.FirstChild(); - nsIFrame* next = nsnull; - frame->GetNextSibling(&next); - if (!next) - return frame; - else - return next; -} - NS_IMETHODIMP nsTitledBoxFrame::GetBorderAndPadding(nsMargin& aBorderAndPadding) { @@ -332,27 +264,3 @@ nsTitledBoxFrame::GetBorderAndPadding(nsMargin& aBorderAndPadding) return NS_OK; } -NS_IMETHODIMP -nsTitledBoxFrame::InsertFrames(nsIPresContext* aPresContext, - nsIPresShell& aPresShell, - nsIAtom* aListName, - nsIFrame* aPrevFrame, - nsIFrame* aFrameList) -{ - nsIFrame* content = GetContentFrame(aPresContext); - NS_ASSERTION(content, "ERROR TitledBoxFrame has no content!!!"); - return content->InsertFrames(aPresContext, aPresShell, aListName, aPrevFrame, aFrameList); -} - - -NS_IMETHODIMP -nsTitledBoxFrame::AppendFrames(nsIPresContext* aPresContext, - nsIPresShell& aPresShell, - nsIAtom* aListName, - nsIFrame* aFrameList) -{ - nsIFrame* content = GetContentFrame(aPresContext); - NS_ASSERTION(content, "ERROR TitledBoxFrame has no content!!!"); - return content->AppendFrames(aPresContext, aPresShell, aListName, aFrameList); -} - diff --git a/mozilla/xpfe/global/resources/content/xul.css b/mozilla/xpfe/global/resources/content/xul.css index 8008c0fee65..81dd7915307 100644 --- a/mozilla/xpfe/global/resources/content/xul.css +++ b/mozilla/xpfe/global/resources/content/xul.css @@ -105,6 +105,28 @@ vbox { behavior: url(chrome://global/content/xulBindings.xml#vbox); } +/******** TitledBox *******/ + +box.titledbox-title { +} + +box.titledbox-body { + vertical-align: inherit; + text-align: inherit; +} + +titledbox { + behavior: url(chrome://global/content/xulBindings.xml#titledbox); +} + +titledbox[value] { + behavior: url(chrome://global/content/xulBindings.xml#titledboxvalue); +} + +title { + behavior: url(chrome://global/content/xulBindings.xml#title); +} + /******* ToolBox & ToolBar *******/ toolbox { diff --git a/mozilla/xpfe/global/resources/content/xulBindings.xml b/mozilla/xpfe/global/resources/content/xulBindings.xml index 6e914d29f16..ff124c7d51d 100644 --- a/mozilla/xpfe/global/resources/content/xulBindings.xml +++ b/mozilla/xpfe/global/resources/content/xulBindings.xml @@ -554,5 +554,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mozilla/xpfe/global/resources/skin/xul.css b/mozilla/xpfe/global/resources/skin/xul.css index 155057771dc..a6cb3d2820a 100644 --- a/mozilla/xpfe/global/resources/skin/xul.css +++ b/mozilla/xpfe/global/resources/skin/xul.css @@ -85,6 +85,23 @@ browser, editor, iframe { /******** Box *******/ +/******** TitledBox *******/ + +box.titledbox-title { +} + +box.titledbox-body { + vertical-align: inherit; + text-align: inherit; +} + +titledbox { + behavior: url(resource:/chrome/xulBindings.xml#titledbox); +} + +title { + behavior: url(resource:/chrome/xulBindings.xml#title); +} /******* ToolBox & ToolBar *******/