Bug 1671950 - Fix assert in SVGSwitchFrame r=emilio

We need to be consistent with the expectations of SVGContainerFrame::ReflowSVGNonDisplayText calling itself recursively on non-SVG content.

Differential Revision: https://phabricator.services.mozilla.com/D94048
This commit is contained in:
longsonr 2020-10-22 08:28:45 +00:00
Родитель 2e01d0a8fd
Коммит c252c0be62
4 изменённых файлов: 38 добавлений и 7 удалений

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

@ -104,10 +104,10 @@ void SVGContainerFrame::ReflowSVGNonDisplayText(nsIFrame* aContainer) {
if (!aContainer->HasAnyStateBits(NS_FRAME_IS_DIRTY)) {
return;
}
NS_ASSERTION(aContainer->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY) ||
!aContainer->IsFrameOfType(nsIFrame::eSVG),
"it is wasteful to call ReflowSVGNonDisplayText on a container "
"frame that is not NS_FRAME_IS_NONDISPLAY");
MOZ_ASSERT(aContainer->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY) ||
!aContainer->IsFrameOfType(nsIFrame::eSVG),
"it is wasteful to call ReflowSVGNonDisplayText on a container "
"frame that is not NS_FRAME_IS_NONDISPLAY or not SVG");
for (nsIFrame* kid : aContainer->PrincipalChildList()) {
LayoutFrameType type = kid->Type();
if (type == LayoutFrameType::SVGText) {
@ -326,8 +326,10 @@ void SVGDisplayContainerFrame::ReflowSVG() {
// Inside a non-display container frame, we might have some
// SVGTextFrames. We need to cause those to get reflowed in
// case they are the target of a rendering observer.
NS_ASSERTION(kid->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY),
"expected kid to be a NS_FRAME_IS_NONDISPLAY frame");
MOZ_ASSERT(
kid->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY) ||
!kid->IsFrameOfType(nsIFrame::eSVG),
"expected kid to be a NS_FRAME_IS_NONDISPLAY frame or not SVG");
if (kid->HasAnyStateBits(NS_FRAME_IS_DIRTY)) {
SVGContainerFrame* container = do_QueryFrame(kid);
if (container && container->GetContent()->IsSVGElement()) {

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

@ -233,7 +233,8 @@ void SVGSwitchFrame::ReflowSVG() {
// frame list, and we're iterating over that list now anyway.
ConsiderChildOverflow(overflowRects, child);
} else if (child && shouldReflowSVGTextFrameInside(child)) {
MOZ_ASSERT(child->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY),
MOZ_ASSERT(child->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY) ||
!child->IsFrameOfType(nsIFrame::eSVG),
"Check for this explicitly in the |if|, then");
ReflowSVGNonDisplayText(child);
}

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

@ -0,0 +1,27 @@
<html>
<head>
<style>
* {
break-before: always ! important;
}
</style>
<script>
window.addEventListener('load', () => {
const style = document.createElement('style')
document.head.appendChild(style)
const svg_1 = document.getElementById('id_3')
const svg_2 = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
const switch_0 = document.createElementNS('http://www.w3.org/2000/svg', 'switch')
const c_0 = document.createElementNS('http://www.w3.org/2000/svg', 'c')
switch_0.appendChild(c_0)
svg_1.appendChild(switch_0)
svg_2.appendChild(svg_1)
document.documentElement.appendChild(svg_2)
style.sheet.insertRule('@-moz-document url-prefix(){*,a{all:inherit', 0)
SpecialPowers.wrap(window).printPreview()?.close()
})
</script>
<svg id='id_3'></svg>
</head>
</html>

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

@ -235,3 +235,4 @@ load 1600855.html
load 1601824.html
load 1605223-1.html
load 1609663.html
load 1671950.html