nsSize nsGridLayout2::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState) { nsSize maxSize = nsStackLayout::GetMaxSize(aBox, aState); // if there are no <rows> tags that will sum up our columns, // sum up our columns here. nsSize total(NS_INTRINSICSIZE, NS_INTRINSICSIZE); nsIBox* rowsBox = mGrid.GetRowsBox(); nsIBox* columnsBox = mGrid.GetColumnsBox(); if (!rowsBox || !columnsBox) { if (!rowsBox) { total.height = 0; // max height is the sum of our rows PRInt32 rows = mGrid.GetRowCount(); for (PRInt32 i=0; i < rows; i++) { nscoord height = mGrid.GetMaxRowHeight(aState, i, PR_TRUE); AddWidth(total, height, PR_FALSE); // AddHeight } } if (!columnsBox) { total.width = 0; // max height is the sum of our rows PRInt32 columns = mGrid.GetColumnCount(); for (PRInt32 i=0; i < columns; i++) { nscoord width = mGrid.GetMaxRowHeight(aState, i, PR_FALSE); AddWidth(total, width, PR_TRUE); // AddWidth } } AddMargin(aBox, total); AddOffset(aState, aBox, total); AddSmallestSize(maxSize, total); } return maxSize; }
nsSize nsStackLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState) { nsSize maxSize (NS_INTRINSICSIZE, NS_INTRINSICSIZE); // run through all the children and get their min, max, and preferred sizes nsIBox* child = aBox->GetChildBox(); while (child) { nsSize min = child->GetMinSize(aState); nsSize max = nsBox::BoundsCheckMinMax(min, child->GetMaxSize(aState)); AddMargin(child, max); AddOffset(aState, child, max); AddSmallestSize(maxSize, max); child = child->GetNextBox(); } // now add our border and padding AddBorderAndPadding(aBox, maxSize); return maxSize; }
nsSize nsSprocketLayout::GetMaxSize(nsIFrame* aBox, nsBoxLayoutState& aState) { bool isHorizontal = IsHorizontal(aBox); nscoord smallestMax = NS_INTRINSICSIZE; nsSize maxSize (NS_INTRINSICSIZE, NS_INTRINSICSIZE); // run through all the children and get their min, max, and preferred sizes // return us the size of the box nsIFrame* child = nsBox::GetChildBox(aBox); nsFrameState frameState = nsFrameState(0); GetFrameState(aBox, frameState); bool isEqual = !!(frameState & NS_STATE_EQUAL_SIZE); int32_t count = 0; while (child) { // ignore collapsed children if (!child->IsCollapsed()) { // if completely redefined don't even ask our child for its size. nsSize min = child->GetMinSize(aState); nsSize max = nsBox::BoundsCheckMinMax(min, child->GetMaxSize(aState)); AddMargin(child, max); AddSmallestSize(maxSize, max, isHorizontal); if (isEqual) { if (isHorizontal) { if (max.width < smallestMax) smallestMax = max.width; } else { if (max.height < smallestMax) smallestMax = max.height; } } count++; } child = nsBox::GetNextBox(child); } if (isEqual) { if (isHorizontal) { if (smallestMax != NS_INTRINSICSIZE) maxSize.width = smallestMax*count; else maxSize.width = NS_INTRINSICSIZE; } else { if (smallestMax != NS_INTRINSICSIZE) maxSize.height = smallestMax*count; else maxSize.height = NS_INTRINSICSIZE; } } // now add our border and padding AddBorderAndPadding(aBox, maxSize); return maxSize; }