Made grids scroll for dogfood bug 30511.

-r hyatt
This commit is contained in:
evaughan%netscape.com 2000-06-02 22:15:09 +00:00
parent a16af811db
commit 90aa7a4744
21 changed files with 452 additions and 192 deletions

View File

@ -204,7 +204,8 @@ nsScrollFrame::GetScrollPosition(nsIPresContext* aPresContext, nscoord &aX, nsco
nsIScrollableView* scrollingView;
nsIView* view;
GetView(aPresContext, &view);
NS_ASSERTION(NS_SUCCEEDED(view->QueryInterface(kScrollViewIID, (void**)&scrollingView)), "No scrolling view");
nsresult rv = view->QueryInterface(kScrollViewIID, (void**)&scrollingView);
NS_ASSERTION(NS_SUCCEEDED(rv), "No scrolling view");
return scrollingView->GetScrollPosition(aX, aY);
}
@ -215,7 +216,8 @@ nsScrollFrame::ScrollTo(nsIPresContext* aPresContext, nscoord aX, nscoord aY, PR
nsIView* view;
GetView(aPresContext, &view);
NS_ASSERTION(NS_SUCCEEDED(view->QueryInterface(kScrollViewIID, (void**)&scrollingView)), "No scrolling view");
nsresult rv = view->QueryInterface(kScrollViewIID, (void**)&scrollingView);
NS_ASSERTION(NS_SUCCEEDED(rv), "No scrolling view");
return scrollingView->ScrollTo(aX, aY, aFlags);
}

View File

@ -43,6 +43,10 @@
#include "nsINameSpaceManager.h"
#include "nsHTMLAtoms.h"
#include "nsXULAtoms.h"
#include "nsIDOMNode.h"
#include "nsIDOMNamedNodeMap.h"
#include "nsIDOMAttr.h"
//#define DEBUG_REFLOW
@ -50,11 +54,10 @@
static PRInt32 coelesced = 0;
#endif
#ifdef DEBUG_REFLOW
PRInt32 gIndent = 0;
PRInt32 gLayout = 0;
#ifdef DEBUG_REFLOW
void
nsBoxAddIndents()
{
@ -63,42 +66,68 @@ nsBoxAddIndents()
printf(" ");
}
}
#endif
void
nsBoxAppendAttribute(nsIContent* aContent, nsIAtom* aAtom, nsAutoString& aResult)
nsBox::AppendAttribute(const nsAutoString& aAttribute, const nsAutoString& aValue, nsAutoString& aResult)
{
nsAutoString att;
aContent->GetAttribute(kNameSpaceID_None, aAtom, att);
nsAutoString name;
aAtom->ToString(name);
aResult.AppendWithConversion("[");
aResult.Append(name);
aResult.AppendWithConversion("=");
aResult.Append(att);
aResult.AppendWithConversion("]");
aResult.Append(aAttribute);
aResult.AppendWithConversion("='");
aResult.Append(aValue);
aResult.AppendWithConversion("' ");
}
#endif
void
nsBox::ListBox(nsAutoString& aResult)
{
#ifdef DEBUG_REFLOW
nsAutoString name;
nsIFrame* frame;
GetFrame(&frame);
GetBoxName(name);
char addr[100];
sprintf(addr, "[@%p] ", frame);
aResult.AppendWithConversion(addr);
aResult.Append(name);
aResult.AppendWithConversion(" ");
nsCOMPtr<nsIContent> content;
frame->GetContent(getter_AddRefs(content));
// add on all the set attributes
if (content) {
nsBoxAppendAttribute(content, nsHTMLAtoms::id, aResult);
nsBoxAppendAttribute(content, nsHTMLAtoms::kClass, aResult);
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
nsCOMPtr<nsIDOMNamedNodeMap> namedMap;
node->GetAttributes(getter_AddRefs(namedMap));
PRUint32 length;
namedMap->GetLength(&length);
nsCOMPtr<nsIDOMNode> attribute;
for (PRUint32 i = 0; i < length; ++i)
{
namedMap->Item(i, getter_AddRefs(attribute));
nsCOMPtr<nsIDOMAttr> attr(do_QueryInterface(attribute));
nsAutoString name;
attr->GetName(name);
nsAutoString value;
attr->GetValue(value);
AppendAttribute(name, value, aResult);
}
}
#endif
}
NS_IMETHODIMP
nsBox::DumpBox(FILE* aFile)
{
nsAutoString s;
ListBox(s);
char ch[1000];
s.ToCString(ch,1000);
fprintf(aFile, "%s", ch);
return NS_OK;
}
void
@ -131,10 +160,8 @@ nsBox::EnterLayout(nsBoxLayoutState& aState)
char ch[100];
reason.ToCString(ch,100);
printf("%s Layout: ", ch);
nsAutoString s;
ListBox(s);
s.ToCString(ch,100);
printf("%s\n",ch);
DumpBox(stdout);
printf("\n");
gIndent++;
#endif
}
@ -465,7 +492,7 @@ nsBox::GetContentRect(nsRect& aContentRect)
GetBounds(aContentRect);
aContentRect.x = 0;
aContentRect.y = 0;
NS_ASSERTION(aContentRect.width >=0 && aContentRect.height >= 0, "Content Size < 0");
NS_BOX_ASSERTION(this, aContentRect.width >=0 && aContentRect.height >= 0, "Content Size < 0");
return NS_OK;
}
@ -481,7 +508,7 @@ nsBox::GetBounds(nsRect& aRect)
NS_IMETHODIMP
nsBox::SetBounds(nsBoxLayoutState& aState, const nsRect& aRect)
{
NS_ASSERTION(aRect.width >=0 && aRect.height >= 0, "SetBounds Size < 0");
NS_BOX_ASSERTION(this, aRect.width >=0 && aRect.height >= 0, "SetBounds Size < 0");
nsRect rect(0,0,0,0);
GetBounds(rect);
@ -1081,7 +1108,7 @@ nsBox::Redraw(nsBoxLayoutState& aState,
nsPoint offset;
frame->GetOffsetFromView(presContext, offset, &view);
NS_ASSERTION(nsnull != view, "no view");
NS_BOX_ASSERTION(this, nsnull != view, "no view");
rect += offset;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->UpdateView(view, rect, flags);

View File

@ -79,6 +79,7 @@ public:
NS_IMETHOD MarkChildrenStyleChange();
NS_IMETHOD MarkStyleChange(nsBoxLayoutState& aState);
NS_IMETHOD DumpBox(FILE* out);
nsBox(nsIPresShell* aShell);
@ -104,6 +105,11 @@ public:
static void BoundsCheck(nsSize& aMinSize, nsSize& aPrefSize, nsSize& aMaxSize);
protected:
virtual void AppendAttribute(const nsAutoString& aAttribute, const nsAutoString& aValue, nsAutoString& aResult);
virtual void ListBox(nsAutoString& aResult);
virtual PRBool HasStyleChange();
virtual void SetStyleChangeFlag(PRBool aDirty);
@ -115,7 +121,6 @@ protected:
void EnterLayout(nsBoxLayoutState& aState);
void ExitLayout(nsBoxLayoutState& aState);
virtual void GetBoxName(nsAutoString& aName);
virtual void ListBox(nsAutoString& aResult);
enum eMouseThrough {
unset,
@ -132,5 +137,12 @@ private:
//nscoord mY;
};
#define NS_BOX_ASSERTION(box,expr,str) \
if (!(expr)) { \
box->DumpBox(stdout); \
nsDebug::Assertion(str, #expr, __FILE__, __LINE__); \
} \
#endif

View File

@ -2026,61 +2026,21 @@ nsBoxFrameInner::DisplayDebugInfoFor(nsIBox* aBox,
if (mDebugChild == child)
return NS_OK;
nsCOMPtr<nsIContent> content;
ourFrame->GetContent(getter_AddRefs(content));
nsAutoString id;
nsAutoString kClass;
nsCOMPtr<nsIAtom> tag;
nsAutoString tagString;
char tagValue[100];
char kClassValue[100];
char idValue[100];
if (content) {
content->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::id, id);
id.ToCString(idValue,100);
content->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::kClass, kClass);
kClass.ToCString(kClassValue,100);
content->GetTag(*getter_AddRefs(tag));
tag->ToString(tagString);
tagString.ToCString(tagValue,100);
printf("----- ");
#ifdef NS_DEBUG
nsFrame::ListTag(stdout, ourFrame);
#endif
printf(" Tag='%s', id='%s' class='%s'---------------\n", tagValue, idValue, kClassValue);
if (content) {
printf("---------------\n");
mOuter->DumpBox(stdout);
printf("\n");
}
childFrame->GetContent(getter_AddRefs(content));
if (content) {
id.SetLength(0);
kClass.SetLength(0);
tagString.SetLength(0);
content->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::id, id);
id.ToCString(idValue,100);
content->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::kClass, kClass);
kClass.ToCString(kClassValue,100);
content->GetTag(*getter_AddRefs(tag));
tag->ToString(tagString);
tagString.ToCString(tagValue,100);
printf("child #%d: ", count);
#ifdef NS_DEBUG
nsFrame::ListTag(stdout, childFrame);
#endif
printf(" Tag='%s', id='%s' class='%s'\n", tagValue, idValue, kClassValue);
child->DumpBox(stdout);
printf("\n");
}

View File

@ -55,14 +55,16 @@
#include "nsIFontMetrics.h"
//#define DEBUG_REFLOW
//#define DEBUG_GROW
#ifdef DEBUG_REFLOW
PRInt32 gIndent = 0;
PRInt32 gIndent2 = 0;
void
nsAdaptorAddIndents()
{
for(PRInt32 i=0; i < gIndent; i++)
for(PRInt32 i=0; i < gIndent2; i++)
{
printf(" ");
}
@ -131,6 +133,18 @@ nsBoxToBlockAdaptor::HasStyleChange()
return mStyleChange;
}
void
nsBoxToBlockAdaptor::GetBoxName(nsAutoString& aName)
{
nsIFrameDebug* frameDebug;
nsAutoString name;
if (NS_SUCCEEDED(mFrame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) {
frameDebug->GetFrameName(name);
}
aName = name;
}
void
nsBoxToBlockAdaptor::SetStyleChangeFlag(PRBool aDirty)
{
@ -428,7 +442,21 @@ nsBoxToBlockAdaptor::Layout(nsBoxLayoutState& aState)
mFrame->SizeTo(presContext, 0, 0);
} else {
mAscent = desiredSize.ascent;
mFrame->SizeTo(presContext, desiredSize.width, desiredSize.height);
if (desiredSize.width > ourRect.width || desiredSize.height > ourRect.height) {
#ifdef DEBUG_GROW
DumpBox(stdout);
printf(" GREW from (%d,%d) -> (%d,%d)\n", ourRect.width, ourRect.height, desiredSize.width, desiredSize.height);
#endif
if (desiredSize.width > ourRect.width)
ourRect.width = desiredSize.width;
if (desiredSize.height > ourRect.height)
ourRect.height = desiredSize.height;
mFrame->SizeTo(presContext, ourRect.width, ourRect.height);
}
}
}
@ -458,7 +486,7 @@ nsBoxToBlockAdaptor::Reflow(nsBoxLayoutState& aState,
printf("Reflowing: ");
nsFrame::ListTag(stdout, mFrame);
printf("\n");
gIndent++;
gIndent2++;
#endif
//printf("width=%d, height=%d\n", aWidth, aHeight);
@ -931,7 +959,7 @@ nsBoxToBlockAdaptor::Reflow(nsBoxLayoutState& aState,
}
#ifdef DEBUG_REFLOW
gIndent--;
gIndent2--;
#endif
return NS_OK;

View File

@ -56,6 +56,7 @@ public:
virtual ~nsBoxToBlockAdaptor();
protected:
virtual void GetBoxName(nsAutoString& aName);
virtual PRBool HasStyleChange();
virtual void SetStyleChangeFlag(PRBool aDirty);

View File

@ -30,6 +30,8 @@
#include "nsCOMPtr.h"
#include "nsIBoxLayout.h"
class nsFrameList;
class nsContainerBox : public nsBox {
public:

View File

@ -30,6 +30,7 @@
#include "nsGridLayout.h"
#include "nsTempleLayout.h"
#include "nsIBox.h"
#include "nsIScrollableFrame.h"
nsresult
NS_NewGridLayout( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout)
@ -75,6 +76,17 @@ nsGridLayout::GetOtherTemple(nsIBox* aBox, nsTempleLayout** aTemple, nsIBox** aT
while(child)
{
nsIBox* oldBox = child;
nsresult rv = NS_OK;
nsCOMPtr<nsIScrollableFrame> scrollFrame = do_QueryInterface(child, &rv);
if (scrollFrame) {
nsIFrame* scrolledFrame = nsnull;
scrollFrame->GetScrolledFrame(nsnull, scrolledFrame);
NS_ASSERTION(scrolledFrame,"Error no scroll frame!!");
nsCOMPtr<nsIBox> b = do_QueryInterface(scrolledFrame);
child = b;
}
nsIBoxLayout* layout = nsnull;
child->GetLayoutManager(&layout);
@ -94,6 +106,10 @@ nsGridLayout::GetOtherTemple(nsIBox* aBox, nsTempleLayout** aTemple, nsIBox** aT
}
}
if (scrollFrame) {
child = oldBox;
}
child->GetNextBox(&child);
}
@ -106,17 +122,24 @@ nsGridLayout::GetOtherTemple(nsIBox* aBox, nsTempleLayout** aTemple, nsIBox** aT
NS_IMETHODIMP
nsGridLayout::CastToTemple(nsTempleLayout** aTemple)
{
NS_ERROR("Should not be called");
*aTemple = nsnull;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsGridLayout::CastToObelisk(nsObeliskLayout** aObelisk)
{
NS_ERROR("Should not be called");
*aObelisk = nsnull;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsGridLayout::CastToGrid(nsGridLayout** aGrid)
{
*aGrid = this;
return NS_OK;
}
NS_IMETHODIMP
nsGridLayout::GetParentMonument(nsIBox* aBox, nsCOMPtr<nsIBox>& aParentBox, nsIMonument** aParentMonument)
{
@ -140,7 +163,7 @@ nsGridLayout::GetMonumentsAt(nsIBox* aBox, PRInt32 aMonumentIndex, nsBoxSizeList
NS_IMETHODIMP
nsGridLayout::BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast)
nsGridLayout::BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast, PRBool aIsHorizontal)
{
NS_ERROR("Should not be called");
return NS_ERROR_FAILURE;

View File

@ -50,11 +50,13 @@ public:
NS_IMETHOD CastToTemple(nsTempleLayout** aTemple);
NS_IMETHOD CastToObelisk(nsObeliskLayout** aObelisk);
NS_IMETHOD CastToGrid(nsGridLayout** aGrid);
NS_IMETHOD GetOtherMonuments(nsIBox* aBox, nsBoxSizeList** aList);
NS_IMETHOD GetOtherMonumentsAt(nsIBox* aBox, PRInt32 aIndexOfObelisk, nsBoxSizeList** aList, nsMonumentLayout* aRequestor = nsnull);
NS_IMETHOD GetOtherTemple(nsIBox* aBox, nsTempleLayout** aTemple, nsIBox** aTempleBox, nsMonumentLayout* aRequestor = nsnull);
NS_IMETHOD GetMonumentsAt(nsIBox* aBox, PRInt32 aMonumentIndex, nsBoxSizeList** aList);
NS_IMETHOD BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast);
NS_IMETHOD BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast, PRBool aIsHorizontal);
NS_IMETHOD GetParentMonument(nsIBox* aBox, nsCOMPtr<nsIBox>& aParentBox, nsIMonument** aParentMonument);
NS_IMETHOD GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList** aList);
NS_IMETHOD EnscriptionChanged(nsBoxLayoutState& aState, PRInt32 aIndex);

View File

@ -103,6 +103,7 @@ public:
NS_IMETHOD GetMouseThrough(PRBool& aMouseThrough)=0;
NS_IMETHOD MarkChildrenStyleChange()=0;
NS_IMETHOD MarkStyleChange(nsBoxLayoutState& aState)=0;
NS_IMETHOD DumpBox(FILE* out)=0;
static PRBool AddCSSPrefSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize);
static PRBool AddCSSMinSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize);

View File

@ -33,6 +33,7 @@
class nsIBox;
class nsBoxLayoutState;
class nsTempleLayout;
class nsGridLayout;
class nsObeliskLayout;
class nsMonumentLayout;
class nsBoxLayoutState;
@ -50,7 +51,7 @@ public:
class nsBoxSizeList
{
public:
virtual nsBoxSize GetBoxSize(nsBoxLayoutState& aState)=0;
virtual nsBoxSize GetBoxSize(nsBoxLayoutState& aState, PRBool aIsHorizontal)=0;
virtual nsBoxSizeList* GetFirst()=0;
virtual nsBoxSizeList* GetLast()=0;
virtual nsBoxSizeList* GetNext()=0;
@ -85,11 +86,12 @@ public:
NS_IMETHOD CastToTemple(nsTempleLayout** aTemple)=0;
NS_IMETHOD CastToObelisk(nsObeliskLayout** aObelisk)=0;
NS_IMETHOD CastToGrid(nsGridLayout** aGrid)=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 BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast)=0;
NS_IMETHOD BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast, PRBool aIsHorizontal)=0;
NS_IMETHOD GetParentMonument(nsIBox* aBox, nsCOMPtr<nsIBox>& aParentBox, nsIMonument** aParentMonument)=0;
NS_IMETHOD GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList** aList)=0;
NS_IMETHOD EnscriptionChanged(nsBoxLayoutState& aState, PRInt32 aIndex)=0;

