зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #18335 - stylo: Compute font-size calcs against appropriate base size (from Manishearth:stylo-calc-anim); r=birtles
r=birtles https://bugzilla.mozilla.org/show_bug.cgi?id=1394302 Source-Repo: https://github.com/servo/servo Source-Revision: 60daf543524e6c5e6dfb5e309ceae638425f010d --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : f8d2fd56656732f8ae4512d2718d32cfa7f21871
This commit is contained in:
Родитель
d57b5bd646
Коммит
b0873633b7
|
@ -859,7 +859,7 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
base_size.resolve(context).scale_by(pc.0).into()
|
||||
}
|
||||
SpecifiedValue::Length(LengthOrPercentage::Calc(ref calc)) => {
|
||||
let calc = calc.to_computed_value_zoomed(context);
|
||||
let calc = calc.to_computed_value_zoomed(context, base_size);
|
||||
calc.to_used_value(Some(base_size.resolve(context))).unwrap().into()
|
||||
}
|
||||
SpecifiedValue::Keyword(ref key, fraction) => {
|
||||
|
|
|
@ -217,7 +217,8 @@ impl ToCss for 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
|
||||
fn to_computed_value_with_zoom<F>(&self, context: &Context, zoom_fn: F,
|
||||
base_size: FontBaseSize) -> CalcLengthOrPercentage
|
||||
where F: Fn(Au) -> Au {
|
||||
let mut length = Au(0);
|
||||
|
||||
|
@ -239,7 +240,7 @@ impl specified::CalcLengthOrPercentage {
|
|||
self.ex.map(FontRelativeLength::Ex),
|
||||
self.rem.map(FontRelativeLength::Rem)] {
|
||||
if let Some(val) = *val {
|
||||
length += val.to_computed_value(context, FontBaseSize::CurrentStyle);
|
||||
length += val.to_computed_value(context, base_size);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -251,8 +252,8 @@ impl 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.into()).0)
|
||||
pub fn to_computed_value_zoomed(&self, context: &Context, base_size: FontBaseSize) -> CalcLengthOrPercentage {
|
||||
self.to_computed_value_with_zoom(context, |abs| context.maybe_zoom_text(abs.into()).0, base_size)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,7 +261,8 @@ 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)
|
||||
// normal properties don't zoom, and compute em units against the current style's font-size
|
||||
self.to_computed_value_with_zoom(context, |abs| abs, FontBaseSize::CurrentStyle)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -80,6 +80,7 @@ impl ToCss for FontRelativeLength {
|
|||
}
|
||||
|
||||
/// A source to resolve font-relative units against
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub enum FontBaseSize {
|
||||
/// Use the font-size of the current element
|
||||
CurrentStyle,
|
||||
|
|
|
@ -112,7 +112,7 @@ impl ToComputedValue for LineHeight {
|
|||
).into()
|
||||
}
|
||||
LengthOrPercentage::Calc(ref calc) => {
|
||||
let computed_calc = calc.to_computed_value_zoomed(context);
|
||||
let computed_calc = calc.to_computed_value_zoomed(context, FontBaseSize::CurrentStyle);
|
||||
let font_relative_length =
|
||||
FontRelativeLength::Em(computed_calc.percentage())
|
||||
.to_computed_value(
|
||||
|
|
Загрузка…
Ссылка в новой задаче