1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 //
8 // Eric Vaughan
9 // Netscape Communications
10 //
11 // See documentation in associated header file
12 //
13 
14 #include "nsBox.h"
15 #include "nsCOMPtr.h"
16 #include "nsContainerFrame.h"
17 #include "nsBoxLayout.h"
18 
AddBorderAndPadding(nsIFrame * aBox,nsSize & aSize)19 void nsBoxLayout::AddBorderAndPadding(nsIFrame* aBox, nsSize& aSize) {
20   nsBox::AddBorderAndPadding(aBox, aSize);
21 }
22 
AddMargin(nsIFrame * aBox,nsSize & aSize)23 void nsBoxLayout::AddMargin(nsIFrame* aBox, nsSize& aSize) {
24   nsBox::AddMargin(aBox, aSize);
25 }
26 
AddMargin(nsSize & aSize,const nsMargin & aMargin)27 void nsBoxLayout::AddMargin(nsSize& aSize, const nsMargin& aMargin) {
28   nsBox::AddMargin(aSize, aMargin);
29 }
30 
GetXULPrefSize(nsIFrame * aBox,nsBoxLayoutState & aBoxLayoutState)31 nsSize nsBoxLayout::GetXULPrefSize(nsIFrame* aBox,
32                                    nsBoxLayoutState& aBoxLayoutState) {
33   nsSize pref(0, 0);
34   AddBorderAndPadding(aBox, pref);
35 
36   return pref;
37 }
38 
GetXULMinSize(nsIFrame * aBox,nsBoxLayoutState & aBoxLayoutState)39 nsSize nsBoxLayout::GetXULMinSize(nsIFrame* aBox,
40                                   nsBoxLayoutState& aBoxLayoutState) {
41   nsSize minSize(0, 0);
42   AddBorderAndPadding(aBox, minSize);
43   return minSize;
44 }
45 
GetXULMaxSize(nsIFrame * aBox,nsBoxLayoutState & aBoxLayoutState)46 nsSize nsBoxLayout::GetXULMaxSize(nsIFrame* aBox,
47                                   nsBoxLayoutState& aBoxLayoutState) {
48   // AddBorderAndPadding () never changes maxSize (NS_INTRINSICSIZE)
49   // AddBorderAndPadding(aBox, maxSize);
50   return nsSize(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
51 }
52 
GetAscent(nsIFrame * aBox,nsBoxLayoutState & aBoxLayoutState)53 nscoord nsBoxLayout::GetAscent(nsIFrame* aBox,
54                                nsBoxLayoutState& aBoxLayoutState) {
55   return 0;
56 }
57 
58 NS_IMETHODIMP
XULLayout(nsIFrame * aBox,nsBoxLayoutState & aBoxLayoutState)59 nsBoxLayout::XULLayout(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState) {
60   return NS_OK;
61 }
62 
AddLargestSize(nsSize & aSize,const nsSize & aSize2)63 void nsBoxLayout::AddLargestSize(nsSize& aSize, const nsSize& aSize2) {
64   if (aSize2.width > aSize.width) aSize.width = aSize2.width;
65 
66   if (aSize2.height > aSize.height) aSize.height = aSize2.height;
67 }
68 
AddSmallestSize(nsSize & aSize,const nsSize & aSize2)69 void nsBoxLayout::AddSmallestSize(nsSize& aSize, const nsSize& aSize2) {
70   if (aSize2.width < aSize.width) aSize.width = aSize2.width;
71 
72   if (aSize2.height < aSize.height) aSize.height = aSize2.height;
73 }
74 
75 NS_IMPL_ISUPPORTS(nsBoxLayout, nsBoxLayout)
76