Issue #1355 - Better way to create display items for column backgrounds

Part 1: Remove current table item, as it's never set.

Part 2: Get rid of generic table painting code, and handle each class separately.

Part 4: Hoist outline skipping into col(group) frame code.

Part 5: Skip box-shadow for table column and column groups.

Part 6: Store column and column group backgrounds separately, and then append them before the rest of the table contents.

Part 7: Pass rects in display list coordinates to AppendBackgroundItemsToTop.

Part 8: Create column and column group background display items as part of the cell's BuildDisplayList.

Part 9: Used cached values instead of calling nsDisplayListBuilder::ToReferenceFrame when possible, since it can be expensive when the requested frame isn't the builder's current frame.

Part 10: Make sure we build display items for table parts where only the normal position is visible, since we may need to create background items for ancestors at that position.

Part 11: Create an AutoBuildingDisplayList when we create background items for table columns and column groups, so that we initialize the invalidation state correctly.
This commit is contained in:
win7-7 2020-05-08 01:21:41 +03:00 committed by Roy Tam
commit 9c783146b2
29 changed files with 488 additions and 340 deletions

View file

@ -461,14 +461,14 @@ nsTableCellFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
new (aBuilder) nsDisplayBoxShadowOuter(aBuilder, this));
}
nsRect bgRect = GetRectRelativeToSelf() + aBuilder->ToReferenceFrame(this);
// display background if we need to.
if (aBuilder->IsForEventDelivery() ||
!StyleBackground()->IsTransparent() ||
StyleDisplay()->mAppearance) {
nsDisplayBackgroundImage::AppendBackgroundItemsToTop(aBuilder,
this,
GetRectRelativeToSelf(),
aLists.BorderBackground());
nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
aBuilder, this, bgRect, aLists.BorderBackground());
}
// display inset box-shadows if we need to.
@ -487,16 +487,49 @@ nsTableCellFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
"TableCellSelection",
nsDisplayItem::TYPE_TABLE_CELL_SELECTION));
}
// This can be null if display list building initiated in the middle
// of the table, which can happen with background-clip:text and
// -moz-element.
nsDisplayTableBackgroundSet* backgrounds =
aBuilder->GetTableBackgroundSet();
if (backgrounds) {
// Compute bgRect relative to reference frame, but using the
// normal (without position:relative offsets) positions for the
// cell, row and row group.
bgRect = GetRectRelativeToSelf() + GetNormalPosition();
nsTableRowFrame* row = GetTableRowFrame();
bgRect += row->GetNormalPosition();
nsTableRowGroupFrame* rowGroup = row->GetTableRowGroupFrame();
bgRect += rowGroup->GetNormalPosition();
bgRect += backgrounds->TableToReferenceFrame();
// Create backgrounds items as needed for the column and column
// group that this cell occupies.
nsTableColFrame* col = backgrounds->GetColForIndex(ColIndex());
nsTableColGroupFrame* colGroup = col->GetTableColGroupFrame();
Maybe<nsDisplayListBuilder::AutoBuildingDisplayList> buildingForColGroup;
nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
aBuilder, colGroup, bgRect, backgrounds->ColGroupBackgrounds(), false,
nullptr, colGroup->GetRect() + backgrounds->TableToReferenceFrame(),
this, &buildingForColGroup);
Maybe<nsDisplayListBuilder::AutoBuildingDisplayList> buildingForCol;
nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
aBuilder, col, bgRect, backgrounds->ColBackgrounds(), false, nullptr,
col->GetRect() + colGroup->GetPosition() +
backgrounds->TableToReferenceFrame(),
this, &buildingForCol);
}
}
// 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;
pushTableItem.Push(aBuilder, nullptr);
nsIFrame* kid = mFrames.FirstChild();
NS_ASSERTION(kid && !kid->GetNextSibling(), "Table cells should have just one child");
// The child's background will go in our BorderBackground() list.