mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
style: Don't clamp font-size calc() factors too early.
These two bugs (bug 1572738 and bug 1572451) are stylo regressions. When font-family changes, we try to recompute the font-size with a length / percentage combinations in case the generic family changes, so the user preferences are kept. When calc() is involved, we clamp to non-negative too early, via NonNegativeLength::scale_by. I think we should generally dump this "try to track font-size across calc()" thingie, as as various comments note it is not quite perfect, and it's not clear how it should work in presence of min()/max(). This patch fixes the issue and simplifies code a bit, I may consider removing this altogether in a follow-up. Differential Revision: https://phabricator.services.mozilla.com/D41776
This commit is contained in:
parent
bff52ae4a1
commit
9404ac89b7
8 changed files with 149 additions and 169 deletions
|
@ -297,7 +297,7 @@ impl specified::CalcLengthPercentage {
|
|||
) -> LengthPercentage {
|
||||
self.to_computed_value_with_zoom(
|
||||
context,
|
||||
|abs| context.maybe_zoom_text(abs.into()).0,
|
||||
|abs| context.maybe_zoom_text(abs.into()),
|
||||
base_size,
|
||||
)
|
||||
}
|
||||
|
@ -360,8 +360,8 @@ impl LengthPercentage {
|
|||
self.unclamped_length().px() == 0.0 && self.percentage.0 == 0.0
|
||||
}
|
||||
|
||||
// CSSFloat doesn't implement Hash, so does CSSPixelLength. Therefore, we still use Au as the
|
||||
// hash key.
|
||||
// CSSFloat doesn't implement Hash, so does CSSPixelLength. Therefore, we
|
||||
// still use Au as the hash key.
|
||||
#[allow(missing_docs)]
|
||||
pub fn to_hash_key(&self) -> (Au, NotNan<f32>) {
|
||||
(
|
||||
|
@ -840,14 +840,6 @@ impl NonNegativeLength {
|
|||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// Scale this NonNegativeLength.
|
||||
/// We scale NonNegativeLength by zero if the factor is negative because it doesn't
|
||||
/// make sense to scale a negative factor on a non-negative length.
|
||||
#[inline]
|
||||
pub fn scale_by(&self, factor: f32) -> Self {
|
||||
Self::new(self.0.px() * factor.max(0.))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Length> for NonNegativeLength {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue