зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1409114
- Part 2: Get rid of generic table painting code, and handle each class separately. r=dbaron
Most of the code in DisplayGenericTablePart was all within a per-class if statement, so it doesn't add much value, and makes the control flow harder to understand. Differential Revision: https://phabricator.services.mozilla.com/D29273 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
a40b05d67d
Коммит
1b955945aa
|
@ -2433,7 +2433,9 @@ void nsFrame::DisplayBorderBackgroundOutline(nsDisplayListBuilder* aBuilder,
|
|||
|
||||
// If there's a themed background, we should not create a border item.
|
||||
// It won't be rendered.
|
||||
if (!bgIsThemed && StyleBorder()->HasBorder()) {
|
||||
// Don't paint borders for tables here, since they paint them in a different
|
||||
// order.
|
||||
if (!bgIsThemed && StyleBorder()->HasBorder() && !IsTableFrame()) {
|
||||
aLists.BorderBackground()->AppendNewToTop<nsDisplayBorder>(aBuilder, this);
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,53 @@ void nsTableColFrame::Reflow(nsPresContext* aPresContext,
|
|||
|
||||
void nsTableColFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
const nsDisplayListSet& aLists) {
|
||||
nsTableFrame::DisplayGenericTablePart(aBuilder, this, aLists);
|
||||
if (IsVisibleForPainting()) {
|
||||
// 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<nsDisplayBoxShadowOuter>(
|
||||
aBuilder, this);
|
||||
}
|
||||
}
|
||||
|
||||
// Compute background rect by iterating all cell frame.
|
||||
AutoTArray<uint32_t, 1> colIdx;
|
||||
colIdx.AppendElement(GetColIndex());
|
||||
|
||||
nsTableFrame* table = GetTableFrame();
|
||||
nsTableFrame::RowGroupArray rowGroups;
|
||||
table->OrderRowGroups(rowGroups);
|
||||
for (nsTableRowGroupFrame* rowGroup : rowGroups) {
|
||||
auto offset = rowGroup->GetNormalPosition() - GetNormalPosition() -
|
||||
GetTableColGroupFrame()->GetNormalPosition();
|
||||
if (!aBuilder->GetDirtyRect().Intersects(
|
||||
nsRect(offset, rowGroup->GetSize()))) {
|
||||
continue;
|
||||
}
|
||||
rowGroup->PaintCellBackgroundsForColumns(this, aBuilder, aLists, colIdx,
|
||||
offset);
|
||||
}
|
||||
|
||||
if (IsVisibleForPainting()) {
|
||||
// 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<nsDisplayBoxShadowInner>(
|
||||
aBuilder, this);
|
||||
}
|
||||
}
|
||||
|
||||
DisplayOutline(aBuilder, aLists);
|
||||
|
||||
for (nsIFrame* kid : PrincipalChildList()) {
|
||||
BuildDisplayListForChild(aBuilder, kid, aLists);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t nsTableColFrame::GetSpan() { return StyleTable()->mSpan; }
|
||||
|
|
|
@ -352,7 +352,59 @@ void nsTableColGroupFrame::Reflow(nsPresContext* aPresContext,
|
|||
|
||||
void nsTableColGroupFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
const nsDisplayListSet& aLists) {
|
||||
nsTableFrame::DisplayGenericTablePart(aBuilder, this, aLists);
|
||||
if (IsVisibleForPainting()) {
|
||||
// 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<nsDisplayBoxShadowOuter>(
|
||||
aBuilder, this);
|
||||
}
|
||||
}
|
||||
|
||||
// Collecting column index.
|
||||
AutoTArray<uint32_t, 1> colIdx;
|
||||
for (nsTableColFrame* col = GetFirstColumn(); col; col = col->GetNextCol()) {
|
||||
MOZ_ASSERT(colIdx.IsEmpty() || static_cast<uint32_t>(col->GetColIndex()) >
|
||||
colIdx.LastElement());
|
||||
colIdx.AppendElement(col->GetColIndex());
|
||||
}
|
||||
|
||||
if (!colIdx.IsEmpty()) {
|
||||
// We have some actual cells that live inside this rowgroup.
|
||||
nsTableFrame* table = GetTableFrame();
|
||||
nsTableFrame::RowGroupArray rowGroups;
|
||||
table->OrderRowGroups(rowGroups);
|
||||
for (nsTableRowGroupFrame* rowGroup : rowGroups) {
|
||||
auto offset = rowGroup->GetNormalPosition() - GetNormalPosition();
|
||||
if (!aBuilder->GetDirtyRect().Intersects(
|
||||
nsRect(offset, rowGroup->GetSize()))) {
|
||||
continue;
|
||||
}
|
||||
rowGroup->PaintCellBackgroundsForColumns(this, aBuilder, aLists, colIdx,
|
||||
offset);
|
||||
}
|
||||
}
|
||||
|
||||
if (IsVisibleForPainting()) {
|
||||
// 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<nsDisplayBoxShadowInner>(
|
||||
aBuilder, this);
|
||||
}
|
||||
}
|
||||
|
||||
DisplayOutline(aBuilder, aLists);
|
||||
|
||||
for (nsIFrame* kid : PrincipalChildList()) {
|
||||
BuildDisplayListForChild(aBuilder, kid, aLists);
|
||||
}
|
||||
}
|
||||
|
||||
nsTableColFrame* nsTableColGroupFrame::GetFirstColumn() {
|
||||
|
|
|
@ -1215,106 +1215,6 @@ bool nsDisplayTableBorderCollapse::CreateWebRenderCommands(
|
|||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void nsTableFrame::GenericTraversal(nsDisplayListBuilder* aBuilder,
|
||||
nsFrame* aFrame,
|
||||
const nsDisplayListSet& aLists) {
|
||||
// This is similar to what
|
||||
// nsContainerFrame::BuildDisplayListForNonBlockChildren does, except that we
|
||||
// allow the children's background and borders to go in our BorderBackground
|
||||
// list. This doesn't really affect background painting --- the children won't
|
||||
// actually draw their own backgrounds because the nsTableFrame already drew
|
||||
// them, unless a child has its own stacking context, in which case the child
|
||||
// won't use its passed-in BorderBackground list anyway. It does affect cell
|
||||
// borders though; this lets us get cell borders into the nsTableFrame's
|
||||
// BorderBackground list.
|
||||
for (nsIFrame* kid : aFrame->GetChildList(kColGroupList)) {
|
||||
aFrame->BuildDisplayListForChild(aBuilder, kid, aLists);
|
||||
}
|
||||
|
||||
for (nsIFrame* kid : aFrame->PrincipalChildList()) {
|
||||
aFrame->BuildDisplayListForChild(aBuilder, kid, aLists);
|
||||
}
|
||||
}
|
||||
|
||||
static void PaintRowBackground(nsTableRowFrame* aRow, nsIFrame* aFrame,
|
||||
nsDisplayListBuilder* aBuilder,
|
||||
const nsDisplayListSet& aLists,
|
||||
const nsPoint& aOffset = nsPoint()) {
|
||||
// Compute background rect by iterating all cell frame.
|
||||
for (nsTableCellFrame* cell = aRow->GetFirstCell(); cell;
|
||||
cell = cell->GetNextCell()) {
|
||||
if (!cell->ShouldPaintBackground(aBuilder)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto cellRect =
|
||||
cell->GetRectRelativeToSelf() + cell->GetNormalPosition() + aOffset;
|
||||
if (!aBuilder->GetDirtyRect().Intersects(cellRect)) {
|
||||
continue;
|
||||
}
|
||||
nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
|
||||
aBuilder, aFrame, cellRect, aLists.BorderBackground(), true, nullptr,
|
||||
aFrame->GetRectRelativeToSelf(), cell);
|
||||
}
|
||||
}
|
||||
|
||||
static void PaintRowGroupBackground(nsTableRowGroupFrame* aRowGroup,
|
||||
nsIFrame* aFrame,
|
||||
nsDisplayListBuilder* aBuilder,
|
||||
const nsDisplayListSet& aLists) {
|
||||
for (nsTableRowFrame* row = aRowGroup->GetFirstRow(); row;
|
||||
row = row->GetNextRow()) {
|
||||
if (!aBuilder->GetDirtyRect().Intersects(
|
||||
nsRect(row->GetNormalPosition(), row->GetSize()))) {
|
||||
continue;
|
||||
}
|
||||
PaintRowBackground(row, aFrame, aBuilder, aLists, row->GetNormalPosition());
|
||||
}
|
||||
}
|
||||
|
||||
static void PaintRowGroupBackgroundByColIdx(nsTableRowGroupFrame* aRowGroup,
|
||||
nsIFrame* aFrame,
|
||||
nsDisplayListBuilder* aBuilder,
|
||||
const nsDisplayListSet& aLists,
|
||||
const nsTArray<uint32_t>& aColIdx,
|
||||
const nsPoint& aOffset) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(!aColIdx.IsEmpty(),
|
||||
"Must be painting backgrounds for something");
|
||||
|
||||
for (nsTableRowFrame* row = aRowGroup->GetFirstRow(); row;
|
||||
row = row->GetNextRow()) {
|
||||
auto rowPos = row->GetNormalPosition() + aOffset;
|
||||
if (!aBuilder->GetDirtyRect().Intersects(nsRect(rowPos, row->GetSize()))) {
|
||||
continue;
|
||||
}
|
||||
for (nsTableCellFrame* cell = row->GetFirstCell(); cell;
|
||||
cell = cell->GetNextCell()) {
|
||||
uint32_t curColIdx = cell->ColIndex();
|
||||
if (!aColIdx.ContainsSorted(curColIdx)) {
|
||||
if (curColIdx > aColIdx.LastElement()) {
|
||||
// We can just stop looking at this row.
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!cell->ShouldPaintBackground(aBuilder)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto cellPos = cell->GetNormalPosition() + rowPos;
|
||||
auto cellRect = nsRect(cellPos, cell->GetSize());
|
||||
if (!aBuilder->GetDirtyRect().Intersects(cellRect)) {
|
||||
continue;
|
||||
}
|
||||
nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
|
||||
aBuilder, aFrame, cellRect, aLists.BorderBackground(), false, nullptr,
|
||||
aFrame->GetRectRelativeToSelf(), cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool FrameHasBorder(nsIFrame* f) {
|
||||
if (!f->StyleVisibility()->IsVisible()) {
|
||||
return false;
|
||||
|
@ -1384,130 +1284,46 @@ void nsTableFrame::CalcHasBCBorders() {
|
|||
SetHasBCBorders(false);
|
||||
}
|
||||
|
||||
/* static */
|
||||
void nsTableFrame::DisplayGenericTablePart(
|
||||
nsDisplayListBuilder* aBuilder, nsFrame* aFrame,
|
||||
const nsDisplayListSet& aLists,
|
||||
DisplayGenericTablePartTraversal aTraversal) {
|
||||
bool isVisible = aFrame->IsVisibleForPainting();
|
||||
bool isTable = aFrame->IsTableFrame();
|
||||
|
||||
if (isVisible) {
|
||||
// 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 (!aFrame->StyleEffects()->mBoxShadow.IsEmpty()) {
|
||||
aLists.BorderBackground()->AppendNewToTop<nsDisplayBoxShadowOuter>(
|
||||
aBuilder, aFrame);
|
||||
}
|
||||
}
|
||||
|
||||
// Background visibility for rows, rowgroups, columns, colgroups depends on
|
||||
// the visibility of the _cell_, not of the row/col(group).
|
||||
if (aFrame->IsTableRowGroupFrame()) {
|
||||
nsTableRowGroupFrame* rowGroup = static_cast<nsTableRowGroupFrame*>(aFrame);
|
||||
PaintRowGroupBackground(rowGroup, aFrame, aBuilder, aLists);
|
||||
} else if (aFrame->IsTableRowFrame()) {
|
||||
nsTableRowFrame* row = static_cast<nsTableRowFrame*>(aFrame);
|
||||
PaintRowBackground(row, aFrame, aBuilder, aLists);
|
||||
} else if (aFrame->IsTableColGroupFrame()) {
|
||||
// Compute background rect by iterating all cell frame.
|
||||
nsTableColGroupFrame* colGroup = static_cast<nsTableColGroupFrame*>(aFrame);
|
||||
// Collecting column index.
|
||||
AutoTArray<uint32_t, 1> colIdx;
|
||||
for (nsTableColFrame* col = colGroup->GetFirstColumn(); col;
|
||||
col = col->GetNextCol()) {
|
||||
MOZ_ASSERT(colIdx.IsEmpty() || static_cast<uint32_t>(col->GetColIndex()) >
|
||||
colIdx.LastElement());
|
||||
colIdx.AppendElement(col->GetColIndex());
|
||||
}
|
||||
|
||||
if (!colIdx.IsEmpty()) {
|
||||
// We have some actual cells that live inside this rowgroup.
|
||||
nsTableFrame* table = colGroup->GetTableFrame();
|
||||
RowGroupArray rowGroups;
|
||||
table->OrderRowGroups(rowGroups);
|
||||
for (nsTableRowGroupFrame* rowGroup : rowGroups) {
|
||||
auto offset =
|
||||
rowGroup->GetNormalPosition() - colGroup->GetNormalPosition();
|
||||
if (!aBuilder->GetDirtyRect().Intersects(
|
||||
nsRect(offset, rowGroup->GetSize()))) {
|
||||
continue;
|
||||
}
|
||||
PaintRowGroupBackgroundByColIdx(rowGroup, aFrame, aBuilder, aLists,
|
||||
colIdx, offset);
|
||||
}
|
||||
}
|
||||
} else if (aFrame->IsTableColFrame()) {
|
||||
// Compute background rect by iterating all cell frame.
|
||||
nsTableColFrame* col = static_cast<nsTableColFrame*>(aFrame);
|
||||
AutoTArray<uint32_t, 1> colIdx;
|
||||
colIdx.AppendElement(col->GetColIndex());
|
||||
|
||||
nsTableFrame* table = col->GetTableFrame();
|
||||
RowGroupArray rowGroups;
|
||||
table->OrderRowGroups(rowGroups);
|
||||
for (nsTableRowGroupFrame* rowGroup : rowGroups) {
|
||||
auto offset = rowGroup->GetNormalPosition() - col->GetNormalPosition() -
|
||||
col->GetTableColGroupFrame()->GetNormalPosition();
|
||||
if (!aBuilder->GetDirtyRect().Intersects(
|
||||
nsRect(offset, rowGroup->GetSize()))) {
|
||||
continue;
|
||||
}
|
||||
PaintRowGroupBackgroundByColIdx(rowGroup, aFrame, aBuilder, aLists,
|
||||
colIdx, offset);
|
||||
}
|
||||
} else if (isVisible) {
|
||||
nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
|
||||
aBuilder, aFrame, aFrame->GetRectRelativeToSelf(),
|
||||
aLists.BorderBackground());
|
||||
}
|
||||
|
||||
if (isVisible) {
|
||||
// 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 (!aFrame->StyleEffects()->mBoxShadow.IsEmpty()) {
|
||||
aLists.BorderBackground()->AppendNewToTop<nsDisplayBoxShadowInner>(
|
||||
aBuilder, aFrame);
|
||||
}
|
||||
}
|
||||
|
||||
aFrame->DisplayOutline(aBuilder, aLists);
|
||||
|
||||
aTraversal(aBuilder, aFrame, aLists);
|
||||
|
||||
if (isVisible) {
|
||||
if (isTable) {
|
||||
nsTableFrame* table = static_cast<nsTableFrame*>(aFrame);
|
||||
// In the collapsed border model, overlay all collapsed borders.
|
||||
if (table->IsBorderCollapse()) {
|
||||
if (table->HasBCBorders()) {
|
||||
aLists.BorderBackground()
|
||||
->AppendNewToTop<nsDisplayTableBorderCollapse>(aBuilder, table);
|
||||
}
|
||||
} else {
|
||||
const nsStyleBorder* borderStyle = aFrame->StyleBorder();
|
||||
if (borderStyle->HasBorder()) {
|
||||
aLists.BorderBackground()->AppendNewToTop<nsDisplayBorder>(aBuilder,
|
||||
table);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// table paint code is concerned primarily with borders and bg color
|
||||
// SEC: TODO: adjust the rect for captions
|
||||
void nsTableFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
const nsDisplayListSet& aLists) {
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP_COLOR("nsTableFrame", NS_RGB(255, 128, 255));
|
||||
|
||||
DisplayGenericTablePart(aBuilder, this, aLists);
|
||||
DisplayBorderBackgroundOutline(aBuilder, aLists);
|
||||
|
||||
// This is similar to what
|
||||
// nsContainerFrame::BuildDisplayListForNonBlockChildren does, except that we
|
||||
// allow the children's background and borders to go in our BorderBackground
|
||||
// list. This doesn't really affect background painting --- the children won't
|
||||
// actually draw their own backgrounds because the nsTableFrame already drew
|
||||
// them, unless a child has its own stacking context, in which case the child
|
||||
// won't use its passed-in BorderBackground list anyway. It does affect cell
|
||||
// borders though; this lets us get cell borders into the nsTableFrame's
|
||||
// BorderBackground list.
|
||||
for (nsIFrame* kid : GetChildList(kColGroupList)) {
|
||||
BuildDisplayListForChild(aBuilder, kid, aLists);
|
||||
}
|
||||
|
||||
for (nsIFrame* kid : PrincipalChildList()) {
|
||||
BuildDisplayListForChild(aBuilder, kid, aLists);
|
||||
}
|
||||
|
||||
if (IsVisibleForPainting()) {
|
||||
// In the collapsed border model, overlay all collapsed borders.
|
||||
if (IsBorderCollapse()) {
|
||||
if (HasBCBorders()) {
|
||||
aLists.BorderBackground()->AppendNewToTop<nsDisplayTableBorderCollapse>(
|
||||
aBuilder, this);
|
||||
}
|
||||
} else {
|
||||
const nsStyleBorder* borderStyle = StyleBorder();
|
||||
if (borderStyle->HasBorder()) {
|
||||
aLists.BorderBackground()->AppendNewToTop<nsDisplayBorder>(aBuilder,
|
||||
this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsMargin nsTableFrame::GetDeflationForBackground(
|
||||
|
|
|
@ -186,28 +186,6 @@ class nsTableFrame : public nsContainerFrame {
|
|||
nsIFrame* aSourceFrame,
|
||||
bool* aDidPassThrough);
|
||||
|
||||
typedef void (*DisplayGenericTablePartTraversal)(
|
||||
nsDisplayListBuilder* aBuilder, nsFrame* aFrame,
|
||||
const nsDisplayListSet& aLists);
|
||||
static void GenericTraversal(nsDisplayListBuilder* aBuilder, nsFrame* aFrame,
|
||||
const nsDisplayListSet& aLists);
|
||||
|
||||
/**
|
||||
* Helper method to handle display common to table frames, rowgroup frames
|
||||
* and row frames. It creates a background display item for handling events
|
||||
* if necessary, an outline display item if necessary, and displays
|
||||
* all the the frame's children.
|
||||
* @param aDisplayItem the display item created for this part, or null
|
||||
* if this part's border/background painting is delegated to an ancestor
|
||||
* @param aTraversal a function that gets called to traverse the table
|
||||
* part's child frames and add their display list items to a
|
||||
* display list set.
|
||||
*/
|
||||
static void DisplayGenericTablePart(
|
||||
nsDisplayListBuilder* aBuilder, nsFrame* aFrame,
|
||||
const nsDisplayListSet& aLists,
|
||||
DisplayGenericTablePartTraversal aTraversal = GenericTraversal);
|
||||
|
||||
// Return the closest sibling of aPriorChildFrame (including aPriroChildFrame)
|
||||
// of type aChildType.
|
||||
static nsIFrame* GetFrameAtOrBefore(nsIFrame* aParentFrame,
|
||||
|
|
|
@ -532,9 +532,60 @@ nscoord 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.
|
||||
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;
|
||||
}
|
||||
nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
|
||||
aBuilder, aFrame, cellRect, aLists.BorderBackground(), true, nullptr,
|
||||
aFrame->GetRectRelativeToSelf(), cell);
|
||||
}
|
||||
}
|
||||
|
||||
void nsTableRowFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
const nsDisplayListSet& aLists) {
|
||||
nsTableFrame::DisplayGenericTablePart(aBuilder, this, aLists);
|
||||
if (IsVisibleForPainting()) {
|
||||
// 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<nsDisplayBoxShadowOuter>(
|
||||
aBuilder, this);
|
||||
}
|
||||
}
|
||||
|
||||
PaintCellBackgroundsForFrame(this, aBuilder, aLists);
|
||||
|
||||
if (IsVisibleForPainting()) {
|
||||
// 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<nsDisplayBoxShadowInner>(
|
||||
aBuilder, this);
|
||||
}
|
||||
}
|
||||
|
||||
DisplayOutline(aBuilder, aLists);
|
||||
|
||||
for (nsIFrame* kid : PrincipalChildList()) {
|
||||
BuildDisplayListForChild(aBuilder, kid, aLists);
|
||||
}
|
||||
}
|
||||
|
||||
nsIFrame::LogicalSides nsTableRowFrame::GetLogicalSkipSides(
|
||||
|
|
|
@ -76,6 +76,11 @@ class nsTableRowFrame : public nsContainerFrame {
|
|||
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
const nsDisplayListSet& aLists) override;
|
||||
|
||||
void PaintCellBackgroundsForFrame(nsIFrame* aFrame,
|
||||
nsDisplayListBuilder* aBuilder,
|
||||
const nsDisplayListSet& aLists,
|
||||
const nsPoint& aOffset = nsPoint());
|
||||
|
||||
// Implemented in nsTableCellFrame.h, because it needs to know about the
|
||||
// nsTableCellFrame class, but we can't include nsTableCellFrame.h here.
|
||||
inline nsTableCellFrame* GetFirstCell() const;
|
||||
|
|
|
@ -236,9 +236,83 @@ static void DisplayRows(nsDisplayListBuilder* aBuilder, nsFrame* aFrame,
|
|||
}
|
||||
}
|
||||
|
||||
void nsTableRowGroupFrame::PaintCellBackgroundsForColumns(
|
||||
nsIFrame* aFrame, nsDisplayListBuilder* aBuilder,
|
||||
const nsDisplayListSet& aLists, const nsTArray<uint32_t>& aColIdx,
|
||||
const nsPoint& aOffset) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(!aColIdx.IsEmpty(),
|
||||
"Must be painting backgrounds for something");
|
||||
|
||||
for (nsTableRowFrame* row = GetFirstRow(); row; row = row->GetNextRow()) {
|
||||
auto rowPos = row->GetNormalPosition() + aOffset;
|
||||
if (!aBuilder->GetDirtyRect().Intersects(nsRect(rowPos, row->GetSize()))) {
|
||||
continue;
|
||||
}
|
||||
for (nsTableCellFrame* cell = row->GetFirstCell(); cell;
|
||||
cell = cell->GetNextCell()) {
|
||||
uint32_t curColIdx = cell->ColIndex();
|
||||
if (!aColIdx.ContainsSorted(curColIdx)) {
|
||||
if (curColIdx > aColIdx.LastElement()) {
|
||||
// We can just stop looking at this row.
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!cell->ShouldPaintBackground(aBuilder)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto cellPos = cell->GetNormalPosition() + rowPos;
|
||||
auto cellRect = nsRect(cellPos, cell->GetSize());
|
||||
if (!aBuilder->GetDirtyRect().Intersects(cellRect)) {
|
||||
continue;
|
||||
}
|
||||
nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
|
||||
aBuilder, aFrame, cellRect, aLists.BorderBackground(), false, nullptr,
|
||||
aFrame->GetRectRelativeToSelf(), cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void nsTableRowGroupFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
const nsDisplayListSet& aLists) {
|
||||
nsTableFrame::DisplayGenericTablePart(aBuilder, this, aLists, DisplayRows);
|
||||
if (IsVisibleForPainting()) {
|
||||
// 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<nsDisplayBoxShadowOuter>(
|
||||
aBuilder, this);
|
||||
}
|
||||
}
|
||||
|
||||
for (nsTableRowFrame* row = GetFirstRow(); row; row = row->GetNextRow()) {
|
||||
if (!aBuilder->GetDirtyRect().Intersects(
|
||||
nsRect(row->GetNormalPosition(), row->GetSize()))) {
|
||||
continue;
|
||||
}
|
||||
row->PaintCellBackgroundsForFrame(this, aBuilder, aLists,
|
||||
row->GetNormalPosition());
|
||||
}
|
||||
|
||||
if (IsVisibleForPainting()) {
|
||||
// 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<nsDisplayBoxShadowInner>(
|
||||
aBuilder, this);
|
||||
}
|
||||
}
|
||||
|
||||
DisplayOutline(aBuilder, aLists);
|
||||
|
||||
DisplayRows(aBuilder, this, aLists);
|
||||
}
|
||||
|
||||
nsIFrame::LogicalSides nsTableRowGroupFrame::GetLogicalSkipSides(
|
||||
|
|
|
@ -76,6 +76,12 @@ class nsTableRowGroupFrame final : public nsContainerFrame,
|
|||
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
const nsDisplayListSet& aLists) override;
|
||||
|
||||
void PaintCellBackgroundsForColumns(nsIFrame* aFrame,
|
||||
nsDisplayListBuilder* aBuilder,
|
||||
const nsDisplayListSet& aLists,
|
||||
const nsTArray<uint32_t>& aColIdx,
|
||||
const nsPoint& aOffset);
|
||||
|
||||
/**
|
||||
* Calls Reflow for all of its child rows.
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче