Skip to content

Commit

Permalink
Add Servo_RestyleSubtree.
Browse files Browse the repository at this point in the history
  • Loading branch information
heycam committed May 25, 2016
1 parent a04e30d commit bbc89a2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
2 changes: 2 additions & 0 deletions ports/geckolib/gecko_bindings/bindings.rs
Expand Up @@ -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)
Expand Down
27 changes: 20 additions & 7 deletions ports/geckolib/glue.rs
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit bbc89a2

Please sign in to comment.