Bug 929484 - Draw each table's background on their own display item. r=mstange

This patch do following things:
1. Create nsDisplayTableBorderCollapse that draws all collapse border of
table.
2. Don't use nsDisplayTableBorderBackground.
3. Let column and column group frame generate display items.
4. When traversing the table, also traverse the column and column group
frames.
5. For each type of table frame (col group, col, row group, row and
cell), draw their own background.

MozReview-Commit-ID: 1s2VLv6G8xi
This commit is contained in:
Morris Tseng
2017-05-05 14:30:15 +08:00
parent 411cbb77a9
commit 6476db5de7
13 changed files with 227 additions and 228 deletions

View File

@@ -490,71 +490,51 @@ nsTableCellFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists)
{
DO_GLOBAL_REFLOW_COUNT_DSP("nsTableCellFrame");
if (IsVisibleInSelection(aBuilder)) {
nsTableFrame* tableFrame = GetTableFrame();
int32_t emptyCellStyle = GetContentEmpty() && !tableFrame->IsBorderCollapse() ?
StyleTableBorder()->mEmptyCells
: NS_STYLE_TABLE_EMPTY_CELLS_SHOW;
// take account of 'empty-cells'
if (StyleVisibility()->IsVisible() &&
(NS_STYLE_TABLE_EMPTY_CELLS_HIDE != emptyCellStyle)) {
// display outset box-shadows if we need to.
bool hasBoxShadow = !!StyleEffects()->mBoxShadow;
if (hasBoxShadow) {
aLists.BorderBackground()->AppendNewToTop(
new (aBuilder) nsDisplayBoxShadowOuter(aBuilder, this));
}
// display background if we need to.
if (aBuilder->IsForEventDelivery() ||
!StyleBackground()->IsTransparent(this) ||
StyleDisplay()->UsedAppearance()) {
if (!tableFrame->IsBorderCollapse()) {
nsDisplayBackgroundImage::AppendBackgroundItemsToTop(aBuilder,
this,
GetRectRelativeToSelf(),
aLists.BorderBackground());
} else if (aBuilder->IsAtRootOfPseudoStackingContext() ||
aBuilder->IsForEventDelivery()) {
// The cell background was not painted by the nsTablePainter,
// so we need to do it. We have special background processing here
// so we need to duplicate some code from nsFrame::DisplayBorderBackgroundOutline
nsDisplayTableItem* item =
new (aBuilder) nsDisplayTableCellBackground(aBuilder, this);
aLists.BorderBackground()->AppendNewToTop(item);
item->UpdateForFrameBackground(this);
} else {
// The nsTablePainter will paint our background. Make sure it
// knows if we're background-attachment:fixed.
nsDisplayTableItem* currentItem = aBuilder->GetCurrentTableItem();
if (currentItem) {
currentItem->UpdateForFrameBackground(this);
}
}
}
// display inset box-shadows if we need to.
if (hasBoxShadow) {
aLists.BorderBackground()->AppendNewToTop(
new (aBuilder) nsDisplayBoxShadowInner(aBuilder, this));
}
// display borders if we need to
ProcessBorders(tableFrame, aBuilder, aLists);
// and display the selection border if we need to
if (IsSelected()) {
aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
nsDisplayGeneric(aBuilder, this, ::PaintTableCellSelection,
"TableCellSelection",
nsDisplayItem::TYPE_TABLE_CELL_SELECTION));
}
nsTableFrame* tableFrame = GetTableFrame();
int32_t emptyCellStyle = GetContentEmpty() && !tableFrame->IsBorderCollapse() ?
StyleTableBorder()->mEmptyCells
: NS_STYLE_TABLE_EMPTY_CELLS_SHOW;
// take account of 'empty-cells'
if (StyleVisibility()->IsVisible() &&
(NS_STYLE_TABLE_EMPTY_CELLS_HIDE != emptyCellStyle)) {
// display outset box-shadows if we need to.
bool hasBoxShadow = !!StyleEffects()->mBoxShadow;
if (hasBoxShadow) {
aLists.BorderBackground()->AppendNewToTop(
new (aBuilder) nsDisplayBoxShadowOuter(aBuilder, this));
}
// display background if we need to.
if (aBuilder->IsForEventDelivery() ||
!StyleBackground()->IsTransparent(this) ||
StyleDisplay()->UsedAppearance()) {
nsDisplayBackgroundImage::AppendBackgroundItemsToTop(aBuilder,
this,
GetRectRelativeToSelf(),
aLists.BorderBackground());
}
// display inset box-shadows if we need to.
if (hasBoxShadow) {
aLists.BorderBackground()->AppendNewToTop(
new (aBuilder) nsDisplayBoxShadowInner(aBuilder, this));
}
// display borders if we need to
ProcessBorders(tableFrame, aBuilder, aLists);
// and display the selection border if we need to
if (IsSelected()) {
aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
nsDisplayGeneric(aBuilder, this, ::PaintTableCellSelection,
"TableCellSelection",
nsDisplayItem::TYPE_TABLE_CELL_SELECTION));
}
// the 'empty-cells' property has no effect on 'outline'
DisplayOutline(aBuilder, aLists);
}
// the 'empty-cells' property has no effect on 'outline'
DisplayOutline(aBuilder, aLists);
// Push a null 'current table item' so that descendant tables can't
// accidentally mess with our table
nsAutoPushCurrentTableItem pushTableItem;