Bug 935056 - Don't apply minimum font sizes to SVG text. r=heycam

Differential Revision: https://phabricator.services.mozilla.com/D74581
This commit is contained in:
longsonr 2020-05-13 09:10:54 +00:00
parent 0da2867bf2
commit 5fa0ddbf8f
10 changed files with 43 additions and 18 deletions

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<meta charset=utf-8>
<style>
* { margin: 3px; }
p { font: 32px serif; }
text { font: 16px serif; }
</style>
<p>This text should be affected by the minimum font size.</p>
<svg width="800" height="40">
<text x="10" y="20">This text should not be affected by the minimum font size.</text>
</svg>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<meta charset=utf-8>
<style>
* { margin: 3px; }
p, text { font: 16px serif; }
</style>
<p>This text should be affected by the minimum font size.</p>
<svg width="800" height="40">
<text x="10" y="20">This text should not be affected by the minimum font size.</text>
</svg>

View File

@ -1773,6 +1773,7 @@ fuzzy-if(skiaContent,0-1,0-3) == 931464-1.html 931464-1-ref.html
== 931853.html 931853-ref.html
== 931853-quirks.html 931853-quirks-ref.html
== 933264-1.html 933264-1-ref.html
test-pref(font.minimum-size.x-western,32) fuzzy-if(Android,0-45,0-324) == 935056-1.html 935056-1-ref.html
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == 936670-1.svg 936670-1-ref.svg # Bug 1392106
== 941940-1.html 941940-1-ref.html
fails == 942017.html 942017-ref.html # bug 942017

View File

@ -1354,9 +1354,10 @@ void Gecko_nsStyleFont_PrioritizeUserFonts(
nscoord Gecko_nsStyleFont_ComputeMinSize(const nsStyleFont* aFont,
const Document* aDocument) {
// Don't change font-size:0, since that would un-hide hidden text, nor chrome
// docs, we assume those know what they do.
if (aFont->mSize == 0 || nsContentUtils::IsChromeDoc(aDocument)) {
// Don't change font-size:0, since that would un-hide hidden text,
// or SVG text, or chrome docs, we assume those know what they do.
if (aFont->mSize == 0 || !aFont->mAllowZoomAndMinSize ||
nsContentUtils::IsChromeDoc(aDocument)) {
return 0;
}

View File

@ -2162,7 +2162,7 @@ bool nsComputedDOMStyle::GetLineHeightCoord(nscoord& aCoord) {
// the text zoom, if any.
const nsStyleFont* font = StyleFont();
float fCoord = float(aCoord);
if (font->mAllowZoom) {
if (font->mAllowZoomAndMinSize) {
fCoord /= presContext->EffectiveTextZoom();
}
if (font->mFont.size != font->mSize) {

View File

@ -231,7 +231,7 @@ nsStyleFont::nsStyleFont(const nsStyleFont& aSrc)
mMathDisplay(aSrc.mMathDisplay),
mMinFontSizeRatio(aSrc.mMinFontSizeRatio),
mExplicitLanguage(aSrc.mExplicitLanguage),
mAllowZoom(aSrc.mAllowZoom),
mAllowZoomAndMinSize(aSrc.mAllowZoomAndMinSize),
mScriptUnconstrainedSize(aSrc.mScriptUnconstrainedSize),
mScriptMinSize(aSrc.mScriptMinSize),
mScriptSizeMultiplier(aSrc.mScriptSizeMultiplier),
@ -252,7 +252,7 @@ nsStyleFont::nsStyleFont(const Document& aDocument)
mMathDisplay(NS_MATHML_DISPLAYSTYLE_INLINE),
mMinFontSizeRatio(100), // 100%
mExplicitLanguage(false),
mAllowZoom(true),
mAllowZoomAndMinSize(true),
mScriptUnconstrainedSize(mSize),
mScriptMinSize(nsPresContext::CSSTwipsToAppUnits(
NS_POINTS_TO_TWIPS(NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT))),
@ -269,8 +269,9 @@ nsStyleFont::nsStyleFont(const Document& aDocument)
}
nsChangeHint nsStyleFont::CalcDifference(const nsStyleFont& aNewData) const {
MOZ_ASSERT(mAllowZoom == aNewData.mAllowZoom,
"expected mAllowZoom to be the same on both nsStyleFonts");
MOZ_ASSERT(
mAllowZoomAndMinSize == aNewData.mAllowZoomAndMinSize,
"expected mAllowZoomAndMinSize to be the same on both nsStyleFonts");
if (mSize != aNewData.mSize || mLanguage != aNewData.mLanguage ||
mExplicitLanguage != aNewData.mExplicitLanguage ||
mMathVariant != aNewData.mMathVariant ||

View File

@ -121,8 +121,9 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleFont {
bool mExplicitLanguage;
// should calls to ZoomText() and UnZoomText() be made to the font
// size on this nsStyleFont?
bool mAllowZoom;
// size on this nsStyleFont? Also used to prevent SVG text from being
// affected by minimum font size pref.
bool mAllowZoomAndMinSize;
// The value mSize would have had if scriptminsize had never been applied
nscoord mScriptUnconstrainedSize;

View File

@ -920,8 +920,8 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
let builder = &mut self.context.builder;
let parent_zoom = builder.get_parent_font().gecko().mAllowZoom;
let zoom = builder.get_font().gecko().mAllowZoom;
let parent_zoom = builder.get_parent_font().gecko().mAllowZoomAndMinSize;
let zoom = builder.get_font().gecko().mAllowZoomAndMinSize;
if zoom == parent_zoom {
return;
}
@ -968,7 +968,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
}
let mut min = Au(parent_font.mScriptMinSize);
if font.mAllowZoom {
if font.mAllowZoomAndMinSize {
min = builder.device.zoom_text(min);
}

View File

@ -1108,12 +1108,12 @@ fn static_assert() {
#[allow(non_snake_case)]
pub fn set__x_text_zoom(&mut self, v: longhands::_x_text_zoom::computed_value::T) {
self.gecko.mAllowZoom = v.0;
self.gecko.mAllowZoomAndMinSize = v.0;
}
#[allow(non_snake_case)]
pub fn copy__x_text_zoom_from(&mut self, other: &Self) {
self.gecko.mAllowZoom = other.gecko.mAllowZoom;
self.gecko.mAllowZoomAndMinSize = other.gecko.mAllowZoomAndMinSize;
}
#[allow(non_snake_case)]
@ -1123,7 +1123,7 @@ fn static_assert() {
#[allow(non_snake_case)]
pub fn clone__x_text_zoom(&self) -> longhands::_x_text_zoom::computed_value::T {
longhands::_x_text_zoom::computed_value::T(self.gecko.mAllowZoom)
longhands::_x_text_zoom::computed_value::T(self.gecko.mAllowZoomAndMinSize)
}
<% impl_simple_type_with_conversion("font_language_override", "mFont.languageOverride") %>

View File

@ -223,8 +223,8 @@ impl<'a> Context<'a> {
pub fn maybe_zoom_text(&self, size: CSSPixelLength) -> CSSPixelLength {
// We disable zoom for <svg:text> by unsetting the
// -x-text-zoom property, which leads to a false value
// in mAllowZoom
if self.style().get_font().gecko.mAllowZoom {
// in mAllowZoomAndMinSize
if self.style().get_font().gecko.mAllowZoomAndMinSize {
self.device().zoom_text(Au::from(size)).into()
} else {
size