mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
style: Expose line-height resolution to style, and use it from ToResolvedValue
For ToResolvedValue implementation purposes we wouldn't need to split out the vertical / font / line-height arguments and we could just pass around the ComputedStyle, but the lh unit would need that distinction, (because computing lh on font properties should use the parent style). Differential Revision: https://phabricator.services.mozilla.com/D168705
This commit is contained in:
parent
aa810f77ec
commit
8997888c6f
4 changed files with 62 additions and 28 deletions
|
@ -119,12 +119,12 @@ impl ToResolvedValue for LineHeight {
|
|||
|
||||
fn to_resolved_value(self, context: &ResolvedContext) -> Self::ResolvedValue {
|
||||
// Resolve <number> to an absolute <length> based on font size.
|
||||
if let LineHeight::Number(num) = &self {
|
||||
let size = context.style.get_font().clone_font_size().computed_size();
|
||||
LineHeight::Length(NonNegativeLength::new(size.px() * num.0))
|
||||
} else {
|
||||
self
|
||||
if matches!(self, Self::Normal | Self::MozBlockHeight) {
|
||||
return self;
|
||||
}
|
||||
let wm = context.style.writing_mode;
|
||||
let vertical = wm.is_vertical() && !wm.is_sideways();
|
||||
Self::Length(context.device.calc_line_height(&self, vertical, context.style.get_font(), Some(context.element_info.element)))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue