Bug 366531 - "deCOMtaminate nsBox.h [BoundsCheck()]" [p=ldx@users.sourceforge.net (Lorenzo Dieryckx) r+sr=roc a1.9=damons]

This commit is contained in:
reed@reedloden.com 2008-01-04 21:49:44 -08:00
Родитель ab40731434
Коммит 327b1fc144
12 изменённых файлов: 40 добавлений и 54 удалений

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

@ -1092,10 +1092,8 @@ nsGrid::GetMaxRowHeight(nsBoxLayoutState& aState, PRInt32 aIndex, PRBool aIsHori
// ignore collapsed children
if (!child->IsCollapsed(aState))
{
nsSize childSize = child->GetMaxSize(aState);
nsSize min = child->GetMinSize(aState);
nsBox::BoundsCheckMinMax(min, childSize);
nsSize childSize = nsBox::BoundsCheckMinMax(min, child->GetMaxSize(aState));
nsSprocketLayout::AddLargestSize(size, childSize, aIsHorizontal);
}
}

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

@ -218,7 +218,7 @@ nsGridRowLeafLayout::PopulateBoxSizes(nsIBox* aBox, nsBoxLayoutState& aState, ns
}
// initialize the box size here
nsBox::BoundsCheck(min, pref, max);
pref = nsBox::BoundsCheck(min, pref, max);
current = new (aState) nsBoxSize();
current->pref = pref;

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

@ -469,9 +469,7 @@ nsBox::GetPrefSize(nsBoxLayoutState& aState)
nsSize minSize = GetMinSize(aState);
nsSize maxSize = GetMaxSize(aState);
BoundsCheck(minSize, pref, maxSize);
return pref;
return BoundsCheck(minSize, pref, maxSize);
}
nsSize
@ -991,35 +989,30 @@ nsBox::AddMargin(nsSize& aSize, const nsMargin& aMargin)
aSize.height += aMargin.top + aMargin.bottom;
}
void
nsBox::BoundsCheck(nscoord& aMin, nscoord& aPref, nscoord& aMax)
nscoord
nsBox::BoundsCheck(nscoord aMin, nscoord aPref, nscoord aMax)
{
if (aMax < aMin)
aMax = aMin;
if (aPref > aMax)
aPref = aMax;
if (aPref < aMin)
aPref = aMin;
return aPref;
}
void
nsBox::BoundsCheckMinMax(nsSize& aMinSize, nsSize& aMaxSize)
nsSize
nsBox::BoundsCheckMinMax(const nsSize& aMinSize, const nsSize& aMaxSize)
{
if (aMaxSize.width < aMinSize.width) {
aMaxSize.width = aMinSize.width;
}
if (aMaxSize.height < aMinSize.height)
aMaxSize.height = aMinSize.height;
return nsSize(PR_MAX(aMaxSize.width, aMinSize.width),
PR_MAX(aMaxSize.height, aMinSize.height));
}
void
nsBox::BoundsCheck(nsSize& aMinSize, nsSize& aPrefSize, nsSize& aMaxSize)
nsSize
nsBox::BoundsCheck(const nsSize& aMinSize, const nsSize& aPrefSize, const nsSize& aMaxSize)
{
BoundsCheck(aMinSize.width, aPrefSize.width, aMaxSize.width);
BoundsCheck(aMinSize.height, aPrefSize.height, aMaxSize.height);
return nsSize(BoundsCheck(aMinSize.width, aPrefSize.width, aMaxSize.width),
BoundsCheck(aMinSize.height, aPrefSize.height, aMaxSize.height));
}
#ifdef DEBUG_LAYOUT

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

@ -117,9 +117,9 @@ rollbox.
static void AddMargin(nsIBox* aChild, nsSize& aSize);
static void AddMargin(nsSize& aSize, const nsMargin& aMargin);
static void BoundsCheckMinMax(nsSize& aMinSize, nsSize& aMaxSize);
static void BoundsCheck(nsSize& aMinSize, nsSize& aPrefSize, nsSize& aMaxSize);
static void BoundsCheck(nscoord& aMinSize, nscoord& aPrefSize, nscoord& aMaxSize);
static nsSize BoundsCheckMinMax(const nsSize& aMinSize, const nsSize& aMaxSize);
static nsSize BoundsCheck(const nsSize& aMinSize, const nsSize& aPrefSize, const nsSize& aMaxSize);
static nscoord BoundsCheck(nscoord aMinSize, nscoord aPrefSize, nscoord aMaxSize);
protected:

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

