зеркало из https://github.com/mozilla/gecko-dev.git
1) Bug fixes.
2) Changed to fix rods text control 3) Added new Grid widget
This commit is contained in:
Родитель
9e09ad2f78
Коммит
6a2ad59407
|
@ -157,23 +157,9 @@ nsresult
|
|||
NS_NewGfxListControlFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
#endif
|
||||
|
||||
// grid
|
||||
|
||||
/*
|
||||
nsresult
|
||||
NS_NewGridFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
|
||||
nsresult
|
||||
NS_NewTempleFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRBool aIsHorizontal);
|
||||
|
||||
nsresult
|
||||
NS_NewObeliskFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRBool aIsHorizontal);
|
||||
|
||||
// end grid
|
||||
*/
|
||||
|
||||
nsresult
|
||||
NS_NewRootBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
NS_NewRootBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame);
|
||||
|
||||
nsresult
|
||||
NS_NewThumbFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
|
@ -188,13 +174,13 @@ nsresult
|
|||
NS_NewTabFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
|
||||
nsresult
|
||||
NS_NewDeckFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
NS_NewDeckFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame, nsIBoxLayout* aLayoutManager = nsnull);
|
||||
|
||||
nsresult
|
||||
NS_NewSpringFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
|
||||
nsresult
|
||||
NS_NewStackFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
NS_NewStackFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame, nsIBoxLayout* aLayoutManager = nsnull);
|
||||
|
||||
nsresult
|
||||
NS_NewProgressMeterFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
|
@ -217,9 +203,6 @@ NS_NewTitledBoxInnerFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
|||
nsresult
|
||||
NS_NewTitleFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
|
||||
nsresult
|
||||
NS_NewBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRBool aIsRoot);
|
||||
|
||||
nsresult
|
||||
NS_NewButtonBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame);
|
||||
|
||||
|
@ -262,6 +245,18 @@ NS_NewMenuFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRUint32 aFlag
|
|||
nsresult
|
||||
NS_NewMenuBarFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
|
||||
// grid
|
||||
nsresult
|
||||
NS_NewGridLayout ( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout );
|
||||
|
||||
nsresult
|
||||
NS_NewObeliskLayout ( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout );
|
||||
|
||||
nsresult
|
||||
NS_NewTempleLayout ( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout );
|
||||
|
||||
// end grid
|
||||
|
||||
#endif
|
||||
|
||||
//static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID);
|
||||
|
@ -5412,13 +5407,13 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
|
|||
rv = NS_NewMenuPopupFrame(aPresShell, &newFrame);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
// ------- Begin Grid ---------
|
||||
else if (aTag == nsXULAtoms::grid) {
|
||||
processChildren = PR_TRUE;
|
||||
isReplaced = PR_TRUE;
|
||||
rv = NS_NewGridFrame(aPresShell, &newFrame);
|
||||
nsCOMPtr<nsIBoxLayout> layout;
|
||||
NS_NewGridLayout(aPresShell, layout);
|
||||
rv = NS_NewBoxFrame(aPresShell, &newFrame, PR_FALSE, layout);
|
||||
|
||||
const nsStyleDisplay* display = (const nsStyleDisplay*)
|
||||
aStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
@ -5445,7 +5440,10 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
|
|||
processChildren = PR_TRUE;
|
||||
isReplaced = PR_TRUE;
|
||||
PRBool isHorizontal = (aTag == nsXULAtoms::columns);
|
||||
rv = NS_NewTempleFrame(aPresShell, &newFrame, isHorizontal);
|
||||
|
||||
nsCOMPtr<nsIBoxLayout> layout;
|
||||
NS_NewTempleLayout(aPresShell, layout);
|
||||
rv = NS_NewBoxFrame(aPresShell, &newFrame, PR_FALSE, layout, isHorizontal);
|
||||
|
||||
const nsStyleDisplay* display = (const nsStyleDisplay*)
|
||||
aStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
@ -5472,7 +5470,9 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
|
|||
processChildren = PR_TRUE;
|
||||
isReplaced = PR_TRUE;
|
||||
PRBool isHorizontal = (aTag == nsXULAtoms::row);
|
||||
rv = NS_NewObeliskFrame(aPresShell, &newFrame, isHorizontal);
|
||||
nsCOMPtr<nsIBoxLayout> layout;
|
||||
NS_NewObeliskLayout(aPresShell, layout);
|
||||
rv = NS_NewBoxFrame(aPresShell, &newFrame, PR_FALSE, layout, isHorizontal);
|
||||
|
||||
const nsStyleDisplay* display = (const nsStyleDisplay*)
|
||||
aStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
@ -5493,7 +5493,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
|
|||
|
||||
}
|
||||
} //------- End Grid ------
|
||||
*/
|
||||
|
||||
else if (aTag == nsXULAtoms::title) {
|
||||
processChildren = PR_TRUE;
|
||||
isReplaced = PR_TRUE;
|
||||
|
|
|
@ -521,6 +521,37 @@ nsGfxScrollFrame::GetMaxSize(nsBoxLayoutState& aState, nsSize& aSize)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxScrollFrame::Reflow(nsIPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
nsresult rv = nsBoxFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
||||
|
||||
/*
|
||||
// max sure the max element size reflects
|
||||
// our min width
|
||||
if (aDesiredSize.maxElementSize)
|
||||
{
|
||||
// get the ara frame is the scrollarea
|
||||
nsIBox* child = nsnull;
|
||||
mInner->mScrollAreaBox->GetChildBox(&child);
|
||||
nsBoxLayoutState state(aPresContext, aReflowState, aDesiredSize);
|
||||
nsSize minSize(0,0);
|
||||
child->GetMinSize(state, minSize);
|
||||
AddMargin(child, minSize);
|
||||
AddBorderAndPadding(mInner->mScrollAreaBox, minSize);
|
||||
AddInset(mInner->mScrollAreaBox, minSize);
|
||||
AddBorderAndPadding(minSize);
|
||||
AddInset(minSize);
|
||||
aDesiredSize.maxElementSize->width += minSize.width;
|
||||
}
|
||||
*/
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsGfxScrollFrame::AddRef(void)
|
||||
{
|
||||
|
|
|
@ -62,6 +62,11 @@ public:
|
|||
nsIAtom* aListName,
|
||||
nsIFrame* aChildList);
|
||||
|
||||
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus);
|
||||
|
||||
// Because there can be only one child frame, these two function return
|
||||
// NS_ERROR_FAILURE
|
||||
NS_IMETHOD AppendFrames(nsIPresContext* aPresContext,
|
||||
|
|
|
@ -521,6 +521,37 @@ nsGfxScrollFrame::GetMaxSize(nsBoxLayoutState& aState, nsSize& aSize)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxScrollFrame::Reflow(nsIPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
nsresult rv = nsBoxFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
||||
|
||||
/*
|
||||
// max sure the max element size reflects
|
||||
// our min width
|
||||
if (aDesiredSize.maxElementSize)
|
||||
{
|
||||
// get the ara frame is the scrollarea
|
||||
nsIBox* child = nsnull;
|
||||
mInner->mScrollAreaBox->GetChildBox(&child);
|
||||
nsBoxLayoutState state(aPresContext, aReflowState, aDesiredSize);
|
||||
nsSize minSize(0,0);
|
||||
child->GetMinSize(state, minSize);
|
||||
AddMargin(child, minSize);
|
||||
AddBorderAndPadding(mInner->mScrollAreaBox, minSize);
|
||||
AddInset(mInner->mScrollAreaBox, minSize);
|
||||
AddBorderAndPadding(minSize);
|
||||
AddInset(minSize);
|
||||
aDesiredSize.maxElementSize->width += minSize.width;
|
||||
}
|
||||
*/
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsGfxScrollFrame::AddRef(void)
|
||||
{
|
||||
|
|
|
@ -62,6 +62,11 @@ public:
|
|||
nsIAtom* aListName,
|
||||
nsIFrame* aChildList);
|
||||
|
||||
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus);
|
||||
|
||||
// Because there can be only one child frame, these two function return
|
||||
// NS_ERROR_FAILURE
|
||||
NS_IMETHOD AppendFrames(nsIPresContext* aPresContext,
|
||||
|
|
|
@ -157,23 +157,9 @@ nsresult
|
|||
NS_NewGfxListControlFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
#endif
|
||||
|
||||
// grid
|
||||
|
||||
/*
|
||||
nsresult
|
||||
NS_NewGridFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
|
||||
nsresult
|
||||
NS_NewTempleFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRBool aIsHorizontal);
|
||||
|
||||
nsresult
|
||||
NS_NewObeliskFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRBool aIsHorizontal);
|
||||
|
||||
// end grid
|
||||
*/
|
||||
|
||||
nsresult
|
||||
NS_NewRootBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
NS_NewRootBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame);
|
||||
|
||||
nsresult
|
||||
NS_NewThumbFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
|
@ -188,13 +174,13 @@ nsresult
|
|||
NS_NewTabFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
|
||||
nsresult
|
||||
NS_NewDeckFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
NS_NewDeckFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame, nsIBoxLayout* aLayoutManager = nsnull);
|
||||
|
||||
nsresult
|
||||
NS_NewSpringFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
|
||||
nsresult
|
||||
NS_NewStackFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
NS_NewStackFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame, nsIBoxLayout* aLayoutManager = nsnull);
|
||||
|
||||
nsresult
|
||||
NS_NewProgressMeterFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
|
@ -217,9 +203,6 @@ NS_NewTitledBoxInnerFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
|||
nsresult
|
||||
NS_NewTitleFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
|
||||
nsresult
|
||||
NS_NewBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRBool aIsRoot);
|
||||
|
||||
nsresult
|
||||
NS_NewButtonBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame);
|
||||
|
||||
|
@ -262,6 +245,18 @@ NS_NewMenuFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRUint32 aFlag
|
|||
nsresult
|
||||
NS_NewMenuBarFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame );
|
||||
|
||||
// grid
|
||||
nsresult
|
||||
NS_NewGridLayout ( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout );
|
||||
|
||||
nsresult
|
||||
NS_NewObeliskLayout ( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout );
|
||||
|
||||
nsresult
|
||||
NS_NewTempleLayout ( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout );
|
||||
|
||||
// end grid
|
||||
|
||||
#endif
|
||||
|
||||
//static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID);
|
||||
|
@ -5412,13 +5407,13 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
|
|||
rv = NS_NewMenuPopupFrame(aPresShell, &newFrame);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
// ------- Begin Grid ---------
|
||||
else if (aTag == nsXULAtoms::grid) {
|
||||
processChildren = PR_TRUE;
|
||||
isReplaced = PR_TRUE;
|
||||
rv = NS_NewGridFrame(aPresShell, &newFrame);
|
||||
nsCOMPtr<nsIBoxLayout> layout;
|
||||
NS_NewGridLayout(aPresShell, layout);
|
||||
rv = NS_NewBoxFrame(aPresShell, &newFrame, PR_FALSE, layout);
|
||||
|
||||
const nsStyleDisplay* display = (const nsStyleDisplay*)
|
||||
aStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
@ -5445,7 +5440,10 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
|
|||
processChildren = PR_TRUE;
|
||||
isReplaced = PR_TRUE;
|
||||
PRBool isHorizontal = (aTag == nsXULAtoms::columns);
|
||||
rv = NS_NewTempleFrame(aPresShell, &newFrame, isHorizontal);
|
||||
|
||||
nsCOMPtr<nsIBoxLayout> layout;
|
||||
NS_NewTempleLayout(aPresShell, layout);
|
||||
rv = NS_NewBoxFrame(aPresShell, &newFrame, PR_FALSE, layout, isHorizontal);
|
||||
|
||||
const nsStyleDisplay* display = (const nsStyleDisplay*)
|
||||
aStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
@ -5472,7 +5470,9 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
|
|||
processChildren = PR_TRUE;
|
||||
isReplaced = PR_TRUE;
|
||||
PRBool isHorizontal = (aTag == nsXULAtoms::row);
|
||||
rv = NS_NewObeliskFrame(aPresShell, &newFrame, isHorizontal);
|
||||
nsCOMPtr<nsIBoxLayout> layout;
|
||||
NS_NewObeliskLayout(aPresShell, layout);
|
||||
rv = NS_NewBoxFrame(aPresShell, &newFrame, PR_FALSE, layout, isHorizontal);
|
||||
|
||||
const nsStyleDisplay* display = (const nsStyleDisplay*)
|
||||
aStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
|
@ -5493,7 +5493,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
|
|||
|
||||
}
|
||||
} //------- End Grid ------
|
||||
*/
|
||||
|
||||
else if (aTag == nsXULAtoms::title) {
|
||||
processChildren = PR_TRUE;
|
||||
isReplaced = PR_TRUE;
|
||||
|
|
|
@ -28,6 +28,10 @@ REQUIRES=xpcom raptor pref
|
|||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
CPPSRCS= \
|
||||
nsGridLayout.cpp \
|
||||
nsTempleLayout.cpp \
|
||||
nsObeliskLayout.cpp \
|
||||
nsMonumentLayout.cpp \
|
||||
nsImageBoxFrame.cpp \
|
||||
nsRootBoxFrame.cpp \
|
||||
nsStackLayout.cpp \
|
||||
|
@ -83,6 +87,10 @@ CPPSRCS= \
|
|||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsGridLayout.obj \
|
||||
.\$(OBJDIR)\nsTempleLayout.obj \
|
||||
.\$(OBJDIR)\nsObeliskLayout.obj \
|
||||
.\$(OBJDIR)\nsMonumentLayout.obj \
|
||||
.\$(OBJDIR)\nsImageBoxFrame.obj \
|
||||
.\$(OBJDIR)\nsRootBoxFrame.obj \
|
||||
.\$(OBJDIR)\nsStackLayout.obj \
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "nsHTMLAtoms.h"
|
||||
#include "nsXULAtoms.h"
|
||||
|
||||
nsBox::nsBox(nsIPresShell* aShell):mParentBox(nsnull),mNextChild(nsnull),mMouseThrough(always)
|
||||
nsBox::nsBox(nsIPresShell* aShell):mParentBox(nsnull),mNextChild(nsnull),mMouseThrough(sometimes)
|
||||
{
|
||||
//mX = 0;
|
||||
//mY = 0;
|
||||
|
|
|
@ -172,7 +172,6 @@ public:
|
|||
static PRBool gDebug;
|
||||
static nsIBox* mDebugChild;
|
||||
|
||||
|
||||
#ifdef DEBUG_REFLOW
|
||||
PRInt32 reflowCount;
|
||||
#endif
|
||||
|
@ -190,28 +189,33 @@ PRInt32 gReflows = 0;
|
|||
#endif
|
||||
|
||||
nsresult
|
||||
NS_NewBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRBool aIsRoot)
|
||||
NS_NewBoxFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRBool aIsRoot, nsIBoxLayout* aLayoutManager, PRBool aIsHorizontal)
|
||||
{
|
||||
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
||||
if (nsnull == aNewFrame) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsBoxFrame* it = new (aPresShell) nsBoxFrame(aPresShell, aIsRoot);
|
||||
nsBoxFrame* it = new (aPresShell) nsBoxFrame(aPresShell, aIsRoot, aLayoutManager, aIsHorizontal);
|
||||
|
||||
if (nsnull == it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*aNewFrame = it;
|
||||
|
||||
return NS_OK;
|
||||
|
||||
} // NS_NewBoxFrame
|
||||
|
||||
nsBoxFrame::nsBoxFrame(nsIPresShell* aPresShell, PRBool aIsRoot):nsContainerBox(aPresShell)
|
||||
nsBoxFrame::nsBoxFrame(nsIPresShell* aPresShell, PRBool aIsRoot, nsIBoxLayout* aLayoutManager, PRBool aIsHorizontal):nsContainerBox(aPresShell)
|
||||
{
|
||||
mInner = new (aPresShell) nsBoxFrameInner(aPresShell, this);
|
||||
|
||||
// if not otherwise specified boxes by default are horizontal.
|
||||
mState |= NS_STATE_IS_HORIZONTAL;
|
||||
if (aIsHorizontal) {
|
||||
mState |= NS_STATE_IS_HORIZONTAL;
|
||||
mState |= NS_STATE_DEFAULT_HORIZONTAL;
|
||||
}
|
||||
|
||||
mState |= NS_STATE_AUTO_STRETCH;
|
||||
|
||||
if (aIsRoot)
|
||||
|
@ -223,9 +227,22 @@ nsBoxFrame::nsBoxFrame(nsIPresShell* aPresShell, PRBool aIsRoot):nsContainerBox(
|
|||
|
||||
NeedsRecalc();
|
||||
|
||||
nsSprocketLayout* layout = new nsSprocketLayout(aPresShell);
|
||||
|
||||
#ifdef DEBUG_REFLOW
|
||||
mInner->reflowCount = 100;
|
||||
#endif
|
||||
|
||||
// if no layout manager specified us the static sprocket layout
|
||||
nsCOMPtr<nsIBoxLayout> layout = aLayoutManager;
|
||||
|
||||
if (layout == nsnull) {
|
||||
NS_NewSprocketLayout(aPresShell, layout);
|
||||
}
|
||||
|
||||
SetLayoutManager(layout);
|
||||
|
||||
NeedsRecalc();
|
||||
|
||||
#ifdef DEBUG_REFLOW
|
||||
mInner->reflowCount = 100;
|
||||
#endif
|
||||
|
@ -302,7 +319,10 @@ nsBoxFrame::Init(nsIPresContext* aPresContext,
|
|||
GetInitialVAlignment(mInner->mValign);
|
||||
GetInitialHAlignment(mInner->mHalign);
|
||||
|
||||
PRBool orient = mState & NS_STATE_IS_HORIZONTAL;
|
||||
PRBool orient = PR_FALSE;
|
||||
if (mState & NS_STATE_DEFAULT_HORIZONTAL)
|
||||
orient = PR_TRUE;
|
||||
|
||||
GetInitialOrientation(orient);
|
||||
if (orient)
|
||||
mState |= NS_STATE_IS_HORIZONTAL;
|
||||
|
@ -605,7 +625,7 @@ nsBoxFrame::Reflow(nsIPresContext* aPresContext,
|
|||
nsBoxLayoutState state(aPresContext, aReflowState, aDesiredSize);
|
||||
|
||||
// coelesce reflows if we are root.
|
||||
if (state.HandleReflow(this, (mState & NS_STATE_IS_ROOT))) {
|
||||
if (state.HandleReflow(this, mState & NS_STATE_IS_ROOT)) {
|
||||
aDesiredSize.width = 10;
|
||||
aDesiredSize.height = 10;
|
||||
aDesiredSize.ascent = 0;
|
||||
|
@ -631,8 +651,8 @@ nsBoxFrame::Reflow(nsIPresContext* aPresContext,
|
|||
|
||||
// if we are told to layout intrinic then get our preferred size.
|
||||
if (computedSize.width == NS_INTRINSICSIZE || computedSize.height == NS_INTRINSICSIZE) {
|
||||
nsSize minSize;
|
||||
nsSize maxSize;
|
||||
nsSize minSize(0,0);
|
||||
nsSize maxSize(0,0);
|
||||
GetPrefSize(state, prefSize);
|
||||
GetMinSize(state, minSize);
|
||||
GetMaxSize(state, maxSize);
|
||||
|
@ -676,6 +696,20 @@ nsBoxFrame::Reflow(nsIPresContext* aPresContext,
|
|||
aDesiredSize.ascent = ascent;
|
||||
aDesiredSize.descent = 0;
|
||||
|
||||
// max sure the max element size reflects
|
||||
// our min width
|
||||
nsSize* size = nsnull;
|
||||
state.GetMaxElementSize(&size);
|
||||
if (size)
|
||||
{
|
||||
nsSize minSize(0,0);
|
||||
GetMinSize(state, minSize);
|
||||
if (mRect.width < minSize.width)
|
||||
size->width = minSize.width;
|
||||
else
|
||||
size->width = mRect.width;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,12 +56,18 @@ class nsHTMLInfo;
|
|||
#define NS_STATE_SET_TO_DEBUG 0x04000000
|
||||
#define NS_STATE_DEBUG_WAS_SET 0x08000000
|
||||
#define NS_STATE_IS_COLLAPSED 0x10000000
|
||||
#define NS_STATE_DEFAULT_HORIZONTAL 0x20000000
|
||||
|
||||
class nsBoxFrame : public nsHTMLContainerFrame, public nsContainerBox
|
||||
{
|
||||
public:
|
||||
|
||||
friend nsresult NS_NewBoxFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRBool aIsRoot = PR_FALSE);
|
||||
friend nsresult NS_NewBoxFrame(nsIPresShell* aPresShell,
|
||||
nsIFrame** aNewFrame,
|
||||
PRBool aIsRoot = PR_FALSE,
|
||||
nsIBoxLayout* aLayoutManager = nsnull,
|
||||
PRBool aDefaultHorizontal = PR_TRUE);
|
||||
|
||||
// gets the rect inside our border and debug border. If you wish to paint inside a box
|
||||
// call this method to get the rect so you don't draw on the debug border or outer border.
|
||||
|
||||
|
@ -159,8 +165,9 @@ public:
|
|||
|
||||
virtual nsresult GetContentOf(nsIContent** aContent);
|
||||
|
||||
nsBoxFrame(nsIPresShell* aPresShell, PRBool aIsRoot = nsnull, nsIBoxLayout* aLayoutManager = nsnull, PRBool aDefaultHorizontal = PR_TRUE);
|
||||
|
||||
protected:
|
||||
nsBoxFrame(nsIPresShell* aPresShell, PRBool aIsRoot = PR_FALSE);
|
||||
|
||||
virtual void PropagateDebug(nsBoxLayoutState& aState);
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ nsBoxLayout::GetParentLayout(nsIBox* aBox, nsIBoxLayout** aParent)
|
|||
aBox->GetParentBox(&parent);
|
||||
if (parent)
|
||||
{
|
||||
aBox->GetLayoutManager(aParent);
|
||||
parent->GetLayoutManager(aParent);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -156,15 +156,19 @@ nsBoxLayoutState::UnWind(nsIReflowCommand* aCommand, nsIBox* aBox, PRBool aCoele
|
|||
// ok we got a box is it the target?
|
||||
if (incrementalChild == target) {
|
||||
|
||||
if (!aCoelesce) {
|
||||
nsFrameState state;
|
||||
nsIFrame* frame;
|
||||
aBox->GetFrame(&frame);
|
||||
frame->GetFrameState(&state);
|
||||
nsFrameState state;
|
||||
nsIFrame* frame;
|
||||
aBox->GetFrame(&frame);
|
||||
frame->GetFrameState(&state);
|
||||
|
||||
if (aCoelesce)
|
||||
state &= ~NS_FRAME_HAS_DIRTY_CHILDREN;
|
||||
else
|
||||
state |= NS_FRAME_HAS_DIRTY_CHILDREN;
|
||||
frame->SetFrameState(state);
|
||||
}
|
||||
// the target is a box?
|
||||
|
||||
frame->SetFrameState(state);
|
||||
|
||||
// the target is a box?
|
||||
// mark it dirty generating a new reflow command targeted
|
||||
// at us and coelesce out this one.
|
||||
ibox->MarkDirty(*this);
|
||||
|
@ -175,7 +179,7 @@ nsBoxLayoutState::UnWind(nsIReflowCommand* aCommand, nsIBox* aBox, PRBool aCoele
|
|||
nsIBox* parent;
|
||||
ibox->GetParentBox(&parent);
|
||||
parent->MarkDirty(*this);
|
||||
//DirtyAllChildren(*this, box);
|
||||
DirtyAllChildren(*this, ibox);
|
||||
}
|
||||
|
||||
// yes we coelesed
|
||||
|
|
|
@ -170,9 +170,6 @@ nsBoxToBlockAdaptor::GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize)
|
|||
if (currentSize) {
|
||||
desiredSize.maxElementSize = nsnull;
|
||||
|
||||
if (size.width > currentSize->width)
|
||||
currentSize->width = size.width;
|
||||
|
||||
if (size.height > currentSize->height)
|
||||
currentSize->height = size.height;
|
||||
}
|
||||
|
@ -315,10 +312,7 @@ nsBoxToBlockAdaptor::Layout(nsBoxLayoutState& aState)
|
|||
desiredSize.maxElementSize = nsnull;
|
||||
|
||||
if (size.width > currentSize->width)
|
||||
currentSize->width = size.width;
|
||||
|
||||
if (size.height > currentSize->height)
|
||||
currentSize->height = size.height;
|
||||
currentSize->width = size.width;
|
||||
}
|
||||
|
||||
mAscent = desiredSize.ascent;
|
||||
|
|
|
@ -47,17 +47,16 @@
|
|||
#include "nsStackLayout.h"
|
||||
|
||||
nsresult
|
||||
NS_NewDeckFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame )
|
||||
NS_NewDeckFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame, nsIBoxLayout* aLayoutManager)
|
||||
{
|
||||
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
||||
if (nsnull == aNewFrame) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsDeckFrame* it = new (aPresShell) nsDeckFrame(aPresShell);
|
||||
nsDeckFrame* it = new (aPresShell) nsDeckFrame(aPresShell, aLayoutManager);
|
||||
if (nsnull == it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
|
||||
|
@ -66,12 +65,16 @@ NS_NewDeckFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame )
|
|||
|
||||
nsCOMPtr<nsIBoxLayout> nsDeckFrame::gLayout = nsnull;
|
||||
|
||||
nsDeckFrame::nsDeckFrame(nsIPresShell* aPresShell):nsBoxFrame(aPresShell)
|
||||
nsDeckFrame::nsDeckFrame(nsIPresShell* aPresShell, nsIBoxLayout* aLayoutManager):nsBoxFrame(aPresShell)
|
||||
{
|
||||
if (!gLayout)
|
||||
gLayout = new nsStackLayout(aPresShell);
|
||||
// if no layout manager specified us the static sprocket layout
|
||||
nsCOMPtr<nsIBoxLayout> layout = aLayoutManager;
|
||||
|
||||
SetLayoutManager(gLayout);
|
||||
if (layout == nsnull) {
|
||||
NS_NewStackLayout(aPresShell, layout);
|
||||
}
|
||||
|
||||
SetLayoutManager(layout);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -37,7 +37,7 @@ class nsDeckFrame : public nsBoxFrame
|
|||
{
|
||||
public:
|
||||
|
||||
friend nsresult NS_NewDeckFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame);
|
||||
friend nsresult NS_NewDeckFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame, nsIBoxLayout* aLayoutManager);
|
||||
|
||||
|
||||
|
||||
|
@ -66,6 +66,8 @@ public:
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsDeckFrame(nsIPresShell* aPresShell, nsIBoxLayout* aLayout = nsnull);
|
||||
|
||||
protected:
|
||||
|
||||
nsDeckFrame(nsIPresShell* aPresShell);
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
//
|
||||
// Eric Vaughan
|
||||
// Netscape Communications
|
||||
//
|
||||
// See documentation in associated header file
|
||||
//
|
||||
|
||||
#include "nsGridLayout.h"
|
||||
#include "nsTempleLayout.h"
|
||||
#include "nsIBox.h"
|
||||
|
||||
nsresult
|
||||
NS_NewGridLayout( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout)
|
||||
{
|
||||
aNewLayout = new nsGridLayout(aPresShell);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
nsGridLayout::nsGridLayout(nsIPresShell* aPresShell):nsStackLayout()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the monuments in the other temple at the give monument index
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsGridLayout::GetOtherMonumentsAt(nsIBox* aBox, PRInt32 aIndexOfObelisk, nsBoxSizeList** aList, nsMonumentLayout* aRequestor)
|
||||
{
|
||||
nsTempleLayout* temple = nsnull;
|
||||
nsIBox* templeBox = nsnull;
|
||||
GetOtherTemple(aBox, &temple, &templeBox, aRequestor);
|
||||
if (temple)
|
||||
return temple->GetMonumentsAt(templeBox, aIndexOfObelisk, aList);
|
||||
else
|
||||
*aList = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* a Grid always has 2 temples. This is called by one temple to get the other
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsGridLayout::GetOtherTemple(nsIBox* aBox, nsTempleLayout** aTemple, nsIBox** aTempleBox, nsMonumentLayout* aRequestor)
|
||||
{
|
||||
// this is really easy. We know the index of the temple who requested
|
||||
// so find our other temple who doesn't have that index.
|
||||
|
||||
nsIBox* child = nsnull;
|
||||
aBox->GetChildBox(&child);
|
||||
|
||||
while(child)
|
||||
{
|
||||
nsIBoxLayout* layout = nsnull;
|
||||
child->GetLayoutManager(&layout);
|
||||
|
||||
// must find a temple that is not our requestor and is a monument.
|
||||
if (layout != aRequestor) {
|
||||
nsIMonument* monument = nsnull;
|
||||
if (NS_SUCCEEDED(layout->QueryInterface(NS_GET_IID(nsIMonument), (void**)&monument)) && monument)
|
||||
{
|
||||
nsTempleLayout* temple = nsnull;
|
||||
monument->CastToTemple(&temple);
|
||||
if (temple) {
|
||||
// yes its a temple.
|
||||
*aTemple = temple;
|
||||
*aTempleBox = child;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
child->GetNextBox(&child);
|
||||
}
|
||||
|
||||
*aTemple = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Author:
|
||||
Eric D Vaughan
|
||||
|
||||
**/
|
||||
|
||||
#ifndef nsGridLayout_h___
|
||||
#define nsGridLayout_h___
|
||||
|
||||
#include "nsStackLayout.h"
|
||||
#include "nsCOMPtr.h"
|
||||
class nsTempleLayout;
|
||||
class nsMonumentLayout;
|
||||
class nsBoxSizeList;
|
||||
|
||||
class nsGridLayout : public nsStackLayout
|
||||
{
|
||||
public:
|
||||
|
||||
friend nsresult NS_NewGridLayout(nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout);
|
||||
|
||||
NS_IMETHOD GetOtherMonumentsAt(nsIBox* aBox, PRInt32 aIndexOfObelisk, nsBoxSizeList** aList, nsMonumentLayout* aRequestor = nsnull);
|
||||
NS_IMETHOD GetOtherTemple(nsIBox* aBox, nsTempleLayout** aTempleLayout, nsIBox** aTempleBox, nsMonumentLayout* aRequestor = nsnull);
|
||||
|
||||
protected:
|
||||
nsGridLayout(nsIPresShell* aShell);
|
||||
}; // class nsGridLayout
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Author:
|
||||
* Eric D Vaughan
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsIMonument_h___
|
||||
#define nsIMonument_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIFrame.h"
|
||||
|
||||
class nsIBox;
|
||||
class nsBoxLayoutState;
|
||||
class nsTempleLayout;
|
||||
class nsObeliskLayout;
|
||||
class nsMonumentLayout;
|
||||
class nsBoxLayoutState;
|
||||
class nsIPresShell;
|
||||
|
||||
class nsBoxSizeList
|
||||
{
|
||||
public:
|
||||
virtual nsBoxSize GetBoxSize(nsBoxLayoutState& aState)=0;
|
||||
virtual nsBoxSizeList* GetFirst()=0;
|
||||
virtual nsBoxSizeList* GetLast()=0;
|
||||
virtual nsBoxSizeList* GetNext()=0;
|
||||
virtual nsBoxSizeList* GetParent()=0;
|
||||
virtual nsBoxSizeList* GetAt(PRInt32 aIndex)=0;
|
||||
virtual void SetParent(nsBoxSizeList* aParent)=0;
|
||||
virtual void SetNext(nsBoxLayoutState& aState, nsBoxSizeList* aNext)=0;
|
||||
virtual void Append(nsBoxLayoutState& aState, nsBoxSizeList* aChild)=0;
|
||||
virtual void Clear(nsBoxLayoutState& aState)=0;
|
||||
virtual PRInt32 GetCount()=0;
|
||||
virtual void Desecrate()=0;
|
||||
virtual void AddRef()=0;
|
||||
virtual void Release(nsBoxLayoutState& aState)=0;
|
||||
virtual PRBool IsSet()=0;
|
||||
virtual nsIBox* GetBox()=0;
|
||||
virtual PRInt32 GetRefCount()=0;
|
||||
};
|
||||
|
||||
// {AF0C1603-06C3-11d4-BA07-001083023C1E}
|
||||
#define NS_IMONUMENT_IID { 0xaf0c1603, 0x6c3, 0x11d4, { 0xba, 0x7, 0x0, 0x10, 0x83, 0x2, 0x3c, 0x1e } };
|
||||
|
||||
class nsIMonument : public nsISupports {
|
||||
|
||||
public:
|
||||
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IBOX_LAYOUT_IID; return iid; }
|
||||
|
||||
NS_IMETHOD CastToTemple(nsTempleLayout** aTemple)=0;
|
||||
NS_IMETHOD CastToObelisk(nsObeliskLayout** aObelisk)=0;
|
||||
NS_IMETHOD GetOtherMonuments(nsIBox* aBox, nsBoxSizeList** aList)=0;
|
||||
NS_IMETHOD GetOtherMonumentsAt(nsIBox* aBox, PRInt32 aIndexOfObelisk, nsBoxSizeList** aList, nsMonumentLayout* aRequestor = nsnull)=0;
|
||||
NS_IMETHOD GetOtherTemple(nsIBox* aBox, nsTempleLayout** aTemple, nsIBox** aTempleBox, nsMonumentLayout* aRequestor = nsnull)=0;
|
||||
NS_IMETHOD GetMonumentsAt(nsIBox* aBox, PRInt32 aMonumentIndex, nsBoxSizeList** aList)=0;
|
||||
//NS_IMETHOD CountMonuments(PRInt32& aCount)=0;
|
||||
NS_IMETHOD BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize** aFirst, nsBoxSize** aLast)=0;
|
||||
NS_IMETHOD GetParentMonument(nsIBox* aBox, nsIMonument** aMonument)=0;
|
||||
NS_IMETHOD GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList** aList)=0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,370 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
//
|
||||
// Eric Vaughan
|
||||
// Netscape Communications
|
||||
//
|
||||
// See documentation in associated header file
|
||||
//
|
||||
|
||||
#include "nsMonumentLayout.h"
|
||||
#include "nsBoxLayoutState.h"
|
||||
#include "nsIBox.h"
|
||||
#include "nsBox.h"
|
||||
|
||||
//------ nsInfoListNodeImpl ----
|
||||
|
||||
void
|
||||
nsBoxSizeListNodeImpl::Release(nsBoxLayoutState& aState)
|
||||
{
|
||||
mRefCount--;
|
||||
if (mRefCount == 0) {
|
||||
Clear(aState);
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsBoxSizeListNodeImpl::Desecrate()
|
||||
{
|
||||
if (mParent)
|
||||
mParent->Desecrate();
|
||||
}
|
||||
|
||||
void nsBoxSizeListNodeImpl::SetNext(nsBoxLayoutState& aState, nsBoxSizeList* aNext)
|
||||
{
|
||||
if (mNext) {
|
||||
mNext->Release(aState);
|
||||
}
|
||||
|
||||
mNext = aNext;
|
||||
aNext->AddRef();
|
||||
}
|
||||
|
||||
void
|
||||
nsBoxSizeListNodeImpl::Append(nsBoxLayoutState& aState, nsBoxSizeList* aChild)
|
||||
{
|
||||
NS_ERROR("Attept at append to a leaf");
|
||||
}
|
||||
|
||||
nsBoxSizeListNodeImpl::nsBoxSizeListNodeImpl(nsIBox* aBox):mNext(nsnull),
|
||||
mParent(nsnull),
|
||||
mRefCount(1),
|
||||
mBox(aBox),
|
||||
mIsSet(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
nsBoxSizeList*
|
||||
nsBoxSizeListNodeImpl::GetAt(PRInt32 aIndex)
|
||||
{
|
||||
nsBoxSizeList* node = this;
|
||||
PRInt32 count = 0;
|
||||
while(node)
|
||||
{
|
||||
if (count == aIndex)
|
||||
return node;
|
||||
|
||||
node = node->GetNext();
|
||||
count++;
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
||||
//------ nsInfoListImpl2 ----
|
||||
|
||||
nsBoxSizeListImpl::nsBoxSizeListImpl(nsIBox* aBox):nsBoxSizeListNodeImpl(aBox),mFirst(nsnull),mLast(nsnull),mCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
nsBoxSizeListImpl::Clear(nsBoxLayoutState& aState)
|
||||
{
|
||||
nsBoxSizeList* list = mFirst;
|
||||
while(list)
|
||||
{
|
||||
list->Release(aState);
|
||||
list = list->GetNext();
|
||||
}
|
||||
|
||||
mFirst = nsnull;
|
||||
mLast = nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
nsBoxSizeListImpl::Append(nsBoxLayoutState& aState, nsBoxSizeList* aChild)
|
||||
{
|
||||
if (!mFirst)
|
||||
mFirst = aChild;
|
||||
else
|
||||
mLast->SetNext(aState, aChild);
|
||||
|
||||
mLast = aChild;
|
||||
aChild->SetParent(this);
|
||||
aChild->AddRef();
|
||||
}
|
||||
|
||||
void
|
||||
nsBoxSizeListImpl::Desecrate()
|
||||
{
|
||||
if (mIsSet) {
|
||||
mIsSet = PR_FALSE;
|
||||
nsBoxSizeListNodeImpl::Desecrate();
|
||||
}
|
||||
}
|
||||
|
||||
nsBoxSize
|
||||
nsBoxSizeListImpl::GetBoxSize(nsBoxLayoutState& aState)
|
||||
{
|
||||
if (!mIsSet) {
|
||||
|
||||
mIsSet = PR_TRUE;
|
||||
|
||||
mBoxSize.Clear();
|
||||
|
||||
nsBoxSizeList* node = mFirst;
|
||||
|
||||
PRBool isHorizontal = PR_FALSE;
|
||||
mBox->GetOrientation(isHorizontal);
|
||||
|
||||
while(node) {
|
||||
nsIBox* box = node->GetBox();
|
||||
|
||||
nsSize pref(0,0);
|
||||
nsSize min(0,0);
|
||||
nsSize max(NS_INTRINSICSIZE,NS_INTRINSICSIZE);
|
||||
nscoord ascent = 0;
|
||||
nscoord flex = 0;
|
||||
|
||||
box->GetPrefSize(aState, pref);
|
||||
box->GetMinSize(aState, min);
|
||||
box->GetMaxSize(aState, max);
|
||||
box->GetAscent(aState, ascent);
|
||||
box->GetFlex(aState, flex);
|
||||
mBoxSize.Add(min, pref, max, ascent, flex, !isHorizontal);
|
||||
|
||||
node = node->GetNext();
|
||||
}
|
||||
}
|
||||
|
||||
return mBoxSize;
|
||||
}
|
||||
|
||||
// ------ nsMonumentLayout ------
|
||||
|
||||
nsMonumentLayout::nsMonumentLayout(nsIPresShell* aPresShell):nsSprocketLayout()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
PRBool
|
||||
nsMonumentLayout::GetInitialOrientation(PRBool& aIsHorizontal)
|
||||
{
|
||||
aIsHorizontal = (mState & NS_STATE_IS_HORIZONTAL);
|
||||
return PR_TRUE;
|
||||
}
|
||||
*/
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMonumentLayout::CastToTemple(nsTempleLayout** aTemple)
|
||||
{
|
||||
*aTemple = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMonumentLayout::CastToObelisk(nsObeliskLayout** aObelisk)
|
||||
{
|
||||
*aObelisk = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
void
|
||||
nsMonumentLayout::SetHorizontal(PRBool aIsHorizontal)
|
||||
{
|
||||
if (aIsHorizontal)
|
||||
mState |= NS_STATE_IS_HORIZONTAL;
|
||||
else
|
||||
mState &= ~NS_STATE_IS_HORIZONTAL;
|
||||
}
|
||||
*/
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMonumentLayout::GetParentMonument(nsIBox* aBox, nsIMonument** aMonument)
|
||||
{
|
||||
// go up and find our parent monument. Skip and non monument
|
||||
// parents.
|
||||
nsIBoxLayout* parent = this;
|
||||
*aMonument = nsnull;
|
||||
while (parent) {
|
||||
GetParentLayout(aBox, &parent);
|
||||
|
||||
if (parent && NS_SUCCEEDED(parent->QueryInterface(NS_GET_IID(nsIMonument), (void**)aMonument)) && *aMonument)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMonumentLayout::GetOtherMonuments(nsIBox* aBox, nsBoxSizeList** aList)
|
||||
{
|
||||
nsIMonument* parent;
|
||||
GetParentMonument(aBox, &parent);
|
||||
return parent->GetOtherMonumentsAt(aBox, 0, aList, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the monuments in the other temple at the give monument index
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsMonumentLayout::GetOtherMonumentsAt(nsIBox* aBox, PRInt32 aIndexOfObelisk, nsBoxSizeList** aList, nsMonumentLayout* aRequestor)
|
||||
{
|
||||
PRInt32 index = 0;
|
||||
nsIBox* child = nsnull;
|
||||
aBox->GetChildBox(&child);
|
||||
PRInt32 count = 0;
|
||||
while(child)
|
||||
{
|
||||
nsIBoxLayout* layout = nsnull;
|
||||
child->GetLayoutManager(&layout);
|
||||
nsIMonument* monument = nsnull;
|
||||
if (layout == aRequestor) {
|
||||
index = count;
|
||||
break;
|
||||
}
|
||||
|
||||
child->GetNextBox(&child);
|
||||
count++;
|
||||
}
|
||||
|
||||
NS_ASSERTION(index != -1,"Error can't find requestor!!");
|
||||
aIndexOfObelisk += index;
|
||||
|
||||
nsIMonument* parent;
|
||||
GetParentMonument(aBox, &parent);
|
||||
|
||||
parent->GetOtherMonumentsAt(aBox, aIndexOfObelisk, aList, this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMonumentLayout::GetOtherTemple(nsIBox* aBox, nsTempleLayout** aTemple, nsIBox** aTempleBox, nsMonumentLayout* aRequestor)
|
||||
{
|
||||
nsIMonument* parent;
|
||||
GetParentMonument(aBox, &parent);
|
||||
parent->GetOtherTemple(aBox, aTemple, aTempleBox, this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMonumentLayout::GetMonumentsAt(nsIBox* aBox, PRInt32 aMonumentIndex, nsBoxSizeList** aList)
|
||||
{
|
||||
// create an info list for the given column.
|
||||
nsIBox* box = nsnull;
|
||||
aBox->GetChildBox(&box);
|
||||
PRInt32 count = 0;
|
||||
while(box) {
|
||||
if (count == aMonumentIndex)
|
||||
{
|
||||
*aList = new nsBoxSizeListNodeImpl(box);
|
||||
return NS_OK;
|
||||
}
|
||||
box->GetNextBox(&box);
|
||||
count++;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsMonumentLayout::CountMonuments(PRInt32& aCount)
|
||||
{
|
||||
aCount = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMonumentLayout::BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize** aFirst, nsBoxSize** aLast)
|
||||
{
|
||||
*aFirst = *aLast = new nsBoxSize();
|
||||
|
||||
nsSize pref(0,0);
|
||||
nsSize min(0,0);
|
||||
nsSize max(NS_INTRINSICSIZE,NS_INTRINSICSIZE);
|
||||
nscoord flex = 0;
|
||||
nscoord ascent = 0;
|
||||
|
||||
aBox->GetPrefSize(aState, pref);
|
||||
aBox->GetMinSize(aState, min);
|
||||
aBox->GetMaxSize(aState, max);
|
||||
aBox->GetAscent(aState, ascent);
|
||||
aBox->GetFlex(aState, flex);
|
||||
nsBox::BoundsCheck(min, pref, max);
|
||||
nsMargin borderPadding(0,0,0,0);
|
||||
aBox->GetBorderAndPadding(borderPadding);
|
||||
|
||||
nsMargin margin(0,0,0,0);
|
||||
aBox->GetMargin(margin);
|
||||
|
||||
PRBool isHorizontal = PR_FALSE;
|
||||
aBox->GetOrientation(isHorizontal);
|
||||
|
||||
(*aFirst)->Add(min, pref, max, ascent, flex, isHorizontal);
|
||||
(*aFirst)->Add(borderPadding,isHorizontal);
|
||||
(*aFirst)->Add(margin,isHorizontal);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMonumentLayout::GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList** aList)
|
||||
{
|
||||
nsIBox* child = nsnull;
|
||||
aBox->GetChildBox(&child);
|
||||
nsBoxSizeList* last = nsnull;
|
||||
while(child)
|
||||
{
|
||||
nsBoxSizeList* newOne = new nsBoxSizeListNodeImpl(child);
|
||||
if (*aList == nsnull)
|
||||
*aList = last = newOne;
|
||||
else {
|
||||
last->SetNext(aState, newOne);
|
||||
last = newOne;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsMonumentLayout, nsBoxLayout);
|
||||
NS_IMPL_RELEASE_INHERITED(nsMonumentLayout, nsBoxLayout);
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsMonumentLayout)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIMonument)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsBoxLayout)
|
|
@ -0,0 +1,214 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
//
|
||||
// Eric Vaughan
|
||||
// Netscape Communications
|
||||
//
|
||||
// See documentation in associated header file
|
||||
//
|
||||
|
||||
#include "nsObeliskLayout.h"
|
||||
#include "nsTempleLayout.h"
|
||||
#include "nsBoxLayoutState.h"
|
||||
#include "nsBox.h"
|
||||
|
||||
nsresult
|
||||
NS_NewObeliskLayout( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout)
|
||||
{
|
||||
aNewLayout = new nsObeliskLayout(aPresShell);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
nsObeliskLayout::nsObeliskLayout(nsIPresShell* aPresShell):nsMonumentLayout(aPresShell), mOtherMonumentList(nsnull)
|
||||
{
|
||||
mOtherMonumentList = nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsObeliskLayout::CastToObelisk(nsObeliskLayout** aObelisk)
|
||||
{
|
||||
*aObelisk = this;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsObeliskLayout::UpdateMonuments(nsIBox* aBox, nsBoxLayoutState& aState)
|
||||
{
|
||||
if (!mOtherMonumentList || mOtherMonumentList->GetRefCount() == 1)
|
||||
{
|
||||
if (mOtherMonumentList) {
|
||||
mOtherMonumentList->Release(aState);
|
||||
}
|
||||
|
||||
mOtherMonumentList = nsnull;
|
||||
GetOtherMonuments(aBox, &mOtherMonumentList);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsObeliskLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSize)
|
||||
{
|
||||
nsresult rv = nsMonumentLayout::GetPrefSize(aBox, aState, aSize);
|
||||
|
||||
UpdateMonuments(aBox, aState);
|
||||
|
||||
nsBoxSizeList* node = mOtherMonumentList;
|
||||
|
||||
PRBool isHorizontal = PR_FALSE;
|
||||
aBox->GetOrientation(isHorizontal);
|
||||
|
||||
// for each info
|
||||
while(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.
|
||||
// if the infos max width is smaller than aSizes then set it.
|
||||
nsBoxSize size = node->GetBoxSize(aState);
|
||||
|
||||
nscoord s = size.pref;
|
||||
nscoord& s2 = GET_HEIGHT(aSize, isHorizontal);
|
||||
|
||||
if (s > s2)
|
||||
s2 = s;
|
||||
|
||||
node = node->GetNext();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsObeliskLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSize)
|
||||
{
|
||||
nsresult rv = nsMonumentLayout::GetMinSize(aBox, aState, aSize);
|
||||
|
||||
UpdateMonuments(aBox, aState);
|
||||
|
||||
nsBoxSizeList* node = mOtherMonumentList;
|
||||
|
||||
PRBool isHorizontal = PR_FALSE;
|
||||
aBox->GetOrientation(isHorizontal);
|
||||
|
||||
// for each info
|
||||
while(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.
|
||||
// if the infos max width is smaller than aSizes then set it.
|
||||
nsBoxSize size = node->GetBoxSize(aState);
|
||||
|
||||
nscoord s = size.min;
|
||||
nscoord& s2 = GET_HEIGHT(aSize, isHorizontal);
|
||||
|
||||
if (s > s2)
|
||||
s2 = s;
|
||||
|
||||
node = node->GetNext();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsObeliskLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSize)
|
||||
{
|
||||
nsresult rv = nsMonumentLayout::GetMaxSize(aBox, aState, aSize);
|
||||
|
||||
UpdateMonuments(aBox, aState);
|
||||
|
||||
nsBoxSizeList* node = mOtherMonumentList;
|
||||
|
||||
PRBool isHorizontal = PR_FALSE;
|
||||
aBox->GetOrientation(isHorizontal);
|
||||
|
||||
// for each info
|
||||
while(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.
|
||||
// if the infos max width is smaller than aSizes then set it.
|
||||
nsBoxSize size = node->GetBoxSize(aState);
|
||||
|
||||
nscoord s = size.max;
|
||||
nscoord& s2 = GET_HEIGHT(aSize, isHorizontal);
|
||||
|
||||
if (s > s2)
|
||||
s2 = s;
|
||||
|
||||
node = node->GetNext();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsObeliskLayout::ChildNeedsLayout(nsIBox* aBox, nsIBoxLayout* aChild)
|
||||
{
|
||||
// if one of our cells has changed size and needs reflow
|
||||
// make sure we clean any cached information about it.
|
||||
nsIBoxLayout* layout;
|
||||
GetParentLayout(aBox, &layout);
|
||||
nsTempleLayout* parent = nsnull;
|
||||
nsIMonument* monument = nsnull;
|
||||
|
||||
nsIBox* child = nsnull;
|
||||
aBox->GetChildBox(&child);
|
||||
PRInt32 count = 0;
|
||||
while(child)
|
||||
{
|
||||
nsIBoxLayout* layout = nsnull;
|
||||
child->GetLayoutManager(&layout);
|
||||
if (layout && NS_SUCCEEDED(layout->QueryInterface(NS_GET_IID(nsIMonument), (void**)&monument)) && monument)
|
||||
{
|
||||
if (layout == aChild) {
|
||||
parent->EncriptionChanged(count);
|
||||
return;
|
||||
}
|
||||
}
|
||||
child->GetNextBox(&child);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsObeliskLayout::ComputeChildSizes(nsIBox* aBox,
|
||||
nsBoxLayoutState& aState,
|
||||
nscoord& aGivenSize,
|
||||
nsBoxSize* aBoxSizes,
|
||||
nsComputedBoxSize* aComputedBoxSizes)
|
||||
{
|
||||
nsTempleLayout* temple = nsnull;
|
||||
nsIBox* aTempleBox = nsnull;
|
||||
GetOtherTemple(aBox, &temple, &aTempleBox);
|
||||
if (temple) {
|
||||
// substitute our sizes for the other temples obelisk sizes.
|
||||
nsBoxSize* last = nsnull;
|
||||
temple->BuildBoxSizeList(aTempleBox, aState, &aBoxSizes, &last);
|
||||
}
|
||||
|
||||
nsSprocketLayout::ComputeChildSizes(aBox, aState, aGivenSize, aBoxSizes, aComputedBoxSizes);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Author:
|
||||
Eric D Vaughan
|
||||
|
||||
**/
|
||||
|
||||
#ifndef nsObeliskLayout_h___
|
||||
#define nsObeliskLayout_h___
|
||||
|
||||
#include "nsMonumentLayout.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsObeliskLayout : public nsMonumentLayout
|
||||
{
|
||||
public:
|
||||
|
||||
friend nsresult NS_NewObeliskLayout(nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout);
|
||||
|
||||
NS_IMETHOD GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
|
||||
NS_IMETHOD GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
|
||||
NS_IMETHOD GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
|
||||
NS_IMETHOD CastToObelisk(nsObeliskLayout** aObelisk);
|
||||
|
||||
protected:
|
||||
|
||||
void ChildNeedsLayout(nsIBox* aBox, nsIBoxLayout* aChild);
|
||||
virtual void UpdateMonuments(nsIBox* aBox, nsBoxLayoutState& aState);
|
||||
|
||||
virtual void ComputeChildSizes(nsIBox* aBox,
|
||||
nsBoxLayoutState& aState,
|
||||
nscoord& aGivenSize,
|
||||
nsBoxSize* aBoxSizes,
|
||||
nsComputedBoxSize* aComputedBoxSizes);
|
||||
|
||||
nsObeliskLayout(nsIPresShell* aShell);
|
||||
|
||||
private:
|
||||
nsBoxSizeList* mOtherMonumentList;
|
||||
|
||||
}; // class nsObeliskLayout
|
||||
|
||||
#endif
|
||||
|
|
@ -100,8 +100,6 @@ public:
|
|||
NS_IMETHOD GetFrameName(nsString& aResult) const;
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
|
||||
#endif
|
||||
|
||||
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -118,13 +116,16 @@ NS_NewRootBoxFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
it->SetLayoutManager(new nsStackLayout(aPresShell));
|
||||
*aNewFrame = it;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRootBoxFrame::nsRootBoxFrame(nsIPresShell* aShell):nsBoxFrame(aShell, PR_TRUE)
|
||||
{
|
||||
nsCOMPtr<nsIBoxLayout> layout;
|
||||
NS_NewStackLayout(aShell, layout);
|
||||
SetLayoutManager(layout);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -54,6 +54,7 @@ NS_IMETHODIMP nsSpringFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
|||
if (!mRect.Contains(aPoint))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
/*
|
||||
// see if it is in our border, padding, or inset
|
||||
nsRect r(mRect);
|
||||
nsMargin m;
|
||||
|
@ -62,9 +63,12 @@ NS_IMETHODIMP nsSpringFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
|||
GetBorderAndPadding(m);
|
||||
r.Deflate(m);
|
||||
if (!r.Contains(aPoint)) {
|
||||
*/
|
||||
*aFrame = this;
|
||||
/*
|
||||
return NS_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,8 @@
|
|||
#include "nsXULAtoms.h"
|
||||
#include "nsBoxFrame.h"
|
||||
|
||||
nsCOMPtr<nsIBoxLayout> nsSprocketLayout::gInstance = new nsSprocketLayout();
|
||||
|
||||
class nsBoxSizeSpecial : public nsBoxSize
|
||||
{
|
||||
public:
|
||||
|
@ -62,7 +64,16 @@ public:
|
|||
#define DEBUG_BORDER_SIZE 2
|
||||
#define COIL_SIZE 8
|
||||
|
||||
nsSprocketLayout::nsSprocketLayout(nsIPresShell* aShell)
|
||||
|
||||
nsresult
|
||||
NS_NewSprocketLayout( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout)
|
||||
{
|
||||
// we have not instance variables so just return our static one.
|
||||
aNewLayout = nsSprocketLayout::gInstance;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsSprocketLayout::nsSprocketLayout()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#define nsSprocketLayout_h___
|
||||
|
||||
#include "nsBoxLayout.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsBoxSize
|
||||
{
|
||||
|
@ -87,6 +88,7 @@ class nsSprocketLayout : public nsBoxLayout {
|
|||
|
||||
public:
|
||||
|
||||
friend nsresult NS_NewSprocketLayout(nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout);
|
||||
|
||||
NS_IMETHOD Layout(nsIBox* aBox, nsBoxLayoutState& aState);
|
||||
|
||||
|
@ -97,7 +99,7 @@ public:
|
|||
NS_IMETHOD GetAscent(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent);
|
||||
NS_IMETHOD IsCollapsed(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, PRBool& aCollapsed);
|
||||
|
||||
nsSprocketLayout(nsIPresShell* aShell);
|
||||
nsSprocketLayout();
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -148,6 +150,10 @@ protected:
|
|||
virtual void GetFrameState(nsIBox* aBox, nsFrameState& aState);
|
||||
virtual void SetFrameState(nsIBox* aBox, nsFrameState aState);
|
||||
|
||||
// because the sprocket layout manager has no instance variables. We
|
||||
// can make a static on and reuse it everywhere.
|
||||
static nsCOMPtr<nsIBoxLayout> gInstance;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -47,29 +47,34 @@
|
|||
#include "nsStackLayout.h"
|
||||
|
||||
nsresult
|
||||
NS_NewStackFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame )
|
||||
NS_NewStackFrame ( nsIPresShell* aPresShell, nsIFrame** aNewFrame, nsIBoxLayout* aLayoutManager)
|
||||
{
|
||||
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
||||
if (nsnull == aNewFrame) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsStackFrame* it = new (aPresShell) nsStackFrame(aPresShell);
|
||||
nsStackFrame* it = new (aPresShell) nsStackFrame(aPresShell, aLayoutManager);
|
||||
if (nsnull == it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*aNewFrame = it;
|
||||
|
||||
return NS_OK;
|
||||
|
||||
} // NS_NewStackFrame
|
||||
|
||||
nsCOMPtr<nsIBoxLayout> nsStackFrame::gLayout = nsnull;
|
||||
|
||||
nsStackFrame::nsStackFrame(nsIPresShell* aPresShell):nsBoxFrame(aPresShell)
|
||||
nsStackFrame::nsStackFrame(nsIPresShell* aPresShell, nsIBoxLayout* aLayoutManager):nsBoxFrame(aPresShell)
|
||||
{
|
||||
if (!gLayout)
|
||||
gLayout = new nsStackLayout(aPresShell);
|
||||
// if no layout manager specified us the stack layout
|
||||
nsCOMPtr<nsIBoxLayout> layout = aLayoutManager;
|
||||
|
||||
SetLayoutManager(gLayout);
|
||||
if (layout == nsnull) {
|
||||
NS_NewStackLayout(aPresShell, layout);
|
||||
}
|
||||
|
||||
SetLayoutManager(layout);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class nsStackFrame : public nsBoxFrame
|
|||
{
|
||||
public:
|
||||
|
||||
friend nsresult NS_NewStackFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame);
|
||||
friend nsresult NS_NewStackFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame, nsIBoxLayout* aLayout = nsnull);
|
||||
|
||||
NS_IMETHOD GetFrameName(nsString& aResult) const
|
||||
{
|
||||
|
@ -68,6 +68,9 @@ private:
|
|||
const nsRect& aRect,
|
||||
const nsPoint& aPoint,
|
||||
nsIFrame** aFrame);
|
||||
|
||||
nsStackFrame(nsIPresShell* aPresShell, nsIBoxLayout* aLayout = nsnull);
|
||||
|
||||
protected:
|
||||
|
||||
nsStackFrame(nsIPresShell* aPresShell);
|
||||
|
|
|
@ -46,7 +46,17 @@
|
|||
#include "nsBoxLayoutState.h"
|
||||
#include "nsIBox.h"
|
||||
|
||||
nsStackLayout::nsStackLayout(nsIPresShell* aPresShell)
|
||||
nsCOMPtr<nsIBoxLayout> nsStackLayout::gInstance = new nsStackLayout();
|
||||
|
||||
nsresult
|
||||
NS_NewStackLayout( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout)
|
||||
{
|
||||
// we have not instance variables so just return our static one.
|
||||
aNewLayout = nsStackLayout::gInstance;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsStackLayout::nsStackLayout()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -32,12 +32,15 @@
|
|||
#define nsStackLayout_h___
|
||||
|
||||
#include "nsBoxLayout.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsStackLayout : public nsBoxLayout
|
||||
{
|
||||
public:
|
||||
|
||||
nsStackLayout(nsIPresShell* aShell);
|
||||
friend nsresult NS_NewStackLayout(nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout);
|
||||
|
||||
nsStackLayout();
|
||||
|
||||
NS_IMETHOD Layout(nsIBox* aBox, nsBoxLayoutState& aState);
|
||||
|
||||
|
@ -45,6 +48,10 @@ public:
|
|||
NS_IMETHOD GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
|
||||
NS_IMETHOD GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
|
||||
NS_IMETHOD GetAscent(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent);
|
||||
|
||||
private:
|
||||
static nsCOMPtr<nsIBoxLayout> gInstance;
|
||||
|
||||
}; // class nsStackLayout
|
||||
|
||||
|
||||
|
|
|
@ -155,17 +155,21 @@ nsTabFrame::GetChildWithTag(nsIAtom* atom, nsCOMPtr<nsIContent> start, nsCOMPtr<
|
|||
nsresult
|
||||
nsTabFrame::GetTabControl(nsCOMPtr<nsIContent> content, nsCOMPtr<nsIContent>& tabcontrol)
|
||||
{
|
||||
while(nsnull != content)
|
||||
{
|
||||
content->GetParent(*getter_AddRefs(content));
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
|
||||
if (content) {
|
||||
while(content != nsnull)
|
||||
{
|
||||
content->GetParent(*getter_AddRefs(parent));
|
||||
|
||||
if (parent) {
|
||||
nsCOMPtr<nsIAtom> atom;
|
||||
if (content->GetTag(*getter_AddRefs(atom)) == NS_OK && atom.get() == nsXULAtoms::tabcontrol) {
|
||||
tabcontrol = content;
|
||||
if (parent->GetTag(*getter_AddRefs(atom)) == NS_OK && atom.get() == nsXULAtoms::tabcontrol) {
|
||||
tabcontrol = parent;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
content = parent;
|
||||
}
|
||||
|
||||
tabcontrol = nsnull;
|
||||
|
|
|
@ -0,0 +1,177 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
//
|
||||
// Eric Vaughan
|
||||
// Netscape Communications
|
||||
//
|
||||
// See documentation in associated header file
|
||||
//
|
||||
|
||||
#include "nsTempleLayout.h"
|
||||
#include "nsIBox.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
nsresult
|
||||
NS_NewTempleLayout( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout)
|
||||
{
|
||||
aNewLayout = new nsTempleLayout(aPresShell);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
nsTempleLayout::nsTempleLayout(nsIPresShell* aPresShell):nsMonumentLayout(aPresShell), mMonuments(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTempleLayout::CastToTemple(nsTempleLayout** aTemple)
|
||||
{
|
||||
*aTemple = this;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsTempleLayout::EncriptionChanged(PRInt32 aIndex)
|
||||
{
|
||||
// if a cell changes size.
|
||||
if (mMonuments) {
|
||||
nsBoxSizeList* size = mMonuments->GetAt(aIndex);
|
||||
if (size)
|
||||
size->Desecrate();
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTempleLayout::GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList** aList)
|
||||
{
|
||||
if (mMonuments) {
|
||||
*aList = mMonuments;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aList = nsnull;
|
||||
|
||||
// run through our children.
|
||||
// ask each child for its monument list
|
||||
// append the list to our list
|
||||
nsIBox* box = nsnull;
|
||||
aBox->GetChildBox(&box);
|
||||
nsBoxSizeList* current = nsnull;
|
||||
|
||||
while(box) {
|
||||
|
||||
nsIMonument* monument = nsnull;
|
||||
if (NS_SUCCEEDED(box->QueryInterface(NS_GET_IID(nsIMonument), (void**)&monument)) && monument)
|
||||
{
|
||||
if (!mMonuments) {
|
||||
mMonuments = new nsBoxSizeListImpl(box);
|
||||
}
|
||||
|
||||
current = mMonuments;
|
||||
nsBoxSizeList* node = nsnull;
|
||||
monument->GetMonumentList(aBox, aState, &node);
|
||||
|
||||
while(node)
|
||||
{
|
||||
current->Append(aState, node);
|
||||
if (!current->GetNext()) {
|
||||
nsBoxSizeList* newOne = new nsBoxSizeListImpl(box);
|
||||
current->SetNext(aState, newOne);
|
||||
current = newOne;
|
||||
} else {
|
||||
current = current->GetNext();
|
||||
}
|
||||
|
||||
node = node->GetNext();
|
||||
}
|
||||
|
||||
box->GetNextBox(&box);
|
||||
}
|
||||
}
|
||||
|
||||
*aList = mMonuments;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTempleLayout::BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize** aFirst, nsBoxSize** aLast)
|
||||
{
|
||||
nsIBox* box = nsnull;
|
||||
aBox->GetChildBox(&box);
|
||||
|
||||
aFirst = nsnull;
|
||||
aLast = nsnull;
|
||||
|
||||
nsBoxSize* first;
|
||||
nsBoxSize* last;
|
||||
PRInt32 count = 0;
|
||||
while(box) {
|
||||
nsIMonument* monument = nsnull;
|
||||
if (NS_SUCCEEDED(box->QueryInterface(NS_GET_IID(nsIMonument), (void**)&monument)) && monument)
|
||||
{
|
||||
monument->BuildBoxSizeList(box, aState, &first, &last);
|
||||
if (count == 0)
|
||||
*aFirst = first;
|
||||
else
|
||||
(*aLast)->next = first;
|
||||
|
||||
*aLast = last;
|
||||
}
|
||||
box->GetNextBox(&box);
|
||||
count++;
|
||||
}
|
||||
|
||||
nsMargin borderPadding(0,0,0,0);
|
||||
aBox->GetBorderAndPadding(borderPadding);
|
||||
nsMargin margin(0,0,0,0);
|
||||
aBox->GetMargin(margin);
|
||||
|
||||
nsMargin leftMargin(borderPadding.left + margin.left, borderPadding.top + margin.top, 0, 0);
|
||||
nsMargin rightMargin(0,0, borderPadding.right + margin.right, borderPadding.bottom + margin.bottom);
|
||||
|
||||
PRBool isHorizontal = PR_FALSE;
|
||||
aBox->GetOrientation(isHorizontal);
|
||||
|
||||
(*aFirst)->Add(leftMargin,isHorizontal);
|
||||
(*aLast)->Add(rightMargin,isHorizontal);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
void
|
||||
nsTempleLayout::DesecrateMonuments(nsBoxLayoutState& aState)
|
||||
{
|
||||
mMonuments->Clear(aState);
|
||||
delete mMonuments;
|
||||
mMonuments = nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTempleLayout::ChildrenAddedOrRemoved()
|
||||
{
|
||||
DesecrateMonuments(aPresContext);
|
||||
return nsMonumentLayout::ChildrenAddedOrRemoved();
|
||||
}
|
||||
*/
|
|
@ -0,0 +1,58 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Author:
|
||||
Eric D Vaughan
|
||||
|
||||
**/
|
||||
|
||||
#ifndef nsTempleLayout_h___
|
||||
#define nsTempleLayout_h___
|
||||
|
||||
#include "nsMonumentLayout.h"
|
||||
|
||||
class nsTempleLayout : public nsMonumentLayout
|
||||
{
|
||||
public:
|
||||
|
||||
friend nsresult NS_NewTempleLayout(nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout);
|
||||
|
||||
//NS_IMETHOD GetMonumentsAt(nsIBox* aBox, PRInt32 aMonumentIndex, nsBoxSizeList** aList);
|
||||
//NS_IMETHOD CountMonuments(PRInt32& aCount);
|
||||
NS_IMETHOD CastToTemple(nsTempleLayout** aTemple);
|
||||
NS_IMETHOD BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize** aFirst, nsBoxSize** aLast);
|
||||
NS_IMETHOD GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList** aList);
|
||||
|
||||
virtual void EncriptionChanged(PRInt32 aIndex);
|
||||
|
||||
protected:
|
||||
|
||||
nsTempleLayout(nsIPresShell* aShell);
|
||||
|
||||
private:
|
||||
nsBoxSizeList* mMonuments;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Загрузка…
Ссылка в новой задаче