Bug 1159101 part 3 - Replace most of nsTableFrame::GetTableFrame() usage with new GetTableFrame() methods. r=roc

--HG--
extra : source : 626bc4d2a946d0499a529f974abe2711c0174241
This commit is contained in:
Xidorn Quan 2015-04-30 16:24:59 +12:00
Родитель e30901b6a0
Коммит 82e7b5cf9f
7 изменённых файлов: 47 добавлений и 59 удалений

Просмотреть файл

@ -230,7 +230,7 @@ ComputeBorderOverflow(nsMathMLmtdFrame* aFrame, nsStyleBorder aStyleBorder)
nsMargin overflow;
int32_t rowIndex;
int32_t columnIndex;
nsTableFrame* table = nsTableFrame::GetTableFrame(aFrame);
nsTableFrame* table = aFrame->GetTableFrame();
aFrame->GetCellIndexes(rowIndex, columnIndex);
if (!columnIndex) {
overflow.left = table->GetColSpacing(-1);

Просмотреть файл

@ -218,7 +218,7 @@ public:
// helper to restyle and reflow the table -- @see nsMathMLmtableFrame.
void RestyleTable()
{
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
if (tableFrame && tableFrame->IsFrameOfType(nsIFrame::eMathML)) {
// relayout the table
((nsMathMLmtableFrame*)tableFrame)->RestyleTable();

Просмотреть файл

@ -131,7 +131,7 @@ nsTableCellFrame::NotifyPercentHeight(const nsHTMLReflowState& aReflowState)
// both this cell and the sibling cell span exactly 1 row.)
if (nsTableFrame::AncestorsHaveStyleHeight(*cellRS) ||
(nsTableFrame::GetTableFrame(this)->GetEffectiveRowSpan(*this) == 1 &&
(GetTableFrame()->GetEffectiveRowSpan(*this) == 1 &&
(cellRS->parentReflowState->frame->GetStateBits() &
NS_ROW_HAS_CELL_WITH_STYLE_HEIGHT))) {
@ -220,8 +220,7 @@ nsTableCellFrame::AttributeChanged(int32_t aNameSpaceID,
FrameNeedsReflow(this, nsIPresShell::eTreeChange, NS_FRAME_IS_DIRTY);
}
// let the table frame decide what to do
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
tableFrame->AttributeChangedFor(this, mContent, aAttribute);
GetTableFrame()->AttributeChangedFor(this, mContent, aAttribute);
return NS_OK;
}
@ -233,7 +232,7 @@ nsTableCellFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
if (!aOldStyleContext) //avoid this on init
return;
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
if (tableFrame->IsBorderCollapse() &&
tableFrame->BCRecalcNeeded(aOldStyleContext, StyleContext())) {
int32_t colIndex, rowIndex;
@ -479,7 +478,7 @@ nsTableCellFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
{
DO_GLOBAL_REFLOW_COUNT_DSP("nsTableCellFrame");
if (IsVisibleInSelection(aBuilder)) {
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
int32_t emptyCellStyle = GetContentEmpty() && !tableFrame->IsBorderCollapse() ?
StyleTableBorder()->mEmptyCells
: NS_STYLE_TABLE_EMPTY_CELLS_SHOW;
@ -901,7 +900,7 @@ nsTableCellFrame::Reflow(nsPresContext* aPresContext,
SetPriorAvailWidth(aReflowState.AvailableWidth());
nsIFrame* firstKid = mFrames.FirstChild();
NS_ASSERTION(firstKid, "Frame construction error, a table cell always has an inner cell frame");
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
if (aReflowState.mFlags.mSpecialHeightReflow) {
const_cast<nsHTMLReflowState&>(aReflowState).SetComputedHeight(mRect.height - topInset - bottomInset);

Просмотреть файл

@ -59,7 +59,7 @@ nsTableColFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
if (!aOldStyleContext) //avoid this on init
return;
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
if (tableFrame->IsBorderCollapse() &&
tableFrame->BCRecalcNeeded(aOldStyleContext, StyleContext())) {
nsIntRect damageArea(GetColIndex(), 0, 1, tableFrame->GetRowCount());
@ -98,8 +98,7 @@ nsTableColFrame::Reflow(nsPresContext* aPresContext,
const nsStyleVisibility* colVis = StyleVisibility();
bool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colVis->mVisible);
if (collapseCol) {
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
tableFrame->SetNeedToCollapse(true);
GetTableFrame()->SetNeedToCollapse(true);
}
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);

Просмотреть файл

@ -75,7 +75,7 @@ nsTableColGroupFrame::AddColsToTable(int32_t aFirstColIndex,
bool aResetSubsequentColIndices,
const nsFrameList::Slice& aCols)
{
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
tableFrame->InvalidateFrameSubtree();
@ -141,9 +141,8 @@ nsTableColGroupFrame::SetInitialChildList(ChildListID aListID,
"unexpected second call to SetInitialChildList");
MOZ_ASSERT(aListID == kPrincipalList, "unexpected child list");
if (aChildList.IsEmpty()) {
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
tableFrame->AppendAnonymousColFrames(this, GetSpan(), eColAnonymousColGroup,
false);
GetTableFrame()->AppendAnonymousColFrames(this, GetSpan(),
eColAnonymousColGroup, false);
return;
}
@ -158,7 +157,7 @@ nsTableColGroupFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
if (!aOldStyleContext) //avoid this on init
return;
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
if (tableFrame->IsBorderCollapse() &&
tableFrame->BCRecalcNeeded(aOldStyleContext, StyleContext())) {
int32_t colCount = GetColCount();
@ -317,7 +316,7 @@ nsTableColGroupFrame::RemoveFrame(ChildListID aListID,
// The RemoveChild call handles calling FrameNeedsReflow on us.
RemoveChild(*colFrame, true);
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
tableFrame->RemoveCol(this, colIndex, true, true);
if (mFrames.IsEmpty() && contentRemoval &&
GetColType() == eColGroupContent) {
@ -362,8 +361,7 @@ nsTableColGroupFrame::Reflow(nsPresContext* aPresContext,
const nsStyleVisibility* groupVis = StyleVisibility();
bool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
if (collapseGroup) {
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
tableFrame->SetNeedToCollapse(true);
GetTableFrame()->SetNeedToCollapse(true);
}
// for every content child that (is a column thingy and does not already have a frame)
// create a frame and adjust it's style
@ -436,8 +434,8 @@ void nsTableColGroupFrame::SetContinuousBCBorderWidth(uint8_t aForSide,
void nsTableColGroupFrame::GetContinuousBCBorderWidth(nsMargin& aBorder)
{
int32_t aPixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
nsTableFrame* table = nsTableFrame::GetTableFrame(this);
nsTableColFrame* col = table->GetColFrame(mStartColIndex + mColCount - 1);
nsTableColFrame* col = GetTableFrame()->
GetColFrame(mStartColIndex + mColCount - 1);
col->GetContinuousBCBorderWidth(aBorder);
aBorder.top = BC_BORDER_BOTTOM_HALF_COORD(aPixelsToTwips,
mTopContBorderWidth);

Просмотреть файл

@ -171,7 +171,7 @@ nsTableRowFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
if (!aOldStyleContext) //avoid this on init
return;
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
if (tableFrame->IsBorderCollapse() &&
tableFrame->BCRecalcNeeded(aOldStyleContext, StyleContext())) {
nsIntRect damageArea(0, GetRowIndex(), tableFrame->GetColCount(), 1);
@ -189,7 +189,7 @@ nsTableRowFrame::AppendFrames(ChildListID aListID,
const nsFrameList::Slice& newCells = mFrames.AppendFrames(nullptr, aFrameList);
// Add the new cell frames to the table
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
for (nsFrameList::Enumerator e(newCells) ; !e.AtEnd(); e.Next()) {
nsIFrame *childFrame = e.get();
NS_ASSERTION(IS_TABLE_CELL(childFrame->GetType()),"Not a table cell frame/pseudo frame construction failure");
@ -215,7 +215,7 @@ nsTableRowFrame::InsertFrames(ChildListID aListID,
const nsFrameList::Slice& newCells = mFrames.InsertFrames(nullptr, aPrevFrame, aFrameList);
// Get the table frame
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
nsIAtom* cellFrameType = tableFrame->IsBorderCollapse() ? nsGkAtoms::bcTableCellFrame : nsGkAtoms::tableCellFrame;
nsTableCellFrame* prevCellFrame = (nsTableCellFrame *)nsTableFrame::GetFrameAtOrBefore(this, aPrevFrame, cellFrameType);
nsTArray<nsTableCellFrame*> cellChildren;
@ -245,7 +245,7 @@ nsTableRowFrame::RemoveFrame(ChildListID aListID,
MOZ_ASSERT((nsTableCellFrame*)do_QueryFrame(aOldFrame));
nsTableCellFrame* cellFrame = static_cast<nsTableCellFrame*>(aOldFrame);
// remove the cell from the cell map
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
tableFrame->RemoveCell(cellFrame, GetRowIndex());
// Remove the frame and destroy it
@ -316,7 +316,7 @@ void
nsTableRowFrame::DidResize()
{
// Resize and re-align the cell frames based on our row height
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
nsTableIterator iter(*this);
nsIFrame* childFrame = iter.First();
@ -482,7 +482,7 @@ nsTableRowFrame::UpdateHeight(nscoord aHeight,
nscoord
nsTableRowFrame::CalcHeight(const nsHTMLReflowState& aReflowState)
{
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
nscoord computedHeight = (NS_UNCONSTRAINEDSIZE == aReflowState.ComputedHeight())
? 0 : aReflowState.ComputedHeight();
ResetHeight(computedHeight);
@ -546,16 +546,14 @@ void
nsDisplayTableRowBackground::Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx)
{
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(mFrame);
TableBackgroundPainter painter(tableFrame,
auto rowFrame = static_cast<nsTableRowFrame*>(mFrame);
TableBackgroundPainter painter(rowFrame->GetTableFrame(),
TableBackgroundPainter::eOrigin_TableRow,
mFrame->PresContext(), *aCtx,
mVisibleRect, ToReferenceFrame(),
aBuilder->GetBackgroundPaintFlags());
DrawResult result =
painter.PaintRow(static_cast<nsTableRowFrame*>(mFrame));
DrawResult result = painter.PaintRow(rowFrame);
nsDisplayTableItemGeometry::UpdateDrawResult(this, result);
}
@ -611,8 +609,7 @@ nsTableRowFrame::CalculateCellActualHeight(nsTableCellFrame* aCellFrame,
// Get the height specified in the style information
const nsStylePosition* position = aCellFrame->StylePosition();
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
int32_t rowSpan = tableFrame->GetEffectiveRowSpan(*aCellFrame);
int32_t rowSpan = GetTableFrame()->GetEffectiveRowSpan(*aCellFrame);
switch (position->mHeight.GetUnit()) {
case eStyleUnit_Calc: {
@ -1043,7 +1040,7 @@ nsTableRowFrame::Reflow(nsPresContext* aPresContext,
DO_GLOBAL_REFLOW_COUNT("nsTableRowFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
const nsStyleVisibility* rowVis = StyleVisibility();
bool collapseRow = (NS_STYLE_VISIBILITY_COLLAPSE == rowVis->mVisible);
if (collapseRow) {
@ -1099,8 +1096,7 @@ nsTableRowFrame::ReflowCellFrame(nsPresContext* aPresContext,
nsRect cellVisualOverflow = aCellFrame->GetVisualOverflowRect();
nsSize availSize(cellRect.width, aAvailableHeight);
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
bool borderCollapse = tableFrame->IsBorderCollapse();
bool borderCollapse = GetTableFrame()->IsBorderCollapse();
nsTableCellReflowState
cellReflowState(aPresContext, aReflowState, aCellFrame,
LogicalSize(aCellFrame->GetWritingMode(),
@ -1144,8 +1140,8 @@ nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset,
{
const nsStyleVisibility* rowVis = StyleVisibility();
bool collapseRow = (NS_STYLE_VISIBILITY_COLLAPSE == rowVis->mVisible);
nsTableFrame* tableFrame = static_cast<nsTableFrame*>(
nsTableFrame::GetTableFrame(this)->FirstInFlow());
nsTableFrame* tableFrame =
static_cast<nsTableFrame*>(GetTableFrame()->FirstInFlow());
if (collapseRow) {
tableFrame->SetNeedToCollapse(true);
}

Просмотреть файл

@ -74,8 +74,7 @@ int32_t nsTableRowGroupFrame::GetStartRowIndex()
}
// if the row group doesn't have any children, get it the hard way
if (-1 == result) {
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
return tableFrame->GetStartRowIndex(this);
return GetTableFrame()->GetStartRowIndex(this);
}
return result;
@ -157,16 +156,14 @@ void
nsDisplayTableRowGroupBackground::Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx)
{
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(mFrame);
TableBackgroundPainter painter(tableFrame,
auto rgFrame = static_cast<nsTableRowGroupFrame*>(mFrame);
TableBackgroundPainter painter(rgFrame->GetTableFrame(),
TableBackgroundPainter::eOrigin_TableRowGroup,
mFrame->PresContext(), *aCtx,
mVisibleRect, ToReferenceFrame(),
aBuilder->GetBackgroundPaintFlags());
DrawResult result =
painter.PaintRowGroup(static_cast<nsTableRowGroupFrame*>(mFrame));
DrawResult result = painter.PaintRowGroup(rgFrame);
nsDisplayTableItemGeometry::UpdateDrawResult(this, result);
}
@ -327,7 +324,7 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
if (aPageBreakBeforeEnd)
*aPageBreakBeforeEnd = false;
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
const bool borderCollapse = tableFrame->IsBorderCollapse();
// XXXldb Should we really be checking this rather than available height?
@ -525,7 +522,7 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState)
{
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
const bool isPaginated = aPresContext->IsPaginated();
int32_t numEffCols = tableFrame->GetEffectiveColCount();
@ -804,7 +801,7 @@ nscoord
nsTableRowGroupFrame::CollapseRowGroupIfNecessary(nscoord aYTotalOffset,
nscoord aWidth)
{
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
const nsStyleVisibility* groupVis = StyleVisibility();
bool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
if (collapseGroup) {
@ -1294,7 +1291,7 @@ nsTableRowGroupFrame::Reflow(nsPresContext* aPresContext,
// see if a special height reflow needs to occur due to having a pct height
nsTableFrame::CheckRequestSpecialHeightReflow(aReflowState);
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
nsRowGroupReflowState state(aReflowState, tableFrame);
const nsStyleVisibility* groupVis = StyleVisibility();
bool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
@ -1375,7 +1372,7 @@ nsTableRowGroupFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
if (!aOldStyleContext) //avoid this on init
return;
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
if (tableFrame->IsBorderCollapse() &&
tableFrame->BCRecalcNeeded(aOldStyleContext, StyleContext())) {
nsIntRect damageArea(0, GetStartRowIndex(), tableFrame->GetColCount(),
@ -1412,7 +1409,7 @@ nsTableRowGroupFrame::AppendFrames(ChildListID aListID,
mFrames.AppendFrames(nullptr, aFrameList);
if (rows.Length() > 0) {
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
tableFrame->AppendRows(this, rowIndex, rows);
PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
@ -1435,7 +1432,7 @@ nsTableRowGroupFrame::InsertFrames(ChildListID aListID,
// collect the new row frames in an array
// XXXbz why are we doing the QI stuff? There shouldn't be any non-rows here.
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
nsTArray<nsTableRowFrame*> rows;
bool gotFirstRow = false;
for (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) {
@ -1479,10 +1476,10 @@ nsTableRowGroupFrame::RemoveFrame(ChildListID aListID,
ClearRowCursor();
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
// XXX why are we doing the QI stuff? There shouldn't be any non-rows here.
nsTableRowFrame* rowFrame = do_QueryFrame(aOldFrame);
if (rowFrame) {
nsTableFrame* tableFrame = GetTableFrame();
// remove the rows from the table (and flag a rebalance)
tableFrame->RemoveRows(*rowFrame, 1, true);
@ -1516,7 +1513,7 @@ nscoord
nsTableRowGroupFrame::GetHeightBasis(const nsHTMLReflowState& aReflowState)
{
nscoord result = 0;
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsTableFrame* tableFrame = GetTableFrame();
int32_t startRowIndex = GetStartRowIndex();
if ((aReflowState.ComputedHeight() > 0) && (aReflowState.ComputedHeight() < NS_UNCONSTRAINEDSIZE)) {
nscoord cellSpacing = tableFrame->GetRowSpacing(startRowIndex,
@ -1652,9 +1649,8 @@ nsTableRowGroupFrame::GetNumLines()
bool
nsTableRowGroupFrame::GetDirection()
{
nsTableFrame* table = nsTableFrame::GetTableFrame(this);
return (NS_STYLE_DIRECTION_RTL ==
table->StyleVisibility()->mDirection);
GetTableFrame()->StyleVisibility()->mDirection);
}
NS_IMETHODIMP
@ -1666,7 +1662,7 @@ nsTableRowGroupFrame::GetLine(int32_t aLineNumber,
NS_ENSURE_ARG_POINTER(aFirstFrameOnLine);
NS_ENSURE_ARG_POINTER(aNumFramesOnLine);
nsTableFrame* table = nsTableFrame::GetTableFrame(this);
nsTableFrame* table = GetTableFrame();
nsTableCellMap* cellMap = table->GetCellMap();
*aFirstFrameOnLine = nullptr;
@ -1728,7 +1724,7 @@ nsTableRowGroupFrame::FindFrameAt(int32_t aLineNumber,
bool* aPosIsBeforeFirstFrame,
bool* aPosIsAfterLastFrame)
{
nsTableFrame* table = nsTableFrame::GetTableFrame(this);
nsTableFrame* table = GetTableFrame();
nsTableCellMap* cellMap = table->GetCellMap();
WritingMode wm = table->GetWritingMode();