stylo: Handle text-zoom for font-size

This commit is contained in:
Manish Goregaokar 2017-07-28 17:32:30 -07:00 committed by Manish Goregaokar
parent de5f6f19bd
commit 16d46eaf7a
5 changed files with 52 additions and 15 deletions

View file

@ -228,14 +228,14 @@ impl ToCss for CalcLengthOrPercentage {
}
}
impl ToComputedValue for specified::CalcLengthOrPercentage {
type ComputedValue = CalcLengthOrPercentage;
fn to_computed_value(&self, context: &Context) -> CalcLengthOrPercentage {
impl specified::CalcLengthOrPercentage {
/// Compute the value, zooming any absolute units by the zoom function.
fn to_computed_value_with_zoom<F>(&self, context: &Context, zoom_fn: F) -> CalcLengthOrPercentage
where F: Fn(Au) -> Au {
let mut length = Au(0);
if let Some(absolute) = self.absolute {
length += absolute;
length += zoom_fn(absolute);
}
for val in &[self.vw.map(ViewportPercentageLength::Vw),
@ -263,6 +263,19 @@ impl ToComputedValue for specified::CalcLengthOrPercentage {
}
}
/// Compute font-size or line-height taking into account text-zoom if necessary.
pub fn to_computed_value_zoomed(&self, context: &Context) -> CalcLengthOrPercentage {
self.to_computed_value_with_zoom(context, |abs| context.maybe_zoom_text(abs))
}
}
impl ToComputedValue for specified::CalcLengthOrPercentage {
type ComputedValue = CalcLengthOrPercentage;
fn to_computed_value(&self, context: &Context) -> CalcLengthOrPercentage {
self.to_computed_value_with_zoom(context, |abs| abs)
}
#[inline]
fn from_computed_value(computed: &CalcLengthOrPercentage) -> Self {
specified::CalcLengthOrPercentage {