gecko-dev/layout/xul/grid/nsGridRowLeafFrame.cpp

96 строки
2.4 KiB
C++
Исходник Обычный вид История

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
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();
nsIFrame*
NS_NewGridRowLeafFrame(nsIPresShell* aPresShell,
ComputedStyle* aStyle)
2001-10-20 00:47:36 +04:00
{
2011-07-11 18:05:10 +04:00
nsCOMPtr<nsBoxLayout> layout = NS_NewGridRowLeafLayout();
return new (aPresShell) nsGridRowLeafFrame(aStyle, false, layout);
}
NS_IMPL_FRAMEARENA_HELPERS(nsGridRowLeafFrame)
2001-10-20 00:47:36 +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
*/
nsresult
nsGridRowLeafFrame::GetXULBorderAndPadding(nsMargin& aBorderAndPadding)
2001-10-20 00:47:36 +04:00
{
// if our columns have made our padding larger add it in.
nsresult rv = nsBoxFrame::GetXULBorderAndPadding(aBorderAndPadding);
2001-10-20 00:47:36 +04:00
nsIGridPart* part = nsGrid::GetPartFromBox(this);
2001-10-20 00:47:36 +04:00
if (!part)
return rv;
int32_t index = 0;
nsGrid* grid = part->GetGrid(this, &index);
2001-10-20 00:47:36 +04:00
if (!grid)
2001-10-20 00:47:36 +04:00
return rv;
bool isHorizontal = IsXULHorizontal();
2001-10-20 00:47:36 +04:00
int32_t firstIndex = 0;
int32_t lastIndex = 0;
nsGridRow* firstRow = nullptr;
nsGridRow* lastRow = nullptr;
grid->GetFirstAndLastRow(firstIndex, lastIndex, firstRow, lastRow, isHorizontal);
2001-10-31 02:41:30 +03:00
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;
grid->GetRowOffsets(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-20 00:47:36 +04:00
}
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;
grid->GetRowOffsets(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;
}
}
2001-10-20 00:47:36 +04:00
return rv;
}