From 157cd64a8efd0d9ed7a39004aafdb1e1e5e4c338 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Thu, 30 Apr 2020 21:45:28 +0000 Subject: Issue #80 - De-unify layout/tables --- layout/tables/FixedTableLayoutStrategy.cpp | 4 ++++ layout/tables/SpanningCellSorter.cpp | 2 ++ layout/tables/moz.build | 2 +- layout/tables/nsTableFrame.cpp | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) (limited to 'layout/tables') diff --git a/layout/tables/FixedTableLayoutStrategy.cpp b/layout/tables/FixedTableLayoutStrategy.cpp index 427765795..d69946a33 100644 --- a/layout/tables/FixedTableLayoutStrategy.cpp +++ b/layout/tables/FixedTableLayoutStrategy.cpp @@ -15,6 +15,10 @@ #include "nsTableCellFrame.h" #include +#include "mozilla/WritingModes.h" + +using namespace mozilla; + FixedTableLayoutStrategy::FixedTableLayoutStrategy(nsTableFrame *aTableFrame) : nsITableLayoutStrategy(nsITableLayoutStrategy::Fixed) , mTableFrame(aTableFrame) diff --git a/layout/tables/SpanningCellSorter.cpp b/layout/tables/SpanningCellSorter.cpp index c67d784bb..686b02d89 100644 --- a/layout/tables/SpanningCellSorter.cpp +++ b/layout/tables/SpanningCellSorter.cpp @@ -12,6 +12,8 @@ #include "nsQuickSort.h" #include "nsIPresShell.h" +using mozilla::fallible; + //#define DEBUG_SPANNING_CELL_SORTER SpanningCellSorter::SpanningCellSorter() diff --git a/layout/tables/moz.build b/layout/tables/moz.build index e28e21ee0..554ffebec 100644 --- a/layout/tables/moz.build +++ b/layout/tables/moz.build @@ -13,7 +13,7 @@ EXPORTS += [ 'nsITableCellLayout.h', ] -UNIFIED_SOURCES += [ +SOURCES += [ 'BasicTableLayoutStrategy.cpp', 'FixedTableLayoutStrategy.cpp', 'nsCellMap.cpp', diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index e5a48139a..648fa7ddf 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -41,6 +41,7 @@ #include "nsCSSFrameConstructor.h" #include "mozilla/StyleSetHandle.h" #include "mozilla/StyleSetHandleInlines.h" +#include "mozilla/gfx/Helpers.h" #include "nsDisplayList.h" #include "nsIScrollableFrame.h" #include "nsCSSProps.h" @@ -48,6 +49,7 @@ #include using namespace mozilla; +using namespace mozilla::gfx; using namespace mozilla::image; using namespace mozilla::layout; -- cgit v1.2.3 From 71137783ac6927bd0dc02fce1d6e61e6ec027753 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Fri, 8 May 2020 15:20:01 +0300 Subject: Issue #1355 - Store the dirty rect on the display list builder rather than passing it as a parameter to BuildDisplayList Also fix build bustage for De-unified layout/xul in nsRootBoxFrame.cpp --- layout/tables/nsTableCellFrame.cpp | 3 +-- layout/tables/nsTableCellFrame.h | 1 - layout/tables/nsTableColFrame.cpp | 3 +-- layout/tables/nsTableColFrame.h | 1 - layout/tables/nsTableColGroupFrame.cpp | 3 +-- layout/tables/nsTableColGroupFrame.h | 1 - layout/tables/nsTableFrame.cpp | 40 +++++++++++++++------------------- layout/tables/nsTableFrame.h | 6 ++--- layout/tables/nsTableRowFrame.cpp | 3 +-- layout/tables/nsTableRowFrame.h | 1 - layout/tables/nsTableRowGroupFrame.cpp | 13 +++++------ layout/tables/nsTableRowGroupFrame.h | 1 - layout/tables/nsTableWrapperFrame.cpp | 11 ++++------ layout/tables/nsTableWrapperFrame.h | 2 -- 14 files changed, 34 insertions(+), 55 deletions(-) (limited to 'layout/tables') diff --git a/layout/tables/nsTableCellFrame.cpp b/layout/tables/nsTableCellFrame.cpp index 8b811df1e..64e7d2cfe 100644 --- a/layout/tables/nsTableCellFrame.cpp +++ b/layout/tables/nsTableCellFrame.cpp @@ -450,7 +450,6 @@ nsTableCellFrame::ShouldPaintBackground(nsDisplayListBuilder* aBuilder) void nsTableCellFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists) { DO_GLOBAL_REFLOW_COUNT_DSP("nsTableCellFrame"); @@ -506,7 +505,7 @@ nsTableCellFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, // because that/ would put the child's background in the Content() list // which isn't right (e.g., would end up on top of our child floats for // event handling). - BuildDisplayListForChild(aBuilder, kid, aDirtyRect, aLists); + BuildDisplayListForChild(aBuilder, kid, aLists); } nsIFrame::LogicalSides diff --git a/layout/tables/nsTableCellFrame.h b/layout/tables/nsTableCellFrame.h index f626a45b0..a822e309d 100644 --- a/layout/tables/nsTableCellFrame.h +++ b/layout/tables/nsTableCellFrame.h @@ -104,7 +104,6 @@ public: virtual bool NeedsToObserve(const ReflowInput& aReflowInput) override; virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists) override; virtual nsresult ProcessBorders(nsTableFrame* aFrame, diff --git a/layout/tables/nsTableColFrame.cpp b/layout/tables/nsTableColFrame.cpp index 54b03522b..659f0fd35 100644 --- a/layout/tables/nsTableColFrame.cpp +++ b/layout/tables/nsTableColFrame.cpp @@ -110,10 +110,9 @@ nsTableColFrame::Reflow(nsPresContext* aPresContext, void nsTableColFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists) { - nsTableFrame::DisplayGenericTablePart(aBuilder, this, aDirtyRect, aLists); + nsTableFrame::DisplayGenericTablePart(aBuilder, this, aLists); } int32_t nsTableColFrame::GetSpan() diff --git a/layout/tables/nsTableColFrame.h b/layout/tables/nsTableColFrame.h index fb989061f..ed6a843b6 100644 --- a/layout/tables/nsTableColFrame.h +++ b/layout/tables/nsTableColFrame.h @@ -60,7 +60,6 @@ public: nsReflowStatus& aStatus) override; virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists) override; /** diff --git a/layout/tables/nsTableColGroupFrame.cpp b/layout/tables/nsTableColGroupFrame.cpp index 6ee7f0b24..732783428 100644 --- a/layout/tables/nsTableColGroupFrame.cpp +++ b/layout/tables/nsTableColGroupFrame.cpp @@ -385,10 +385,9 @@ nsTableColGroupFrame::Reflow(nsPresContext* aPresContext, void nsTableColGroupFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists) { - nsTableFrame::DisplayGenericTablePart(aBuilder, this, aDirtyRect, aLists); + nsTableFrame::DisplayGenericTablePart(aBuilder, this, aLists); } nsTableColFrame * nsTableColGroupFrame::GetFirstColumn() diff --git a/layout/tables/nsTableColGroupFrame.h b/layout/tables/nsTableColGroupFrame.h index b3dfb94e7..88ed67c2a 100644 --- a/layout/tables/nsTableColGroupFrame.h +++ b/layout/tables/nsTableColGroupFrame.h @@ -44,7 +44,6 @@ public: } virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists) override; /** A colgroup can be caused by three things: diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 648fa7ddf..99838f217 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -1165,7 +1165,7 @@ nsDisplayTableBorderCollapse::Paint(nsDisplayListBuilder* aBuilder, /* static */ void nsTableFrame::GenericTraversal(nsDisplayListBuilder* aBuilder, nsFrame* aFrame, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists) + const nsDisplayListSet& aLists) { // This is similar to what nsContainerFrame::BuildDisplayListForNonBlockChildren // does, except that we allow the children's background and borders to go @@ -1176,11 +1176,11 @@ nsTableFrame::GenericTraversal(nsDisplayListBuilder* aBuilder, nsFrame* aFrame, // 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, aDirtyRect, aLists); + aFrame->BuildDisplayListForChild(aBuilder, kid, aLists); } for (nsIFrame* kid : aFrame->PrincipalChildList()) { - aFrame->BuildDisplayListForChild(aBuilder, kid, aDirtyRect, aLists); + aFrame->BuildDisplayListForChild(aBuilder, kid, aLists); } } @@ -1189,7 +1189,6 @@ PaintRowBackground(nsTableRowFrame* aRow, nsIFrame* aFrame, nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists, - const nsRect& aDirtyRect, const nsPoint& aOffset = nsPoint()) { // Compute background rect by iterating over all cell frames. @@ -1199,7 +1198,7 @@ PaintRowBackground(nsTableRowFrame* aRow, } auto cellRect = cell->GetRectRelativeToSelf() + cell->GetNormalPosition() + aOffset; - if (!aDirtyRect.Intersects(cellRect)) { + if (!aBuilder->GetDirtyRect().Intersects(cellRect)) { continue; } nsDisplayBackgroundImage::AppendBackgroundItemsToTop(aBuilder, aFrame, cellRect, @@ -1214,14 +1213,14 @@ static void PaintRowGroupBackground(nsTableRowGroupFrame* aRowGroup, nsIFrame* aFrame, nsDisplayListBuilder* aBuilder, - const nsDisplayListSet& aLists, - const nsRect& aDirtyRect) + const nsDisplayListSet& aLists) { for (nsTableRowFrame* row = aRowGroup->GetFirstRow(); row; row = row->GetNextRow()) { - if (!aDirtyRect.Intersects(nsRect(row->GetNormalPosition(), row->GetSize()))) { + if (!aBuilder->GetDirtyRect().Intersects(nsRect(row->GetNormalPosition(), + row->GetSize()))) { continue; } - PaintRowBackground(row, aFrame, aBuilder, aLists, aDirtyRect, row->GetNormalPosition()); + PaintRowBackground(row, aFrame, aBuilder, aLists, row->GetNormalPosition()); } } @@ -1230,7 +1229,6 @@ PaintRowGroupBackgroundByColIdx(nsTableRowGroupFrame* aRowGroup, nsIFrame* aFrame, nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists, - const nsRect& aDirtyRect, const nsTArray& aColIdx, const nsPoint& aOffset) { @@ -1238,7 +1236,7 @@ PaintRowGroupBackgroundByColIdx(nsTableRowGroupFrame* aRowGroup, "Must be painting backgrounds for something"); for (nsTableRowFrame* row = aRowGroup->GetFirstRow(); row; row = row->GetNextRow()) { auto rowPos = row->GetNormalPosition() + aOffset; - if (!aDirtyRect.Intersects(nsRect(rowPos, row->GetSize()))) { + if (!aBuilder->GetDirtyRect().Intersects(nsRect(rowPos, row->GetSize()))) { continue; } for (nsTableCellFrame* cell = row->GetFirstCell(); cell; cell = cell->GetNextCell()) { @@ -1258,7 +1256,7 @@ PaintRowGroupBackgroundByColIdx(nsTableRowGroupFrame* aRowGroup, auto cellPos = cell->GetNormalPosition() + rowPos; auto cellRect = nsRect(cellPos, cell->GetSize()); - if (!aDirtyRect.Intersects(cellRect)) { + if (!aBuilder->GetDirtyRect().Intersects(cellRect)) { continue; } nsDisplayBackgroundImage::AppendBackgroundItemsToTop(aBuilder, aFrame, cellRect, @@ -1341,7 +1339,6 @@ void nsTableFrame::CalcHasBCBorders() /* static */ void nsTableFrame::DisplayGenericTablePart(nsDisplayListBuilder* aBuilder, nsFrame* aFrame, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists, DisplayGenericTablePartTraversal aTraversal) { @@ -1374,10 +1371,10 @@ nsTableFrame::DisplayGenericTablePart(nsDisplayListBuilder* aBuilder, // See spec at https://drafts.csswg.org/css-tables-3/#drawing-cell-backgrounds if (aFrame->GetType() == nsGkAtoms::tableRowGroupFrame) { nsTableRowGroupFrame* rowGroup = static_cast(aFrame); - PaintRowGroupBackground(rowGroup, aFrame, aBuilder, aLists, aDirtyRect); + PaintRowGroupBackground(rowGroup, aFrame, aBuilder, aLists); } else if (aFrame->GetType() == nsGkAtoms::tableRowFrame) { nsTableRowFrame* row = static_cast(aFrame); - PaintRowBackground(row, aFrame, aBuilder, aLists, aDirtyRect); + PaintRowBackground(row, aFrame, aBuilder, aLists); } else if (aFrame->GetType() == nsGkAtoms::tableColGroupFrame) { // Compute background rect by iterating all cell frame. nsTableColGroupFrame* colGroup = static_cast(aFrame); @@ -1396,10 +1393,10 @@ nsTableFrame::DisplayGenericTablePart(nsDisplayListBuilder* aBuilder, table->OrderRowGroups(rowGroups); for (nsTableRowGroupFrame* rowGroup : rowGroups) { auto offset = rowGroup->GetNormalPosition() - colGroup->GetNormalPosition(); - if (!aDirtyRect.Intersects(nsRect(offset, rowGroup->GetSize()))) { + if (!aBuilder->GetDirtyRect().Intersects(nsRect(offset, rowGroup->GetSize()))) { continue; } - PaintRowGroupBackgroundByColIdx(rowGroup, aFrame, aBuilder, aLists, aDirtyRect, colIdx, offset); + PaintRowGroupBackgroundByColIdx(rowGroup, aFrame, aBuilder, aLists, colIdx, offset); } } } else if (aFrame->GetType() == nsGkAtoms::tableColFrame) { @@ -1415,10 +1412,10 @@ nsTableFrame::DisplayGenericTablePart(nsDisplayListBuilder* aBuilder, auto offset = rowGroup->GetNormalPosition() - col->GetNormalPosition() - col->GetTableColGroupFrame()->GetNormalPosition(); - if (!aDirtyRect.Intersects(nsRect(offset, rowGroup->GetSize()))) { + if (!aBuilder->GetDirtyRect().Intersects(nsRect(offset, rowGroup->GetSize()))) { continue; } - PaintRowGroupBackgroundByColIdx(rowGroup, aFrame, aBuilder, aLists, aDirtyRect, colIdx, offset); + PaintRowGroupBackgroundByColIdx(rowGroup, aFrame, aBuilder, aLists, colIdx, offset); } } else if (isVisible) { nsDisplayBackgroundImage::AppendBackgroundItemsToTop(aBuilder, aFrame, @@ -1438,7 +1435,7 @@ nsTableFrame::DisplayGenericTablePart(nsDisplayListBuilder* aBuilder, } } - aTraversal(aBuilder, aFrame, aDirtyRect, aLists); + aTraversal(aBuilder, aFrame, aLists); if (isVisible) { if (isTable) { @@ -1466,12 +1463,11 @@ nsTableFrame::DisplayGenericTablePart(nsDisplayListBuilder* aBuilder, // SEC: TODO: adjust the rect for captions void nsTableFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists) { DO_GLOBAL_REFLOW_COUNT_DSP_COLOR("nsTableFrame", NS_RGB(255,128,255)); - DisplayGenericTablePart(aBuilder, this, aDirtyRect, aLists); + DisplayGenericTablePart(aBuilder, this, aLists); } nsMargin diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index d739faa72..8a2384134 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -231,9 +231,9 @@ public: typedef void (* DisplayGenericTablePartTraversal) (nsDisplayListBuilder* aBuilder, nsFrame* aFrame, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists); + const nsDisplayListSet& aLists); static void GenericTraversal(nsDisplayListBuilder* aBuilder, nsFrame* aFrame, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists); + const nsDisplayListSet& aLists); /** * Helper method to handle display common to table frames, rowgroup frames @@ -248,7 +248,6 @@ public: */ static void DisplayGenericTablePart(nsDisplayListBuilder* aBuilder, nsFrame* aFrame, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists, DisplayGenericTablePartTraversal aTraversal = GenericTraversal); @@ -268,7 +267,6 @@ public: virtual void GetChildLists(nsTArray* aLists) const override; virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists) override; /** Get the outer half (i.e., the part outside the height and width of diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp index 02b85a141..685f4fdea 100644 --- a/layout/tables/nsTableRowFrame.cpp +++ b/layout/tables/nsTableRowFrame.cpp @@ -551,10 +551,9 @@ nsTableRowFrame::CalcBSize(const ReflowInput& aReflowInput) void nsTableRowFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists) { - nsTableFrame::DisplayGenericTablePart(aBuilder, this, aDirtyRect, aLists); + nsTableFrame::DisplayGenericTablePart(aBuilder, this, aLists); } nsIFrame::LogicalSides diff --git a/layout/tables/nsTableRowFrame.h b/layout/tables/nsTableRowFrame.h index c53c81ff1..350b4f6f7 100644 --- a/layout/tables/nsTableRowFrame.h +++ b/layout/tables/nsTableRowFrame.h @@ -79,7 +79,6 @@ public: virtual nsMargin GetUsedPadding() const override; virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists) override; // Implemented in nsTableCellFrame.h, because it needs to know about the diff --git a/layout/tables/nsTableRowGroupFrame.cpp b/layout/tables/nsTableRowGroupFrame.cpp index 37f577f5c..1b7f029c8 100644 --- a/layout/tables/nsTableRowGroupFrame.cpp +++ b/layout/tables/nsTableRowGroupFrame.cpp @@ -156,7 +156,7 @@ nsTableRowGroupFrame::InitRepeatedFrame(nsTableRowGroupFrame* aHeaderFooterFrame // Handle the child-traversal part of DisplayGenericTablePart static void DisplayRows(nsDisplayListBuilder* aBuilder, nsFrame* aFrame, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists) + const nsDisplayListSet& aLists) { nscoord overflowAbove; nsTableRowGroupFrame* f = static_cast(aFrame); @@ -169,15 +169,15 @@ DisplayRows(nsDisplayListBuilder* aBuilder, nsFrame* aFrame, // approximate it by checking it for |f|: if it's true for any row // in |f| then it's true for |f| itself. nsIFrame* kid = aBuilder->ShouldDescendIntoFrame(f) ? - nullptr : f->GetFirstRowContaining(aDirtyRect.y, &overflowAbove); + nullptr : f->GetFirstRowContaining(aBuilder->GetDirtyRect().y, &overflowAbove); if (kid) { // If we have a cursor, use it while (kid) { - if (kid->GetRect().y - overflowAbove >= aDirtyRect.YMost()) { + if (kid->GetRect().y - overflowAbove >= aBuilder->GetDirtyRect().YMost()) { break; } - f->BuildDisplayListForChild(aBuilder, kid, aDirtyRect, aLists); + f->BuildDisplayListForChild(aBuilder, kid, aLists); kid = kid->GetNextSibling(); } return; @@ -187,7 +187,7 @@ DisplayRows(nsDisplayListBuilder* aBuilder, nsFrame* aFrame, nsTableRowGroupFrame::FrameCursorData* cursor = f->SetupRowCursor(); kid = f->PrincipalChildList().FirstChild(); while (kid) { - f->BuildDisplayListForChild(aBuilder, kid, aDirtyRect, aLists); + f->BuildDisplayListForChild(aBuilder, kid, aLists); if (cursor) { if (!cursor->AppendFrame(kid)) { @@ -205,10 +205,9 @@ DisplayRows(nsDisplayListBuilder* aBuilder, nsFrame* aFrame, void nsTableRowGroupFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists) { - nsTableFrame::DisplayGenericTablePart(aBuilder, this, aDirtyRect, + nsTableFrame::DisplayGenericTablePart(aBuilder, this, aLists, DisplayRows); } diff --git a/layout/tables/nsTableRowGroupFrame.h b/layout/tables/nsTableRowGroupFrame.h index 721d91046..eb9f6205e 100644 --- a/layout/tables/nsTableRowGroupFrame.h +++ b/layout/tables/nsTableRowGroupFrame.h @@ -75,7 +75,6 @@ public: virtual nsMargin GetUsedPadding() const override; virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists) override; /** calls Reflow for all of its child rows. diff --git a/layout/tables/nsTableWrapperFrame.cpp b/layout/tables/nsTableWrapperFrame.cpp index da71375d5..043522fb2 100644 --- a/layout/tables/nsTableWrapperFrame.cpp +++ b/layout/tables/nsTableWrapperFrame.cpp @@ -168,7 +168,6 @@ nsTableWrapperFrame::RemoveFrame(ChildListID aListID, void nsTableWrapperFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists) { // No border, background or outline are painted because they all belong @@ -177,16 +176,15 @@ nsTableWrapperFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, // If there's no caption, take a short cut to avoid having to create // the special display list set and then sort it. if (mCaptionFrames.IsEmpty()) { - BuildDisplayListForInnerTable(aBuilder, aDirtyRect, aLists); + BuildDisplayListForInnerTable(aBuilder, aLists); return; } nsDisplayListCollection set; - BuildDisplayListForInnerTable(aBuilder, aDirtyRect, set); + BuildDisplayListForInnerTable(aBuilder, set); nsDisplayListSet captionSet(set, set.BlockBorderBackgrounds()); - BuildDisplayListForChild(aBuilder, mCaptionFrames.FirstChild(), - aDirtyRect, captionSet); + BuildDisplayListForChild(aBuilder, mCaptionFrames.FirstChild(), captionSet); // Now we have to sort everything by content order, since the caption // may be somewhere inside the table @@ -200,7 +198,6 @@ nsTableWrapperFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, void nsTableWrapperFrame::BuildDisplayListForInnerTable(nsDisplayListBuilder* aBuilder, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists) { // Just paint the regular children, but the children's background is our @@ -208,7 +205,7 @@ nsTableWrapperFrame::BuildDisplayListForInnerTable(nsDisplayListBuilder* aBuil nsIFrame* kid = mFrames.FirstChild(); // The children should be in content order while (kid) { - BuildDisplayListForChild(aBuilder, kid, aDirtyRect, aLists); + BuildDisplayListForChild(aBuilder, kid, aLists); kid = kid->GetNextSibling(); } } diff --git a/layout/tables/nsTableWrapperFrame.h b/layout/tables/nsTableWrapperFrame.h index 45d7c33e4..8095c7fc4 100644 --- a/layout/tables/nsTableWrapperFrame.h +++ b/layout/tables/nsTableWrapperFrame.h @@ -59,11 +59,9 @@ public: #endif virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists) override; void BuildDisplayListForInnerTable(nsDisplayListBuilder* aBuilder, - const nsRect& aDirtyRect, const nsDisplayListSet& aLists); virtual nscoord GetLogicalBaseline(mozilla::WritingMode aWritingMode) const override; -- cgit v1.2.3 From 3c1e71f0b105835cba634088682c922d6640d1c5 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Fri, 8 May 2020 00:46:35 +0300 Subject: Issue #1355 - Preemptively fix build bustage for 1409114 --- layout/tables/nsTableWrapperFrame.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'layout/tables') diff --git a/layout/tables/nsTableWrapperFrame.cpp b/layout/tables/nsTableWrapperFrame.cpp index 043522fb2..476024e96 100644 --- a/layout/tables/nsTableWrapperFrame.cpp +++ b/layout/tables/nsTableWrapperFrame.cpp @@ -180,7 +180,7 @@ nsTableWrapperFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, return; } - nsDisplayListCollection set; + nsDisplayListCollection set(aBuilder); BuildDisplayListForInnerTable(aBuilder, set); nsDisplayListSet captionSet(set, set.BlockBorderBackgrounds()); -- cgit v1.2.3 From d8d0538162defbb3e44be475c4781bb71f55c2ba Mon Sep 17 00:00:00 2001 From: win7-7 Date: Fri, 8 May 2020 01:13:51 +0300 Subject: Issue #1355 - SetNeedToCalcHasBCBorders to true when initialize nsTableFrame In the printing preview, we create continuous table frame if table is too long to containing in a page. But the default value of NeedToCalcHasBCBorders is false which means we don't calculate HasBCBorders for continuous table frame. Thus, the border collapse is not shown when printing preview. --- layout/tables/nsTableFrame.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'layout/tables') diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 99838f217..57b249fb3 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -176,6 +176,9 @@ nsTableFrame::Init(nsIContent* aContent, const nsStyleTableBorder* tableStyle = StyleTableBorder(); bool borderCollapse = (NS_STYLE_BORDER_COLLAPSE == tableStyle->mBorderCollapse); SetBorderCollapse(borderCollapse); + if (borderCollapse) { + SetNeedToCalcHasBCBorders(true); + } if (!aPrevInFlow) { // If we're the first-in-flow, we manage the cell map & layout strategy that -- cgit v1.2.3 From d3d3aad6e52397334844ed80f8db650174937854 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Fri, 8 May 2020 01:21:41 +0300 Subject: 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. --- layout/tables/nsTableCellFrame.cpp | 51 ++++-- layout/tables/nsTableColFrame.cpp | 8 +- layout/tables/nsTableColGroupFrame.cpp | 8 +- layout/tables/nsTableFrame.cpp | 286 ++++++--------------------------- layout/tables/nsTableFrame.h | 95 +++++------ layout/tables/nsTableRowFrame.cpp | 57 ++++++- layout/tables/nsTableRowFrame.h | 5 + layout/tables/nsTableRowGroupFrame.cpp | 39 ++++- 8 files changed, 253 insertions(+), 296 deletions(-) (limited to 'layout/tables') diff --git a/layout/tables/nsTableCellFrame.cpp b/layout/tables/nsTableCellFrame.cpp index 64e7d2cfe..9c715d999 100644 --- a/layout/tables/nsTableCellFrame.cpp +++ b/layout/tables/nsTableCellFrame.cpp @@ -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 buildingForColGroup; + nsDisplayBackgroundImage::AppendBackgroundItemsToTop( + aBuilder, colGroup, bgRect, backgrounds->ColGroupBackgrounds(), false, + nullptr, colGroup->GetRect() + backgrounds->TableToReferenceFrame(), + this, &buildingForColGroup); + + Maybe 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. diff --git a/layout/tables/nsTableColFrame.cpp b/layout/tables/nsTableColFrame.cpp index 659f0fd35..6723f4701 100644 --- a/layout/tables/nsTableColFrame.cpp +++ b/layout/tables/nsTableColFrame.cpp @@ -112,7 +112,13 @@ void nsTableColFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) { - nsTableFrame::DisplayGenericTablePart(aBuilder, this, aLists); + // Per https://drafts.csswg.org/css-tables-3/#global-style-overrides: + // "All css properties of table-column and table-column-group boxes are + // ignored, except when explicitly specified by this specification." + // CSS outlines and box-shadows fall into this category, so we skip them + // on these boxes. + + MOZ_ASSERT_UNREACHABLE("Cols don't paint themselves"); } int32_t nsTableColFrame::GetSpan() diff --git a/layout/tables/nsTableColGroupFrame.cpp b/layout/tables/nsTableColGroupFrame.cpp index 732783428..be5b71bb2 100644 --- a/layout/tables/nsTableColGroupFrame.cpp +++ b/layout/tables/nsTableColGroupFrame.cpp @@ -387,7 +387,13 @@ void nsTableColGroupFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) { - nsTableFrame::DisplayGenericTablePart(aBuilder, this, aLists); + // Per https://drafts.csswg.org/css-tables-3/#global-style-overrides: + // "All css properties of table-column and table-column-group boxes are + // ignored, except when explicitly specified by this specification." + // CSS outlines and box-shadows fall into this category, so we skip them + // on these boxes. + + MOZ_ASSERT_UNREACHABLE("Colgroups don't paint themselves"); } nsTableColFrame * nsTableColGroupFrame::GetFirstColumn() diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 57b249fb3..59a6d0f1a 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -1166,113 +1166,7 @@ nsDisplayTableBorderCollapse::Paint(nsDisplayListBuilder* aBuilder, static_cast(mFrame)->PaintBCBorders(*drawTarget, mVisibleRect - pt); } -/* 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 over all cell frames. - 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& 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.Contains(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(), - true, nullptr, - aFrame->GetRectRelativeToSelf(), - cell); - } - } -} - -static inline bool FrameHasBorder(nsIFrame* f) -{ +static inline bool FrameHasBorder(nsIFrame* f) { if (!f->StyleVisibility()->IsVisible()) { return false; } @@ -1284,8 +1178,7 @@ static inline bool FrameHasBorder(nsIFrame* f) return false; } -void nsTableFrame::CalcHasBCBorders() -{ +void nsTableFrame::CalcHasBCBorders() { if (!IsBorderCollapse()) { SetHasBCBorders(false); return; @@ -1303,8 +1196,9 @@ void nsTableFrame::CalcHasBCBorders() return; } - nsTableColGroupFrame *colGroup = static_cast(f); - for (nsTableColFrame* col = colGroup->GetFirstColumn(); col; col = col->GetNextCol()) { + nsTableColGroupFrame* colGroup = static_cast(f); + for (nsTableColFrame* col = colGroup->GetFirstColumn(); col; + col = col->GetNextCol()) { if (FrameHasBorder(col)) { SetHasBCBorders(true); return; @@ -1321,13 +1215,15 @@ void nsTableFrame::CalcHasBCBorders() return; } - for (nsTableRowFrame* row = rowGroup->GetFirstRow(); row; row = row->GetNextRow()) { + for (nsTableRowFrame* row = rowGroup->GetFirstRow(); row; + row = row->GetNextRow()) { if (FrameHasBorder(row)) { SetHasBCBorders(true); return; } - for (nsTableCellFrame* cell = row->GetFirstCell(); cell; cell = cell->GetNextCell()) { + for (nsTableCellFrame* cell = row->GetFirstCell(); cell; + cell = cell->GetNextCell()) { if (FrameHasBorder(cell)) { SetHasBCBorders(true); return; @@ -1339,138 +1235,58 @@ void nsTableFrame::CalcHasBCBorders() SetHasBCBorders(false); } -/* static */ void -nsTableFrame::DisplayGenericTablePart(nsDisplayListBuilder* aBuilder, - nsFrame* aFrame, - const nsDisplayListSet& aLists, - DisplayGenericTablePartTraversal aTraversal) -{ - bool isVisible = aFrame->IsVisibleForPainting(aBuilder); - bool isTable = (aFrame->GetType() == nsGkAtoms::tableFrame); - - if (isVisible || !isTable) { - nsDisplayTableItem* currentItem = aBuilder->GetCurrentTableItem(); - // currentItem may be null, when none of the table parts have a - // background or border - if (currentItem) { - currentItem->UpdateForFrameBackground(aFrame); - } - } - - if (isVisible) { - // XXX: 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) { - aLists.BorderBackground()->AppendNewToTop( - new (aBuilder) nsDisplayBoxShadowOuter(aBuilder, aFrame)); - } - } - - // Background visibility for rows, rowgroups, columns, colgroups depends on - // the visibility of the _cell_, not of the row/col(group). - // See spec at https://drafts.csswg.org/css-tables-3/#drawing-cell-backgrounds - if (aFrame->GetType() == nsGkAtoms::tableRowGroupFrame) { - nsTableRowGroupFrame* rowGroup = static_cast(aFrame); - PaintRowGroupBackground(rowGroup, aFrame, aBuilder, aLists); - } else if (aFrame->GetType() == nsGkAtoms::tableRowFrame) { - nsTableRowFrame* row = static_cast(aFrame); - PaintRowBackground(row, aFrame, aBuilder, aLists); - } else if (aFrame->GetType() == nsGkAtoms::tableColGroupFrame) { - // Compute background rect by iterating all cell frame. - nsTableColGroupFrame* colGroup = static_cast(aFrame); - // Collecting column index. - AutoTArray colIdx; - for (nsTableColFrame* col = colGroup->GetFirstColumn(); col; col = col->GetNextCol()) { - MOZ_ASSERT(colIdx.IsEmpty() || - static_cast(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->GetType() == nsGkAtoms::tableColFrame) { - // Compute background rect by iterating all cell frame. - nsTableColFrame* col = static_cast(aFrame); - AutoTArray colIdx; - colIdx.AppendElement(col->GetColIndex()); +// 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)); - 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()); - } + DisplayBorderBackgroundOutline(aBuilder, aLists); - if (isVisible) { - // XXX: 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? + nsDisplayTableBackgroundSet tableBGs(aBuilder, this); + nsDisplayListCollection lists(aBuilder); - // Paint the inset box-shadows for the table frames - if (aFrame->StyleEffects()->mBoxShadow) { - aLists.BorderBackground()->AppendNewToTop( - new (aBuilder) nsDisplayBoxShadowInner(aBuilder, aFrame)); +// 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* colGroup : FirstContinuation()->GetChildList(kColGroupList)) { + for (nsIFrame* col : colGroup->PrincipalChildList()) { + tableBGs.AddColumn((nsTableColFrame*)col); } } - aTraversal(aBuilder, aFrame, aLists); + for (nsIFrame* kid : PrincipalChildList()) { + BuildDisplayListForChild(aBuilder, kid, lists); + } - if (isVisible) { - if (isTable) { - nsTableFrame* table = static_cast(aFrame); - // In the collapsed border model, overlay all collapsed borders. - if (table->IsBorderCollapse()) { - if (table->HasBCBorders()) { - aLists.BorderBackground()->AppendNewToTop( - new (aBuilder) nsDisplayTableBorderCollapse(aBuilder, table)); - } - } else { - const nsStyleBorder* borderStyle = aFrame->StyleBorder(); - if (borderStyle->HasBorder()) { - aLists.BorderBackground()->AppendNewToTop( - new (aBuilder) nsDisplayBorder(aBuilder, table)); - } + tableBGs.MoveTo(aLists); + lists.MoveTo(aLists); + + if (IsVisibleForPainting(aBuilder)) { + // In the collapsed border model, overlay all collapsed borders. + if (IsBorderCollapse()) { + if (HasBCBorders()) { + aLists.BorderBackground()->AppendNewToTop( + new (aBuilder) nsDisplayTableBorderCollapse + (aBuilder, this)); + } + } else { + const nsStyleBorder* borderStyle = StyleBorder(); + if (borderStyle->HasBorder()) { + aLists.BorderBackground()->AppendNewToTop( + new (aBuilder) nsDisplayBorder + (aBuilder, this)); } } } - - aFrame->DisplayOutline(aBuilder, aLists); -} - -// 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); } nsMargin diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index 8a2384134..7fcdcb9d8 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -72,36 +72,59 @@ private: bool mDrawsBackground; }; -class nsAutoPushCurrentTableItem -{ -public: - nsAutoPushCurrentTableItem() : mBuilder(nullptr) {} +class nsDisplayTableBackgroundSet { + public: + nsDisplayList* ColGroupBackgrounds() { return &mColGroupBackgrounds; } + + nsDisplayList* ColBackgrounds() { return &mColBackgrounds; } + + nsDisplayTableBackgroundSet(nsDisplayListBuilder* aBuilder, nsIFrame* aTable) + : mBuilder(aBuilder) { + mPrevTableBackgroundSet = mBuilder->SetTableBackgroundSet(this); + mozilla::DebugOnly reference = + mBuilder->FindReferenceFrameFor(aTable, &mToReferenceFrame); + MOZ_ASSERT(nsLayoutUtils::IsAncestorFrameCrossDoc(reference, aTable)); + mDirtyRect = mBuilder->GetDirtyRect(); + } - void Push(nsDisplayListBuilder* aBuilder, nsDisplayTableItem* aPushItem) - { - mBuilder = aBuilder; - mOldCurrentItem = aBuilder->GetCurrentTableItem(); - aBuilder->SetCurrentTableItem(aPushItem); -#ifdef DEBUG - mPushedItem = aPushItem; -#endif + ~nsDisplayTableBackgroundSet() { + mozilla::DebugOnly result = + mBuilder->SetTableBackgroundSet(mPrevTableBackgroundSet); + MOZ_ASSERT(result == this); } - ~nsAutoPushCurrentTableItem() { - if (!mBuilder) - return; -#ifdef DEBUG - NS_ASSERTION(mBuilder->GetCurrentTableItem() == mPushedItem, - "Someone messed with the current table item behind our back!"); -#endif - mBuilder->SetCurrentTableItem(mOldCurrentItem); + + /** + * Move all display items in our lists to top of the corresponding lists in + * the destination. + */ + void MoveTo(const nsDisplayListSet& aDestination) { + aDestination.BorderBackground()->AppendToTop(ColGroupBackgrounds()); + aDestination.BorderBackground()->AppendToTop(ColBackgrounds()); } -private: + void AddColumn(nsTableColFrame* aFrame) { mColumns.AppendElement(aFrame); } + + nsTableColFrame* GetColForIndex(int32_t aIndex) { return mColumns[aIndex]; } + + const nsPoint& TableToReferenceFrame() { return mToReferenceFrame; } + + const nsRect& GetDirtyRect() { return mDirtyRect; } + + 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! + void* operator new(size_t sz) CPP_THROW_NEW; + + protected: nsDisplayListBuilder* mBuilder; - nsDisplayTableItem* mOldCurrentItem; -#ifdef DEBUG - nsDisplayTableItem* mPushedItem; -#endif + nsDisplayTableBackgroundSet* mPrevTableBackgroundSet; + + nsDisplayList mColGroupBackgrounds; + nsDisplayList mColBackgrounds; + + nsTArray mColumns; + nsPoint mToReferenceFrame; + nsRect mDirtyRect; }; /* ============================================================================ */ @@ -229,28 +252,6 @@ public: 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, diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp index 685f4fdea..18f11f876 100644 --- a/layout/tables/nsTableRowFrame.cpp +++ b/layout/tables/nsTableRowFrame.cpp @@ -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 diff --git a/layout/tables/nsTableRowFrame.h b/layout/tables/nsTableRowFrame.h index 350b4f6f7..4b6dd2628 100644 --- a/layout/tables/nsTableRowFrame.h +++ b/layout/tables/nsTableRowFrame.h @@ -81,6 +81,11 @@ public: 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; diff --git a/layout/tables/nsTableRowGroupFrame.cpp b/layout/tables/nsTableRowGroupFrame.cpp index 1b7f029c8..b6d8a4364 100644 --- a/layout/tables/nsTableRowGroupFrame.cpp +++ b/layout/tables/nsTableRowGroupFrame.cpp @@ -207,8 +207,43 @@ void nsTableRowGroupFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) { - nsTableFrame::DisplayGenericTablePart(aBuilder, this, - aLists, DisplayRows); + 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)); + } + } + + for (nsTableRowFrame* row = GetFirstRow(); row; row = row->GetNextRow()) { + if (!aBuilder->GetDirtyRect().Intersects(row->GetVisualOverflowRect() + row->GetNormalPosition())) { + continue; + } + row->PaintCellBackgroundsForFrame(this, aBuilder, aLists, + row->GetNormalPosition()); + } + + 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); + + DisplayRows(aBuilder, this, aLists); } nsIFrame::LogicalSides -- cgit v1.2.3 From d050188cd525b769d33e2a2d94454b32aaa0b622 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Mon, 11 May 2020 23:17:47 +0000 Subject: Issue #1543 - Align with no src to the updated spec. --- layout/tables/crashtests/crashtests.list | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'layout/tables') diff --git a/layout/tables/crashtests/crashtests.list b/layout/tables/crashtests/crashtests.list index f110053f1..40b1ba82e 100644 --- a/layout/tables/crashtests/crashtests.list +++ b/layout/tables/crashtests/crashtests.list @@ -109,7 +109,7 @@ asserts(8) load 420654-1.xhtml # bug 458238, bug 436123, bug 457397 load 423514-1.xhtml load 430374.html load 444431-1.html -load 444702-1.html +asserts(1) load 444702-1.html # nscoord overflow. load 448988-1.xhtml load 450311-1.html load 451170.html -- cgit v1.2.3 From ad69c023a96f516ae9a0089b1bc6e4c0712dccd3 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Tue, 12 May 2020 19:23:47 +0300 Subject: Issue #1545 - Fix border-radius on table row groups, rows, column groups, or columns Before issue #146, border-radius on row groups, rows, column groups, or columns don't apply to the background of each cell, yet the border-radius on the cell itself does. After issue #146, the behaviors changed. In this patch, I tried to revert the behaviors of border-radius on table row groups, rows, column groups, or columns back to what happened before issue #146. Also: Don't override GetBorderRadii in nsBCTableCellFrame. --- layout/tables/nsTableCellFrame.cpp | 12 ------------ layout/tables/nsTableCellFrame.h | 4 ---- 2 files changed, 16 deletions(-) (limited to 'layout/tables') diff --git a/layout/tables/nsTableCellFrame.cpp b/layout/tables/nsTableCellFrame.cpp index 9c715d999..ee05565a9 100644 --- a/layout/tables/nsTableCellFrame.cpp +++ b/layout/tables/nsTableCellFrame.cpp @@ -1108,18 +1108,6 @@ nsBCTableCellFrame::GetUsedBorder() const return GetBorderWidth(wm).GetPhysicalMargin(wm); } -/* virtual */ bool -nsBCTableCellFrame::GetBorderRadii(const nsSize& aFrameSize, - const nsSize& aBorderArea, - Sides aSkipSides, - nscoord aRadii[8]) const -{ - NS_FOR_CSS_HALF_CORNERS(corner) { - aRadii[corner] = 0; - } - return false; -} - #ifdef DEBUG_FRAME_DUMP nsresult nsBCTableCellFrame::GetFrameName(nsAString& aResult) const diff --git a/layout/tables/nsTableCellFrame.h b/layout/tables/nsTableCellFrame.h index a822e309d..2acd59667 100644 --- a/layout/tables/nsTableCellFrame.h +++ b/layout/tables/nsTableCellFrame.h @@ -340,10 +340,6 @@ public: virtual nsIAtom* GetType() const override; virtual nsMargin GetUsedBorder() const override; - virtual bool GetBorderRadii(const nsSize& aFrameSize, - const nsSize& aBorderArea, - Sides aSkipSides, - nscoord aRadii[8]) const override; // Get the *inner half of the border only*, in twips. virtual LogicalMargin GetBorderWidth(WritingMode aWM) const override; -- cgit v1.2.3 From 21348b56d992e48d7a18259f95fc82edf53239d7 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Wed, 13 May 2020 19:57:18 +0300 Subject: issue #1547 - Correct z-ordering for some table parts and add reftests --- layout/tables/nsTableWrapperFrame.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'layout/tables') diff --git a/layout/tables/nsTableWrapperFrame.cpp b/layout/tables/nsTableWrapperFrame.cpp index 476024e96..86f032218 100644 --- a/layout/tables/nsTableWrapperFrame.cpp +++ b/layout/tables/nsTableWrapperFrame.cpp @@ -187,8 +187,11 @@ nsTableWrapperFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, BuildDisplayListForChild(aBuilder, mCaptionFrames.FirstChild(), captionSet); // Now we have to sort everything by content order, since the caption - // may be somewhere inside the table - set.BlockBorderBackgrounds()->SortByContentOrder(GetContent()); + // may be somewhere inside the table. + // We don't sort BlockBorderBackgrounds and BorderBackgrounds because the + // display items in those lists should stay out of content order in order to + // follow the rules in https://www.w3.org/TR/CSS21/zindex.html#painting-order + // and paint the caption background after all of the rest. set.Floats()->SortByContentOrder(GetContent()); set.Content()->SortByContentOrder(GetContent()); set.PositionedDescendants()->SortByContentOrder(GetContent()); -- cgit v1.2.3