View File

@ -33,6 +33,89 @@
#include "nsIScrollableFrame.h"
#include "nsBox.h"
// ----- Monument Iterator -----
nsLayoutIterator::nsLayoutIterator(nsIBox* aBox):mBox(nsnull),mStartBox(aBox),mScrollFrameCount(0)
{
}
void
nsLayoutIterator::Reset()
{
mBox = nsnull;
}
PRBool
nsLayoutIterator::GetNextLayout(nsIBoxLayout** aLayout)
{
if (mBox == nsnull) {
mBox = mStartBox;
} else {
mBox->GetNextBox(&mBox);
}
if (!mBox) {
if (mScrollFrameCount > 0) {
mBox = mScrollFrames[--mScrollFrameCount];
return GetNextLayout(aLayout);
}
*aLayout = nsnull;
return PR_FALSE;
}
nsresult rv = NS_OK;
nsCOMPtr<nsIScrollableFrame> scrollFrame = do_QueryInterface(mBox, &rv);
if (scrollFrame) {
nsIFrame* scrolledFrame = nsnull;
scrollFrame->GetScrolledFrame(nsnull, scrolledFrame);
NS_ASSERTION(scrolledFrame,"Error no scroll frame!!");
mScrollFrames[mScrollFrameCount++] = mBox;
nsCOMPtr<nsIBox> b = do_QueryInterface(scrolledFrame);
mBox = b;
}
nsCOMPtr<nsIBoxLayout> layout;
mBox->GetLayoutManager(getter_AddRefs(layout));
*aLayout = layout;
NS_IF_ADDREF(*aLayout);
return PR_TRUE;
}
// ---- Monument Iterator -----
nsMonumentIterator::nsMonumentIterator(nsIBox* aBox):nsLayoutIterator(aBox)
{
}
PRBool
nsMonumentIterator::GetNextMonument(nsIMonument** aMonument)
{
nsCOMPtr<nsIBoxLayout> layout;
while(GetNextLayout(getter_AddRefs(layout))) {
if (layout)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIMonument> monument = do_QueryInterface(layout, &rv);
*aMonument = monument;
if (monument) {
NS_IF_ADDREF(*aMonument);
return PR_TRUE;
}
}
}
return PR_FALSE;
}
//------ nsInfoListNodeImpl ----
void
@ -211,7 +294,7 @@ nsBoxSizeListImpl::RemoveListener()
}
nsBoxSize
nsBoxSizeListImpl::GetBoxSize(nsBoxLayoutState& aState)
nsBoxSizeListImpl::GetBoxSize(nsBoxLayoutState& aState, PRBool aIsHorizontal)
{
if (!mIsSet) {
@ -222,7 +305,7 @@ nsBoxSizeListImpl::GetBoxSize(nsBoxLayoutState& aState)
nsBoxSizeList* node = mFirst;
while(node) {
nsBoxSize size = node->GetBoxSize(aState);
nsBoxSize size = node->GetBoxSize(aState, aIsHorizontal);
if (size.pref > mBoxSize.pref)
mBoxSize.pref = size.pref;
@ -247,11 +330,9 @@ nsBoxSizeListImpl::GetBoxSize(nsBoxLayoutState& aState)
}
nsBoxSize
nsBoxSizeListNodeImpl::GetBoxSize(nsBoxLayoutState& aState)
nsBoxSizeListNodeImpl::GetBoxSize(nsBoxLayoutState& aState, PRBool aIsHorizontal)
{
nsBoxSize size;
PRBool isHorizontal = PR_FALSE;
mBox->GetOrientation(isHorizontal);
nsSize pref(0,0);
nsSize min(0,0);
@ -266,7 +347,7 @@ nsBoxSizeListNodeImpl::GetBoxSize(nsBoxLayoutState& aState)
mBox->GetFlex(aState, flex);
nsBox::AddMargin(mBox, pref);
size.Add(min, pref, max, ascent, flex, isHorizontal);
size.Add(min, pref, max, ascent, flex, !aIsHorizontal);
return size;
}
@ -292,6 +373,13 @@ nsMonumentLayout::CastToObelisk(nsObeliskLayout** aObelisk)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsMonumentLayout::CastToGrid(nsGridLayout** aGrid)
{
*aGrid = nsnull;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsMonumentLayout::GetParentMonument(nsIBox* aBox, nsCOMPtr<nsIBox>& aParentBox, nsIMonument** aParentMonument)
{
@ -416,7 +504,7 @@ nsMonumentLayout::GetMonumentsAt(nsIBox* aBox, PRInt32 aMonumentIndex, nsBoxSize
NS_IMETHODIMP
nsMonumentLayout::BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast)
nsMonumentLayout::BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast, PRBool aIsHorizontal)
{
aFirst = aLast = new (aState) nsBoxSize();
@ -432,19 +520,17 @@ nsMonumentLayout::BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBox
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);
aFirst->Add(min, pref, max, ascent, flex, aIsHorizontal);
aFirst->Add(borderPadding,aIsHorizontal);
aFirst->Add(margin,aIsHorizontal);
return NS_OK;
}

View File

@ -33,13 +33,37 @@
#include "nsSprocketLayout.h"
#include "nsIMonument.h"
class nsTempleLayout;
class nsGridLayout;
class nsBoxLayoutState;
class nsIPresShell;
class nsLayoutIterator
{
public:
nsLayoutIterator(nsIBox* aBox);
virtual void Reset();
virtual PRBool GetNextLayout(nsIBoxLayout** aLayout);
virtual void GetBox(nsIBox** aBox) { *aBox = mBox; }
protected:
nsIBox* mBox;
nsIBox* mStartBox;
PRInt32 mScrollFrameCount;
nsIBox* mScrollFrames[100];
};
class nsMonumentIterator: public nsLayoutIterator
{
public:
nsMonumentIterator(nsIBox* aBox);
virtual PRBool GetNextMonument(nsIMonument** aMonument);
};
class nsBoxSizeListNodeImpl : public nsBoxSizeList
{
public:
virtual nsBoxSize GetBoxSize(nsBoxLayoutState& aState);
virtual nsBoxSize GetBoxSize(nsBoxLayoutState& aState, PRBool aIsHorizontal);
virtual nsBoxSizeList* GetFirst() { return nsnull; }
virtual nsBoxSizeList* GetLast() { return nsnull; }
virtual nsBoxSizeList* GetNext() { return mNext; }
@ -73,7 +97,7 @@ public:
class nsBoxSizeListImpl : public nsBoxSizeListNodeImpl
{
public:
virtual nsBoxSize GetBoxSize(nsBoxLayoutState& aState);
virtual nsBoxSize GetBoxSize(nsBoxLayoutState& aState, PRBool aIsHorizontal);
virtual nsBoxSizeList* GetFirst() { return mFirst; }
virtual nsBoxSizeList* GetLast() { return mLast; }
virtual PRInt32 GetCount() { return mCount; }
@ -103,11 +127,12 @@ public:
NS_IMETHOD CastToTemple(nsTempleLayout** aTemple);
NS_IMETHOD CastToObelisk(nsObeliskLayout** aObelisk);
NS_IMETHOD CastToGrid(nsGridLayout** aGrid);
NS_IMETHOD GetOtherMonuments(nsIBox* aBox, nsBoxSizeList** aList);
NS_IMETHOD GetOtherMonumentsAt(nsIBox* aBox, PRInt32 aIndexOfObelisk, nsBoxSizeList** aList, nsMonumentLayout* aRequestor = nsnull);
NS_IMETHOD GetOtherTemple(nsIBox* aBox, nsTempleLayout** aTemple, nsIBox** aTempleBox, nsMonumentLayout* aRequestor = nsnull);
NS_IMETHOD GetMonumentsAt(nsIBox* aBox, PRInt32 aMonumentIndex, nsBoxSizeList** aList);
NS_IMETHOD BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast);
NS_IMETHOD BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast, PRBool aIsHorizontal);
NS_IMETHOD GetParentMonument(nsIBox* aBox, nsCOMPtr<nsIBox>& aParentBox, nsIMonument** aParentMonument);
NS_IMETHOD GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList** aList);
NS_IMETHOD EnscriptionChanged(nsBoxLayoutState& aState, PRInt32 aIndex);

View File

@ -31,6 +31,7 @@
#include "nsTempleLayout.h"
#include "nsBoxLayoutState.h"
#include "nsBox.h"
#include "nsIScrollableFrame.h"
nsresult
NS_NewObeliskLayout( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout)
@ -90,20 +91,27 @@ nsObeliskLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSi
PRBool isHorizontal = PR_FALSE;
aBox->GetOrientation(isHorizontal);
//nscoord totalWidth = 0;
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 max width is smaller than aSizes then set it.
nsBoxSize size = node->GetBoxSize(aState);
nsBoxSize size = node->GetBoxSize(aState, isHorizontal);
nscoord s = size.pref;
nsMargin bp(0,0,0,0);
aBox->GetBorderAndPadding(bp);
if (isHorizontal) {
s += bp.top + bp.bottom;
} else {
s += bp.left + bp.right;
}
nscoord& s2 = GET_HEIGHT(aSize, isHorizontal);
if (s > s2)
s2 = s;
}
return rv;
@ -125,9 +133,18 @@ nsObeliskLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSiz
// 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);
nsBoxSize size = node->GetBoxSize(aState, isHorizontal);
nscoord s = size.min;
nsMargin bp(0,0,0,0);
aBox->GetBorderAndPadding(bp);
if (isHorizontal) {
s += bp.top + bp.bottom;
} else {
s += bp.left + bp.right;
}
nscoord& s2 = GET_HEIGHT(aSize, isHorizontal);
if (s > s2)
@ -153,7 +170,7 @@ nsObeliskLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSiz
// 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);
nsBoxSize size = node->GetBoxSize(aState, isHorizontal);
nscoord s = size.max;
nscoord& s2 = GET_HEIGHT(aSize, isHorizontal);
@ -217,15 +234,84 @@ nsObeliskLayout::PopulateBoxSizes(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxS
GetOtherTemple(aBox, &temple, &aTempleBox);
if (temple) {
// substitute our sizes for the other temples obelisk sizes.
PRBool isHorizontal = PR_FALSE;
aTempleBox->GetOrientation(isHorizontal);
nsBoxSize* first = nsnull;
nsBoxSize* last = nsnull;
temple->BuildBoxSizeList(aTempleBox, aState, first, last);
temple->BuildBoxSizeList(aTempleBox, aState, first, last, isHorizontal);
aBoxSizes = first;
}
nsSprocketLayout::PopulateBoxSizes(aBox, aState, aBoxSizes, aComputedBoxSizes, aMinSize, aMaxSize, aFlexes);
}
void
nsObeliskLayout::ComputeChildSizes(nsIBox* aBox,
nsBoxLayoutState& aState,
nscoord& aGivenSize,
nsBoxSize* aBoxSizes,
nsComputedBoxSize*& aComputedBoxSizes)
{
nsCOMPtr<nsIBoxLayout> layout;
nsCOMPtr<nsIMonument> parentMonument;
nsCOMPtr<nsIScrollableFrame> scrollable;
nsresult rv = NS_OK;
aBox->GetParentBox(&aBox);
nscoord size = aGivenSize;
while (aBox) {
aBox->GetLayoutManager(getter_AddRefs(layout));
parentMonument = do_QueryInterface(layout, &rv);
if (NS_SUCCEEDED(rv) && parentMonument) {
// we have a parent monument good. Go up until we hit the grid.
nsGridLayout* grid;
parentMonument->CastToGrid(&grid);
if (grid) {
if (size > aGivenSize) {
nscoord diff = size - aGivenSize;
aGivenSize += diff;
nsSprocketLayout::ComputeChildSizes(aBox, aState, aGivenSize, aBoxSizes, aComputedBoxSizes);
nsComputedBoxSize* s = aComputedBoxSizes;
nsComputedBoxSize* last = aComputedBoxSizes;
while(s)
{
last = s;
s = s->next;
}
last->size -= diff;
aGivenSize -= diff;
} else {
nsSprocketLayout::ComputeChildSizes(aBox, aState, aGivenSize, aBoxSizes, aComputedBoxSizes);
}
return;
}
} else {
scrollable = do_QueryInterface(aBox, &rv);
if (NS_SUCCEEDED(rv)) {
// oops we are in a scrollable. Did it change our size?
// if so remove the excess space.
nsRect r;
aBox->GetBounds(r);
PRBool isHorizontal = PR_FALSE;
aBox->GetOrientation(isHorizontal);
if (size < GET_WIDTH(r, isHorizontal)) {
if (isHorizontal) {
size = r.width;
} else {
size = r.height;
}
}
}
}
aBox->GetParentBox(&aBox);
}
NS_ERROR("Not in GRID!!!");
}
void
nsObeliskLayout::WillBeDestroyed(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList& aList)
{

View File

@ -64,6 +64,13 @@ protected:
*/
virtual void PopulateBoxSizes(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsBoxSize*& aBoxSizes, nsComputedBoxSize*& aComputedBoxSizes, nscoord& aMinSize, nscoord& aMaxSize, PRInt32& aFlexes);
virtual void ComputeChildSizes(nsIBox* aBox,
nsBoxLayoutState& aState,
nscoord& aGivenSize,
nsBoxSize* aBoxSizes,
nsComputedBoxSize*& aComputedBoxSizes);
virtual void WillBeDestroyed(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList& aList);
virtual void Desecrated(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList& aList);

View File

@ -309,7 +309,7 @@ nsSliderFrame::Layout(nsBoxLayoutState& aState)
// if there is more room than the thumb need stretch the
// thumb
nscoord thumbsize = nsSprocketLayout::Round(nscoord(ourmaxpos * mRatio), onePixel);
nscoord thumbsize = NSToCoordRound(ourmaxpos * mRatio);
if (thumbsize > thumbcoord) {
nscoord flex = 0;
@ -845,36 +845,6 @@ nsSliderFrame::Destroy(nsIPresContext* aPresContext)
mMediator = nsnull;
}
// Ensure our repeat service isn't going... it's possible that a scrollbar can disappear out
// from under you while you're in the process of scrolling.
//nsRepeatService::GetInstance()->Stop();
// XXX: HACK! WORKAROUND FOR BUG 21571
/*
the root cause of the crash is that nsSliderFrame implements nsIDOMEventListener and passes
itself to nsEventListenerManager::AddEventListener().
nsEventListenerManager::AddEventListener() assumes it is passed an
object that is governed by ref-counting. But nsSliderFrame is **not** a
ref-counted object, and it's lifetime is implicitly controlled by the lifetime
of the frame model. By passing itself to
nsEventListenerManager::AddEventListener(), the slider is passing in a pointer
that can be yanked out from underneath the event listener manager. When the
event listener manager is destroyed, it correctly tries to clean up any objects
still under it's control, including the already-deleted slider.
This bug is only evident when a slider is the last focused object before deletion.
Calling RemoveListener() removes *this* from nsEventListenerManager,
removing the worst symptom of the bug.
The real solution is to create a ref-counted listener object for the
slider to hand off to nsEventListenerManager::AddEventListener().
Part of that fix should be removing nsSliderFrame::AddRef and
nsSliderFrame::Release, which were masking this problem. Without those
methods, we would have gotten assertions as soon as the first slider was passed
to any interface that tried to refcount it.
*/
// RemoveListener(); // remove this line when 21571 is fixed properly
// call base class Destroy()
return nsBoxFrame::Destroy(aPresContext);
}

