Bug 1384602 part 1. When coalescing lazy frame construction reframes for stylo, do it even across comments. r=emilio

MozReview-Commit-ID: 7MyO1ZyS9zu
This commit is contained in:
Boris Zbarsky 2017-08-11 00:17:07 -04:00
parent 60cd46bdce
commit 3e9a6da953
4 changed files with 64 additions and 2 deletions

View File

@ -1267,6 +1267,23 @@ StyleChangeReflow(nsIFrame* aFrame, nsChangeHint aHint)
} while (aFrame);
}
// Get the next sibling which might have a frame. This only considers siblings
// that stylo post-traversal looks at, so only elements and text. In
// particular, it ignores comments.
static nsIContent*
NextSiblingWhichMayHaveFrame(nsIContent* aContent)
{
for (nsIContent* next = aContent->GetNextSibling();
next;
next = next->GetNextSibling()) {
if (next->IsElement() || next->IsNodeOfType(nsINode::eTEXT)) {
return next;
}
}
return nullptr;
}
void
RestyleManager::ProcessRestyledFrames(nsStyleChangeList& aChangeList)
{
@ -1397,7 +1414,8 @@ RestyleManager::ProcessRestyledFrames(nsStyleChangeList& aChangeList)
aChangeList[i].mContent &&
aChangeList[i].mContent->HasFlag(NODE_NEEDS_FRAME) &&
(i == lazyRangeStart ||
aChangeList[i - 1].mContent->GetNextSibling() == aChangeList[i].mContent))
NextSiblingWhichMayHaveFrame(aChangeList[i - 1].mContent) ==
aChangeList[i].mContent))
{
MOZ_ASSERT(aChangeList[i].mHint & nsChangeHint_ReconstructFrame);
MOZ_ASSERT(!aChangeList[i].mFrame);
@ -1405,7 +1423,7 @@ RestyleManager::ProcessRestyledFrames(nsStyleChangeList& aChangeList)
}
if (i != lazyRangeStart) {
nsIContent* start = aChangeList[lazyRangeStart].mContent;
nsIContent* end = aChangeList[i-1].mContent->GetNextSibling();
nsIContent* end = NextSiblingWhichMayHaveFrame(aChangeList[i-1].mContent);
nsIContent* container = start->GetParent();
MOZ_ASSERT(container);
if (!end) {

View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<style>
table {
table-layout: fixed;
width: 100%;
border-collapse: collapse;
}
</style>
<table>
<tbody>
<tr>
<td colspan="4">Spanning.</td>
</tr>
</tbody>
<tbody>
<tr><td>1</td><td>2</td><td>3</td><td>4</td></tr>
</tbody>
</table>

View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<style>
table {
table-layout: fixed;
width: 100%;
border-collapse: collapse;
}
</style>
<table>
<tbody>
<tr>
<td colspan="4">Spanning.</td>
</tr>
</tbody>
<tbody>
<tr id="target"></tr>
</tbody>
</table>
<script>
onload = function() {
document.body.offsetWidth;
var row = document.getElementById("target");
row.innerHTML = "<td>1</td><td>2</td><!--This comment is needed--><td>3</td><td>4</td>";
}
</script>

View File

@ -111,3 +111,4 @@ fuzzy(255,40) == border-style-outset-becomes-groove.html border-style-outset-bec
# is 20px).
fuzzy(255,40) == border-style-inset-becomes-ridge.html border-style-inset-becomes-ridge-ref.html
fuzzy(2,11000) == 1324524.html 1324524-ref.html
== 1384602-1a.html 1384602-1-ref.html