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