Bug 1735265 - Part 1: Set clip on background items for table cols and colgroups, when the table cell has captured clip r=mstange

Differential Revision: https://phabricator.services.mozilla.com/D129681
This commit is contained in:
Miko Mynttinen
2022-03-22 18:40:51 +00:00
parent 7e0c5884e8
commit 5e2929ac64
3 changed files with 31 additions and 0 deletions

View File

@@ -1093,6 +1093,25 @@ void nsTableCellFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
bgRect += backgrounds->TableToReferenceFrame();
DisplayListClipState::AutoSaveRestore clipState(aBuilder);
nsDisplayListBuilder::AutoCurrentActiveScrolledRootSetter asrSetter(
aBuilder);
if (IsStackingContext()) {
// The col/colgroup items we create below will be inserted directly into the
// BorderBackgrounds list of the table frame. That means that they'll be moved
// *outside* of any wrapper items from this table cell, and will not participate in
// this table cell's opacity / transform / filter / mask effects.
// If this cell is a stacking context, then we may have one or more of those
// wrapper items, and one of them may have captured a clip. In order to ensure
// correct clipping and scrolling of the col/colgroup items, restore the clip and ASR
// that we observed when we entered the table frame.
// If this cell is a stacking context but doesn't have any clip capturing wrapper items,
// then we'll double-apply the clip. That's ok.
clipState.SetClipChainForContainingBlockDescendants(
backgrounds->GetTableClipChain());
asrSetter.SetCurrentActiveScrolledRoot(backgrounds->GetTableASR());
}
// Create backgrounds items as needed for the column and column
// group that this cell occupies.
nsTableColFrame* col = backgrounds->GetColForIndex(ColIndex());

View File

@@ -7528,6 +7528,9 @@ nsDisplayTableBackgroundSet::nsDisplayTableBackgroundSet(
mBuilder->FindReferenceFrameFor(aTable, &mToReferenceFrame);
MOZ_ASSERT(nsLayoutUtils::FindNearestCommonAncestorFrame(reference, aTable));
mDirtyRect = mBuilder->GetDirtyRect();
mCombinedTableClipChain =
mBuilder->ClipState().GetCurrentCombinedClipChain(aBuilder);
mTableASR = mBuilder->CurrentActiveScrolledRoot();
}
// A display item that draws all collapsed borders for a table.

View File

@@ -95,6 +95,12 @@ class nsDisplayTableBackgroundSet {
const nsRect& GetDirtyRect() { return mDirtyRect; }
const DisplayItemClipChain* GetTableClipChain() {
return mCombinedTableClipChain;
}
const ActiveScrolledRoot* GetTableASR() { return mTableASR; }
private:
// This class is only used on stack, so we don't have to worry about leaking
// it. Don't let us be heap-allocated!
@@ -110,6 +116,9 @@ class nsDisplayTableBackgroundSet {
nsTArray<nsTableColFrame*> mColumns;
nsPoint mToReferenceFrame;
nsRect mDirtyRect;
const DisplayItemClipChain* mCombinedTableClipChain;
const ActiveScrolledRoot* mTableASR;
};
} // namespace mozilla