aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXidorn Quan <me@upsuper.org>2016-11-03 15:03:48 +1100
committerXidorn Quan <me@upsuper.org>2016-11-03 15:03:48 +1100
commitedec344b15fa1245f319d64b5ec0754322d83ff4 (patch)
tree8004709a598104b419c80497400ca9226a70af9e
parent9ef129295789bfc1741bbd3646739e38bd86e5f1 (diff)
downloadservo-edec344b15fa1245f319d64b5ec0754322d83ff4.tar.gz
servo-edec344b15fa1245f319d64b5ec0754322d83ff4.zip
Add binding function for setting property
-rw-r--r--components/style/gecko_bindings/bindings.rs8
-rw-r--r--ports/geckolib/glue.rs22
2 files changed, 30 insertions, 0 deletions
diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs
index e054a37eec9..6611454dbdb 100644
--- a/components/style/gecko_bindings/bindings.rs
+++ b/components/style/gecko_bindings/bindings.rs
@@ -977,6 +977,14 @@ extern "C" {
-> 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" {
pub fn Servo_DeclarationBlock_RemoveProperty(declarations:
RawServoDeclarationBlockBorrowed,
property: *mut nsIAtom,
diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs
index ce65420c6a9..1e28edf114b 100644
--- a/ports/geckolib/glue.rs
+++ b/ports/geckolib/glue.rs
@@ -539,6 +539,28 @@ pub extern "C" fn Servo_DeclarationBlock_GetPropertyIsImportant(declarations: Ra
}
#[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]
pub extern "C" fn Servo_DeclarationBlock_RemoveProperty(declarations: RawServoDeclarationBlockBorrowed,
property: *mut nsIAtom, is_custom: bool) {
let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);