View File

@ -46,6 +46,7 @@
nsCOMPtr<nsIBoxLayout> nsSprocketLayout::gInstance = new nsSprocketLayout();
//#define DEBUG_GROW
#define DEBUG_SPRING_SIZE 8
#define DEBUG_BORDER_SIZE 2
@ -281,6 +282,11 @@ nsSprocketLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
height = childComputedBoxSize->size;
}
if (frameState & NS_STATE_IS_HORIZONTAL)
x += (childBoxSize->left);
else
y += (childBoxSize->left);
nextX = x;
nextY = y;
@ -308,6 +314,11 @@ nsSprocketLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
maxAscent);
if (frameState & NS_STATE_IS_HORIZONTAL)
nextX += (childBoxSize->right);
else
nextY += (childBoxSize->right);
childRect.x = x;
childRect.y = y;
@ -328,11 +339,11 @@ nsSprocketLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
child->GetMargin(margin);
//if (childRect.width >= margin.left + margin.right && childRect.height >= margin.top + margin.bottom)
childRect.Deflate(margin);
if (childRect.width < 0)
childRect.width = 0;
childRect.width = 0;
if (childRect.height < 0)
childRect.height = 0;
childRect.height = 0;
if (passes > 0) {
layout = PR_FALSE;
@ -395,6 +406,10 @@ nsSprocketLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
if (newChildRect != childRect)
{
#ifdef DEBUG_GROW
child->DumpBox(stdout);
printf(" GREW from (%d,%d) -> (%d,%d)\n", childRect.width, childRect.height, newChildRect.width, newChildRect.height);
#endif
newChildRect.Inflate(margin);
childRect.Inflate(margin);
@ -949,20 +964,6 @@ nsSprocketLayout::InvalidateComputedSizes(nsComputedBoxSize* aComputedBoxSizes)
}
}
PRInt32
nsSprocketLayout::Round(PRInt32 aCoord, PRInt32 aOnePixel)
{
/*
PRInt32 newCoordPx = aCoord/aOnePixel;
PRInt32 diff = aCoord - (newCoordPx*aOnePixel);
if (diff > aOnePixel/2)
newCoordPx++;
return newCoordPx*aOnePixel;
*/
return aCoord;
}
void
nsSprocketLayout::ComputeChildSizes(nsIBox* aBox,
nsBoxLayoutState& aState,
@ -971,9 +972,9 @@ nsSprocketLayout::ComputeChildSizes(nsIBox* aBox,
nsComputedBoxSize*& aComputedBoxSizes)
{
float p2t;
aState.GetPresContext()->GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
// float p2t;
// aState.GetPresContext()->GetScaledPixelsToTwips(&p2t);
//nscoord onePixel = NSIntPixelsToTwips(1, p2t);
PRInt32 sizeRemaining = aGivenSize;
PRInt32 springConstantsRemaining = 0;
@ -1017,11 +1018,14 @@ nsSprocketLayout::ComputeChildSizes(nsIBox* aBox,
springConstantsRemaining += boxSizes->flex;
sizeRemaining -= boxSizes->pref;
}
sizeRemaining -= (boxSizes->left + boxSizes->right);
//}
boxSizes = boxSizes->next;
if (!computedBoxSizes->next)
if (boxSizes && !computedBoxSizes->next)
computedBoxSizes->next = new (aState) nsComputedBoxSize();
computedBoxSizes = computedBoxSizes->next;
@ -1058,7 +1062,7 @@ nsSprocketLayout::ComputeChildSizes(nsIBox* aBox,
// ----- look at our min and max limits make sure we aren't too small or too big -----
if (!computedBoxSizes->valid) {
PRInt32 newSize = Round(pref + (sizeRemaining*flex/springConstantsRemaining), onePixel);
PRInt32 newSize = pref + sizeRemaining*flex/springConstantsRemaining; //NSToCoordRound(float((sizeRemaining*flex)/springConstantsRemaining));
if (newSize<=min) {
computedBoxSizes->size = min;
@ -1085,6 +1089,7 @@ nsSprocketLayout::ComputeChildSizes(nsIBox* aBox,
// ---- once we have removed and min and max issues just stretch us out in the remaining space
// ---- or shrink us. Depends on the size remaining and the spring constants
nscoord oldsize = aGivenSize;
aGivenSize = 0;
boxSizes = aBoxSizes;
computedBoxSizes = aComputedBoxSizes;
@ -1100,11 +1105,13 @@ nsSprocketLayout::ComputeChildSizes(nsIBox* aBox,
flex = boxSizes->flex;
if (!computedBoxSizes->valid) {
computedBoxSizes->size = Round(pref + flex*sizeRemaining/springConstantsRemaining,onePixel);
computedBoxSizes->size = pref + flex*sizeRemaining/springConstantsRemaining; //NSToCoordFloor(float((flex*sizeRemaining)/springConstantsRemaining));
computedBoxSizes->valid = PR_TRUE;
}
aGivenSize += (boxSizes->left + boxSizes->right);
aGivenSize += computedBoxSizes->size;
// }
boxSizes = boxSizes->next;
@ -1421,10 +1428,15 @@ nsBoxSize::Add(const nsMargin& aMargin, PRBool aIsHorizontal)
if (aIsHorizontal) {
left += aMargin.left;
right += aMargin.right;
pref -= (aMargin.left + aMargin.right);
} else {
left += aMargin.top;
right += aMargin.bottom;
pref -= (aMargin.top + aMargin.bottom);
}
if (pref < min)
min = pref;
}
nsComputedBoxSize::nsComputedBoxSize()

View File

@ -107,8 +107,6 @@ public:
nsSprocketLayout();
static PRInt32 Round(PRInt32 aCoord, PRInt32 aOnePixel);
protected:
virtual PRBool IsHorizontal(nsIBox* aBox) const;

View File

@ -44,7 +44,8 @@
#include "nsCSSRendering.h"
#include "nsIViewManager.h"
#include "nsBoxLayoutState.h"
#include "nsIBox.h"
#include "nsBox.h"
#include "nsContainerBox.h"
nsCOMPtr<nsIBoxLayout> nsStackLayout::gInstance = new nsStackLayout();
@ -217,7 +218,7 @@ nsStackLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
{
nsRect clientRect;
aBox->GetClientRect(clientRect);
nsIBox* child = nsnull;
PRBool grow;
@ -235,9 +236,10 @@ nsStackLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
if (childRect.width < 0)
childRect.width = 0;
if (childRect.height < 0)
childRect.height = 0;
child->SetBounds(aState, childRect);
child->Layout(aState);
child->GetBounds(childRect);
@ -256,7 +258,10 @@ nsStackLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
child->GetNextBox(&child);
}
NS_ASSERTION(passes < 10,"Infinite loop! Someone won't stop growing!!");
NS_BOX_ASSERTION(aBox, passes < 10,"Infinite loop! Someone won't stop growing!!");
//if (passes > 3)
// printf("Growing!!!\n");
passes++;
} while(grow);

View File

@ -30,6 +30,7 @@
#include "nsTempleLayout.h"
#include "nsIBox.h"
#include "nsCOMPtr.h"
#include "nsIScrollableFrame.h"
nsresult
NS_NewTempleLayout( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout)
@ -80,15 +81,13 @@ nsTempleLayout::GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSiz
nsIBox* box = nsnull;
aBox->GetChildBox(&box);
nsBoxSizeList* current = nsnull;
nsCOMPtr<nsIBoxLayout> layout;
while(box) {
nsCOMPtr<nsIMonument> monument;
box->GetLayoutManager(getter_AddRefs(layout));
nsMonumentIterator it(box);
nsresult rv = NS_OK;
nsCOMPtr<nsIMonument> monument = do_QueryInterface(layout, &rv);
while(it.GetNextMonument(getter_AddRefs(monument))) {
if (monument) {
it.GetBox(&box);
if (!mMonuments) {
mMonuments = new nsBoxSizeListImpl(box);
@ -121,10 +120,7 @@ nsTempleLayout::GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSiz
} else {
current = current->GetNext();
}
}
}
box->GetNextBox(&box);
}
}
*aList = mMonuments;
@ -132,8 +128,10 @@ nsTempleLayout::GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSiz
}
NS_IMETHODIMP
nsTempleLayout::BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast)
nsTempleLayout::BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast, PRBool aIsHorizontal)
{
// ok we need to build a nsBoxSize for each obelisk in this temple. We will then return the list of them.
// We are just returning a flattened list that we will use to layout our each cell.
nsIBox* box = nsnull;
aBox->GetChildBox(&box);
@ -143,17 +141,23 @@ nsTempleLayout::BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSi
nsBoxSize* first;
nsBoxSize* last;
PRInt32 count = 0;
nsCOMPtr<nsIBoxLayout> layout;
while(box) {
nsIMonument* monument = nsnull;
box->GetLayoutManager(getter_AddRefs(layout));
nsLayoutIterator it(box);
while(it.GetNextLayout(getter_AddRefs(layout))) {
it.GetBox(&box);
if (layout) {
layout->QueryInterface(NS_GET_IID(nsIMonument), (void**)&monument);
nsresult rv = NS_OK;
nsCOMPtr<nsIMonument> monument = do_QueryInterface(layout, &rv);
if (monument)
monument->BuildBoxSizeList(box, aState, first, last);
monument->BuildBoxSizeList(box, aState, first, last, aIsHorizontal);
else {
nsMonumentLayout::BuildBoxSizeList(box, aState, first, last);
nsMonumentLayout::BuildBoxSizeList(box, aState, first, last, aIsHorizontal);
first->bogus = PR_TRUE;
}
@ -164,25 +168,32 @@ nsTempleLayout::BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSi
aLast = last;
}
box->GetNextBox(&box);
count++;
}
/*
// ok now we might have a margin or border. If we do then we need to take that into account. One example
// might be if we are oriented vertically making us a "columns" and we contain a horizontal obelisk "row".
// Now say we have a left border of 10px. Well if we just layed things out then the whole row would be pushed over and
// the columns would not not line up. So we must take the space from somewhere. So if its on the left we take from the first
// child (which is leftmost) and if its on the right we take from the last child (which is rightmost). So for our example we
// need to subtract 10px from the first child.
// so get the border and padding and add them up.
nsMargin borderPadding(0,0,0,0);
aBox->GetBorderAndPadding(borderPadding);
nsMargin margin(0,0,0,0);
aBox->GetMargin(margin);
// add the margins up
nsMargin leftMargin(borderPadding.left + margin.left, borderPadding.top + margin.top, 0, 0);
nsMargin rightMargin(0,0, borderPadding.right + margin.right, borderPadding.bottom + margin.bottom);
// Subtract them out.
PRBool isHorizontal = PR_FALSE;
aBox->GetOrientation(isHorizontal);
(aFirst)->Add(leftMargin,isHorizontal);
(aLast)->Add(rightMargin,isHorizontal);
*/
aFirst->Add(leftMargin,isHorizontal);
aLast->Add(rightMargin,isHorizontal);
return NS_OK;
}

View File

@ -39,7 +39,7 @@ public:
friend nsresult NS_NewTempleLayout(nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout);
NS_IMETHOD CastToTemple(nsTempleLayout** aTemple);
NS_IMETHOD BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast);
NS_IMETHOD BuildBoxSizeList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aFirst, nsBoxSize*& aLast, PRBool aIsHorizontal);
NS_IMETHOD GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSizeList** aList);
NS_IMETHOD ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aPrevBox, nsIBox* aChildList);
NS_IMETHOD ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList);