Exemple #1
0
DrawResult
TableBackgroundPainter::PaintCell(nsTableCellFrame* aCell,
                                  const TableBackgroundData& aRowGroupBGData,
                                  const TableBackgroundData& aRowBGData,
                                  nsRect&           aCellBGRect,
                                  nsRect&           aRowBGRect,
                                  nsRect&           aRowGroupBGRect,
                                  nsRect&           aColBGRect,
                                  bool              aPassSelf)
{
  MOZ_ASSERT(aCell, "null frame");

  const nsStyleTableBorder* cellTableStyle;
  cellTableStyle = aCell->StyleTableBorder();
  if (NS_STYLE_TABLE_EMPTY_CELLS_SHOW != cellTableStyle->mEmptyCells &&
      aCell->GetContentEmpty() && !mIsBorderCollapse) {
    return DrawResult::SUCCESS;
  }

  int32_t colIndex;
  aCell->GetColIndex(colIndex);
  // We're checking mNumCols instead of mCols.Length() here because mCols can
  // be empty even if mNumCols > 0.
  NS_ASSERTION(size_t(colIndex) < mNumCols, "out-of-bounds column index");
  if (size_t(colIndex) >= mNumCols) {
    return DrawResult::SUCCESS;
  }

  // If callers call PaintRowGroup or PaintRow directly, we haven't processed
  // our columns. Ignore column / col group backgrounds in that case.
  bool haveColumns = !mCols.IsEmpty();

  DrawResult result = DrawResult::SUCCESS;

  //Paint column group background
  if (haveColumns && mCols[colIndex].mColGroup.IsVisible()) {
    DrawResult colGroupResult =
      nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
                                            mCols[colIndex].mColGroup.mFrame, mDirtyRect,
                                            mCols[colIndex].mColGroup.mRect + mRenderPt,
                                            mCols[colIndex].mColGroup.mFrame->StyleContext(),
                                            mCols[colIndex].mColGroup.StyleBorder(mZeroBorder),
                                            mBGPaintFlags, &aColBGRect);
    UpdateDrawResult(&result, colGroupResult);
  }

  //Paint column background
  if (haveColumns && mCols[colIndex].mCol.IsVisible()) {
    DrawResult colResult =
      nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
                                            mCols[colIndex].mCol.mFrame, mDirtyRect,
                                            mCols[colIndex].mCol.mRect + mRenderPt,
                                            mCols[colIndex].mCol.mFrame->StyleContext(),
                                            mCols[colIndex].mCol.StyleBorder(mZeroBorder),
                                            mBGPaintFlags, &aColBGRect);
    UpdateDrawResult(&result, colResult);
  }

  //Paint row group background
  if (aRowGroupBGData.IsVisible()) {
    DrawResult rowGroupResult =
      nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
                                            aRowGroupBGData.mFrame, mDirtyRect,
                                            aRowGroupBGData.mRect + mRenderPt,
                                            aRowGroupBGData.mFrame->StyleContext(),
                                            aRowGroupBGData.StyleBorder(mZeroBorder),
                                            mBGPaintFlags, &aRowGroupBGRect);
    UpdateDrawResult(&result, rowGroupResult);
  }

  //Paint row background
  if (aRowBGData.IsVisible()) {
    DrawResult rowResult =
      nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
                                            aRowBGData.mFrame, mDirtyRect,
                                            aRowBGData.mRect + mRenderPt,
                                            aRowBGData.mFrame->StyleContext(),
                                            aRowBGData.StyleBorder(mZeroBorder),
                                            mBGPaintFlags, &aRowBGRect);
    UpdateDrawResult(&result, rowResult);
  }

  //Paint cell background in border-collapse unless we're just passing
  if (mIsBorderCollapse && !aPassSelf) {
    DrawResult cellResult =
      aCell->PaintCellBackground(mRenderingContext, mDirtyRect,
                                 aCellBGRect.TopLeft(), mBGPaintFlags);
    UpdateDrawResult(&result, cellResult);
  }

  return result;
}