From fc63af3f2ada98fc4649e2dbcf037259980a4990 Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Wed, 3 Nov 2004 12:20:13 +0000 Subject: [PATCH] relanding fix for bug 265165 because it wasn't the source of Tp/Tdhtml regression --- layout/xul/base/src/grid/nsGrid.cpp | 4 +++- layout/xul/base/src/nsBox.cpp | 25 ++++++++++++++++++++++-- layout/xul/base/src/nsBox.h | 1 + layout/xul/base/src/nsSprocketLayout.cpp | 11 +++++++++++ layout/xul/base/src/nsStackLayout.cpp | 3 +++ xpfe/global/resources/content/xul.css | 2 ++ 6 files changed, 43 insertions(+), 3 deletions(-) diff --git a/layout/xul/base/src/grid/nsGrid.cpp b/layout/xul/base/src/grid/nsGrid.cpp index 065aeca74d1..3e83956a1ec 100644 --- a/layout/xul/base/src/grid/nsGrid.cpp +++ b/layout/xul/base/src/grid/nsGrid.cpp @@ -1173,8 +1173,10 @@ nsGrid::GetMaxRowHeight(nsBoxLayoutState& aState, PRInt32 aIndex, nscoord& aSize if (!isCollapsed) { nsSize childSize(0,0); - child->GetMaxSize(aState, childSize); + nsSize min(0,0); + child->GetMinSize(aState, min); + nsBox::BoundsCheckMinMax(min, childSize); nsSprocketLayout::AddLargestSize(size, childSize, aIsHorizontal); } diff --git a/layout/xul/base/src/nsBox.cpp b/layout/xul/base/src/nsBox.cpp index 08bf167660b..068a4c51f7b 100644 --- a/layout/xul/base/src/nsBox.cpp +++ b/layout/xul/base/src/nsBox.cpp @@ -1010,6 +1010,11 @@ nsIBox::AddCSSMinSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize) aSize.width = min; widthSet = PR_TRUE; } + } else if (position->mMinWidth.GetUnit() == eStyleUnit_Percent) { + float min = position->mMinWidth.GetPercentValue(); + NS_ASSERTION(min == 0.0f, "Non-zero percentage values not currently supported"); + aSize.width = 0; + widthSet = PR_TRUE; } if (position->mMinHeight.GetUnit() == eStyleUnit_Coord) { @@ -1018,6 +1023,11 @@ nsIBox::AddCSSMinSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize) aSize.height = min; heightSet = PR_TRUE; } + } else if (position->mMinHeight.GetUnit() == eStyleUnit_Percent) { + float min = position->mMinHeight.GetPercentValue(); + NS_ASSERTION(min == 0.0f, "Non-zero percentage values not currently supported"); + aSize.height = 0; + heightSet = PR_TRUE; } nsIContent* content = aBox->GetContent(); @@ -1228,8 +1238,8 @@ nsBox::AddInset(nsIBox* aBox, nsSize& aSize) void nsBox::BoundsCheck(nscoord& aMin, nscoord& aPref, nscoord& aMax) { - if (aMin > aMax) - aMin = aMax; + if (aMax < aMin) + aMax = aMin; if (aPref > aMax) aPref = aMax; @@ -1238,6 +1248,17 @@ nsBox::BoundsCheck(nscoord& aMin, nscoord& aPref, nscoord& aMax) aPref = aMin; } +void +nsBox::BoundsCheckMinMax(nsSize& aMinSize, nsSize& aMaxSize) +{ + if (aMaxSize.width < aMinSize.width) { + aMaxSize.width = aMinSize.width; + } + + if (aMaxSize.height < aMinSize.height) + aMaxSize.height = aMinSize.height; +} + void nsBox::BoundsCheck(nsSize& aMinSize, nsSize& aPrefSize, nsSize& aMaxSize) { diff --git a/layout/xul/base/src/nsBox.h b/layout/xul/base/src/nsBox.h index 2c648f847af..6ba67b5e315 100644 --- a/layout/xul/base/src/nsBox.h +++ b/layout/xul/base/src/nsBox.h @@ -133,6 +133,7 @@ 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); diff --git a/layout/xul/base/src/nsSprocketLayout.cpp b/layout/xul/base/src/nsSprocketLayout.cpp index 00925616d2b..116d3574310 100644 --- a/layout/xul/base/src/nsSprocketLayout.cpp +++ b/layout/xul/base/src/nsSprocketLayout.cpp @@ -514,7 +514,9 @@ nsSprocketLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState) if (sizeChanged) { // Our size is different. Sanity check against our maximum allowed size to ensure // we didn't exceed it. + child->GetMinSize(aState, minSize); child->GetMaxSize(aState, maxSize); + nsBox::BoundsCheckMinMax(minSize, maxSize); // make sure the size is in our max size. if (childRect.width > maxSize.width) @@ -1037,7 +1039,10 @@ nsSprocketLayout::ChildResized(nsIBox* aBox, // so we will set the changed index to be us. And signal that we need a new pass. nsSize max(0,0); + nsSize min(0,0); aChild->GetMaxSize(aState, max); + aChild->GetMinSize(aState, max); + nsBox::BoundsCheckMinMax(min, max); AddMargin(aChild, max); if (isHorizontal) @@ -1072,7 +1077,10 @@ nsSprocketLayout::ChildResized(nsIBox* aBox, if (childActualWidth > childLayoutWidth) { nsSize max(0,0); + nsSize min(0,0); + aChild->GetMinSize(aState, min); aChild->GetMaxSize(aState, max); + nsBox::BoundsCheckMinMax(min, max); AddMargin(aChild, max); // our width now becomes the new size @@ -1467,7 +1475,10 @@ nsSprocketLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSi { // if completely redefined don't even ask our child for its size. nsSize max(NS_INTRINSICSIZE, NS_INTRINSICSIZE); + nsSize min(NS_INTRINSICSIZE, NS_INTRINSICSIZE); child->GetMaxSize(aState, max); + child->GetMinSize(aState, min); + nsBox::BoundsCheckMinMax(min, max); AddMargin(child, max); AddSmallestSize(aSize, max, isHorizontal); diff --git a/layout/xul/base/src/nsStackLayout.cpp b/layout/xul/base/src/nsStackLayout.cpp index 3cb5b96c227..8fcb9f2dbf2 100644 --- a/layout/xul/base/src/nsStackLayout.cpp +++ b/layout/xul/base/src/nsStackLayout.cpp @@ -148,6 +148,9 @@ nsStackLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSize) while (child) { nsSize max(NS_INTRINSICSIZE, NS_INTRINSICSIZE); child->GetMaxSize(aState, max); + nsSize min(NS_INTRINSICSIZE, NS_INTRINSICSIZE); + child->GetMinSize(aState, min); + nsBox::BoundsCheckMinMax(min, max); AddMargin(child, max); AddOffset(aState, child, max); diff --git a/xpfe/global/resources/content/xul.css b/xpfe/global/resources/content/xul.css index d2c0227737a..fcd5a59a91b 100644 --- a/xpfe/global/resources/content/xul.css +++ b/xpfe/global/resources/content/xul.css @@ -707,6 +707,8 @@ grippy { .tree-splitter { width: 0px; max-width: 0px; + min-width: 0% ! important; + min-height: 0% ! important; -moz-box-ordinal-group: 2147483646; }