Bug 1588025 - Make the custom content container a font inflation root. r=emilio

font-inflation-1e.html is adapted from font-inflation-1a.html with the
writing-mode set on <html> instead of <body>. It can trigger the
assertion "current writing mode should match that of our flow root" in
nsFontInflationData::FindFontInflationDataFor().

The root cause is: nsCanvasFrame can generate the position:absolute
custom content container to contain elements like AccessibleCaret. When
the container is constructed, the container's writing-mode is always
horizontal-rl, which is getting from nsCanvasFrame that uses
ViewportFrame's style.

If <html> has a vertical writing-mode, custom content container's used
mWritingMode becomes orthogonal to ViewportFrame, because <html>'s used
mWritingMode is propagated all the way up to ViewportFrame.

This patch solves the above issue by making the custom content container
a font inflation root, so FindFontInflationDataFor() stops at it instead
of finding all the way up to the ViewportFrame.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ting-Yu Lin 2019-10-28 20:42:06 +00:00
parent 1a277253b9
commit 7fd6d04f2b
3 changed files with 29 additions and 4 deletions

View File

@ -59,6 +59,7 @@
#include "nsGkAtoms.h"
#include "nsCSSAnonBoxes.h"
#include "nsCSSClipPathInstance.h"
#include "nsCanvasFrame.h"
#include "nsFrameTraversal.h"
#include "nsRange.h"
@ -544,6 +545,13 @@ static bool IsFontSizeInflationContainer(nsIFrame* aFrame,
}
nsIContent* content = aFrame->GetContent();
if (content && content->IsInNativeAnonymousSubtree()) {
// Native anonymous content shouldn't be a font inflation root,
// except for the canvas custom content container.
nsCanvasFrame* canvas = aFrame->PresShell()->GetCanvasFrame();
return canvas && canvas->GetCustomContentContainer() == content;
}
LayoutFrameType frameType = aFrame->Type();
bool isInline =
(nsStyleDisplay::IsInlineFlow(aFrame->GetDisplay()) ||
@ -555,8 +563,7 @@ static bool IsFontSizeInflationContainer(nsIFrame* aFrame,
(aFrame->GetParent()->GetContent() == content) ||
(content &&
(content->IsAnyOfHTMLElements(nsGkAtoms::option, nsGkAtoms::optgroup,
nsGkAtoms::select) ||
content->IsInNativeAnonymousSubtree()))) &&
nsGkAtoms::select)))) &&
!(aFrame->IsXULBoxFrame() && aFrame->GetParent()->IsXULBoxFrame());
NS_ASSERTION(!aFrame->IsFrameOfType(nsIFrame::eLineParticipant) || isInline ||
// br frames and mathml frames report being line

View File

@ -0,0 +1,19 @@
<!DOCTYPE HTML>
<style>
html { writing-mode: vertical-lr; text-orientation: sideways-right; }
#outer { width: 450px; }
#inner { font-size: 12px; width: 100%; height: 100%; }
</style>
<div id="outer">
<div id="inner">Inflated?
<script>
// When AccessibleCaret is enabled, the above markup is sufficient to trigger
// the assertion on the custom content container. This script forces
// AccessibleCaret to show, and tests that font inflation doesn't trigger
// assertion for elements in the custom content container subtree.
var sel = window.getSelection();
sel.selectAllChildren(document.documentElement);
document.documentElement.offsetWidth;
sel.removeAllRanges();
</script>

View File

@ -117,7 +117,6 @@ fuzzy-if(winWidget,0-255,0-236) == 1136557-3-nested-spans.html 1136557-3-nested-
!= 1138356-2-button-contents-alignment.html 1138356-2-button-contents-alignment-notref.html
# Font inflation behaves wrong in vertical writing mode: bug 1138495
default-preferences pref(layout.accessiblecaret.enabled_on_touch,false) # Disable AccessibleCaret to work around bug 1588025
test-pref(dom.meta-viewport.enabled,true) test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) == font-inflation-1a.html font-inflation-1-ref.html
test-pref(dom.meta-viewport.enabled,true) test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) == font-inflation-1b.html font-inflation-1-ref.html
test-pref(dom.meta-viewport.enabled,true) test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) != font-inflation-1c.html font-inflation-1-ref.html
@ -125,7 +124,7 @@ test-pref(dom.meta-viewport.enabled,true) test-pref(font.size.inflation.emPerLin
pref(dom.meta-viewport.enabled,true) pref(font.size.inflation.emPerLine,15) pref(font.size.inflation.forceEnabled,true) pref(font.size.inflation.lineThreshold,0) != font-inflation-1c.html font-inflation-1d.html
test-pref(dom.meta-viewport.enabled,true) test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) == font-inflation-1c.html font-inflation-1c-ref.html
test-pref(dom.meta-viewport.enabled,true) test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) == font-inflation-1d.html font-inflation-1d-ref.html
default-preferences pref(layout.accessiblecaret.enabled_on_touch,true)
test-pref(dom.meta-viewport.enabled,true) test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.forceEnabled,true) test-pref(font.size.inflation.lineThreshold,0) test-pref(layout.accessiblecaret.enabled,true) == font-inflation-1e.html font-inflation-1-ref.html
== 1144501-1a-block-end-margin-orthogonal-size.html 1144501-1-block-end-margin-orthogonal-size-ref.html
== 1144501-1b-block-end-margin-orthogonal-size.html 1144501-1-block-end-margin-orthogonal-size-ref.html