Back to index

lightning-sunbird  0.9+nobinonly
nsBoxLayout.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Communicator client code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Pierre Phaneuf <pp@ludusdesign.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 //
00040 // Eric Vaughan
00041 // Netscape Communications
00042 //
00043 // See documentation in associated header file
00044 //
00045 
00046 #include "nsBox.h"
00047 #include "nsPresContext.h"
00048 #include "nsCOMPtr.h"
00049 #include "nsIContent.h"
00050 #include "nsIViewManager.h"
00051 #include "nsIView.h"
00052 #include "nsIPresShell.h"
00053 #include "nsHTMLContainerFrame.h"
00054 #include "nsIFrame.h"
00055 #include "nsBoxLayout.h"
00056 
00057 nsBoxLayout::nsBoxLayout()
00058 {
00059 }
00060 
00061 void
00062 nsBoxLayout::GetParentLayout(nsIBox* aBox, nsIBoxLayout** aParent)
00063 {
00064   nsIBox* parent = nsnull;
00065   aBox->GetParentBox(&parent);
00066   if (parent)
00067   {
00068     parent->GetLayoutManager(aParent);
00069     return;
00070   }
00071 
00072   *aParent = nsnull;
00073 }
00074 
00075 void
00076 nsBoxLayout::AddBorderAndPadding(nsIBox* aBox, nsSize& aSize)
00077 {
00078   nsBox::AddBorderAndPadding(aBox, aSize);
00079 }
00080 
00081 void
00082 nsBoxLayout::AddMargin(nsIBox* aBox, nsSize& aSize)
00083 {
00084   nsBox::AddMargin(aBox, aSize);
00085 }
00086 
00087 void
00088 nsBoxLayout::AddMargin(nsSize& aSize, const nsMargin& aMargin)
00089 {
00090   nsBox::AddMargin(aSize, aMargin);
00091 }
00092 
00093 void
00094 nsBoxLayout::AddInset(nsIBox* aBox, nsSize& aSize)
00095 {
00096   nsBox::AddInset(aBox, aSize);
00097 }
00098 
00099 NS_IMETHODIMP
00100 nsBoxLayout::GetFlex(nsIBox* aBox, nsBoxLayoutState& aState, nscoord& aFlex)
00101 {
00102   return aBox->GetFlex(aState, aFlex);
00103 }
00104 
00105 
00106 NS_IMETHODIMP
00107 nsBoxLayout::IsCollapsed(nsIBox* aBox, nsBoxLayoutState& aState, PRBool& aCollapsed)
00108 {
00109   return aBox->IsCollapsed(aState, aCollapsed);
00110 }
00111 
00112 NS_IMETHODIMP
00113 nsBoxLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)
00114 {
00115   aSize.width = 0;
00116   aSize.height = 0;
00117   AddBorderAndPadding(aBox, aSize);
00118   AddInset(aBox, aSize);
00119 
00120   return NS_OK;
00121 }
00122 
00123 NS_IMETHODIMP
00124 nsBoxLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)
00125 {
00126   aSize.width = 0;
00127   aSize.height = 0;
00128   AddBorderAndPadding(aBox, aSize);
00129   AddInset(aBox, aSize);
00130   return NS_OK;
00131 }
00132 
00133 NS_IMETHODIMP
00134 nsBoxLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)
00135 {
00136   aSize.width = NS_INTRINSICSIZE;
00137   aSize.height = NS_INTRINSICSIZE;
00138   AddBorderAndPadding(aBox, aSize);
00139   AddInset(aBox, aSize);
00140   return NS_OK;
00141 }
00142 
00143 
00144 NS_IMETHODIMP
00145 nsBoxLayout::GetAscent(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent)
00146 {
00147   aAscent = 0;
00148   return NS_OK;
00149 }
00150 
00151 
00152 NS_IMETHODIMP
00153 nsBoxLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)
00154 {
00155   return NS_OK;
00156 }
00157 
00158 void
00159 nsBoxLayout::AddLargestSize(nsSize& aSize, const nsSize& aSize2)
00160 {
00161   if (aSize2.width > aSize.width)
00162      aSize.width = aSize2.width;
00163 
00164   if (aSize2.height > aSize.height)
00165      aSize.height = aSize2.height;
00166 }
00167 
00168 void
00169 nsBoxLayout::AddSmallestSize(nsSize& aSize, const nsSize& aSize2)
00170 {
00171   if (aSize2.width < aSize.width)
00172      aSize.width = aSize2.width;
00173 
00174   if (aSize2.height < aSize.height)
00175      aSize.height = aSize2.height;
00176 }
00177 
00178 NS_IMETHODIMP
00179 nsBoxLayout::ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aPrevBox, nsIBox* aChildList)
00180 {
00181   return NS_OK;
00182 }
00183 
00184 NS_IMETHODIMP
00185 nsBoxLayout::ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)
00186 {
00187   return NS_OK;
00188 }
00189 
00190 NS_IMETHODIMP
00191 nsBoxLayout::ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)
00192 {
00193   return NS_OK;
00194 }
00195 
00196 NS_IMETHODIMP
00197 nsBoxLayout::ChildrenSet(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)
00198 {
00199   return NS_OK;
00200 }
00201 
00202 NS_IMETHODIMP
00203 nsBoxLayout::ChildBecameDirty(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChild)
00204 {
00205   return NS_OK;
00206 }
00207 
00208 NS_IMETHODIMP
00209 nsBoxLayout::BecameDirty(nsIBox* aBox, nsBoxLayoutState& aState)
00210 {
00211   return NS_OK;
00212 }
00213 
00214 // nsISupports
00215 NS_IMPL_ADDREF(nsBoxLayout)
00216 NS_IMPL_RELEASE(nsBoxLayout)
00217 
00218 //
00219 // QueryInterface
00220 //
00221 NS_INTERFACE_MAP_BEGIN(nsBoxLayout)
00222   NS_INTERFACE_MAP_ENTRY(nsIBoxLayout)
00223   NS_INTERFACE_MAP_ENTRY(nsISupports)
00224 NS_INTERFACE_MAP_END