Bug 1788645: Do not reset font-weight/font-style when mathvariant is specified. r=emilio

In the past, mathvariant was cancelling the effect of legacy
fontstyle/fontweight attributes by resetting the font-style/font-weight
properties. These legacy attributes have been removed in bug 1783841,
so remove this hack from Stylo and add corresponding WPT test.

Differential Revision: https://phabricator.services.mozilla.com/D156174
This commit is contained in:
Frederic Wang 2022-09-03 07:09:44 +00:00
parent 0d769acdfa
commit e5e1ea3245
3 changed files with 93 additions and 14 deletions

View File

@ -363,19 +363,6 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
}
}
/// When mathvariant is not "none", font-weight and font-style are
/// both forced to "normal".
#[cfg(feature = "gecko")]
fn adjust_for_mathvariant(&mut self) {
use crate::properties::longhands::_moz_math_variant::computed_value::T as MozMathVariant;
use crate::values::computed::font::{FontWeight, FontStyle};
if self.style.get_font().clone__moz_math_variant() != MozMathVariant::None {
let font_style = self.style.mutate_font();
font_style.set_font_weight(FontWeight::NORMAL);
font_style.set_font_style(FontStyle::NORMAL);
}
}
/// This implements an out-of-date spec. The new spec moves the handling of
/// this to layout, which Gecko implements but Servo doesn't.
///
@ -875,7 +862,6 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
#[cfg(feature = "gecko")]
{
self.adjust_for_table_text_align();
self.adjust_for_mathvariant();
self.adjust_for_justify_items();
}
#[cfg(feature = "servo")]

View File

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>mathvariant attribute and font-style/font-weight (reference)</title>
<style>
.italic { font-style: italic; }
.bold { font-weight: bold; }
</style>
</head>
<body>
<p>This test passes if you see six lines of text (italic, italic, bold, bold, bold italic and bold italic) with the corresponding style applied:</p>
<p>
<math>
<mtext class="italic">italic</mtext>
</math>
</p>
<p>
<math>
<mtext class="italic">italic</mtext>
</math>
</p>
<p>
<math>
<mtext class="bold">bold</mtext>
</math>
</p>
<p>
<math>
<mtext class="bold">bold</mtext>
</math>
</p>
<p>
<math>
<mtext class="bold italic">bold italic</mtext>
</math>
</p>
<p>
<math>
<mtext class="bold italic">bold italic</mtext>
</math>
</p>
</body>
</html>

View File

@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>mathvariant attribute and font-style/font-weight</title>
<link rel="help" href="https://w3c.github.io/mathml-core/#css-styling">
<link rel="help" href="https://w3c.github.io/mathml-core/#the-mathvariant-attribute">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1788645">
<link rel="match" href="mathvariant-font-style-font-weight-ref.html"/>
<meta name="assert" content="Verify that a mathvariant attribute does not cancel the effect of font-style/font-weight.">
<style>
.italic { font-style: italic; }
.bold { font-weight: bold; }
</style>
</head>
<body>
<p>This test passes if you see six lines of text (italic, italic, bold, bold, bold italic and bold italic) with the corresponding style applied:</p>
<p>
<math mathvariant="normal">
<mtext class="italic">italic</mtext>
</math>
</p>
<p>
<math>
<mtext mathvariant="normal" class="italic">italic</mtext>
</math>
</p>
<p>
<math mathvariant="normal">
<mtext class="bold">bold</mtext>
</math>
</p>
<p>
<math>
<mtext mathvariant="normal" class="bold">bold</mtext>
</math>
</p>
<p>
<math mathvariant="normal">
<mtext class="bold italic">bold italic</mtext>
</math>
</p>
<p>
<math>
<mtext mathvariant="normal" class="bold italic">bold italic</mtext>
</math>
</p>
</body>
</html>