mirror of
https://github.com/servo/servo.git
synced 2025-08-12 08:55:32 +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
|
@ -1146,7 +1146,7 @@ fn static_assert() {
|
|||
}
|
||||
|
||||
pub fn set_font_size(&mut self, v: FontSize) {
|
||||
use crate::values::generics::font::KeywordSize;
|
||||
use crate::values::specified::font::KeywordSize;
|
||||
|
||||
let size = v.size();
|
||||
self.gecko.mScriptUnconstrainedSize = size.0;
|
||||
|
@ -1167,7 +1167,7 @@ fn static_assert() {
|
|||
KeywordSize::XXXLarge => structs::NS_STYLE_FONT_SIZE_XXXLARGE,
|
||||
} as u8;
|
||||
self.gecko.mFontSizeFactor = info.factor;
|
||||
self.gecko.mFontSizeOffset = info.offset.0.to_i32_au();
|
||||
self.gecko.mFontSizeOffset = info.offset.to_i32_au();
|
||||
} else {
|
||||
self.gecko.mFontSizeKeyword = structs::NS_STYLE_FONT_SIZE_NO_KEYWORD as u8;
|
||||
self.gecko.mFontSizeFactor = 1.;
|
||||
|
@ -1176,7 +1176,7 @@ fn static_assert() {
|
|||
}
|
||||
|
||||
pub fn clone_font_size(&self) -> FontSize {
|
||||
use crate::values::generics::font::{KeywordInfo, KeywordSize};
|
||||
use crate::values::specified::font::{KeywordInfo, KeywordSize};
|
||||
let size = Au(self.gecko.mSize).into();
|
||||
let kw = match self.gecko.mFontSizeKeyword as u32 {
|
||||
structs::NS_STYLE_FONT_SIZE_XXSMALL => KeywordSize::XXSmall,
|
||||
|
|
|
@ -401,7 +401,7 @@ ${helpers.predefined_type(
|
|||
is_system_font: true,
|
||||
},
|
||||
font_size: FontSize {
|
||||
size: cx.maybe_zoom_text(Au(system.size).into()),
|
||||
size: NonNegative(cx.maybe_zoom_text(Au(system.size).into())),
|
||||
keyword_info: None
|
||||
},
|
||||
font_weight,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue