-r hyatt
This commit is contained in:
evaughan%netscape.com 2000-06-12 23:23:00 +00:00
Родитель c2f1ed3c3f
Коммит 02070c889c
14 изменённых файлов: 302 добавлений и 328 удалений

Просмотреть файл

@ -75,7 +75,6 @@
#include "nsIAttributeContent.h" #include "nsIAttributeContent.h"
#include "nsIPref.h" #include "nsIPref.h"
#include "nsLegendFrame.h" #include "nsLegendFrame.h"
#include "nsTitleFrame.h"
#include "nsIContentIterator.h" #include "nsIContentIterator.h"
#include "nsBoxLayoutState.h" #include "nsBoxLayoutState.h"
#include "nsIBindingManager.h" #include "nsIBindingManager.h"
@ -209,9 +208,6 @@ NS_NewTextBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
nsresult nsresult
NS_NewTitledBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame ); NS_NewTitledBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
nsresult
NS_NewTitledBoxInnerFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
nsresult nsresult
NS_NewTitleFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame ); NS_NewTitleFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
@ -4565,6 +4561,7 @@ nsCSSFrameConstructor::ConstructTitledBoxFrame(nsIPresShell* aPresShell,
nsIStyleContext* aStyleContext, nsIStyleContext* aStyleContext,
nsIFrame*& aNewFrame) nsIFrame*& aNewFrame)
{ {
/*
nsIFrame * newFrame; nsIFrame * newFrame;
nsresult rv = NS_NewTitledBoxFrame(aPresShell, &newFrame); nsresult rv = NS_NewTitledBoxFrame(aPresShell, &newFrame);
if (!NS_SUCCEEDED(rv)) { 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. // our new frame retured is the top frame which is the list frame.
aNewFrame = newFrame; aNewFrame = newFrame;
*/
return NS_OK; return NS_OK;
} }
@ -5811,8 +5808,10 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
else if (aTag == nsXULAtoms::titledbox) { else if (aTag == nsXULAtoms::titledbox) {
ConstructTitledBoxFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, aTag, aStyleContext, newFrame); rv = NS_NewTitledBoxFrame(aPresShell, &newFrame);
processChildren = PR_FALSE;
//ConstructTitledBoxFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, aTag, aStyleContext, newFrame);
processChildren = PR_TRUE;
isReplaced = PR_TRUE; isReplaced = PR_TRUE;
const nsStyleDisplay* display = (const nsStyleDisplay*) const nsStyleDisplay* display = (const nsStyleDisplay*)

Просмотреть файл

@ -75,7 +75,6 @@
#include "nsIAttributeContent.h" #include "nsIAttributeContent.h"
#include "nsIPref.h" #include "nsIPref.h"
#include "nsLegendFrame.h" #include "nsLegendFrame.h"
#include "nsTitleFrame.h"
#include "nsIContentIterator.h" #include "nsIContentIterator.h"
#include "nsBoxLayoutState.h" #include "nsBoxLayoutState.h"
#include "nsIBindingManager.h" #include "nsIBindingManager.h"
@ -209,9 +208,6 @@ NS_NewTextBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
nsresult nsresult
NS_NewTitledBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame ); NS_NewTitledBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
nsresult
NS_NewTitledBoxInnerFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
nsresult nsresult
NS_NewTitleFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame ); NS_NewTitleFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
@ -4565,6 +4561,7 @@ nsCSSFrameConstructor::ConstructTitledBoxFrame(nsIPresShell* aPresShell,
nsIStyleContext* aStyleContext, nsIStyleContext* aStyleContext,
nsIFrame*& aNewFrame) nsIFrame*& aNewFrame)
{ {
/*
nsIFrame * newFrame; nsIFrame * newFrame;
nsresult rv = NS_NewTitledBoxFrame(aPresShell, &newFrame); nsresult rv = NS_NewTitledBoxFrame(aPresShell, &newFrame);
if (!NS_SUCCEEDED(rv)) { 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. // our new frame retured is the top frame which is the list frame.
aNewFrame = newFrame; aNewFrame = newFrame;
*/
return NS_OK; return NS_OK;
} }
@ -5811,8 +5808,10 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
else if (aTag == nsXULAtoms::titledbox) { else if (aTag == nsXULAtoms::titledbox) {
ConstructTitledBoxFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, aTag, aStyleContext, newFrame); rv = NS_NewTitledBoxFrame(aPresShell, &newFrame);
processChildren = PR_FALSE;
//ConstructTitledBoxFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, aTag, aStyleContext, newFrame);
processChildren = PR_TRUE;
isReplaced = PR_TRUE; isReplaced = PR_TRUE;
const nsStyleDisplay* display = (const nsStyleDisplay*) const nsStyleDisplay* display = (const nsStyleDisplay*)

Просмотреть файл

@ -22,30 +22,6 @@
// YY need to pass isMultiple before create called // 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 "nsCSSRendering.h"
#include "nsIStyleContext.h" #include "nsIStyleContext.h"
#include "nsBoxFrame.h" #include "nsBoxFrame.h"
@ -55,10 +31,6 @@ public:
nsTitledBoxFrame(nsIPresShell* aShell); nsTitledBoxFrame(nsIPresShell* aShell);
NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList);
NS_IMETHOD GetBorderAndPadding(nsMargin& aBorderAndPadding); NS_IMETHOD GetBorderAndPadding(nsMargin& aBorderAndPadding);
@ -67,17 +39,6 @@ public:
const nsRect& aDirtyRect, const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer); 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 #ifdef DEBUG
NS_IMETHOD GetFrameName(nsString& aResult) const { NS_IMETHOD GetFrameName(nsString& aResult) const {
return MakeFrameName("GroupBoxFrame", aResult); return MakeFrameName("GroupBoxFrame", aResult);
@ -92,11 +53,10 @@ public:
virtual PRBool GetInitialVAlignment(Valignment& aValign) { aValign = vAlign_Top; return PR_TRUE; } virtual PRBool GetInitialVAlignment(Valignment& aValign) { aValign = vAlign_Top; return PR_TRUE; }
virtual PRBool GetInitialAutoStretch(PRBool& aStretch) { aStretch = PR_TRUE; return PR_TRUE; } virtual PRBool GetInitialAutoStretch(PRBool& aStretch) { aStretch = PR_TRUE; return PR_TRUE; }
nsIFrame* GetTitleFrame(nsIPresContext* aPresContext, nsRect& aRect); nsIBox* GetTitleBox(nsIPresContext* aPresContext, nsRect& aRect);
nsIFrame* GetContentFrame(nsIPresContext* aPresContext);
}; };
/*
class nsTitledBoxInnerFrame : public nsBoxFrame { class nsTitledBoxInnerFrame : public nsBoxFrame {
public: public:
@ -113,22 +73,7 @@ public:
virtual PRBool GetDefaultFlex(PRInt32& aFlex) { aFlex = 1; return PR_TRUE; } 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 nsresult
NS_NewTitledBoxFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) 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. // this is identical to nsHTMLContainerFrame::Paint except for the background and border.
NS_IMETHODIMP NS_IMETHODIMP
nsTitledBoxFrame::Paint(nsIPresContext* aPresContext, nsTitledBoxFrame::Paint(nsIPresContext* aPresContext,
@ -187,9 +123,12 @@ nsTitledBoxFrame::Paint(nsIPresContext* aPresContext,
nscoord yoff = 0; nscoord yoff = 0;
nsRect titleRect; 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 // if the border is smaller than the legend. Move the border down
// to be centered on the legend. // to be centered on the legend.
const nsStyleSpacing* titleSpacing; const nsStyleSpacing* titleSpacing;
@ -210,7 +149,7 @@ nsTitledBoxFrame::Paint(nsIPresContext* aPresContext,
aDirtyRect, rect, *color, *spacing, 0, 0); aDirtyRect, rect, *color, *spacing, 0, 0);
if (titleFrame) { if (titleBox) {
// we should probably use PaintBorderEdges to do this but for now just use clipping // we should probably use PaintBorderEdges to do this but for now just use clipping
// to achieve the same effect. // to achieve the same effect.
@ -284,26 +223,33 @@ nsTitledBoxFrame::Paint(nsIPresContext* aPresContext,
return NS_OK; return NS_OK;
} }
nsIFrame* nsIBox*
nsTitledBoxFrame::GetTitleFrame(nsIPresContext* aPresContext, nsRect& aTitleRect) nsTitledBoxFrame::GetTitleBox(nsIPresContext* aPresContext, nsRect& aTitleRect)
{ {
// if we only have one child fail // first child is out titled area
nsIFrame* frame = mFrames.FirstChild(); nsIBox* box;
nsIFrame* next = nsnull; GetChildBox(&box);
frame->GetNextSibling(&next);
if (!next) // no area fail.
if (!box)
return nsnull; return nsnull;
// if we have more than one child. The first is our baby. // get the first child in the titled area that is the title
// then get the first child inside. box->GetChildBox(&box);
nsIFrame* child;
frame->FirstChild(aPresContext, nsnull, &child); // 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) { if (child) {
// convert to our coordinates. // convert to our coordinates.
nsRect parentRect; nsRect parentRect;
frame->GetRect(parentRect); box->GetBounds(parentRect);
child->GetRect(aTitleRect); child->GetBounds(aTitleRect);
aTitleRect.x += parentRect.x; aTitleRect.x += parentRect.x;
aTitleRect.y += parentRect.y; aTitleRect.y += parentRect.y;
} }
@ -311,20 +257,6 @@ nsTitledBoxFrame::GetTitleFrame(nsIPresContext* aPresContext, nsRect& aTitleRect
return child; 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 NS_IMETHODIMP
nsTitledBoxFrame::GetBorderAndPadding(nsMargin& aBorderAndPadding) nsTitledBoxFrame::GetBorderAndPadding(nsMargin& aBorderAndPadding)
{ {
@ -332,27 +264,3 @@ nsTitledBoxFrame::GetBorderAndPadding(nsMargin& aBorderAndPadding)
return NS_OK; 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);
}

Просмотреть файл

@ -35,7 +35,7 @@
// ----- Monument Iterator ----- // ----- 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 PRBool
nsLayoutIterator::GetNextLayout(nsIBoxLayout** aLayout) nsLayoutIterator::GetNextLayout(nsIBoxLayout** aLayout, PRBool aSearchChildren)
{ {
if (mBox == nsnull) { if (mBox == nsnull) {
mBox = mStartBox; mBox = mStartBox;
} else {
if (aSearchChildren) {
mParents[mParentCount++] = mBox;
NS_ASSERTION(mParentCount < PARENT_STACK_SIZE, "Stack overflow!!");
mBox->GetChildBox(&mBox);
} else { } else {
mBox->GetNextBox(&mBox); mBox->GetNextBox(&mBox);
} }
}
return DigDeep(aLayout, aSearchChildren);
}
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 (!mBox) {
if (mParentCount > 0) {
if (mScrollFrameCount > 0) { mBox = mParents[--mParentCount];
mBox = mScrollFrames[--mScrollFrameCount]; mBox->GetNextBox(&mBox);
return GetNextLayout(aLayout); return DigDeep(aLayout, aSearchChildren);
} }
*aLayout = nsnull; *aLayout = nsnull;
return PR_FALSE; return PR_FALSE;
} }
// if its a scrollframe. Then continue down into the scrolled frame
nsresult rv = NS_OK; nsresult rv = NS_OK;
nsCOMPtr<nsIScrollableFrame> scrollFrame = do_QueryInterface(mBox, &rv); nsCOMPtr<nsIScrollableFrame> scrollFrame = do_QueryInterface(mBox, &rv);
if (scrollFrame) { if (scrollFrame) {
nsIFrame* scrolledFrame = nsnull; nsIFrame* scrolledFrame = nsnull;
scrollFrame->GetScrolledFrame(nsnull, scrolledFrame); scrollFrame->GetScrolledFrame(nsnull, scrolledFrame);
NS_ASSERTION(scrolledFrame,"Error no scroll frame!!"); NS_ASSERTION(scrolledFrame,"Error no scroll frame!!");
mScrollFrames[mScrollFrameCount++] = mBox; mParents[mParentCount++] = mBox;
NS_ASSERTION(mParentCount < PARENT_STACK_SIZE, "Stack overflow!!");
nsCOMPtr<nsIBox> b = do_QueryInterface(scrolledFrame); nsCOMPtr<nsIBox> b = do_QueryInterface(scrolledFrame);
mBox = b; mBox = b;
} }
// get the layout manager
nsCOMPtr<nsIBoxLayout> layout; nsCOMPtr<nsIBoxLayout> layout;
mBox->GetLayoutManager(getter_AddRefs(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; *aLayout = layout;
NS_IF_ADDREF(*aLayout); NS_IF_ADDREF(*aLayout);
if (layout)
return PR_TRUE; return PR_TRUE;
else
return PR_FALSE;
} }
// ---- Monument Iterator ----- // ---- Monument Iterator -----
nsMonumentIterator::nsMonumentIterator(nsIBox* aBox):nsLayoutIterator(aBox) nsMonumentIterator::nsMonumentIterator(nsIBox* aBox):nsLayoutIterator(aBox)
@ -94,11 +123,11 @@ nsMonumentIterator::nsMonumentIterator(nsIBox* aBox):nsLayoutIterator(aBox)
} }
PRBool PRBool
nsMonumentIterator::GetNextMonument(nsIMonument** aMonument) nsMonumentIterator::GetNextMonument(nsIMonument** aMonument, PRBool aSearchChildren)
{ {
nsCOMPtr<nsIBoxLayout> layout; nsCOMPtr<nsIBoxLayout> layout;
while(GetNextLayout(getter_AddRefs(layout))) { while(GetNextLayout(getter_AddRefs(layout), aSearchChildren)) {
if (layout) if (layout)
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
@ -115,6 +144,38 @@ nsMonumentIterator::GetNextMonument(nsIMonument** aMonument)
return PR_FALSE; return PR_FALSE;
} }
PRBool
nsMonumentIterator::GetNextObelisk(nsObeliskLayout** aObelisk, PRBool aSearchChildren)
{
nsCOMPtr<nsIMonument> 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 ---- //------ nsInfoListNodeImpl ----

Просмотреть файл

@ -37,27 +37,30 @@ class nsGridLayout;
class nsBoxLayoutState; class nsBoxLayoutState;
class nsIPresShell; class nsIPresShell;
#define PARENT_STACK_SIZE 100
class nsLayoutIterator class nsLayoutIterator
{ {
public: public:
nsLayoutIterator(nsIBox* aBox); nsLayoutIterator(nsIBox* aBox);
virtual void Reset(); 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 void GetBox(nsIBox** aBox) { *aBox = mBox; }
virtual PRBool DigDeep(nsIBoxLayout** aLayout, PRBool aSearchChildren);
protected: protected:
nsIBox* mBox; nsIBox* mBox;
nsIBox* mStartBox; nsIBox* mStartBox;
PRInt32 mScrollFrameCount; PRInt32 mParentCount;
nsIBox* mScrollFrames[100]; nsIBox* mParents[PARENT_STACK_SIZE];
}; };
class nsMonumentIterator: public nsLayoutIterator class nsMonumentIterator: public nsLayoutIterator
{ {
public: public:
nsMonumentIterator(nsIBox* aBox); 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 class nsBoxSizeListNodeImpl : public nsBoxSizeList

Просмотреть файл

@ -120,15 +120,76 @@ nsObeliskLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSi
NS_IMETHODIMP NS_IMETHODIMP
nsObeliskLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSize) 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); UpdateMonuments(aBox, aState);
nsBoxSizeList* node = mOtherMonumentList; nsBoxSizeList* node = mOtherMonumentList;
PRBool isHorizontal = PR_FALSE;
aBox->GetOrientation(isHorizontal);
if (node) { if (node) {
// if the infos pref width is greater than aSize's use it. // if the infos pref width is greater than aSize's use it.
// if the infos min 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; s2 = s;
} }
return rv; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP

Просмотреть файл

@ -234,3 +234,13 @@ nsTempleLayout::DesecrateMonuments(nsIBox* aBox, nsBoxLayoutState& aState)
return NS_OK; 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);
}

Просмотреть файл

@ -46,6 +46,7 @@ public:
NS_IMETHOD ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList); NS_IMETHOD ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList);
NS_IMETHOD DesecrateMonuments(nsIBox* aBox, nsBoxLayoutState& aState); NS_IMETHOD DesecrateMonuments(nsIBox* aBox, nsBoxLayoutState& aState);
NS_IMETHOD EnscriptionChanged(nsBoxLayoutState& aState, PRInt32 aIndex); NS_IMETHOD EnscriptionChanged(nsBoxLayoutState& aState, PRInt32 aIndex);
NS_IMETHOD GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
protected: protected:

Просмотреть файл

@ -24,25 +24,6 @@
#include "nsTitleFrame.h" #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 nsresult
NS_NewTitleFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) 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 #ifdef NS_DEBUG
NS_IMETHODIMP NS_IMETHODIMP
nsTitleFrame::GetFrameName(nsString& aResult) const nsTitleFrame::GetFrameName(nsString& aResult) const

Просмотреть файл

@ -25,16 +25,10 @@
#include "nsBoxFrame.h" #include "nsBoxFrame.h"
#define NS_TITLE_FRAME_CID \
{ 0x73801d40, 0x5a22, 0x12d2, { 0x80, 0x46, 0x0, 0x60, 0x2, 0x14, 0xa7, 0x90 } }
class nsTitleFrame : public nsBoxFrame { class nsTitleFrame : public nsBoxFrame {
public: public:
nsTitleFrame(nsIPresShell* aShell); nsTitleFrame(nsIPresShell* aShell);
virtual ~nsTitleFrame();
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
// we are always a vertical box. // we are always a vertical box.
virtual PRBool GetInitialOrientation(PRBool& aIsHorizontal) { aIsHorizontal = PR_FALSE; return PR_TRUE; } virtual PRBool GetInitialOrientation(PRBool& aIsHorizontal) { aIsHorizontal = PR_FALSE; return PR_TRUE; }
@ -42,6 +36,9 @@ public:
// never autostretch we align out children. // never autostretch we align out children.
virtual PRBool GetInitialAutoStretch(PRBool& aStretch) { aStretch = PR_FALSE; return PR_TRUE; } 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 #ifdef NS_DEBUG
NS_IMETHOD GetFrameName(nsString& aResult) const; NS_IMETHOD GetFrameName(nsString& aResult) const;
#endif #endif

Просмотреть файл

@ -22,30 +22,6 @@
// YY need to pass isMultiple before create called // 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 "nsCSSRendering.h"
#include "nsIStyleContext.h" #include "nsIStyleContext.h"
#include "nsBoxFrame.h" #include "nsBoxFrame.h"
@ -55,10 +31,6 @@ public:
nsTitledBoxFrame(nsIPresShell* aShell); nsTitledBoxFrame(nsIPresShell* aShell);
NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList);
NS_IMETHOD GetBorderAndPadding(nsMargin& aBorderAndPadding); NS_IMETHOD GetBorderAndPadding(nsMargin& aBorderAndPadding);
@ -67,17 +39,6 @@ public:
const nsRect& aDirtyRect, const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer); 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 #ifdef DEBUG
NS_IMETHOD GetFrameName(nsString& aResult) const { NS_IMETHOD GetFrameName(nsString& aResult) const {
return MakeFrameName("GroupBoxFrame", aResult); return MakeFrameName("GroupBoxFrame", aResult);
@ -92,11 +53,10 @@ public:
virtual PRBool GetInitialVAlignment(Valignment& aValign) { aValign = vAlign_Top; return PR_TRUE; } virtual PRBool GetInitialVAlignment(Valignment& aValign) { aValign = vAlign_Top; return PR_TRUE; }
virtual PRBool GetInitialAutoStretch(PRBool& aStretch) { aStretch = PR_TRUE; return PR_TRUE; } virtual PRBool GetInitialAutoStretch(PRBool& aStretch) { aStretch = PR_TRUE; return PR_TRUE; }
nsIFrame* GetTitleFrame(nsIPresContext* aPresContext, nsRect& aRect); nsIBox* GetTitleBox(nsIPresContext* aPresContext, nsRect& aRect);
nsIFrame* GetContentFrame(nsIPresContext* aPresContext);
}; };
/*
class nsTitledBoxInnerFrame : public nsBoxFrame { class nsTitledBoxInnerFrame : public nsBoxFrame {
public: public:
@ -113,22 +73,7 @@ public:
virtual PRBool GetDefaultFlex(PRInt32& aFlex) { aFlex = 1; return PR_TRUE; } 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 nsresult
NS_NewTitledBoxFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) 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. // this is identical to nsHTMLContainerFrame::Paint except for the background and border.
NS_IMETHODIMP NS_IMETHODIMP
nsTitledBoxFrame::Paint(nsIPresContext* aPresContext, nsTitledBoxFrame::Paint(nsIPresContext* aPresContext,
@ -187,9 +123,12 @@ nsTitledBoxFrame::Paint(nsIPresContext* aPresContext,
nscoord yoff = 0; nscoord yoff = 0;
nsRect titleRect; 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 // if the border is smaller than the legend. Move the border down
// to be centered on the legend. // to be centered on the legend.
const nsStyleSpacing* titleSpacing; const nsStyleSpacing* titleSpacing;
@ -210,7 +149,7 @@ nsTitledBoxFrame::Paint(nsIPresContext* aPresContext,
aDirtyRect, rect, *color, *spacing, 0, 0); aDirtyRect, rect, *color, *spacing, 0, 0);
if (titleFrame) { if (titleBox) {
// we should probably use PaintBorderEdges to do this but for now just use clipping // we should probably use PaintBorderEdges to do this but for now just use clipping
// to achieve the same effect. // to achieve the same effect.
@ -284,26 +223,33 @@ nsTitledBoxFrame::Paint(nsIPresContext* aPresContext,
return NS_OK; return NS_OK;
} }
nsIFrame* nsIBox*
nsTitledBoxFrame::GetTitleFrame(nsIPresContext* aPresContext, nsRect& aTitleRect) nsTitledBoxFrame::GetTitleBox(nsIPresContext* aPresContext, nsRect& aTitleRect)
{ {
// if we only have one child fail // first child is out titled area
nsIFrame* frame = mFrames.FirstChild(); nsIBox* box;
nsIFrame* next = nsnull; GetChildBox(&box);
frame->GetNextSibling(&next);
if (!next) // no area fail.
if (!box)
return nsnull; return nsnull;
// if we have more than one child. The first is our baby. // get the first child in the titled area that is the title
// then get the first child inside. box->GetChildBox(&box);
nsIFrame* child;
frame->FirstChild(aPresContext, nsnull, &child); // 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) { if (child) {
// convert to our coordinates. // convert to our coordinates.
nsRect parentRect; nsRect parentRect;
frame->GetRect(parentRect); box->GetBounds(parentRect);
child->GetRect(aTitleRect); child->GetBounds(aTitleRect);
aTitleRect.x += parentRect.x; aTitleRect.x += parentRect.x;
aTitleRect.y += parentRect.y; aTitleRect.y += parentRect.y;
} }
@ -311,20 +257,6 @@ nsTitledBoxFrame::GetTitleFrame(nsIPresContext* aPresContext, nsRect& aTitleRect
return child; 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 NS_IMETHODIMP
nsTitledBoxFrame::GetBorderAndPadding(nsMargin& aBorderAndPadding) nsTitledBoxFrame::GetBorderAndPadding(nsMargin& aBorderAndPadding)
{ {
@ -332,27 +264,3 @@ nsTitledBoxFrame::GetBorderAndPadding(nsMargin& aBorderAndPadding)
return NS_OK; 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);
}

Просмотреть файл

@ -105,6 +105,28 @@ vbox {
behavior: url(chrome://global/content/xulBindings.xml#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 & ToolBar *******/
toolbox { toolbox {

Просмотреть файл

@ -554,5 +554,33 @@
</interface> </interface>
</binding> </binding>
<binding id="titledbox">
<content>
<xul:box class="titledbox-title">
<children includes="title"/>
</xul:box>
<xul:box flex="1" class="titledbox-body" inherits="orient,autostretch,align,valign">
<children/>
</xul:box>
</content>
</binding>
<binding id="titledboxvalue">
<content>
<xul:box class="titledbox-title">
<xul:title inherits="value"/>
</xul:box>
<xul:box flex="1" class="titledbox-body" inherits="orient,autostretch,align,valign">
<children/>
</xul:box>
</content>
</binding>
<binding id="title">
<content>
<xul:text inherits="value"/>
</content>
</binding>
</bindings> </bindings>

Просмотреть файл

@ -85,6 +85,23 @@ browser, editor, iframe {
/******** Box *******/ /******** 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 *******/ /******* ToolBox & ToolBar *******/