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:
Emilio Cobos Álvarez 2019-08-19 19:59:48 +00:00
parent bff52ae4a1
commit 9404ac89b7
8 changed files with 149 additions and 169 deletions

View file

@ -230,7 +230,7 @@ impl<'a> Context<'a> {
/// Apply text-zoom if enabled.
#[cfg(feature = "gecko")]
pub fn maybe_zoom_text(&self, size: NonNegativeLength) -> NonNegativeLength {
pub fn maybe_zoom_text(&self, size: CSSPixelLength) -> CSSPixelLength {
// We disable zoom for <svg:text> by unsetting the
// -x-text-zoom property, which leads to a false value
// in mAllowZoom
@ -243,7 +243,7 @@ impl<'a> Context<'a> {
/// (Servo doesn't do text-zoom)
#[cfg(feature = "servo")]
pub fn maybe_zoom_text(&self, size: NonNegativeLength) -> NonNegativeLength {
pub fn maybe_zoom_text(&self, size: CSSPixelLength) -> CSSPixelLength {
size
}
}