Skip to content
Permalink
Browse files

stylo: Add font keyword info fields on nsStyleFont

  • Loading branch information
Manishearth committed Sep 23, 2017
1 parent c2fcc9c commit c73dc5704b397527ba91c44c16d2063bb17a3133
@@ -440,6 +440,7 @@ pub mod root {
pub const NS_STYLE_FONT_SIZE_XXXLARGE: ::std::os::raw::c_uint = 7;
pub const NS_STYLE_FONT_SIZE_LARGER: ::std::os::raw::c_uint = 8;
pub const NS_STYLE_FONT_SIZE_SMALLER: ::std::os::raw::c_uint = 9;
pub const NS_STYLE_FONT_SIZE_NO_KEYWORD: ::std::os::raw::c_uint = 10;
pub const NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED: ::std::os::raw::c_int =
-4;
pub const NS_STYLE_FONT_STRETCH_EXTRA_CONDENSED: ::std::os::raw::c_int =
@@ -4528,7 +4529,7 @@ pub mod root {
}
#[test]
fn bindgen_test_layout_GeckoFont() {
assert_eq!(::std::mem::size_of::<GeckoFont>() , 120usize , concat
assert_eq!(::std::mem::size_of::<GeckoFont>() , 128usize , concat
! ( "Size of: " , stringify ! ( GeckoFont ) ));
assert_eq! (::std::mem::align_of::<GeckoFont>() , 8usize , concat
! ( "Alignment of " , stringify ! ( GeckoFont ) ));
pub struct nsStyleFont {
pub mFont: root::nsFont,
pub mSize: root::nscoord,
pub mFontSizeFactor: f32,
pub mFontSizeOffset: root::nscoord,
pub mFontSizeKeyword: u8,
pub mGenericID: u8,
pub mScriptLevel: i8,
pub mMathVariant: u8,
pub const nsStyleFont_kHasFinishStyle: bool = false;
#[test]
fn bindgen_test_layout_nsStyleFont() {
assert_eq!(::std::mem::size_of::<nsStyleFont>() , 120usize , concat !
assert_eq!(::std::mem::size_of::<nsStyleFont>() , 128usize , concat !
( "Size of: " , stringify ! ( nsStyleFont ) ));
assert_eq! (::std::mem::align_of::<nsStyleFont>() , 8usize , concat !
( "Alignment of " , stringify ! ( nsStyleFont ) ));
as usize } , 88usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mSize ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mFontSizeFactor as
* const _ as usize } , 92usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mFontSizeFactor ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mFontSizeOffset as
* const _ as usize } , 96usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mFontSizeOffset ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mFontSizeKeyword as
* const _ as usize } , 100usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mFontSizeKeyword ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mGenericID as *
const _ as usize } , 92usize , concat ! (
const _ as usize } , 101usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mGenericID ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mScriptLevel as *
const _ as usize } , 93usize , concat ! (
const _ as usize } , 102usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mScriptLevel ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mMathVariant as *
const _ as usize } , 94usize , concat ! (
const _ as usize } , 103usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mMathVariant ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mMathDisplay as *
const _ as usize } , 95usize , concat ! (
const _ as usize } , 104usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mMathDisplay ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mMinFontSizeRatio
as * const _ as usize } , 96usize , concat ! (
as * const _ as usize } , 105usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mMinFontSizeRatio ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mExplicitLanguage
as * const _ as usize } , 97usize , concat ! (
as * const _ as usize } , 106usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mExplicitLanguage ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mAllowZoom as *
const _ as usize } , 98usize , concat ! (
const _ as usize } , 107usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mAllowZoom ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) .
mScriptUnconstrainedSize as * const _ as usize } ,
100usize , concat ! (
108usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mScriptUnconstrainedSize ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mScriptMinSize as *
const _ as usize } , 104usize , concat ! (
const _ as usize } , 112usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mScriptMinSize ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) .
mScriptSizeMultiplier as * const _ as usize } , 108usize ,
mScriptSizeMultiplier as * const _ as usize } , 116usize ,
concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mScriptSizeMultiplier ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mLanguage as *
const _ as usize } , 112usize , concat ! (
const _ as usize } , 120usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mLanguage ) ));
}
@@ -440,6 +440,7 @@ pub mod root {
pub const NS_STYLE_FONT_SIZE_XXXLARGE: ::std::os::raw::c_uint = 7;
pub const NS_STYLE_FONT_SIZE_LARGER: ::std::os::raw::c_uint = 8;
pub const NS_STYLE_FONT_SIZE_SMALLER: ::std::os::raw::c_uint = 9;
pub const NS_STYLE_FONT_SIZE_NO_KEYWORD: ::std::os::raw::c_uint = 10;
pub const NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED: ::std::os::raw::c_int =
-4;
pub const NS_STYLE_FONT_STRETCH_EXTRA_CONDENSED: ::std::os::raw::c_int =
@@ -4448,7 +4449,7 @@ pub mod root {
}
#[test]
fn bindgen_test_layout_GeckoFont() {
assert_eq!(::std::mem::size_of::<GeckoFont>() , 120usize , concat
assert_eq!(::std::mem::size_of::<GeckoFont>() , 128usize , concat
! ( "Size of: " , stringify ! ( GeckoFont ) ));
assert_eq! (::std::mem::align_of::<GeckoFont>() , 8usize , concat
! ( "Alignment of " , stringify ! ( GeckoFont ) ));
pub struct nsStyleFont {
pub mFont: root::nsFont,
pub mSize: root::nscoord,
pub mFontSizeFactor: f32,
pub mFontSizeOffset: root::nscoord,
pub mFontSizeKeyword: u8,
pub mGenericID: u8,
pub mScriptLevel: i8,
pub mMathVariant: u8,
pub const nsStyleFont_kHasFinishStyle: bool = false;
#[test]
fn bindgen_test_layout_nsStyleFont() {
assert_eq!(::std::mem::size_of::<nsStyleFont>() , 120usize , concat !
assert_eq!(::std::mem::size_of::<nsStyleFont>() , 128usize , concat !
( "Size of: " , stringify ! ( nsStyleFont ) ));
assert_eq! (::std::mem::align_of::<nsStyleFont>() , 8usize , concat !
( "Alignment of " , stringify ! ( nsStyleFont ) ));
as usize } , 88usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mSize ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mFontSizeFactor as
* const _ as usize } , 92usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mFontSizeFactor ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mFontSizeOffset as
* const _ as usize } , 96usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mFontSizeOffset ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mFontSizeKeyword as
* const _ as usize } , 100usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mFontSizeKeyword ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mGenericID as *
const _ as usize } , 92usize , concat ! (
const _ as usize } , 101usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mGenericID ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mScriptLevel as *
const _ as usize } , 93usize , concat ! (
const _ as usize } , 102usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mScriptLevel ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mMathVariant as *
const _ as usize } , 94usize , concat ! (
const _ as usize } , 103usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mMathVariant ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mMathDisplay as *
const _ as usize } , 95usize , concat ! (
const _ as usize } , 104usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mMathDisplay ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mMinFontSizeRatio
as * const _ as usize } , 96usize , concat ! (
as * const _ as usize } , 105usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mMinFontSizeRatio ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mExplicitLanguage
as * const _ as usize } , 97usize , concat ! (
as * const _ as usize } , 106usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mExplicitLanguage ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mAllowZoom as *
const _ as usize } , 98usize , concat ! (
const _ as usize } , 107usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mAllowZoom ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) .
mScriptUnconstrainedSize as * const _ as usize } ,
100usize , concat ! (
108usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mScriptUnconstrainedSize ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mScriptMinSize as *
const _ as usize } , 104usize , concat ! (
const _ as usize } , 112usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mScriptMinSize ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) .
mScriptSizeMultiplier as * const _ as usize } , 108usize ,
mScriptSizeMultiplier as * const _ as usize } , 116usize ,
concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mScriptSizeMultiplier ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const nsStyleFont ) ) . mLanguage as *
const _ as usize } , 112usize , concat ! (
const _ as usize } , 120usize , concat ! (
"Alignment of field: " , stringify ! ( nsStyleFont ) ,
"::" , stringify ! ( mLanguage ) ));
}
@@ -2167,8 +2167,27 @@ fn static_assert() {
}

