From 0d96c7997fc5ea17f8ea7f2390d7f73bf7730bc1 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Thu, 30 Mar 2017 10:44:14 +1100 Subject: [PATCH] Support CSSOM access to @font-face rules. --- ports/geckolib/glue.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 8f16fe47c6d..318932d82ca 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -54,7 +54,7 @@ use style::gecko_bindings::bindings::nsTimingFunctionBorrowedMut; use style::gecko_bindings::structs; use style::gecko_bindings::structs::{SheetParsingMode, nsIAtom, nsCSSPropertyID}; use style::gecko_bindings::structs::{ThreadSafePrincipalHolder, ThreadSafeURIHolder}; -use style::gecko_bindings::structs::{nsRestyleHint, nsChangeHint}; +use style::gecko_bindings::structs::{nsRestyleHint, nsChangeHint, nsCSSFontFaceRule}; use style::gecko_bindings::structs::Loader; use style::gecko_bindings::structs::RawGeckoPresContextOwned; use style::gecko_bindings::structs::ServoStyleSheet; @@ -602,6 +602,19 @@ impl_basic_rule_funcs! { (Namespace, NamespaceRule, RawServoNamespaceRule), to_css: Servo_NamespaceRule_GetCssText, } +#[no_mangle] +pub extern "C" fn Servo_CssRules_GetFontFaceRuleAt(rules: ServoCssRulesBorrowed, index: u32) + -> *mut nsCSSFontFaceRule +{ + let global_style_data = &*GLOBAL_STYLE_DATA; + let guard = global_style_data.shared_lock.read(); + let rules = Locked::::as_arc(&rules).read_with(&guard); + match rules.0[index as usize] { + CssRule::FontFace(ref rule) => rule.read_with(&guard).get(), + _ => unreachable!("Servo_CssRules_GetFontFaceRuleAt should only be called on a FontFace rule"), + } +} + #[no_mangle] pub extern "C" fn Servo_StyleRule_GetStyle(rule: RawServoStyleRuleBorrowed) -> RawServoDeclarationBlockStrong { read_locked_arc(rule, |rule: &StyleRule| {