style: Refactor and add infrastructure for font metrics in style.

This commit itself only moves things around and adds an extra parameter to the
`apply_declarations` function to eventually handle #14079 correctly.

Probably needs a more granular API to query fonts, á la nsFontMetrics, but
that's trivial to do once this is landed.

Then we should make the font provider mandatory, and implement the missing stylo
bits.
This commit is contained in:
Emilio Cobos Álvarez 2016-11-11 19:56:04 +01:00
parent 9fd6f0acd5
commit 6c3458767b
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
15 changed files with 196 additions and 94 deletions

View file

@ -25,6 +25,7 @@ use url::Url;
#[cfg(feature = "servo")] use euclid::side_offsets::SideOffsets2D;
use euclid::size::Size2D;
use computed_values;
use font_metrics::FontMetricsProvider;
#[cfg(feature = "servo")] use logical_geometry::{LogicalMargin, PhysicalSide};
use logical_geometry::WritingMode;
use parser::{Parse, ParserContext, ParserContextExtraData};
@ -1464,6 +1465,7 @@ pub fn cascade(viewport_size: Size2D<Au>,
inherited_style,
cascade_info,
error_reporter,
None,
flags)
}
@ -1475,6 +1477,7 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>,
inherited_style: &ComputedValues,
mut cascade_info: Option<<&mut CascadeInfo>,
mut error_reporter: StdBox<ParseErrorReporter + Send>,
font_metrics_provider: Option<<&FontMetricsProvider>,
flags: CascadeFlags)
-> ComputedValues
where F: Fn() -> I, I: Iterator<Item = &'a PropertyDeclaration>
@ -1528,6 +1531,7 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>,
viewport_size: viewport_size,
inherited_style: inherited_style,
style: starting_style,
font_metrics_provider: font_metrics_provider,
};
// Set computed values, overwriting earlier declarations for the same
@ -1562,6 +1566,7 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>,
// classification is correct.
let is_early_property = matches!(*declaration,
PropertyDeclaration::FontSize(_) |
PropertyDeclaration::FontFamily(_) |
PropertyDeclaration::Color(_) |
PropertyDeclaration::Position(_) |
PropertyDeclaration::Float(_) |