Bug 1607045 - Look in all table continuations for the original header/footer of a repeated header/footer. r=TYLin

Differential Revision: https://phabricator.services.mozilla.com/D60553

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mats Palmgren 2020-01-23 15:51:22 +00:00
Родитель ecd3506c24
Коммит 02656fc8cd
5 изменённых файлов: 48 добавлений и 58 удалений

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

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html class="reftest-paged">
<head>
<style>
table tbody td {
border-right:1px solid;
}
table {
border-collapse:collapse;
}
</style>
</head>
<body>
<div style="height:150px"></div>
<table>
<tbody>
<tr height=150></tr>
<tr height=10><td></td></tr>
</tbody>
<tfoot><tr height=50><td>footer</tfoot>
</table>
</body>

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

@ -168,3 +168,4 @@ load 1555757-1.html
load 1555757-2.html
load 1555757-3.html
load 1555757-4.html
load 1607045.html

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

@ -206,21 +206,28 @@ nsCellMap* nsTableCellMap::GetMapFor(const nsTableRowGroupFrame* aRowGroup,
return map;
}
// if aRowGroup is a repeated header or footer find the header or footer it
// was repeated from
// If aRowGroup is a repeated header or footer find the header or footer it
// was repeated from.
if (aRowGroup->IsRepeatable()) {
nsTableFrame* fifTable =
static_cast<nsTableFrame*>(mTableFrame.FirstInFlow());
const nsStyleDisplay* display = aRowGroup->StyleDisplay();
nsTableRowGroupFrame* rgOrig =
(StyleDisplay::TableHeaderGroup == display->mDisplay)
? fifTable->GetTHead()
: fifTable->GetTFoot();
// find the row group cell map using the original header/footer
if (rgOrig && rgOrig != aRowGroup) {
auto findOtherRowGroupOfType =
[aRowGroup](nsTableFrame* aTable) -> nsTableRowGroupFrame* {
const auto display = aRowGroup->StyleDisplay()->mDisplay;
auto* table = aTable->FirstContinuation();
for (; table; table = table->GetNextContinuation()) {
for (auto* child : table->PrincipalChildList()) {
if (child->StyleDisplay()->mDisplay == display &&
child != aRowGroup) {
return static_cast<nsTableRowGroupFrame*>(child);
}
}
}
return nullptr;
};
if (auto* rgOrig = findOtherRowGroupOfType(&mTableFrame)) {
return GetMapFor(rgOrig, aStartHint);
}
MOZ_ASSERT_UNREACHABLE("A repeated header/footer should always have an "
"original header/footer it was repeated from");
}
return nullptr;

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

@ -2754,46 +2754,6 @@ void nsTableFrame::OrderRowGroups(RowGroupArray& aChildren,
if (aFoot) *aFoot = foot;
}
nsTableRowGroupFrame* nsTableFrame::GetTHead() const {
nsIFrame* kidFrame = mFrames.FirstChild();
while (kidFrame) {
if (kidFrame->StyleDisplay()->mDisplay ==
mozilla::StyleDisplay::TableHeaderGroup) {
return static_cast<nsTableRowGroupFrame*>(kidFrame);
}
// Get the next sibling but skip it if it's also the next-in-flow, since
// a next-in-flow will not be part of the current table.
while (kidFrame) {
nsIFrame* nif = kidFrame->GetNextInFlow();
kidFrame = kidFrame->GetNextSibling();
if (kidFrame != nif) break;
}
}
return nullptr;
}
nsTableRowGroupFrame* nsTableFrame::GetTFoot() const {
nsIFrame* kidFrame = mFrames.FirstChild();
while (kidFrame) {
if (kidFrame->StyleDisplay()->mDisplay ==
mozilla::StyleDisplay::TableFooterGroup) {
return static_cast<nsTableRowGroupFrame*>(kidFrame);
}
// Get the next sibling but skip it if it's also the next-in-flow, since
// a next-in-flow will not be part of the current table.
while (kidFrame) {
nsIFrame* nif = kidFrame->GetNextInFlow();
kidFrame = kidFrame->GetNextSibling();
if (kidFrame != nif) break;
}
}
return nullptr;
}
static bool IsRepeatable(nscoord aFrameHeight, nscoord aPageHeight) {
return aFrameHeight < (aPageHeight / 4);
}

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

@ -691,12 +691,6 @@ class nsTableFrame : public nsContainerFrame {
nsTableRowGroupFrame** aHead = nullptr,
nsTableRowGroupFrame** aFoot = nullptr) const;
// Return the thead, if any
nsTableRowGroupFrame* GetTHead() const;
// Return the tfoot, if any
nsTableRowGroupFrame* GetTFoot() const;
// Returns true if there are any cells above the row at
// aRowIndex and spanning into the row at aRowIndex, the number of
// effective columns limits the search up to that column