@ -722,7 +722,7 @@ nsBoxFrame::Reflow(nsPresContext* aPresContext,
prefSize = GetPrefSize(state);
nsSize minSize = GetMinSize(state);
nsSize maxSize = GetMaxSize(state);
BoundsCheck(minSize, prefSize, maxSize);
prefSize = BoundsCheck(minSize, prefSize, maxSize);
}
// get our desiredSize
@ -821,10 +821,9 @@ nsBoxFrame::GetPrefSize(nsBoxLayoutState& aBoxLayoutState)
nsSize minSize = GetMinSize(aBoxLayoutState);
nsSize maxSize = GetMaxSize(aBoxLayoutState);
BoundsCheck(minSize, size, maxSize);
mPrefSize = size;
mPrefSize = BoundsCheck(minSize, size, maxSize);
return size;
return mPrefSize;
}
nscoord

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

@ -453,10 +453,9 @@ nsImageBoxFrame::GetPrefSize(nsBoxLayoutState& aState)
nsIBox::AddCSSPrefSize(aState, this, size);
nsSize minSize = GetMinSize(aState);
nsSize maxSize = GetMaxSize(aState);
BoundsCheck(minSize, size, maxSize);
nsSize maxSize = GetMaxSize(aState);
return size;
return BoundsCheck(minSize, size, maxSize);
}
nsSize

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

@ -298,7 +298,7 @@ nsLeafBoxFrame::Reflow(nsPresContext* aPresContext,
prefSize = GetPrefSize(state);
nsSize minSize = GetMinSize(state);
nsSize maxSize = GetMaxSize(state);
BoundsCheck(minSize, prefSize, maxSize);
prefSize = BoundsCheck(minSize, prefSize, maxSize);
}
// get our desiredSize

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

@ -742,7 +742,7 @@ nsMenuFrame::DoLayout(nsBoxLayoutState& aState)
nsSize minSize = mPopupFrame->GetMinSize(aState);
nsSize maxSize = mPopupFrame->GetMaxSize(aState);
BoundsCheck(minSize, prefSize, maxSize);
prefSize = BoundsCheck(minSize, prefSize, maxSize);
if (sizeToPopup)
prefSize.width = mRect.width;
@ -1286,7 +1286,7 @@ nsMenuFrame::GetPrefSize(nsBoxLayoutState& aState)
// We now need to ensure that size is within the min - max range.
nsSize minSize = nsBoxFrame::GetMinSize(aState);
nsSize maxSize = GetMaxSize(aState);
BoundsCheck(minSize, size, maxSize);
size = BoundsCheck(minSize, size, maxSize);
}
return size;

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

@ -170,7 +170,7 @@ nsPopupSetFrame::DoLayout(nsBoxLayoutState& aState)
nsSize minSize = popupChild->GetMinSize(aState);
nsSize maxSize = popupChild->GetMaxSize(aState);
BoundsCheck(minSize, prefSize, maxSize);
prefSize = BoundsCheck(minSize, prefSize, maxSize);
popupChild->SetPreferredBounds(aState, nsRect(0,0,prefSize.width, prefSize.height));
popupChild->SetPopupPosition(nsnull);

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

