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

@ -549,11 +549,66 @@ nsTableRowFrame::CalcBSize(const ReflowInput& aReflowInput)
return GetInitialBSize();
}
void nsTableRowFrame::PaintCellBackgroundsForFrame(
nsIFrame* aFrame, nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists, const nsPoint& aOffset) {
// Compute background rect by iterating all cell frame.
const nsPoint toReferenceFrame = aBuilder->ToReferenceFrame(aFrame);
for (nsTableCellFrame* cell = GetFirstCell(); cell;
cell = cell->GetNextCell()) {
if (!cell->ShouldPaintBackground(aBuilder)) {
continue;
}
auto cellRect =
cell->GetRectRelativeToSelf() + cell->GetNormalPosition() + aOffset;
if (!aBuilder->GetDirtyRect().Intersects(cellRect)) {
continue;
}
cellRect += toReferenceFrame;
nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
aBuilder, aFrame, cellRect, aLists.BorderBackground(), true, nullptr,
aFrame->GetRectRelativeToSelf() + toReferenceFrame, cell);
}
}
void
nsTableRowFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists)
{
nsTableFrame::DisplayGenericTablePart(aBuilder, this, aLists);
if (IsVisibleForPainting(aBuilder)) {
// XXXbz should box-shadow for rows/rowgroups/columns/colgroups get painted
// just because we're visible? Or should it depend on the cell visibility
// when we're not the whole table?
// Paint the outset box-shadows for the table frames
if (StyleEffects()->mBoxShadow) {
aLists.BorderBackground()->AppendNewToTop(
new (aBuilder) nsDisplayBoxShadowOuter
(aBuilder, this));
}
}
PaintCellBackgroundsForFrame(this, aBuilder, aLists);
if (IsVisibleForPainting(aBuilder)) {
// XXXbz should box-shadow for rows/rowgroups/columns/colgroups get painted
// just because we're visible? Or should it depend on the cell visibility
// when we're not the whole table?
// Paint the inset box-shadows for the table frames
if (StyleEffects()->mBoxShadow) {
aLists.BorderBackground()->AppendNewToTop(
new (aBuilder) nsDisplayBoxShadowInner
(aBuilder, this));
}
}
DisplayOutline(aBuilder, aLists);
for (nsIFrame* kid : PrincipalChildList()) {
BuildDisplayListForChild(aBuilder, kid, aLists);
}
}
nsIFrame::LogicalSides