pub fn set_font_size(&mut self, v: longhands::font_size::computed_value::T) {
use self::longhands::font_size::KeywordSize;
self.gecko.mSize = v.size().0;
self.gecko.mScriptUnconstrainedSize = v.size().0;
if let Some(info) = v.info {
self.gecko.mFontSizeKeyword = match info.kw {
KeywordSize::XXSmall => structs::NS_STYLE_FONT_SIZE_XXSMALL,
KeywordSize::XSmall => structs::NS_STYLE_FONT_SIZE_XSMALL,
KeywordSize::Small => structs::NS_STYLE_FONT_SIZE_SMALL,
KeywordSize::Medium => structs::NS_STYLE_FONT_SIZE_MEDIUM,
KeywordSize::Large => structs::NS_STYLE_FONT_SIZE_LARGE,
KeywordSize::XLarge => structs::NS_STYLE_FONT_SIZE_XLARGE,
KeywordSize::XXLarge => structs::NS_STYLE_FONT_SIZE_XXLARGE,
KeywordSize::XXXLarge => structs::NS_STYLE_FONT_SIZE_XXXLARGE,
} as u8;
self.gecko.mFontSizeFactor = info.factor;
self.gecko.mFontSizeOffset = info.offset.0.to_i32_au();
} else {
self.gecko.mFontSizeKeyword = structs::NS_STYLE_FONT_SIZE_NO_KEYWORD as u8;
self.gecko.mFontSizeFactor = 1.;
self.gecko.mFontSizeOffset = 0;
}
}

