From 1154600dd44438b4af9959288ac34b7a004a316d Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 7 Apr 2017 15:49:44 -0700 Subject: [PATCH] stylo: Add bindings for fetching font metrics from Gecko --- components/style/build_gecko.rs | 2 ++ components/style/gecko_bindings/bindings.rs | 7 +++++ .../style/gecko_bindings/structs_debug.rs | 27 +++++++++++++++++++ .../style/gecko_bindings/structs_release.rs | 27 +++++++++++++++++++ 4 files changed, 63 insertions(+) diff --git a/components/style/build_gecko.rs b/components/style/build_gecko.rs index 85997cdb3c2..3a8cd29b41f 100644 --- a/components/style/build_gecko.rs +++ b/components/style/build_gecko.rs @@ -343,6 +343,7 @@ mod bindings { "FragmentOrURL", "FrameRequestCallback", "GeckoParserExtraData", + "GeckoFontMetrics", "gfxAlternateValue", "gfxFontFeature", "gfxFontVariation", @@ -626,6 +627,7 @@ mod bindings { "FontFamilyList", "FontFamilyType", "FontSizePrefs", + "GeckoFontMetrics", "Keyframe", "ServoBundledURI", "ServoElementSnapshot", diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index 9f9ed20ff44..35e7f17f9ed 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -28,6 +28,7 @@ use gecko_bindings::structs::ComputedTimingFunction_BeforeFlag; use gecko_bindings::structs::FontFamilyList; use gecko_bindings::structs::FontFamilyType; use gecko_bindings::structs::FontSizePrefs; +use gecko_bindings::structs::GeckoFontMetrics; use gecko_bindings::structs::Keyframe; use gecko_bindings::structs::ServoBundledURI; use gecko_bindings::structs::ServoElementSnapshot; @@ -1076,6 +1077,12 @@ extern "C" { extern "C" { pub fn Gecko_GetBaseSize(lang: *mut nsIAtom) -> FontSizePrefs; } +extern "C" { + pub fn Gecko_GetFontMetrics(pres_context: RawGeckoPresContextBorrowed, + is_vertical: bool, font: *const nsStyleFont, + font_size: nscoord, use_user_font_set: bool) + -> GeckoFontMetrics; +} extern "C" { pub fn Gecko_GetMediaFeatures() -> *const nsMediaFeature; } diff --git a/components/style/gecko_bindings/structs_debug.rs b/components/style/gecko_bindings/structs_debug.rs index 1c65c51d414..128fdde4d23 100644 --- a/components/style/gecko_bindings/structs_debug.rs +++ b/components/style/gecko_bindings/structs_debug.rs @@ -27213,6 +27213,33 @@ pub mod root { fn clone(&self) -> Self { *self } } #[repr(C)] + #[derive(Debug, Copy)] + pub struct GeckoFontMetrics { + pub mChSize: root::nscoord, + pub mXSize: root::nscoord, + } + #[test] + fn bindgen_test_layout_GeckoFontMetrics() { + assert_eq!(::std::mem::size_of::() , 8usize , concat + ! ( "Size of: " , stringify ! ( GeckoFontMetrics ) )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( GeckoFontMetrics ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const GeckoFontMetrics ) ) . mChSize as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( GeckoFontMetrics ) + , "::" , stringify ! ( mChSize ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const GeckoFontMetrics ) ) . mXSize as * + const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( GeckoFontMetrics ) + , "::" , stringify ! ( mXSize ) )); + } + impl Clone for GeckoFontMetrics { + fn clone(&self) -> Self { *self } + } + #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct nsROCSSPrimitiveValue([u8; 0]); #[repr(C)] diff --git a/components/style/gecko_bindings/structs_release.rs b/components/style/gecko_bindings/structs_release.rs index e75474a2b43..34415e0ced0 100644 --- a/components/style/gecko_bindings/structs_release.rs +++ b/components/style/gecko_bindings/structs_release.rs @@ -26554,6 +26554,33 @@ pub mod root { fn clone(&self) -> Self { *self } } #[repr(C)] + #[derive(Debug, Copy)] + pub struct GeckoFontMetrics { + pub mChSize: root::nscoord, + pub mXSize: root::nscoord, + } + #[test] + fn bindgen_test_layout_GeckoFontMetrics() { + assert_eq!(::std::mem::size_of::() , 8usize , concat + ! ( "Size of: " , stringify ! ( GeckoFontMetrics ) )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( GeckoFontMetrics ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const GeckoFontMetrics ) ) . mChSize as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( GeckoFontMetrics ) + , "::" , stringify ! ( mChSize ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const GeckoFontMetrics ) ) . mXSize as * + const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( GeckoFontMetrics ) + , "::" , stringify ! ( mXSize ) )); + } + impl Clone for GeckoFontMetrics { + fn clone(&self) -> Self { *self } + } + #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct nsROCSSPrimitiveValue([u8; 0]); #[repr(C)]