mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Move font-size-adjust outside of mako
This commit is contained in:
parent
cbf2ac35f7
commit
e73f2377cf
5 changed files with 135 additions and 121 deletions
|
@ -7,7 +7,8 @@
|
|||
use app_units::Au;
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
use values::animated::ToAnimatedValue;
|
||||
use values::CSSFloat;
|
||||
use values::animated::{ToAnimatedValue, ToAnimatedZero};
|
||||
use values::computed::{Context, NonNegativeLength, ToComputedValue};
|
||||
use values::specified::font as specified;
|
||||
use values::specified::length::{FontBaseSize, NoCalcLength};
|
||||
|
@ -212,6 +213,58 @@ impl ToAnimatedValue for FontSize {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss)]
|
||||
/// Preserve the readability of text when font fallback occurs
|
||||
pub enum FontSizeAdjust {
|
||||
#[animation(error)]
|
||||
/// None variant
|
||||
None,
|
||||
/// Number variant
|
||||
Number(CSSFloat),
|
||||
}
|
||||
|
||||
impl FontSizeAdjust {
|
||||
#[inline]
|
||||
/// Default value of font-size-adjust
|
||||
pub fn none() -> Self {
|
||||
FontSizeAdjust::None
|
||||
}
|
||||
|
||||
/// Get font-size-adjust with float number
|
||||
pub fn from_gecko_adjust(gecko: f32) -> Self {
|
||||
if gecko == -1.0 {
|
||||
FontSizeAdjust::None
|
||||
} else {
|
||||
FontSizeAdjust::Number(gecko)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToAnimatedZero for FontSizeAdjust {
|
||||
#[inline]
|
||||
// FIXME(emilio): why?
|
||||
fn to_animated_zero(&self) -> Result<Self, ()> {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToAnimatedValue for FontSizeAdjust {
|
||||
type AnimatedValue = Self;
|
||||
|
||||
#[inline]
|
||||
fn to_animated_value(self) -> Self {
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
|
||||
match animated {
|
||||
FontSizeAdjust::Number(number) => FontSizeAdjust::Number(number.max(0.)),
|
||||
_ => animated
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToComputedValue for specified::MozScriptMinSize {
|
||||
type ComputedValue = MozScriptMinSize;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue