From 1ad9463558dd656d830b1e3b7d52921bbf014765 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 8 Sep 2017 15:25:44 -0700 Subject: [PATCH] stylo: Add (unused) absolute offset to FontComputationData --- .../style/gecko/generated/structs_debug.rs | 8 ++++---- .../style/gecko/generated/structs_release.rs | 8 ++++---- components/style/properties/gecko.mako.rs | 4 ++-- .../style/properties/longhand/font.mako.rs | 12 +++++------ .../style/properties/properties.mako.rs | 20 ++++++++++--------- 5 files changed, 27 insertions(+), 25 deletions(-) diff --git a/components/style/gecko/generated/structs_debug.rs b/components/style/gecko/generated/structs_debug.rs index 982722b5ef5c..0ff3aa970589 100644 --- a/components/style/gecko/generated/structs_debug.rs +++ b/components/style/gecko/generated/structs_debug.rs @@ -5007,7 +5007,7 @@ pub mod root { } #[test] fn bindgen_test_layout_ServoStyleContext() { - assert_eq!(::std::mem::size_of::() , 272usize , + assert_eq!(::std::mem::size_of::() , 280usize , concat ! ( "Size of: " , stringify ! ( ServoStyleContext ) )); assert_eq! (::std::mem::align_of::() , 8usize , @@ -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 ) )); @@ -15914,7 +15914,7 @@ pub mod root { } #[test] fn bindgen_test_layout_ServoComputedData() { - assert_eq!(::std::mem::size_of::() , 224usize , + assert_eq!(::std::mem::size_of::() , 232usize , concat ! ( "Size of: " , stringify ! ( ServoComputedData ) )); assert_eq! (::std::mem::align_of::() , 8usize , diff --git a/components/style/gecko/generated/structs_release.rs b/components/style/gecko/generated/structs_release.rs index eb0379fca121..b91938c68c24 100644 --- a/components/style/gecko/generated/structs_release.rs +++ b/components/style/gecko/generated/structs_release.rs @@ -4895,7 +4895,7 @@ pub mod root { } #[test] fn bindgen_test_layout_ServoStyleContext() { - assert_eq!(::std::mem::size_of::() , 264usize , + assert_eq!(::std::mem::size_of::() , 272usize , concat ! ( "Size of: " , stringify ! ( ServoStyleContext ) )); assert_eq! (::std::mem::align_of::() , 8usize , @@ -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 ) )); @@ -15706,7 +15706,7 @@ pub mod root { } #[test] fn bindgen_test_layout_ServoComputedData() { - assert_eq!(::std::mem::size_of::() , 224usize , + assert_eq!(::std::mem::size_of::() , 232usize , concat ! ( "Size of: " , stringify ! ( ServoComputedData ) )); assert_eq! (::std::mem::align_of::() , 8usize , diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index a2d01bbf4ca9..739d6d1a015b 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -85,7 +85,7 @@ impl ComputedValues { pseudo: Option<<&PseudoElement>, custom_properties: Option>, 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, visited_style: Option>, @@ -188,7 +188,7 @@ type ParentStyleContextInfo<'a> = Option< &'a ComputedValues>; impl ComputedValuesInner { pub fn new(custom_properties: Option>, 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, visited_style: Option>, diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index 18c25ecbd799..6298ecdebdab 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -955,7 +955,7 @@ ${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 @@ -963,8 +963,8 @@ ${helpers.single_keyword_system("font-variant-caps", // 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; } @@ -982,7 +982,7 @@ ${helpers.single_keyword_system("font-variant-caps", context.builder.get_parent_font().gecko().mLanguage.raw::() || 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)); } } @@ -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; @@ -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())); } diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index d9769383d1ef..8b4286d550f7 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -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; @@ -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. @@ -2007,7 +2009,7 @@ impl ComputedValues { _: Option<<&PseudoElement>, custom_properties: Option>, 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, visited_style: Option>, @@ -2040,7 +2042,7 @@ impl ComputedValuesInner { pub fn new( custom_properties: Option>, 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, visited_style: Option>, @@ -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 @@ -2587,7 +2589,7 @@ impl<'a> StyleBuilder<'a> { rules: Option, custom_properties: Option>, 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>, ) -> Self {