Bug 1128769 (Part 4) - Record the last draw result when drawing CSS tables and use it to decide whether to sync decode. r=tn

This commit is contained in:
Seth Fowler
2015-02-05 20:45:56 -08:00
parent 6cb87a0c67
commit 2488118ac6
8 changed files with 247 additions and 151 deletions

View File

@@ -40,6 +40,7 @@
using namespace mozilla;
using namespace mozilla::gfx;
using namespace mozilla::image;
nsTableCellFrame::nsTableCellFrame(nsStyleContext* aContext) :
nsContainerFrame(aContext)
@@ -363,27 +364,28 @@ nsTableCellFrame::DecorateForSelection(nsRenderingContext& aRenderingContext,
}
}
void
DrawResult
nsTableCellFrame::PaintBackground(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt,
uint32_t aFlags)
{
nsRect rect(aPt, GetSize());
nsCSSRendering::PaintBackground(PresContext(), aRenderingContext, this,
aDirtyRect, rect, aFlags);
return nsCSSRendering::PaintBackground(PresContext(), aRenderingContext, this,
aDirtyRect, rect, aFlags);
}
// Called by nsTablePainter
void
DrawResult
nsTableCellFrame::PaintCellBackground(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect, nsPoint aPt,
uint32_t aFlags)
{
if (!StyleVisibility()->IsVisible())
return;
if (!StyleVisibility()->IsVisible()) {
return DrawResult::SUCCESS;
}
PaintBackground(aRenderingContext, aDirtyRect, aPt, aFlags);
return PaintBackground(aRenderingContext, aDirtyRect, aPt, aFlags);
}
nsresult
@@ -426,6 +428,7 @@ public:
nsRenderingContext* aCtx) MOZ_OVERRIDE;
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
bool* aSnap) MOZ_OVERRIDE;
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE;
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion *aInvalidRegion) MOZ_OVERRIDE;
@@ -436,9 +439,11 @@ public:
void nsDisplayTableCellBackground::Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx)
{
static_cast<nsTableCellFrame*>(mFrame)->
DrawResult result = static_cast<nsTableCellFrame*>(mFrame)->
PaintBackground(*aCtx, mVisibleRect, ToReferenceFrame(),
aBuilder->GetBackgroundPaintFlags());
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
}
nsRect
@@ -450,16 +455,24 @@ nsDisplayTableCellBackground::GetBounds(nsDisplayListBuilder* aBuilder,
return nsDisplayItem::GetBounds(aBuilder, aSnap);
}
nsDisplayItemGeometry*
nsDisplayTableCellBackground::AllocateGeometry(nsDisplayListBuilder* aBuilder)
{
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
}
void
nsDisplayTableCellBackground::ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion *aInvalidRegion)
{
if (aBuilder->ShouldSyncDecodeImages()) {
if (!nsCSSRendering::AreAllBackgroundImagesDecodedForFrame(mFrame)) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
auto geometry =
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
if (aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
nsDisplayTableItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
@@ -1219,7 +1232,7 @@ nsBCTableCellFrame::GetBorderOverflow()
}
void
DrawResult
nsBCTableCellFrame::PaintBackground(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt,
@@ -1239,8 +1252,8 @@ nsBCTableCellFrame::PaintBackground(nsRenderingContext& aRenderingContext,
nsRect rect(aPt, GetSize());
// bypassing nsCSSRendering::PaintBackground is safe because this kind
// of frame cannot be used for the root element
nsCSSRendering::PaintBackgroundWithSC(PresContext(), aRenderingContext, this,
aDirtyRect, rect,
StyleContext(), myBorder,
aFlags, nullptr);
return nsCSSRendering::PaintBackgroundWithSC(PresContext(), aRenderingContext,
this, aDirtyRect, rect,
StyleContext(), myBorder,
aFlags, nullptr);
}

View File

@@ -7,6 +7,7 @@
#include "mozilla/Attributes.h"
#include "celldata.h"
#include "imgIContainer.h"
#include "nsITableCellLayout.h"
#include "nscore.h"
#include "nsContainerFrame.h"
@@ -33,6 +34,8 @@ class nsTableCellFrame : public nsContainerFrame,
public nsITableCellLayout,
public nsIPercentHeightObserver
{
typedef mozilla::image::DrawResult DrawResult;
public:
NS_DECL_QUERYFRAME_TARGET(nsTableCellFrame)
NS_DECL_QUERYFRAME
@@ -93,9 +96,9 @@ public:
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
void PaintCellBackground(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect, nsPoint aPt,
uint32_t aFlags);
DrawResult PaintCellBackground(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect, nsPoint aPt,
uint32_t aFlags);
virtual nsresult ProcessBorders(nsTableFrame* aFrame,
@@ -202,10 +205,10 @@ public:
virtual nsMargin* GetBorderWidth(nsMargin& aBorder) const;
virtual void PaintBackground(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt,
uint32_t aFlags);
virtual DrawResult PaintBackground(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt,
uint32_t aFlags);
void DecorateForSelection(nsRenderingContext& aRenderingContext,
nsPoint aPt);
@@ -289,6 +292,7 @@ inline void nsTableCellFrame::SetHasPctOverHeight(bool aValue)
// nsBCTableCellFrame
class nsBCTableCellFrame MOZ_FINAL : public nsTableCellFrame
{
typedef mozilla::image::DrawResult DrawResult;
public:
NS_DECL_FRAMEARENA_HELPERS
@@ -319,10 +323,10 @@ public:
virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
#endif
virtual void PaintBackground(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt,
uint32_t aFlags) MOZ_OVERRIDE;
virtual DrawResult PaintBackground(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt,
uint32_t aFlags) MOZ_OVERRIDE;
private:

View File

@@ -47,6 +47,7 @@
#include <algorithm>
using namespace mozilla;
using namespace mozilla::image;
using namespace mozilla::layout;
/********************************************************************************
@@ -1107,6 +1108,7 @@ public:
}
#endif
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE;
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion *aInvalidRegion) MOZ_OVERRIDE;
@@ -1129,25 +1131,10 @@ IsFrameAllowedInTable(nsIAtom* aType)
}
#endif
/* static */ bool
nsTableFrame::AnyTablePartHasUndecodedBackgroundImage(nsIFrame* aStart,
nsIFrame* aEnd)
nsDisplayItemGeometry*
nsDisplayTableBorderBackground::AllocateGeometry(nsDisplayListBuilder* aBuilder)
{
for (nsIFrame* f = aStart; f != aEnd; f = f->GetNextSibling()) {
NS_ASSERTION(IsFrameAllowedInTable(f->GetType()), "unexpected frame type");
if (!nsCSSRendering::AreAllBackgroundImagesDecodedForFrame(f))
return true;
nsTableCellFrame *cellFrame = do_QueryFrame(f);
if (cellFrame)
continue;
if (AnyTablePartHasUndecodedBackgroundImage(f->PrincipalChildList().FirstChild(), nullptr))
return true;
}
return false;
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
}
void
@@ -1155,13 +1142,13 @@ nsDisplayTableBorderBackground::ComputeInvalidationRegion(nsDisplayListBuilder*
const nsDisplayItemGeometry* aGeometry,
nsRegion *aInvalidRegion)
{
if (aBuilder->ShouldSyncDecodeImages()) {
if (nsTableFrame::AnyTablePartHasUndecodedBackgroundImage(mFrame, mFrame->GetNextSibling()) ||
nsTableFrame::AnyTablePartHasUndecodedBackgroundImage(
mFrame->GetChildList(nsIFrame::kColGroupList).FirstChild(), nullptr)) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
auto geometry =
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
if (aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
nsDisplayTableItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
@@ -1171,10 +1158,12 @@ void
nsDisplayTableBorderBackground::Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx)
{
static_cast<nsTableFrame*>(mFrame)->
DrawResult result = static_cast<nsTableFrame*>(mFrame)->
PaintTableBorderBackground(*aCtx, mVisibleRect,
ToReferenceFrame(),
aBuilder->GetBackgroundPaintFlags());
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
}
static int32_t GetTablePartRank(nsDisplayItem* aItem)
@@ -1345,7 +1334,7 @@ nsTableFrame::GetDeflationForBackground(nsPresContext* aPresContext) const
// XXX We don't put the borders and backgrounds in tree order like we should.
// That requires some major surgery which we aren't going to do right now.
void
DrawResult
nsTableFrame::PaintTableBorderBackground(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt, uint32_t aBGPaintFlags)
@@ -1358,7 +1347,8 @@ nsTableFrame::PaintTableBorderBackground(nsRenderingContext& aRenderingContext,
nsMargin deflate = GetDeflationForBackground(presContext);
// If 'deflate' is (0,0,0,0) then we'll paint the table background
// in a separate display item, so don't do it here.
painter.PaintTable(this, deflate, deflate != nsMargin(0, 0, 0, 0));
DrawResult result =
painter.PaintTable(this, deflate, deflate != nsMargin(0, 0, 0, 0));
if (StyleVisibility()->IsVisible()) {
if (!IsBorderCollapse()) {
@@ -1382,6 +1372,8 @@ nsTableFrame::PaintTableBorderBackground(nsRenderingContext& aRenderingContext,
PaintBCBorders(aRenderingContext, aDirtyRect - aPt);
}
}
return result;
}
nsIFrame::LogicalSides

View File

@@ -7,6 +7,7 @@
#include "mozilla/Attributes.h"
#include "celldata.h"
#include "imgIContainer.h"
#include "nscore.h"
#include "nsContainerFrame.h"
#include "nsStyleCoord.h"
@@ -106,6 +107,8 @@ private:
*/
class nsTableFrame : public nsContainerFrame
{
typedef mozilla::image::DrawResult DrawResult;
public:
NS_DECL_FRAMEARENA_HELPERS
@@ -246,16 +249,9 @@ public:
* columns, row groups, rows, and cells), and the table border, and all
* internal borders if border-collapse is on.
*/
void PaintTableBorderBackground(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt, uint32_t aBGPaintFlags);
/**
* Determines if any table part has a background image that is currently not
* decoded. Does not look into cell contents (ie only table parts).
*/
static bool AnyTablePartHasUndecodedBackgroundImage(nsIFrame* aStart,
nsIFrame* aEnd);
DrawResult PaintTableBorderBackground(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt, uint32_t aBGPaintFlags);
/** Get the outer half (i.e., the part outside the height and width of
* the table) of the largest segment (?) of border-collapsed border on

View File

@@ -95,6 +95,8 @@
XXX views are going
*/
using namespace mozilla::image;
TableBackgroundPainter::TableBackgroundData::TableBackgroundData()
: mFrame(nullptr)
, mVisible(false)
@@ -185,7 +187,16 @@ TableBackgroundPainter::~TableBackgroundPainter()
MOZ_COUNT_DTOR(TableBackgroundPainter);
}
void
static void
UpdateDrawResult(DrawResult* aCurrentResult, DrawResult aNewResult)
{
MOZ_ASSERT(aCurrentResult);
if (*aCurrentResult == DrawResult::SUCCESS) {
*aCurrentResult = aNewResult;
}
}
DrawResult
TableBackgroundPainter::PaintTableFrame(nsTableFrame* aTableFrame,
nsTableRowGroupFrame* aFirstRowGroup,
nsTableRowGroupFrame* aLastRowGroup,
@@ -220,14 +231,20 @@ TableBackgroundPainter::PaintTableFrame(nsTableFrame* aTableFrame,
tableData.SetBCBorder(border);
}
}
DrawResult result = DrawResult::SUCCESS;
if (tableData.IsVisible()) {
nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
tableData.mFrame, mDirtyRect,
tableData.mRect + mRenderPt,
tableData.mFrame->StyleContext(),
tableData.StyleBorder(mZeroBorder),
mBGPaintFlags);
result =
nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
tableData.mFrame, mDirtyRect,
tableData.mRect + mRenderPt,
tableData.mFrame->StyleContext(),
tableData.StyleBorder(mZeroBorder),
mBGPaintFlags);
}
return result;
}
void
@@ -249,7 +266,7 @@ TableBackgroundPainter::ColData::ColData(nsIFrame* aFrame, TableBackgroundData&
{
}
void
DrawResult
TableBackgroundPainter::PaintTable(nsTableFrame* aTableFrame,
const nsMargin& aDeflate,
bool aPaintTableBackground)
@@ -259,12 +276,14 @@ TableBackgroundPainter::PaintTable(nsTableFrame* aTableFrame,
nsTableFrame::RowGroupArray rowGroups;
aTableFrame->OrderRowGroups(rowGroups);
DrawResult result = DrawResult::SUCCESS;
if (rowGroups.Length() < 1) { //degenerate case
if (aPaintTableBackground) {
PaintTableFrame(aTableFrame, nullptr, nullptr, nsMargin(0,0,0,0));
}
/* No cells; nothing else to paint */
return;
return result;
}
if (aPaintTableBackground) {
@@ -343,18 +362,22 @@ TableBackgroundPainter::PaintTable(nsTableFrame* aTableFrame,
nsRect rgNormalRect = rgVisualOverflow + rg->GetNormalPosition();
if (rgOverflowRect.Union(rgNormalRect).Intersects(mDirtyRect - mRenderPt)) {
PaintRowGroup(rg, rowGroupBGData, rg->IsPseudoStackingContextFromStyle());
DrawResult rowGroupResult =
PaintRowGroup(rg, rowGroupBGData, rg->IsPseudoStackingContextFromStyle());
UpdateDrawResult(&result, rowGroupResult);
}
}
return result;
}
void
DrawResult
TableBackgroundPainter::PaintRowGroup(nsTableRowGroupFrame* aFrame)
{
PaintRowGroup(aFrame, TableBackgroundData(aFrame), false);
return PaintRowGroup(aFrame, TableBackgroundData(aFrame), false);
}
void
DrawResult
TableBackgroundPainter::PaintRowGroup(nsTableRowGroupFrame* aFrame,
TableBackgroundData aRowGroupBGData,
bool aPassThrough)
@@ -412,6 +435,8 @@ TableBackgroundPainter::PaintRowGroup(nsTableRowGroupFrame* aFrame,
row = firstRow;
}
DrawResult result = DrawResult::SUCCESS;
/* Finally paint */
for (; row; row = row->GetNextRow()) {
TableBackgroundData rowBackgroundData(row);
@@ -427,23 +452,28 @@ TableBackgroundPainter::PaintRowGroup(nsTableRowGroupFrame* aFrame,
break;
}
PaintRow(row, aRowGroupBGData, rowBackgroundData,
aPassThrough || row->IsPseudoStackingContextFromStyle());
DrawResult rowResult =
PaintRow(row, aRowGroupBGData, rowBackgroundData,
aPassThrough || row->IsPseudoStackingContextFromStyle());
UpdateDrawResult(&result, rowResult);
}
/* translate back into table coord system */
if (eOrigin_TableRowGroup != mOrigin) {
TranslateContext(-rgRect.x, -rgRect.y);
}
return result;
}
void
DrawResult
TableBackgroundPainter::PaintRow(nsTableRowFrame* aFrame)
{
return PaintRow(aFrame, TableBackgroundData(), TableBackgroundData(aFrame), false);
}
void
DrawResult
TableBackgroundPainter::PaintRow(nsTableRowFrame* aFrame,
const TableBackgroundData& aRowGroupBGData,
TableBackgroundData aRowBGData,
@@ -480,6 +510,8 @@ TableBackgroundPainter::PaintRow(nsTableRowFrame* aFrame,
}
//else: Use row group's coord system -> no translation necessary
DrawResult result = DrawResult::SUCCESS;
for (nsTableCellFrame* cell = aFrame->GetFirstCell(); cell; cell = cell->GetNextCell()) {
nsRect cellBGRect, rowBGRect, rowGroupBGRect, colBGRect;
ComputeCellBackgrounds(cell, aRowGroupBGData, aRowBGData,
@@ -494,13 +526,18 @@ TableBackgroundPainter::PaintRow(nsTableRowFrame* aFrame,
if (combinedRect.Intersects(mDirtyRect)) {
bool passCell = aPassThrough || cell->IsPseudoStackingContextFromStyle();
PaintCell(cell, aRowGroupBGData, aRowBGData,
cellBGRect, rowBGRect, rowGroupBGRect, colBGRect, passCell);
DrawResult cellResult =
PaintCell(cell, aRowGroupBGData, aRowBGData,
cellBGRect, rowBGRect, rowGroupBGRect, colBGRect, passCell);
UpdateDrawResult(&result, cellResult);
}
}
return result;
}
void
DrawResult
TableBackgroundPainter::PaintCell(nsTableCellFrame* aCell,
const TableBackgroundData& aRowGroupBGData,
const TableBackgroundData& aRowBGData,
@@ -516,7 +553,7 @@ TableBackgroundPainter::PaintCell(nsTableCellFrame* aCell,
cellTableStyle = aCell->StyleTableBorder();
if (NS_STYLE_TABLE_EMPTY_CELLS_SHOW != cellTableStyle->mEmptyCells &&
aCell->GetContentEmpty() && !mIsBorderCollapse) {
return;
return DrawResult::SUCCESS;
}
int32_t colIndex;
@@ -524,58 +561,73 @@ TableBackgroundPainter::PaintCell(nsTableCellFrame* aCell,
// 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;
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()) {
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);
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()) {
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);
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()) {
nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
aRowGroupBGData.mFrame, mDirtyRect,
aRowGroupBGData.mRect + mRenderPt,
aRowGroupBGData.mFrame->StyleContext(),
aRowGroupBGData.StyleBorder(mZeroBorder),
mBGPaintFlags, &aRowGroupBGRect);
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()) {
nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
aRowBGData.mFrame, mDirtyRect,
aRowBGData.mRect + mRenderPt,
aRowBGData.mFrame->StyleContext(),
aRowBGData.StyleBorder(mZeroBorder),
mBGPaintFlags, &aRowBGRect);
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) {
aCell->PaintCellBackground(mRenderingContext, mDirtyRect,
aCellBGRect.TopLeft(), mBGPaintFlags);
DrawResult cellResult =
aCell->PaintCellBackground(mRenderingContext, mDirtyRect,
aCellBGRect.TopLeft(), mBGPaintFlags);
UpdateDrawResult(&result, cellResult);
}
return result;
}
void

View File

@@ -6,6 +6,8 @@
#ifndef nsTablePainter_h__
#define nsTablePainter_h__
#include "imgIContainer.h"
#include "celldata.h"
// flags for Paint, PaintChild, PaintChildren are currently only used by tables.
@@ -27,6 +29,8 @@ class TableBackgroundPainter
*
*/
typedef mozilla::image::DrawResult DrawResult;
public:
enum Origin { eOrigin_Table, eOrigin_TableRowGroup, eOrigin_TableRow };
@@ -80,9 +84,12 @@ class TableBackgroundPainter
* to the outer grid lines in border-collapse
* @param aPaintTableBackground - if true, the table background
* is included, otherwise it isn't
* @returns DrawResult::SUCCESS if all painting was successful. If some
* painting failed or an improved result could be achieved by sync
* decoding images, returns another value.
*/
void PaintTable(nsTableFrame* aTableFrame, const nsMargin& aDeflate,
bool aPaintTableBackground);
DrawResult PaintTable(nsTableFrame* aTableFrame, const nsMargin& aDeflate,
bool aPaintTableBackground);
/** Paint background for the row group and its children down through cells
* (Cells themselves will only be painted in border collapse)
@@ -90,8 +97,11 @@ class TableBackgroundPainter
* Table Row Group must do a flagged TABLE_BG_PAINT ::Paint call on its
* children afterwards
* @param aFrame - the table row group frame
* @returns DrawResult::SUCCESS if all painting was successful. If some
* painting failed or an improved result could be achieved by sync
* decoding images, returns another value.
*/
void PaintRowGroup(nsTableRowGroupFrame* aFrame);
DrawResult PaintRowGroup(nsTableRowGroupFrame* aFrame);
/** Paint background for the row and its children down through cells
* (Cells themselves will only be painted in border collapse)
@@ -99,8 +109,11 @@ class TableBackgroundPainter
* Table Row must do a flagged TABLE_BG_PAINT ::Paint call on its
* children afterwards
* @param aFrame - the table row frame
* @returns DrawResult::SUCCESS if all painting was successful. If some
* painting failed or an improved result could be achieved by sync
* decoding images, returns another value.
*/
void PaintRow(nsTableRowFrame* aFrame);
DrawResult PaintRow(nsTableRowFrame* aFrame);
private:
struct TableBackgroundData;
@@ -114,10 +127,10 @@ class TableBackgroundPainter
* @param aDeflate - adjustment to frame's rect (used for quirks BC)
* may be null
*/
void PaintTableFrame(nsTableFrame* aTableFrame,
nsTableRowGroupFrame* aFirstRowGroup,
nsTableRowGroupFrame* aLastRowGroup,
const nsMargin& aDeflate);
DrawResult PaintTableFrame(nsTableFrame* aTableFrame,
nsTableRowGroupFrame* aFirstRowGroup,
nsTableRowGroupFrame* aLastRowGroup,
const nsMargin& aDeflate);
/* aPassThrough params indicate whether to paint the element or to just
* pass through and paint underlying layers only.
@@ -125,14 +138,14 @@ class TableBackgroundPainter
* its copy. Same for aRowBGData in PaintRow.
* See Public versions for function descriptions
*/
void PaintRowGroup(nsTableRowGroupFrame* aFrame,
TableBackgroundData aRowGroupBGData,
bool aPassThrough);
DrawResult PaintRowGroup(nsTableRowGroupFrame* aFrame,
TableBackgroundData aRowGroupBGData,
bool aPassThrough);
void PaintRow(nsTableRowFrame* aFrame,
const TableBackgroundData& aRowGroupBGData,
TableBackgroundData aRowBGData,
bool aPassThrough);
DrawResult PaintRow(nsTableRowFrame* aFrame,
const TableBackgroundData& aRowGroupBGData,
TableBackgroundData aRowBGData,
bool aPassThrough);
/** Paint table background layers for this cell space
* Also paints cell's own background in border-collapse mode
@@ -145,14 +158,14 @@ class TableBackgroundPainter
* @param aColBGRect - background rect for the column and column group
* @param aPassSelf - pass this cell; i.e. paint only underlying layers
*/
void PaintCell(nsTableCellFrame* aCell,
const TableBackgroundData& aRowGroupBGData,
const TableBackgroundData& aRowBGData,
nsRect& aCellBGRect,
nsRect& aRowBGRect,
nsRect& aRowGroupBGRect,
nsRect& aColBGRect,
bool aPassSelf);
DrawResult PaintCell(nsTableCellFrame* aCell,
const TableBackgroundData& aRowGroupBGData,
const TableBackgroundData& aRowBGData,
nsRect& aCellBGRect,
nsRect& aRowBGRect,
nsRect& aRowGroupBGRect,
nsRect& aColBGRect,
bool aPassSelf);
/** Compute table background layer positions for this cell space
* @param aCell - the cell

View File

@@ -535,6 +535,7 @@ public:
}
#endif
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE;
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion *aInvalidRegion) MOZ_OVERRIDE;
@@ -543,16 +544,24 @@ public:
NS_DISPLAY_DECL_NAME("TableRowBackground", TYPE_TABLE_ROW_BACKGROUND)
};
nsDisplayItemGeometry*
nsDisplayTableRowBackground::AllocateGeometry(nsDisplayListBuilder* aBuilder)
{
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
}
void
nsDisplayTableRowBackground::ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion *aInvalidRegion)
{
if (aBuilder->ShouldSyncDecodeImages()) {
if (nsTableFrame::AnyTablePartHasUndecodedBackgroundImage(mFrame, mFrame->GetNextSibling())) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
auto geometry =
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
if (aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
nsDisplayTableItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
@@ -568,7 +577,11 @@ nsDisplayTableRowBackground::Paint(nsDisplayListBuilder* aBuilder,
mFrame->PresContext(), *aCtx,
mVisibleRect, ToReferenceFrame(),
aBuilder->GetBackgroundPaintFlags());
painter.PaintRow(static_cast<nsTableRowFrame*>(mFrame));
DrawResult result =
painter.PaintRow(static_cast<nsTableRowFrame*>(mFrame));
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
}
void

View File

@@ -147,6 +147,7 @@ public:
}
#endif
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE;
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion *aInvalidRegion) MOZ_OVERRIDE;
@@ -156,16 +157,24 @@ public:
NS_DISPLAY_DECL_NAME("TableRowGroupBackground", TYPE_TABLE_ROW_GROUP_BACKGROUND)
};
nsDisplayItemGeometry*
nsDisplayTableRowGroupBackground::AllocateGeometry(nsDisplayListBuilder* aBuilder)
{
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
}
void
nsDisplayTableRowGroupBackground::ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion *aInvalidRegion)
{
if (aBuilder->ShouldSyncDecodeImages()) {
if (nsTableFrame::AnyTablePartHasUndecodedBackgroundImage(mFrame, mFrame->GetNextSibling())) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
auto geometry =
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
if (aBuilder->ShouldSyncDecodeImages() &&
geometry->ShouldInvalidateToSyncDecodeImages()) {
bool snap;
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
}
nsDisplayTableItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
@@ -181,7 +190,11 @@ nsDisplayTableRowGroupBackground::Paint(nsDisplayListBuilder* aBuilder,
mFrame->PresContext(), *aCtx,
mVisibleRect, ToReferenceFrame(),
aBuilder->GetBackgroundPaintFlags());
painter.PaintRowGroup(static_cast<nsTableRowGroupFrame*>(mFrame));
DrawResult result =
painter.PaintRowGroup(static_cast<nsTableRowGroupFrame*>(mFrame));
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
}
// Handle the child-traversal part of DisplayGenericTablePart