Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | // |
michael@0 | 7 | // Eric Vaughan |
michael@0 | 8 | // Netscape Communications |
michael@0 | 9 | // |
michael@0 | 10 | // See documentation in associated header file |
michael@0 | 11 | // |
michael@0 | 12 | |
michael@0 | 13 | #include "nsGridRowLeafFrame.h" |
michael@0 | 14 | #include "nsGridRowLeafLayout.h" |
michael@0 | 15 | #include "nsGridRow.h" |
michael@0 | 16 | #include "nsBoxLayoutState.h" |
michael@0 | 17 | #include "nsGridLayout2.h" |
michael@0 | 18 | |
michael@0 | 19 | already_AddRefed<nsBoxLayout> NS_NewGridRowLeafLayout(); |
michael@0 | 20 | |
michael@0 | 21 | nsIFrame* |
michael@0 | 22 | NS_NewGridRowLeafFrame(nsIPresShell* aPresShell, |
michael@0 | 23 | nsStyleContext* aContext) |
michael@0 | 24 | { |
michael@0 | 25 | nsCOMPtr<nsBoxLayout> layout = NS_NewGridRowLeafLayout(); |
michael@0 | 26 | return new (aPresShell) nsGridRowLeafFrame(aPresShell, aContext, false, |
michael@0 | 27 | layout); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | NS_IMPL_FRAMEARENA_HELPERS(nsGridRowLeafFrame) |
michael@0 | 31 | |
michael@0 | 32 | /* |
michael@0 | 33 | * Our border and padding could be affected by our columns or rows. |
michael@0 | 34 | * Let's go check it out. |
michael@0 | 35 | */ |
michael@0 | 36 | nsresult |
michael@0 | 37 | nsGridRowLeafFrame::GetBorderAndPadding(nsMargin& aBorderAndPadding) |
michael@0 | 38 | { |
michael@0 | 39 | // if our columns have made our padding larger add it in. |
michael@0 | 40 | nsresult rv = nsBoxFrame::GetBorderAndPadding(aBorderAndPadding); |
michael@0 | 41 | |
michael@0 | 42 | nsIGridPart* part = nsGrid::GetPartFromBox(this); |
michael@0 | 43 | if (!part) |
michael@0 | 44 | return rv; |
michael@0 | 45 | |
michael@0 | 46 | int32_t index = 0; |
michael@0 | 47 | nsGrid* grid = part->GetGrid(this, &index); |
michael@0 | 48 | |
michael@0 | 49 | if (!grid) |
michael@0 | 50 | return rv; |
michael@0 | 51 | |
michael@0 | 52 | bool isHorizontal = IsHorizontal(); |
michael@0 | 53 | |
michael@0 | 54 | nsBoxLayoutState state(PresContext()); |
michael@0 | 55 | |
michael@0 | 56 | int32_t firstIndex = 0; |
michael@0 | 57 | int32_t lastIndex = 0; |
michael@0 | 58 | nsGridRow* firstRow = nullptr; |
michael@0 | 59 | nsGridRow* lastRow = nullptr; |
michael@0 | 60 | grid->GetFirstAndLastRow(state, firstIndex, lastIndex, firstRow, lastRow, isHorizontal); |
michael@0 | 61 | |
michael@0 | 62 | // only the first and last rows can be affected. |
michael@0 | 63 | if (firstRow && firstRow->GetBox() == this) { |
michael@0 | 64 | |
michael@0 | 65 | nscoord top = 0; |
michael@0 | 66 | nscoord bottom = 0; |
michael@0 | 67 | grid->GetRowOffsets(state, firstIndex, top, bottom, isHorizontal); |
michael@0 | 68 | |
michael@0 | 69 | if (isHorizontal) { |
michael@0 | 70 | if (top > aBorderAndPadding.top) |
michael@0 | 71 | aBorderAndPadding.top = top; |
michael@0 | 72 | } else { |
michael@0 | 73 | if (top > aBorderAndPadding.left) |
michael@0 | 74 | aBorderAndPadding.left = top; |
michael@0 | 75 | } |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | if (lastRow && lastRow->GetBox() == this) { |
michael@0 | 79 | |
michael@0 | 80 | nscoord top = 0; |
michael@0 | 81 | nscoord bottom = 0; |
michael@0 | 82 | grid->GetRowOffsets(state, lastIndex, top, bottom, isHorizontal); |
michael@0 | 83 | |
michael@0 | 84 | if (isHorizontal) { |
michael@0 | 85 | if (bottom > aBorderAndPadding.bottom) |
michael@0 | 86 | aBorderAndPadding.bottom = bottom; |
michael@0 | 87 | } else { |
michael@0 | 88 | if (bottom > aBorderAndPadding.right) |
michael@0 | 89 | aBorderAndPadding.right = bottom; |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | } |
michael@0 | 93 | |
michael@0 | 94 | return rv; |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 |