Skip to content

Commit

Permalink
stylo: Add (unused) absolute offset to FontComputationData
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Sep 11, 2017
1 parent ac2fd02 commit 1ad9463
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 25 deletions.
8 changes: 4 additions & 4 deletions components/style/gecko/generated/structs_debug.rs
Expand Up @@ -5007,7 +5007,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>() , 280usize ,
concat ! (
"Size of: " , stringify ! ( ServoStyleContext ) ));
assert_eq! (::std::mem::align_of::<ServoStyleContext>() , 8usize ,
Expand All @@ -5030,14 +5030,14 @@ pub mod root {
assert_eq! (unsafe {
& ( * ( 0 as * const ServoStyleContext ) ) .
mNextInheritingAnonBoxStyle as * const _ as usize } ,
256usize , concat ! (
264usize , concat ! (
"Alignment of field: " , stringify ! (
ServoStyleContext ) , "::" , stringify ! (
mNextInheritingAnonBoxStyle ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const ServoStyleContext ) ) .
mNextLazyPseudoStyle as * const _ as usize } ,
264usize , concat ! (
272usize , concat ! (
"Alignment of field: " , stringify ! (
ServoStyleContext ) , "::" , stringify ! (
mNextLazyPseudoStyle ) ));
Expand Down Expand Up @@ -15914,7 +15914,7 @@ pub mod root {
}
#[test]
fn bindgen_test_layout_ServoComputedData() {
assert_eq!(::std::mem::size_of::<ServoComputedData>() , 224usize ,
assert_eq!(::std::mem::size_of::<ServoComputedData>() , 232usize ,
concat ! ( "Size of: " , stringify ! ( ServoComputedData )
));
assert_eq! (::std::mem::align_of::<ServoComputedData>() , 8usize ,
Expand Down
8 changes: 4 additions & 4 deletions components/style/gecko/generated/structs_release.rs
Expand Up @@ -4895,7 +4895,7 @@ pub mod root {
}
#[test]
fn bindgen_test_layout_ServoStyleContext() {
assert_eq!(::std::mem::size_of::<ServoStyleContext>() , 264usize ,
assert_eq!(::std::mem::size_of::<ServoStyleContext>() , 272usize ,
concat ! (
"Size of: " , stringify ! ( ServoStyleContext ) ));
assert_eq! (::std::mem::align_of::<ServoStyleContext>() , 8usize ,
Expand All @@ -4918,14 +4918,14 @@ pub mod root {
assert_eq! (unsafe {
& ( * ( 0 as * const ServoStyleContext ) ) .
mNextInheritingAnonBoxStyle as * const _ as usize } ,
248usize , concat ! (
256usize , concat ! (
"Alignment of field: " , stringify ! (
ServoStyleContext ) , "::" , stringify ! (
mNextInheritingAnonBoxStyle ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const ServoStyleContext ) ) .
mNextLazyPseudoStyle as * const _ as usize } ,
256usize , concat ! (
264usize , concat ! (
"Alignment of field: " , stringify ! (
ServoStyleContext ) , "::" , stringify ! (
mNextLazyPseudoStyle ) ));
Expand Down Expand Up @@ -15706,7 +15706,7 @@ pub mod root {
}
#[test]
fn bindgen_test_layout_ServoComputedData() {
assert_eq!(::std::mem::size_of::<ServoComputedData>() , 224usize ,
assert_eq!(::std::mem::size_of::<ServoComputedData>() , 232usize ,
concat ! ( "Size of: " , stringify ! ( ServoComputedData )
));
assert_eq! (::std::mem::align_of::<ServoComputedData>() , 8usize ,
Expand Down
4 changes: 2 additions & 2 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -85,7 +85,7 @@ impl ComputedValues {
pseudo: Option<<&PseudoElement>,
custom_properties: Option<Arc<CustomPropertiesMap>>,
writing_mode: WritingMode,
font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>,
font_size_keyword: Option<(longhands::font_size::KeywordSize, f32, NonNegativeAu)>,
flags: ComputedValueFlags,
rules: Option<StrongRuleNode>,
visited_style: Option<Arc<ComputedValues>>,
Expand Down Expand Up @@ -188,7 +188,7 @@ type ParentStyleContextInfo<'a> = Option< &'a ComputedValues>;
impl ComputedValuesInner {
pub fn new(custom_properties: Option<Arc<CustomPropertiesMap>>,
writing_mode: WritingMode,
font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>,
font_size_keyword: Option<(longhands::font_size::KeywordSize, f32, NonNegativeAu)>,
flags: ComputedValueFlags,
rules: Option<StrongRuleNode>,
visited_style: Option<Arc<ComputedValues>>,
Expand Down
12 changes: 6 additions & 6 deletions components/style/properties/longhand/font.mako.rs
Expand Up @@ -955,16 +955,16 @@ ${helpers.single_keyword_system("font-variant-caps",
specified_value: &SpecifiedValue,
mut computed: NonNegativeAu) {
if let SpecifiedValue::Keyword(kw, fraction) = *specified_value {
context.builder.font_size_keyword = Some((kw, fraction));
context.builder.font_size_keyword = Some((kw, fraction, Au(0).into()));
} else if let Some(ratio) = specified_value.as_font_ratio() {
// 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)) = context.builder.inherited_font_computation_data().font_size_keyword {
context.builder.font_size_keyword = Some((kw, fraction * ratio));
if let Some((kw, fraction, _)) = context.builder.inherited_font_computation_data().font_size_keyword {
context.builder.font_size_keyword = Some((kw, fraction * ratio, Au(0).into()));
} else {
context.builder.font_size_keyword = None;
}
Expand All @@ -982,7 +982,7 @@ ${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)) = context.builder.font_size_keyword {
if let Some((kw, ratio, _)) = context.builder.font_size_keyword {
computed = context.maybe_zoom_text(kw.to_computed_value(context).scale_by(ratio));
}
}
Expand Down Expand Up @@ -1012,7 +1012,7 @@ ${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)| {
let kw_inherited_size = context.builder.font_size_keyword.map(|(kw, ratio, _)| {
context.maybe_zoom_text(SpecifiedValue::Keyword(kw, ratio).to_computed_value(context))
});
let parent_kw;
Expand Down Expand Up @@ -1047,7 +1047,7 @@ ${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.));
context.builder.font_size_keyword = Some((Default::default(), 1., Au(0).into()));
}
</%helpers:longhand>

Expand Down
20 changes: 11 additions & 9 deletions components/style/properties/properties.mako.rs
Expand Up @@ -10,6 +10,7 @@

<%namespace name="helpers" file="/helpers.mako.rs" />

use app_units::Au;
#[cfg(feature = "servo")] use app_units::Au;
use servo_arc::{Arc, UniqueArc};
use smallbitvec::SmallBitVec;
Expand Down Expand Up @@ -109,22 +110,23 @@ pub struct FontComputationData {
/// 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 generic font, and then multiplying it by the ratio (as well as adding any
/// absolute offset from calcs)
pub font_size_keyword: Option<(longhands::font_size::KeywordSize, f32, NonNegativeAu)>
}


impl FontComputationData {
/// Assigns values for variables in struct FontComputationData
pub fn new(font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>) -> Self {
pub fn new(font_size_keyword: Option<(longhands::font_size::KeywordSize, f32, NonNegativeAu)>) -> Self {
FontComputationData {
font_size_keyword: font_size_keyword
}
}

/// Assigns default values for variables in struct FontComputationData
pub fn default_font_size_keyword() -> Option<(longhands::font_size::KeywordSize, f32)> {
Some((Default::default(), 1.))
pub fn default_font_size_keyword() -> Option<(longhands::font_size::KeywordSize, f32, NonNegativeAu)> {
Some((Default::default(), 1., Au(0).into()))
}

/// Gets a FontComputationData with the default values.
Expand Down Expand Up @@ -2007,7 +2009,7 @@ impl ComputedValues {
_: Option<<&PseudoElement>,
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
writing_mode: WritingMode,
font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>,
font_size_keyword: Option<(longhands::font_size::KeywordSize, f32, NonNegativeAu)>,
flags: ComputedValueFlags,
rules: Option<StrongRuleNode>,
visited_style: Option<Arc<ComputedValues>>,
Expand Down Expand Up @@ -2040,7 +2042,7 @@ impl ComputedValuesInner {
pub fn new(
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
writing_mode: WritingMode,
font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>,
font_size_keyword: Option<(longhands::font_size::KeywordSize, f32, NonNegativeAu)>,
flags: ComputedValueFlags,
rules: Option<StrongRuleNode>,
visited_style: Option<Arc<ComputedValues>>,
Expand Down Expand Up @@ -2564,7 +2566,7 @@ 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: Option<(longhands::font_size::KeywordSize, f32)>,
pub font_size_keyword: Option<(longhands::font_size::KeywordSize, f32, NonNegativeAu)>,
/// Flags for the computed value.
pub flags: ComputedValueFlags,
/// The element's style if visited, only computed if there's a relevant link
Expand All @@ -2587,7 +2589,7 @@ impl<'a> StyleBuilder<'a> {
rules: Option<StrongRuleNode>,
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
writing_mode: WritingMode,
font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>,
font_size_keyword: Option<(longhands::font_size::KeywordSize, f32, NonNegativeAu)>,
flags: ComputedValueFlags,
visited_style: Option<Arc<ComputedValues>>,
) -> Self {
Expand Down

0 comments on commit 1ad9463

Please sign in to comment.