1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is Mozilla Communicator client code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 1998
20
* the Initial Developer. All Rights Reserved.
23
* Pierre Phaneuf <pp@ludusdesign.com>
25
* Alternatively, the contents of this file may be used under the terms of
26
* either the GNU General Public License Version 2 or later (the "GPL"), or
27
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
* in which case the provisions of the GPL or the LGPL are applicable instead
29
* of those above. If you wish to allow use of your version of this file only
30
* under the terms of either the GPL or the LGPL, and not to allow others to
31
* use your version of this file under the terms of the NPL, indicate your
32
* decision by deleting the provisions above and replace them with the notice
33
* and other provisions required by the GPL or the LGPL. If you do not delete
34
* the provisions above, a recipient may use your version of this file under
35
* the terms of any one of the NPL, the GPL or the LGPL.
37
* ***** END LICENSE BLOCK ***** */
41
// Netscape Communications
43
// See documentation in associated header file
47
#include "nsIPresContext.h"
49
#include "nsIContent.h"
50
#include "nsIViewManager.h"
52
#include "nsIPresShell.h"
53
#include "nsHTMLContainerFrame.h"
55
#include "nsBoxLayout.h"
57
nsBoxLayout::nsBoxLayout()
62
nsBoxLayout::GetParentLayout(nsIBox* aBox, nsIBoxLayout** aParent)
64
nsIBox* parent = nsnull;
65
aBox->GetParentBox(&parent);
68
parent->GetLayoutManager(aParent);
76
nsBoxLayout::AddBorderAndPadding(nsIBox* aBox, nsSize& aSize)
78
nsBox::AddBorderAndPadding(aBox, aSize);
82
nsBoxLayout::AddMargin(nsIBox* aBox, nsSize& aSize)
84
nsBox::AddMargin(aBox, aSize);
88
nsBoxLayout::AddMargin(nsSize& aSize, const nsMargin& aMargin)
90
nsBox::AddMargin(aSize, aMargin);
94
nsBoxLayout::AddInset(nsIBox* aBox, nsSize& aSize)
96
nsBox::AddInset(aBox, aSize);
100
nsBoxLayout::GetFlex(nsIBox* aBox, nsBoxLayoutState& aState, nscoord& aFlex)
102
return aBox->GetFlex(aState, aFlex);
107
nsBoxLayout::IsCollapsed(nsIBox* aBox, nsBoxLayoutState& aState, PRBool& aCollapsed)
109
return aBox->IsCollapsed(aState, aCollapsed);
113
nsBoxLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)
117
AddBorderAndPadding(aBox, aSize);
118
AddInset(aBox, aSize);
124
nsBoxLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)
128
AddBorderAndPadding(aBox, aSize);
129
AddInset(aBox, aSize);
134
nsBoxLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)
136
aSize.width = NS_INTRINSICSIZE;
137
aSize.height = NS_INTRINSICSIZE;
138
AddBorderAndPadding(aBox, aSize);
139
AddInset(aBox, aSize);
145
nsBoxLayout::GetAscent(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent)
153
nsBoxLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)
159
nsBoxLayout::AddLargestSize(nsSize& aSize, const nsSize& aSize2)
161
if (aSize2.width > aSize.width)
162
aSize.width = aSize2.width;
164
if (aSize2.height > aSize.height)
165
aSize.height = aSize2.height;
169
nsBoxLayout::AddSmallestSize(nsSize& aSize, const nsSize& aSize2)
171
if (aSize2.width < aSize.width)
172
aSize.width = aSize2.width;
174
if (aSize2.height < aSize.height)
175
aSize.height = aSize2.height;
179
nsBoxLayout::ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aPrevBox, nsIBox* aChildList)
185
nsBoxLayout::ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)
191
nsBoxLayout::ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)
197
nsBoxLayout::ChildrenSet(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)
203
nsBoxLayout::ChildBecameDirty(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChild)
209
nsBoxLayout::BecameDirty(nsIBox* aBox, nsBoxLayoutState& aState)
215
NS_IMPL_ADDREF(nsBoxLayout)
216
NS_IMPL_RELEASE(nsBoxLayout)
221
NS_INTERFACE_MAP_BEGIN(nsBoxLayout)
222
NS_INTERFACE_MAP_ENTRY(nsIBoxLayout)
223
NS_INTERFACE_MAP_ENTRY(nsISupports)