mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
stylo: Bypass cache when fetching font size prefs from Stylo
This commit is contained in:
parent
6020c2feeb
commit
2ea8d61fbf
6 changed files with 142 additions and 8 deletions
|
@ -338,6 +338,7 @@ mod bindings {
|
||||||
"FontFamilyListRefCnt",
|
"FontFamilyListRefCnt",
|
||||||
"FontFamilyName",
|
"FontFamilyName",
|
||||||
"FontFamilyType",
|
"FontFamilyType",
|
||||||
|
"FontSizePrefs",
|
||||||
"FragmentOrURL",
|
"FragmentOrURL",
|
||||||
"FrameRequestCallback",
|
"FrameRequestCallback",
|
||||||
"GeckoParserExtraData",
|
"GeckoParserExtraData",
|
||||||
|
@ -623,6 +624,7 @@ mod bindings {
|
||||||
"ComputedTimingFunction_BeforeFlag",
|
"ComputedTimingFunction_BeforeFlag",
|
||||||
"FontFamilyList",
|
"FontFamilyList",
|
||||||
"FontFamilyType",
|
"FontFamilyType",
|
||||||
|
"FontSizePrefs",
|
||||||
"Keyframe",
|
"Keyframe",
|
||||||
"ServoBundledURI",
|
"ServoBundledURI",
|
||||||
"ServoElementSnapshot",
|
"ServoElementSnapshot",
|
||||||
|
|
|
@ -27,6 +27,7 @@ use gecko_bindings::structs::TraversalRootBehavior;
|
||||||
use gecko_bindings::structs::ComputedTimingFunction_BeforeFlag;
|
use gecko_bindings::structs::ComputedTimingFunction_BeforeFlag;
|
||||||
use gecko_bindings::structs::FontFamilyList;
|
use gecko_bindings::structs::FontFamilyList;
|
||||||
use gecko_bindings::structs::FontFamilyType;
|
use gecko_bindings::structs::FontFamilyType;
|
||||||
|
use gecko_bindings::structs::FontSizePrefs;
|
||||||
use gecko_bindings::structs::Keyframe;
|
use gecko_bindings::structs::Keyframe;
|
||||||
use gecko_bindings::structs::ServoBundledURI;
|
use gecko_bindings::structs::ServoBundledURI;
|
||||||
use gecko_bindings::structs::ServoElementSnapshot;
|
use gecko_bindings::structs::ServoElementSnapshot;
|
||||||
|
@ -1062,10 +1063,9 @@ extern "C" {
|
||||||
aSource: *const nsStyleFont);
|
aSource: *const nsStyleFont);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_nsStyleFont_GetBaseSize(font: *const nsStyleFont,
|
pub fn Gecko_GetBaseSize(lang: *mut nsIAtom,
|
||||||
pres_context:
|
pres_context: RawGeckoPresContextBorrowed)
|
||||||
RawGeckoPresContextBorrowed)
|
-> FontSizePrefs;
|
||||||
-> nscoord;
|
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Gecko_GetMediaFeatures() -> *const nsMediaFeature;
|
pub fn Gecko_GetMediaFeatures() -> *const nsMediaFeature;
|
||||||
|
|
|
@ -27150,6 +27150,67 @@ pub mod root {
|
||||||
fn clone(&self) -> Self { *self }
|
fn clone(&self) -> Self { *self }
|
||||||
}
|
}
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Debug, Copy)]
|
||||||
|
pub struct FontSizePrefs {
|
||||||
|
pub mDefaultVariableSize: root::nscoord,
|
||||||
|
pub mDefaultFixedSize: root::nscoord,
|
||||||
|
pub mDefaultSerifSize: root::nscoord,
|
||||||
|
pub mDefaultSansSerifSize: root::nscoord,
|
||||||
|
pub mDefaultMonospaceSize: root::nscoord,
|
||||||
|
pub mDefaultCursiveSize: root::nscoord,
|
||||||
|
pub mDefaultFantasySize: root::nscoord,
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn bindgen_test_layout_FontSizePrefs() {
|
||||||
|
assert_eq!(::std::mem::size_of::<FontSizePrefs>() , 28usize , concat !
|
||||||
|
( "Size of: " , stringify ! ( FontSizePrefs ) ));
|
||||||
|
assert_eq! (::std::mem::align_of::<FontSizePrefs>() , 4usize , concat
|
||||||
|
! ( "Alignment of " , stringify ! ( FontSizePrefs ) ));
|
||||||
|
assert_eq! (unsafe {
|
||||||
|
& ( * ( 0 as * const FontSizePrefs ) ) .
|
||||||
|
mDefaultVariableSize as * const _ as usize } , 0usize ,
|
||||||
|
concat ! (
|
||||||
|
"Alignment of field: " , stringify ! ( FontSizePrefs ) ,
|
||||||
|
"::" , stringify ! ( mDefaultVariableSize ) ));
|
||||||
|
assert_eq! (unsafe {
|
||||||
|
& ( * ( 0 as * const FontSizePrefs ) ) . mDefaultFixedSize
|
||||||
|
as * const _ as usize } , 4usize , concat ! (
|
||||||
|
"Alignment of field: " , stringify ! ( FontSizePrefs ) ,
|
||||||
|
"::" , stringify ! ( mDefaultFixedSize ) ));
|
||||||
|
assert_eq! (unsafe {
|
||||||
|
& ( * ( 0 as * const FontSizePrefs ) ) . mDefaultSerifSize
|
||||||
|
as * const _ as usize } , 8usize , concat ! (
|
||||||
|
"Alignment of field: " , stringify ! ( FontSizePrefs ) ,
|
||||||
|
"::" , stringify ! ( mDefaultSerifSize ) ));
|
||||||
|
assert_eq! (unsafe {
|
||||||
|
& ( * ( 0 as * const FontSizePrefs ) ) .
|
||||||
|
mDefaultSansSerifSize as * const _ as usize } , 12usize ,
|
||||||
|
concat ! (
|
||||||
|
"Alignment of field: " , stringify ! ( FontSizePrefs ) ,
|
||||||
|
"::" , stringify ! ( mDefaultSansSerifSize ) ));
|
||||||
|
assert_eq! (unsafe {
|
||||||
|
& ( * ( 0 as * const FontSizePrefs ) ) .
|
||||||
|
mDefaultMonospaceSize as * const _ as usize } , 16usize ,
|
||||||
|
concat ! (
|
||||||
|
"Alignment of field: " , stringify ! ( FontSizePrefs ) ,
|
||||||
|
"::" , stringify ! ( mDefaultMonospaceSize ) ));
|
||||||
|
assert_eq! (unsafe {
|
||||||
|
& ( * ( 0 as * const FontSizePrefs ) ) .
|
||||||
|
mDefaultCursiveSize as * const _ as usize } , 20usize ,
|
||||||
|
concat ! (
|
||||||
|
"Alignment of field: " , stringify ! ( FontSizePrefs ) ,
|
||||||
|
"::" , stringify ! ( mDefaultCursiveSize ) ));
|
||||||
|
assert_eq! (unsafe {
|
||||||
|
& ( * ( 0 as * const FontSizePrefs ) ) .
|
||||||
|
mDefaultFantasySize as * const _ as usize } , 24usize ,
|
||||||
|
concat ! (
|
||||||
|
"Alignment of field: " , stringify ! ( FontSizePrefs ) ,
|
||||||
|
"::" , stringify ! ( mDefaultFantasySize ) ));
|
||||||
|
}
|
||||||
|
impl Clone for FontSizePrefs {
|
||||||
|
fn clone(&self) -> Self { *self }
|
||||||
|
}
|
||||||
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct nsROCSSPrimitiveValue([u8; 0]);
|
pub struct nsROCSSPrimitiveValue([u8; 0]);
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
|
|
@ -26491,6 +26491,67 @@ pub mod root {
|
||||||
fn clone(&self) -> Self { *self }
|
fn clone(&self) -> Self { *self }
|
||||||
}
|
}
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Debug, Copy)]
|
||||||
|
pub struct FontSizePrefs {
|
||||||
|
pub mDefaultVariableSize: root::nscoord,
|
||||||
|
pub mDefaultFixedSize: root::nscoord,
|
||||||
|
pub mDefaultSerifSize: root::nscoord,
|
||||||
|
pub mDefaultSansSerifSize: root::nscoord,
|
||||||
|
pub mDefaultMonospaceSize: root::nscoord,
|
||||||
|
pub mDefaultCursiveSize: root::nscoord,
|
||||||
|
pub mDefaultFantasySize: root::nscoord,
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn bindgen_test_layout_FontSizePrefs() {
|
||||||
|
assert_eq!(::std::mem::size_of::<FontSizePrefs>() , 28usize , concat !
|
||||||
|
( "Size of: " , stringify ! ( FontSizePrefs ) ));
|
||||||
|
assert_eq! (::std::mem::align_of::<FontSizePrefs>() , 4usize , concat
|
||||||
|
! ( "Alignment of " , stringify ! ( FontSizePrefs ) ));
|
||||||
|
assert_eq! (unsafe {
|
||||||
|
& ( * ( 0 as * const FontSizePrefs ) ) .
|
||||||
|
mDefaultVariableSize as * const _ as usize } , 0usize ,
|
||||||
|
concat ! (
|
||||||
|
"Alignment of field: " , stringify ! ( FontSizePrefs ) ,
|
||||||
|
"::" , stringify ! ( mDefaultVariableSize ) ));
|
||||||
|
assert_eq! (unsafe {
|
||||||
|
& ( * ( 0 as * const FontSizePrefs ) ) . mDefaultFixedSize
|
||||||
|
as * const _ as usize } , 4usize , concat ! (
|
||||||
|
"Alignment of field: " , stringify ! ( FontSizePrefs ) ,
|
||||||
|
"::" , stringify ! ( mDefaultFixedSize ) ));
|
||||||
|
assert_eq! (unsafe {
|
||||||
|
& ( * ( 0 as * const FontSizePrefs ) ) . mDefaultSerifSize
|
||||||
|
as * const _ as usize } , 8usize , concat ! (
|
||||||
|
"Alignment of field: " , stringify ! ( FontSizePrefs ) ,
|
||||||
|
"::" , stringify ! ( mDefaultSerifSize ) ));
|
||||||
|
assert_eq! (unsafe {
|
||||||
|
& ( * ( 0 as * const FontSizePrefs ) ) .
|
||||||
|
mDefaultSansSerifSize as * const _ as usize } , 12usize ,
|
||||||
|
concat ! (
|
||||||
|
"Alignment of field: " , stringify ! ( FontSizePrefs ) ,
|
||||||
|
"::" , stringify ! ( mDefaultSansSerifSize ) ));
|
||||||
|
assert_eq! (unsafe {
|
||||||
|
& ( * ( 0 as * const FontSizePrefs ) ) .
|
||||||
|
mDefaultMonospaceSize as * const _ as usize } , 16usize ,
|
||||||
|
concat ! (
|
||||||
|
"Alignment of field: " , stringify ! ( FontSizePrefs ) ,
|
||||||
|
"::" , stringify ! ( mDefaultMonospaceSize ) ));
|
||||||
|
assert_eq! (unsafe {
|
||||||
|
& ( * ( 0 as * const FontSizePrefs ) ) .
|
||||||
|
mDefaultCursiveSize as * const _ as usize } , 20usize ,
|
||||||
|
concat ! (
|
||||||
|
"Alignment of field: " , stringify ! ( FontSizePrefs ) ,
|
||||||
|
"::" , stringify ! ( mDefaultCursiveSize ) ));
|
||||||
|
assert_eq! (unsafe {
|
||||||
|
& ( * ( 0 as * const FontSizePrefs ) ) .
|
||||||
|
mDefaultFantasySize as * const _ as usize } , 24usize ,
|
||||||
|
concat ! (
|
||||||
|
"Alignment of field: " , stringify ! ( FontSizePrefs ) ,
|
||||||
|
"::" , stringify ! ( mDefaultFantasySize ) ));
|
||||||
|
}
|
||||||
|
impl Clone for FontSizePrefs {
|
||||||
|
fn clone(&self) -> Self { *self }
|
||||||
|
}
|
||||||
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct nsROCSSPrimitiveValue([u8; 0]);
|
pub struct nsROCSSPrimitiveValue([u8; 0]);
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
|
|
@ -536,7 +536,8 @@ ${helpers.single_keyword("font-variant-caps",
|
||||||
type ComputedValue = Au;
|
type ComputedValue = Au;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_computed_value(&self, cx: &Context) -> computed_value::T {
|
fn to_computed_value(&self, cx: &Context) -> computed_value::T {
|
||||||
use gecko_bindings::bindings::Gecko_nsStyleFont_GetBaseSize;
|
use gecko_bindings::bindings::Gecko_GetBaseSize;
|
||||||
|
use gecko_bindings::structs;
|
||||||
use values::specified::length::au_to_int_px;
|
use values::specified::length::au_to_int_px;
|
||||||
// Data from nsRuleNode.cpp in Gecko
|
// Data from nsRuleNode.cpp in Gecko
|
||||||
// Mapping from base size and HTML size to pixels
|
// Mapping from base size and HTML size to pixels
|
||||||
|
@ -561,10 +562,18 @@ ${helpers.single_keyword("font-variant-caps",
|
||||||
|
|
||||||
// XXXManishearth handle quirks mode
|
// XXXManishearth handle quirks mode
|
||||||
|
|
||||||
let base_size = unsafe {
|
let base_sizes = unsafe {
|
||||||
Gecko_nsStyleFont_GetBaseSize(cx.style().get_font().gecko(),
|
Gecko_GetBaseSize(cx.style().get_font().gecko().mLanguage.raw())
|
||||||
&*cx.device.pres_context)
|
|
||||||
};
|
};
|
||||||
|
let base_size = match cx.style().get_font().gecko().mGenericID {
|
||||||
|
structs::kGenericFont_serif => base_sizes.mDefaultSerifSize,
|
||||||
|
structs::kGenericFont_sans_serif => base_sizes.mDefaultSansSerifSize,
|
||||||
|
structs::kGenericFont_monospace => base_sizes.mDefaultMonospaceSize,
|
||||||
|
structs::kGenericFont_cursive => base_sizes.mDefaultCursiveSize,
|
||||||
|
structs::kGenericFont_fantasy => base_sizes.mDefaultFantasySize,
|
||||||
|
x => unreachable!("Unknown generic ID {}", x),
|
||||||
|
};
|
||||||
|
|
||||||
let base_size_px = au_to_int_px(base_size as f32);
|
let base_size_px = au_to_int_px(base_size as f32);
|
||||||
let html_size = *self as usize;
|
let html_size = *self as usize;
|
||||||
if base_size_px >= 9 && base_size_px <= 16 {
|
if base_size_px >= 9 && base_size_px <= 16 {
|
||||||
|
|
|
@ -2109,6 +2109,7 @@ pub fn apply_declarations<'a, F, I>(device: &Device,
|
||||||
| LonghandId::TextOrientation
|
| LonghandId::TextOrientation
|
||||||
| LonghandId::AnimationName
|
| LonghandId::AnimationName
|
||||||
| LonghandId::TransitionProperty
|
| LonghandId::TransitionProperty
|
||||||
|
| LonghandId::XLang
|
||||||
% endif
|
% endif
|
||||||
);
|
);
|
||||||
if
|
if
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue