mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Putting the font computation data in its own struct
This commit is contained in:
parent
3c267d7fdd
commit
af124f2d89
3 changed files with 53 additions and 30 deletions
|
@ -57,6 +57,7 @@ use logical_geometry::WritingMode;
|
|||
use media_queries::Device;
|
||||
use properties::animated_properties::TransitionProperty;
|
||||
use properties::longhands;
|
||||
use properties:: FontComputationData;
|
||||
use properties::{Importance, LonghandId};
|
||||
use properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyDeclarationId};
|
||||
use std::fmt::{self, Debug};
|
||||
|
@ -74,6 +75,7 @@ pub mod style_structs {
|
|||
% endfor
|
||||
}
|
||||
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ComputedValues {
|
||||
% for style_struct in data.style_structs:
|
||||
|
@ -83,23 +85,7 @@ pub struct ComputedValues {
|
|||
custom_properties: Option<Arc<ComputedValuesMap>>,
|
||||
pub writing_mode: WritingMode,
|
||||
pub root_font_size: Au,
|
||||
/// font-size keyword values (and font-size-relative values applied
|
||||
/// to keyword values) need to preserve their identity as originating
|
||||
/// from keywords and relative font sizes. We store this information
|
||||
/// out of band in the ComputedValues. When None, the font size on the
|
||||
/// current struct was computed from a value that was not a keyword
|
||||
/// or a chain of font-size-relative values applying to successive parents
|
||||
/// terminated by a keyword. When Some, this means the font-size was derived
|
||||
/// from a keyword value or a keyword value on some ancestor with only
|
||||
/// font-size-relative keywords and regular inheritance in between. The
|
||||
/// integer stores the final ratio of the chain of font size relative values.
|
||||
/// and is 1 when there was just a keyword and no relative values.
|
||||
///
|
||||
/// When this is Some, we compute font sizes by computing the keyword against
|
||||
/// the generic font, and then multiplying it by the ratio.
|
||||
pub font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>,
|
||||
/// The cached system font. See longhand/font.mako.rs
|
||||
pub cached_system_font: Option<longhands::system_font::ComputedSystemFont>,
|
||||
pub font_computation_data: FontComputationData,
|
||||
|
||||
/// The element's computed values if visited, only computed if there's a
|
||||
/// relevant link for this element. A element's "relevant link" is the
|
||||
|
@ -121,8 +107,7 @@ impl ComputedValues {
|
|||
custom_properties: custom_properties,
|
||||
writing_mode: writing_mode,
|
||||
root_font_size: root_font_size,
|
||||
cached_system_font: None,
|
||||
font_size_keyword: font_size_keyword,
|
||||
font_computation_data: FontComputationData::new(font_size_keyword),
|
||||
visited_style: visited_style,
|
||||
% for style_struct in data.style_structs:
|
||||
${style_struct.ident}: ${style_struct.ident},
|
||||
|
@ -135,8 +120,7 @@ impl ComputedValues {
|
|||
custom_properties: None,
|
||||
writing_mode: WritingMode::empty(), // FIXME(bz): This seems dubious
|
||||
root_font_size: longhands::font_size::get_initial_value(), // FIXME(bz): Also seems dubious?
|
||||
font_size_keyword: Some((Default::default(), 1.)),
|
||||
cached_system_font: None,
|
||||
font_computation_data: FontComputationData::default_values(),
|
||||
visited_style: None,
|
||||
% for style_struct in data.style_structs:
|
||||
${style_struct.ident}: style_structs::${style_struct.name}::default(pres_context),
|
||||
|
@ -144,6 +128,7 @@ impl ComputedValues {
|
|||
})
|
||||
}
|
||||
|
||||
|
||||
#[inline]
|
||||
pub fn is_display_contents(&self) -> bool {
|
||||
self.get_box().clone_display() == longhands::display::computed_value::T::contents
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue