Closed Bug 1355707 Opened 7 years ago Closed 7 years ago

stylo: relative font-size applied to defaults should cascade too

Categories

(Core :: CSS Parsing and Computation, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: manishearth, Assigned: manishearth)

References

Details

Attachments

(1 file)

Not only do we preserve keyword-ness of font sizes when cascading, we also preserve the usage of font-relative units. font-size: medium computes to different values based on the generic family, but also `font-size: 0.9em` will compute to different values based on the family provided it was applied to a keyword font size.

<body style="font-family: serif; /* (default) font-size: medium */"> <!-- computes to 16px -->
  <div style="font-size: 0.9em"> <!-- computes to 14.4px -->
    <span style="font-family: monospace"> <!-- computes to 0.9*13px = 11.7px, NOT 14.4px-->

Gecko does this by this complicated rule tree walking. We can instead expand the infrastructure in bug 1341775 and store a ratio with the keyword. Specifying em will change the ratio.

(This will make it not work for rem/ex/ch but we don't really care about those)
Comment on attachment 8857339 [details]
Bug 1355707 - stylo: Cascade relative font-sizes applied to keyword sizes;

https://reviewboard.mozilla.org/r/129320/#review131872

::: servo/components/style/properties/gecko.mako.rs:82
(Diff revision 1)
>      % endfor
>  
>      custom_properties: Option<Arc<ComputedValuesMap>>,
>      pub writing_mode: WritingMode,
>      pub root_font_size: Au,
> -    pub font_size_keyword: Option<longhands::font_size::KeywordSize>,
> +    pub font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>,

Maybe "font_size_keyword" isn't the right name any more.  And it would be nice to mention something about generic fonts.  What about "keyword_based_generic_font_size", if that's not too long?  Also please add a comment describing what the two elements of the tuple are, and when we do or don't have a Some value here.
Attachment #8857339 - Flags: review?(cam) → review+
Pushed by manishearth@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/80a6af7ea610
stylo: Cascade relative font-sizes applied to keyword sizes; r=heycam
https://hg.mozilla.org/mozilla-central/rev/80a6af7ea610
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: