diff --git a/servo/ports/geckolib/gecko_bindings/bindings.rs b/servo/ports/geckolib/gecko_bindings/bindings.rs index 425fa65ea123..c3a29f948859 100644 --- a/servo/ports/geckolib/gecko_bindings/bindings.rs +++ b/servo/ports/geckolib/gecko_bindings/bindings.rs @@ -223,6 +223,8 @@ extern "C" { pub fn Servo_Initialize(); pub fn Servo_RestyleDocument(doc: *mut RawGeckoDocument, set: *mut RawServoStyleSet); + pub fn Servo_RestyleSubtree(node: *mut RawGeckoNode, + set: *mut RawServoStyleSet); pub fn Gecko_GetAttrAsUTF8(element: *mut RawGeckoElement, ns: *mut nsIAtom, name: *mut nsIAtom, length: *mut u32) diff --git a/servo/ports/geckolib/glue.rs b/servo/ports/geckolib/glue.rs index 578fb5a1a770..b5ca86c4301e 100644 --- a/servo/ports/geckolib/glue.rs +++ b/servo/ports/geckolib/glue.rs @@ -73,13 +73,9 @@ pub extern "C" fn Servo_Initialize() -> () { env_logger::init().unwrap(); } -#[no_mangle] -pub extern "C" fn Servo_RestyleDocument(doc: *mut RawGeckoDocument, raw_data: *mut RawServoStyleSet) -> () { - let document = unsafe { GeckoDocument::from_raw(doc) }; - let node = match document.root_node() { - Some(x) => x, - None => return, - }; +fn restyle_subtree(node: GeckoNode, raw_data: *mut RawServoStyleSet) { + debug_assert!(node.is_element() || node.is_text_node()); + let data = unsafe { &mut *(raw_data as *mut PerDocumentStyleData) }; // Force the creation of our lazily-constructed initial computed values on @@ -112,6 +108,23 @@ pub extern "C" fn Servo_RestyleDocument(doc: *mut RawGeckoDocument, raw_data: *m } } +#[no_mangle] +pub extern "C" fn Servo_RestyleSubtree(node: *mut RawGeckoNode, + raw_data: *mut RawServoStyleSet) -> () { + let node = unsafe { GeckoNode::from_raw(node) }; + restyle_subtree(node, raw_data); +} + +#[no_mangle] +pub extern "C" fn Servo_RestyleDocument(doc: *mut RawGeckoDocument, raw_data: *mut RawServoStyleSet) -> () { + let document = unsafe { GeckoDocument::from_raw(doc) }; + let node = match document.root_node() { + Some(x) => x, + None => return, + }; + restyle_subtree(node, raw_data); +} + #[no_mangle] pub extern "C" fn Servo_DropNodeData(data: *mut ServoNodeData) -> () { unsafe {