2001-10-20 00:47:36 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-10-20 00:47:36 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// Eric Vaughan
|
|
|
|
// Netscape Communications
|
|
|
|
//
|
|
|
|
// See documentation in associated header file
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "nsGridRowLeafFrame.h"
|
|
|
|
#include "nsGridRowLeafLayout.h"
|
|
|
|
#include "nsGridRow.h"
|
|
|
|
#include "nsBoxLayoutState.h"
|
|
|
|
#include "nsGridLayout2.h"
|
|
|
|
|
2011-07-11 18:05:10 +04:00
|
|
|
already_AddRefed<nsBoxLayout> NS_NewGridRowLeafLayout();
|
2009-01-19 21:31:33 +03:00
|
|
|
|
2005-10-27 01:46:39 +04:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewGridRowLeafFrame(nsIPresShell* aPresShell,
|
2009-01-19 21:31:33 +03:00
|
|
|
nsStyleContext* aContext)
|
2001-10-20 00:47:36 +04:00
|
|
|
{
|
2011-07-11 18:05:10 +04:00
|
|
|
nsCOMPtr<nsBoxLayout> layout = NS_NewGridRowLeafLayout();
|
2011-10-17 18:59:28 +04:00
|
|
|
return new (aPresShell) nsGridRowLeafFrame(aPresShell, aContext, false,
|
2009-01-19 21:31:33 +03:00
|
|
|
layout);
|
2009-09-12 20:49:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsGridRowLeafFrame)
|
2001-10-20 00:47:36 +04:00
|
|
|
|
|
|
|
/*
|
2004-09-28 22:37:50 +04:00
|
|
|
* Our border and padding could be affected by our columns or rows.
|
|
|
|
* Let's go check it out.
|
2001-10-20 00:47:36 +04:00
|
|
|
*/
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2001-10-20 00:47:36 +04:00
|
|
|
nsGridRowLeafFrame::GetBorderAndPadding(nsMargin& aBorderAndPadding)
|
|
|
|
{
|
|
|
|
// if our columns have made our padding larger add it in.
|
|
|
|
nsresult rv = nsBoxFrame::GetBorderAndPadding(aBorderAndPadding);
|
|
|
|
|
2011-07-04 18:39:10 +04:00
|
|
|
nsIGridPart* part = nsGrid::GetPartFromBox(this);
|
2001-10-20 00:47:36 +04:00
|
|
|
if (!part)
|
|
|
|
return rv;
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t index = 0;
|
2006-12-18 21:25:48 +03:00
|
|
|
nsGrid* grid = part->GetGrid(this, &index);
|
2001-10-20 00:47:36 +04:00
|
|
|
|
|
|
|
if (!grid)
|
|
|
|
return rv;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isHorizontal = IsHorizontal();
|
2001-10-20 00:47:36 +04:00
|
|
|
|
2007-05-04 03:11:00 +04:00
|
|
|
nsBoxLayoutState state(PresContext());
|
2001-10-20 00:47:36 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t firstIndex = 0;
|
|
|
|
int32_t lastIndex = 0;
|
2012-07-30 18:20:58 +04:00
|
|
|
nsGridRow* firstRow = nullptr;
|
|
|
|
nsGridRow* lastRow = nullptr;
|
2001-10-31 02:41:30 +03:00
|
|
|
grid->GetFirstAndLastRow(state, firstIndex, lastIndex, firstRow, lastRow, isHorizontal);
|
|
|
|
|
2001-10-20 00:47:36 +04:00
|
|
|
// only the first and last rows can be affected.
|
2001-10-31 02:41:30 +03:00
|
|
|
if (firstRow && firstRow->GetBox() == this) {
|
2001-10-20 00:47:36 +04:00
|
|
|
|
|
|
|
nscoord top = 0;
|
|
|
|
nscoord bottom = 0;
|
2001-10-31 02:41:30 +03:00
|
|
|
grid->GetRowOffsets(state, firstIndex, top, bottom, isHorizontal);
|
2001-10-20 00:47:36 +04:00
|
|
|
|
2001-10-26 06:41:06 +04:00
|
|
|
if (isHorizontal) {
|
2001-10-20 00:47:36 +04:00
|
|
|
if (top > aBorderAndPadding.top)
|
|
|
|
aBorderAndPadding.top = top;
|
|
|
|
} else {
|
|
|
|
if (top > aBorderAndPadding.left)
|
|
|
|
aBorderAndPadding.left = top;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-31 02:41:30 +03:00
|
|
|
if (lastRow && lastRow->GetBox() == this) {
|
2001-10-20 00:47:36 +04:00
|
|
|
|
|
|
|
nscoord top = 0;
|
|
|
|
nscoord bottom = 0;
|
2001-10-31 02:41:30 +03:00
|
|
|
grid->GetRowOffsets(state, lastIndex, top, bottom, isHorizontal);
|
2001-10-20 00:47:36 +04:00
|
|
|
|
2001-10-26 06:41:06 +04:00
|
|
|
if (isHorizontal) {
|
2001-10-20 00:47:36 +04:00
|
|
|
if (bottom > aBorderAndPadding.bottom)
|
|
|
|
aBorderAndPadding.bottom = bottom;
|
|
|
|
} else {
|
|
|
|
if (bottom > aBorderAndPadding.right)
|
|
|
|
aBorderAndPadding.right = bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|