/// Set font size, taking into account scriptminsize and scriptlevel
@@ -2327,12 +2346,24 @@ fn static_assert() {
// In the case that MathML has given us an adjusted size, apply it.
// Keep track of the unconstrained adjusted size.
self.gecko.mSize = adjusted_size.0;

// Technically the MathML constrained size may also be keyword-derived
// but we ignore this since it would be too complicated
// to correctly track and it's mostly unnecessary.
self.gecko.mFontSizeKeyword = structs::NS_STYLE_FONT_SIZE_NO_KEYWORD as u8;
self.gecko.mFontSizeFactor = 1.;
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();
// Copy keyword info over.
self.gecko.mFontSizeFactor = parent.gecko.mFontSizeFactor;
self.gecko.mFontSizeOffset = parent.gecko.mFontSizeOffset;
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);
@@ -2341,16 +2372,43 @@ fn static_assert() {
// MathML isn't affecting us, and our parent element does not
// have a keyword-derived size. Set things normally.
self.gecko.mSize = parent.gecko.mSize;
// copy keyword info over
self.gecko.mFontSizeKeyword = structs::NS_STYLE_FONT_SIZE_NO_KEYWORD as u8;
self.gecko.mFontSizeFactor = 1.;
self.gecko.mFontSizeOffset = 0;
self.gecko.mScriptUnconstrainedSize = parent.gecko.mScriptUnconstrainedSize;
self.fixup_font_min_size(device);
false
}
}

pub fn clone_font_size(&self) -> longhands::font_size::computed_value::T {
use self::longhands::font_size::KeywordSize;
let size = Au(self.gecko.mSize).into();
let kw = match self.gecko.mFontSizeKeyword as u32 {
structs::NS_STYLE_FONT_SIZE_XXSMALL => KeywordSize::XXSmall,
structs::NS_STYLE_FONT_SIZE_XSMALL => KeywordSize::XSmall,
structs::NS_STYLE_FONT_SIZE_SMALL => KeywordSize::Small,
structs::NS_STYLE_FONT_SIZE_MEDIUM => KeywordSize::Medium,
structs::NS_STYLE_FONT_SIZE_LARGE => KeywordSize::Large,
structs::NS_STYLE_FONT_SIZE_XLARGE => KeywordSize::XLarge,
structs::NS_STYLE_FONT_SIZE_XXLARGE => KeywordSize::XXLarge,
structs::NS_STYLE_FONT_SIZE_XXXLARGE => KeywordSize::XXXLarge,
structs::NS_STYLE_FONT_SIZE_NO_KEYWORD => {
return longhands::font_size::computed_value::T {
size: size,
info: None,
}
}
_ => unreachable!("mFontSizeKeyword should be an absolute keyword or NO_KEYWORD")
};
longhands::font_size::computed_value::T {
size: Au(self.gecko.mSize).into(),
info: None, // XXXManishearth this is a placeholder
size: size,
info: Some(longhands::font_size::computed_value::KeywordInfo {
kw: kw,
factor: self.gecko.mFontSizeFactor,
offset: Au(self.gecko.mFontSizeOffset).into()
})
}
}

0 comments on commit c73dc57

Please sign in to comment.
You can’t perform that action at this time.