mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Add binding function for setting property
This commit is contained in:
parent
9ef1292957
commit
edec344b15
2 changed files with 30 additions and 0 deletions
|
@ -976,6 +976,14 @@ extern "C" {
|
||||||
is_custom: bool)
|
is_custom: bool)
|
||||||
-> bool;
|
-> bool;
|
||||||
}
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Servo_DeclarationBlock_SetProperty(declarations:
|
||||||
|
RawServoDeclarationBlockBorrowed,
|
||||||
|
property: *mut nsIAtom,
|
||||||
|
is_custom: bool,
|
||||||
|
value: *mut nsACString_internal,
|
||||||
|
is_important: bool) -> bool;
|
||||||
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_DeclarationBlock_RemoveProperty(declarations:
|
pub fn Servo_DeclarationBlock_RemoveProperty(declarations:
|
||||||
RawServoDeclarationBlockBorrowed,
|
RawServoDeclarationBlockBorrowed,
|
||||||
|
|
|
@ -538,6 +538,28 @@ pub extern "C" fn Servo_DeclarationBlock_GetPropertyIsImportant(declarations: Ra
|
||||||
declarations.read().property_priority(&property).important()
|
declarations.read().property_priority(&property).important()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn Servo_DeclarationBlock_SetProperty(declarations: RawServoDeclarationBlockBorrowed,
|
||||||
|
property: *mut nsIAtom, is_custom: bool,
|
||||||
|
value: *mut nsACString, is_important: bool) -> bool {
|
||||||
|
let property = get_property_name_from_atom(property, is_custom);
|
||||||
|
let value = unsafe { value.as_ref().unwrap().as_str_unchecked() };
|
||||||
|
// FIXME Needs real URL and ParserContextExtraData.
|
||||||
|
let base_url = &*DUMMY_BASE_URL;
|
||||||
|
let extra_data = ParserContextExtraData::default();
|
||||||
|
if let Ok(decls) = parse_one_declaration(&property, value, &base_url,
|
||||||
|
Box::new(StdoutErrorReporter), extra_data) {
|
||||||
|
let mut declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations).write();
|
||||||
|
let importance = if is_important { Importance::Important } else { Importance::Normal };
|
||||||
|
for decl in decls.into_iter() {
|
||||||
|
declarations.set_parsed_declaration(decl, importance);
|
||||||
|
}
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_DeclarationBlock_RemoveProperty(declarations: RawServoDeclarationBlockBorrowed,
|
pub extern "C" fn Servo_DeclarationBlock_RemoveProperty(declarations: RawServoDeclarationBlockBorrowed,
|
||||||
property: *mut nsIAtom, is_custom: bool) {
|
property: *mut nsIAtom, is_custom: bool) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue