Backed out changeset 3c90c2d82cf4 (bug 1945637) for causing build bustages in gfxFontUtils.h. CLOSED TREE

This commit is contained in:
Stanca Serban
2025-02-05 17:14:07 +02:00
parent 84d41371c1
commit d8376bba5c
21 changed files with 191 additions and 220 deletions

View File

@@ -4219,6 +4219,8 @@ bool CanvasRenderingContext2D::SetFontInternalDisconnected(
// In the OffscreenCanvas case we don't have the context necessary to call
// GetFontStyleForServo(), as we do in the main-thread canvas context, so
// instead we borrow ParseFontShorthandForMatching to parse the attribute.
StyleComputedFontStyleDescriptor style(
StyleComputedFontStyleDescriptor::Normal());
StyleFontFamilyList list;
gfxFontStyle fontStyle;
float size = 0.0f;

View File

@@ -233,7 +233,7 @@ void Family::AddFaces(FontList* aList, const nsTArray<Face::InitData>& aFaces) {
if (f.mWeight.Min().IsBold()) {
slot |= kBoldMask;
}
if (!f.mStyle.Min().IsNormal()) {
if (f.mStyle.Min().IsItalic() || f.mStyle.Min().IsOblique()) {
slot |= kItalicMask;
}
if (slots[slot]) {
@@ -604,7 +604,7 @@ void Family::SetFacePtrs(FontList* aList, nsTArray<Pointer>& aFaces) {
if (f->mWeight.Min().IsBold()) {
slot |= kBoldMask;
}
if (!f->mStyle.Min().IsNormal()) {
if (f->mStyle.Min().IsItalic() || f->mStyle.Min().IsOblique()) {
slot |= kItalicMask;
}
if (!slots[slot].IsNull()) {

View File

@@ -1334,7 +1334,7 @@ void gfxFontEntry::GetVariationsForStyle(nsTArray<gfxFontVariation>& aResult,
// The 'ital' axis is normally a binary toggle; intermediate values
// can only be set using font-variation-settings.
aResult.AppendElement(gfxFontVariation{HB_TAG('i', 't', 'a', 'l'), 1.0f});
} else if (HasSlantVariation()) {
} else if (aStyle.style != StyleFontStyle::NORMAL && HasSlantVariation()) {
// Figure out what slant angle we should try to match from the
// requested style.
float angle = aStyle.style.SlantAngle();

View File

@@ -232,9 +232,7 @@ class gfxFontEntry {
bool IsLocalUserFont() const { return mIsLocalUserFont; }
bool IsFixedPitch() const { return mFixedPitch; }
bool IsItalic() const { return SlantStyle().Min().IsItalic(); }
// IsOblique returns true if the oblique angle is non-zero; 'oblique 0deg'
// is synonymous with 'normal' and will return false here.
bool IsOblique() const { return !IsUpright() && !IsItalic(); }
bool IsOblique() const { return SlantStyle().Min().IsOblique(); }
bool IsUpright() const { return SlantStyle().Min().IsNormal(); }
inline bool SupportsItalic(); // defined below, because of RangeFlags use
inline bool SupportsBold();

View File

@@ -1241,55 +1241,50 @@ static inline double StyleDistance(const mozilla::SlantStyleRange& aRange,
const double kNegate = 200.0;
if (aTargetStyle.IsNormal()) {
if (minStyle.IsItalic()) {
// italic is worse than any non-negative oblique;
// treat as a match in the wrong search direction
return kReverse;
}
if (minStyle.IsOblique()) {
// to distinguish oblique 0deg from normal, we add 1.0 to the angle
const double minAngle = minStyle.ObliqueAngle();
if (minAngle >= 0.0) {
return minAngle;
return 1.0 + minAngle;
}
const mozilla::FontSlantStyle maxStyle = aRange.Max();
const double maxAngle = maxStyle.ObliqueAngle();
if (maxAngle >= 0.0) {
// [min,max] range includes 0.0, so it's a perfect match
return 0.0;
// [min,max] range includes 0.0, so just return our minimum
return 1.0;
}
// negative oblique is even worse than italic
return kNegate - maxAngle;
}
// must be italic, which is worse than any non-negative oblique;
// treat as a match in the wrong search direction
MOZ_ASSERT(minStyle.IsItalic());
return kReverse;
}
const double kDefaultAngle = mozilla::FontSlantStyle::DEFAULT_OBLIQUE_DEGREES;
if (aTargetStyle.IsItalic()) {
MOZ_ASSERT(!minStyle.IsItalic()); // we checked for equality above
double targetAngle = kDefaultAngle;
double fallbackBias = 0.0;
if (!aItalicToObliqueFallback) {
// If 'font-style-synthesis: oblique-only' is applied, we should not use
// oblique as a fallback for italic, so we add a large "fallback bias" to
// all results here, and prefer an angle as close to zero as possible.
targetAngle = 0.0;
fallbackBias = kBadFallback;
}
if (minStyle.IsOblique()) {
const double minAngle = minStyle.ObliqueAngle();
if (minAngle >= targetAngle) {
// Add 1.0 to ensure italic vs non-italic never returns 0.0, even if the
// angle matches.
return fallbackBias + minAngle - targetAngle + 1.0;
if (minAngle >= kDefaultAngle) {
return 1.0 + (minAngle - kDefaultAngle);
}
const mozilla::FontSlantStyle maxStyle = aRange.Max();
const double maxAngle = maxStyle.ObliqueAngle();
if (maxAngle >= targetAngle) {
return fallbackBias + 1.0;
if (maxAngle >= kDefaultAngle) {
return 1.0;
}
if (maxAngle > 0.0) {
// wrong direction but still > 0, add bias of 100
return fallbackBias + kReverse + (targetAngle - maxAngle);
return kReverse + (kDefaultAngle - maxAngle);
}
// negative oblique angle, add bias of 300
return fallbackBias + kReverse + kNegate + (targetAngle - maxAngle);
return kReverse + kNegate + (kDefaultAngle - maxAngle);
}
// normal is worse than oblique > 0, but better than oblique <= 0
MOZ_ASSERT(minStyle.IsNormal());
return kNegate;
}
// target is oblique <angle>: four different cases depending on
@@ -1297,9 +1292,7 @@ static inline double StyleDistance(const mozilla::SlantStyleRange& aRange,
// of search
const double targetAngle = aTargetStyle.ObliqueAngle();
if (targetAngle >= kDefaultAngle) {
if (minStyle.IsItalic()) {
return kReverse + kNegate;
}
if (minStyle.IsOblique()) {
const double minAngle = minStyle.ObliqueAngle();
if (minAngle >= targetAngle) {
return minAngle - targetAngle;
@@ -1314,11 +1307,14 @@ static inline double StyleDistance(const mozilla::SlantStyleRange& aRange,
}
return kReverse + kNegate + (targetAngle - maxAngle);
}
if (targetAngle <= -kDefaultAngle) {
if (minStyle.IsItalic()) {
return kReverse + kNegate;
}
return kReverse + kNegate + 1.0;
}
if (targetAngle <= -kDefaultAngle) {
if (minStyle.IsOblique()) {
const mozilla::FontSlantStyle maxStyle = aRange.Max();
const double maxAngle = maxStyle.ObliqueAngle();
if (maxAngle <= targetAngle) {
@@ -1333,11 +1329,14 @@ static inline double StyleDistance(const mozilla::SlantStyleRange& aRange,
}
return kReverse + kNegate + (minAngle - targetAngle);
}
if (minStyle.IsItalic()) {
return kReverse + kNegate;
}
return kReverse + kNegate + 1.0;
}
if (targetAngle >= 0.0) {
if (minStyle.IsItalic()) {
return kReverse + kNegate - 1.0;
}
if (minStyle.IsOblique()) {
const double minAngle = minStyle.ObliqueAngle();
if (minAngle > targetAngle) {
return kReverse + (minAngle - targetAngle);
@@ -1352,11 +1351,14 @@ static inline double StyleDistance(const mozilla::SlantStyleRange& aRange,
}
return kReverse + kNegate + (targetAngle - maxAngle);
}
// last case: (targetAngle < 0.0 && targetAngle > kDefaultAngle)
if (minStyle.IsItalic()) {
return kReverse + kNegate - 2.0;
}
return kReverse + kNegate - 1.0;
}
// last case: (targetAngle < 0.0 && targetAngle > kDefaultAngle)
if (minStyle.IsOblique()) {
const mozilla::FontSlantStyle maxStyle = aRange.Max();
const double maxAngle = maxStyle.ObliqueAngle();
if (maxAngle < targetAngle) {
@@ -1370,6 +1372,11 @@ static inline double StyleDistance(const mozilla::SlantStyleRange& aRange,
return minAngle - targetAngle;
}
return kReverse + kNegate + (minAngle - targetAngle);
}
if (minStyle.IsItalic()) {
return kReverse + kNegate - 2.0;
}
return kReverse + kNegate - 1.0;
}
// stretch distance ==> [0,2000]

View File

@@ -62,8 +62,8 @@ testDescriptor("font-stretch", [
]);
testDescriptor("font-style", [
{ value: "normal", testDescriptors: ["normal", "oblique 10deg 40deg", "oblique 20deg 30deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
{ value: "italic", testDescriptors: ["italic", "oblique 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 5deg 10deg", "oblique 5deg", "normal", "oblique -60deg -30deg", "oblique -50deg -40deg" ] },
{ value: "normal", testDescriptors: ["normal", "oblique 0deg", "oblique 10deg 40deg", "oblique 20deg 30deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
{ value: "italic", testDescriptors: ["italic", "oblique 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 5deg 10deg", "oblique 5deg", "normal", "oblique 0deg", "oblique -60deg -30deg", "oblique -50deg -40deg" ] },
{ value: "oblique 20deg", testDescriptors: ["oblique 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 10deg", "italic", "oblique 0deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
{ value: "oblique 21deg", testDescriptors: ["oblique 21deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 20deg", "oblique 10deg", "italic", "oblique 0deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
{ value: "oblique 10deg", testDescriptors: ["oblique 10deg", "oblique 5deg", "oblique 15deg 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "italic", "oblique 0deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },

View File

@@ -595,6 +595,9 @@ bool FontFaceImpl::GetAttributes(gfxUserFontAttributes& aAttr) {
if (Servo_FontFaceRule_GetFontStyle(data, &styleDesc)) {
aAttr.mRangeFlags &= ~gfxFontEntry::RangeFlags::eAutoSlantStyle;
switch (styleDesc.tag) {
case StyleComputedFontStyleDescriptor::Tag::Normal:
aAttr.mStyle = SlantStyleRange(FontSlantStyle::NORMAL);
break;
case StyleComputedFontStyleDescriptor::Tag::Italic:
aAttr.mStyle = SlantStyleRange(FontSlantStyle::ITALIC);
break;

View File

@@ -1097,8 +1097,12 @@ inline bool StyleFontWeight::IsBold() const { return *this >= BOLD_THRESHOLD; }
inline bool StyleFontStyle::IsItalic() const { return *this == ITALIC; }
inline bool StyleFontStyle::IsOblique() const {
return !IsItalic() && !IsNormal();
}
inline float StyleFontStyle::ObliqueAngle() const {
MOZ_ASSERT(!IsItalic());
MOZ_ASSERT(IsOblique());
return ToFloat();
}

View File

@@ -379,6 +379,7 @@ impl FontStretchRange {
#[derive(Clone, Debug, PartialEq, ToShmem)]
#[allow(missing_docs)]
pub enum FontStyle {
Normal,
Italic,
Oblique(Angle, Angle),
}
@@ -388,6 +389,7 @@ pub enum FontStyle {
#[repr(u8)]
#[allow(missing_docs)]
pub enum ComputedFontStyleDescriptor {
Normal,
Italic,
Oblique(f32, f32),
}
@@ -397,14 +399,9 @@ impl Parse for FontStyle {
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
// We parse 'normal' explicitly here to distinguish it from 'oblique 0deg',
// because we must not accept a following angle.
if input.try_parse(|i| i.expect_ident_matching("normal")).is_ok() {
return Ok(FontStyle::Oblique(Angle::zero(), Angle::zero()));
}
let style = SpecifiedFontStyle::parse(context, input)?;
Ok(match style {
GenericFontStyle::Normal => FontStyle::Normal,
GenericFontStyle::Italic => FontStyle::Italic,
GenericFontStyle::Oblique(angle) => {
let second_angle = input
@@ -423,13 +420,9 @@ impl ToCss for FontStyle {
W: fmt::Write,
{
match *self {
FontStyle::Normal => dest.write_str("normal"),
FontStyle::Italic => dest.write_str("italic"),
FontStyle::Oblique(ref first, ref second) => {
// Not first.is_zero() because we don't want to serialize
// `oblique calc(0deg)` as `normal`.
if *first == Angle::zero() && first == second {
return dest.write_str("normal");
}
dest.write_str("oblique")?;
if *first != SpecifiedFontStyle::default_angle() || first != second {
dest.write_char(' ')?;
@@ -449,6 +442,7 @@ impl FontStyle {
/// Returns a computed font-style descriptor.
pub fn compute(&self) -> ComputedFontStyleDescriptor {
match *self {
FontStyle::Normal => ComputedFontStyleDescriptor::Normal,
FontStyle::Italic => ComputedFontStyleDescriptor::Italic,
FontStyle::Oblique(ref first, ref second) => {
let (min, max) = sort_range(

View File

@@ -1050,8 +1050,8 @@ impl ToComputedValue for specified::MathDepth {
/// - Use a signed 8.8 fixed-point value (representable range -128.0..128)
///
/// Values of <angle> below -90 or above 90 are not permitted, so we use an out
/// of range value to represent `italic`.
/// Values of <angle> below -90 or above 90 not permitted, so we use out of
/// range values to represent normal | oblique
pub const FONT_STYLE_FRACTION_BITS: u16 = 8;
/// This is an alias which is useful mostly as a cbindgen / C++ inference
@@ -1060,9 +1060,10 @@ pub type FontStyleFixedPoint = FixedPoint<i16, FONT_STYLE_FRACTION_BITS>;
/// The computed value of `font-style`.
///
/// - Define angle of zero degrees as `normal`
/// - Define out-of-range value 100 degrees as `italic`
/// - Other values represent `oblique <angle>`
/// - Define out of range values min value (-128.0) as meaning 'normal'
/// - Define max value (127.99609375) as 'italic'
/// - Other values represent 'oblique <angle>'
/// - Note that 'oblique 0deg' is distinct from 'normal' (should it be?)
///
/// cbindgen:derive-lt
/// cbindgen:derive-lte
@@ -1085,14 +1086,13 @@ pub type FontStyleFixedPoint = FixedPoint<i16, FONT_STYLE_FRACTION_BITS>;
pub struct FontStyle(FontStyleFixedPoint);
impl FontStyle {
/// The `normal` keyword, equal to `oblique` with angle zero.
/// The normal keyword.
pub const NORMAL: FontStyle = FontStyle(FontStyleFixedPoint {
value: 0 << FONT_STYLE_FRACTION_BITS,
value: 100 << FONT_STYLE_FRACTION_BITS,
});
/// The italic keyword.
pub const ITALIC: FontStyle = FontStyle(FontStyleFixedPoint {
value: 100 << FONT_STYLE_FRACTION_BITS,
value: 101 << FONT_STYLE_FRACTION_BITS,
});
/// The default angle for `font-style: oblique`.
@@ -1121,6 +1121,7 @@ impl FontStyle {
/// Returns the oblique angle for this style.
pub fn oblique_degrees(&self) -> f32 {
debug_assert_ne!(*self, Self::NORMAL);
debug_assert_ne!(*self, Self::ITALIC);
self.0.to_float()
}
@@ -1137,12 +1138,12 @@ impl ToCss for FontStyle {
if *self == Self::ITALIC {
return dest.write_str("italic");
}
dest.write_str("oblique")?;
if *self != Self::OBLIQUE {
// It's not the default oblique amount, so append the angle in degrees.
dest.write_char(' ')?;
Angle::from_degrees(self.oblique_degrees()).to_css(dest)?;
if *self == Self::OBLIQUE {
return dest.write_str("oblique");
}
dest.write_str("oblique ")?;
let angle = Angle::from_degrees(self.oblique_degrees());
angle.to_css(dest)?;
Ok(())
}
}
@@ -1152,6 +1153,12 @@ impl ToAnimatedValue for FontStyle {
#[inline]
fn to_animated_value(self, _: &crate::values::animated::Context) -> Self::AnimatedValue {
if self == Self::NORMAL {
// This allows us to animate between normal and oblique values. Per spec,
// https://drafts.csswg.org/css-fonts-4/#font-style-prop:
// Animation type: by computed value type; 'normal' animates as 'oblique 0deg'
return generics::FontStyle::Oblique(Angle::from_degrees(0.0));
}
if self == Self::ITALIC {
return generics::FontStyle::Italic;
}
@@ -1161,8 +1168,16 @@ impl ToAnimatedValue for FontStyle {
#[inline]
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
match animated {
generics::FontStyle::Normal => Self::NORMAL,
generics::FontStyle::Italic => Self::ITALIC,
generics::FontStyle::Oblique(ref angle) => Self::oblique(angle.degrees()),
generics::FontStyle::Oblique(ref angle) => {
if angle.degrees() == 0.0 {
// Reverse the conversion done in to_animated_value()
Self::NORMAL
} else {
Self::oblique(angle.degrees())
}
},
}
}
}

View File

@@ -6,7 +6,7 @@
use crate::parser::{Parse, ParserContext};
use crate::values::animated::ToAnimatedZero;
use crate::{One, Zero};
use crate::One;
use byteorder::{BigEndian, ReadBytesExt};
use cssparser::Parser;
use std::fmt::{self, Write};
@@ -208,18 +208,13 @@ impl Parse for FontTag {
ToResolvedValue,
ToShmem,
)]
#[value_info(other_values = "normal")]
pub enum FontStyle<Angle> {
// Note that 'oblique 0deg' represents 'normal', and will serialize as such.
#[value_info(starts_with_keyword)]
Oblique(Angle),
#[animation(error)]
Normal,
#[animation(error)]
Italic,
}
impl<Angle: Zero> FontStyle<Angle> {
/// Return the 'normal' value, which is represented as 'oblique 0deg'.
pub fn normal() -> Self { Self::Oblique(Angle::zero()) }
#[value_info(starts_with_keyword)]
Oblique(Angle),
}
/// A generic value for the `font-size-adjust` property.

View File

@@ -257,19 +257,14 @@ impl ToCss for SpecifiedFontStyle {
W: Write,
{
match *self {
generics::FontStyle::Normal => dest.write_str("normal"),
generics::FontStyle::Italic => dest.write_str("italic"),
generics::FontStyle::Oblique(ref angle) => {
// Not angle.is_zero() because we don't want to serialize
// `oblique calc(0deg)` as `normal`.
if *angle == Angle::zero() {
dest.write_str("normal")?;
} else {
dest.write_str("oblique")?;
if *angle != Self::default_angle() {
dest.write_char(' ')?;
angle.to_css(dest)?;
}
}
Ok(())
},
}
@@ -282,7 +277,7 @@ impl Parse for SpecifiedFontStyle {
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
Ok(try_match_ident_ignore_ascii_case! { input,
"normal" => generics::FontStyle::normal(),
"normal" => generics::FontStyle::Normal,
"italic" => generics::FontStyle::Italic,
"oblique" => {
let angle = input.try_parse(|input| Self::parse_angle(context, input))
@@ -299,12 +294,16 @@ impl ToComputedValue for SpecifiedFontStyle {
fn to_computed_value(&self, _: &Context) -> Self::ComputedValue {
match *self {
Self::Normal => computed::FontStyle::NORMAL,
Self::Italic => computed::FontStyle::ITALIC,
Self::Oblique(ref angle) => computed::FontStyle::oblique(angle.degrees()),
}
}
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
if *computed == computed::FontStyle::NORMAL {
return Self::Normal;
}
if *computed == computed::FontStyle::ITALIC {
return Self::Italic;
}
@@ -376,7 +375,7 @@ impl FontStyle {
/// Return the `normal` value.
#[inline]
pub fn normal() -> Self {
FontStyle::Specified(generics::FontStyle::normal())
FontStyle::Specified(generics::FontStyle::Normal)
}
system_font_methods!(FontStyle, font_style);

View File

@@ -1025,7 +1025,8 @@ renaming_overrides_prefixing = true
SERVO_FIXED_POINT_HELPERS(StyleFontStyle, int16_t, StyleFONT_STYLE_FRACTION_BITS);
bool IsNormal() const { return *this == NORMAL; }
inline bool IsItalic() const;
inline float ObliqueAngle() const; // Not for use when IsItalic() is true
inline bool IsOblique() const;
inline float ObliqueAngle() const; // Only for use when IsOblique() is true
inline float SlantAngle() const; // Returns angle for any font-style, including
// normal/italic as well as explicit oblique
"""
@@ -1075,12 +1076,6 @@ renaming_overrides_prefixing = true
float ToMilliseconds() const { return seconds * 1000.0f; }
"""
"ComputedFontStyleDescriptor" = """
inline static StyleComputedFontStyleDescriptor Normal() {
return StyleComputedFontStyleDescriptor::Oblique(0, 0);
}
"""
"FontFaceSourceTechFlags" = """
inline static StyleFontFaceSourceTechFlags Empty() {
return StyleFontFaceSourceTechFlags{0};

View File

@@ -5429,11 +5429,11 @@ pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue(
longhands::font_size::SpecifiedValue::from_html_size(value as u8)
},
FontStyle => {
specified::FontStyle::Specified(if value == structs::NS_FONT_STYLE_ITALIC {
style::values::specified::FontStyle::Specified(if value == structs::NS_FONT_STYLE_ITALIC {
FontStyle::Italic
} else {
debug_assert_eq!(value, structs::NS_FONT_STYLE_NORMAL);
FontStyle::normal()
FontStyle::Normal
})
},
FontWeight => longhands::font_weight::SpecifiedValue::from_gecko_keyword(value),
@@ -8555,6 +8555,7 @@ pub unsafe extern "C" fn Servo_ParseFontShorthandForMatching(
};
*style = match *specified_font_style {
GenericFontStyle::Normal => FontStyle::NORMAL,
GenericFontStyle::Italic => FontStyle::ITALIC,
GenericFontStyle::Oblique(ref angle) => FontStyle::oblique(angle.degrees()),
};

View File

@@ -1,3 +1,11 @@
[font-style-computed.html]
expected:
if (os == "android") and fission: [OK, TIMEOUT]
[Property font-style value 'oblique calc(30deg + (sign(20cqw - 10px) * 5deg))']
expected: FAIL
[Property font-style value 'oblique 0deg']
expected: FAIL
[Property font-style value 'oblique calc(10deg - 10deg)']
expected: FAIL

View File

@@ -1,3 +1,8 @@
[font-style-valid.html]
expected:
if (os == "android") and fission: [OK, TIMEOUT]
[e.style['font-style'\] = "oblique calc(30deg + (sign(2cqw - 10px) * 5deg))" should set the property value]
expected: FAIL
[e.style['font-style'\] = "oblique 0deg" should set the property value]
expected: FAIL

View File

@@ -0,0 +1,3 @@
[font-style-parsing.html]
[Font-style (computed): 'oblique' followed by zero degrees is valid]
expected: FAIL

View File

@@ -1,54 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Fonts: parsing 'normal' in the font-style descriptor</title>
<link rel="author" title="Jonathan Kew" href="mailto:jkew@mozilla.org"/>
<link rel="help" href="https://drafts.csswg.org/css-fonts/#descdef-font-face-font-style">
<meta name="assert" content="Ensure that although 'normal' equates to 'oblique 0deg', a following <angle> is not allowed.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<style>
@font-face {
font-family: test1;
font-style: normal;
src: local(Ahem);
}
@font-face {
font-family: test2;
font-style: oblique 0deg;
src: local(Ahem);
}
@font-face {
font-family: test3;
font-style: oblique 0deg 10deg;
src: local(Ahem);
}
@font-face {
font-family: test4;
font-style: normal 10deg;
src: local(Ahem);
}
</style>
<script>
promise_test(async (t) => {
const fonts = await document.fonts.load("12px test1");
assert_equals(fonts[0].style, "normal", "'normal' serializes as specified");
});
promise_test(async (t) => {
const fonts = await document.fonts.load("12px test2");
assert_equals(fonts[0].style, "normal", "'oblique 0deg' serializes as 'normal'");
});
promise_test(async (t) => {
const fonts = await document.fonts.load("12px test3");
assert_equals(fonts[0].style, "oblique 0deg 10deg", "oblique range serializes as specified");
});
promise_test(async (t) => {
const fonts = await document.fonts.load("12px test4");
assert_equals(fonts[0].style, "normal", "'normal 10deg' is not a valid range");
});
</script>
</body>
</html>

View File

@@ -33,8 +33,6 @@ test_computed_value('font-style', 'oblique calc(10deg - 10deg)', 'normal');
test_computed_value('font-style', 'oblique 10deg');
test_computed_value('font-style', 'oblique -10deg');
test_computed_value('font-style', 'oblique 14deg', 'oblique');
test_computed_value('font-style', 'oblique -14deg');
test_computed_value('font-style', 'oblique -90deg');
test_computed_value('font-style', 'oblique 90deg');
test_computed_value('font-style', 'oblique 10grad', 'oblique 9deg');

View File

@@ -20,8 +20,6 @@ test_valid_value('font-style', 'oblique calc(10deg - 10deg)', 'oblique calc(0deg
test_valid_value('font-style', 'oblique 10deg');
test_valid_value('font-style', 'oblique -10deg');
test_valid_value('font-style', 'oblique 14deg', 'oblique');
test_valid_value('font-style', 'oblique -14deg');
test_valid_value('font-style', 'oblique -90deg');
test_valid_value('font-style', 'oblique 90deg');
test_valid_value('font-style', 'oblique 10grad');

View File

@@ -126,7 +126,7 @@
}
function createFontFaceRules(fontFaceFamily, descriptorName, expectedMatch, unexpectedMatch) {
dynamicStyles.innerHTML =
"@font-face { font-family: " + fontFaceFamily + "; src: url('./resources/csstest-weights-100-kerned.ttf'); " + descriptorName + ": " + expectedMatch + "; }" +
"@font-face { font-family: " + fontFaceFamily + "; src: url('./resources/csstest-weights-100-kerned.ttf'); "+ descriptorName + ": " + expectedMatch + "; }" +
"@font-face { font-family: " + fontFaceFamily + "; src: url('./resources/csstest-weights-200-kerned.ttf'); " + descriptorName + ": " + unexpectedMatch + "; }";
return Promise.all([
@@ -179,8 +179,8 @@
]);
testDescriptor("font-style", [
{ value: "normal", testDescriptors: ["normal", "oblique 10deg 40deg", "oblique 20deg 30deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
{ value: "italic", testDescriptors: ["italic", "oblique 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 5deg 10deg", "oblique 5deg", "normal", "oblique -60deg -30deg", "oblique -50deg -40deg" ] },
{ value: "normal", testDescriptors: ["normal", "oblique 0deg", "oblique 10deg 40deg", "oblique 20deg 30deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
{ value: "italic", testDescriptors: ["italic", "oblique 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 5deg 10deg", "oblique 5deg", "normal", "oblique 0deg", "oblique -60deg -30deg", "oblique -50deg -40deg" ] },
{ value: "oblique 20deg", testDescriptors: ["oblique 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 10deg", "italic", "oblique 0deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
{ value: "oblique 21deg", testDescriptors: ["oblique 21deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "oblique 20deg", "oblique 10deg", "italic", "oblique 0deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },
{ value: "oblique 10deg", testDescriptors: ["oblique 10deg", "oblique 5deg", "oblique 15deg 20deg", "oblique 30deg 60deg", "oblique 40deg 50deg", "italic", "oblique 0deg", "oblique -50deg -20deg", "oblique -40deg -30deg" ] },