--- a/layout/xul/nsSprocketLayout.cpp
+++ b/layout/xul/nsSprocketLayout.cpp
@@ -36,29 +36,29 @@ NS_NewSprocketLayout(nsCOMPtr<nsBoxLayou
{
if (!nsSprocketLayout::gInstance) {
nsSprocketLayout::gInstance = new nsSprocketLayout();
NS_IF_ADDREF(nsSprocketLayout::gInstance);
}
// we have not instance variables so just return our static one.
aNewLayout = nsSprocketLayout::gInstance;
return NS_OK;
-}
+}
/*static*/ void
nsSprocketLayout::Shutdown()
{
NS_IF_RELEASE(gInstance);
}
nsSprocketLayout::nsSprocketLayout()
{
}
-bool
+bool
nsSprocketLayout::IsXULHorizontal(nsIFrame* aBox)
{
return (aBox->GetStateBits() & NS_STATE_IS_HORIZONTAL) != 0;
}
void
nsSprocketLayout::GetFrameState(nsIFrame* aBox, nsFrameState& aState)
{
@@ -67,17 +67,17 @@ nsSprocketLayout::GetFrameState(nsIFrame
static uint8_t
GetFrameDirection(nsIFrame* aBox)
{
return aBox->StyleVisibility()->mDirection;
}
static void
-HandleBoxPack(nsIFrame* aBox, const nsFrameState& aFrameState, nscoord& aX, nscoord& aY,
+HandleBoxPack(nsIFrame* aBox, const nsFrameState& aFrameState, nscoord& aX, nscoord& aY,
const nsRect& aOriginalRect, const nsRect& aClientRect)
{
// In the normal direction we lay out our kids in the positive direction (e.g., |x| will get
// bigger for a horizontal box, and |y| will get bigger for a vertical box). In the reverse
// direction, the opposite is true. We'll be laying out each child at a smaller |x| or
// |y|.
uint8_t frameDirection = GetFrameDirection(aBox);
@@ -86,17 +86,17 @@ HandleBoxPack(nsIFrame* aBox, const nsFr
// The normal direction. |x| increases as we move through our children.
aX = aClientRect.x;
}
else {
// The reverse direction. |x| decreases as we move through our children.
aX = aClientRect.x + aOriginalRect.width;
}
// |y| is always in the normal direction in horizontal boxes
- aY = aClientRect.y;
+ aY = aClientRect.y;
}
else {
// take direction property into account for |x| in vertical boxes
if (frameDirection == NS_STYLE_DIRECTION_LTR) {
// The normal direction. |x| increases as we move through our children.
aX = aClientRect.x;
}
else {
@@ -112,33 +112,33 @@ HandleBoxPack(nsIFrame* aBox, const nsFr
aY = aClientRect.y + aOriginalRect.height;
}
}
// Get our pack/alignment information.
nsIFrame::Halignment halign = aBox->GetXULHAlign();
nsIFrame::Valignment valign = aBox->GetXULVAlign();
- // The following code handles box PACKING. Packing comes into play in the case where the computed size for
+ // The following code handles box PACKING. Packing comes into play in the case where the computed size for
// all of our children (now stored in our client rect) is smaller than the size available for
- // the box (stored in |aOriginalRect|).
- //
+ // the box (stored in |aOriginalRect|).
+ //
// Here we adjust our |x| and |y| variables accordingly so that we start at the beginning,
// middle, or end of the box.
//
// XXXdwh JUSTIFY needs to be implemented!
if (aFrameState & NS_STATE_IS_HORIZONTAL) {
switch(halign) {
case nsBoxFrame::hAlign_Left:
break; // Nothing to do. The default initialized us properly.
case nsBoxFrame::hAlign_Center:
if (aFrameState & NS_STATE_IS_DIRECTION_NORMAL)
aX += (aOriginalRect.width - aClientRect.width)/2;
- else
+ else
aX -= (aOriginalRect.width - aClientRect.width)/2;
break;
case nsBoxFrame::hAlign_Right:
if (aFrameState & NS_STATE_IS_DIRECTION_NORMAL)
aX += (aOriginalRect.width - aClientRect.width);
else
aX -= (aOriginalRect.width - aClientRect.width);
@@ -169,19 +169,19 @@ HandleBoxPack(nsIFrame* aBox, const nsFr
NS_IMETHODIMP
nsSprocketLayout::XULLayout(nsIFrame* aBox, nsBoxLayoutState& aState)
{
// See if we are collapsed. If we are, then simply iterate over all our
// children and give them a rect of 0 width and height.
if (aBox->IsXULCollapsed()) {
nsIFrame* child = nsBox::GetChildXULBox(aBox);
- while(child)
+ while(child)
{
- nsBoxFrame::LayoutChildAt(aState, child, nsRect(0,0,0,0));
+ nsBoxFrame::LayoutChildAt(aState, child, nsRect(0,0,0,0));
child = nsBox::GetNextXULBox(child);
}
return NS_OK;
}
nsBoxLayoutState::AutoReflowDepth depth(aState);
mozilla::AutoStackArena arena;
@@ -209,31 +209,31 @@ nsSprocketLayout::XULLayout(nsIFrame* aB
// Build a list of our children's desired sizes and computed sizes
nsBoxSize* boxSizes = nullptr;
nsComputedBoxSize* computedBoxSizes = nullptr;
nscoord min = 0;
nscoord max = 0;
int32_t flexes = 0;
PopulateBoxSizes(aBox, aState, boxSizes, min, max, flexes);
-
+
// The |size| variable will hold the total size of children along the axis of
// the box. Continuing with the example begun in the comment above, size would
// be 150 pixels.
nscoord size = clientRect.width;
if (!IsXULHorizontal(aBox))
size = clientRect.height;
ComputeChildSizes(aBox, aState, size, boxSizes, computedBoxSizes);
// After the call to ComputeChildSizes, the |size| variable contains the
// total required size of all the children. We adjust our clientRect in the
// appropriate dimension to match this size. In our example, we now assign
// 150 pixels into the clientRect.width.
//
- // The variables |min| and |max| hold the minimum required size box must be
+ // The variables |min| and |max| hold the minimum required size box must be
// in the OPPOSITE orientation, e.g., for a horizontal box, |min| is the minimum
// height we require to enclose our children, and |max| is the maximum height
// required to enclose our children.
if (IsXULHorizontal(aBox)) {
clientRect.width = size;
if (clientRect.height < min)
clientRect.height = min;
@@ -251,98 +251,98 @@ nsSprocketLayout::XULLayout(nsIFrame* aB
clientRect.width = max;
}
}
// With the sizes computed, now it's time to lay out our children.
bool finished;
nscoord passes = 0;
- // We flow children at their preferred locations (along with the appropriate computed flex).
+ // We flow children at their preferred locations (along with the appropriate computed flex).
// After we flow a child, it is possible that the child will change its size. If/when this happens,
// we have to do another pass. Typically only 2 passes are required, but the code is prepared to
// do as many passes as are necessary to achieve equilibrium.
nscoord x = 0;
nscoord y = 0;
nscoord origX = 0;
nscoord origY = 0;
// |childResized| lets us know if a child changed its size after we attempted to lay it out at
// the specified size. If this happens, we usually have to do another pass.
bool childResized = false;
// |passes| stores our number of passes. If for any reason we end up doing more than, say, 10
// passes, we assert to indicate that something is seriously screwed up.
passes = 0;
- do
- {
+ do
+ {
#ifdef DEBUG_REFLOW
if (passes > 0) {
AddIndents();
printf("ChildResized doing pass: %d\n", passes);
}
-#endif
+#endif
// Always assume that we're done. This will change if, for example, children don't stay
// the same size after being flowed.
finished = true;
// Handle box packing.
HandleBoxPack(aBox, frameState, x, y, originalClientRect, clientRect);
// Now that packing is taken care of we set up a few additional
// tracking variables.
origX = x;
origY = y;
- // Now we iterate over our box children and our box size lists in
+ // Now we iterate over our box children and our box size lists in
// parallel. For each child, we look at its sizes and figure out
// where to place it.
nsComputedBoxSize* childComputedBoxSize = computedBoxSizes;
nsBoxSize* childBoxSize = boxSizes;
nsIFrame* child = nsBox::GetChildXULBox(aBox);
int32_t count = 0;
while (child || (childBoxSize && childBoxSize->bogus))
- {
+ {
// If for some reason, our lists are not the same length, we guard
// by bailing out of the loop.
if (childBoxSize == nullptr) {
NS_NOTREACHED("Lists not the same length.");
break;
}
-
+
nscoord width = clientRect.width;
nscoord height = clientRect.height;
if (!childBoxSize->bogus) {
// We have a valid box size entry. This entry already contains information about our
// sizes along the axis of the box (e.g., widths in a horizontal box). If our default
// ALIGN is not stretch, however, then we also need to know the child's size along the
// opposite axis.
if (!(frameState & NS_STATE_AUTO_STRETCH)) {
nsSize prefSize = child->GetXULPrefSize(aState);
nsSize minSize = child->GetXULMinSize(aState);
nsSize maxSize = child->GetXULMaxSize(aState);
prefSize = nsBox::BoundsCheck(minSize, prefSize, maxSize);
-
+
AddMargin(child, prefSize);
width = std::min(prefSize.width, originalClientRect.width);
height = std::min(prefSize.height, originalClientRect.height);
}
}
- // Obtain the computed size along the axis of the box for this child from the computedBoxSize entry.
+ // Obtain the computed size along the axis of the box for this child from the computedBoxSize entry.
// We store the result in |width| for horizontal boxes and |height| for vertical boxes.
if (frameState & NS_STATE_IS_HORIZONTAL)
width = childComputedBoxSize->size;
else
height = childComputedBoxSize->size;
-
+
// Adjust our x/y for the left/right spacing.
if (frameState & NS_STATE_IS_HORIZONTAL) {
if (frameState & NS_STATE_IS_DIRECTION_NORMAL)
x += (childBoxSize->left);
else
x -= (childBoxSize->right);
} else {
if (frameState & NS_STATE_IS_DIRECTION_NORMAL)
@@ -369,17 +369,17 @@ nsSprocketLayout::XULLayout(nsIFrame* aB
// our client rect. Remember, clientRect is not the total rect of the enclosing
// box. It currently holds our perception of how big the children needed to
// be.
if (childRect.width > clientRect.width)
clientRect.width = childRect.width;
if (childRect.height > clientRect.height)
clientRect.height = childRect.height;
-
+
// Either |nextX| or |nextY| is updated by this function call, according
// to our axis.
nscoord nextX = x;
nscoord nextY = y;
ComputeChildsNextPosition(aBox, x, y, nextX, nextY, childRect);
// Now we further update our nextX/Y along our axis.
@@ -390,29 +390,29 @@ nsSprocketLayout::XULLayout(nsIFrame* aB
nextX += (childBoxSize->right);
else
nextX -= (childBoxSize->left);
childRect.y = originalClientRect.y;
}
else {
if (frameState & NS_STATE_IS_DIRECTION_NORMAL)
nextY += (childBoxSize->right);
- else
+ else
nextY -= (childBoxSize->left);
if (GetFrameDirection(aBox) == NS_STYLE_DIRECTION_LTR) {
childRect.x = originalClientRect.x;
} else {
// keep the right edge of the box the same
childRect.x = clientRect.x + originalClientRect.width - childRect.width;
}
}
-
+
// If we encounter a completely bogus box size, we just leave this child completely
// alone and continue through the loop to the next child.
- if (childBoxSize->bogus)
+ if (childBoxSize->bogus)
{
childComputedBoxSize = childComputedBoxSize->next;
childBoxSize = childBoxSize->next;
count++;
x = nextX;
y = nextY;
continue;
}
@@ -467,48 +467,48 @@ nsSprocketLayout::XULLayout(nsIFrame* aB
maxSize = nsBox::BoundsCheckMinMax(minSize, maxSize);
// make sure the size is in our max size.
if (childRect.width > maxSize.width)
childRect.width = maxSize.width;
if (childRect.height > maxSize.height)
childRect.height = maxSize.height;
-
+
// set it again
child->SetXULBounds(aState, childRect);
}
// If we already determined that layout was required or if our size has changed, then
// we make sure to call layout on the child, since its children may need to be shifted
// around as a result of the size change.
if (layout || sizeChanged)
child->XULLayout(aState);
-
- // If the child was a block or inline (e.g., HTML) it may have changed its rect *during* layout.
+
+ // If the child was a block or inline (e.g., HTML) it may have changed its rect *during* layout.
// We have to check for this.
nsRect newChildRect(child->GetRect());
if (!newChildRect.IsEqualInterior(childRect)) {
#ifdef DEBUG_GROW
child->XULDumpBox(stdout);
printf(" GREW from (%d,%d) -> (%d,%d)\n", childRect.width, childRect.height, newChildRect.width, newChildRect.height);
#endif
newChildRect.Inflate(margin);
childRect.Inflate(margin);
// The child changed size during layout. The ChildResized method handles this
// scenario.
ChildResized(aBox,
- aState,
+ aState,
child,
childBoxSize,
childComputedBoxSize,
- boxSizes,
- computedBoxSizes,
+ boxSizes,
+ computedBoxSizes,
childRect,
newChildRect,
clientRect,
flexes,
finished);
// We note that a child changed size, which means that another pass will be required.
childResized = true;
@@ -539,33 +539,33 @@ nsSprocketLayout::XULLayout(nsIFrame* aB
// keep the right edge the same
newChildRect.x = childRect.XMost() - newChildRect.width;
}
}
// If the child resized then recompute its position.
ComputeChildsNextPosition(aBox, x, y, nextX, nextY, newChildRect);
- if (newChildRect.width >= margin.left + margin.right && newChildRect.height >= margin.top + margin.bottom)
+ if (newChildRect.width >= margin.left + margin.right && newChildRect.height >= margin.top + margin.bottom)
newChildRect.Deflate(margin);
- if (childRect.width >= margin.left + margin.right && childRect.height >= margin.top + margin.bottom)
+ if (childRect.width >= margin.left + margin.right && childRect.height >= margin.top + margin.bottom)
childRect.Deflate(margin);
-
+
child->SetXULBounds(aState, newChildRect);
// If we are the first box that changed size, then we don't need to do a second pass
if (count == 0)
finished = true;
}
// Now update our x/y finally.
x = nextX;
y = nextY;
-
+
// Move to the next child.
childComputedBoxSize = childComputedBoxSize->next;
childBoxSize = childBoxSize->next;
child = nsBox::GetNextXULBox(child);
count++;
}
@@ -618,32 +618,32 @@ nsSprocketLayout::XULLayout(nsIFrame* aB
// Compare against our original x and y and only worry about adjusting the children if
// we really did have to change the positions because of packing (typically for 'center'
// or 'end' pack values).
if (x != origX || y != origY) {
nsIFrame* child = nsBox::GetChildXULBox(aBox);
// reposition all our children
- while (child)
+ while (child)
{
nsRect childRect(child->GetRect());
childRect.x += (x - origX);
childRect.y += (y - origY);
child->SetXULBounds(aState, childRect);
child = nsBox::GetNextXULBox(child);
}
}
// Perform out-of-axis alignment for non-stretch alignments
if (!(frameState & NS_STATE_AUTO_STRETCH)) {
AlignChildren(aBox, aState);
}
-
- // That's it! If you made it this far without having a nervous breakdown,
+
+ // That's it! If you made it this far without having a nervous breakdown,
// congratulations! Go get yourself a beer.
return NS_OK;
}
void
nsSprocketLayout::PopulateBoxSizes(nsIFrame* aBox, nsBoxLayoutState& aState, nsBoxSize*& aBoxSizes, nscoord& aMinSize, nscoord& aMaxSize, int32_t& aFlexes)
{
// used for the equal size flag
@@ -679,46 +679,46 @@ nsSprocketLayout::PopulateBoxSizes(nsIFr
// set flexes
nsIFrame* child = nsBox::GetChildXULBox(aBox);
aFlexes = 0;
nsBoxSize* currentBox = nullptr;
#if 0
nsBoxSize* start = aBoxSizes;
-
+
while(child)
{
// ok if we started with a list move down the list
// until we reach the end. Then start looking at childen.
// This feature is used extensively for Grid.
- nscoord flex = 0;
+ nscoord flex = 0;
if (!start) {
if (!currentBox) {
aBoxSizes = new (aState) nsBoxSize();
currentBox = aBoxSizes;
} else {
currentBox->next = new (aState) nsBoxSize();
currentBox = currentBox->next;
}
-
+
flex = child->GetXULFlex();
currentBox->flex = flex;
currentBox->collapsed = child->IsXULCollapsed();
} else {
flex = start->flex;
start = start->next;
}
-
- if (flex > 0)
+
+ if (flex > 0)
aFlexes++;
-
+
child = GetNextXULBox(child);
}
#endif
// get pref, min, max
child = nsBox::GetChildXULBox(aBox);
currentBox = aBoxSizes;
nsBoxSize* last = nullptr;
@@ -796,23 +796,23 @@ nsSprocketLayout::PopulateBoxSizes(nsIFr
maxFlex = flex;
}
currentBox->flex = flex;
}
// we specified all our children are equal size;
if (frameState & NS_STATE_EQUAL_SIZE) {
- if (prefWidth > biggestPrefWidth)
+ if (prefWidth > biggestPrefWidth)
biggestPrefWidth = prefWidth;
- if (minWidth > biggestMinWidth)
+ if (minWidth > biggestMinWidth)
biggestMinWidth = minWidth;
- if (maxWidth < smallestMaxWidth)
+ if (maxWidth < smallestMaxWidth)
smallestMaxWidth = maxWidth;
} else { // not we can set our children right now.
currentBox->pref = prefWidth;
currentBox->min = minWidth;
currentBox->max = maxWidth;
}
NS_ASSERTION(minWidth <= prefWidth && prefWidth <= maxWidth,"Bad min, pref, max widths!");
@@ -841,23 +841,23 @@ nsSprocketLayout::PopulateBoxSizes(nsIFr
last = currentBox;
currentBox = currentBox->next;
}
if (childCount > 0) {
nscoord maxAllowedFlex = nscoord_MAX / childCount;
-
+
if (MOZ_UNLIKELY(maxFlex > maxAllowedFlex)) {
// clamp all the flexes
currentBox = aBoxSizes;
while (currentBox) {
currentBox->flex = std::min(currentBox->flex, maxAllowedFlex);
- currentBox = currentBox->next;
+ currentBox = currentBox->next;
}
}
}
#ifdef DEBUG
else {
NS_ASSERTION(maxFlex == 0, "How did that happen?");
}
#endif
@@ -882,21 +882,21 @@ nsSprocketLayout::PopulateBoxSizes(nsIFr
}
currentBox = currentBox->next;
}
}
}
void
-nsSprocketLayout::ComputeChildsNextPosition(nsIFrame* aBox,
- const nscoord& aCurX,
- const nscoord& aCurY,
- nscoord& aNextX,
- nscoord& aNextY,
+nsSprocketLayout::ComputeChildsNextPosition(nsIFrame* aBox,
+ const nscoord& aCurX,
+ const nscoord& aCurY,
+ nscoord& aNextX,
+ nscoord& aNextY,
const nsRect& aCurrentChildSize)
{
// Get the position along the box axis for the child.
// The out-of-axis position is not set.
nsFrameState frameState = nsFrameState(0);
GetFrameState(aBox, frameState);
if (IsXULHorizontal(aBox)) {
@@ -1006,50 +1006,50 @@ nsSprocketLayout::AlignChildren(nsIFrame
}
child = nsBox::GetNextXULBox(child);
}
}
void
nsSprocketLayout::ChildResized(nsIFrame* aBox,
- nsBoxLayoutState& aState,
+ nsBoxLayoutState& aState,
nsIFrame* aChild,
nsBoxSize* aChildBoxSize,
nsComputedBoxSize* aChildComputedSize,
- nsBoxSize* aBoxSizes,
- nsComputedBoxSize* aComputedBoxSizes,
- const nsRect& aChildLayoutRect,
- nsRect& aChildActualRect,
+ nsBoxSize* aBoxSizes,
+ nsComputedBoxSize* aComputedBoxSizes,
+ const nsRect& aChildLayoutRect,
+ nsRect& aChildActualRect,
nsRect& aContainingRect,
- int32_t aFlexes,
+ int32_t aFlexes,
bool& aFinished)
-
+
{
nsRect childCurrentRect(aChildLayoutRect);
bool isHorizontal = IsXULHorizontal(aBox);
nscoord childLayoutWidth = GET_WIDTH(aChildLayoutRect,isHorizontal);
nscoord& childActualWidth = GET_WIDTH(aChildActualRect,isHorizontal);
- nscoord& containingWidth = GET_WIDTH(aContainingRect,isHorizontal);
-
+ nscoord& containingWidth = GET_WIDTH(aContainingRect,isHorizontal);
+
//nscoord childLayoutHeight = GET_HEIGHT(aChildLayoutRect,isHorizontal);
nscoord& childActualHeight = GET_HEIGHT(aChildActualRect,isHorizontal);
nscoord& containingHeight = GET_HEIGHT(aContainingRect,isHorizontal);
bool recompute = false;
// if we are a horizontal box see if the child will fit inside us.
if ( childActualHeight > containingHeight) {
// if we are a horizontal box and the child is bigger than our height
// 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 min = aChild->GetXULMinSize(aState);
+ nsSize min = aChild->GetXULMinSize(aState);
nsSize max = nsBox::BoundsCheckMinMax(min, aChild->GetXULMaxSize(aState));
AddMargin(aChild, max);
if (isHorizontal)
childActualHeight = max.height < childActualHeight ? max.height : childActualHeight;
else
childActualHeight = max.width < childActualHeight ? max.width : childActualHeight;
@@ -1069,24 +1069,24 @@ nsSprocketLayout::ChildResized(nsIFrame*
InvalidateComputedSizes(aComputedBoxSizes);
nsComputedBoxSize* node = aComputedBoxSizes;
while(node) {
node->resized = false;
node = node->next;
}
- }
+ }
}
- }
-
+ }
+
if (childActualWidth > childLayoutWidth) {
nsSize min = aChild->GetXULMinSize(aState);
nsSize max = nsBox::BoundsCheckMinMax(min, aChild->GetXULMaxSize(aState));
-
+
AddMargin(aChild, max);
// our width now becomes the new size
if (isHorizontal)
childActualWidth = max.width < childActualWidth ? max.width : childActualWidth;
else
childActualWidth = max.height < childActualWidth ? max.height : childActualWidth;
@@ -1104,39 +1104,39 @@ nsSprocketLayout::ChildResized(nsIFrame*
InvalidateComputedSizes(aComputedBoxSizes);
nsComputedBoxSize* node = aComputedBoxSizes;
aChildComputedSize->resized = true;
while(node) {
if (node->resized)
node->valid = true;
-
+
node = node->next;
}
recompute = true;
aFinished = false;
} else {
containingWidth += aChildComputedSize->size - childLayoutWidth;
- }
+ }
}
}
if (recompute)
ComputeChildSizes(aBox, aState, containingWidth, aBoxSizes, aComputedBoxSizes);
if (!childCurrentRect.IsEqualInterior(aChildActualRect)) {
// the childRect includes the margin
- // make sure we remove it before setting
+ // make sure we remove it before setting
// the bounds.
nsMargin margin(0,0,0,0);
aChild->GetXULMargin(margin);
nsRect rect(aChildActualRect);
- if (rect.width >= margin.left + margin.right && rect.height >= margin.top + margin.bottom)
+ if (rect.width >= margin.left + margin.right && rect.height >= margin.top + margin.bottom)
rect.Deflate(margin);
aChild->SetXULBounds(aState, rect);
aChild->XULLayout(aState);
}
}
@@ -1146,98 +1146,98 @@ nsSprocketLayout::InvalidateComputedSize
while(aComputedBoxSizes) {
aComputedBoxSizes->valid = false;
aComputedBoxSizes = aComputedBoxSizes->next;
}
}
void
nsSprocketLayout::ComputeChildSizes(nsIFrame* aBox,
- nsBoxLayoutState& aState,
- nscoord& aGivenSize,
- nsBoxSize* aBoxSizes,
+ nsBoxLayoutState& aState,
+ nscoord& aGivenSize,
+ nsBoxSize* aBoxSizes,
nsComputedBoxSize*& aComputedBoxSizes)
-{
+{
//nscoord onePixel = aState.PresContext()->IntScaledPixelsToTwips(1);
int32_t sizeRemaining = aGivenSize;
int32_t spacerConstantsRemaining = 0;
// ----- calculate the spacers constants and the size remaining -----
if (!aComputedBoxSizes)
aComputedBoxSizes = new (aState) nsComputedBoxSize();
-
+
nsBoxSize* boxSizes = aBoxSizes;
nsComputedBoxSize* computedBoxSizes = aComputedBoxSizes;
int32_t count = 0;
int32_t validCount = 0;
- while (boxSizes)
+ while (boxSizes)
{
NS_ASSERTION((boxSizes->min <= boxSizes->pref && boxSizes->pref <= boxSizes->max),"bad pref, min, max size");
-
+
// ignore collapsed children
- // if (boxSizes->collapsed)
+ // if (boxSizes->collapsed)
// {
// computedBoxSizes->valid = true;
// computedBoxSizes->size = boxSizes->pref;
// validCount++;
// boxSizes->flex = 0;
// }// else {
-
- if (computedBoxSizes->valid) {
+
+ if (computedBoxSizes->valid) {
sizeRemaining -= computedBoxSizes->size;
validCount++;
} else {
if (boxSizes->flex == 0)
{
computedBoxSizes->valid = true;
computedBoxSizes->size = boxSizes->pref;
validCount++;
}
spacerConstantsRemaining += boxSizes->flex;
sizeRemaining -= boxSizes->pref;
}
sizeRemaining -= (boxSizes->left + boxSizes->right);
- //}
+ //}
boxSizes = boxSizes->next;
- if (boxSizes && !computedBoxSizes->next)
+ if (boxSizes && !computedBoxSizes->next)
computedBoxSizes->next = new (aState) nsComputedBoxSize();
computedBoxSizes = computedBoxSizes->next;
count++;
}
// everything accounted for?
if (validCount < count)
{
// ----- Ok we are give a size to fit into so stretch or squeeze to fit
// ----- Make sure we look at our min and max size
bool limit = true;
- for (int pass=1; true == limit; pass++)
+ for (int pass=1; true == limit; pass++)
{
limit = false;
boxSizes = aBoxSizes;
computedBoxSizes = aComputedBoxSizes;
- while (boxSizes) {
+ while (boxSizes) {
// ignore collapsed spacers
// if (!boxSizes->collapsed) {
-
+
nscoord pref = 0;
nscoord max = NS_INTRINSICSIZE;
nscoord min = 0;
nscoord flex = 0;
pref = boxSizes->pref;
min = boxSizes->min;
max = boxSizes->max;
@@ -1263,29 +1263,29 @@ nsSprocketLayout::ComputeChildSizes(nsIF
limit = true;
}
}
// }
boxSizes = boxSizes->next;
computedBoxSizes = computedBoxSizes->next;
}
}
- }
+ }
// ---- 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 spacer constants
aGivenSize = 0;
boxSizes = aBoxSizes;
computedBoxSizes = aComputedBoxSizes;
- while (boxSizes) {
+ while (boxSizes) {
// ignore collapsed spacers
// if (!(boxSizes && boxSizes->collapsed)) {
-
+
nscoord pref = 0;
nscoord flex = 0;
pref = boxSizes->pref;
flex = boxSizes->flex;
if (!computedBoxSizes->valid) {
computedBoxSizes->size = pref + int32_t(int64_t(sizeRemaining) * flex / spacerConstantsRemaining);
computedBoxSizes->valid = true;
@@ -1300,32 +1300,32 @@ nsSprocketLayout::ComputeChildSizes(nsIF
computedBoxSizes = computedBoxSizes->next;
}
}
nsSize
nsSprocketLayout::GetXULPrefSize(nsIFrame* aBox, nsBoxLayoutState& aState)
{
- nsSize vpref (0, 0);
+ nsSize vpref (0, 0);
bool isHorizontal = IsXULHorizontal(aBox);
nscoord biggestPref = 0;
// run through all the children and get their min, max, and preferred sizes
// return us the size of the box
nsIFrame* child = nsBox::GetChildXULBox(aBox);
nsFrameState frameState = nsFrameState(0);
GetFrameState(aBox, frameState);
bool isEqual = !!(frameState & NS_STATE_EQUAL_SIZE);
int32_t count = 0;
-
- while (child)
- {
+
+ while (child)
+ {
// ignore collapsed children
if (!child->IsXULCollapsed())
{
nsSize pref = child->GetXULPrefSize(aState);
AddMargin(child, pref);
if (isEqual) {
if (isHorizontal)
@@ -1346,17 +1346,17 @@ nsSprocketLayout::GetXULPrefSize(nsIFram
}
if (isEqual) {
if (isHorizontal)
vpref.width = biggestPref*count;
else
vpref.height = biggestPref*count;
}
-
+
// now add our border and padding
AddBorderAndPadding(aBox, vpref);
return vpref;
}
nsSize
nsSprocketLayout::GetXULMinSize(nsIFrame* aBox, nsBoxLayoutState& aState)
@@ -1371,24 +1371,24 @@ nsSprocketLayout::GetXULMinSize(nsIFrame
// return us the size of the box
nsIFrame* child = nsBox::GetChildXULBox(aBox);
nsFrameState frameState = nsFrameState(0);
GetFrameState(aBox, frameState);
bool isEqual = !!(frameState & NS_STATE_EQUAL_SIZE);
int32_t count = 0;
- while (child)
- {
+ while (child)
+ {
// ignore collapsed children
if (!child->IsXULCollapsed())
{
nsSize min = child->GetXULMinSize(aState);
nsSize pref(0,0);
-
+
// if the child is not flexible then
// its min size is its pref size.
if (child->GetXULFlex() == 0) {
pref = child->GetXULPrefSize(aState);
if (isHorizontal)
min.width = pref.width;
else
min.height = pref.height;
@@ -1408,17 +1408,17 @@ nsSprocketLayout::GetXULMinSize(nsIFrame
AddMargin(child, min);
AddLargestSize(minSize, min, isHorizontal);
count++;
}
child = nsBox::GetNextXULBox(child);
}
-
+
if (isEqual) {
if (isHorizontal)
minSize.width = biggestMin*count;
else
minSize.height = biggestMin*count;
}
// now add our border and padding
@@ -1440,18 +1440,18 @@ nsSprocketLayout::GetXULMaxSize(nsIFrame
// return us the size of the box
nsIFrame* child = nsBox::GetChildXULBox(aBox);
nsFrameState frameState = nsFrameState(0);
GetFrameState(aBox, frameState);
bool isEqual = !!(frameState & NS_STATE_EQUAL_SIZE);
int32_t count = 0;
- while (child)
- {
+ while (child)
+ {
// ignore collapsed children
if (!child->IsXULCollapsed())
{
// if completely redefined don't even ask our child for its size.
nsSize min = child->GetXULMinSize(aState);
nsSize max = nsBox::BoundsCheckMinMax(min, child->GetXULMaxSize(aState));
AddMargin(child, max);
@@ -1498,21 +1498,21 @@ nscoord
nsSprocketLayout::GetAscent(nsIFrame* aBox, nsBoxLayoutState& aState)
{
nscoord vAscent = 0;
bool isHorizontal = IsXULHorizontal(aBox);
// run through all the children and get their min, max, and preferred sizes
// return us the size of the box
-
+
nsIFrame* child = nsBox::GetChildXULBox(aBox);
-
- while (child)
- {
+
+ while (child)
+ {
// ignore collapsed children
//if (!child->IsXULCollapsed())
//{
// if completely redefined don't even ask our child for its size.
nscoord ascent = child->GetXULBoxAscent(aState);
nsMargin margin;
child->GetXULMargin(margin);
@@ -1523,17 +1523,17 @@ nsSprocketLayout::GetAscent(nsIFrame* aB
if (ascent > vAscent)
vAscent = ascent;
} else {
if (vAscent == 0)
vAscent = ascent;
}
//}
- child = nsBox::GetNextXULBox(child);
+ child = nsBox::GetNextXULBox(child);
}
nsMargin borderPadding;
aBox->GetXULBorderAndPadding(borderPadding);
return vAscent + borderPadding.top;
}
@@ -1573,32 +1573,32 @@ nsSprocketLayout::AddLargestSize(nsSize&
AddCoord(aSize.height, aSizeToAdd.height);
SetLargestSize(aSize, aSizeToAdd, aIsHorizontal);
}
void
nsSprocketLayout::AddCoord(nscoord& aCoord, nscoord aCoordToAdd)
{
- if (aCoord != NS_INTRINSICSIZE)
+ if (aCoord != NS_INTRINSICSIZE)
{
if (aCoordToAdd == NS_INTRINSICSIZE)
aCoord = aCoordToAdd;
else
aCoord += aCoordToAdd;
}
}
void
nsSprocketLayout::AddSmallestSize(nsSize& aSize, const nsSize& aSizeToAdd, bool aIsHorizontal)
{
if (aIsHorizontal)
AddCoord(aSize.width, aSizeToAdd.width);
else
AddCoord(aSize.height, aSizeToAdd.height);
-
+
SetSmallestSize(aSize, aSizeToAdd, aIsHorizontal);
}
bool
nsSprocketLayout::GetDefaultFlex(int32_t& aFlex)
{
aFlex = 0;
return true;
@@ -1621,31 +1621,31 @@ nsBoxSize::nsBoxSize()
left = 0;
right = 0;
flex = 0;
next = nullptr;
bogus = false;
}
-void*
+void*
nsBoxSize::operator new(size_t sz, nsBoxLayoutState& aState) CPP_THROW_NEW
{
return mozilla::AutoStackArena::Allocate(sz);
}
-void
+void
nsBoxSize::operator delete(void* aPtr, size_t sz)
{
}
-void*
+void*
nsComputedBoxSize::operator new(size_t sz, nsBoxLayoutState& aState) CPP_THROW_NEW
{
return mozilla::AutoStackArena::Allocate(sz);
}
-void
+void
nsComputedBoxSize::operator delete(void* aPtr, size_t sz)
{
}