/src/mozilla-central/layout/xul/grid/nsGridRowLeafFrame.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 "nsGridRowLeafFrame.h" |
15 | | #include "nsGridRowLeafLayout.h" |
16 | | #include "nsGridRow.h" |
17 | | #include "nsBoxLayoutState.h" |
18 | | #include "nsGridLayout2.h" |
19 | | |
20 | | already_AddRefed<nsBoxLayout> NS_NewGridRowLeafLayout(); |
21 | | |
22 | | nsIFrame* |
23 | | NS_NewGridRowLeafFrame(nsIPresShell* aPresShell, |
24 | | ComputedStyle* aStyle) |
25 | 0 | { |
26 | 0 | nsCOMPtr<nsBoxLayout> layout = NS_NewGridRowLeafLayout(); |
27 | 0 | return new (aPresShell) nsGridRowLeafFrame(aStyle, false, layout); |
28 | 0 | } |
29 | | |
30 | | NS_IMPL_FRAMEARENA_HELPERS(nsGridRowLeafFrame) |
31 | | |
32 | | /* |
33 | | * Our border and padding could be affected by our columns or rows. |
34 | | * Let's go check it out. |
35 | | */ |
36 | | nsresult |
37 | | nsGridRowLeafFrame::GetXULBorderAndPadding(nsMargin& aBorderAndPadding) |
38 | 0 | { |
39 | 0 | // if our columns have made our padding larger add it in. |
40 | 0 | nsresult rv = nsBoxFrame::GetXULBorderAndPadding(aBorderAndPadding); |
41 | 0 |
|
42 | 0 | nsIGridPart* part = nsGrid::GetPartFromBox(this); |
43 | 0 | if (!part) |
44 | 0 | return rv; |
45 | 0 | |
46 | 0 | int32_t index = 0; |
47 | 0 | nsGrid* grid = part->GetGrid(this, &index); |
48 | 0 |
|
49 | 0 | if (!grid) |
50 | 0 | return rv; |
51 | 0 | |
52 | 0 | bool isHorizontal = IsXULHorizontal(); |
53 | 0 |
|
54 | 0 | int32_t firstIndex = 0; |
55 | 0 | int32_t lastIndex = 0; |
56 | 0 | nsGridRow* firstRow = nullptr; |
57 | 0 | nsGridRow* lastRow = nullptr; |
58 | 0 | grid->GetFirstAndLastRow(firstIndex, lastIndex, firstRow, lastRow, isHorizontal); |
59 | 0 |
|
60 | 0 | // only the first and last rows can be affected. |
61 | 0 | if (firstRow && firstRow->GetBox() == this) { |
62 | 0 |
|
63 | 0 | nscoord top = 0; |
64 | 0 | nscoord bottom = 0; |
65 | 0 | grid->GetRowOffsets(firstIndex, top, bottom, isHorizontal); |
66 | 0 |
|
67 | 0 | if (isHorizontal) { |
68 | 0 | if (top > aBorderAndPadding.top) |
69 | 0 | aBorderAndPadding.top = top; |
70 | 0 | } else { |
71 | 0 | if (top > aBorderAndPadding.left) |
72 | 0 | aBorderAndPadding.left = top; |
73 | 0 | } |
74 | 0 | } |
75 | 0 |
|
76 | 0 | if (lastRow && lastRow->GetBox() == this) { |
77 | 0 |
|
78 | 0 | nscoord top = 0; |
79 | 0 | nscoord bottom = 0; |
80 | 0 | grid->GetRowOffsets(lastIndex, top, bottom, isHorizontal); |
81 | 0 |
|
82 | 0 | if (isHorizontal) { |
83 | 0 | if (bottom > aBorderAndPadding.bottom) |
84 | 0 | aBorderAndPadding.bottom = bottom; |
85 | 0 | } else { |
86 | 0 | if (bottom > aBorderAndPadding.right) |
87 | 0 | aBorderAndPadding.right = bottom; |
88 | 0 | } |
89 | 0 |
|
90 | 0 | } |
91 | 0 |
|
92 | 0 | return rv; |
93 | 0 | } |
94 | | |
95 | | |