@ -792,8 +792,8 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
if (atom != nsGkAtoms::splitter) {
nsSize prefSize = childBox->GetPrefSize(state);
nsSize minSize = childBox->GetMinSize(state);
nsSize maxSize = childBox->GetMaxSize(state);
nsBox::BoundsCheck(minSize, prefSize, maxSize);
nsSize maxSize = nsBox::BoundsCheckMinMax(minSize, childBox->GetMaxSize(state));
prefSize = nsBox::BoundsCheck(minSize, prefSize, maxSize);
mOuter->AddMargin(childBox, minSize);
mOuter->AddMargin(childBox, prefSize);

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

@ -360,7 +360,7 @@ nsSprocketLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
nsSize prefSize = child->GetPrefSize(aState);
nsSize minSize = child->GetMinSize(aState);
nsSize maxSize = child->GetMaxSize(aState);
nsBox::BoundsCheck(minSize, prefSize, maxSize);
prefSize = nsBox::BoundsCheck(minSize, prefSize, maxSize);
AddMargin(child, prefSize);
width = PR_MIN(prefSize.width, originalClientRect.width);
@ -496,7 +496,7 @@ nsSprocketLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
// we didn't exceed it.
nsSize minSize = child->GetMinSize(aState);
nsSize maxSize = child->GetMaxSize(aState);
nsBox::BoundsCheckMinMax(minSize, maxSize);
maxSize = nsBox::BoundsCheckMinMax(minSize, maxSize);
// make sure the size is in our max size.
if (childRect.width > maxSize.width)
@ -800,14 +800,14 @@ nsSprocketLayout::PopulateBoxSizes(nsIBox* aBox, nsBoxLayoutState& aState, nsBox
pref = child->GetPrefSize(aState);
min = child->GetMinSize(aState);
max = child->GetMaxSize(aState);
max = nsBox::BoundsCheckMinMax(min, child->GetMaxSize(aState));
ascent = child->GetBoxAscent(aState);
nsMargin margin;
child->GetMargin(margin);
ascent += margin.top;
//}
nsBox::BoundsCheck(min, pref, max);
pref = nsBox::BoundsCheck(min, pref, max);
AddMargin(child, pref);
AddMargin(child, min);
@ -920,7 +920,7 @@ nsSprocketLayout::PopulateBoxSizes(nsIBox* aBox, nsBoxLayoutState& aState, nsBox
// we specified all our children are equal size;
if (frameState & NS_STATE_EQUAL_SIZE) {
nsBox::BoundsCheck(biggestMinWidth, biggestPrefWidth, smallestMaxWidth);
biggestPrefWidth = nsBox::BoundsCheck(biggestMinWidth, biggestPrefWidth, smallestMaxWidth);
currentBox = aBoxSizes;
@ -1053,9 +1053,8 @@ nsSprocketLayout::ChildResized(nsIBox* aBox,
// ok if the height changed then we need to reflow everyone but us at the new height
// so we will set the changed index to be us. And signal that we need a new pass.
nsSize max = aChild->GetMaxSize(aState);
nsSize min = aChild->GetMinSize(aState);
nsBox::BoundsCheckMinMax(min, max);
nsSize min = aChild->GetMinSize(aState);
nsSize max = nsBox::BoundsCheckMinMax(min, aChild->GetMaxSize(aState));
AddMargin(aChild, max);
if (isHorizontal)
@ -1090,8 +1089,8 @@ nsSprocketLayout::ChildResized(nsIBox* aBox,
if (childActualWidth > childLayoutWidth) {
nsSize min = aChild->GetMinSize(aState);
nsSize max = aChild->GetMaxSize(aState);
nsBox::BoundsCheckMinMax(min, max);
nsSize max = nsBox::BoundsCheckMinMax(min, aChild->GetMaxSize(aState));
AddMargin(aChild, max);
// our width now becomes the new size
@ -1466,9 +1465,8 @@ nsSprocketLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSi
if (!child->IsCollapsed(aState))
{
// if completely redefined don't even ask our child for its size.
nsSize max = child->GetMaxSize(aState);
nsSize min = child->GetMinSize(aState);
nsBox::BoundsCheckMinMax(min, max);
nsSize max = nsBox::BoundsCheckMinMax(min, child->GetMaxSize(aState));
AddMargin(child, max);
AddSmallestSize(aSize, max, isHorizontal);

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

@ -136,9 +136,8 @@ nsStackLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSize)
nsIBox* child = aBox->GetChildBox();
while (child) {
nsSize max = child->GetMaxSize(aState);
nsSize min = child->GetMinSize(aState);
nsBox::BoundsCheckMinMax(min, max);
nsSize max = nsBox::BoundsCheckMinMax(min, child->GetMaxSize(aState));
AddMargin(child, max);
AddOffset(aState, child, max);