mirror of
https://github.com/servo/servo.git
synced 2025-08-15 10:25:32 +01:00
style: Update font-weight property and descriptor to css-fonts-4.
Bug: 1454596 Reviewed-by: xidorn MozReview-Commit-ID: 27aS2UrgXjs
This commit is contained in:
parent
76a14d6a64
commit
bc1126ee8c
10 changed files with 199 additions and 141 deletions
|
@ -873,20 +873,6 @@ impl ToAnimatedZero for MaxLength {
|
|||
fn to_animated_zero(&self) -> Result<Self, ()> { Err(()) }
|
||||
}
|
||||
|
||||
/// <http://dev.w3.org/csswg/css-transitions/#animtype-font-weight>
|
||||
impl Animate for FontWeight {
|
||||
#[inline]
|
||||
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
||||
let a = self.0 as f64;
|
||||
let b = other.0 as f64;
|
||||
const NORMAL: f64 = 400.;
|
||||
let (this_weight, other_weight) = procedure.weights();
|
||||
let weight = (a - NORMAL) * this_weight + (b - NORMAL) * other_weight + NORMAL;
|
||||
let weight = (weight.max(100.).min(900.) / 100.).round() * 100.;
|
||||
Ok(FontWeight(weight as u16))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToAnimatedZero for FontWeight {
|
||||
#[inline]
|
||||
fn to_animated_zero(&self) -> Result<Self, ()> {
|
||||
|
@ -897,8 +883,7 @@ impl ToAnimatedZero for FontWeight {
|
|||
/// <https://drafts.csswg.org/css-fonts/#font-stretch-prop>
|
||||
impl Animate for FontStretch {
|
||||
#[inline]
|
||||
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()>
|
||||
{
|
||||
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
||||
let from = f64::from(*self);
|
||||
let to = f64::from(*other);
|
||||
let normal = f64::from(FontStretch::Normal);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue