Make Servo_TraverseSubtree return whether it did any work.
draft
Make Servo_TraverseSubtree return whether it did any work.
MozReview-Commit-ID: 8EWxdt0pZ6W
--- a/servo/components/style/gecko_bindings/bindings.rs
+++ b/servo/components/style/gecko_bindings/bindings.rs
@@ -1372,17 +1372,17 @@ extern "C" {
pub fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
pseudo_tag: *mut nsIAtom,
set: RawServoStyleSetBorrowed)
-> ServoComputedValuesStrong;
}
extern "C" {
pub fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
set: RawServoStyleSetBorrowed,
- root_behavior: TraversalRootBehavior);
+ root_behavior: TraversalRootBehavior) -> bool;
}
extern "C" {
pub fn Servo_AssertTreeIsClean(root: RawGeckoElementBorrowed);
}
extern "C" {
pub fn Servo_GetStyleFont(computed_values:
ServoComputedValuesBorrowedOrNull)
-> *const nsStyleFont;
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -144,24 +144,29 @@ fn traverse_subtree(element: GeckoElemen
if per_doc_data.num_threads == 1 || per_doc_data.work_queue.is_none() {
sequential::traverse_dom(&traversal, element, token);
} else {
parallel::traverse_dom(&traversal, element, known_depth, token,
per_doc_data.work_queue.as_mut().unwrap());
}
}
+/// Traverses the subtree rooted at `root` for restyling. Returns whether a
+/// Gecko post-traversal (to perform lazy frame construction, or consume any
+/// RestyleData, or drop any ElementData) is required.
#[no_mangle]
pub extern "C" fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
raw_data: RawServoStyleSetBorrowed,
- behavior: structs::TraversalRootBehavior) -> () {
+ behavior: structs::TraversalRootBehavior) -> bool {
let element = GeckoElement(root);
debug!("Servo_TraverseSubtree: {:?}", element);
traverse_subtree(element, raw_data,
behavior == structs::TraversalRootBehavior::UnstyledChildrenOnly);
+
+ element.has_dirty_descendants() || element.mutate_data().unwrap().has_restyle()
}
/// Takes a ServoAnimationValues and populates it with the animation values corresponding
/// to a given property declaration block
#[no_mangle]
pub extern "C" fn Servo_AnimationValues_Populate(anim: RawGeckoAnimationValueListBorrowedMut,
declarations: RawServoDeclarationBlockBorrowed,
style: ServoComputedValuesBorrowed,