/src/mozilla-central/layout/xul/grid/nsGridCell.cpp
Line | Count | Source (jump to first uncovered line) |
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 "nsGridCell.h" |
15 | | #include "nsFrame.h" |
16 | | #include "nsBox.h" |
17 | | #include "nsGridLayout2.h" |
18 | | |
19 | | |
20 | | nsGridCell::nsGridCell():mBoxInColumn(nullptr),mBoxInRow(nullptr) |
21 | 0 | { |
22 | 0 | MOZ_COUNT_CTOR(nsGridCell); |
23 | 0 | } |
24 | | |
25 | | nsGridCell::~nsGridCell() |
26 | 0 | { |
27 | 0 | MOZ_COUNT_DTOR(nsGridCell); |
28 | 0 | } |
29 | | |
30 | | nsSize |
31 | | nsGridCell::GetXULPrefSize(nsBoxLayoutState& aState) |
32 | 0 | { |
33 | 0 | nsSize sum(0,0); |
34 | 0 |
|
35 | 0 | // take our 2 children and add them up. |
36 | 0 | // we are as wide as the widest child plus its left offset |
37 | 0 | // we are tall as the tallest child plus its top offset |
38 | 0 |
|
39 | 0 | if (mBoxInColumn) { |
40 | 0 | nsSize pref = mBoxInColumn->GetXULPrefSize(aState); |
41 | 0 |
|
42 | 0 | nsBox::AddMargin(mBoxInColumn, pref); |
43 | 0 | nsGridLayout2::AddOffset(mBoxInColumn, pref); |
44 | 0 |
|
45 | 0 | nsBoxLayout::AddLargestSize(sum, pref); |
46 | 0 | } |
47 | 0 |
|
48 | 0 | if (mBoxInRow) { |
49 | 0 | nsSize pref = mBoxInRow->GetXULPrefSize(aState); |
50 | 0 |
|
51 | 0 | nsBox::AddMargin(mBoxInRow, pref); |
52 | 0 | nsGridLayout2::AddOffset(mBoxInRow, pref); |
53 | 0 |
|
54 | 0 | nsBoxLayout::AddLargestSize(sum, pref); |
55 | 0 | } |
56 | 0 |
|
57 | 0 | return sum; |
58 | 0 | } |
59 | | |
60 | | nsSize |
61 | | nsGridCell::GetXULMinSize(nsBoxLayoutState& aState) |
62 | 0 | { |
63 | 0 | nsSize sum(0, 0); |
64 | 0 |
|
65 | 0 | // take our 2 children and add them up. |
66 | 0 | // we are as wide as the widest child plus its left offset |
67 | 0 | // we are tall as the tallest child plus its top offset |
68 | 0 |
|
69 | 0 | if (mBoxInColumn) { |
70 | 0 | nsSize min = mBoxInColumn->GetXULMinSize(aState); |
71 | 0 |
|
72 | 0 | nsBox::AddMargin(mBoxInColumn, min); |
73 | 0 | nsGridLayout2::AddOffset(mBoxInColumn, min); |
74 | 0 |
|
75 | 0 | nsBoxLayout::AddLargestSize(sum, min); |
76 | 0 | } |
77 | 0 |
|
78 | 0 | if (mBoxInRow) { |
79 | 0 | nsSize min = mBoxInRow->GetXULMinSize(aState); |
80 | 0 |
|
81 | 0 | nsBox::AddMargin(mBoxInRow, min); |
82 | 0 | nsGridLayout2::AddOffset(mBoxInRow, min); |
83 | 0 |
|
84 | 0 | nsBoxLayout::AddLargestSize(sum, min); |
85 | 0 | } |
86 | 0 |
|
87 | 0 | return sum; |
88 | 0 | } |
89 | | |
90 | | nsSize |
91 | | nsGridCell::GetXULMaxSize(nsBoxLayoutState& aState) |
92 | 0 | { |
93 | 0 | nsSize sum(NS_INTRINSICSIZE, NS_INTRINSICSIZE); |
94 | 0 |
|
95 | 0 | // take our 2 children and add them up. |
96 | 0 | // we are as wide as the smallest child plus its left offset |
97 | 0 | // we are tall as the shortest child plus its top offset |
98 | 0 |
|
99 | 0 | if (mBoxInColumn) { |
100 | 0 | nsSize max = mBoxInColumn->GetXULMaxSize(aState); |
101 | 0 |
|
102 | 0 | nsBox::AddMargin(mBoxInColumn, max); |
103 | 0 | nsGridLayout2::AddOffset(mBoxInColumn, max); |
104 | 0 |
|
105 | 0 | nsBoxLayout::AddSmallestSize(sum, max); |
106 | 0 | } |
107 | 0 |
|
108 | 0 | if (mBoxInRow) { |
109 | 0 | nsSize max = mBoxInRow->GetXULMaxSize(aState); |
110 | 0 |
|
111 | 0 | nsBox::AddMargin(mBoxInRow, max); |
112 | 0 | nsGridLayout2::AddOffset(mBoxInRow, max); |
113 | 0 |
|
114 | 0 | nsBoxLayout::AddSmallestSize(sum, max); |
115 | 0 | } |
116 | 0 |
|
117 | 0 | return sum; |
118 | 0 | } |
119 | | |
120 | | |
121 | | bool |
122 | | nsGridCell::IsXULCollapsed() |
123 | 0 | { |
124 | 0 | return ((mBoxInColumn && mBoxInColumn->IsXULCollapsed()) || |
125 | 0 | (mBoxInRow && mBoxInRow->IsXULCollapsed())); |
126 | 0 | } |
127 | | |
128 | | |