diff options
-rw-r--r-- | components/style/gecko_bindings/bindings.rs | 22 | ||||
-rw-r--r-- | ports/geckolib/glue.rs | 38 |
2 files changed, 60 insertions, 0 deletions
diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index b3fa77ee974..e054a37eec9 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -961,6 +961,28 @@ extern "C" { -> bool; } extern "C" { + pub fn Servo_DeclarationBlock_GetPropertyValue(declarations: + RawServoDeclarationBlockBorrowed, + property: *mut nsIAtom, + is_custom: bool, + value: + *mut nsAString_internal); +} +extern "C" { + pub fn Servo_DeclarationBlock_GetPropertyIsImportant(declarations: + RawServoDeclarationBlockBorrowed, + property: + *mut nsIAtom, + is_custom: bool) + -> bool; +} +extern "C" { + pub fn Servo_DeclarationBlock_RemoveProperty(declarations: + RawServoDeclarationBlockBorrowed, + property: *mut nsIAtom, + is_custom: bool); +} +extern "C" { pub fn Servo_CSSSupports(name: *const nsACString_internal, value: *const nsACString_internal) -> bool; } diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index becd1ff7dc0..ce65420c6a9 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -508,6 +508,44 @@ pub extern "C" fn Servo_DeclarationBlock_GetNthProperty(declarations: RawServoDe } } +// FIXME Methods of PropertyDeclarationBlock should take atoms directly. +// This function is just a temporary workaround before that finishes. +fn get_property_name_from_atom(atom: *mut nsIAtom, is_custom: bool) -> String { + let atom = Atom::from(atom); + if !is_custom { + atom.to_string() + } else { + let mut result = String::with_capacity(atom.len() as usize + 2); + write!(result, "--{}", atom).unwrap(); + result + } +} + +#[no_mangle] +pub extern "C" fn Servo_DeclarationBlock_GetPropertyValue(declarations: RawServoDeclarationBlockBorrowed, + property: *mut nsIAtom, is_custom: bool, + value: *mut nsAString) { + let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations); + let property = get_property_name_from_atom(property, is_custom); + declarations.read().property_value_to_css(&property, unsafe { value.as_mut().unwrap() }).unwrap(); +} + +#[no_mangle] +pub extern "C" fn Servo_DeclarationBlock_GetPropertyIsImportant(declarations: RawServoDeclarationBlockBorrowed, + property: *mut nsIAtom, is_custom: bool) -> bool { + let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations); + let property = get_property_name_from_atom(property, is_custom); + declarations.read().property_priority(&property).important() +} + +#[no_mangle] +pub extern "C" fn Servo_DeclarationBlock_RemoveProperty(declarations: RawServoDeclarationBlockBorrowed, + property: *mut nsIAtom, is_custom: bool) { + let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations); + let property = get_property_name_from_atom(property, is_custom); + declarations.write().remove_property(&property); +} + #[no_mangle] pub extern "C" fn Servo_CSSSupports(property: *const nsACString, value: *const nsACString) -> bool { let property = unsafe { property.as_ref().unwrap().as_str_unchecked() }; |