mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
stylo: Remove FontComputationData, switch over to using the new font tracking
This commit is contained in:
parent
c73dc5704b
commit
e1a39a2012
5 changed files with 34 additions and 202 deletions
|
@ -10,7 +10,6 @@ pub type ServoUnsafeCell<T> = ::std::cell::UnsafeCell<T>;
|
|||
pub type ServoCell<T> = ::std::cell::Cell<T>;
|
||||
pub type ServoNodeData = AtomicRefCell<ElementData>;
|
||||
pub type ServoWritingMode = ::logical_geometry::WritingMode;
|
||||
pub type ServoFontComputationData = ::properties::FontComputationData;
|
||||
pub type ServoCustomPropertiesMap = Option<::servo_arc::Arc<::custom_properties::CustomPropertiesMap>>;
|
||||
pub type ServoRuleNode = Option<::rule_tree::StrongRuleNode>;
|
||||
pub type ServoVisitedStyle = Option<::servo_arc::RawOffsetArc<::properties::ComputedValues>>;
|
||||
|
@ -4463,19 +4462,6 @@ pub mod root {
|
|||
FirstLetterContinuation = 1,
|
||||
PlaceholderFrame = 2,
|
||||
}
|
||||
#[repr(u32)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum ServoKeywordSize {
|
||||
Empty = 0,
|
||||
XXSmall = 1,
|
||||
XSmall = 2,
|
||||
Small = 3,
|
||||
Medium = 4,
|
||||
Large = 5,
|
||||
XLarge = 6,
|
||||
XXLarge = 7,
|
||||
XXXLarge = 8,
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct ServoStyleContext {
|
||||
|
@ -4487,7 +4473,7 @@ pub mod root {
|
|||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_ServoStyleContext() {
|
||||
assert_eq!(::std::mem::size_of::<ServoStyleContext>() , 280usize ,
|
||||
assert_eq!(::std::mem::size_of::<ServoStyleContext>() , 264usize ,
|
||||
concat ! (
|
||||
"Size of: " , stringify ! ( ServoStyleContext ) ));
|
||||
assert_eq! (::std::mem::align_of::<ServoStyleContext>() , 8usize ,
|
||||
|
@ -4510,14 +4496,14 @@ pub mod root {
|
|||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const ServoStyleContext ) ) .
|
||||
mNextInheritingAnonBoxStyle as * const _ as usize } ,
|
||||
264usize , concat ! (
|
||||
248usize , concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
ServoStyleContext ) , "::" , stringify ! (
|
||||
mNextInheritingAnonBoxStyle ) ));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const ServoStyleContext ) ) .
|
||||
mNextLazyPseudoStyle as * const _ as usize } ,
|
||||
272usize , concat ! (
|
||||
256usize , concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
ServoStyleContext ) , "::" , stringify ! (
|
||||
mNextLazyPseudoStyle ) ));
|
||||
|
@ -14828,11 +14814,10 @@ pub mod root {
|
|||
/// /// relevant link for this element. A element's "relevant link" is the
|
||||
/// /// element being matched if it is a link or the nearest ancestor link.
|
||||
pub visited_style: ::gecko_bindings::structs::ServoVisitedStyle,
|
||||
pub font_computation_data: ::gecko_bindings::structs::ServoFontComputationData,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_ServoComputedData() {
|
||||
assert_eq!(::std::mem::size_of::<ServoComputedData>() , 232usize ,
|
||||
assert_eq!(::std::mem::size_of::<ServoComputedData>() , 216usize ,
|
||||
concat ! ( "Size of: " , stringify ! ( ServoComputedData )
|
||||
));
|
||||
assert_eq! (::std::mem::align_of::<ServoComputedData>() , 8usize ,
|
||||
|
@ -14979,12 +14964,6 @@ pub mod root {
|
|||
as * const _ as usize } , 208usize , concat ! (
|
||||
"Alignment of field: " , stringify ! ( ServoComputedData )
|
||||
, "::" , stringify ! ( visited_style ) ));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const ServoComputedData ) ) .
|
||||
font_computation_data as * const _ as usize } , 216usize ,
|
||||
concat ! (
|
||||
"Alignment of field: " , stringify ! ( ServoComputedData )
|
||||
, "::" , stringify ! ( font_computation_data ) ));
|
||||
}
|
||||
#[repr(u32)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -10,7 +10,6 @@ pub type ServoUnsafeCell<T> = ::std::cell::UnsafeCell<T>;
|
|||
pub type ServoCell<T> = ::std::cell::Cell<T>;
|
||||
pub type ServoNodeData = AtomicRefCell<ElementData>;
|
||||
pub type ServoWritingMode = ::logical_geometry::WritingMode;
|
||||
pub type ServoFontComputationData = ::properties::FontComputationData;
|
||||
pub type ServoCustomPropertiesMap = Option<::servo_arc::Arc<::custom_properties::CustomPropertiesMap>>;
|
||||
pub type ServoRuleNode = Option<::rule_tree::StrongRuleNode>;
|
||||
pub type ServoVisitedStyle = Option<::servo_arc::RawOffsetArc<::properties::ComputedValues>>;
|
||||
|
@ -4383,19 +4382,6 @@ pub mod root {
|
|||
FirstLetterContinuation = 1,
|
||||
PlaceholderFrame = 2,
|
||||
}
|
||||
#[repr(u32)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum ServoKeywordSize {
|
||||
Empty = 0,
|
||||
XXSmall = 1,
|
||||
XSmall = 2,
|
||||
Small = 3,
|
||||
Medium = 4,
|
||||
Large = 5,
|
||||
XLarge = 6,
|
||||
XXLarge = 7,
|
||||
XXXLarge = 8,
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct ServoStyleContext {
|
||||
|
@ -4407,7 +4393,7 @@ pub mod root {
|
|||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_ServoStyleContext() {
|
||||
assert_eq!(::std::mem::size_of::<ServoStyleContext>() , 272usize ,
|
||||
assert_eq!(::std::mem::size_of::<ServoStyleContext>() , 256usize ,
|
||||
concat ! (
|
||||
"Size of: " , stringify ! ( ServoStyleContext ) ));
|
||||
assert_eq! (::std::mem::align_of::<ServoStyleContext>() , 8usize ,
|
||||
|
@ -4430,14 +4416,14 @@ pub mod root {
|
|||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const ServoStyleContext ) ) .
|
||||
mNextInheritingAnonBoxStyle as * const _ as usize } ,
|
||||
256usize , concat ! (
|
||||
240usize , concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
ServoStyleContext ) , "::" , stringify ! (
|
||||
mNextInheritingAnonBoxStyle ) ));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const ServoStyleContext ) ) .
|
||||
mNextLazyPseudoStyle as * const _ as usize } ,
|
||||
264usize , concat ! (
|
||||
248usize , concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
ServoStyleContext ) , "::" , stringify ! (
|
||||
mNextLazyPseudoStyle ) ));
|
||||
|
@ -14675,11 +14661,10 @@ pub mod root {
|
|||
/// /// relevant link for this element. A element's "relevant link" is the
|
||||
/// /// element being matched if it is a link or the nearest ancestor link.
|
||||
pub visited_style: ::gecko_bindings::structs::ServoVisitedStyle,
|
||||
pub font_computation_data: ::gecko_bindings::structs::ServoFontComputationData,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_ServoComputedData() {
|
||||
assert_eq!(::std::mem::size_of::<ServoComputedData>() , 232usize ,
|
||||
assert_eq!(::std::mem::size_of::<ServoComputedData>() , 216usize ,
|
||||
concat ! ( "Size of: " , stringify ! ( ServoComputedData )
|
||||
));
|
||||
assert_eq! (::std::mem::align_of::<ServoComputedData>() , 8usize ,
|
||||
|
@ -14826,12 +14811,6 @@ pub mod root {
|
|||
as * const _ as usize } , 208usize , concat ! (
|
||||
"Alignment of field: " , stringify ! ( ServoComputedData )
|
||||
, "::" , stringify ! ( visited_style ) ));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const ServoComputedData ) ) .
|
||||
font_computation_data as * const _ as usize } , 216usize ,
|
||||
concat ! (
|
||||
"Alignment of field: " , stringify ! ( ServoComputedData )
|
||||
, "::" , stringify ! ( font_computation_data ) ));
|
||||
}
|
||||
#[repr(u32)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -53,7 +53,7 @@ use logical_geometry::WritingMode;
|
|||
use media_queries::Device;
|
||||
use properties::animated_properties::TransitionProperty;
|
||||
use properties::computed_value_flags::*;
|
||||
use properties::{default_font_size_keyword, longhands, FontComputationData, Importance, LonghandId};
|
||||
use properties::{longhands, Importance, LonghandId};
|
||||
use properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyDeclarationId};
|
||||
use rule_tree::StrongRuleNode;
|
||||
use selector_parser::PseudoElement;
|
||||
|
@ -85,7 +85,6 @@ impl ComputedValues {
|
|||
pseudo: Option<<&PseudoElement>,
|
||||
custom_properties: Option<Arc<CustomPropertiesMap>>,
|
||||
writing_mode: WritingMode,
|
||||
font_size_keyword: FontComputationData,
|
||||
flags: ComputedValueFlags,
|
||||
rules: Option<StrongRuleNode>,
|
||||
visited_style: Option<Arc<ComputedValues>>,
|
||||
|
@ -96,7 +95,6 @@ impl ComputedValues {
|
|||
ComputedValuesInner::new(
|
||||
custom_properties,
|
||||
writing_mode,
|
||||
font_size_keyword,
|
||||
flags,
|
||||
rules,
|
||||
visited_style,
|
||||
|
@ -114,7 +112,6 @@ impl ComputedValues {
|
|||
ComputedValuesInner::new(
|
||||
/* custom_properties = */ None,
|
||||
/* writing_mode = */ WritingMode::empty(), // FIXME(bz): This seems dubious
|
||||
default_font_size_keyword(),
|
||||
ComputedValueFlags::empty(),
|
||||
/* rules = */ None,
|
||||
/* visited_style = */ None,
|
||||
|
@ -174,7 +171,6 @@ impl Clone for ComputedValuesInner {
|
|||
% endfor
|
||||
custom_properties: self.custom_properties.clone(),
|
||||
writing_mode: self.writing_mode.clone(),
|
||||
font_computation_data: self.font_computation_data.clone(),
|
||||
flags: self.flags.clone(),
|
||||
rules: self.rules.clone(),
|
||||
visited_style: self.visited_style.clone(),
|
||||
|
@ -188,7 +184,6 @@ type ParentStyleContextInfo<'a> = Option< &'a ComputedValues>;
|
|||
impl ComputedValuesInner {
|
||||
pub fn new(custom_properties: Option<Arc<CustomPropertiesMap>>,
|
||||
writing_mode: WritingMode,
|
||||
font_size_keyword: FontComputationData,
|
||||
flags: ComputedValueFlags,
|
||||
rules: Option<StrongRuleNode>,
|
||||
visited_style: Option<Arc<ComputedValues>>,
|
||||
|
@ -199,7 +194,6 @@ impl ComputedValuesInner {
|
|||
ComputedValuesInner {
|
||||
custom_properties: custom_properties,
|
||||
writing_mode: writing_mode,
|
||||
font_computation_data: font_size_keyword,
|
||||
rules: rules,
|
||||
visited_style: visited_style.map(|x| Arc::into_raw_offset(x)),
|
||||
flags: flags,
|
||||
|
@ -2322,11 +2316,9 @@ fn static_assert() {
|
|||
/// This function will also handle scriptminsize and scriptlevel
|
||||
/// so should not be called when you just want the font sizes to be copied.
|
||||
/// Hence the different name.
|
||||
///
|
||||
/// Returns true if the inherited keyword size was actually used
|
||||
pub fn inherit_font_size_from(&mut self, parent: &Self,
|
||||
kw_inherited_size: Option<NonNegativeLength>,
|
||||
device: &Device) -> bool {
|
||||
device: &Device) {
|
||||
let (adjusted_size, adjusted_unconstrained_size)
|
||||
= self.calculate_script_level_size(parent, device);
|
||||
if adjusted_size.0 != parent.gecko.mSize ||
|
||||
|
@ -2355,8 +2347,6 @@ fn static_assert() {
|
|||
self.gecko.mFontSizeOffset = 0;
|
||||
|
||||
self.gecko.mScriptUnconstrainedSize = adjusted_unconstrained_size.0;
|
||||
self.fixup_font_min_size(device);
|
||||
false
|
||||
} else if let Some(size) = kw_inherited_size {
|
||||
// Parent element was a keyword-derived size.
|
||||
self.gecko.mSize = size.0.to_i32_au();
|
||||
|
@ -2366,8 +2356,6 @@ fn static_assert() {
|
|||
self.gecko.mFontSizeKeyword = parent.gecko.mFontSizeKeyword;
|
||||
// MathML constraints didn't apply here, so we can ignore this.
|
||||
self.gecko.mScriptUnconstrainedSize = size.0.to_i32_au();
|
||||
self.fixup_font_min_size(device);
|
||||
true
|
||||
} else {
|
||||
// MathML isn't affecting us, and our parent element does not
|
||||
// have a keyword-derived size. Set things normally.
|
||||
|
@ -2377,9 +2365,8 @@ fn static_assert() {
|
|||
self.gecko.mFontSizeFactor = 1.;
|
||||
self.gecko.mFontSizeOffset = 0;
|
||||
self.gecko.mScriptUnconstrainedSize = parent.gecko.mScriptUnconstrainedSize;
|
||||
self.fixup_font_min_size(device);
|
||||
false
|
||||
}
|
||||
self.fixup_font_min_size(device);
|
||||
}
|
||||
|
||||
pub fn clone_font_size(&self) -> longhands::font_size::computed_value::T {
|
||||
|
|
|
@ -605,7 +605,7 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
use style_traits::ToCss;
|
||||
use values::FONT_MEDIUM_PX;
|
||||
use values::computed::NonNegativeLength;
|
||||
use values::specified::{AllowQuirks, FontRelativeLength, LengthOrPercentage, NoCalcLength};
|
||||
use values::specified::{AllowQuirks, LengthOrPercentage, NoCalcLength};
|
||||
use values::specified::length::FontBaseSize;
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
|
@ -861,46 +861,6 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
}, 1., Au(0).into())
|
||||
}
|
||||
|
||||
/// If this value is specified as a ratio of the parent font (em units
|
||||
/// or percent) return the ratio
|
||||
pub fn as_font_ratio(&self, context: &Context) -> Option<(f32, NonNegativeLength)> {
|
||||
match *self {
|
||||
SpecifiedValue::Length(ref lop) => {
|
||||
match *lop {
|
||||
LengthOrPercentage::Percentage(pc) => {
|
||||
Some((pc.0, NonNegativeLength::zero()))
|
||||
}
|
||||
LengthOrPercentage::Length(ref nocalc) => {
|
||||
match *nocalc {
|
||||
NoCalcLength::FontRelative(FontRelativeLength::Em(em)) => {
|
||||
Some((em, NonNegativeLength::zero()))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
LengthOrPercentage::Calc(ref calc) => {
|
||||
if calc.em.is_none() && calc.percentage.is_none() {
|
||||
return None;
|
||||
}
|
||||
let ratio = calc.em.unwrap_or(0.) + calc.percentage.map_or(0., |pc| pc.0);
|
||||
// Compute it, but shave off the font-relative part (em, %)
|
||||
// This will mean that other font-relative units like ex and ch will be computed against
|
||||
// the old font even when the font changes. There's no particular "right answer" for what
|
||||
// to do here -- Gecko recascades as if the font had changed, we instead track the changes
|
||||
// and reapply, which means that we carry over old computed ex/ch values whilst Gecko
|
||||
// recomputes new ones. This is enough of an edge case to not really matter.
|
||||
let abs = calc.to_computed_value_zoomed(context, FontBaseSize::Custom(Au(0)))
|
||||
.length_component().into();
|
||||
Some((ratio, abs))
|
||||
}
|
||||
}
|
||||
}
|
||||
SpecifiedValue::Larger => Some((LARGER_FONT_SIZE_RATIO, Au(0).into())),
|
||||
SpecifiedValue::Smaller => Some((1. / LARGER_FONT_SIZE_RATIO, Au(0).into())),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Compute it against a given base font size
|
||||
pub fn to_computed_value_against(
|
||||
&self,
|
||||
|
@ -908,6 +868,11 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
base_size: FontBaseSize,
|
||||
) -> computed_value::T {
|
||||
use values::specified::length::FontRelativeLength;
|
||||
let compose_keyword = |factor| {
|
||||
context.style().get_parent_font()
|
||||
.clone_font_size().info
|
||||
.map(|i| i.compose(factor, Au(0).into()))
|
||||
};
|
||||
let mut info = None;
|
||||
let size = match *self {
|
||||
SpecifiedValue::Length(LengthOrPercentage::Length(
|
||||
|
@ -915,8 +880,7 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
if let FontRelativeLength::Em(em) = value {
|
||||
// If the parent font was keyword-derived, this is too.
|
||||
// Tack the em unit onto the factor
|
||||
info = context.style().get_parent_font()
|
||||
.clone_font_size().info.map(|i| i.compose(em, Au(0).into()));
|
||||
info = compose_keyword(em);
|
||||
}
|
||||
value.to_computed_value(context, base_size).into()
|
||||
}
|
||||
|
@ -934,7 +898,7 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
SpecifiedValue::Length(LengthOrPercentage::Percentage(pc)) => {
|
||||
// If the parent font was keyword-derived, this is too.
|
||||
// Tack the % onto the factor
|
||||
info = context.style().get_parent_font().clone_font_size().info.map(|i| i.compose(pc.0, Au(0).into()));
|
||||
info = compose_keyword(pc.0);
|
||||
base_size.resolve(context).scale_by(pc.0).into()
|
||||
}
|
||||
SpecifiedValue::Length(LengthOrPercentage::Calc(ref calc)) => {
|
||||
|
@ -967,10 +931,12 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
context.maybe_zoom_text(key_len).into()
|
||||
}
|
||||
SpecifiedValue::Smaller => {
|
||||
info = compose_keyword(1. / LARGER_FONT_SIZE_RATIO);
|
||||
FontRelativeLength::Em(1. / LARGER_FONT_SIZE_RATIO)
|
||||
.to_computed_value(context, base_size).into()
|
||||
}
|
||||
SpecifiedValue::Larger => {
|
||||
info = compose_keyword(LARGER_FONT_SIZE_RATIO);
|
||||
FontRelativeLength::Em(LARGER_FONT_SIZE_RATIO)
|
||||
.to_computed_value(context, base_size).into()
|
||||
}
|
||||
|
@ -1063,25 +1029,6 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
pub fn cascade_specified_font_size(context: &mut Context,
|
||||
specified_value: &SpecifiedValue,
|
||||
mut computed: computed_value::T) {
|
||||
if let SpecifiedValue::Keyword(kw, fraction, offset) = *specified_value {
|
||||
context.builder.font_size_keyword = Some((kw, fraction, offset));
|
||||
} else if let Some((ratio, abs)) = specified_value.as_font_ratio(context) {
|
||||
// In case a font-size-relative value was applied to a keyword
|
||||
// value, we must preserve this fact in case the generic font family
|
||||
// changes. relative values (em and %) applied to keywords must be
|
||||
// recomputed from the base size for the keyword and the relative size.
|
||||
//
|
||||
// See bug 1355707
|
||||
if let Some((kw, fraction, old_abs)) = *context.builder.inherited_font_computation_data() {
|
||||
context.builder.font_size_keyword =
|
||||
Some((kw, fraction * ratio, abs + old_abs.scale_by(ratio)));
|
||||
} else {
|
||||
context.builder.font_size_keyword = None;
|
||||
}
|
||||
} else {
|
||||
context.builder.font_size_keyword = None;
|
||||
}
|
||||
|
||||
// we could use clone_language and clone_font_family() here but that's
|
||||
// expensive. Do it only in gecko mode for now.
|
||||
% if product == "gecko":
|
||||
|
@ -1092,16 +1039,9 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
context.builder.get_parent_font().gecko().mLanguage.raw::<nsIAtom>() ||
|
||||
context.builder.get_font().gecko().mGenericID !=
|
||||
context.builder.get_parent_font().gecko().mGenericID {
|
||||
if let Some((kw, ratio, offset)) = context.builder.font_size_keyword {
|
||||
let len = context.maybe_zoom_text(kw.to_computed_value(context).scale_by(ratio) + offset);
|
||||
computed = computed_value::T {
|
||||
size: len,
|
||||
info: Some(computed_value::KeywordInfo {
|
||||
kw: kw,
|
||||
factor: ratio,
|
||||
offset: offset
|
||||
}),
|
||||
}
|
||||
if let Some(info) = computed.info {
|
||||
computed.size = context.maybe_zoom_text(info.kw.to_computed_value(context)
|
||||
.scale_by(info.factor) + info.offset)
|
||||
}
|
||||
}
|
||||
% endif
|
||||
|
@ -1130,21 +1070,17 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
// If inheriting, we must recompute font-size in case of language
|
||||
// changes using the font_size_keyword. We also need to do this to
|
||||
// handle mathml scriptlevel changes
|
||||
let kw_inherited_size = context.builder.font_size_keyword.map(|(kw, ratio, offset)| {
|
||||
context.maybe_zoom_text(SpecifiedValue::Keyword(kw, ratio, offset).to_computed_value(context).size)
|
||||
let kw_inherited_size = context.builder.get_parent_font()
|
||||
.clone_font_size()
|
||||
.info.map(|info| {
|
||||
context.maybe_zoom_text(SpecifiedValue::Keyword(info.kw, info.factor, info.offset)
|
||||
.to_computed_value(context).size)
|
||||
});
|
||||
let parent_kw;
|
||||
let device = context.builder.device;
|
||||
let mut font = context.builder.take_font();
|
||||
let used_kw = {
|
||||
let parent_font = context.builder.get_parent_font();
|
||||
parent_kw = *context.builder.inherited_font_computation_data();
|
||||
|
||||
font.inherit_font_size_from(parent_font, kw_inherited_size, device)
|
||||
};
|
||||
font.inherit_font_size_from(context.builder.get_parent_font(),
|
||||
kw_inherited_size,
|
||||
context.builder.device);
|
||||
context.builder.put_font(font);
|
||||
context.builder.font_size_keyword =
|
||||
if used_kw { parent_kw } else { None };
|
||||
}
|
||||
|
||||
/// Cascade the initial value for the `font-size` property.
|
||||
|
@ -1164,7 +1100,6 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
let device = context.builder.device;
|
||||
context.builder.mutate_font().fixup_font_min_size(device);
|
||||
% endif
|
||||
context.builder.font_size_keyword = Some((Default::default(), 1., Au(0).into()));
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
<%namespace name="helpers" file="/helpers.mako.rs" />
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
use app_units::Au;
|
||||
use servo_arc::{Arc, UniqueArc};
|
||||
use smallbitvec::SmallBitVec;
|
||||
|
@ -92,32 +93,6 @@ pub trait MaybeBoxed<Out> {
|
|||
fn maybe_boxed(self) -> Out;
|
||||
}
|
||||
|
||||
|
||||
/// This is where we store extra font data while
|
||||
/// while computing font sizes.
|
||||
///
|
||||
/// 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 (as well as adding any
|
||||
/// absolute offset from calcs)
|
||||
pub type FontComputationData = Option<(longhands::font_size::KeywordSize, f32, NonNegativeLength)>;
|
||||
|
||||
/// Default value for FontComputationData
|
||||
pub fn default_font_size_keyword() -> FontComputationData {
|
||||
Some((Default::default(), 1., Au(0).into()))
|
||||
}
|
||||
|
||||
impl<T> MaybeBoxed<T> for T {
|
||||
#[inline]
|
||||
fn maybe_boxed(self) -> T { self }
|
||||
|
@ -1845,9 +1820,8 @@ pub mod style_structs {
|
|||
/// (Servo does not handle MathML, so this just calls copy_font_size_from)
|
||||
pub fn inherit_font_size_from(&mut self, parent: &Self,
|
||||
_: Option<NonNegativeLength>,
|
||||
_: &Device) -> bool {
|
||||
_: &Device) {
|
||||
self.copy_font_size_from(parent);
|
||||
false
|
||||
}
|
||||
/// (Servo does not handle MathML, so this just calls set_font_size)
|
||||
pub fn apply_font_size(&mut self,
|
||||
|
@ -1985,9 +1959,6 @@ pub struct ComputedValuesInner {
|
|||
/// The writing mode of this computed values struct.
|
||||
pub writing_mode: WritingMode,
|
||||
|
||||
/// The keyword behind the current font-size property, if any
|
||||
pub font_computation_data: FontComputationData,
|
||||
|
||||
/// A set of flags we use to store misc information regarding this style.
|
||||
pub flags: ComputedValueFlags,
|
||||
|
||||
|
@ -2043,7 +2014,6 @@ impl ComputedValues {
|
|||
_: Option<<&PseudoElement>,
|
||||
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||
writing_mode: WritingMode,
|
||||
font_size_keyword: FontComputationData,
|
||||
flags: ComputedValueFlags,
|
||||
rules: Option<StrongRuleNode>,
|
||||
visited_style: Option<Arc<ComputedValues>>,
|
||||
|
@ -2055,7 +2025,6 @@ impl ComputedValues {
|
|||
inner: ComputedValuesInner::new(
|
||||
custom_properties,
|
||||
writing_mode,
|
||||
font_size_keyword,
|
||||
flags,
|
||||
rules,
|
||||
visited_style,
|
||||
|
@ -2076,7 +2045,6 @@ impl ComputedValuesInner {
|
|||
pub fn new(
|
||||
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||
writing_mode: WritingMode,
|
||||
font_size_keyword: FontComputationData,
|
||||
flags: ComputedValueFlags,
|
||||
rules: Option<StrongRuleNode>,
|
||||
visited_style: Option<Arc<ComputedValues>>,
|
||||
|
@ -2087,7 +2055,6 @@ impl ComputedValuesInner {
|
|||
ComputedValuesInner {
|
||||
custom_properties: custom_properties,
|
||||
writing_mode: writing_mode,
|
||||
font_computation_data: font_size_keyword,
|
||||
rules: rules,
|
||||
visited_style: visited_style,
|
||||
flags: flags,
|
||||
|
@ -2609,8 +2576,6 @@ pub struct StyleBuilder<'a> {
|
|||
///
|
||||
/// TODO(emilio): Make private.
|
||||
pub writing_mode: WritingMode,
|
||||
/// The keyword behind the current font-size property, if any.
|
||||
pub font_size_keyword: FontComputationData,
|
||||
/// Flags for the computed value.
|
||||
pub flags: ComputedValueFlags,
|
||||
/// The element's style if visited, only computed if there's a relevant link
|
||||
|
@ -2633,7 +2598,6 @@ impl<'a> StyleBuilder<'a> {
|
|||
rules: Option<StrongRuleNode>,
|
||||
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||
writing_mode: WritingMode,
|
||||
font_size_keyword: FontComputationData,
|
||||
mut flags: ComputedValueFlags,
|
||||
visited_style: Option<Arc<ComputedValues>>,
|
||||
) -> Self {
|
||||
|
@ -2671,7 +2635,6 @@ impl<'a> StyleBuilder<'a> {
|
|||
modified_reset: false,
|
||||
custom_properties,
|
||||
writing_mode,
|
||||
font_size_keyword,
|
||||
flags,
|
||||
visited_style,
|
||||
% for style_struct in data.active_style_structs():
|
||||
|
@ -2714,7 +2677,6 @@ impl<'a> StyleBuilder<'a> {
|
|||
rules: None, // FIXME(emilio): Dubious...
|
||||
custom_properties: style_to_derive_from.custom_properties(),
|
||||
writing_mode: style_to_derive_from.writing_mode,
|
||||
font_size_keyword: style_to_derive_from.font_computation_data,
|
||||
flags: style_to_derive_from.flags,
|
||||
visited_style: style_to_derive_from.clone_visited_style(),
|
||||
% for style_struct in data.active_style_structs():
|
||||
|
@ -2834,7 +2796,6 @@ impl<'a> StyleBuilder<'a> {
|
|||
/* rules = */ None,
|
||||
parent.custom_properties(),
|
||||
parent.writing_mode,
|
||||
parent.font_computation_data,
|
||||
parent.flags,
|
||||
parent.clone_visited_style()
|
||||
)
|
||||
|
@ -2941,7 +2902,6 @@ impl<'a> StyleBuilder<'a> {
|
|||
self.pseudo,
|
||||
self.custom_properties,
|
||||
self.writing_mode,
|
||||
self.font_size_keyword,
|
||||
self.flags,
|
||||
self.rules,
|
||||
self.visited_style,
|
||||
|
@ -2964,11 +2924,6 @@ impl<'a> StyleBuilder<'a> {
|
|||
/// ::first-line case some of the inherited information needs to come from
|
||||
/// one ComputedValues instance and some from a different one.
|
||||
|
||||
/// Inherited font bits.
|
||||
pub fn inherited_font_computation_data(&self) -> &FontComputationData {
|
||||
&self.inherited_style.font_computation_data
|
||||
}
|
||||
|
||||
/// Inherited writing-mode.
|
||||
pub fn inherited_writing_mode(&self) -> &WritingMode {
|
||||
&self.inherited_style.writing_mode
|
||||
|
@ -3006,7 +2961,6 @@ mod lazy_static_module {
|
|||
use logical_geometry::WritingMode;
|
||||
use servo_arc::Arc;
|
||||
use super::{ComputedValues, ComputedValuesInner, longhands, style_structs};
|
||||
use super::default_font_size_keyword;
|
||||
use super::computed_value_flags::ComputedValueFlags;
|
||||
|
||||
/// The initial values for all style structs as defined by the specification.
|
||||
|
@ -3025,7 +2979,6 @@ mod lazy_static_module {
|
|||
% endfor
|
||||
custom_properties: None,
|
||||
writing_mode: WritingMode::empty(),
|
||||
font_computation_data: default_font_size_keyword(),
|
||||
rules: None,
|
||||
visited_style: None,
|
||||
flags: ComputedValueFlags::empty(),
|
||||
|
@ -3252,7 +3205,6 @@ where
|
|||
Some(rules.clone()),
|
||||
custom_properties,
|
||||
WritingMode::empty(),
|
||||
inherited_style.font_computation_data,
|
||||
ComputedValueFlags::empty(),
|
||||
visited_style,
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue