1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/xul/grid/nsGridRowLeafFrame.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,97 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +// 1.10 +// Eric Vaughan 1.11 +// Netscape Communications 1.12 +// 1.13 +// See documentation in associated header file 1.14 +// 1.15 + 1.16 +#include "nsGridRowLeafFrame.h" 1.17 +#include "nsGridRowLeafLayout.h" 1.18 +#include "nsGridRow.h" 1.19 +#include "nsBoxLayoutState.h" 1.20 +#include "nsGridLayout2.h" 1.21 + 1.22 +already_AddRefed<nsBoxLayout> NS_NewGridRowLeafLayout(); 1.23 + 1.24 +nsIFrame* 1.25 +NS_NewGridRowLeafFrame(nsIPresShell* aPresShell, 1.26 + nsStyleContext* aContext) 1.27 +{ 1.28 + nsCOMPtr<nsBoxLayout> layout = NS_NewGridRowLeafLayout(); 1.29 + return new (aPresShell) nsGridRowLeafFrame(aPresShell, aContext, false, 1.30 + layout); 1.31 +} 1.32 + 1.33 +NS_IMPL_FRAMEARENA_HELPERS(nsGridRowLeafFrame) 1.34 + 1.35 +/* 1.36 + * Our border and padding could be affected by our columns or rows. 1.37 + * Let's go check it out. 1.38 + */ 1.39 +nsresult 1.40 +nsGridRowLeafFrame::GetBorderAndPadding(nsMargin& aBorderAndPadding) 1.41 +{ 1.42 + // if our columns have made our padding larger add it in. 1.43 + nsresult rv = nsBoxFrame::GetBorderAndPadding(aBorderAndPadding); 1.44 + 1.45 + nsIGridPart* part = nsGrid::GetPartFromBox(this); 1.46 + if (!part) 1.47 + return rv; 1.48 + 1.49 + int32_t index = 0; 1.50 + nsGrid* grid = part->GetGrid(this, &index); 1.51 + 1.52 + if (!grid) 1.53 + return rv; 1.54 + 1.55 + bool isHorizontal = IsHorizontal(); 1.56 + 1.57 + nsBoxLayoutState state(PresContext()); 1.58 + 1.59 + int32_t firstIndex = 0; 1.60 + int32_t lastIndex = 0; 1.61 + nsGridRow* firstRow = nullptr; 1.62 + nsGridRow* lastRow = nullptr; 1.63 + grid->GetFirstAndLastRow(state, firstIndex, lastIndex, firstRow, lastRow, isHorizontal); 1.64 + 1.65 + // only the first and last rows can be affected. 1.66 + if (firstRow && firstRow->GetBox() == this) { 1.67 + 1.68 + nscoord top = 0; 1.69 + nscoord bottom = 0; 1.70 + grid->GetRowOffsets(state, firstIndex, top, bottom, isHorizontal); 1.71 + 1.72 + if (isHorizontal) { 1.73 + if (top > aBorderAndPadding.top) 1.74 + aBorderAndPadding.top = top; 1.75 + } else { 1.76 + if (top > aBorderAndPadding.left) 1.77 + aBorderAndPadding.left = top; 1.78 + } 1.79 + } 1.80 + 1.81 + if (lastRow && lastRow->GetBox() == this) { 1.82 + 1.83 + nscoord top = 0; 1.84 + nscoord bottom = 0; 1.85 + grid->GetRowOffsets(state, lastIndex, top, bottom, isHorizontal); 1.86 + 1.87 + if (isHorizontal) { 1.88 + if (bottom > aBorderAndPadding.bottom) 1.89 + aBorderAndPadding.bottom = bottom; 1.90 + } else { 1.91 + if (bottom > aBorderAndPadding.right) 1.92 + aBorderAndPadding.right = bottom; 1.93 + } 1.94 + 1.95 + } 1.96 + 1.97 + return rv; 1.98 +} 1.99 + 1.100 +