Bug 1388625 part 2. During a stylo restyle, update the style of the anonymous cols in a colgroup, if any. r=heycam

MozReview-Commit-ID: 4H2NzhCyygU

--HG--
extra : rebase_source : 88f0802f507478c97b4b971ba13348c44f212f31
This commit is contained in:
Boris Zbarsky 2017-08-10 12:43:05 -04:00
Родитель fbecdd2153
Коммит dd203db270
3 изменённых файлов: 49 добавлений и 0 удалений

Просмотреть файл

@ -188,6 +188,15 @@ nsTableColGroupFrame::AppendFrames(ChildListID aListID,
col = nextCol; col = nextCol;
} }
// Our next colframe should be an eColContent. We've removed all the
// eColAnonymousColGroup colframes, eColAnonymousCol colframes always follow
// eColContent ones, and eColAnonymousCell colframes only appear in an
// eColGroupAnonymousCell colgroup, which never gets AppendFrames() called on
// it.
MOZ_ASSERT(!col || col->GetColType() == eColContent,
"What's going on with our columns?");
RemoveStateBits(NS_FRAME_OWNS_ANON_BOXES);
const nsFrameList::Slice& newFrames = const nsFrameList::Slice& newFrames =
mFrames.AppendFrames(this, aFrameList); mFrames.AppendFrames(this, aFrameList);
InsertColsReflow(GetStartColumnIndex() + mColCount, newFrames); InsertColsReflow(GetStartColumnIndex() + mColCount, newFrames);
@ -221,6 +230,15 @@ nsTableColGroupFrame::InsertFrames(ChildListID aListID,
col = nextCol; col = nextCol;
} }
// Our next colframe should be an eColContent. We've removed all the
// eColAnonymousColGroup colframes, eColAnonymousCol colframes always follow
// eColContent ones, and eColAnonymousCell colframes only appear in an
// eColGroupAnonymousCell colgroup, which never gets InsertFrames() called on
// it.
MOZ_ASSERT(!col || col->GetColType() == eColContent,
"What's going on with our columns?");
RemoveStateBits(NS_FRAME_OWNS_ANON_BOXES);
NS_ASSERTION(!aPrevFrame || aPrevFrame == aPrevFrame->LastContinuation(), NS_ASSERTION(!aPrevFrame || aPrevFrame == aPrevFrame->LastContinuation(),
"Prev frame should be last in continuation chain"); "Prev frame should be last in continuation chain");
NS_ASSERTION(!aPrevFrame || !GetNextColumn(aPrevFrame) || NS_ASSERTION(!aPrevFrame || !GetNextColumn(aPrevFrame) ||
@ -484,6 +502,30 @@ nsTableColGroupFrame::InvalidateFrameWithRect(const nsRect& aRect,
GetParent()->InvalidateFrameWithRect(aRect + GetPosition(), aDisplayItemKey); GetParent()->InvalidateFrameWithRect(aRect + GetPosition(), aDisplayItemKey);
} }
void
nsTableColGroupFrame::AppendDirectlyOwnedAnonBoxes(
nsTArray<OwnedAnonBox>& aResult)
{
nsTableColFrame* col = GetFirstColumn();
if (!col) {
// No columns, nothing to do.
return;
}
if (col->GetColType() == eColContent) {
// We have actual columns; no anon boxes here.
return;
}
for ( ; col; col = col->GetNextCol()) {
MOZ_ASSERT(col->GetColType() != eColContent,
"We should not have any real columns after anonymous ones");
MOZ_ASSERT(col->GetColType() != eColAnonymousCol,
"We shouldn't have spanning anonymous columns");
aResult.AppendElement(OwnedAnonBox(col));
}
}
#ifdef DEBUG_FRAME_DUMP #ifdef DEBUG_FRAME_DUMP
nsresult nsresult
nsTableColGroupFrame::GetFrameName(nsAString& aResult) const nsTableColGroupFrame::GetFrameName(nsAString& aResult) const

Просмотреть файл

@ -202,6 +202,9 @@ public:
virtual void InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey = 0) override; virtual void InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey = 0) override;
virtual void InvalidateFrameForRemoval() override { InvalidateFrameSubtree(); } virtual void InvalidateFrameForRemoval() override { InvalidateFrameSubtree(); }
// Return any anonymous columns we contain.
void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
protected: protected:
explicit nsTableColGroupFrame(nsStyleContext* aContext); explicit nsTableColGroupFrame(nsStyleContext* aContext);

Просмотреть файл

@ -700,6 +700,7 @@ nsTableFrame::CreateAnonymousColGroupFrame(nsTableColGroupType aColGroupType)
void void
nsTableFrame::AppendAnonymousColFrames(int32_t aNumColsToAdd) nsTableFrame::AppendAnonymousColFrames(int32_t aNumColsToAdd)
{ {
MOZ_ASSERT(aNumColsToAdd > 0, "We should be adding _something_.");
// get the last col group frame // get the last col group frame
nsTableColGroupFrame* colGroupFrame = nsTableColGroupFrame* colGroupFrame =
static_cast<nsTableColGroupFrame*>(mColGroups.LastChild()); static_cast<nsTableColGroupFrame*>(mColGroups.LastChild());
@ -732,6 +733,7 @@ nsTableFrame::AppendAnonymousColFrames(nsTableColGroupFrame* aColGroupFrame,
{ {
NS_PRECONDITION(aColGroupFrame, "null frame"); NS_PRECONDITION(aColGroupFrame, "null frame");
NS_PRECONDITION(aColType != eColAnonymousCol, "Shouldn't happen"); NS_PRECONDITION(aColType != eColAnonymousCol, "Shouldn't happen");
MOZ_ASSERT(aNumColsToAdd > 0, "We should be adding _something_.");
nsIPresShell *shell = PresContext()->PresShell(); nsIPresShell *shell = PresContext()->PresShell();
@ -741,6 +743,8 @@ nsTableFrame::AppendAnonymousColFrames(nsTableColGroupFrame* aColGroupFrame,
int32_t startIndex = mColFrames.Length(); int32_t startIndex = mColFrames.Length();
int32_t lastIndex = startIndex + aNumColsToAdd - 1; int32_t lastIndex = startIndex + aNumColsToAdd - 1;
// aColGroupFrame will need to handle restyling these cols we're about to add.
aColGroupFrame->AddStateBits(NS_FRAME_OWNS_ANON_BOXES);
for (int32_t childX = startIndex; childX <= lastIndex; childX++) { for (int32_t childX = startIndex; childX <= lastIndex; childX++) {
nsIContent* iContent; nsIContent* iContent;
RefPtr<nsStyleContext> styleContext; RefPtr<nsStyleContext> styleContext;