2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// Eric Vaughan
|
|
|
|
// Netscape Communications
|
|
|
|
//
|
|
|
|
// See documentation in associated header file
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "nsStackLayout.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsBoxLayoutState.h"
|
2000-06-03 02:15:09 +04:00
|
|
|
#include "nsBox.h"
|
2001-09-06 05:07:40 +04:00
|
|
|
#include "nsBoxFrame.h"
|
2006-12-26 20:47:52 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2001-09-06 05:07:40 +04:00
|
|
|
#include "nsIContent.h"
|
2014-02-28 03:04:46 +04:00
|
|
|
#include "nsNameSpaceManager.h"
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2011-10-28 22:33:28 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
nsBoxLayout* nsStackLayout::gInstance = nullptr;
|
2000-04-05 04:19:00 +04:00
|
|
|
|
2016-11-18 13:12:25 +03:00
|
|
|
#define SPECIFIED_LEFT (1 << eSideLeft)
|
|
|
|
#define SPECIFIED_RIGHT (1 << eSideRight)
|
|
|
|
#define SPECIFIED_TOP (1 << eSideTop)
|
|
|
|
#define SPECIFIED_BOTTOM (1 << eSideBottom)
|
2009-09-14 01:13:54 +04:00
|
|
|
|
2000-04-05 04:19:00 +04:00
|
|
|
nsresult
|
2015-12-08 02:27:01 +03:00
|
|
|
NS_NewStackLayout(nsCOMPtr<nsBoxLayout>& aNewLayout)
|
2000-04-05 04:19:00 +04:00
|
|
|
{
|
2000-11-08 06:20:22 +03:00
|
|
|
if (!nsStackLayout::gInstance) {
|
|
|
|
nsStackLayout::gInstance = new nsStackLayout();
|
|
|
|
NS_IF_ADDREF(nsStackLayout::gInstance);
|
|
|
|
}
|
2000-04-05 04:19:00 +04:00
|
|
|
// we have not instance variables so just return our static one.
|
|
|
|
aNewLayout = nsStackLayout::gInstance;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-11-08 06:20:22 +03:00
|
|
|
/*static*/ void
|
|
|
|
nsStackLayout::Shutdown()
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(gInstance);
|
|
|
|
}
|
|
|
|
|
2000-04-05 04:19:00 +04:00
|
|
|
nsStackLayout::nsStackLayout()
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-06-05 10:46:24 +04:00
|
|
|
/*
|
|
|
|
* Sizing: we are as wide as the widest child plus its left offset
|
|
|
|
* we are tall as the tallest child plus its top offset.
|
|
|
|
*
|
|
|
|
* Only children which have -moz-stack-sizing set to stretch-to-fit
|
|
|
|
* (the default) will be included in the size computations.
|
|
|
|
*/
|
|
|
|
|
2008-01-09 10:28:39 +03:00
|
|
|
nsSize
|
2016-04-21 07:28:31 +03:00
|
|
|
nsStackLayout::GetXULPrefSize(nsIFrame* aBox, nsBoxLayoutState& aState)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2008-06-05 10:46:24 +04:00
|
|
|
nsSize prefSize (0, 0);
|
2007-02-22 21:05:14 +03:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
nsIFrame* child = nsBox::GetChildXULBox(aBox);
|
2008-06-05 10:46:24 +04:00
|
|
|
while (child) {
|
2013-02-17 01:51:02 +04:00
|
|
|
if (child->StyleXUL()->mStretchStack) {
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize pref = child->GetXULPrefSize(aState);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2008-06-05 10:46:24 +04:00
|
|
|
AddMargin(child, pref);
|
2009-09-14 01:13:54 +04:00
|
|
|
nsMargin offset;
|
2015-12-07 21:17:47 +03:00
|
|
|
GetOffset(child, offset);
|
2009-09-14 01:13:54 +04:00
|
|
|
pref.width += offset.LeftRight();
|
|
|
|
pref.height += offset.TopBottom();
|
2008-06-05 10:46:24 +04:00
|
|
|
AddLargestSize(prefSize, pref);
|
|
|
|
}
|
2001-09-06 05:07:40 +04:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
child = nsBox::GetNextXULBox(child);
|
2001-09-06 05:07:40 +04:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2008-06-05 10:46:24 +04:00
|
|
|
AddBorderAndPadding(aBox, prefSize);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2008-06-05 10:46:24 +04:00
|
|
|
return prefSize;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2008-01-09 10:28:39 +03:00
|
|
|
nsSize
|
2016-04-21 07:28:31 +03:00
|
|
|
nsStackLayout::GetXULMinSize(nsIFrame* aBox, nsBoxLayoutState& aState)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2008-01-09 10:28:39 +03:00
|
|
|
nsSize minSize (0, 0);
|
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
nsIFrame* child = nsBox::GetChildXULBox(aBox);
|
2008-06-05 10:46:24 +04:00
|
|
|
while (child) {
|
2013-02-17 01:51:02 +04:00
|
|
|
if (child->StyleXUL()->mStretchStack) {
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize min = child->GetXULMinSize(aState);
|
2008-06-05 10:46:24 +04:00
|
|
|
|
|
|
|
AddMargin(child, min);
|
2009-09-14 01:13:54 +04:00
|
|
|
nsMargin offset;
|
2015-12-07 21:17:47 +03:00
|
|
|
GetOffset(child, offset);
|
2009-09-14 01:13:54 +04:00
|
|
|
min.width += offset.LeftRight();
|
|
|
|
min.height += offset.TopBottom();
|
2008-06-05 10:46:24 +04:00
|
|
|
AddLargestSize(minSize, min);
|
|
|
|
}
|
2001-09-06 05:07:40 +04:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
child = nsBox::GetNextXULBox(child);
|
2001-09-06 05:07:40 +04:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2008-01-09 10:28:39 +03:00
|
|
|
AddBorderAndPadding(aBox, minSize);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2008-01-09 10:28:39 +03:00
|
|
|
return minSize;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2008-01-09 10:28:39 +03:00
|
|
|
nsSize
|
2016-04-21 07:28:31 +03:00
|
|
|
nsStackLayout::GetXULMaxSize(nsIFrame* aBox, nsBoxLayoutState& aState)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2008-01-09 10:28:39 +03:00
|
|
|
nsSize maxSize (NS_INTRINSICSIZE, NS_INTRINSICSIZE);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
nsIFrame* child = nsBox::GetChildXULBox(aBox);
|
2008-06-05 10:46:24 +04:00
|
|
|
while (child) {
|
2013-02-17 01:51:02 +04:00
|
|
|
if (child->StyleXUL()->mStretchStack) {
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize min = child->GetXULMinSize(aState);
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize max = child->GetXULMaxSize(aState);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2008-06-05 10:46:24 +04:00
|
|
|
max = nsBox::BoundsCheckMinMax(min, max);
|
|
|
|
|
|
|
|
AddMargin(child, max);
|
2009-09-14 01:13:54 +04:00
|
|
|
nsMargin offset;
|
2015-12-07 21:17:47 +03:00
|
|
|
GetOffset(child, offset);
|
2009-09-14 01:13:54 +04:00
|
|
|
max.width += offset.LeftRight();
|
|
|
|
max.height += offset.TopBottom();
|
2008-06-05 10:46:24 +04:00
|
|
|
AddSmallestSize(maxSize, max);
|
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
child = nsBox::GetNextXULBox(child);
|
2001-09-06 05:07:40 +04:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2008-01-09 10:28:39 +03:00
|
|
|
AddBorderAndPadding(aBox, maxSize);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2008-01-09 10:28:39 +03:00
|
|
|
return maxSize;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-09 10:28:39 +03:00
|
|
|
nscoord
|
2012-08-06 07:00:57 +04:00
|
|
|
nsStackLayout::GetAscent(nsIFrame* aBox, nsBoxLayoutState& aState)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2008-01-09 10:28:39 +03:00
|
|
|
nscoord vAscent = 0;
|
2007-02-22 21:05:14 +03:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
nsIFrame* child = nsBox::GetChildXULBox(aBox);
|
2001-09-06 05:07:40 +04:00
|
|
|
while (child) {
|
2016-04-21 07:28:32 +03:00
|
|
|
nscoord ascent = child->GetXULBoxAscent(aState);
|
2001-09-06 05:07:40 +04:00
|
|
|
nsMargin margin;
|
2016-04-21 07:28:33 +03:00
|
|
|
child->GetXULMargin(margin);
|
2009-04-06 05:50:51 +04:00
|
|
|
ascent += margin.top;
|
2008-01-09 10:28:39 +03:00
|
|
|
if (ascent > vAscent)
|
|
|
|
vAscent = ascent;
|
2007-02-22 21:05:14 +03:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
child = nsBox::GetNextXULBox(child);
|
2001-09-06 05:07:40 +04:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2008-01-09 10:28:39 +03:00
|
|
|
return vAscent;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t
|
2015-12-07 21:17:47 +03:00
|
|
|
nsStackLayout::GetOffset(nsIFrame* aChild, nsMargin& aOffset)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2009-09-14 01:13:54 +04:00
|
|
|
aOffset = nsMargin(0, 0, 0, 0);
|
|
|
|
|
|
|
|
// get the left, right, top and bottom offsets
|
|
|
|
|
2001-09-06 05:07:40 +04:00
|
|
|
// As an optimization, we cache the fact that we are not positioned to avoid
|
2009-09-14 01:13:54 +04:00
|
|
|
// wasting time fetching attributes.
|
2016-04-21 07:28:30 +03:00
|
|
|
if (aChild->IsXULBoxFrame() &&
|
2007-04-24 12:14:58 +04:00
|
|
|
(aChild->GetStateBits() & NS_STATE_STACK_NOT_POSITIONED))
|
2009-09-14 01:13:54 +04:00
|
|
|
return 0;
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t offsetSpecified = 0;
|
2004-09-28 22:37:50 +04:00
|
|
|
nsIContent* content = aChild->GetContent();
|
2001-09-06 05:07:40 +04:00
|
|
|
if (content) {
|
2013-02-17 01:51:02 +04:00
|
|
|
bool ltr = aChild->StyleVisibility()->mDirection == NS_STYLE_DIRECTION_LTR;
|
2001-09-06 05:07:40 +04:00
|
|
|
nsAutoString value;
|
2012-07-27 17:59:29 +04:00
|
|
|
nsresult error;
|
2001-09-06 05:07:40 +04:00
|
|
|
|
2011-02-28 21:06:29 +03:00
|
|
|
content->GetAttr(kNameSpaceID_None, nsGkAtoms::start, value);
|
|
|
|
if (!value.IsEmpty()) {
|
|
|
|
value.Trim("%");
|
|
|
|
if (ltr) {
|
|
|
|
aOffset.left =
|
|
|
|
nsPresContext::CSSPixelsToAppUnits(value.ToInteger(&error));
|
|
|
|
offsetSpecified |= SPECIFIED_LEFT;
|
|
|
|
} else {
|
|
|
|
aOffset.right =
|
|
|
|
nsPresContext::CSSPixelsToAppUnits(value.ToInteger(&error));
|
|
|
|
offsetSpecified |= SPECIFIED_RIGHT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
content->GetAttr(kNameSpaceID_None, nsGkAtoms::end, value);
|
|
|
|
if (!value.IsEmpty()) {
|
|
|
|
value.Trim("%");
|
|
|
|
if (ltr) {
|
|
|
|
aOffset.right =
|
|
|
|
nsPresContext::CSSPixelsToAppUnits(value.ToInteger(&error));
|
|
|
|
offsetSpecified |= SPECIFIED_RIGHT;
|
|
|
|
} else {
|
|
|
|
aOffset.left =
|
|
|
|
nsPresContext::CSSPixelsToAppUnits(value.ToInteger(&error));
|
|
|
|
offsetSpecified |= SPECIFIED_LEFT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-26 20:47:52 +03:00
|
|
|
content->GetAttr(kNameSpaceID_None, nsGkAtoms::left, value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (!value.IsEmpty()) {
|
2001-09-06 05:07:40 +04:00
|
|
|
value.Trim("%");
|
2009-09-14 01:13:54 +04:00
|
|
|
aOffset.left =
|
|
|
|
nsPresContext::CSSPixelsToAppUnits(value.ToInteger(&error));
|
|
|
|
offsetSpecified |= SPECIFIED_LEFT;
|
|
|
|
}
|
|
|
|
|
|
|
|
content->GetAttr(kNameSpaceID_None, nsGkAtoms::right, value);
|
|
|
|
if (!value.IsEmpty()) {
|
|
|
|
value.Trim("%");
|
|
|
|
aOffset.right =
|
2007-02-07 10:46:44 +03:00
|
|
|
nsPresContext::CSSPixelsToAppUnits(value.ToInteger(&error));
|
2009-09-14 01:13:54 +04:00
|
|
|
offsetSpecified |= SPECIFIED_RIGHT;
|
2001-09-06 05:07:40 +04:00
|
|
|
}
|
|
|
|
|
2006-12-26 20:47:52 +03:00
|
|
|
content->GetAttr(kNameSpaceID_None, nsGkAtoms::top, value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (!value.IsEmpty()) {
|
2001-09-06 05:07:40 +04:00
|
|
|
value.Trim("%");
|
2009-09-14 01:13:54 +04:00
|
|
|
aOffset.top =
|
2007-02-07 10:46:44 +03:00
|
|
|
nsPresContext::CSSPixelsToAppUnits(value.ToInteger(&error));
|
2009-09-14 01:13:54 +04:00
|
|
|
offsetSpecified |= SPECIFIED_TOP;
|
2001-09-06 05:07:40 +04:00
|
|
|
}
|
2000-07-11 00:10:27 +04:00
|
|
|
|
2009-09-14 01:13:54 +04:00
|
|
|
content->GetAttr(kNameSpaceID_None, nsGkAtoms::bottom, value);
|
|
|
|
if (!value.IsEmpty()) {
|
|
|
|
value.Trim("%");
|
|
|
|
aOffset.bottom =
|
|
|
|
nsPresContext::CSSPixelsToAppUnits(value.ToInteger(&error));
|
|
|
|
offsetSpecified |= SPECIFIED_BOTTOM;
|
|
|
|
}
|
|
|
|
}
|
2000-07-11 00:10:27 +04:00
|
|
|
|
2016-04-21 07:28:30 +03:00
|
|
|
if (!offsetSpecified && aChild->IsXULBoxFrame()) {
|
2001-09-06 05:07:40 +04:00
|
|
|
// If no offset was specified at all, then we cache this fact to avoid requerying
|
|
|
|
// CSS or the content model.
|
2004-09-28 22:37:50 +04:00
|
|
|
aChild->AddStateBits(NS_STATE_STACK_NOT_POSITIONED);
|
2001-09-06 05:07:40 +04:00
|
|
|
}
|
2009-09-14 01:13:54 +04:00
|
|
|
|
2001-09-19 06:05:57 +04:00
|
|
|
return offsetSpecified;
|
2001-09-06 05:07:40 +04:00
|
|
|
}
|
2000-07-11 00:10:27 +04:00
|
|
|
|
|
|
|
|
2001-09-06 05:07:40 +04:00
|
|
|
NS_IMETHODIMP
|
2016-04-21 07:28:32 +03:00
|
|
|
nsStackLayout::XULLayout(nsIFrame* aBox, nsBoxLayoutState& aState)
|
2001-09-06 05:07:40 +04:00
|
|
|
{
|
|
|
|
nsRect clientRect;
|
2016-04-21 07:28:33 +03:00
|
|
|
aBox->GetXULClientRect(clientRect);
|
2001-09-06 05:07:40 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool grow;
|
2001-09-06 05:07:40 +04:00
|
|
|
|
|
|
|
do {
|
2016-04-21 07:28:32 +03:00
|
|
|
nsIFrame* child = nsBox::GetChildXULBox(aBox);
|
2011-10-17 18:59:28 +04:00
|
|
|
grow = false;
|
2001-09-06 05:07:40 +04:00
|
|
|
|
|
|
|
while (child)
|
|
|
|
{
|
|
|
|
nsMargin margin;
|
2016-04-21 07:28:33 +03:00
|
|
|
child->GetXULMargin(margin);
|
2001-09-06 05:07:40 +04:00
|
|
|
nsRect childRect(clientRect);
|
|
|
|
childRect.Deflate(margin);
|
|
|
|
|
|
|
|
if (childRect.width < 0)
|
|
|
|
childRect.width = 0;
|
|
|
|
|
|
|
|
if (childRect.height < 0)
|
|
|
|
childRect.height = 0;
|
|
|
|
|
2004-09-28 22:37:50 +04:00
|
|
|
nsRect oldRect(child->GetRect());
|
2011-09-29 10:19:26 +04:00
|
|
|
bool sizeChanged = !oldRect.IsEqualEdges(childRect);
|
2001-09-06 05:07:40 +04:00
|
|
|
|
|
|
|
// only lay out dirty children or children whose sizes have changed
|
2007-05-06 23:16:51 +04:00
|
|
|
if (sizeChanged || NS_SUBTREE_DIRTY(child)) {
|
2001-09-06 05:07:40 +04:00
|
|
|
// add in the child's margin
|
|
|
|
nsMargin margin;
|
2016-04-21 07:28:33 +03:00
|
|
|
child->GetXULMargin(margin);
|
2001-09-06 05:07:40 +04:00
|
|
|
|
|
|
|
// obtain our offset from the top left border of the stack's content box.
|
2009-09-14 01:13:54 +04:00
|
|
|
nsMargin offset;
|
2015-12-07 21:17:47 +03:00
|
|
|
uint8_t offsetSpecified = GetOffset(child, offset);
|
2009-09-14 01:13:54 +04:00
|
|
|
|
|
|
|
// Set the position and size based on which offsets have been specified:
|
|
|
|
// left only - offset from left edge, preferred width
|
|
|
|
// right only - offset from right edge, preferred width
|
|
|
|
// left and right - offset from left and right edges, width in between this
|
|
|
|
// neither - no offset, full width of stack
|
|
|
|
// Vertical direction is similar.
|
|
|
|
//
|
|
|
|
// Margins on the child are also included in the edge offsets
|
2001-09-19 06:05:57 +04:00
|
|
|
if (offsetSpecified) {
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize min = child->GetXULMinSize(aState);
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize max = child->GetXULMaxSize(aState);
|
2009-09-14 01:13:54 +04:00
|
|
|
if (offsetSpecified & SPECIFIED_LEFT) {
|
|
|
|
childRect.x = clientRect.x + offset.left + margin.left;
|
|
|
|
if (offsetSpecified & SPECIFIED_RIGHT) {
|
|
|
|
nscoord width = clientRect.width - offset.LeftRight() - margin.LeftRight();
|
2011-10-28 22:33:28 +04:00
|
|
|
childRect.width = clamped(width, min.width, max.width);
|
2009-09-14 01:13:54 +04:00
|
|
|
}
|
|
|
|
else {
|
2016-04-21 07:28:31 +03:00
|
|
|
nscoord width = child->GetXULPrefSize(aState).width;
|
2015-08-01 01:21:28 +03:00
|
|
|
childRect.width = clamped(width, min.width, max.width);
|
2009-09-14 01:13:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (offsetSpecified & SPECIFIED_RIGHT) {
|
2016-04-21 07:28:31 +03:00
|
|
|
nscoord width = child->GetXULPrefSize(aState).width;
|
2015-08-01 01:21:28 +03:00
|
|
|
childRect.width = clamped(width, min.width, max.width);
|
2009-09-14 01:13:54 +04:00
|
|
|
childRect.x = clientRect.XMost() - offset.right - margin.right - childRect.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (offsetSpecified & SPECIFIED_TOP) {
|
|
|
|
childRect.y = clientRect.y + offset.top + margin.top;
|
|
|
|
if (offsetSpecified & SPECIFIED_BOTTOM) {
|
|
|
|
nscoord height = clientRect.height - offset.TopBottom() - margin.TopBottom();
|
2011-10-28 22:33:28 +04:00
|
|
|
childRect.height = clamped(height, min.height, max.height);
|
2009-09-14 01:13:54 +04:00
|
|
|
}
|
|
|
|
else {
|
2016-04-21 07:28:31 +03:00
|
|
|
nscoord height = child->GetXULPrefSize(aState).height;
|
2015-08-01 01:21:28 +03:00
|
|
|
childRect.height = clamped(height, min.height, max.height);
|
2009-09-14 01:13:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (offsetSpecified & SPECIFIED_BOTTOM) {
|
2016-04-21 07:28:31 +03:00
|
|
|
nscoord height = child->GetXULPrefSize(aState).height;
|
2015-08-01 01:21:28 +03:00
|
|
|
childRect.height = clamped(height, min.height, max.height);
|
2009-09-14 01:13:54 +04:00
|
|
|
childRect.y = clientRect.YMost() - offset.bottom - margin.bottom - childRect.height;
|
|
|
|
}
|
2001-09-06 05:07:40 +04:00
|
|
|
}
|
2000-07-11 00:10:27 +04:00
|
|
|
|
2001-09-06 05:07:40 +04:00
|
|
|
// Now place the child.
|
2016-04-21 07:28:32 +03:00
|
|
|
child->SetXULBounds(aState, childRect);
|
2001-09-06 05:07:40 +04:00
|
|
|
|
|
|
|
// Flow the child.
|
2016-04-21 07:28:32 +03:00
|
|
|
child->XULLayout(aState);
|
2001-09-06 05:07:40 +04:00
|
|
|
|
|
|
|
// Get the child's new rect.
|
2012-10-26 05:39:31 +04:00
|
|
|
childRect = child->GetRect();
|
2000-07-11 00:10:27 +04:00
|
|
|
childRect.Inflate(margin);
|
|
|
|
|
2013-02-17 01:51:02 +04:00
|
|
|
if (child->StyleXUL()->mStretchStack) {
|
2008-06-05 10:46:24 +04:00
|
|
|
// Did the child push back on us and get bigger?
|
2009-09-14 01:13:54 +04:00
|
|
|
if (offset.LeftRight() + childRect.width > clientRect.width) {
|
|
|
|
clientRect.width = childRect.width + offset.LeftRight();
|
2011-10-17 18:59:28 +04:00
|
|
|
grow = true;
|
2008-06-05 10:46:24 +04:00
|
|
|
}
|
|
|
|
|
2009-09-14 01:13:54 +04:00
|
|
|
if (offset.TopBottom() + childRect.height > clientRect.height) {
|
|
|
|
clientRect.height = childRect.height + offset.TopBottom();
|
2011-10-17 18:59:28 +04:00
|
|
|
grow = true;
|
2008-06-05 10:46:24 +04:00
|
|
|
}
|
2000-07-11 00:10:27 +04:00
|
|
|
}
|
2001-09-06 05:07:40 +04:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
child = nsBox::GetNextXULBox(child);
|
2001-09-06 05:07:40 +04:00
|
|
|
}
|
|
|
|
} while (grow);
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// if some HTML inside us got bigger we need to force ourselves to
|
|
|
|
// get bigger
|
2004-09-28 22:37:50 +04:00
|
|
|
nsRect bounds(aBox->GetRect());
|
2000-03-31 11:02:06 +04:00
|
|
|
nsMargin bp;
|
2016-04-21 07:28:32 +03:00
|
|
|
aBox->GetXULBorderAndPadding(bp);
|
2000-03-31 11:02:06 +04:00
|
|
|
clientRect.Inflate(bp);
|
|
|
|
|
|
|
|
if (clientRect.width > bounds.width || clientRect.height > bounds.height)
|
|
|
|
{
|
2001-09-06 05:07:40 +04:00
|
|
|
if (clientRect.width > bounds.width)
|
|
|
|
bounds.width = clientRect.width;
|
|
|
|
if (clientRect.height > bounds.height)
|
|
|
|
bounds.height = clientRect.height;
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
aBox->SetXULBounds(aState, bounds);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|